react-select-rohit10 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 ADDED
@@ -0,0 +1,16 @@
1
+ # React + Vite
2
+
3
+ This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
+
5
+ Currently, two official plugins are available:
6
+
7
+ - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8
+ - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
+
10
+ ## React Compiler
11
+
12
+ The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
13
+
14
+ ## Expanding the ESLint configuration
15
+
16
+ If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project.
package/dist/index.cjs ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";const m=require("react");var H={exports:{}},D={};var K;function ne(){if(K)return D;K=1;var o=Symbol.for("react.transitional.element"),R=Symbol.for("react.fragment");function p(_,c,f){var E=null;if(f!==void 0&&(E=""+f),c.key!==void 0&&(E=""+c.key),"key"in c){f={};for(var h in c)h!=="key"&&(f[h]=c[h])}else f=c;return c=f.ref,{$$typeof:o,type:_,key:E,ref:c!==void 0?c:null,props:f}}return D.Fragment=R,D.jsx=p,D.jsxs=p,D}var Y={};var ee;function ae(){return ee||(ee=1,process.env.NODE_ENV!=="production"&&(function(){function o(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===W?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case u:return"Fragment";case y:return"Profiler";case k:return"StrictMode";case B:return"Suspense";case L:return"SuspenseList";case Z:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case g:return"Portal";case F:return e.displayName||"Context";case S:return(e._context.displayName||"Context")+".Consumer";case A:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return r=e.displayName||null,r!==null?r:o(e.type)||"Memo";case P:r=e._payload,e=e._init;try{return o(e(r))}catch{}}return null}function R(e){return""+e}function p(e){try{R(e);var r=!1}catch{r=!0}if(r){r=console;var n=r.error,a=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",a),R(e)}}function _(e){if(e===u)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===P)return"<...>";try{var r=o(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function c(){var e=x.A;return e===null?null:e.getOwner()}function f(){return Error("react-stack-top-frame")}function E(e){if(U.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function h(e,r){function n(){M||(M=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}function i(){var e=o(this.type);return z[e]||(z[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function Q(e,r,n,a,w,C){var s=n.ref;return e={$$typeof:I,type:e,key:r,props:n,_owner:a},(s!==void 0?s:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:i}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:w}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:C}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function O(e,r,n,a,w,C){var s=r.children;if(s!==void 0)if(a)if(q(s)){for(a=0;a<s.length;a++)$(s[a]);Object.freeze&&Object.freeze(s)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else $(s);if(U.call(r,"key")){s=o(e);var v=Object.keys(r).filter(function(l){return l!=="key"});a=0<v.length?"{key: someKey, "+v.join(": ..., ")+": ...}":"{key: someKey}",X[s+a]||(v=0<v.length?"{"+v.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
+ let props = %s;
3
+ <%s {...props} />
4
+ React keys must be passed directly to JSX without using spread:
5
+ let props = %s;
6
+ <%s key={someKey} {...props} />`,a,s,v,s),X[s+a]=!0)}if(s=null,n!==void 0&&(p(n),s=""+n),E(r)&&(p(r.key),s=""+r.key),"key"in r){n={};for(var t in r)t!=="key"&&(n[t]=r[t])}else n=r;return s&&h(n,typeof e=="function"?e.displayName||e.name||"Unknown":e),Q(e,s,n,c(),w,C)}function $(e){N(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===P&&(e._payload.status==="fulfilled"?N(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function N(e){return typeof e=="object"&&e!==null&&e.$$typeof===I}var T=m,I=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),u=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),F=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),L=Symbol.for("react.suspense_list"),V=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),Z=Symbol.for("react.activity"),W=Symbol.for("react.client.reference"),x=T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=Object.prototype.hasOwnProperty,q=Array.isArray,j=console.createTask?console.createTask:function(){return null};T={react_stack_bottom_frame:function(e){return e()}};var M,z={},J=T.react_stack_bottom_frame.bind(T,f)(),G=j(_(f)),X={};Y.Fragment=u,Y.jsx=function(e,r,n){var a=1e4>x.recentlyCreatedOwnerStacks++;return O(e,r,n,!1,a?Error("react-stack-top-frame"):J,a?j(_(e)):G)},Y.jsxs=function(e,r,n){var a=1e4>x.recentlyCreatedOwnerStacks++;return O(e,r,n,!0,a?Error("react-stack-top-frame"):J,a?j(_(e)):G)}})()),Y}var re;function se(){return re||(re=1,process.env.NODE_ENV==="production"?H.exports=ne():H.exports=ae()),H.exports}var d=se();function oe({event:o,open:R,options:p,highlightedIndex:_,setHighlightedIndex:c,onSelect:f,closeDropdown:E,userNavigatedRef:h}){if(R){if(o.key==="ArrowDown"&&(o.preventDefault(),h.current=!0,c(i=>Math.min(i+1,p.length-1))),o.key==="ArrowUp"&&(o.preventDefault(),h.current=!0,c(i=>Math.max(i-1,0))),o.key==="Enter"){o.preventDefault();const i=p[_];i&&f(i)}o.key==="Escape"&&E()}}function le({options:o=[],value:R,onChange:p,onClear:_,onSearch:c,onReachEnd:f,isLoading:E=!1,hasMoreOptions:h=!1,isMultipleAllowed:i=!0,placeholder:Q,renderOption:O,renderChipValue:$}){const N=R!==void 0,[T,I]=m.useState(i?[]:null),g=N?R:T;let u;i?Array.isArray(g)?u=g:u=[]:Array.isArray(g)?u=null:u=g??null;function k(t){N||I(t),p?.(t)}const[y,S]=m.useState(!1),[F,A]=m.useState(0),[B,L]=m.useState(""),V=m.useRef(null),P=m.useRef(null),Z=m.useRef(null),W=m.useRef(null),x=m.useRef(!1),U=m.useRef(!1),q=i?u:u?[u]:[],j=q.length>0,M=()=>S(!1),z=()=>S(t=>!t),J=t=>oe({event:t,open:y,options:o,highlightedIndex:F,setHighlightedIndex:A,onSelect:e,closeDropdown:M,userNavigatedRef:U}),G=t=>{t.stopPropagation(),k(i?[]:null),_?.()},X=t=>{const l=t.target.value;L(l),clearTimeout(W.current),W.current=setTimeout(()=>c?.(l.trim()),300)};m.useEffect(()=>{function t(l){V.current?.contains(l.target)||S(!1)}return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]),m.useEffect(()=>{y||(L(""),A(0),c?.(""))},[y]);function e(t){if(!i){k(t),S(!1);return}const l=u.some(b=>b.id===t.id);k(l?u.filter(b=>b.id!==t.id):[...u,t])}function r(t){return l=>{l.stopPropagation(),k(u.filter(b=>b.id!==t.id))}}function n(t){if(!h||x.current)return;const l=t.currentTarget;l.scrollTop+l.clientHeight>=l.scrollHeight-5&&(x.current=!0,f?.())}function a({selected:t,highlighted:l}){return`select-option ${t?"selected":""} ${l?"highlighted":""}`}function w(){return j?q.map(t=>d.jsxs("span",{className:"chip",children:[$(t),i&&d.jsx("button",{className:"chip-remove",onClick:r(t),children:"×"})]},t.id)):d.jsx("span",{className:"placeholder",children:Q})}function C(){return o.map((t,l)=>{const b=i?u.some(te=>te.id===t.id):u?.id===t.id;return d.jsx("li",{className:a({selected:b,highlighted:l===F}),onMouseEnter:()=>A(l),onClick:()=>e(t),children:O?O(t,{selected:b}):t.label},t.id)})}function s(){return E?d.jsx("li",{className:"select-loading",children:"Loading…"}):!E&&o.length===0?d.jsx("li",{className:"select-empty",children:"No results"}):null}function v(){return y?d.jsxs(d.Fragment,{children:[d.jsx("input",{ref:P,className:"select-search",value:B,onChange:X}),d.jsxs("ul",{ref:Z,className:"select-dropdown",onScroll:n,children:[C(),s()]})]}):null}return d.jsxs("div",{ref:V,className:"select-wrapper",tabIndex:0,onKeyDown:J,children:[d.jsxs("div",{className:"select-trigger",onClick:z,children:[d.jsx("div",{className:"chips",children:w()}),j&&d.jsx("button",{className:"clear-btn",onClick:G,children:"Clear"})]}),v()]})}module.exports=le;
package/dist/index.js ADDED
@@ -0,0 +1,458 @@
1
+ import oe, { useState as H, useRef as w, useEffect as ee } from "react";
2
+ var Q = { exports: {} }, D = {};
3
+ var re;
4
+ function se() {
5
+ if (re) return D;
6
+ re = 1;
7
+ var s = /* @__PURE__ */ Symbol.for("react.transitional.element"), h = /* @__PURE__ */ Symbol.for("react.fragment");
8
+ function m(_, c, f) {
9
+ var p = null;
10
+ if (f !== void 0 && (p = "" + f), c.key !== void 0 && (p = "" + c.key), "key" in c) {
11
+ f = {};
12
+ for (var E in c)
13
+ E !== "key" && (f[E] = c[E]);
14
+ } else f = c;
15
+ return c = f.ref, {
16
+ $$typeof: s,
17
+ type: _,
18
+ key: p,
19
+ ref: c !== void 0 ? c : null,
20
+ props: f
21
+ };
22
+ }
23
+ return D.Fragment = h, D.jsx = m, D.jsxs = m, D;
24
+ }
25
+ var Y = {};
26
+ var te;
27
+ function le() {
28
+ return te || (te = 1, process.env.NODE_ENV !== "production" && (function() {
29
+ function s(e) {
30
+ if (e == null) return null;
31
+ if (typeof e == "function")
32
+ return e.$$typeof === W ? null : e.displayName || e.name || null;
33
+ if (typeof e == "string") return e;
34
+ switch (e) {
35
+ case u:
36
+ return "Fragment";
37
+ case k:
38
+ return "Profiler";
39
+ case g:
40
+ return "StrictMode";
41
+ case Z:
42
+ return "Suspense";
43
+ case L:
44
+ return "SuspenseList";
45
+ case K:
46
+ return "Activity";
47
+ }
48
+ if (typeof e == "object")
49
+ switch (typeof e.tag == "number" && console.error(
50
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
51
+ ), e.$$typeof) {
52
+ case T:
53
+ return "Portal";
54
+ case F:
55
+ return e.displayName || "Context";
56
+ case y:
57
+ return (e._context.displayName || "Context") + ".Consumer";
58
+ case A:
59
+ var r = e.render;
60
+ return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
61
+ case V:
62
+ return r = e.displayName || null, r !== null ? r : s(e.type) || "Memo";
63
+ case P:
64
+ r = e._payload, e = e._init;
65
+ try {
66
+ return s(e(r));
67
+ } catch {
68
+ }
69
+ }
70
+ return null;
71
+ }
72
+ function h(e) {
73
+ return "" + e;
74
+ }
75
+ function m(e) {
76
+ try {
77
+ h(e);
78
+ var r = !1;
79
+ } catch {
80
+ r = !0;
81
+ }
82
+ if (r) {
83
+ r = console;
84
+ var n = r.error, a = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
85
+ return n.call(
86
+ r,
87
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
88
+ a
89
+ ), h(e);
90
+ }
91
+ }
92
+ function _(e) {
93
+ if (e === u) return "<>";
94
+ if (typeof e == "object" && e !== null && e.$$typeof === P)
95
+ return "<...>";
96
+ try {
97
+ var r = s(e);
98
+ return r ? "<" + r + ">" : "<...>";
99
+ } catch {
100
+ return "<...>";
101
+ }
102
+ }
103
+ function c() {
104
+ var e = x.A;
105
+ return e === null ? null : e.getOwner();
106
+ }
107
+ function f() {
108
+ return Error("react-stack-top-frame");
109
+ }
110
+ function p(e) {
111
+ if (U.call(e, "key")) {
112
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
113
+ if (r && r.isReactWarning) return !1;
114
+ }
115
+ return e.key !== void 0;
116
+ }
117
+ function E(e, r) {
118
+ function n() {
119
+ q || (q = !0, console.error(
120
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
121
+ r
122
+ ));
123
+ }
124
+ n.isReactWarning = !0, Object.defineProperty(e, "key", {
125
+ get: n,
126
+ configurable: !0
127
+ });
128
+ }
129
+ function i() {
130
+ var e = s(this.type);
131
+ return z[e] || (z[e] = !0, console.error(
132
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
133
+ )), e = this.props.ref, e !== void 0 ? e : null;
134
+ }
135
+ function B(e, r, n, a, j, C) {
136
+ var o = n.ref;
137
+ return e = {
138
+ $$typeof: I,
139
+ type: e,
140
+ key: r,
141
+ props: n,
142
+ _owner: a
143
+ }, (o !== void 0 ? o : null) !== null ? Object.defineProperty(e, "ref", {
144
+ enumerable: !1,
145
+ get: i
146
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
147
+ configurable: !1,
148
+ enumerable: !1,
149
+ writable: !0,
150
+ value: 0
151
+ }), Object.defineProperty(e, "_debugInfo", {
152
+ configurable: !1,
153
+ enumerable: !1,
154
+ writable: !0,
155
+ value: null
156
+ }), Object.defineProperty(e, "_debugStack", {
157
+ configurable: !1,
158
+ enumerable: !1,
159
+ writable: !0,
160
+ value: j
161
+ }), Object.defineProperty(e, "_debugTask", {
162
+ configurable: !1,
163
+ enumerable: !1,
164
+ writable: !0,
165
+ value: C
166
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
167
+ }
168
+ function O(e, r, n, a, j, C) {
169
+ var o = r.children;
170
+ if (o !== void 0)
171
+ if (a)
172
+ if (M(o)) {
173
+ for (a = 0; a < o.length; a++)
174
+ $(o[a]);
175
+ Object.freeze && Object.freeze(o);
176
+ } else
177
+ console.error(
178
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
179
+ );
180
+ else $(o);
181
+ if (U.call(r, "key")) {
182
+ o = s(e);
183
+ var R = Object.keys(r).filter(function(l) {
184
+ return l !== "key";
185
+ });
186
+ a = 0 < R.length ? "{key: someKey, " + R.join(": ..., ") + ": ...}" : "{key: someKey}", X[o + a] || (R = 0 < R.length ? "{" + R.join(": ..., ") + ": ...}" : "{}", console.error(
187
+ `A props object containing a "key" prop is being spread into JSX:
188
+ let props = %s;
189
+ <%s {...props} />
190
+ React keys must be passed directly to JSX without using spread:
191
+ let props = %s;
192
+ <%s key={someKey} {...props} />`,
193
+ a,
194
+ o,
195
+ R,
196
+ o
197
+ ), X[o + a] = !0);
198
+ }
199
+ if (o = null, n !== void 0 && (m(n), o = "" + n), p(r) && (m(r.key), o = "" + r.key), "key" in r) {
200
+ n = {};
201
+ for (var t in r)
202
+ t !== "key" && (n[t] = r[t]);
203
+ } else n = r;
204
+ return o && E(
205
+ n,
206
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
207
+ ), B(
208
+ e,
209
+ o,
210
+ n,
211
+ c(),
212
+ j,
213
+ C
214
+ );
215
+ }
216
+ function $(e) {
217
+ N(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === P && (e._payload.status === "fulfilled" ? N(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
218
+ }
219
+ function N(e) {
220
+ return typeof e == "object" && e !== null && e.$$typeof === I;
221
+ }
222
+ var b = oe, I = /* @__PURE__ */ Symbol.for("react.transitional.element"), T = /* @__PURE__ */ Symbol.for("react.portal"), u = /* @__PURE__ */ Symbol.for("react.fragment"), g = /* @__PURE__ */ Symbol.for("react.strict_mode"), k = /* @__PURE__ */ Symbol.for("react.profiler"), y = /* @__PURE__ */ Symbol.for("react.consumer"), F = /* @__PURE__ */ Symbol.for("react.context"), A = /* @__PURE__ */ Symbol.for("react.forward_ref"), Z = /* @__PURE__ */ Symbol.for("react.suspense"), L = /* @__PURE__ */ Symbol.for("react.suspense_list"), V = /* @__PURE__ */ Symbol.for("react.memo"), P = /* @__PURE__ */ Symbol.for("react.lazy"), K = /* @__PURE__ */ Symbol.for("react.activity"), W = /* @__PURE__ */ Symbol.for("react.client.reference"), x = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, U = Object.prototype.hasOwnProperty, M = Array.isArray, S = console.createTask ? console.createTask : function() {
223
+ return null;
224
+ };
225
+ b = {
226
+ react_stack_bottom_frame: function(e) {
227
+ return e();
228
+ }
229
+ };
230
+ var q, z = {}, J = b.react_stack_bottom_frame.bind(
231
+ b,
232
+ f
233
+ )(), G = S(_(f)), X = {};
234
+ Y.Fragment = u, Y.jsx = function(e, r, n) {
235
+ var a = 1e4 > x.recentlyCreatedOwnerStacks++;
236
+ return O(
237
+ e,
238
+ r,
239
+ n,
240
+ !1,
241
+ a ? Error("react-stack-top-frame") : J,
242
+ a ? S(_(e)) : G
243
+ );
244
+ }, Y.jsxs = function(e, r, n) {
245
+ var a = 1e4 > x.recentlyCreatedOwnerStacks++;
246
+ return O(
247
+ e,
248
+ r,
249
+ n,
250
+ !0,
251
+ a ? Error("react-stack-top-frame") : J,
252
+ a ? S(_(e)) : G
253
+ );
254
+ };
255
+ })()), Y;
256
+ }
257
+ var ne;
258
+ function ce() {
259
+ return ne || (ne = 1, process.env.NODE_ENV === "production" ? Q.exports = se() : Q.exports = le()), Q.exports;
260
+ }
261
+ var d = ce();
262
+ function ue({
263
+ event: s,
264
+ open: h,
265
+ options: m,
266
+ highlightedIndex: _,
267
+ setHighlightedIndex: c,
268
+ onSelect: f,
269
+ closeDropdown: p,
270
+ userNavigatedRef: E
271
+ }) {
272
+ if (h) {
273
+ if (s.key === "ArrowDown" && (s.preventDefault(), E.current = !0, c(
274
+ (i) => Math.min(i + 1, m.length - 1)
275
+ )), s.key === "ArrowUp" && (s.preventDefault(), E.current = !0, c(
276
+ (i) => Math.max(i - 1, 0)
277
+ )), s.key === "Enter") {
278
+ s.preventDefault();
279
+ const i = m[_];
280
+ i && f(i);
281
+ }
282
+ s.key === "Escape" && p();
283
+ }
284
+ }
285
+ function fe({
286
+ options: s = [],
287
+ value: h,
288
+ onChange: m,
289
+ onClear: _,
290
+ onSearch: c,
291
+ onReachEnd: f,
292
+ isLoading: p = !1,
293
+ hasMoreOptions: E = !1,
294
+ isMultipleAllowed: i = !0,
295
+ placeholder: B,
296
+ renderOption: O,
297
+ renderChipValue: $
298
+ }) {
299
+ const N = h !== void 0, [b, I] = H(
300
+ i ? [] : null
301
+ ), T = N ? h : b;
302
+ let u;
303
+ i ? Array.isArray(T) ? u = T : u = [] : Array.isArray(T) ? u = null : u = T ?? null;
304
+ function g(t) {
305
+ N || I(t), m?.(t);
306
+ }
307
+ const [k, y] = H(!1), [F, A] = H(0), [Z, L] = H(""), V = w(null), P = w(null), K = w(null), W = w(null), x = w(!1), U = w(!1), M = i ? u : u ? [u] : [], S = M.length > 0, q = () => y(!1), z = () => y((t) => !t), J = (t) => ue({
308
+ event: t,
309
+ open: k,
310
+ options: s,
311
+ highlightedIndex: F,
312
+ setHighlightedIndex: A,
313
+ onSelect: e,
314
+ closeDropdown: q,
315
+ userNavigatedRef: U
316
+ }), G = (t) => {
317
+ t.stopPropagation(), g(i ? [] : null), _?.();
318
+ }, X = (t) => {
319
+ const l = t.target.value;
320
+ L(l), clearTimeout(W.current), W.current = setTimeout(
321
+ () => c?.(l.trim()),
322
+ 300
323
+ );
324
+ };
325
+ ee(() => {
326
+ function t(l) {
327
+ V.current?.contains(l.target) || y(!1);
328
+ }
329
+ return document.addEventListener("mousedown", t), () => document.removeEventListener("mousedown", t);
330
+ }, []), ee(() => {
331
+ k || (L(""), A(0), c?.(""));
332
+ }, [k]);
333
+ function e(t) {
334
+ if (!i) {
335
+ g(t), y(!1);
336
+ return;
337
+ }
338
+ const l = u.some(
339
+ (v) => v.id === t.id
340
+ );
341
+ g(
342
+ l ? u.filter(
343
+ (v) => v.id !== t.id
344
+ ) : [...u, t]
345
+ );
346
+ }
347
+ function r(t) {
348
+ return (l) => {
349
+ l.stopPropagation(), g(
350
+ u.filter(
351
+ (v) => v.id !== t.id
352
+ )
353
+ );
354
+ };
355
+ }
356
+ function n(t) {
357
+ if (!E || x.current) return;
358
+ const l = t.currentTarget;
359
+ l.scrollTop + l.clientHeight >= l.scrollHeight - 5 && (x.current = !0, f?.());
360
+ }
361
+ function a({ selected: t, highlighted: l }) {
362
+ return `select-option ${t ? "selected" : ""} ${l ? "highlighted" : ""}`;
363
+ }
364
+ function j() {
365
+ return S ? M.map((t) => /* @__PURE__ */ d.jsxs("span", { className: "chip", children: [
366
+ $(t),
367
+ i && /* @__PURE__ */ d.jsx(
368
+ "button",
369
+ {
370
+ className: "chip-remove",
371
+ onClick: r(t),
372
+ children: "×"
373
+ }
374
+ )
375
+ ] }, t.id)) : /* @__PURE__ */ d.jsx("span", { className: "placeholder", children: B });
376
+ }
377
+ function C() {
378
+ return s.map((t, l) => {
379
+ const v = i ? u.some(
380
+ (ae) => ae.id === t.id
381
+ ) : u?.id === t.id;
382
+ return /* @__PURE__ */ d.jsx(
383
+ "li",
384
+ {
385
+ className: a({
386
+ selected: v,
387
+ highlighted: l === F
388
+ }),
389
+ onMouseEnter: () => A(l),
390
+ onClick: () => e(t),
391
+ children: O ? O(t, { selected: v }) : t.label
392
+ },
393
+ t.id
394
+ );
395
+ });
396
+ }
397
+ function o() {
398
+ return p ? /* @__PURE__ */ d.jsx("li", { className: "select-loading", children: "Loading…" }) : !p && s.length === 0 ? /* @__PURE__ */ d.jsx("li", { className: "select-empty", children: "No results" }) : null;
399
+ }
400
+ function R() {
401
+ return k ? /* @__PURE__ */ d.jsxs(d.Fragment, { children: [
402
+ /* @__PURE__ */ d.jsx(
403
+ "input",
404
+ {
405
+ ref: P,
406
+ className: "select-search",
407
+ value: Z,
408
+ onChange: X
409
+ }
410
+ ),
411
+ /* @__PURE__ */ d.jsxs(
412
+ "ul",
413
+ {
414
+ ref: K,
415
+ className: "select-dropdown",
416
+ onScroll: n,
417
+ children: [
418
+ C(),
419
+ o()
420
+ ]
421
+ }
422
+ )
423
+ ] }) : null;
424
+ }
425
+ return /* @__PURE__ */ d.jsxs(
426
+ "div",
427
+ {
428
+ ref: V,
429
+ className: "select-wrapper",
430
+ tabIndex: 0,
431
+ onKeyDown: J,
432
+ children: [
433
+ /* @__PURE__ */ d.jsxs(
434
+ "div",
435
+ {
436
+ className: "select-trigger",
437
+ onClick: z,
438
+ children: [
439
+ /* @__PURE__ */ d.jsx("div", { className: "chips", children: j() }),
440
+ S && /* @__PURE__ */ d.jsx(
441
+ "button",
442
+ {
443
+ className: "clear-btn",
444
+ onClick: G,
445
+ children: "Clear"
446
+ }
447
+ )
448
+ ]
449
+ }
450
+ ),
451
+ R()
452
+ ]
453
+ }
454
+ );
455
+ }
456
+ export {
457
+ fe as default
458
+ };
@@ -0,0 +1 @@
1
+ :root{--color-primary: cadetblue;--color-highlight: #cfe8ea;--color-selected: #b7dde0;--color-border: cadetblue;--color-text-muted: #888;--color-bg: #ffffff}.form-container{width:420px;margin:40px auto;font-family:sans-serif}.select-wrapper{position:relative;width:100%;outline:none}.select-trigger{display:flex;align-items:center;gap:8px;padding:8px;width:100%;box-sizing:border-box;border:1px solid var(--color-border);border-radius:8px;background:var(--color-bg);cursor:pointer}.chips{display:flex;gap:6px;flex:1;min-width:0;white-space:nowrap;overflow:hidden}.chip{display:inline-flex;align-items:center;gap:6px;padding:4px 10px;border-radius:16px;background:var(--color-primary);color:#fff;font-size:13px}.chip-remove{border:none;background:none;color:#fff;cursor:pointer;font-size:14px;line-height:1}.placeholder{color:var(--color-text-muted);font-size:14px}.clear-btn{border:none;background:none;cursor:pointer;color:var(--color-primary);font-size:13px;white-space:nowrap}.select-search{width:100%;padding:8px;box-sizing:border-box;border:1px solid var(--color-border);border-top:none;outline:none}.select-dropdown{max-height:200px;overflow-y:auto;margin:0;padding:0;list-style:none;border:1px solid var(--color-border);border-top:none;background:var(--color-bg)}.select-option{padding:8px 10px;cursor:pointer;display:flex;align-items:center;gap:8px}.select-option.highlighted{background:var(--color-highlight)}.select-option.selected{background:var(--color-selected)}.select-loading,.select-empty{padding:8px 10px;color:#666}.option-row{display:flex;gap:8px;align-items:center}.option-check{margin-left:auto}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "react-select-rohit10",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+
6
+ "description": "Async searchable select component with single and multi-select support",
7
+ "keywords": ["react", "select", "async", "multiselect"],
8
+
9
+ "main": "dist/index.cjs",
10
+ "module": "dist/index.js",
11
+ "types": "types/index.d.ts",
12
+
13
+ "files": ["dist", "types"],
14
+
15
+ "scripts": {
16
+ "build": "vite build",
17
+ "prepublishOnly": "npm run build"
18
+ },
19
+
20
+ "peerDependencies": {
21
+ "react": ">=17",
22
+ "react-dom": ">=17"
23
+ },
24
+
25
+ "devDependencies": {
26
+ "@eslint/js": "^9.39.1",
27
+ "@types/react": "^19.2.5",
28
+ "@types/react-dom": "^19.2.3",
29
+ "@vitejs/plugin-react": "^5.1.1",
30
+ "eslint": "^9.39.1",
31
+ "eslint-plugin-react-hooks": "^7.0.1",
32
+ "eslint-plugin-react-refresh": "^0.4.24",
33
+ "globals": "^16.5.0",
34
+ "vite": "^7.2.4"
35
+ }
36
+ }
@@ -0,0 +1,77 @@
1
+ import * as React from "react";
2
+
3
+
4
+ export interface SelectOption {
5
+ id: string | number;
6
+ label: string;
7
+ [key: string]: any;
8
+ }
9
+
10
+ export interface RenderOptionMeta {
11
+ selected: boolean;
12
+ }
13
+
14
+ export interface SelectProps<
15
+ T extends SelectOption = SelectOption
16
+ > {
17
+ /** List of available options */
18
+ options: T[];
19
+
20
+ /**
21
+ * Controlled value
22
+ * - single: T | null
23
+ * - multiple: T[]
24
+ */
25
+ value?: T | T[] | null;
26
+
27
+ /**
28
+ * Fired on selection change
29
+ * Matches single / multiple mode automatically
30
+ */
31
+ onChange?: (value: T | T[] | null) => void;
32
+
33
+ /** Clear selection callback */
34
+ onClear?: () => void;
35
+
36
+ /** Search callback (debounced internally) */
37
+ onSearch?: (query: string) => void;
38
+
39
+ /** Triggered when dropdown scroll reaches end */
40
+ onReachEnd?: () => void;
41
+
42
+ /** Loading state */
43
+ isLoading?: boolean;
44
+
45
+ /** Whether more options are available */
46
+ hasMoreOptions?: boolean;
47
+
48
+ /** Enable multi-select mode */
49
+ isMultipleAllowed?: boolean;
50
+
51
+ /** Placeholder text */
52
+ placeholder?: string;
53
+
54
+ /**
55
+ * Custom option renderer
56
+ */
57
+ renderOption?: (
58
+ option: T,
59
+ meta: RenderOptionMeta
60
+ ) => React.ReactNode;
61
+
62
+ /**
63
+ * Custom selected value renderer (chips)
64
+ */
65
+ renderChipValue?: (option: T) => React.ReactNode;
66
+ }
67
+
68
+ /**
69
+ * Select component
70
+ */
71
+ declare const Select: <
72
+ T extends SelectOption = SelectOption
73
+ >(
74
+ props: SelectProps<T>
75
+ ) => React.ReactElement;
76
+
77
+ export default Select;