dropdowns-js 1.1.7 → 2.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 +226 -7
- package/dist/dropdowns-js.cjs.js +5 -6
- package/dist/dropdowns-js.es.js +469 -1368
- package/dist/types/App.d.ts +2 -0
- package/dist/types/MultiSelectionDropdownObjTest.d.ts +29 -0
- package/dist/types/dropdowns/Dropdown.d.ts +51 -0
- package/dist/types/dropdowns/DropdownObj.d.ts +48 -0
- package/dist/types/dropdowns/MultiSelectionDropdown.d.ts +44 -0
- package/dist/types/dropdowns/MultiSelectionDropdownObj.d.ts +46 -0
- package/dist/types/dropdowns/dropdowns.models.d.ts +24 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/main.d.ts +1 -0
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ export default function MyComponent {
|
|
|
46
46
|
|
|
47
47
|
`valueName` - for dropdowns using object type array input. The name of the field that will be used as the underlying unique value of each dropdown item. e.g. 'code', 'id'.
|
|
48
48
|
|
|
49
|
-
`selectedData` - for multi-selection dropdowns. An array of pre-set selection of options.
|
|
49
|
+
`selectedData` - for multi-selection dropdowns. An array of pre-set selection of options. Optional.
|
|
50
50
|
|
|
51
51
|
`selected` - for single selection dropdowns. A pre-set selected option.
|
|
52
52
|
|
|
@@ -62,6 +62,7 @@ export default function MyComponent {
|
|
|
62
62
|
|
|
63
63
|
## 4. Dropdown usage example
|
|
64
64
|
This dropdown is to be used when the underlying data is a primitive type array.
|
|
65
|
+
***Javascript example***
|
|
65
66
|
```
|
|
66
67
|
import { Dropdown } from 'dropdowns-js';
|
|
67
68
|
import 'dropdowns-js/style.css'; // styles must be imported, otherwise the dropdowns do not display properly.
|
|
@@ -99,7 +100,50 @@ export default function MyComponent() {
|
|
|
99
100
|
);
|
|
100
101
|
}
|
|
101
102
|
```
|
|
103
|
+
|
|
104
|
+
***Typescript example***
|
|
105
|
+
```
|
|
106
|
+
import { Dropdown } from 'dropdowns-js';
|
|
107
|
+
import type { DropdownStyle } from 'dropdowns-js';
|
|
108
|
+
import 'dropdowns-js/style.css'; // styles must be imported, otherwise the dropdowns do not display properly.
|
|
109
|
+
import { useState } from 'react';
|
|
110
|
+
|
|
111
|
+
export default function MyComponent() {
|
|
112
|
+
const [output, setOutput] = useState('');
|
|
113
|
+
const fruits = [ "BANANA" "ORANGE", "NAARJIE", "PEACH", "APPLE" ];
|
|
114
|
+
const myDropdownStyle: DropdownStyle = {color: '#000', backgroundColor: '#66ff66'};
|
|
115
|
+
|
|
116
|
+
/**Respond when the user has chosen a fruit */
|
|
117
|
+
function fruitSelected(selFruit: string) {
|
|
118
|
+
setOutput(selFruit);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<div className='' style={{padding: '5px', backgroundColor: 'green'}}>
|
|
123
|
+
<h1>Dropdown Example</h1>
|
|
124
|
+
<p>Select a fruit</p>
|
|
125
|
+
<div style={{padding: '2px', display: 'flex'}}>
|
|
126
|
+
<label htmlFor='fruits' style={{width: '70px'}}>Fruit</label>
|
|
127
|
+
|
|
128
|
+
<Dropdown
|
|
129
|
+
label={'Fruits'}
|
|
130
|
+
data={fruits}
|
|
131
|
+
sortOrder='asc'
|
|
132
|
+
onItemSelected={fruitSelected}
|
|
133
|
+
selected={"BANANA"}
|
|
134
|
+
dropdownStyle={myDropdownStyle}
|
|
135
|
+
/>
|
|
136
|
+
|
|
137
|
+
</div>
|
|
138
|
+
<p>{output}</p>
|
|
139
|
+
|
|
140
|
+
</div>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
```
|
|
102
144
|
## 5. DropdownObj usage example
|
|
145
|
+
|
|
146
|
+
***Javascript example***
|
|
103
147
|
```
|
|
104
148
|
import { DropdownObj } from 'dropdowns-js';
|
|
105
149
|
import 'dropdowns-js/style.css'; // Not to be left out.
|
|
@@ -108,7 +152,7 @@ import { useState } from 'react';
|
|
|
108
152
|
|
|
109
153
|
export default function MyComponent2() {
|
|
110
154
|
const [output, setOutput] = useState('');
|
|
111
|
-
const drivingCodes = [
|
|
155
|
+
const drivingCodes: DrivingCode[] = [
|
|
112
156
|
{ code: 'A1', description: 'Light Motorcycles' },
|
|
113
157
|
{ code: 'A', description: 'Heavy Motorcycles' },
|
|
114
158
|
{ code: 'B', description: 'Light Vehicles' },
|
|
@@ -132,7 +176,8 @@ export default function MyComponent2() {
|
|
|
132
176
|
<label htmlFor='driving-codes' style={{width: '70px'}}>Driving Codes</label>
|
|
133
177
|
|
|
134
178
|
<DropdownObj
|
|
135
|
-
label='Driving Codes'
|
|
179
|
+
label='Driving Codes'
|
|
180
|
+
data={drivingCodes}
|
|
136
181
|
displayName="description"
|
|
137
182
|
valueName="code"
|
|
138
183
|
sortFields={ ['description'] }
|
|
@@ -146,7 +191,69 @@ export default function MyComponent2() {
|
|
|
146
191
|
);
|
|
147
192
|
}
|
|
148
193
|
```
|
|
149
|
-
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
***Typescript example***
|
|
197
|
+
```
|
|
198
|
+
import { DropdownObj } from 'dropdowns-js';
|
|
199
|
+
import style { DropdownStyle } from 'dropdowns-js';
|
|
200
|
+
import 'dropdowns-js/style.css'; // Not to be left out.
|
|
201
|
+
|
|
202
|
+
import { useState } from 'react';
|
|
203
|
+
|
|
204
|
+
// Model
|
|
205
|
+
interface DrivingCode {
|
|
206
|
+
code: string;
|
|
207
|
+
description: string;
|
|
208
|
+
minAge: Number;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export default function MyComponent2() {
|
|
212
|
+
const [output, setOutput] = useState('');
|
|
213
|
+
const drivingCodes: DrivingCode = [
|
|
214
|
+
{ code: 'A1', description: 'Light Motorcycles' },
|
|
215
|
+
{ code: 'A', description: 'Heavy Motorcycles' },
|
|
216
|
+
{ code: 'B', description: 'Light Vehicles' },
|
|
217
|
+
{ code: 'EB', description: 'Light Articulated' },
|
|
218
|
+
{ code: 'C1', description: 'Heavy Vehicles' },
|
|
219
|
+
{ code: 'C', description: 'Extra Heavy Vehicles' },
|
|
220
|
+
{ code: 'EC1', description: 'Heavy Articulated' },
|
|
221
|
+
{ code: 'EC', description: 'Extra Heavy Articulated' }
|
|
222
|
+
];
|
|
223
|
+
|
|
224
|
+
/**Respond when the user has chosen a driving code */
|
|
225
|
+
function drivingCodeSelected(selDrivingCode: DrivingCode) {
|
|
226
|
+
setOutput(`${selDrivingCode.code} => ${selDrivingCode.description}`);
|
|
227
|
+
}
|
|
228
|
+
const dropdownStyle: DropdownStyle = {color: '#000', backgroundColor: '#66ff66'};
|
|
229
|
+
|
|
230
|
+
return (
|
|
231
|
+
<div className='w3-container' style={{padding: '5px', backgroundColor: 'green'}}>
|
|
232
|
+
<h1>DropdownObj Example</h1>
|
|
233
|
+
<p>Select driving licence code</p>
|
|
234
|
+
<div style={{padding: '2px', display: 'flex'}}>
|
|
235
|
+
<label htmlFor='driving-codes' style={{width: '70px'}}>Driving Codes</label>
|
|
236
|
+
|
|
237
|
+
<DropdownObj
|
|
238
|
+
label='Driving Codes'
|
|
239
|
+
data={drivingCodes}
|
|
240
|
+
displayName="description"
|
|
241
|
+
valueName="code"
|
|
242
|
+
sortFields={ ['description'] }
|
|
243
|
+
onItemSelected={drivingCodeSelected}
|
|
244
|
+
selected={drivingCodes[0]}
|
|
245
|
+
dropdownStyle={dropdownStyle} />
|
|
246
|
+
</div>
|
|
247
|
+
|
|
248
|
+
<p>{output}</p>
|
|
249
|
+
</div>
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## 6. MultiselectionDropdown usage example
|
|
255
|
+
|
|
256
|
+
***Javascript Example***
|
|
150
257
|
```
|
|
151
258
|
import { MultiSelectionDropdown } from 'dropdowns-js';
|
|
152
259
|
import 'dropdowns-js/style.css';
|
|
@@ -187,8 +294,55 @@ export default function MyComponent3() {
|
|
|
187
294
|
);
|
|
188
295
|
}
|
|
189
296
|
```
|
|
297
|
+
|
|
298
|
+
***Typescript Example***
|
|
299
|
+
```
|
|
300
|
+
import { MultiSelectionDropdown } from 'dropdowns-js';
|
|
301
|
+
import type { DropdownStyle, ButtonStyle } from 'dropdown-js';
|
|
302
|
+
import 'dropdowns-js/style.css';
|
|
303
|
+
|
|
304
|
+
import { useState } from 'react';
|
|
305
|
+
|
|
306
|
+
export default function MyComponent3() {
|
|
307
|
+
const [output, setOutput] = useState('');
|
|
308
|
+
const sport = [
|
|
309
|
+
"Motor Racing", "Cycling", "Wrestling", "Kung Fu", "Boxing", "Basket Ball",
|
|
310
|
+
"Rugby", "Cricket", "Running", "Soccer", "Netball", "Hockey"
|
|
311
|
+
];
|
|
312
|
+
|
|
313
|
+
/**Respond when the user has chosen an interest */
|
|
314
|
+
function sportsSelected(selSports: string) {
|
|
315
|
+
// Obtain the selected items.
|
|
316
|
+
const selectedSport = selSports("SPORT").join(", );
|
|
317
|
+
setOutput(selectedSport);
|
|
318
|
+
}
|
|
319
|
+
const dropdownStyle: DropdownStyle = {color: '#000', backgroundColor: '#66ff66'};
|
|
320
|
+
const buttonStyle: ButtonStyle = {color: '#fff', backgroundColor: '#008000'};
|
|
321
|
+
|
|
322
|
+
return (
|
|
323
|
+
<div className='container' style={{padding: '5px', backgroundColor: 'green'}}>
|
|
324
|
+
<h1>MultiSelectionDropdown Example</h1>
|
|
325
|
+
<p>Select an interest, and then your topic</p>
|
|
326
|
+
<div style={{padding: '2px', display: 'flex'}}>
|
|
327
|
+
<label htmlFor='sport' style={{width: '70px'}}>Sport</label>
|
|
190
328
|
|
|
329
|
+
<MultiSelectionDropdown
|
|
330
|
+
label='Sport'
|
|
331
|
+
data={sport}
|
|
332
|
+
onItemsSelected={sportsSelected}
|
|
333
|
+
dropdownStyle={dropdownStyle}
|
|
334
|
+
buttonStyle={buttonStyle} />
|
|
335
|
+
</div>
|
|
336
|
+
|
|
337
|
+
<>{output}</>
|
|
338
|
+
</div>
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
191
343
|
## 7. MultiSelectionDropdownObj usage example
|
|
344
|
+
|
|
345
|
+
***Javascript Example***
|
|
192
346
|
```
|
|
193
347
|
import 'dropdowns-js/style.css';
|
|
194
348
|
import { MultiSelectionDropdownObj } from 'dropdowns-js';
|
|
@@ -213,8 +367,7 @@ export default function MyComponent4() {
|
|
|
213
367
|
function drivCodesSelected(selDrivCode) {
|
|
214
368
|
// Create a string array of driving codes.
|
|
215
369
|
const strSelectedCodes = selDrivCodes.map((drivCode)=> drivCode.code)
|
|
216
|
-
|
|
217
|
-
.join(", ");
|
|
370
|
+
.join(", ");
|
|
218
371
|
setOutput(strSelectedCodes);
|
|
219
372
|
}
|
|
220
373
|
|
|
@@ -246,6 +399,72 @@ export default function MyComponent4() {
|
|
|
246
399
|
);
|
|
247
400
|
}
|
|
248
401
|
```
|
|
402
|
+
|
|
403
|
+
***Typescript Example***
|
|
404
|
+
```
|
|
405
|
+
import 'dropdowns-js/style.css';
|
|
406
|
+
import { MultiSelectionDropdownObj } from 'dropdowns-js';
|
|
407
|
+
|
|
408
|
+
import { useState } from 'react';
|
|
409
|
+
|
|
410
|
+
// Model
|
|
411
|
+
interface DrivingCode {
|
|
412
|
+
code: string;
|
|
413
|
+
description: string;
|
|
414
|
+
minAge: Number;
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
export default function MyComponent4() {
|
|
418
|
+
const [output, setOutput] = useState('');
|
|
419
|
+
const drivingCodes = [
|
|
420
|
+
{ code: 'A1', description: 'Light Motorcycles' },
|
|
421
|
+
{ code: 'A', description: 'Heavy Motorcycles' },
|
|
422
|
+
{ code: 'B', description: 'Light Vehicles' },
|
|
423
|
+
{ code: 'EB', description: 'Light Articulated' },
|
|
424
|
+
{ code: 'C1', description: 'Heavy Vehicles' },
|
|
425
|
+
{ code: 'C', description: 'Extra Heavy Vehicles' },
|
|
426
|
+
{ code: 'EC1', description: 'Heavy Articulated' },
|
|
427
|
+
{ code: 'EC', description: 'Extra Heavy Articulated' }
|
|
428
|
+
];
|
|
429
|
+
|
|
430
|
+
/**Respond when the user has chosen an interest */
|
|
431
|
+
function drivCodesSelected(selDrivCode: DrivingCode) {
|
|
432
|
+
// Create a string array of driving codes.
|
|
433
|
+
const strSelectedCodes = selDrivCodes.map((drivCode)=> drivCode.code)
|
|
434
|
+
.join(", ");
|
|
435
|
+
setOutput(strSelectedCodes);
|
|
436
|
+
}
|
|
437
|
+
const dropdownStyle: DropdownStyle = {color: '#000', backgroundColor: '#66ff66'};
|
|
438
|
+
const buttonStyle: ButtonStyle = {color: '#fff', backgroundColor: '#008000'};
|
|
439
|
+
|
|
440
|
+
return (
|
|
441
|
+
<div className='container' style={{padding: '5px', backgroundColor: 'green'}}>
|
|
442
|
+
<h1>MultiSelectionDropdownObj Example</h1>
|
|
443
|
+
<p>Select an interest, and then your topic</p>
|
|
444
|
+
<div style={{padding: '2px', display: 'flex'}}>
|
|
445
|
+
<label htmlFor={'driving-licence-codes'} style={{width: '100px'}}>Lic. Codes</label>
|
|
446
|
+
<MultiSelectionDropdownObj
|
|
447
|
+
label='Driving Licence Codes'
|
|
448
|
+
data={drivingCodes}
|
|
449
|
+
sortFields={ ['description'] }
|
|
450
|
+
valueName='code'
|
|
451
|
+
displayName='description'
|
|
452
|
+
onItemsSelected={drivCodeSelected}
|
|
453
|
+
isDisabled={false}
|
|
454
|
+
dropdownStyle={dropdownStyle}
|
|
455
|
+
buttonStyle={buttonStyle} />
|
|
456
|
+
</div>
|
|
457
|
+
|
|
458
|
+
{(output.length > 0) &&
|
|
459
|
+
<div style={{ marginTop: '10px', padding: '5px' }}>
|
|
460
|
+
{output}
|
|
461
|
+
</div>
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
</div>
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
```
|
|
249
468
|
|
|
250
469
|
## License
|
|
251
|
-
MIT
|
|
470
|
+
MIT
|
package/dist/dropdowns-js.cjs.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("react/jsx-runtime"),_=require("react");function _e(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var oe={exports:{}},ie={exports:{}},V={};var he;function Ie(){if(he)return V;he=1;var n=typeof Symbol=="function"&&Symbol.for,C=n?Symbol.for("react.element"):60103,L=n?Symbol.for("react.portal"):60106,S=n?Symbol.for("react.fragment"):60107,$=n?Symbol.for("react.strict_mode"):60108,p=n?Symbol.for("react.profiler"):60114,w=n?Symbol.for("react.provider"):60109,m=n?Symbol.for("react.context"):60110,T=n?Symbol.for("react.async_mode"):60111,x=n?Symbol.for("react.concurrent_mode"):60111,v=n?Symbol.for("react.forward_ref"):60112,g=n?Symbol.for("react.suspense"):60113,A=n?Symbol.for("react.suspense_list"):60120,O=n?Symbol.for("react.memo"):60115,F=n?Symbol.for("react.lazy"):60116,D=n?Symbol.for("react.block"):60121,M=n?Symbol.for("react.fundamental"):60117,Z=n?Symbol.for("react.responder"):60118,X=n?Symbol.for("react.scope"):60119;function K(o){if(typeof o=="object"&&o!==null){var J=o.$$typeof;switch(J){case C:switch(o=o.type,o){case T:case x:case S:case p:case $:case g:return o;default:switch(o=o&&o.$$typeof,o){case m:case v:case F:case O:case w:return o;default:return J}}case L:return J}}}function z(o){return K(o)===x}return V.AsyncMode=T,V.ConcurrentMode=x,V.ContextConsumer=m,V.ContextProvider=w,V.Element=C,V.ForwardRef=v,V.Fragment=S,V.Lazy=F,V.Memo=O,V.Portal=L,V.Profiler=p,V.StrictMode=$,V.Suspense=g,V.isAsyncMode=function(o){return z(o)||K(o)===T},V.isConcurrentMode=z,V.isContextConsumer=function(o){return K(o)===m},V.isContextProvider=function(o){return K(o)===w},V.isElement=function(o){return typeof o=="object"&&o!==null&&o.$$typeof===C},V.isForwardRef=function(o){return K(o)===v},V.isFragment=function(o){return K(o)===S},V.isLazy=function(o){return K(o)===F},V.isMemo=function(o){return K(o)===O},V.isPortal=function(o){return K(o)===L},V.isProfiler=function(o){return K(o)===p},V.isStrictMode=function(o){return K(o)===$},V.isSuspense=function(o){return K(o)===g},V.isValidElementType=function(o){return typeof o=="string"||typeof o=="function"||o===S||o===x||o===p||o===$||o===g||o===A||typeof o=="object"&&o!==null&&(o.$$typeof===F||o.$$typeof===O||o.$$typeof===w||o.$$typeof===m||o.$$typeof===v||o.$$typeof===M||o.$$typeof===Z||o.$$typeof===X||o.$$typeof===D)},V.typeOf=K,V}var W={};var ye;function De(){return ye||(ye=1,process.env.NODE_ENV!=="production"&&(function(){var n=typeof Symbol=="function"&&Symbol.for,C=n?Symbol.for("react.element"):60103,L=n?Symbol.for("react.portal"):60106,S=n?Symbol.for("react.fragment"):60107,$=n?Symbol.for("react.strict_mode"):60108,p=n?Symbol.for("react.profiler"):60114,w=n?Symbol.for("react.provider"):60109,m=n?Symbol.for("react.context"):60110,T=n?Symbol.for("react.async_mode"):60111,x=n?Symbol.for("react.concurrent_mode"):60111,v=n?Symbol.for("react.forward_ref"):60112,g=n?Symbol.for("react.suspense"):60113,A=n?Symbol.for("react.suspense_list"):60120,O=n?Symbol.for("react.memo"):60115,F=n?Symbol.for("react.lazy"):60116,D=n?Symbol.for("react.block"):60121,M=n?Symbol.for("react.fundamental"):60117,Z=n?Symbol.for("react.responder"):60118,X=n?Symbol.for("react.scope"):60119;function K(u){return typeof u=="string"||typeof u=="function"||u===S||u===x||u===p||u===$||u===g||u===A||typeof u=="object"&&u!==null&&(u.$$typeof===F||u.$$typeof===O||u.$$typeof===w||u.$$typeof===m||u.$$typeof===v||u.$$typeof===M||u.$$typeof===Z||u.$$typeof===X||u.$$typeof===D)}function z(u){if(typeof u=="object"&&u!==null){var te=u.$$typeof;switch(te){case C:var ne=u.type;switch(ne){case T:case x:case S:case p:case $:case g:return ne;default:var pe=ne&&ne.$$typeof;switch(pe){case m:case v:case F:case O:case w:return pe;default:return te}}case L:return te}}}var o=T,J=x,Q=m,G=w,r=C,i=v,d=S,t=F,a=O,h=L,f=p,E=$,l=g,y=!1;function I(u){return y||(y=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),e(u)||z(u)===T}function e(u){return z(u)===x}function s(u){return z(u)===m}function b(u){return z(u)===w}function R(u){return typeof u=="object"&&u!==null&&u.$$typeof===C}function P(u){return z(u)===v}function N(u){return z(u)===S}function k(u){return z(u)===F}function q(u){return z(u)===O}function Y(u){return z(u)===L}function B(u){return z(u)===p}function U(u){return z(u)===$}function ee(u){return z(u)===g}W.AsyncMode=o,W.ConcurrentMode=J,W.ContextConsumer=Q,W.ContextProvider=G,W.Element=r,W.ForwardRef=i,W.Fragment=d,W.Lazy=t,W.Memo=a,W.Portal=h,W.Profiler=f,W.StrictMode=E,W.Suspense=l,W.isAsyncMode=I,W.isConcurrentMode=e,W.isContextConsumer=s,W.isContextProvider=b,W.isElement=R,W.isForwardRef=P,W.isFragment=N,W.isLazy=k,W.isMemo=q,W.isPortal=Y,W.isProfiler=B,W.isStrictMode=U,W.isSuspense=ee,W.isValidElementType=K,W.typeOf=z})()),W}var me;function Te(){return me||(me=1,process.env.NODE_ENV==="production"?ie.exports=Ie():ie.exports=De()),ie.exports}var se,ge;function ke(){if(ge)return se;ge=1;var n=Object.getOwnPropertySymbols,C=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;function S(p){if(p==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(p)}function $(){try{if(!Object.assign)return!1;var p=new String("abc");if(p[5]="de",Object.getOwnPropertyNames(p)[0]==="5")return!1;for(var w={},m=0;m<10;m++)w["_"+String.fromCharCode(m)]=m;var T=Object.getOwnPropertyNames(w).map(function(v){return w[v]});if(T.join("")!=="0123456789")return!1;var x={};return"abcdefghijklmnopqrst".split("").forEach(function(v){x[v]=v}),Object.keys(Object.assign({},x)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return se=$()?Object.assign:function(p,w){for(var m,T=S(p),x,v=1;v<arguments.length;v++){m=Object(arguments[v]);for(var g in m)C.call(m,g)&&(T[g]=m[g]);if(n){x=n(m);for(var A=0;A<x.length;A++)L.call(m,x[A])&&(T[x[A]]=m[x[A]])}}return T},se}var ae,ve;function fe(){if(ve)return ae;ve=1;var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return ae=n,ae}var ce,be;function Ee(){return be||(be=1,ce=Function.call.bind(Object.prototype.hasOwnProperty)),ce}var le,Se;function Me(){if(Se)return le;Se=1;var n=function(){};if(process.env.NODE_ENV!=="production"){var C=fe(),L={},S=Ee();n=function(p){var w="Warning: "+p;typeof console<"u"&&console.error(w);try{throw new Error(w)}catch{}}}function $(p,w,m,T,x){if(process.env.NODE_ENV!=="production"){for(var v in p)if(S(p,v)){var g;try{if(typeof p[v]!="function"){var A=Error((T||"React class")+": "+m+" type `"+v+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof p[v]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw A.name="Invariant Violation",A}g=p[v](w,v,T,m,null,C)}catch(F){g=F}if(g&&!(g instanceof Error)&&n((T||"React class")+": type specification of "+m+" `"+v+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof g+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),g instanceof Error&&!(g.message in L)){L[g.message]=!0;var O=x?x():"";n("Failed "+m+" type: "+g.message+(O??""))}}}}return $.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(L={})},le=$,le}var ue,we;function qe(){if(we)return ue;we=1;var n=Te(),C=ke(),L=fe(),S=Ee(),$=Me(),p=function(){};process.env.NODE_ENV!=="production"&&(p=function(m){var T="Warning: "+m;typeof console<"u"&&console.error(T);try{throw new Error(T)}catch{}});function w(){return null}return ue=function(m,T){var x=typeof Symbol=="function"&&Symbol.iterator,v="@@iterator";function g(e){var s=e&&(x&&e[x]||e[v]);if(typeof s=="function")return s}var A="<<anonymous>>",O={array:Z("array"),bigint:Z("bigint"),bool:Z("boolean"),func:Z("function"),number:Z("number"),object:Z("object"),string:Z("string"),symbol:Z("symbol"),any:X(),arrayOf:K,element:z(),elementType:o(),instanceOf:J,node:i(),objectOf:G,oneOf:Q,oneOfType:r,shape:t,exact:a};function F(e,s){return e===s?e!==0||1/e===1/s:e!==e&&s!==s}function D(e,s){this.message=e,this.data=s&&typeof s=="object"?s:{},this.stack=""}D.prototype=Error.prototype;function M(e){if(process.env.NODE_ENV!=="production")var s={},b=0;function R(N,k,q,Y,B,U,ee){if(Y=Y||A,U=U||q,ee!==L){if(T){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var te=Y+":"+q;!s[te]&&b<3&&(p("You are manually calling a React.PropTypes validation function for the `"+U+"` prop on `"+Y+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),s[te]=!0,b++)}}return k[q]==null?N?k[q]===null?new D("The "+B+" `"+U+"` is marked as required "+("in `"+Y+"`, but its value is `null`.")):new D("The "+B+" `"+U+"` is marked as required in "+("`"+Y+"`, but its value is `undefined`.")):null:e(k,q,Y,B,U)}var P=R.bind(null,!1);return P.isRequired=R.bind(null,!0),P}function Z(e){function s(b,R,P,N,k,q){var Y=b[R],B=E(Y);if(B!==e){var U=l(Y);return new D("Invalid "+N+" `"+k+"` of type "+("`"+U+"` supplied to `"+P+"`, expected ")+("`"+e+"`."),{expectedType:e})}return null}return M(s)}function X(){return M(w)}function K(e){function s(b,R,P,N,k){if(typeof e!="function")return new D("Property `"+k+"` of component `"+P+"` has invalid PropType notation inside arrayOf.");var q=b[R];if(!Array.isArray(q)){var Y=E(q);return new D("Invalid "+N+" `"+k+"` of type "+("`"+Y+"` supplied to `"+P+"`, expected an array."))}for(var B=0;B<q.length;B++){var U=e(q,B,P,N,k+"["+B+"]",L);if(U instanceof Error)return U}return null}return M(s)}function z(){function e(s,b,R,P,N){var k=s[b];if(!m(k)){var q=E(k);return new D("Invalid "+P+" `"+N+"` of type "+("`"+q+"` supplied to `"+R+"`, expected a single ReactElement."))}return null}return M(e)}function o(){function e(s,b,R,P,N){var k=s[b];if(!n.isValidElementType(k)){var q=E(k);return new D("Invalid "+P+" `"+N+"` of type "+("`"+q+"` supplied to `"+R+"`, expected a single ReactElement type."))}return null}return M(e)}function J(e){function s(b,R,P,N,k){if(!(b[R]instanceof e)){var q=e.name||A,Y=I(b[R]);return new D("Invalid "+N+" `"+k+"` of type "+("`"+Y+"` supplied to `"+P+"`, expected ")+("instance of `"+q+"`."))}return null}return M(s)}function Q(e){if(!Array.isArray(e))return process.env.NODE_ENV!=="production"&&(arguments.length>1?p("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):p("Invalid argument supplied to oneOf, expected an array.")),w;function s(b,R,P,N,k){for(var q=b[R],Y=0;Y<e.length;Y++)if(F(q,e[Y]))return null;var B=JSON.stringify(e,function(ee,u){var te=l(u);return te==="symbol"?String(u):u});return new D("Invalid "+N+" `"+k+"` of value `"+String(q)+"` "+("supplied to `"+P+"`, expected one of "+B+"."))}return M(s)}function G(e){function s(b,R,P,N,k){if(typeof e!="function")return new D("Property `"+k+"` of component `"+P+"` has invalid PropType notation inside objectOf.");var q=b[R],Y=E(q);if(Y!=="object")return new D("Invalid "+N+" `"+k+"` of type "+("`"+Y+"` supplied to `"+P+"`, expected an object."));for(var B in q)if(S(q,B)){var U=e(q,B,P,N,k+"."+B,L);if(U instanceof Error)return U}return null}return M(s)}function r(e){if(!Array.isArray(e))return process.env.NODE_ENV!=="production"&&p("Invalid argument supplied to oneOfType, expected an instance of array."),w;for(var s=0;s<e.length;s++){var b=e[s];if(typeof b!="function")return p("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+y(b)+" at index "+s+"."),w}function R(P,N,k,q,Y){for(var B=[],U=0;U<e.length;U++){var ee=e[U],u=ee(P,N,k,q,Y,L);if(u==null)return null;u.data&&S(u.data,"expectedType")&&B.push(u.data.expectedType)}var te=B.length>0?", expected one of type ["+B.join(", ")+"]":"";return new D("Invalid "+q+" `"+Y+"` supplied to "+("`"+k+"`"+te+"."))}return M(R)}function i(){function e(s,b,R,P,N){return h(s[b])?null:new D("Invalid "+P+" `"+N+"` supplied to "+("`"+R+"`, expected a ReactNode."))}return M(e)}function d(e,s,b,R,P){return new D((e||"React class")+": "+s+" type `"+b+"."+R+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+P+"`.")}function t(e){function s(b,R,P,N,k){var q=b[R],Y=E(q);if(Y!=="object")return new D("Invalid "+N+" `"+k+"` of type `"+Y+"` "+("supplied to `"+P+"`, expected `object`."));for(var B in e){var U=e[B];if(typeof U!="function")return d(P,N,k,B,l(U));var ee=U(q,B,P,N,k+"."+B,L);if(ee)return ee}return null}return M(s)}function a(e){function s(b,R,P,N,k){var q=b[R],Y=E(q);if(Y!=="object")return new D("Invalid "+N+" `"+k+"` of type `"+Y+"` "+("supplied to `"+P+"`, expected `object`."));var B=C({},b[R],e);for(var U in B){var ee=e[U];if(S(e,U)&&typeof ee!="function")return d(P,N,k,U,l(ee));if(!ee)return new D("Invalid "+N+" `"+k+"` key `"+U+"` supplied to `"+P+"`.\nBad object: "+JSON.stringify(b[R],null," ")+`
|
|
2
|
-
|
|
3
|
-
${
|
|
4
|
-
${
|
|
5
|
-
${
|
|
6
|
-
${Q&&`dropdown-js-border ${Q}`}`,style:{...w?{pointerEvents:"none"}:{}},children:[j.jsxs("div",{className:"dropdown-js-input-wrapper dropdown-js-rounded",style:J,children:[j.jsx("div",{children:j.jsx("input",{className:"dropdown-js-input dropdown-js-rounded",id:E.multiSelectionDropdownSearch,name:"multiselectionDropdownSearch",style:J,type:"text",autoComplete:"off",role:"combobox","aria-label":n,"aria-placeholder":`Type to search for ${n}`,"aria-autocomplete":"list","aria-controls":E.multiSelectionDropdown,"aria-expanded":g,"aria-haspopup":"listbox",onChange:l=>r(l),placeholder:`Type to Search for ${n}`,value:F})}),j.jsx("div",{className:"dropdown-js-arrow-container dropdown-js-padding dropdown-js-rounded","aria-expanded":g,"aria-controls":"multiSelectionDropdown","aria-label":`${n} options`,onClick:l=>a(),children:j.jsx("span",{className:"dropdown-js-arrow dropdown-js-padding",children:g?"-":"+"})})]}),j.jsx("div",{className:"dropdown-js-padding dropdown-js-selected-wrapper dropdown-js-selected-container",children:j.jsx("div",{id:E.selectedItems,className:"dropdown-js-selected-items","aria-label":`Selected ${n} options`,"aria-live":"polite",children:X.map(l=>j.jsxs("span",{className:"dropdown-js-padding dropdown-js-rounded","aria-label":`${l}`,style:{...J,margin:"3.5px",marginRight:"0px"},children:[l," ",j.jsx("span",{style:{cursor:"pointer"},"aria-label":`Remove ${l}`,onClick:y=>t(l),children:"×"})]},`${l}`))})}),j.jsxs("div",{className:`dropdown-js-padding dropdown-js-menu dropdown-js-rounded ${!g&&"dropdown-js-hide"}`,style:J,id:E.multiSelectionDropdown,name:"multiSelectionDropdown",role:"listbox","aria-multiselectable":!0,"aria-expanded":g,children:[o.map((l,y)=>j.jsxs("div",{children:[j.jsx("input",{type:"checkbox",name:`${l}Checkbox`,role:"option","aria-label":l,"aria-checked":d(l),style:{cursor:"pointer"},checked:d(l),onChange:I=>i(l),value:l}),j.jsx("label",{style:{marginLeft:"5px"},htmlFor:`${l}`,children:l}),j.jsx("hr",{style:{backgroundColor:J.color,border:"none",height:"0.5px"}})]},`${y}#${l}`)),j.jsx("button",{className:"dropdown-js-padding dropdown-js-round",style:x,"aria-label":`Click to collapse ${n} options`,title:"Done",onClick:l=>h(),type:"button",children:"Done"})]})]})}Pe.propTypes={label:c.string.isRequired,data:c.array.isRequired,sortOrder:c.string,selectedData:c.array,selReset:c.bool,maxNumSelections:c.number,isDisabled:c.bool,onItemsSelected:c.func,dropdownStyle:c.shape({color:c.string.isRequired,backgroundColor:c.string.isRequired,fontSize:c.string,borderColor:c.string}),buttonStyle:c.shape({color:c.string.isRequired,backgroundColor:c.string.isRequired,fontSize:c.string,borderColor:c.string})};exports.Dropdown=Oe;exports.DropdownObj=$e;exports.MultiSelectionDropdown=Pe;exports.MultiSelectionDropdownObj=Re;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),s=require("react");function B(i){return i===null||typeof i!="object"||Object.prototype.toString.call(i)!=="[object Object]"?!1:i.constructor===Object}function H(i){if(!B(i))return[];const n=[{value:i}];let f=0;for(;f<n.length;){const c=n[f];if(B(c.value)){for(const a in c.value){let d=c.path?c.path+"."+a:a;n.push({value:c.value[a],path:d})}c.remove=!0}f++}return n.filter(c=>!c.remove).map(c=>c.path)}function G(i,n,f=void 0){if(!B(i))return;let c=n.split("."),a=i;for(let d=0;d<c.length;d++){let u=c[d];if(!(u in a)||(a=a[u],a===void 0))return f}return c.length===0?f:a}function J(i,n,f="asc"){if(!["asc","desc"].includes(f))throw new Error(`sortDir must be one of ${f}`);const c=f==="desc"?-1:1;return i>n?c:i<n?-c:0}function V(i,n,...f){if(!f||!f.length)throw new Error("comparisonFields not supplied!");if(!B(i)||!B(n))throw new Error("Both obj1 and obj2 must be plain objects.");const c=["","asc","desc"];for(let a=0;a<f.length;a++){const d=f[a].split(" "),u=d[0];let w="";if(d.length>2)throw new Error("Each comparison field must be of the form 'fieldName sortDirection' or 'fieldName'.");if(d.length===2&&(w=d[1]),!c.includes(w))throw new Error("Sort direction must be one of "+c.toString());const $=G(i,u),m=G(n,u),j=["string","number","bigint","boolean"];if(!(j.includes(typeof $)||j.includes(typeof m)||$ instanceof Date||m instanceof Date))throw new Error("Comparison values must be primitive type or Date instance");if(typeof $!=typeof m)throw new Error("Comparison values must be of the same type");const b=w==="desc"?-1:1;if($>m)return b;if($<m)return-b}return 0}function Q({label:i,data:n,sortOrder:f="asc",onItemSelected:c,selected:a,selReset:d=!1,dropdownStyle:u,isDisabled:w=!1}){const $=["number","string","boolean","bigint"];if(n.length>0&&n.some(l=>l===null||!$.includes(typeof l)))throw new Error(`Dropdown items must be one of ${$}`);const m=s.useId(),[j,b]=s.useState(!1),[x,y]=s.useState(""),v=s.useMemo(()=>n.toSorted(k),[n]),g=s.useMemo(()=>{if(x.length===0)return v;const l=x.toUpperCase();return v.filter(p=>p.toUpperCase().includes(l))},[v,x]),[M,D]=s.useState(""),[C,T]=s.useState(),z=s.useMemo(()=>{let l,p=-1;return C&&d===!1?(p=n.findIndex(e=>e===C),p>=0&&(l=n[p])):a&&(p=n.findIndex(e=>e===a),p>=0&&(l=n[p])),p>=0?D(l):D(""),l},[d,a,C]),[I,O]=s.useState(0);s.useEffect(()=>{I>0&&C&&c&&c(z)},[I]);const S=(()=>{const l={backgroundColor:u?.backgroundColor,color:u?.color};return u?.fontSize&&(l.fontSize=u.fontSize),l})(),U=u?.borderColor;function k(l,p){return J(l,p,f)}function N(l){y(l.target.value),D(l.target.value),K()}async function P(l){d||(D(l),y(""),T(l),F(),O(p=>p+1))}function q(){w||(j?F():K())}function F(){b(!1)}function K(){g.length>0&&b(!0)}const L={dropdownSearch:`dropdownSearch-${m}`,dropdown:`dropdown-${m}`};return r.jsxs("div",{className:`dropdown-js dropdown-js-rounded
|
|
2
|
+
${U&&`dropdown-js-border ${U}`}`,style:{...w?{pointerEvents:"none"}:{}},children:[r.jsxs("div",{className:"dropdown-js-input-wrapper dropdown-js-rounded",style:S,children:[r.jsx("input",{id:L.dropdownSearch,name:"dropdownSearch",className:"dropdown-js-input dropdown-js-rounded",autoComplete:"off",type:"text",style:S,role:"combobox","aria-placeholder":`Type to Search for ${i}`,"aria-required":!0,"aria-controls":L.dropdown,"aria-autocomplete":"list","aria-haspopup":"listbox","aria-expanded":j,onChange:l=>N(l),disabled:w,placeholder:`Type to Search for ${i}`,value:M}),r.jsx("div",{className:"dropdown-js-arrow-container dropdown-js-padding dropdown-js-rounded","aria-expanded":j,"aria-controls":"multiSelectionDropdown","aria-label":`${i} options`,onClick:()=>q(),children:r.jsx("span",{className:"dropdown-js-arrow dropdown-js-padding","aria-label":`${i} options`,"aria-expanded":j,children:j?"-":"+"})})]}),r.jsx("ul",{className:`dropdown-js-padding dropdown-js-menu ${!j&&"dropdown-js-hide"}`,id:L.dropdown,role:"listbox","aria-expanded":j,"aria-disabled":w,"aria-label":i,style:{...S,marginTop:"3.5px"},children:g.map((l,p)=>r.jsxs("li",{role:"option","aria-label":l,style:{cursor:"pointer"},onClick:()=>P(l),children:[l,p<g.length-1&&r.jsx("hr",{style:{borderColor:S.color}})]},`${p}#${l}`))})]})}function W({label:i,data:n,sortFields:f,selected:c=null,selReset:a=!1,displayName:d,valueName:u,isDisabled:w=!1,onItemSelected:$,dropdownStyle:m}){s.useState(()=>(n.forEach(e=>{if(!B(e))throw new Error("[Dropdowns-js] Non plain object found");const t=Object.keys(e);if(!t.includes(d))throw new Error(`[Dropdowns-js] displayName field ${d} not found`);if(!t.includes(u))throw new Error(`[Dropdowns-js] valueName field ${u} not found`)}),!0));const j=s.useId(),[b,x]=s.useState(!1),[y,v]=s.useState(""),g=s.useMemo(()=>n.length>0?H(n[0]):[],[n]),M=s.useMemo(()=>n.toSorted(q),[n]),D=s.useMemo(()=>{if(y.length===0)return M;const e=y.toUpperCase();return M.filter(t=>t[d].toUpperCase().includes(e))},[y,M]),[C,T]=s.useState(0);s.useEffect(()=>{C>0&&O&&$&&$(U)},[C]);const[z,I]=s.useState(""),[O,S]=s.useState(null),U=s.useMemo(()=>{let e=null,t=-1;return O&&a===!1?(t=n.findIndex(o=>V(o,O,...g)===0),t>=0&&(e=n[t])):c&&(t=n.findIndex(o=>V(o,c,...g)===0),t>=0&&(e=n[t])),t>=0?I(e[d]):I(""),e},[c,O]),k=(()=>{const e={backgroundColor:m?.backgroundColor,color:m?.color};return m?.fontSize&&(e.fontSize=m?.fontSize),e})(),N=m?.borderColor;async function P(e){v(e.target.value),I(e.target.value),l()}function q(e,t){return V(e,t,...f)}function F(e){a||(S({...e}),v(""),L(),T(t=>t+1))}function K(){b?L():l()}function L(){x(!1)}function l(){D.length>0&&x(!0)}const p={dropdownSearch:`dropdownObjSearch-${j}`,dropdownObj:`dropdownObj-${j}`};return r.jsxs("div",{className:`dropdown-js dropdown-js-rounded
|
|
3
|
+
${N&&`dropdown-js-border ${N}`}`,style:{...w?{pointerEvents:"none"}:{}},children:[r.jsxs("div",{className:"dropdown-js-input-wrapper dropdown-js-rounded",style:k,children:[r.jsx("input",{id:p.dropdownSearch,name:"dropdownObjSearch",className:"dropdown-js-input dropdown-js-rounded",style:k,type:"text",autoComplete:"off",role:"combobox","aria-autocomplete":"list","aria-controls":p.dropdownObj,"aria-expanded":b,"aria-placeholder":`Type to Search for ${i}`,"aria-required":!0,onChange:e=>P(e),disabled:w,placeholder:`Type to Search for ${i}`,value:z}),r.jsx("div",{className:"dropdown-js-arrow-container dropdown-js-padding dropdown-js-rounded","aria-label":`${i} options`,"aria-expanded":b,onClick:()=>K(),children:r.jsx("span",{className:"dropdown-js-arrow dropdown-js-padding",children:b?"-":"+"})})]}),r.jsx("div",{className:`dropdown-js-padding dropdown-js-menu ${!b&&"dropdown-js-hide"}`,id:p.dropdownObj,role:"listbox","aria-expanded":b,style:{...k,marginTop:"3.5px"},children:D.map((e,t)=>r.jsxs("div",{role:"option","aria-label":G(e,d),style:{cursor:"pointer"},onClick:()=>F(e),children:[G(e,d),t<D.length-1&&r.jsx("hr",{style:{borderColor:k.color}})]},`${G(e,u)}${t}`))})]})}function X({label:i,data:n,sortFields:f,selectedData:c=[],selReset:a=!1,maxNumSelections:d,displayName:u,valueName:w,isDisabled:$,onItemsSelected:m,dropdownStyle:j,buttonStyle:b}){s.useState(()=>(n.forEach(o=>{if(!B(o))throw new Error("[Dropdowns-js] Non plain object found");const h=Object.keys(o);if(!h.includes(u))throw new Error(`[Dropdowns-js] displayName field ${u} not found`);if(!h.includes(w))throw new Error(`[Dropdowns-js] valueName field ${w} not found`)}),!0));const x=s.useId(),[y,v]=s.useState(!1),g=s.useMemo(()=>n.length>0?H(n[0]):[],[n]),[M,D]=s.useState(""),C=s.useMemo(()=>n.toSorted(P),[n]),[T,z]=s.useState(0),[I,O]=s.useState([]),S=s.useMemo(()=>{let o=a===!1&&I?[...I]:[...c];return o=o.filter(h=>C.some(E=>V(h,E,...g)===0)),d&&o.length>d&&(o=o.slice(0,d-1)),o.toSorted(P)},[C,c,I]);s.useEffect(()=>{T>0&&I&&m&&m([...S])},[T]);const U=s.useMemo(()=>{const o=M.toUpperCase();return o.length===0?C:C.filter(h=>h[u].toUpperCase().includes(o))},[M,C]),k=(()=>{const o={backgroundColor:j?.backgroundColor,color:j?.color};return j?.fontSize&&(o.fontSize=j?.fontSize),o})(),N=j?.borderColor;function P(o,h){return V(o,h,...f)}function q(o){D(o.target.value),e()}function F(o){a||O(h=>{let E=h?[...h]:[...S];return E.some(A=>V(A,o,...g)===0)?E=E.filter(A=>V(A,o,...g)!==0):(d===null||d&&E.length<d)&&E.push(o),E})}function K(o){return S.some(h=>V(h,o,...g)===0)}function L(o){a||(O(h=>{let E=h?[...h]:[...S];return E=E.filter(A=>V(A,o,...g)!==0),E}),z(h=>h+1))}function l(){y?p():e()}function p(){v(!1),z(o=>o+1)}function e(){U.length>0&&v(!0)}const t={multiSelectionDropdownObjSearch:`multiSelectionDropdownSearch-${x}`,multiSelectionDropdownObj:`multiSelectionDropdown-${x}`,selectedItems:`selectedItems-${x}`};return r.jsxs("div",{className:`dropdown-js dropdown-js-rounded
|
|
4
|
+
${N&&`dropdown-js-border ${N}`}`,style:{...$?{pointerEvents:"none"}:{}},children:[r.jsxs("div",{className:"dropdown-js-input-wrapper dropdown-js-rounded",style:k,children:[r.jsx("div",{children:r.jsx("input",{id:t.multiSelectionDropdownObjSearch,name:"multiSelectionDropdownObjSearch",className:"dropdown-js-input dropdown-js-rounded",style:k,"aria-label":i,"aria-autocomplete":"list","aria-controls":t.multiSelectionDropdownObj,role:"combobox","aria-expanded":y,"aria-haspopup":"listbox",type:"text",autoComplete:"off","aria-placeholder":`Type to Search for ${i}`,onChange:o=>q(o),placeholder:`Type to Search for ${i}`,value:M})}),r.jsx("div",{className:"dropdown-js-arrow-container dropdown-js-padding dropdown-js-rounded","aria-expanded":y,"aria-controls":"multiSelectionDropdownObj","aria-label":`${i} options`,onClick:()=>l(),children:r.jsx("span",{className:"dropdown-js-arrow dropdown-js-padding",children:y?"-":"+"})})]}),r.jsx("div",{className:"dropdown-js-padding dropdown-js-selected-wrapper dropdown-js-selected-container",children:r.jsx("div",{id:t.selectedItems,className:"dropdown-js-selected-items","aria-label":`Selected ${i} options`,"aria-multiselectable":!0,"aria-live":"polite",children:S.map(o=>r.jsxs("span",{className:"dropdown-js-padding dropdown-js-rounded","aria-label":`${o[u]}`,style:{...k,margin:"3.5px",marginRight:"0px"},children:[o[u]," ",r.jsx("span",{className:"dropdown-js-padding",style:{cursor:"pointer"},"aria-label":`Remove ${o[u]}`,onClick:()=>L(o),children:"×"})]},`${o[w]}${o[u]}`))})}),r.jsxs("div",{className:`dropdown-js-padding dropdown-js-menu dropdown-js-rounded ${!y&&"dropdown-js-hide"}`,style:k,id:t.multiSelectionDropdownObj,role:"listbox","aria-multiselectable":!0,"aria-expanded":y,children:[U.map(o=>r.jsxs("div",{children:[r.jsx("input",{id:`${o[w]}Checkbox`,type:"checkbox",name:`${o[u]}Checkbox`,role:"option","aria-label":`${o[u]}`,"aria-checked":K(o),style:{cursor:"pointer"},checked:K(o),onChange:()=>F(o),value:o[w]}),r.jsx("label",{style:{marginLeft:"5px"},htmlFor:`${o[w]}`,children:o[u]}),r.jsx("hr",{style:{backgroundColor:k.color,border:"none",height:"0.5px"}})]},`${o[w]}${o[u]}`)),r.jsx("button",{className:"dropdown-js-padding dropdown-js-round",style:b,title:"Done","aria-label":`Close ${i} options`,onClick:()=>p(),type:"button",children:"Done"})]})]})}function Y({label:i,data:n,sortOrder:f="asc",selectedData:c=[],selReset:a=!1,maxNumSelections:d,isDisabled:u=!1,onItemsSelected:w,dropdownStyle:$,buttonStyle:m}){const j=["number","string","boolean","bigint"];if(n.length>0&&n.some(e=>e===null&&!j.includes(typeof e)))throw new Error(`Dropdown items must be one of ${j}`);const b=s.useId(),[x,y]=s.useState(!1),v=s.useMemo(()=>n.toSorted(k),[n]),[g,M]=s.useState(""),[D,C]=s.useState([]),T=s.useMemo(()=>{let e=[];return a===!1&&D?e=[...D]:e=[...c],e=e.filter(t=>v.some(o=>o===t)),d&&e.length>d&&(e=e.slice(0,d-1)),e.toSorted(k)},[a,v,c,D]),[z,I]=s.useState(0);s.useEffect(()=>{z>0&&w&&D!==null&&w([...T])},[z]);const O=s.useMemo(()=>g.length===0?v:v.filter(e=>e.toUpperCase().includes(g.toUpperCase())),[g,v]),S=$,U=$?.borderColor;function k(e,t){return J(e,t,f)}function N(e){const t=e.target.value;M(t),l()}function P(e){a||C(t=>{let o=t?[...t]:[...T];return o.some(h=>h===e)?o=o.filter(h=>h!==e):(d===null||d&&o.length<d)&&o.push(e),o})}function q(e){return T.some(t=>t===e)}function F(e){a||(C(t=>(t?[...t]:[...T]).filter(h=>h!==e)),I(t=>t+1))}function K(){x?L():l()}function L(){y(!1),I(e=>e+1)}function l(){O.length>0&&y(!0)}const p={multiSelectionDropdownSearch:`multiSelectionDropdown-${b}`,multiSelectionDropdown:`multiSelectionDropdown-${b}`,selectedItems:`selectedItems-${b}`};return r.jsxs("div",{className:`dropdown-js dropdown-js-rounded
|
|
5
|
+
${U&&`dropdown-js-border ${U}`}`,style:{...u?{pointerEvents:"none"}:{}},children:[r.jsxs("div",{className:"dropdown-js-input-wrapper dropdown-js-rounded",style:S,children:[r.jsx("div",{children:r.jsx("input",{className:"dropdown-js-input dropdown-js-rounded",id:p.multiSelectionDropdownSearch,name:"multiselectionDropdownSearch",style:S,type:"text",autoComplete:"off",role:"combobox","aria-label":i,"aria-placeholder":`Type to search for ${i}`,"aria-autocomplete":"list","aria-controls":p.multiSelectionDropdown,"aria-expanded":x,"aria-haspopup":"listbox",onChange:N,placeholder:`Type to Search for ${i}`,value:g})}),r.jsx("div",{className:"dropdown-js-arrow-container dropdown-js-padding dropdown-js-rounded","aria-expanded":x,"aria-controls":"multiSelectionDropdown","aria-label":`${i} options`,onClick:()=>K(),children:r.jsx("span",{className:"dropdown-js-arrow dropdown-js-padding",children:x?"-":"+"})})]}),r.jsx("div",{className:"dropdown-js-padding dropdown-js-selected-wrapper dropdown-js-selected-container",children:r.jsx("div",{id:p.selectedItems,className:"dropdown-js-selected-items","aria-label":`Selected ${i} options`,"aria-live":"polite",children:T.map(e=>r.jsxs("span",{className:"dropdown-js-padding dropdown-js-rounded","aria-label":`${e}`,style:{...S,margin:"3.5px",marginRight:"0px"},children:[e," ",r.jsx("span",{style:{cursor:"pointer"},"aria-label":`Remove ${e}`,onClick:()=>F(e),children:"×"})]},`${e}`))})}),r.jsxs("div",{className:`dropdown-js-padding dropdown-js-menu dropdown-js-rounded ${!x&&"dropdown-js-hide"}`,style:S,id:p.multiSelectionDropdown,role:"listbox","aria-multiselectable":!0,"aria-expanded":x,children:[O.map((e,t)=>r.jsxs("div",{children:[r.jsx("input",{type:"checkbox",name:`${e}Checkbox`,role:"option","aria-label":e,"aria-checked":q(e),style:{cursor:"pointer"},checked:q(e),onChange:()=>P(e),value:e}),r.jsx("label",{style:{marginLeft:"5px"},htmlFor:`${e}`,children:e}),r.jsx("hr",{style:{backgroundColor:S.color,border:"none",height:"0.5px"}})]},`${t}#${e}`)),r.jsx("button",{className:"dropdown-js-padding dropdown-js-round",style:m,"aria-label":`Click to collapse ${i} options`,title:"Done",onClick:()=>L(),type:"button",children:"Done"})]})]})}exports.Dropdown=Q;exports.DropdownObj=W;exports.MultiSelectionDropdown=Y;exports.MultiSelectionDropdownObj=X;
|