dropdowns-js 1.1.6 → 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 +229 -8
- package/dist/dropdowns-js.cjs.js +5 -6
- package/dist/dropdowns-js.es.js +472 -1380
- 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,10 +46,12 @@ 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
|
+
|
|
53
|
+
`selReset` - optional. When set to true, selected item(s) can be set only by the parent component, via selected (single selection dropddowns) or selectedData (multi-selection dropdowns), and the user cannot make a selection/deselection.
|
|
54
|
+
|
|
53
55
|
`onItemSelected` - for single selection dropdowns. A function to call when the user has made a selection.
|
|
54
56
|
|
|
55
57
|
`onItemsSelected` - for multi-selection dropdowns. A function to call when the user has made a selection. Or removed items from their selection.
|
|
@@ -60,6 +62,7 @@ export default function MyComponent {
|
|
|
60
62
|
|
|
61
63
|
## 4. Dropdown usage example
|
|
62
64
|
This dropdown is to be used when the underlying data is a primitive type array.
|
|
65
|
+
***Javascript example***
|
|
63
66
|
```
|
|
64
67
|
import { Dropdown } from 'dropdowns-js';
|
|
65
68
|
import 'dropdowns-js/style.css'; // styles must be imported, otherwise the dropdowns do not display properly.
|
|
@@ -97,7 +100,50 @@ export default function MyComponent() {
|
|
|
97
100
|
);
|
|
98
101
|
}
|
|
99
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
|
+
```
|
|
100
144
|
## 5. DropdownObj usage example
|
|
145
|
+
|
|
146
|
+
***Javascript example***
|
|
101
147
|
```
|
|
102
148
|
import { DropdownObj } from 'dropdowns-js';
|
|
103
149
|
import 'dropdowns-js/style.css'; // Not to be left out.
|
|
@@ -106,7 +152,7 @@ import { useState } from 'react';
|
|
|
106
152
|
|
|
107
153
|
export default function MyComponent2() {
|
|
108
154
|
const [output, setOutput] = useState('');
|
|
109
|
-
const drivingCodes = [
|
|
155
|
+
const drivingCodes: DrivingCode[] = [
|
|
110
156
|
{ code: 'A1', description: 'Light Motorcycles' },
|
|
111
157
|
{ code: 'A', description: 'Heavy Motorcycles' },
|
|
112
158
|
{ code: 'B', description: 'Light Vehicles' },
|
|
@@ -130,7 +176,8 @@ export default function MyComponent2() {
|
|
|
130
176
|
<label htmlFor='driving-codes' style={{width: '70px'}}>Driving Codes</label>
|
|
131
177
|
|
|
132
178
|
<DropdownObj
|
|
133
|
-
label='Driving Codes'
|
|
179
|
+
label='Driving Codes'
|
|
180
|
+
data={drivingCodes}
|
|
134
181
|
displayName="description"
|
|
135
182
|
valueName="code"
|
|
136
183
|
sortFields={ ['description'] }
|
|
@@ -144,7 +191,69 @@ export default function MyComponent2() {
|
|
|
144
191
|
);
|
|
145
192
|
}
|
|
146
193
|
```
|
|
147
|
-
|
|
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***
|
|
148
257
|
```
|
|
149
258
|
import { MultiSelectionDropdown } from 'dropdowns-js';
|
|
150
259
|
import 'dropdowns-js/style.css';
|
|
@@ -185,8 +294,55 @@ export default function MyComponent3() {
|
|
|
185
294
|
);
|
|
186
295
|
}
|
|
187
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>
|
|
328
|
+
|
|
329
|
+
<MultiSelectionDropdown
|
|
330
|
+
label='Sport'
|
|
331
|
+
data={sport}
|
|
332
|
+
onItemsSelected={sportsSelected}
|
|
333
|
+
dropdownStyle={dropdownStyle}
|
|
334
|
+
buttonStyle={buttonStyle} />
|
|
335
|
+
</div>
|
|
188
336
|
|
|
337
|
+
<>{output}</>
|
|
338
|
+
</div>
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
189
343
|
## 7. MultiSelectionDropdownObj usage example
|
|
344
|
+
|
|
345
|
+
***Javascript Example***
|
|
190
346
|
```
|
|
191
347
|
import 'dropdowns-js/style.css';
|
|
192
348
|
import { MultiSelectionDropdownObj } from 'dropdowns-js';
|
|
@@ -211,8 +367,7 @@ export default function MyComponent4() {
|
|
|
211
367
|
function drivCodesSelected(selDrivCode) {
|
|
212
368
|
// Create a string array of driving codes.
|
|
213
369
|
const strSelectedCodes = selDrivCodes.map((drivCode)=> drivCode.code)
|
|
214
|
-
|
|
215
|
-
.join(", ");
|
|
370
|
+
.join(", ");
|
|
216
371
|
setOutput(strSelectedCodes);
|
|
217
372
|
}
|
|
218
373
|
|
|
@@ -244,6 +399,72 @@ export default function MyComponent4() {
|
|
|
244
399
|
);
|
|
245
400
|
}
|
|
246
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
|
+
```
|
|
247
468
|
|
|
248
469
|
## License
|
|
249
|
-
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 w=require("react/jsx-runtime"),M=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,O=n?Symbol.for("react.element"):60103,z=n?Symbol.for("react.portal"):60106,b=n?Symbol.for("react.fragment"):60107,T=n?Symbol.for("react.strict_mode"):60108,p=n?Symbol.for("react.profiler"):60114,S=n?Symbol.for("react.provider"):60109,m=n?Symbol.for("react.context"):60110,g=n?Symbol.for("react.async_mode"):60111,C=n?Symbol.for("react.concurrent_mode"):60111,y=n?Symbol.for("react.forward_ref"):60112,j=n?Symbol.for("react.suspense"):60113,E=n?Symbol.for("react.suspense_list"):60120,_=n?Symbol.for("react.memo"):60115,U=n?Symbol.for("react.lazy"):60116,A=n?Symbol.for("react.block"):60121,I=n?Symbol.for("react.fundamental"):60117,F=n?Symbol.for("react.responder"):60118,G=n?Symbol.for("react.scope"):60119;function k(s){if(typeof s=="object"&&s!==null){var H=s.$$typeof;switch(H){case O:switch(s=s.type,s){case g:case C:case b:case p:case T:case j:return s;default:switch(s=s&&s.$$typeof,s){case m:case y:case U:case _:case S:return s;default:return H}}case z:return H}}}function P(s){return k(s)===C}return V.AsyncMode=g,V.ConcurrentMode=C,V.ContextConsumer=m,V.ContextProvider=S,V.Element=O,V.ForwardRef=y,V.Fragment=b,V.Lazy=U,V.Memo=_,V.Portal=z,V.Profiler=p,V.StrictMode=T,V.Suspense=j,V.isAsyncMode=function(s){return P(s)||k(s)===g},V.isConcurrentMode=P,V.isContextConsumer=function(s){return k(s)===m},V.isContextProvider=function(s){return k(s)===S},V.isElement=function(s){return typeof s=="object"&&s!==null&&s.$$typeof===O},V.isForwardRef=function(s){return k(s)===y},V.isFragment=function(s){return k(s)===b},V.isLazy=function(s){return k(s)===U},V.isMemo=function(s){return k(s)===_},V.isPortal=function(s){return k(s)===z},V.isProfiler=function(s){return k(s)===p},V.isStrictMode=function(s){return k(s)===T},V.isSuspense=function(s){return k(s)===j},V.isValidElementType=function(s){return typeof s=="string"||typeof s=="function"||s===b||s===C||s===p||s===T||s===j||s===E||typeof s=="object"&&s!==null&&(s.$$typeof===U||s.$$typeof===_||s.$$typeof===S||s.$$typeof===m||s.$$typeof===y||s.$$typeof===I||s.$$typeof===F||s.$$typeof===G||s.$$typeof===A)},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,O=n?Symbol.for("react.element"):60103,z=n?Symbol.for("react.portal"):60106,b=n?Symbol.for("react.fragment"):60107,T=n?Symbol.for("react.strict_mode"):60108,p=n?Symbol.for("react.profiler"):60114,S=n?Symbol.for("react.provider"):60109,m=n?Symbol.for("react.context"):60110,g=n?Symbol.for("react.async_mode"):60111,C=n?Symbol.for("react.concurrent_mode"):60111,y=n?Symbol.for("react.forward_ref"):60112,j=n?Symbol.for("react.suspense"):60113,E=n?Symbol.for("react.suspense_list"):60120,_=n?Symbol.for("react.memo"):60115,U=n?Symbol.for("react.lazy"):60116,A=n?Symbol.for("react.block"):60121,I=n?Symbol.for("react.fundamental"):60117,F=n?Symbol.for("react.responder"):60118,G=n?Symbol.for("react.scope"):60119;function k(d){return typeof d=="string"||typeof d=="function"||d===b||d===C||d===p||d===T||d===j||d===E||typeof d=="object"&&d!==null&&(d.$$typeof===U||d.$$typeof===_||d.$$typeof===S||d.$$typeof===m||d.$$typeof===y||d.$$typeof===I||d.$$typeof===F||d.$$typeof===G||d.$$typeof===A)}function P(d){if(typeof d=="object"&&d!==null){var te=d.$$typeof;switch(te){case O:var ne=d.type;switch(ne){case g:case C:case b:case p:case T:case j:return ne;default:var pe=ne&&ne.$$typeof;switch(pe){case m:case y:case U:case _:case S:return pe;default:return te}}case z:return te}}}var s=g,H=C,K=m,J=S,t=O,o=y,l=b,r=U,i=_,f=z,c=p,v=T,h=j,X=!1;function Q(d){return X||(X=!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(d)||P(d)===g}function e(d){return P(d)===C}function a(d){return P(d)===m}function x(d){return P(d)===S}function R(d){return typeof d=="object"&&d!==null&&d.$$typeof===O}function $(d){return P(d)===y}function N(d){return P(d)===b}function D(d){return P(d)===U}function q(d){return P(d)===_}function L(d){return P(d)===z}function Z(d){return P(d)===p}function Y(d){return P(d)===T}function ee(d){return P(d)===j}W.AsyncMode=s,W.ConcurrentMode=H,W.ContextConsumer=K,W.ContextProvider=J,W.Element=t,W.ForwardRef=o,W.Fragment=l,W.Lazy=r,W.Memo=i,W.Portal=f,W.Profiler=c,W.StrictMode=v,W.Suspense=h,W.isAsyncMode=Q,W.isConcurrentMode=e,W.isContextConsumer=a,W.isContextProvider=x,W.isElement=R,W.isForwardRef=$,W.isFragment=N,W.isLazy=D,W.isMemo=q,W.isPortal=L,W.isProfiler=Z,W.isStrictMode=Y,W.isSuspense=ee,W.isValidElementType=k,W.typeOf=P})()),W}var ge;function Te(){return ge||(ge=1,process.env.NODE_ENV==="production"?ie.exports=Ie():ie.exports=De()),ie.exports}var se,me;function Me(){if(me)return se;me=1;var n=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;function b(p){if(p==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(p)}function T(){try{if(!Object.assign)return!1;var p=new String("abc");if(p[5]="de",Object.getOwnPropertyNames(p)[0]==="5")return!1;for(var S={},m=0;m<10;m++)S["_"+String.fromCharCode(m)]=m;var g=Object.getOwnPropertyNames(S).map(function(y){return S[y]});if(g.join("")!=="0123456789")return!1;var C={};return"abcdefghijklmnopqrst".split("").forEach(function(y){C[y]=y}),Object.keys(Object.assign({},C)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return se=T()?Object.assign:function(p,S){for(var m,g=b(p),C,y=1;y<arguments.length;y++){m=Object(arguments[y]);for(var j in m)O.call(m,j)&&(g[j]=m[j]);if(n){C=n(m);for(var E=0;E<C.length;E++)z.call(m,C[E])&&(g[C[E]]=m[C[E]])}}return g},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 ue,we;function ke(){if(we)return ue;we=1;var n=function(){};if(process.env.NODE_ENV!=="production"){var O=fe(),z={},b=Ee();n=function(p){var S="Warning: "+p;typeof console<"u"&&console.error(S);try{throw new Error(S)}catch{}}}function T(p,S,m,g,C){if(process.env.NODE_ENV!=="production"){for(var y in p)if(b(p,y)){var j;try{if(typeof p[y]!="function"){var E=Error((g||"React class")+": "+m+" type `"+y+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof p[y]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw E.name="Invariant Violation",E}j=p[y](S,y,g,m,null,O)}catch(U){j=U}if(j&&!(j instanceof Error)&&n((g||"React class")+": type specification of "+m+" `"+y+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof j+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),j instanceof Error&&!(j.message in z)){z[j.message]=!0;var _=C?C():"";n("Failed "+m+" type: "+j.message+(_??""))}}}}return T.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(z={})},ue=T,ue}var le,Se;function qe(){if(Se)return le;Se=1;var n=Te(),O=Me(),z=fe(),b=Ee(),T=ke(),p=function(){};process.env.NODE_ENV!=="production"&&(p=function(m){var g="Warning: "+m;typeof console<"u"&&console.error(g);try{throw new Error(g)}catch{}});function S(){return null}return le=function(m,g){var C=typeof Symbol=="function"&&Symbol.iterator,y="@@iterator";function j(e){var a=e&&(C&&e[C]||e[y]);if(typeof a=="function")return a}var E="<<anonymous>>",_={array:F("array"),bigint:F("bigint"),bool:F("boolean"),func:F("function"),number:F("number"),object:F("object"),string:F("string"),symbol:F("symbol"),any:G(),arrayOf:k,element:P(),elementType:s(),instanceOf:H,node:o(),objectOf:J,oneOf:K,oneOfType:t,shape:r,exact:i};function U(e,a){return e===a?e!==0||1/e===1/a:e!==e&&a!==a}function A(e,a){this.message=e,this.data=a&&typeof a=="object"?a:{},this.stack=""}A.prototype=Error.prototype;function I(e){if(process.env.NODE_ENV!=="production")var a={},x=0;function R(N,D,q,L,Z,Y,ee){if(L=L||E,Y=Y||q,ee!==z){if(g){var d=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 d.name="Invariant Violation",d}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var te=L+":"+q;!a[te]&&x<3&&(p("You are manually calling a React.PropTypes validation function for the `"+Y+"` prop on `"+L+"`. 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."),a[te]=!0,x++)}}return D[q]==null?N?D[q]===null?new A("The "+Z+" `"+Y+"` is marked as required "+("in `"+L+"`, but its value is `null`.")):new A("The "+Z+" `"+Y+"` is marked as required in "+("`"+L+"`, but its value is `undefined`.")):null:e(D,q,L,Z,Y)}var $=R.bind(null,!1);return $.isRequired=R.bind(null,!0),$}function F(e){function a(x,R,$,N,D,q){var L=x[R],Z=v(L);if(Z!==e){var Y=h(L);return new A("Invalid "+N+" `"+D+"` of type "+("`"+Y+"` supplied to `"+$+"`, expected ")+("`"+e+"`."),{expectedType:e})}return null}return I(a)}function G(){return I(S)}function k(e){function a(x,R,$,N,D){if(typeof e!="function")return new A("Property `"+D+"` of component `"+$+"` has invalid PropType notation inside arrayOf.");var q=x[R];if(!Array.isArray(q)){var L=v(q);return new A("Invalid "+N+" `"+D+"` of type "+("`"+L+"` supplied to `"+$+"`, expected an array."))}for(var Z=0;Z<q.length;Z++){var Y=e(q,Z,$,N,D+"["+Z+"]",z);if(Y instanceof Error)return Y}return null}return I(a)}function P(){function e(a,x,R,$,N){var D=a[x];if(!m(D)){var q=v(D);return new A("Invalid "+$+" `"+N+"` of type "+("`"+q+"` supplied to `"+R+"`, expected a single ReactElement."))}return null}return I(e)}function s(){function e(a,x,R,$,N){var D=a[x];if(!n.isValidElementType(D)){var q=v(D);return new A("Invalid "+$+" `"+N+"` of type "+("`"+q+"` supplied to `"+R+"`, expected a single ReactElement type."))}return null}return I(e)}function H(e){function a(x,R,$,N,D){if(!(x[R]instanceof e)){var q=e.name||E,L=Q(x[R]);return new A("Invalid "+N+" `"+D+"` of type "+("`"+L+"` supplied to `"+$+"`, expected ")+("instance of `"+q+"`."))}return null}return I(a)}function K(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.")),S;function a(x,R,$,N,D){for(var q=x[R],L=0;L<e.length;L++)if(U(q,e[L]))return null;var Z=JSON.stringify(e,function(ee,d){var te=h(d);return te==="symbol"?String(d):d});return new A("Invalid "+N+" `"+D+"` of value `"+String(q)+"` "+("supplied to `"+$+"`, expected one of "+Z+"."))}return I(a)}function J(e){function a(x,R,$,N,D){if(typeof e!="function")return new A("Property `"+D+"` of component `"+$+"` has invalid PropType notation inside objectOf.");var q=x[R],L=v(q);if(L!=="object")return new A("Invalid "+N+" `"+D+"` of type "+("`"+L+"` supplied to `"+$+"`, expected an object."));for(var Z in q)if(b(q,Z)){var Y=e(q,Z,$,N,D+"."+Z,z);if(Y instanceof Error)return Y}return null}return I(a)}function t(e){if(!Array.isArray(e))return process.env.NODE_ENV!=="production"&&p("Invalid argument supplied to oneOfType, expected an instance of array."),S;for(var a=0;a<e.length;a++){var x=e[a];if(typeof x!="function")return p("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+X(x)+" at index "+a+"."),S}function R($,N,D,q,L){for(var Z=[],Y=0;Y<e.length;Y++){var ee=e[Y],d=ee($,N,D,q,L,z);if(d==null)return null;d.data&&b(d.data,"expectedType")&&Z.push(d.data.expectedType)}var te=Z.length>0?", expected one of type ["+Z.join(", ")+"]":"";return new A("Invalid "+q+" `"+L+"` supplied to "+("`"+D+"`"+te+"."))}return I(R)}function o(){function e(a,x,R,$,N){return f(a[x])?null:new A("Invalid "+$+" `"+N+"` supplied to "+("`"+R+"`, expected a ReactNode."))}return I(e)}function l(e,a,x,R,$){return new A((e||"React class")+": "+a+" type `"+x+"."+R+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+$+"`.")}function r(e){function a(x,R,$,N,D){var q=x[R],L=v(q);if(L!=="object")return new A("Invalid "+N+" `"+D+"` of type `"+L+"` "+("supplied to `"+$+"`, expected `object`."));for(var Z in e){var Y=e[Z];if(typeof Y!="function")return l($,N,D,Z,h(Y));var ee=Y(q,Z,$,N,D+"."+Z,z);if(ee)return ee}return null}return I(a)}function i(e){function a(x,R,$,N,D){var q=x[R],L=v(q);if(L!=="object")return new A("Invalid "+N+" `"+D+"` of type `"+L+"` "+("supplied to `"+$+"`, expected `object`."));var Z=O({},x[R],e);for(var Y in Z){var ee=e[Y];if(b(e,Y)&&typeof ee!="function")return l($,N,D,Y,h(ee));if(!ee)return new A("Invalid "+N+" `"+D+"` key `"+Y+"` supplied to `"+$+"`.\nBad object: "+JSON.stringify(x[R],null," ")+`
|
|
2
|
-
|
|
3
|
-
${
|
|
4
|
-
${
|
|
5
|
-
${
|
|
6
|
-
${s&&`dropdown-js-border ${s}`}`,style:{...p?{pointerEvents:"none"}:{}},children:[w.jsxs("div",{className:"dropdown-js-input-wrapper dropdown-js-rounded",style:P,children:[w.jsx("div",{children:w.jsx("input",{className:"dropdown-js-input dropdown-js-rounded",id:f.multiSelectionDropdownSearch,name:"multiselectionDropdownSearch",style:P,type:"text",autoComplete:"off",role:"combobox","aria-label":n,"aria-placeholder":`Type to search for ${n}`,"aria-autocomplete":"list","aria-controls":f.multiSelectionDropdown,"aria-expanded":y,"aria-haspopup":"listbox",onChange:c=>K(c),placeholder:`Type to Search for ${n}`,value:_})}),w.jsx("div",{className:"dropdown-js-arrow-container dropdown-js-padding dropdown-js-rounded","aria-expanded":y,"aria-controls":"multiSelectionDropdown","aria-label":`${n} options`,onClick:c=>l(),children:w.jsx("span",{className:"dropdown-js-arrow dropdown-js-padding",children:y?"-":"+"})})]}),w.jsx("div",{className:"dropdown-js-padding dropdown-js-selected-wrapper dropdown-js-selected-container",children:w.jsx("div",{id:f.selectedItems,className:"dropdown-js-selected-items","aria-label":`Selected ${n} options`,"aria-live":"polite",children:F.map(c=>w.jsxs("span",{className:"dropdown-js-padding dropdown-js-rounded","aria-label":`${c}`,style:{...P,margin:"3.5px",marginRight:"0px"},children:[c," ",w.jsx("span",{style:{cursor:"pointer"},"aria-label":`Remove ${c}`,onClick:v=>o(c),children:"×"})]},`${c}`))})}),w.jsxs("div",{className:`dropdown-js-padding dropdown-js-menu dropdown-js-rounded ${!y&&"dropdown-js-hide"}`,style:P,id:f.multiSelectionDropdown,name:"multiSelectionDropdown",role:"listbox","aria-multiselectable":!0,"aria-expanded":y,children:[k.map((c,v)=>w.jsxs("div",{children:[w.jsx("input",{type:"checkbox",name:`${c}Checkbox`,role:"option","aria-label":c,"aria-checked":t(c),style:{cursor:"pointer"},checked:t(c),onChange:h=>J(c),value:c}),w.jsx("label",{style:{marginLeft:"5px"},htmlFor:`${c}`,children:c}),w.jsx("hr",{style:{backgroundColor:P.color,border:"none",height:"0.5px"}})]},`${v}#${c}`)),w.jsx("button",{className:"dropdown-js-padding dropdown-js-round",style:g,"aria-label":`Click to collapse ${n} options`,title:"Done",disabled:k.length===0,onClick:c=>r(),type:"button",children:"Done"})]})]})}Pe.propTypes={label:u.string.isRequired,data:u.array.isRequired,sortOrder:u.string,selectedData:u.array,maxNumSelections:u.number,isDisabled:u.bool,onItemsSelected:u.func,dropdownStyle:u.shape({color:u.string.isRequired,backgroundColor:u.string.isRequired,fontSize:u.string,borderColor:u.string}),buttonStyle:u.shape({color:u.string.isRequired,backgroundColor:u.string.isRequired,fontSize:u.string,borderColor:u.string})};exports.Dropdown=Oe;exports.DropdownObj=Re;exports.MultiSelectionDropdown=Pe;exports.MultiSelectionDropdownObj=$e;
|
|
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;
|