@starasia/dropdown 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.
@@ -0,0 +1,436 @@
1
+ (function(B,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],l):(B=typeof globalThis<"u"?globalThis:B||self,l(B.Dropdown={},B.React))})(this,function(B,l){"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 hr;function Yr(){if(hr)return J;hr=1;var u=l,f=Symbol.for("react.element"),m=Symbol.for("react.fragment"),x=Object.prototype.hasOwnProperty,p=u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,h={key:!0,ref:!0,__self:!0,__source:!0};function T(y,v,F){var k,O={},A=null,W=null;F!==void 0&&(A=""+F),v.key!==void 0&&(A=""+v.key),v.ref!==void 0&&(W=v.ref);for(k in v)x.call(v,k)&&!h.hasOwnProperty(k)&&(O[k]=v[k]);if(y&&y.defaultProps)for(k in v=y.defaultProps,v)O[k]===void 0&&(O[k]=v[k]);return{$$typeof:f,type:y,key:A,ref:W,props:O,_owner:p.current}}return J.Fragment=m,J.jsx=T,J.jsxs=T,J}var H={};/**
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 Mr(){return wr||(wr=1,process.env.NODE_ENV!=="production"&&function(){var u=l,f=Symbol.for("react.element"),m=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),T=Symbol.for("react.provider"),y=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),W=Symbol.for("react.offscreen"),D=Symbol.iterator,o="@@iterator";function z(r){if(r===null||typeof r!="object")return null;var n=D&&r[D]||r[o];return typeof n=="function"?n:null}var P=u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(r){{for(var n=arguments.length,e=new Array(n>1?n-1:0),a=1;a<n;a++)e[a-1]=arguments[a];L("error",r,e)}}function L(r,n,e){{var a=P.ReactDebugCurrentFrame,d=a.getStackAddendum();d!==""&&(n+="%s",e=e.concat([d]));var c=e.map(function(s){return String(s)});c.unshift("Warning: "+n),Function.prototype.apply.call(console[r],console,c)}}var K=!1,G=!1,Q=!1,or=!1,$=!1,q;q=Symbol.for("react.module.reference");function N(r){return!!(typeof r=="string"||typeof r=="function"||r===x||r===h||$||r===p||r===F||r===k||or||r===W||K||G||Q||typeof r=="object"&&r!==null&&(r.$$typeof===A||r.$$typeof===O||r.$$typeof===T||r.$$typeof===y||r.$$typeof===v||r.$$typeof===q||r.getModuleId!==void 0))}function j(r,n,e){var a=r.displayName;if(a)return a;var d=n.displayName||n.name||"";return d!==""?e+"("+d+")":e}function E(r){return r.displayName||"Context"}function C(r){if(r==null)return null;if(typeof r.tag=="number"&&w("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 m:return"Portal";case h:return"Profiler";case p:return"StrictMode";case F:return"Suspense";case k:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case y:var n=r;return E(n)+".Consumer";case T:var e=r;return E(e._context)+".Provider";case v:return j(r,r.render,"ForwardRef");case O:var a=r.displayName||null;return a!==null?a:C(r.type)||"Memo";case A:{var d=r,c=d._payload,s=d._init;try{return C(s(c))}catch{return null}}}return null}var R=Object.assign,Y=0,xr,mr,yr,kr,Er,Rr,jr;function _r(){}_r.__reactDisabledLog=!0;function $r(){{if(Y===0){xr=console.log,mr=console.info,yr=console.warn,kr=console.error,Er=console.group,Rr=console.groupCollapsed,jr=console.groupEnd;var r={configurable:!0,enumerable:!0,value:_r,writable:!0};Object.defineProperties(console,{info:r,log:r,warn:r,error:r,group:r,groupCollapsed:r,groupEnd:r})}Y++}}function qr(){{if(Y--,Y===0){var r={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:R({},r,{value:xr}),info:R({},r,{value:mr}),warn:R({},r,{value:yr}),error:R({},r,{value:kr}),group:R({},r,{value:Er}),groupCollapsed:R({},r,{value:Rr}),groupEnd:R({},r,{value:jr})})}Y<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ir=P.ReactCurrentDispatcher,sr;function rr(r,n,e){{if(sr===void 0)try{throw Error()}catch(d){var a=d.stack.trim().match(/\n( *(at )?)/);sr=a&&a[1]||""}return`
18
+ `+sr+r}}var dr=!1,nr;{var rn=typeof WeakMap=="function"?WeakMap:Map;nr=new rn}function Cr(r,n){if(!r||dr)return"";{var e=nr.get(r);if(e!==void 0)return e}var a;dr=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var c;c=ir.current,ir.current=null,$r();try{if(n){var s=function(){throw Error()};if(Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(S){a=S}Reflect.construct(r,[],s)}else{try{s.call()}catch(S){a=S}r.call(s.prototype)}}else{try{throw Error()}catch(S){a=S}r()}}catch(S){if(S&&a&&typeof S.stack=="string"){for(var i=S.stack.split(`
19
+ `),_=a.stack.split(`
20
+ `),g=i.length-1,b=_.length-1;g>=1&&b>=0&&i[g]!==_[b];)b--;for(;g>=1&&b>=0;g--,b--)if(i[g]!==_[b]){if(g!==1||b!==1)do if(g--,b--,b<0||i[g]!==_[b]){var I=`
21
+ `+i[g].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(g>=1&&b>=0);break}}}finally{dr=!1,ir.current=c,qr(),Error.prepareStackTrace=d}var U=r?r.displayName||r.name:"",M=U?rr(U):"";return typeof r=="function"&&nr.set(r,M),M}function nn(r,n,e){return Cr(r,!1)}function en(r){var n=r.prototype;return!!(n&&n.isReactComponent)}function er(r,n,e){if(r==null)return"";if(typeof r=="function")return Cr(r,en(r));if(typeof r=="string")return rr(r);switch(r){case F:return rr("Suspense");case k:return rr("SuspenseList")}if(typeof r=="object")switch(r.$$typeof){case v:return nn(r.render);case O:return er(r.type,n,e);case A:{var a=r,d=a._payload,c=a._init;try{return er(c(d),n,e)}catch{}}}return""}var X=Object.prototype.hasOwnProperty,Sr={},Tr=P.ReactDebugCurrentFrame;function ar(r){if(r){var n=r._owner,e=er(r.type,r._source,n?n.type:null);Tr.setExtraStackFrame(e)}else Tr.setExtraStackFrame(null)}function an(r,n,e,a,d){{var c=Function.call.bind(X);for(var s in r)if(c(r,s)){var i=void 0;try{if(typeof r[s]!="function"){var _=Error((a||"React class")+": "+e+" type `"+s+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof r[s]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw _.name="Invariant Violation",_}i=r[s](n,s,a,e,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(g){i=g}i&&!(i instanceof Error)&&(ar(d),w("%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).",a||"React class",e,s,typeof i),ar(null)),i instanceof Error&&!(i.message in Sr)&&(Sr[i.message]=!0,ar(d),w("Failed %s type: %s",e,i.message),ar(null))}}}var tn=Array.isArray;function cr(r){return tn(r)}function on(r){{var n=typeof Symbol=="function"&&Symbol.toStringTag,e=n&&r[Symbol.toStringTag]||r.constructor.name||"Object";return e}}function sn(r){try{return Or(r),!1}catch{return!0}}function Or(r){return""+r}function Pr(r){if(sn(r))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",on(r)),Or(r)}var Z=P.ReactCurrentOwner,dn={key:!0,ref:!0,__self:!0,__source:!0},Ir,Dr,lr;lr={};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 ln(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 un(r,n){if(typeof r.ref=="string"&&Z.current&&n&&Z.current.stateNode!==n){var e=C(Z.current.type);lr[e]||(w('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',C(Z.current.type),r.ref),lr[e]=!0)}}function pn(r,n){{var e=function(){Ir||(Ir=!0,w("%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))};e.isReactWarning=!0,Object.defineProperty(r,"key",{get:e,configurable:!0})}}function fn(r,n){{var e=function(){Dr||(Dr=!0,w("%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))};e.isReactWarning=!0,Object.defineProperty(r,"ref",{get:e,configurable:!0})}}var vn=function(r,n,e,a,d,c,s){var i={$$typeof:f,type:r,key:n,ref:e,props:s,_owner:c};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:a}),Object.defineProperty(i,"_source",{configurable:!1,enumerable:!1,writable:!1,value:d}),Object.freeze&&(Object.freeze(i.props),Object.freeze(i)),i};function hn(r,n,e,a,d){{var c,s={},i=null,_=null;e!==void 0&&(Pr(e),i=""+e),ln(n)&&(Pr(n.key),i=""+n.key),cn(n)&&(_=n.ref,un(n,d));for(c in n)X.call(n,c)&&!dn.hasOwnProperty(c)&&(s[c]=n[c]);if(r&&r.defaultProps){var g=r.defaultProps;for(c in g)s[c]===void 0&&(s[c]=g[c])}if(i||_){var b=typeof r=="function"?r.displayName||r.name||"Unknown":r;i&&pn(s,b),_&&fn(s,b)}return vn(r,i,_,d,a,Z.current,s)}}var ur=P.ReactCurrentOwner,Fr=P.ReactDebugCurrentFrame;function V(r){if(r){var n=r._owner,e=er(r.type,r._source,n?n.type:null);Fr.setExtraStackFrame(e)}else Fr.setExtraStackFrame(null)}var pr;pr=!1;function fr(r){return typeof r=="object"&&r!==null&&r.$$typeof===f}function Ar(){{if(ur.current){var r=C(ur.current.type);if(r)return`
22
+
23
+ Check the render method of \``+r+"`."}return""}}function wn(r){{if(r!==void 0){var n=r.fileName.replace(/^.*[\\\/]/,""),e=r.lineNumber;return`
24
+
25
+ Check your code at `+n+":"+e+"."}return""}}var Wr={};function gn(r){{var n=Ar();if(!n){var e=typeof r=="string"?r:r.displayName||r.name;e&&(n=`
26
+
27
+ Check the top-level render call using <`+e+">.")}return n}}function Lr(r,n){{if(!r._store||r._store.validated||r.key!=null)return;r._store.validated=!0;var e=gn(n);if(Wr[e])return;Wr[e]=!0;var a="";r&&r._owner&&r._owner!==ur.current&&(a=" It was passed a child from "+C(r._owner.type)+"."),V(r),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',e,a),V(null)}}function zr(r,n){{if(typeof r!="object")return;if(cr(r))for(var e=0;e<r.length;e++){var a=r[e];fr(a)&&Lr(a,n)}else if(fr(r))r._store&&(r._store.validated=!0);else if(r){var d=z(r);if(typeof d=="function"&&d!==r.entries)for(var c=d.call(r),s;!(s=c.next()).done;)fr(s.value)&&Lr(s.value,n)}}}function bn(r){{var n=r.type;if(n==null||typeof n=="string")return;var e;if(typeof n=="function")e=n.propTypes;else if(typeof n=="object"&&(n.$$typeof===v||n.$$typeof===O))e=n.propTypes;else return;if(e){var a=C(n);an(e,r.props,"prop",a,r)}else if(n.PropTypes!==void 0&&!pr){pr=!0;var d=C(n);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",d||"Unknown")}typeof n.getDefaultProps=="function"&&!n.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function xn(r){{for(var n=Object.keys(r.props),e=0;e<n.length;e++){var a=n[e];if(a!=="children"&&a!=="key"){V(r),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",a),V(null);break}}r.ref!==null&&(V(r),w("Invalid attribute `ref` supplied to `React.Fragment`."),V(null))}}var Nr={};function Br(r,n,e,a,d,c){{var s=N(r);if(!s){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 _=wn(d);_?i+=_:i+=Ar();var g;r===null?g="null":cr(r)?g="array":r!==void 0&&r.$$typeof===f?(g="<"+(C(r.type)||"Unknown")+" />",i=" Did you accidentally export a JSX literal instead of a component?"):g=typeof r,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",g,i)}var b=hn(r,n,e,d,c);if(b==null)return b;if(s){var I=n.children;if(I!==void 0)if(a)if(cr(I)){for(var U=0;U<I.length;U++)zr(I[U],r);Object.freeze&&Object.freeze(I)}else w("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 M=C(r),S=Object.keys(n).filter(function(jn){return jn!=="key"}),vr=S.length>0?"{key: someKey, "+S.join(": ..., ")+": ...}":"{key: someKey}";if(!Nr[M+vr]){var Rn=S.length>0?"{"+S.join(": ..., ")+": ...}":"{}";w(`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} />`,vr,M,Rn,M),Nr[M+vr]=!0}}return r===x?xn(b):bn(b),b}}function mn(r,n,e){return Br(r,n,e,!0)}function yn(r,n,e){return Br(r,n,e,!1)}var kn=yn,En=mn;H.Fragment=x,H.jsx=kn,H.jsxs=En}()),H}process.env.NODE_ENV==="production"?tr.exports=Yr():tr.exports=Mr();var t=tr.exports;const Vr=`@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
33
+ * {
34
+ margin: 0;
35
+ padding: 0;
36
+ font-family: "Poppins", sans-serif;
37
+ box-sizing: border-box;
38
+ }
39
+ :root {
40
+ /* color */
41
+ /* blue */
42
+ --starasia-ui-dropdown-color-primary-blue: var(
43
+ --starasia-ui-color-blue-700,
44
+ #1d4ed8
45
+ );
46
+ --starasia-ui-dropdown-color-secondary-blue: var(
47
+ --starasia-ui-color-blue-500,
48
+ #3b82f6
49
+ );
50
+ --starasia-ui-dropdown-color-tertiary-blue: var(
51
+ --starasia-ui-color-blue-300,
52
+ #93c5fd
53
+ );
54
+ --starasia-ui-dropdown-color-quaternary-blue: var(
55
+ --starasia-ui-color-blue-100,
56
+ #dbeafe
57
+ );
58
+ --starasia-ui-dropdown-color-quinary-blue: var(
59
+ --starasia-ui-color-blue-50,
60
+ #eff6ff
61
+ );
62
+ /* gray */
63
+ --starasia-ui-dropdown-color-primary-gray: var(
64
+ --starasia-ui-color-gray-700,
65
+ #374151
66
+ );
67
+ --starasia-ui-dropdown-color-secondary-gray: var(
68
+ --starasia-ui-color-gray-500,
69
+ #6b7280
70
+ );
71
+ --starasia-ui-dropdown-color-tertiary-gray: var(
72
+ --starasia-ui-color-gray-300,
73
+ #d1d5db
74
+ );
75
+ --starasia-ui-dropdown-color-quaternary-gray: var(
76
+ --starasia-ui-color-gray-100,
77
+ #f3f4f6
78
+ );
79
+ --starasia-ui-dropdown-color-quinary-gray: var(
80
+ --starasia-ui-color-gray-50,
81
+ #f9fafb
82
+ );
83
+ /* bg color */
84
+ --starasia-ui-dropdown-background-color-primary: var(
85
+ --starasia-ui-dropdown-color-secondary-blue,
86
+ #3b82f6
87
+ );
88
+ --starasia-ui-dropdown-background-color-secondary: var(
89
+ --starasia-ui-dropdown-color-quinary-blue,
90
+ #eff6ff
91
+ );
92
+
93
+ /* disalble color */
94
+ --starasia-ui-dropdown-color-disable: var(
95
+ --starasia-ui-dropdown-color-tertiary-gray,
96
+ #d1d5db
97
+ );
98
+
99
+ /* border color */
100
+ --starasia-ui-dropdown-border-color-primary: var(
101
+ --starasia-ui-color-blue-500,
102
+ #3b82f6
103
+ );
104
+ --starasia-ui-dropdown-border-color-secondary: var(
105
+ --starasia-ui-color-gray-300,
106
+ #d1d5db
107
+ );
108
+ --starasia-ui-dropdown-border-color-tertiary: rgba(120, 134, 127, 0.2);
109
+
110
+ --starasia-ui-dropdown-color-secondary-red: var(
111
+ --starasia-ui-color-red-500,
112
+ #ef4444
113
+ );
114
+
115
+ /* plachoder color */
116
+ --starasia-ui-dropdown-placholder-color: var(
117
+ --starasia-ui-color-gray-200,
118
+ #c9cecc
119
+ );
120
+
121
+ /* border width */
122
+ --starasia-ui-dropdown-border-width: var(--starasia-ui-border, 1px);
123
+
124
+ /* spacing */
125
+ --starasia-ui-dropdown-spacing-xs: var(--starasia-ui-spacing-xs, 4px);
126
+ --starasia-ui-dropdown-spacing-sm: var(--starasia-ui-spacing-sm, 8px);
127
+
128
+ /* shadow */
129
+ --starasia-ui-dropdown-box-shadow: 0px 0px 0px 2px rgba(100, 181, 246, 0.2);
130
+
131
+ /* below is for size,above is */
132
+ --starasia-ui-dropdown-fontWeight-normal: var(
133
+ --starasia-ui-fontWeights-normal,
134
+ 300
135
+ );
136
+ /* dropdown size sm */
137
+ --starasia-ui-dropdown-height-sm: var(--starasia-ui-h-8, 32px);
138
+ --starasia-ui-dropdown-border-radius-sm: var(--starasia-ui-radii-md, 8px);
139
+ --starasia-ui-dropdown-padding-inline-sm: var(--starasia-ui-spacing-sm, 8px);
140
+
141
+ /* dropdown size md */
142
+ --starasia-ui-dropdown-height-md: 38px;
143
+ --starasia-ui-dropdown-border-radius-md: var(--starasia-ui-radii-md, 8px);
144
+ --starasia-ui-dropdown-padding-inline-md: var(--starasia-ui-spacing-3, 12px);
145
+
146
+ /* dropdown size lg */
147
+ --starasia-ui-dropdown-height-lg: var(--starasia-ui-h-12, 48px);
148
+ --starasia-ui-dropdown-border-radius-lg: var(--starasia-ui-radii-lg, 12px);
149
+ --starasia-ui-dropdown-padding-inline-lg: var(--starasia-ui-spacing-3, 12px);
150
+ }
151
+
152
+ .starasia-input-dropdown-size-sm {
153
+ --baseFont: var(--starasia-ui-fontSizes-sm, 12px);
154
+ --height: var(--starasia-ui-dropdown-height-sm);
155
+ --borderRadius: var(--starasia-ui-dropdown-border-radius-sm);
156
+ --paddingInline: var(--starasia-ui-dropdown-padding-inline-sm);
157
+ }
158
+
159
+ .starasia-input-dropdown-size-md {
160
+ --baseFont: var(--starasia-ui-fontSizes-md, 14px);
161
+ --height: var(--starasia-ui-dropdown-height-md);
162
+ --borderRadius: var(--starasia-ui-dropdown-border-radius-md);
163
+ --paddingInline: var(--starasia-ui-dropdown-padding-inline-md);
164
+ }
165
+
166
+ .starasia-input-dropdown-size-lg {
167
+ --baseFont: var(--starasia-ui-fontSizes-lg, 16px);
168
+ --height: var(--starasia-ui-dropdown-height-lg);
169
+ --borderRadius: var(--starasia-ui-dropdown-border-radius-lg);
170
+ --paddingInline: var(--starasia-ui-dropdown-padding-inline-lg);
171
+ }
172
+
173
+ .starasia-input-dropdown-container {
174
+ position: relative;
175
+ min-height: var(--height);
176
+ padding-inline: var(--paddingInline);
177
+ display: flex;
178
+ align-items: center;
179
+ border: var(--starasia-ui-dropdown-border-width) solid
180
+ rgba(120, 134, 127, 0.2);
181
+ border-radius: var(--borderRadius);
182
+ background-color: white;
183
+ font-size: var(--baseFont);
184
+ cursor: pointer;
185
+ }
186
+ .starasia-input-dropdown-container.disable {
187
+ background-color: #f2f3f2;
188
+ cursor: not-allowed;
189
+ pointer-events: none;
190
+ }
191
+
192
+ .starasia-input-dropdown-container.error {
193
+ border-color: var(--starasia-ui-dropdown-color-secondary-red) !important;
194
+ }
195
+ .starasia-input-dropdown-container.active {
196
+ border-color: var(--starasia-ui-dropdown-border-color-primary);
197
+ box-shadow: var(--starasia-ui-dropdown-box-shadow);
198
+ background-color: white;
199
+ }
200
+
201
+ .starasia-input-dropdown-preview-container {
202
+ display: flex;
203
+ flex-direction: row;
204
+ gap: var(--starasia-ui-dropdown-spacing-sm);
205
+ align-items: center;
206
+ justify-content: space-between;
207
+ width: 100%;
208
+ overflow-y: hidden;
209
+ }
210
+
211
+ .starasia-input-dropdown-lists-container {
212
+ /* position: absolute; */
213
+ position: fixed;
214
+ /* left: 0; */
215
+ padding: var(--starasia-ui-dropdown-spacing-sm);
216
+ border: var(--starasia-ui-dropdown-border-width) solid
217
+ var(--starasia-ui-dropdown-border-color-tertiary);
218
+ border-radius: var(--borderRadius);
219
+ background-color: #fffeff;
220
+ box-shadow: 0px 8px 12px 0px rgba(0, 0, 0, 0.08);
221
+ max-height: 312px;
222
+ overflow-y: auto;
223
+ z-index: 999;
224
+ width: 100%;
225
+ /* width: max-content; */
226
+ /* min-width: 100%; */
227
+ display: flex;
228
+ flex-direction: column;
229
+ gap: var(--starasia-ui-dropdown-spacing-sm);
230
+ /* overflow: hidden;
231
+ text-overflow: ellipsis;
232
+ white-space: nowrap; */
233
+ }
234
+
235
+ .starasia-input-dropdown-lists-container-bottom {
236
+ top: 100%;
237
+ margin-top: var(--starasia-ui-dropdown-spacing-xs);
238
+ }
239
+ .starasia-input-dropdown-lists-container-top {
240
+ bottom: 100%;
241
+ margin-bottom: var(--starasia-ui-dropdown-spacing-xs);
242
+ }
243
+
244
+ .starasia-input-dropdown-container-dropdown-search {
245
+ display: flex;
246
+ align-items: center;
247
+ height: var(--height);
248
+ min-height: var(--height);
249
+ max-height: var(--height);
250
+ border: var(--starasia-ui-dropdown-border-width) solid
251
+ var(--starasia-ui-dropdown-border-color-secondary);
252
+ border-radius: var(--borderRadius);
253
+ gap: var(--starasia-ui-dropdown-spacing-sm);
254
+ padding-inline: var(--paddingInline);
255
+ background: white;
256
+ & input {
257
+ flex: 1;
258
+ outline: none;
259
+ background-color: transparent;
260
+ border: none;
261
+ font-size: inherit;
262
+ }
263
+ }
264
+
265
+ .starasia-input-dropdwon-item-container {
266
+ display: flex;
267
+ flex-direction: column;
268
+ /* overflow: hidden; */
269
+
270
+ /* gap: var(--starasia-ui-dropdown-spacing-xs); */
271
+ }
272
+ .starasia-input-dropdwon-item-container.multi {
273
+ display: flex;
274
+ flex-direction: column;
275
+ gap: 8px;
276
+ /* overflow: hidden; */
277
+
278
+ /* gap: var(--starasia-ui-dropdown-spacing-xs); */
279
+ }
280
+
281
+ .starasia-input-dropdwon-item {
282
+ /* max-height: var(--height); */
283
+ max-height: 58px;
284
+ box-sizing: border-box;
285
+ padding-inline: var(--paddingInline);
286
+ display: flex;
287
+ align-items: center;
288
+ cursor: pointer;
289
+ gap: var(--starasia-ui-dropdown-spacing-xs);
290
+ padding-block: var(--paddingInline);
291
+ border-radius: var(--starasia-ui-dropdown-border-radius-sm);
292
+ /* min-width: max-content; */
293
+ overflow: hidden;
294
+ }
295
+
296
+ .starasia-input-dropdwon-item:hover {
297
+ background-color: rgba(100, 181, 246, 0.21);
298
+ }
299
+ .starasia-input-dropdwon-item.active {
300
+ /* color: var(--starasia-ui-dropdown-background-color-primary); */
301
+ /* border-radius: var(--borderRadius); */
302
+ background-color: rgba(100, 181, 246, 0.21);
303
+ /* background: var(--starasia-ui-dropdown-background-color-secondary); */
304
+ /* box-shadow: 0px 0px 0px -1px #f0f0f0; */
305
+ }
306
+
307
+ .starasia-input-dropdwon-item-disable {
308
+ color: var(--starasia-ui-dropdown-color-disable) !important;
309
+ pointer-events: none;
310
+ }
311
+
312
+ .starasia-input-dropdown-container-preview-item {
313
+ flex: 1;
314
+ display: flex;
315
+ gap: var(--starasia-ui-dropdown-spacing-xs);
316
+ flex-wrap: wrap;
317
+ align-items: center;
318
+ overflow-y: auto;
319
+ padding-block: 4px;
320
+ }
321
+
322
+ .starasia-input-dropdown-preview-item {
323
+ border: var(--starasia-ui-dropdown-border-width) solid
324
+ var(--starasia-ui-dropdown-border-color-primary);
325
+ padding-inline: var(--paddingInline);
326
+ border-radius: var(--borderRadius);
327
+ background-color: var(--starasia-ui-dropdown-background-color-secondary);
328
+ color: var(--starasia-ui-dropdown-background-color-primary);
329
+ height: max-content;
330
+ font-size: var(--baseFont);
331
+ display: flex;
332
+ align-items: center;
333
+ gap: 2;
334
+ }
335
+ .starasia-input-dropdown-placeholder {
336
+ color: var(--starasia-ui-dropdown-placholder-color);
337
+ font-weight: var(--starasia-ui-dropdown-fontWeight-normal);
338
+ }
339
+
340
+ .starasia-input-dropdwon-item-text {
341
+ color: #181a19;
342
+ /* font-size: 14px; */
343
+ font-size: inherit;
344
+ font-weight: 500;
345
+ }
346
+ .starasia-input-dropdwon-item-text.active {
347
+ color: #1976d2;
348
+ }
349
+
350
+ .starasia-input-dropdwon-item-text-description {
351
+ color: #78867f;
352
+ /* font-size: 14px; */
353
+ font-size: inherit;
354
+ font-weight: 400;
355
+ }
356
+ .starasia-input-dropdwon-item-text-description.active {
357
+ color: #1976d2;
358
+ }
359
+
360
+ /* for checkbox */
361
+ .checkbox-wrapper-30 .checkbox {
362
+ --bg: #fff;
363
+ --brdr: #d1d6ee;
364
+ --brdr-actv: #1976d2;
365
+ --brdr-hovr: #bbc1e1;
366
+ --dur: calc((var(--size, 2) / 2) * 0.6s);
367
+ display: inline-block;
368
+ /* width: calc(var(--size, 1) * 22px); */
369
+ width: 16px;
370
+ height: 16px;
371
+ position: relative;
372
+ }
373
+ .checkbox-wrapper-30 .checkbox:after {
374
+ content: "";
375
+ width: 100%;
376
+ padding-top: 100%;
377
+ display: block;
378
+ }
379
+ .checkbox-wrapper-30 .checkbox > * {
380
+ position: absolute;
381
+ }
382
+ .checkbox-wrapper-30 .checkbox input {
383
+ -webkit-appearance: none;
384
+ -moz-appearance: none;
385
+ -webkit-tap-highlight-color: transparent;
386
+ cursor: pointer;
387
+ background-color: var(--newBgClr, var(--bg));
388
+ border-radius: calc(var(--size, 1) * 4px);
389
+ border: calc(var(--newBrdr, var(--size, 1)) * 1px) solid;
390
+ color: var(--newBrdrClr, var(--brdr));
391
+ outline: none;
392
+ margin: 0;
393
+ padding: 0;
394
+ transition: all calc(var(--dur) / 3) linear;
395
+ }
396
+ .checkbox-wrapper-30 .checkbox input:hover,
397
+ .checkbox-wrapper-30 .checkbox input:checked {
398
+ --newBrdr: calc(var(--size, 1) * 2);
399
+ }
400
+ .checkbox-wrapper-30 .checkbox input:hover {
401
+ --newBrdrClr: var(--brdr-hovr);
402
+ }
403
+ .checkbox-wrapper-30 .checkbox input:checked {
404
+ --newBrdrClr: var(--brdr-actv);
405
+ --newBgClr: var(--brdr-actv);
406
+ /* transition-delay: calc(var(--dur) / 1.3); */
407
+ }
408
+ .checkbox-wrapper-30 .checkbox input:checked + svg {
409
+ --dashArray: 16 93;
410
+ --dashOffset: 109;
411
+ }
412
+ .checkbox-wrapper-30 .checkbox input:checked + svg {
413
+ color: white;
414
+ /* transition-delay: calc(var(--dur) / 1.3); */
415
+ transition-delay: 0.1s;
416
+ }
417
+ .checkbox-wrapper-30 .checkbox svg {
418
+ fill: none;
419
+ left: 0;
420
+ pointer-events: none;
421
+ stroke: var(--stroke, var(--border-active));
422
+ stroke-dasharray: var(--dashArray, 93);
423
+ stroke-dashoffset: var(--dashOffset, 94);
424
+ stroke-linecap: round;
425
+ stroke-linejoin: round;
426
+ stroke-width: 2px;
427
+ top: 0;
428
+ transition: stroke-dasharray var(--dur), stroke-dashoffset var(--dur);
429
+ }
430
+ .checkbox-wrapper-30 .checkbox svg,
431
+ .checkbox-wrapper-30 .checkbox input {
432
+ display: block;
433
+ height: 100%;
434
+ width: 100%;
435
+ }
436
+ `;function Ur(u){const[f,m]=l.useState(u),x=l.useRef(null),p=h=>{x.current&&!x.current.contains(h.target)&&m(!1)};return l.useEffect(()=>(document.addEventListener("click",p,!0),()=>{document.removeEventListener("click",p,!0)}),[]),{ref:x,isComponentVisible:f,setIsComponentVisible:m}}const Jr=({...u})=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",...u,viewBox:"0 0 24 24",fill:"none",color:"#939E99",children:t.jsx("path",{d:"M4 9L12 17L20 9",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5})}),Hr=({...u})=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",...u,viewBox:"0 0 20 20",fill:"none",children:[t.jsx("circle",{cx:"9.80547",cy:"9.8055",r:"7.49047",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M15.0153 15.4043L17.9519 18.3333",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})]}),Kr=({isChecked:u})=>t.jsxs("div",{className:"checkbox-wrapper-30",children:[t.jsxs("span",{className:"checkbox",children:[t.jsx("input",{type:"checkbox",style:{pointerEvents:"none"},checked:u}),t.jsx("svg",{children:t.jsx("use",{xlinkHref:"#checkbox-30",className:"checkbox"})})]}),t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",style:{display:"none"},children:t.jsx("symbol",{id:"checkbox-30",viewBox:"0 0 22 22",children:t.jsx("path",{fill:"none",stroke:"currentColor",d:"M5.5,11.3L9,14.8L20.2,3.3l0,0c-0.5-1-1.5-1.8-2.7-1.8h-13c-1.7,0-3,1.3-3,3v13c0,1.7,1.3,3,3,3h13 c1.7,0,3-1.3,3-3v-13c0-0.4-0.1-0.8-0.3-1.2"})})})]}),Gr=l.forwardRef(({positionDropdown:u,dropdownLists:f,isComponentVisible:m,searchAble:x,onSearch:p,value:h,handleChangeValue:T,multiSelect:y,searchValue:v},F)=>{const[k,O]=l.useState(0),[A,W]=l.useState(),D=l.useRef(null);return l.useEffect(()=>{if(D.current){const o=D.current.getBoundingClientRect();O(o.width)}},[D,m]),l.useEffect(()=>{f&&v?f.forEach(o=>{if(o.label.startsWith(v||"")){W(o.value);return}}):W(void 0)},[v,f]),t.jsx(t.Fragment,{children:m?t.jsxs("div",{className:"starasia-input-dropdown-lists-container",onClick:o=>o.stopPropagation(),ref:F,children:[x?t.jsxs("div",{className:"starasia-input-dropdown-container-dropdown-search",style:{order:u=="bottom"?0:2,position:"sticky",top:0,bottom:0,zIndex:1},children:[t.jsx("div",{style:{display:"flex"},children:t.jsx(Hr,{strokeWidth:2,width:20})}),t.jsx("input",{onChange:o=>{p&&p(o.target.value)},value:v,autoFocus:!0,style:{width:"100%"}})]}):null,t.jsx("div",{className:`starasia-input-dropdwon-item-container ${y?"multi":""}`,ref:D,children:f.map((o,z)=>{const P=!!(h!=null&&h.find(w=>w.value===o.value));return t.jsxs("div",{className:`starasia-input-dropdwon-item ${P?"active":" "} ${o.disable?"starasia-input-dropdwon-item-disable":null}`,onClick:()=>T(o.label,o.value),children:[y?t.jsx("div",{style:{marginRight:"8px"},children:t.jsx(Kr,{isChecked:P})}):null,o.icon?t.jsx("div",{children:l.cloneElement(o.icon,{width:16})}):null,t.jsxs("div",{children:[t.jsx("p",{className:`starasia-input-dropdwon-item-text ${P?"active":null} ${o.disable?"starasia-input-dropdwon-item-disable":null}`,style:{textWrap:"nowrap",width:`${k-12}px`,overflow:"hidden",textOverflow:"ellipsis"},children:o.label}),o.description?t.jsx("p",{className:`starasia-input-dropdwon-item-text-description ${P?"active":null} ${o.disable?"starasia-input-dropdwon-item-disable":null}`,style:{textWrap:"nowrap",width:`${k-12}px`,overflow:"hidden",textOverflow:"ellipsis"},children:o.description}):null]})]},z)})})]}):null})}),Xr=({children:u,handleChangePosition:f})=>{const m=l.useRef(null);l.useEffect(()=>{var T;const p=()=>{if(m.current){let y=m.current.parentElement;for(;y&&!x(y);)y=y.parentElement;y&&f()}};let h=(T=m.current)==null?void 0:T.parentElement;for(;h&&!x(h);)h=h.parentElement;return h&&h.addEventListener("scroll",p),p(),()=>{h&&h.removeEventListener("scroll",p)}},[]);const x=p=>p&&(p.scrollHeight>p.clientHeight||p.scrollWidth>p.clientWidth);return t.jsx("div",{ref:m,children:u})},gr="starasia-input-dropdown-styles";(u=>{if(!document.getElementById(gr)){const f=document.createElement("style");f.id=gr,f.textContent=u,document.head.appendChild(f)}})(Vr);const Zr=({dropdownLists:u,onChange:f,defaultValue:m,size:x="md",multiSelect:p,searchAble:h,iconLeft:T,placeholder:y,onSearch:v,error:F,onBlur:k,onFocus:O,disable:A,searchValue:W})=>{const D=l.useRef(),[o,z]=l.useState([]),[P,w]=l.useState(""),L=l.useRef(null),{isComponentVisible:K,ref:G,setIsComponentVisible:Q}=Ur(!1),or=()=>{Q(j=>!j)},$=(j,E)=>{if(!p)z([{label:j,value:E}]),f([{label:j,value:E}]),Q(!1);else if(o==null?void 0:o.find(R=>R.value===E)){const R=[...o?o.filter(Y=>Y.value!==E):[]];z(R),f(R)}else{const R=[...o||[],{label:j,value:E}];z(R),f(R)}};l.useEffect(()=>{JSON.stringify(D.current)===JSON.stringify(m)||(D.current=m,z(D.current||[]))},[m]);const q=()=>o.length?p?o==null?void 0:o.map((j,E)=>t.jsxs("div",{className:"starasia-input-dropdown-preview-item",children:[t.jsx("p",{style:{minWidth:"max-content"},children:j==null?void 0:j.label},E),t.jsx(Qr,{onClick:()=>$(j.label,j.value)})]})):t.jsx("p",{style:{minWidth:"max-content"},children:o==null?void 0:o[0].label}):t.jsx("p",{className:"starasia-input-dropdown-placeholder",children:y}),N=()=>{if(G.current&&L.current){const j=window.innerHeight,E=G.current.getBoundingClientRect(),C=L.current.getBoundingClientRect(),R=E.bottom+C.height;L.current.style.left=`${E.left}px`,L.current.style.width=`${E.width}px`,R>=j-10?(L.current.style.top=`${E.top-C.height-5}px`,w("top")):(L.current.style.top=`${E.top+E.height}px`,w("bottom"))}};return l.useEffect(()=>(window.addEventListener("scroll",N),window.addEventListener("resize",N),()=>{window.removeEventListener("scroll",N),window.removeEventListener("resize",N)}),[]),l.useEffect(()=>{N()},[K]),t.jsx(Xr,{handleChangePosition:N,children:t.jsxs("div",{className:`starasia-input-dropdown-container ${A?"disable":""} starasia-input-dropdown-size-${x} ${K?"active":""} ${F?"error":""}`,ref:G,onClick:or,children:[t.jsxs("div",{className:"starasia-input-dropdown-preview-container",children:[T?t.jsx(t.Fragment,{children:l.cloneElement(T,{width:br(x),color:"#939E99",style:{color:"#939E99"}})}):null,t.jsx("div",{className:"starasia-input-dropdown-container-preview-item",tabIndex:100,onBlur:k,onFocus:O,children:q()}),t.jsx(Jr,{strokeWidth:2,width:br(x),style:{color:"#939E99"}})]}),t.jsx(Gr,{dropdownLists:u,handleChangeValue:$,isComponentVisible:K,positionDropdown:P,searchAble:!!h,value:o,onSearch:v,ref:L,multiSelect:p,searchValue:W})]})})},br=u=>{if(u==="sm")return 16;if(u==="md")return 16;if(u==="lg")return 20},Qr=u=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",...u,children:t.jsx("path",{d:"M12 6L6 12M6.00001 6L12 12",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})});B.Dropdown=Zr,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,2 @@
1
+ export { Dropdown } from "./Dropdown";
2
+ export * from "./interface";
@@ -0,0 +1,31 @@
1
+ export interface IconPropsDropdown extends React.SVGProps<SVGSVGElement> {
2
+ }
3
+ export interface IDropdown {
4
+ onChange: (props: {
5
+ label: string;
6
+ value: string;
7
+ }[]) => void;
8
+ dropdownLists: {
9
+ icon?: React.ReactElement<IconPropsDropdown>;
10
+ label: string;
11
+ value: string;
12
+ disable?: boolean;
13
+ description?: string;
14
+ }[];
15
+ defaultValue?: {
16
+ label: string;
17
+ value: string;
18
+ }[];
19
+ size?: "sm" | "md" | "lg";
20
+ error?: boolean;
21
+ multiSelect?: boolean;
22
+ searchAble?: boolean;
23
+ iconLeft?: React.ReactElement<IconPropsDropdown>;
24
+ placeholder?: string;
25
+ onSearch?: (e: string) => void;
26
+ position?: "top" | "bottom";
27
+ onBlur?: (e: React.FocusEvent<HTMLDivElement, Element>) => void;
28
+ onFocus?: (e: React.FocusEvent<HTMLDivElement, Element>) => void;
29
+ disable?: boolean;
30
+ searchValue?: string;
31
+ }
@@ -0,0 +1,5 @@
1
+ export declare function useComponentVisible(initialIsVisible: boolean): {
2
+ ref: import("react").MutableRefObject<any>;
3
+ isComponentVisible: boolean;
4
+ setIsComponentVisible: import("react").Dispatch<import("react").SetStateAction<boolean>>;
5
+ };
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@starasia/dropdown",
3
+ "version": "1.0.0",
4
+ "description": "dropdown component for starasia UI",
5
+ "author": "Prawito Hudoro",
6
+ "main": "dist/dropdown.umd.js",
7
+ "module": "dist/dropdown.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
+ }