react-select-rohit10 1.0.2 → 1.0.3
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 +22 -9
- package/dist/index.cjs +2 -2
- package/dist/index.js +173 -157
- package/package.json +15 -6
- package/types/index.d.ts +11 -47
package/README.md
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
1
|
-
# React
|
|
1
|
+
# React Select Component
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An async, searchable Select component for React with support for **single select** and **multi-select** modes.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Built with:
|
|
6
|
+
- React
|
|
7
|
+
- TypeScript
|
|
8
|
+
- Keyboard navigation
|
|
9
|
+
- Controlled & uncontrolled usage
|
|
6
10
|
|
|
7
|
-
|
|
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
|
|
11
|
+
---
|
|
9
12
|
|
|
10
|
-
##
|
|
13
|
+
## Features
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
- Search with debounce
|
|
16
|
+
- Keyboard navigation
|
|
17
|
+
- Single & multi-select support
|
|
18
|
+
- Controlled and uncontrolled modes
|
|
19
|
+
- ustom option rendering
|
|
20
|
+
- ustom selected value (chip) rendering
|
|
21
|
+
- Infinite scroll support
|
|
13
22
|
|
|
14
|
-
## Expanding the ESLint configuration
|
|
15
23
|
|
|
16
|
-
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install react-select-rohit10
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";const m=require("react");var
|
|
1
|
+
"use strict";const m=require("react");var Q={exports:{}},I={};var ee;function ne(){if(ee)return I;ee=1;var l=Symbol.for("react.transitional.element"),h=Symbol.for("react.fragment");function E(_,c,f){var p=null;if(f!==void 0&&(p=""+f),c.key!==void 0&&(p=""+c.key),"key"in c){f={};for(var R in c)R!=="key"&&(f[R]=c[R])}else f=c;return c=f.ref,{$$typeof:l,type:_,key:p,ref:c!==void 0?c:null,props:f}}return I.Fragment=h,I.jsx=E,I.jsxs=E,I}var F={};var re;function ae(){return re||(re=1,process.env.NODE_ENV!=="production"&&(function(){function l(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===D?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case d:return"Fragment";case k:return"Profiler";case T:return"StrictMode";case Z:return"Suspense";case U:return"SuspenseList";case K: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 W:return e.displayName||"Context";case y:return(e._context.displayName||"Context")+".Consumer";case P: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:l(e.type)||"Memo";case C:r=e._payload,e=e._init;try{return l(e(r))}catch{}}return null}function h(e){return""+e}function E(e){try{h(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),h(e)}}function _(e){if(e===d)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===C)return"<...>";try{var r=l(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function c(){var e=S.A;return e===null?null:e.getOwner()}function f(){return Error("react-stack-top-frame")}function p(e){if(q.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function R(e,r){function n(){z||(z=!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 u(){var e=l(this.type);return J[e]||(J[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 B(e,r,n,a,j,Y){var s=n.ref;return e={$$typeof:L,type:e,key:r,props:n,_owner:a},(s!==void 0?s:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:u}):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:j}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Y}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function O(e,r,n,a,j,Y){var s=r.children;if(s!==void 0)if(a)if(M(s)){for(a=0;a<s.length;a++)N(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 N(s);if(q.call(r,"key")){s=l(e);var v=Object.keys(r).filter(function(o){return o!=="key"});a=0<v.length?"{key: someKey, "+v.join(": ..., ")+": ...}":"{key: someKey}",H[s+a]||(v=0<v.length?"{"+v.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,a,s,v,s),
|
|
6
|
+
<%s key={someKey} {...props} />`,a,s,v,s),H[s+a]=!0)}if(s=null,n!==void 0&&(E(n),s=""+n),p(r)&&(E(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&&R(n,typeof e=="function"?e.displayName||e.name||"Unknown":e),B(e,s,n,c(),j,Y)}function N(e){A(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===C&&(e._payload.status==="fulfilled"?A(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function A(e){return typeof e=="object"&&e!==null&&e.$$typeof===L}var b=m,L=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),y=Symbol.for("react.consumer"),W=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),Z=Symbol.for("react.suspense"),U=Symbol.for("react.suspense_list"),V=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),K=Symbol.for("react.activity"),D=Symbol.for("react.client.reference"),S=b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,q=Object.prototype.hasOwnProperty,M=Array.isArray,x=console.createTask?console.createTask:function(){return null};b={react_stack_bottom_frame:function(e){return e()}};var z,J={},G=b.react_stack_bottom_frame.bind(b,f)(),X=x(_(f)),H={};F.Fragment=d,F.jsx=function(e,r,n){var a=1e4>S.recentlyCreatedOwnerStacks++;return O(e,r,n,!1,a?Error("react-stack-top-frame"):G,a?x(_(e)):X)},F.jsxs=function(e,r,n){var a=1e4>S.recentlyCreatedOwnerStacks++;return O(e,r,n,!0,a?Error("react-stack-top-frame"):G,a?x(_(e)):X)}})()),F}var te;function se(){return te||(te=1,process.env.NODE_ENV==="production"?Q.exports=ne():Q.exports=ae()),Q.exports}var i=se();function oe({event:l,open:h,options:E,highlightedIndex:_,setHighlightedIndex:c,onSelect:f,closeDropdown:p,userNavigatedRef:R}){if(h){if(l.key==="ArrowDown"&&(l.preventDefault(),R.current=!0,c(u=>Math.min(u+1,E.length-1))),l.key==="ArrowUp"&&(l.preventDefault(),R.current=!0,c(u=>Math.max(u-1,0))),l.key==="Enter"){l.preventDefault();const u=E[_];u&&f(u)}l.key==="Escape"&&p()}}function le({options:l,value:h,onChange:E,onClear:_,onSearch:c,onReachEnd:f,isLoading:p=!1,hasMoreOptions:R=!1,isMultipleAllowed:u=!0,placeholder:B,renderOption:O,renderChipValue:N}){const A=h!==void 0,[b,L]=m.useState(u?[]:null),g=A?h:b;let d;u?d=Array.isArray(g)?g:[]:d=Array.isArray(g)?null:g??null;function T(t){A||L(t),E?.(t)}const[k,y]=m.useState(!1),[W,P]=m.useState(0),[Z,U]=m.useState(""),V=m.useRef(null),C=m.useRef(null),K=m.useRef(null),D=m.useRef(null),S=m.useRef(!1),q=m.useRef(!1),M=u?d:d?[d]:[],x=M.length>0,z=()=>y(!1),J=()=>y(t=>!t),G=t=>oe({event:t,open:k,options:l,highlightedIndex:W,setHighlightedIndex:P,onSelect:e,closeDropdown:z,userNavigatedRef:q}),X=t=>{t.stopPropagation(),T(u?[]:null),_?.()},H=t=>{const o=t.target.value;U(o),D.current!==null&&clearTimeout(D.current),D.current=window.setTimeout(()=>{c?.(o.trim())},300)};m.useEffect(()=>{function t(o){V.current?.contains(o.target)||y(!1)}return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]),m.useEffect(()=>{k||(U(""),P(0),c?.(""))},[k,c]);function e(t){if(!u){T(t),y(!1);return}const o=d,w=o.some($=>$.id===t.id);T(w?o.filter($=>$.id!==t.id):[...o,t])}function r(t){return o=>{o.stopPropagation(),T(d.filter(w=>w.id!==t.id))}}function n(t){if(!R||S.current)return;const o=t.currentTarget;o.scrollTop+o.clientHeight>=o.scrollHeight-5&&(S.current=!0,f?.())}function a({selected:t,highlighted:o}){return`select-option ${t?"selected":""} ${o?"highlighted":""}`}function j(){return x?i.jsx(i.Fragment,{children:M.map(t=>i.jsxs("span",{className:"chip",children:[N?N(t):t.label,u&&i.jsx("button",{className:"chip-remove",onClick:r(t),children:"×"})]},t.id))}):i.jsx("span",{className:"placeholder",children:B})}function Y(){return l.map((t,o)=>{const w=u?d.some($=>$.id===t.id):d?.id===t.id;return i.jsx("li",{className:a({selected:w,highlighted:o===W}),onMouseEnter:()=>P(o),onClick:()=>e(t),children:O?O(t,{selected:w}):t.label},t.id)})}function s(){return p?i.jsx("li",{className:"select-loading",children:"Loading…"}):!p&&l.length===0?i.jsx("li",{className:"select-empty",children:"No results"}):null}function v(){return k?i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:C,className:"select-search",value:Z,onChange:H}),i.jsxs("ul",{ref:K,className:"select-dropdown",onScroll:n,children:[Y(),s()]})]}):null}return i.jsxs("div",{ref:V,className:"select-wrapper",tabIndex:0,onKeyDown:G,children:[i.jsxs("div",{className:"select-trigger",onClick:J,children:[i.jsx("div",{className:"chips",children:j()}),x&&i.jsx("button",{className:"clear-btn",onClick:X,children:"Clear"})]}),v()]})}module.exports=le;
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import oe, { useState as
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
import oe, { useState as Q, useRef as S, useEffect as re } from "react";
|
|
2
|
+
var B = { exports: {} }, I = {};
|
|
3
|
+
var te;
|
|
4
4
|
function se() {
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
var
|
|
5
|
+
if (te) return I;
|
|
6
|
+
te = 1;
|
|
7
|
+
var l = /* @__PURE__ */ Symbol.for("react.transitional.element"), h = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
8
8
|
function m(_, c, f) {
|
|
9
9
|
var p = null;
|
|
10
10
|
if (f !== void 0 && (p = "" + f), c.key !== void 0 && (p = "" + c.key), "key" in c) {
|
|
@@ -13,57 +13,57 @@ function se() {
|
|
|
13
13
|
E !== "key" && (f[E] = c[E]);
|
|
14
14
|
} else f = c;
|
|
15
15
|
return c = f.ref, {
|
|
16
|
-
$$typeof:
|
|
16
|
+
$$typeof: l,
|
|
17
17
|
type: _,
|
|
18
18
|
key: p,
|
|
19
19
|
ref: c !== void 0 ? c : null,
|
|
20
20
|
props: f
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
return
|
|
23
|
+
return I.Fragment = h, I.jsx = m, I.jsxs = m, I;
|
|
24
24
|
}
|
|
25
|
-
var
|
|
26
|
-
var
|
|
25
|
+
var F = {};
|
|
26
|
+
var ne;
|
|
27
27
|
function le() {
|
|
28
|
-
return
|
|
29
|
-
function
|
|
28
|
+
return ne || (ne = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
29
|
+
function l(e) {
|
|
30
30
|
if (e == null) return null;
|
|
31
31
|
if (typeof e == "function")
|
|
32
|
-
return e.$$typeof ===
|
|
32
|
+
return e.$$typeof === D ? null : e.displayName || e.name || null;
|
|
33
33
|
if (typeof e == "string") return e;
|
|
34
34
|
switch (e) {
|
|
35
|
-
case
|
|
35
|
+
case d:
|
|
36
36
|
return "Fragment";
|
|
37
|
-
case
|
|
37
|
+
case T:
|
|
38
38
|
return "Profiler";
|
|
39
39
|
case g:
|
|
40
40
|
return "StrictMode";
|
|
41
|
-
case
|
|
41
|
+
case K:
|
|
42
42
|
return "Suspense";
|
|
43
|
-
case
|
|
43
|
+
case U:
|
|
44
44
|
return "SuspenseList";
|
|
45
|
-
case
|
|
45
|
+
case ee:
|
|
46
46
|
return "Activity";
|
|
47
47
|
}
|
|
48
48
|
if (typeof e == "object")
|
|
49
49
|
switch (typeof e.tag == "number" && console.error(
|
|
50
50
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
51
51
|
), e.$$typeof) {
|
|
52
|
-
case
|
|
52
|
+
case b:
|
|
53
53
|
return "Portal";
|
|
54
|
-
case
|
|
54
|
+
case W:
|
|
55
55
|
return e.displayName || "Context";
|
|
56
|
-
case
|
|
56
|
+
case k:
|
|
57
57
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
58
58
|
case P:
|
|
59
59
|
var r = e.render;
|
|
60
60
|
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
61
|
-
case
|
|
62
|
-
return r = e.displayName || null, r !== null ? r :
|
|
61
|
+
case V:
|
|
62
|
+
return r = e.displayName || null, r !== null ? r : l(e.type) || "Memo";
|
|
63
63
|
case C:
|
|
64
64
|
r = e._payload, e = e._init;
|
|
65
65
|
try {
|
|
66
|
-
return
|
|
66
|
+
return l(e(r));
|
|
67
67
|
} catch {
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -90,25 +90,25 @@ function le() {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
function _(e) {
|
|
93
|
-
if (e ===
|
|
93
|
+
if (e === d) return "<>";
|
|
94
94
|
if (typeof e == "object" && e !== null && e.$$typeof === C)
|
|
95
95
|
return "<...>";
|
|
96
96
|
try {
|
|
97
|
-
var r =
|
|
97
|
+
var r = l(e);
|
|
98
98
|
return r ? "<" + r + ">" : "<...>";
|
|
99
99
|
} catch {
|
|
100
100
|
return "<...>";
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
function c() {
|
|
104
|
-
var e =
|
|
104
|
+
var e = y.A;
|
|
105
105
|
return e === null ? null : e.getOwner();
|
|
106
106
|
}
|
|
107
107
|
function f() {
|
|
108
108
|
return Error("react-stack-top-frame");
|
|
109
109
|
}
|
|
110
110
|
function p(e) {
|
|
111
|
-
if (
|
|
111
|
+
if (M.call(e, "key")) {
|
|
112
112
|
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
113
113
|
if (r && r.isReactWarning) return !1;
|
|
114
114
|
}
|
|
@@ -116,7 +116,7 @@ function le() {
|
|
|
116
116
|
}
|
|
117
117
|
function E(e, r) {
|
|
118
118
|
function n() {
|
|
119
|
-
|
|
119
|
+
z || (z = !0, console.error(
|
|
120
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
121
|
r
|
|
122
122
|
));
|
|
@@ -126,23 +126,23 @@ function le() {
|
|
|
126
126
|
configurable: !0
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
-
function
|
|
130
|
-
var e =
|
|
131
|
-
return
|
|
129
|
+
function u() {
|
|
130
|
+
var e = l(this.type);
|
|
131
|
+
return J[e] || (J[e] = !0, console.error(
|
|
132
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
133
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function Z(e, r, n, a, j, Y) {
|
|
136
136
|
var o = n.ref;
|
|
137
137
|
return e = {
|
|
138
|
-
$$typeof:
|
|
138
|
+
$$typeof: L,
|
|
139
139
|
type: e,
|
|
140
140
|
key: r,
|
|
141
141
|
props: n,
|
|
142
142
|
_owner: a
|
|
143
143
|
}, (o !== void 0 ? o : null) !== null ? Object.defineProperty(e, "ref", {
|
|
144
144
|
enumerable: !1,
|
|
145
|
-
get:
|
|
145
|
+
get: u
|
|
146
146
|
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
147
147
|
configurable: !1,
|
|
148
148
|
enumerable: !1,
|
|
@@ -162,14 +162,14 @@ function le() {
|
|
|
162
162
|
configurable: !1,
|
|
163
163
|
enumerable: !1,
|
|
164
164
|
writable: !0,
|
|
165
|
-
value:
|
|
165
|
+
value: Y
|
|
166
166
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
167
167
|
}
|
|
168
|
-
function O(e, r, n, a, j,
|
|
168
|
+
function O(e, r, n, a, j, Y) {
|
|
169
169
|
var o = r.children;
|
|
170
170
|
if (o !== void 0)
|
|
171
171
|
if (a)
|
|
172
|
-
if (
|
|
172
|
+
if (q(o)) {
|
|
173
173
|
for (a = 0; a < o.length; a++)
|
|
174
174
|
N(o[a]);
|
|
175
175
|
Object.freeze && Object.freeze(o);
|
|
@@ -178,12 +178,12 @@ function le() {
|
|
|
178
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
179
|
);
|
|
180
180
|
else N(o);
|
|
181
|
-
if (
|
|
182
|
-
o =
|
|
183
|
-
var R = Object.keys(r).filter(function(
|
|
184
|
-
return
|
|
181
|
+
if (M.call(r, "key")) {
|
|
182
|
+
o = l(e);
|
|
183
|
+
var R = Object.keys(r).filter(function(s) {
|
|
184
|
+
return s !== "key";
|
|
185
185
|
});
|
|
186
|
-
a = 0 < R.length ? "{key: someKey, " + R.join(": ..., ") + ": ...}" : "{key: someKey}",
|
|
186
|
+
a = 0 < R.length ? "{key: someKey, " + R.join(": ..., ") + ": ...}" : "{key: someKey}", H[o + a] || (R = 0 < R.length ? "{" + R.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
187
187
|
`A props object containing a "key" prop is being spread into JSX:
|
|
188
188
|
let props = %s;
|
|
189
189
|
<%s {...props} />
|
|
@@ -194,7 +194,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
194
194
|
o,
|
|
195
195
|
R,
|
|
196
196
|
o
|
|
197
|
-
),
|
|
197
|
+
), H[o + a] = !0);
|
|
198
198
|
}
|
|
199
199
|
if (o = null, n !== void 0 && (m(n), o = "" + n), p(r) && (m(r.key), o = "" + r.key), "key" in r) {
|
|
200
200
|
n = {};
|
|
@@ -204,63 +204,63 @@ React keys must be passed directly to JSX without using spread:
|
|
|
204
204
|
return o && E(
|
|
205
205
|
n,
|
|
206
206
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
207
|
-
),
|
|
207
|
+
), Z(
|
|
208
208
|
e,
|
|
209
209
|
o,
|
|
210
210
|
n,
|
|
211
211
|
c(),
|
|
212
212
|
j,
|
|
213
|
-
|
|
213
|
+
Y
|
|
214
214
|
);
|
|
215
215
|
}
|
|
216
216
|
function N(e) {
|
|
217
217
|
A(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === C && (e._payload.status === "fulfilled" ? A(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
218
218
|
}
|
|
219
219
|
function A(e) {
|
|
220
|
-
return typeof e == "object" && e !== null && e.$$typeof ===
|
|
220
|
+
return typeof e == "object" && e !== null && e.$$typeof === L;
|
|
221
221
|
}
|
|
222
|
-
var
|
|
222
|
+
var v = oe, L = /* @__PURE__ */ Symbol.for("react.transitional.element"), b = /* @__PURE__ */ Symbol.for("react.portal"), d = /* @__PURE__ */ Symbol.for("react.fragment"), g = /* @__PURE__ */ Symbol.for("react.strict_mode"), T = /* @__PURE__ */ Symbol.for("react.profiler"), k = /* @__PURE__ */ Symbol.for("react.consumer"), W = /* @__PURE__ */ Symbol.for("react.context"), P = /* @__PURE__ */ Symbol.for("react.forward_ref"), K = /* @__PURE__ */ Symbol.for("react.suspense"), U = /* @__PURE__ */ Symbol.for("react.suspense_list"), V = /* @__PURE__ */ Symbol.for("react.memo"), C = /* @__PURE__ */ Symbol.for("react.lazy"), ee = /* @__PURE__ */ Symbol.for("react.activity"), D = /* @__PURE__ */ Symbol.for("react.client.reference"), y = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, M = Object.prototype.hasOwnProperty, q = Array.isArray, x = console.createTask ? console.createTask : function() {
|
|
223
223
|
return null;
|
|
224
224
|
};
|
|
225
|
-
|
|
225
|
+
v = {
|
|
226
226
|
react_stack_bottom_frame: function(e) {
|
|
227
227
|
return e();
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
|
-
var
|
|
231
|
-
|
|
230
|
+
var z, J = {}, G = v.react_stack_bottom_frame.bind(
|
|
231
|
+
v,
|
|
232
232
|
f
|
|
233
|
-
)(),
|
|
234
|
-
|
|
235
|
-
var a = 1e4 >
|
|
233
|
+
)(), X = x(_(f)), H = {};
|
|
234
|
+
F.Fragment = d, F.jsx = function(e, r, n) {
|
|
235
|
+
var a = 1e4 > y.recentlyCreatedOwnerStacks++;
|
|
236
236
|
return O(
|
|
237
237
|
e,
|
|
238
238
|
r,
|
|
239
239
|
n,
|
|
240
240
|
!1,
|
|
241
|
-
a ? Error("react-stack-top-frame") :
|
|
242
|
-
a ?
|
|
241
|
+
a ? Error("react-stack-top-frame") : G,
|
|
242
|
+
a ? x(_(e)) : X
|
|
243
243
|
);
|
|
244
|
-
},
|
|
245
|
-
var a = 1e4 >
|
|
244
|
+
}, F.jsxs = function(e, r, n) {
|
|
245
|
+
var a = 1e4 > y.recentlyCreatedOwnerStacks++;
|
|
246
246
|
return O(
|
|
247
247
|
e,
|
|
248
248
|
r,
|
|
249
249
|
n,
|
|
250
250
|
!0,
|
|
251
|
-
a ? Error("react-stack-top-frame") :
|
|
252
|
-
a ?
|
|
251
|
+
a ? Error("react-stack-top-frame") : G,
|
|
252
|
+
a ? x(_(e)) : X
|
|
253
253
|
);
|
|
254
254
|
};
|
|
255
|
-
})()),
|
|
255
|
+
})()), F;
|
|
256
256
|
}
|
|
257
|
-
var
|
|
257
|
+
var ae;
|
|
258
258
|
function ce() {
|
|
259
|
-
return
|
|
259
|
+
return ae || (ae = 1, process.env.NODE_ENV === "production" ? B.exports = se() : B.exports = le()), B.exports;
|
|
260
260
|
}
|
|
261
|
-
var
|
|
261
|
+
var i = ce();
|
|
262
262
|
function ue({
|
|
263
|
-
event:
|
|
263
|
+
event: l,
|
|
264
264
|
open: h,
|
|
265
265
|
options: m,
|
|
266
266
|
highlightedIndex: _,
|
|
@@ -270,20 +270,20 @@ function ue({
|
|
|
270
270
|
userNavigatedRef: E
|
|
271
271
|
}) {
|
|
272
272
|
if (h) {
|
|
273
|
-
if (
|
|
274
|
-
(
|
|
275
|
-
)),
|
|
276
|
-
(
|
|
277
|
-
)),
|
|
278
|
-
|
|
279
|
-
const
|
|
280
|
-
|
|
273
|
+
if (l.key === "ArrowDown" && (l.preventDefault(), E.current = !0, c(
|
|
274
|
+
(u) => Math.min(u + 1, m.length - 1)
|
|
275
|
+
)), l.key === "ArrowUp" && (l.preventDefault(), E.current = !0, c(
|
|
276
|
+
(u) => Math.max(u - 1, 0)
|
|
277
|
+
)), l.key === "Enter") {
|
|
278
|
+
l.preventDefault();
|
|
279
|
+
const u = m[_];
|
|
280
|
+
u && f(u);
|
|
281
281
|
}
|
|
282
|
-
|
|
282
|
+
l.key === "Escape" && p();
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
function fe({
|
|
286
|
-
options:
|
|
286
|
+
options: l,
|
|
287
287
|
value: h,
|
|
288
288
|
onChange: m,
|
|
289
289
|
onClear: _,
|
|
@@ -291,157 +291,173 @@ function fe({
|
|
|
291
291
|
onReachEnd: f,
|
|
292
292
|
isLoading: p = !1,
|
|
293
293
|
hasMoreOptions: E = !1,
|
|
294
|
-
isMultipleAllowed:
|
|
295
|
-
placeholder:
|
|
294
|
+
isMultipleAllowed: u = !0,
|
|
295
|
+
placeholder: Z,
|
|
296
296
|
renderOption: O,
|
|
297
297
|
renderChipValue: N
|
|
298
298
|
}) {
|
|
299
|
-
const A = h !== void 0, [
|
|
300
|
-
|
|
301
|
-
)
|
|
302
|
-
let u;
|
|
303
|
-
i ? Array.isArray(T) ? u = T : u = [] : Array.isArray(T) ? u = null : u = T ?? null;
|
|
299
|
+
const A = h !== void 0, [v, L] = Q(u ? [] : null), b = A ? h : v;
|
|
300
|
+
let d;
|
|
301
|
+
u ? d = Array.isArray(b) ? b : [] : d = Array.isArray(b) ? null : b ?? null;
|
|
304
302
|
function g(t) {
|
|
305
|
-
A ||
|
|
303
|
+
A || L(t), m?.(t);
|
|
306
304
|
}
|
|
307
|
-
const [
|
|
305
|
+
const [T, k] = Q(!1), [W, P] = Q(0), [K, U] = Q(""), V = S(null), C = S(null), ee = S(null), D = S(null), y = S(!1), M = S(!1), q = u ? d : d ? [d] : [], x = q.length > 0, z = () => k(!1), J = () => k((t) => !t), G = (t) => ue({
|
|
308
306
|
event: t,
|
|
309
|
-
open:
|
|
310
|
-
options:
|
|
311
|
-
highlightedIndex:
|
|
307
|
+
open: T,
|
|
308
|
+
options: l,
|
|
309
|
+
highlightedIndex: W,
|
|
312
310
|
setHighlightedIndex: P,
|
|
313
311
|
onSelect: e,
|
|
314
|
-
closeDropdown:
|
|
315
|
-
userNavigatedRef:
|
|
316
|
-
}),
|
|
317
|
-
t.stopPropagation(), g(
|
|
318
|
-
},
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
);
|
|
312
|
+
closeDropdown: z,
|
|
313
|
+
userNavigatedRef: M
|
|
314
|
+
}), X = (t) => {
|
|
315
|
+
t.stopPropagation(), g(u ? [] : null), _?.();
|
|
316
|
+
}, H = (t) => {
|
|
317
|
+
const s = t.target.value;
|
|
318
|
+
U(s), D.current !== null && clearTimeout(D.current), D.current = window.setTimeout(() => {
|
|
319
|
+
c?.(s.trim());
|
|
320
|
+
}, 300);
|
|
324
321
|
};
|
|
325
|
-
|
|
326
|
-
function t(
|
|
327
|
-
|
|
322
|
+
re(() => {
|
|
323
|
+
function t(s) {
|
|
324
|
+
V.current?.contains(
|
|
325
|
+
s.target
|
|
326
|
+
) || k(!1);
|
|
328
327
|
}
|
|
329
|
-
return document.addEventListener(
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
328
|
+
return document.addEventListener(
|
|
329
|
+
"mousedown",
|
|
330
|
+
t
|
|
331
|
+
), () => document.removeEventListener(
|
|
332
|
+
"mousedown",
|
|
333
|
+
t
|
|
334
|
+
);
|
|
335
|
+
}, []), re(() => {
|
|
336
|
+
T || (U(""), P(0), c?.(""));
|
|
337
|
+
}, [T, c]);
|
|
333
338
|
function e(t) {
|
|
334
|
-
if (!
|
|
335
|
-
g(t),
|
|
339
|
+
if (!u) {
|
|
340
|
+
g(t), k(!1);
|
|
336
341
|
return;
|
|
337
342
|
}
|
|
338
|
-
const
|
|
339
|
-
(
|
|
343
|
+
const s = d, w = s.some(
|
|
344
|
+
($) => $.id === t.id
|
|
340
345
|
);
|
|
341
346
|
g(
|
|
342
|
-
|
|
343
|
-
(
|
|
344
|
-
) : [...
|
|
347
|
+
w ? s.filter(
|
|
348
|
+
($) => $.id !== t.id
|
|
349
|
+
) : [...s, t]
|
|
345
350
|
);
|
|
346
351
|
}
|
|
347
352
|
function r(t) {
|
|
348
|
-
return (
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
(
|
|
353
|
+
return (s) => {
|
|
354
|
+
s.stopPropagation(), g(
|
|
355
|
+
d.filter(
|
|
356
|
+
(w) => w.id !== t.id
|
|
352
357
|
)
|
|
353
358
|
);
|
|
354
359
|
};
|
|
355
360
|
}
|
|
356
361
|
function n(t) {
|
|
357
|
-
if (!E ||
|
|
358
|
-
|
|
359
|
-
|
|
362
|
+
if (!E || y.current)
|
|
363
|
+
return;
|
|
364
|
+
const s = t.currentTarget;
|
|
365
|
+
s.scrollTop + s.clientHeight >= s.scrollHeight - 5 && (y.current = !0, f?.());
|
|
360
366
|
}
|
|
361
|
-
function a({
|
|
362
|
-
|
|
367
|
+
function a({
|
|
368
|
+
selected: t,
|
|
369
|
+
highlighted: s
|
|
370
|
+
}) {
|
|
371
|
+
return `select-option ${t ? "selected" : ""} ${s ? "highlighted" : ""}`;
|
|
363
372
|
}
|
|
364
373
|
function j() {
|
|
365
|
-
return
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
"
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
374
|
+
return x ? /* @__PURE__ */ i.jsx(i.Fragment, { children: q.map((t) => /* @__PURE__ */ i.jsxs(
|
|
375
|
+
"span",
|
|
376
|
+
{
|
|
377
|
+
className: "chip",
|
|
378
|
+
children: [
|
|
379
|
+
N ? N(t) : t.label,
|
|
380
|
+
u && /* @__PURE__ */ i.jsx(
|
|
381
|
+
"button",
|
|
382
|
+
{
|
|
383
|
+
className: "chip-remove",
|
|
384
|
+
onClick: r(t),
|
|
385
|
+
children: "×"
|
|
386
|
+
}
|
|
387
|
+
)
|
|
388
|
+
]
|
|
389
|
+
},
|
|
390
|
+
t.id
|
|
391
|
+
)) }) : /* @__PURE__ */ i.jsx("span", { className: "placeholder", children: Z });
|
|
376
392
|
}
|
|
377
|
-
function
|
|
378
|
-
return
|
|
379
|
-
const
|
|
380
|
-
(
|
|
381
|
-
) :
|
|
382
|
-
return /* @__PURE__ */
|
|
393
|
+
function Y() {
|
|
394
|
+
return l.map((t, s) => {
|
|
395
|
+
const w = u ? d.some(
|
|
396
|
+
($) => $.id === t.id
|
|
397
|
+
) : d?.id === t.id;
|
|
398
|
+
return /* @__PURE__ */ i.jsx(
|
|
383
399
|
"li",
|
|
384
400
|
{
|
|
385
401
|
className: a({
|
|
386
|
-
selected:
|
|
387
|
-
highlighted:
|
|
402
|
+
selected: w,
|
|
403
|
+
highlighted: s === W
|
|
388
404
|
}),
|
|
389
|
-
onMouseEnter: () => P(
|
|
405
|
+
onMouseEnter: () => P(s),
|
|
390
406
|
onClick: () => e(t),
|
|
391
|
-
children: O ? O(t, { selected:
|
|
407
|
+
children: O ? O(t, { selected: w }) : t.label
|
|
392
408
|
},
|
|
393
409
|
t.id
|
|
394
410
|
);
|
|
395
411
|
});
|
|
396
412
|
}
|
|
397
413
|
function o() {
|
|
398
|
-
return p ? /* @__PURE__ */
|
|
414
|
+
return p ? /* @__PURE__ */ i.jsx("li", { className: "select-loading", children: "Loading…" }) : !p && l.length === 0 ? /* @__PURE__ */ i.jsx("li", { className: "select-empty", children: "No results" }) : null;
|
|
399
415
|
}
|
|
400
416
|
function R() {
|
|
401
|
-
return
|
|
402
|
-
/* @__PURE__ */
|
|
417
|
+
return T ? /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
|
|
418
|
+
/* @__PURE__ */ i.jsx(
|
|
403
419
|
"input",
|
|
404
420
|
{
|
|
405
421
|
ref: C,
|
|
406
422
|
className: "select-search",
|
|
407
|
-
value:
|
|
408
|
-
onChange:
|
|
423
|
+
value: K,
|
|
424
|
+
onChange: H
|
|
409
425
|
}
|
|
410
426
|
),
|
|
411
|
-
/* @__PURE__ */
|
|
427
|
+
/* @__PURE__ */ i.jsxs(
|
|
412
428
|
"ul",
|
|
413
429
|
{
|
|
414
|
-
ref:
|
|
430
|
+
ref: ee,
|
|
415
431
|
className: "select-dropdown",
|
|
416
432
|
onScroll: n,
|
|
417
433
|
children: [
|
|
418
|
-
|
|
434
|
+
Y(),
|
|
419
435
|
o()
|
|
420
436
|
]
|
|
421
437
|
}
|
|
422
438
|
)
|
|
423
439
|
] }) : null;
|
|
424
440
|
}
|
|
425
|
-
return /* @__PURE__ */
|
|
441
|
+
return /* @__PURE__ */ i.jsxs(
|
|
426
442
|
"div",
|
|
427
443
|
{
|
|
428
|
-
ref:
|
|
444
|
+
ref: V,
|
|
429
445
|
className: "select-wrapper",
|
|
430
446
|
tabIndex: 0,
|
|
431
|
-
onKeyDown:
|
|
447
|
+
onKeyDown: G,
|
|
432
448
|
children: [
|
|
433
|
-
/* @__PURE__ */
|
|
449
|
+
/* @__PURE__ */ i.jsxs(
|
|
434
450
|
"div",
|
|
435
451
|
{
|
|
436
452
|
className: "select-trigger",
|
|
437
|
-
onClick:
|
|
453
|
+
onClick: J,
|
|
438
454
|
children: [
|
|
439
|
-
/* @__PURE__ */
|
|
440
|
-
|
|
455
|
+
/* @__PURE__ */ i.jsx("div", { className: "chips", children: j() }),
|
|
456
|
+
x && /* @__PURE__ */ i.jsx(
|
|
441
457
|
"button",
|
|
442
458
|
{
|
|
443
459
|
className: "clear-btn",
|
|
444
|
-
onClick:
|
|
460
|
+
onClick: X,
|
|
445
461
|
children: "Clear"
|
|
446
462
|
}
|
|
447
463
|
)
|
package/package.json
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-select-rohit10",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"license": "MIT",
|
|
5
|
-
"type": "module",
|
|
3
|
+
"version": "1.0.3",
|
|
6
4
|
"description": "Async searchable select component with single and multi-select support",
|
|
5
|
+
"license": "MIT",
|
|
7
6
|
"keywords": [
|
|
8
7
|
"react",
|
|
9
8
|
"select",
|
|
10
9
|
"async",
|
|
11
10
|
"multiselect"
|
|
12
11
|
],
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/index.cjs",
|
|
14
|
+
"module": "./dist/index.js",
|
|
15
|
+
"types": "./types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"require": "./dist/index.cjs",
|
|
20
|
+
"types": "./types/index.d.ts"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
16
23
|
"files": [
|
|
17
24
|
"dist",
|
|
18
25
|
"types"
|
|
@@ -34,6 +41,8 @@
|
|
|
34
41
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
35
42
|
"eslint-plugin-react-refresh": "^0.4.24",
|
|
36
43
|
"globals": "^16.5.0",
|
|
44
|
+
"ts-node": "^10.9.2",
|
|
45
|
+
"typescript": "^5.9.3",
|
|
37
46
|
"vite": "^7.2.4"
|
|
38
47
|
}
|
|
39
48
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,77 +1,41 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
export interface SelectOption {
|
|
5
4
|
id: string | number;
|
|
6
5
|
label: string;
|
|
7
|
-
[key: string]: any;
|
|
8
6
|
}
|
|
9
7
|
|
|
10
8
|
export interface RenderOptionMeta {
|
|
11
9
|
selected: boolean;
|
|
12
10
|
}
|
|
13
11
|
|
|
14
|
-
export interface SelectProps
|
|
15
|
-
|
|
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;
|
|
12
|
+
export interface SelectProps {
|
|
13
|
+
options: SelectOption[];
|
|
26
14
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
onChange?: (value: T | T[] | null) => void;
|
|
15
|
+
value?: SelectOption | SelectOption[] | null;
|
|
16
|
+
onChange?: (
|
|
17
|
+
value: SelectOption | SelectOption[] | null
|
|
18
|
+
) => void;
|
|
32
19
|
|
|
33
|
-
/** Clear selection callback */
|
|
34
20
|
onClear?: () => void;
|
|
35
|
-
|
|
36
|
-
/** Search callback (debounced internally) */
|
|
37
21
|
onSearch?: (query: string) => void;
|
|
38
|
-
|
|
39
|
-
/** Triggered when dropdown scroll reaches end */
|
|
40
22
|
onReachEnd?: () => void;
|
|
41
23
|
|
|
42
|
-
/** Loading state */
|
|
43
24
|
isLoading?: boolean;
|
|
44
|
-
|
|
45
|
-
/** Whether more options are available */
|
|
46
25
|
hasMoreOptions?: boolean;
|
|
47
|
-
|
|
48
|
-
/** Enable multi-select mode */
|
|
49
26
|
isMultipleAllowed?: boolean;
|
|
50
27
|
|
|
51
|
-
/** Placeholder text */
|
|
52
28
|
placeholder?: string;
|
|
53
29
|
|
|
54
|
-
/**
|
|
55
|
-
* Custom option renderer
|
|
56
|
-
*/
|
|
57
30
|
renderOption?: (
|
|
58
|
-
option:
|
|
31
|
+
option: SelectOption,
|
|
59
32
|
meta: RenderOptionMeta
|
|
60
33
|
) => React.ReactNode;
|
|
61
34
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
renderChipValue?: (option: T) => React.ReactNode;
|
|
35
|
+
renderChipValue?: (
|
|
36
|
+
option: SelectOption
|
|
37
|
+
) => React.ReactNode;
|
|
66
38
|
}
|
|
67
39
|
|
|
68
|
-
|
|
69
|
-
* Select component
|
|
70
|
-
*/
|
|
71
|
-
declare const Select: <
|
|
72
|
-
T extends SelectOption = SelectOption
|
|
73
|
-
>(
|
|
74
|
-
props: SelectProps<T>
|
|
75
|
-
) => React.ReactElement;
|
|
76
|
-
|
|
40
|
+
declare const Select: React.FC<SelectProps>;
|
|
77
41
|
export default Select;
|