playbook_ui 13.8.0.pre.alpha.PLAY962SingleSelect1246 → 13.8.0.pre.alpha.play845allkitsbytypes1254

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91dabc0c37f4b0d7c83e0c9728a4db6d2eb34fe92c387934cab037fd18025e2a
4
- data.tar.gz: ab8ea303f33c2cc6e47d9af314ccf15e41fad54fdfa1e743a00cd1ec5b3e41f5
3
+ metadata.gz: 8962b1f5b63702a09832038c0a78be9da51e80bffc9386e15e6540059ba8ccd4
4
+ data.tar.gz: 58c742ec7b33680a19c03e94a4d2fae092d2f43f951baac8bc024ce0079cbe78
5
5
  SHA512:
6
- metadata.gz: dd3547fb3e5ec0242dd18e1ad45c4bbf075adc932f33befa20f5cb6874b63bd90df323661d58330a55ea0f6e4d03460c9d8ac888c5e887cb28cef8c66f208289
7
- data.tar.gz: 44206940d57a0f6dd4d875dac195ade688a6aaff286ae489f9e6ee70987355410a8d397d66f3d06237adb5b49df2e9965a72f63c2245ab78c5b94692e8703f81
6
+ metadata.gz: d142a90639215ce17982e9535ef88069b48e510059261b160dbfe07a65ab8c926e81066a1f07251d48a6bb25cee2b3d2ba686327fe9ebc11b744f521c725b92d
7
+ data.tar.gz: 4d77bf674d1fe3fdb4645c7b4b9ca3be262fe5bafb28e6839c88cebcaf4a0110dc0522b3775d72f7ac93e1b8857fe888503c781793526d21104fc6c332a536a1
@@ -1,9 +1,22 @@
1
- // Function is going over formattedData and returning all objects that match the
2
- // ID of the clicked item from the dropdown
1
+ //function to retrieve all ancestors of unchecked item and set checked to false
2
+ export const getAncestorsOfUnchecked = (
3
+ data: { [key: string]: any }[],
4
+ item: { [key: string]: any }
5
+ ) => {
6
+ if (item.parent_id) {
7
+ const ancestor = filterFormattedDataById(data, item.parent_id);
8
+ ancestor[0].checked = false;
9
+ ancestor[0].parent_id && getAncestorsOfUnchecked(data, ancestor[0]);
10
+ }
11
+ return data;
12
+ };
13
+
14
+ //function is going over formattedData and returning all objects that match the
15
+ //id of the clicked item from the dropdown
3
16
  export const filterFormattedDataById = (
4
17
  formattedData: { [key: string]: any }[],
5
18
  id: string
6
- ): { [key: string]: any }[] => {
19
+ ) => {
7
20
  const matched: { [key: string]: any }[] = [];
8
21
  const recursiveSearch = (data: { [key: string]: any }[], term: string) => {
9
22
  for (const item of data) {
@@ -25,7 +38,7 @@ export const filterFormattedDataById = (
25
38
  export const findByFilter = (
26
39
  formattedData: { [key: string]: any }[],
27
40
  searchTerm: string
28
- ): { [key: string]: any }[] => {
41
+ ) => {
29
42
  const matchedItems: { [key: string]: any }[] = [];
30
43
  const recursiveSearch = (data: { [key: string]: any }[], term: string) => {
31
44
  for (const item of data) {
@@ -43,20 +56,7 @@ export const findByFilter = (
43
56
  return matchedItems;
44
57
  };
45
58
 
46
- // Function to retrieve all ancestors of unchecked item and set checked to false
47
- export const getAncestorsOfUnchecked = (
48
- data: { [key: string]: any }[],
49
- item: { [key: string]: any }
50
- ): { [key: string]: any }[] => {
51
- if (item.parent_id) {
52
- const ancestor = filterFormattedDataById(data, item.parent_id);
53
- ancestor[0].checked = false;
54
- ancestor[0].parent_id && getAncestorsOfUnchecked(data, ancestor[0]);
55
- }
56
- return data;
57
- };
58
-
59
- // Function to get all items with checked = true
59
+ //function to get all items with checked = true
60
60
  export const getCheckedItems = (
61
61
  data: { [key: string]: any }[]
62
62
  ): { [key: string]: any }[] => {
@@ -76,9 +76,7 @@ export const getCheckedItems = (
76
76
  return checkedItems;
77
77
  };
78
78
 
79
- export const getDefaultCheckedItems = (
80
- treeData: { [key: string]: any }[]
81
- ): { [key: string]: any }[] => {
79
+ export const getDefaultCheckedItems = (treeData: { [key: string]: any }[]) => {
82
80
  const checkedDefault: { [key: string]: any }[] = [];
83
81
 
84
82
  const traverseTree = (items: { [key: string]: any }[]) => {
@@ -120,7 +118,7 @@ export const getDefaultCheckedItems = (
120
118
  export const recursiveCheckParent = (
121
119
  item: { [key: string]: any },
122
120
  data: any
123
- ): any => {
121
+ ) => {
124
122
  if (item.parent_id !== null) {
125
123
  const parent = filterFormattedDataById(data, item.parent_id);
126
124
  const allChildrenChecked = parent[0].children.every(
@@ -137,11 +135,8 @@ export const recursiveCheckParent = (
137
135
  return data;
138
136
  };
139
137
 
140
- export const getExpandedItems = (
141
- treeData: { [key: string]: string }[],
142
- selectedIds: string[]
143
- ): any[] => {
144
- const expandedItems: any[] = [];
138
+ export const getExpandedItems = (treeData: { [key: string]: string }[], selectedIds: string[]) => {
139
+ let expandedItems: any[] = [];
145
140
 
146
141
  const traverse = (items: string | any[], ancestors: any[] = []) => {
147
142
  for (let i = 0; i < items.length; i++) {
@@ -30,11 +30,10 @@
30
30
  align-items: center;
31
31
  justify-content: space-between;
32
32
  .input_inner_container {
33
- width: 100%;
33
+ max-width: 90%;
34
34
  }
35
35
 
36
36
  input {
37
- width: 100%;
38
37
  border: none;
39
38
  font-family: $font_family_base;
40
39
  font-size: $font_base;
@@ -3,7 +3,6 @@ import classnames from "classnames"
3
3
  import { globalProps, GlobalProps } from "../utilities/globalProps"
4
4
  import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props"
5
5
  import Checkbox from "../pb_checkbox/_checkbox"
6
- import Radio from "../pb_radio/_radio"
7
6
  import Icon from "../pb_icon/_icon"
8
7
  import FormPill from "../pb_form_pill/_form_pill"
9
8
  import CircleIconButton from "../pb_circle_icon_button/_circle_icon_button"
@@ -25,13 +24,11 @@ type MultiLevelSelectProps = {
25
24
  data?: { [key: string]: string }
26
25
  id?: string
27
26
  inputDisplay?: "pills" | "none"
28
- inputName?: string
29
27
  name?: string
30
28
  returnAllSelected?: boolean
31
29
  treeData?: { [key: string]: string }[]
32
30
  onSelect?: (prop: { [key: string]: any }) => void
33
31
  selectedIds?: string[]
34
- variant?: "multi" | "single"
35
32
  } & GlobalProps
36
33
 
37
34
  const MultiLevelSelect = (props: MultiLevelSelectProps) => {
@@ -41,13 +38,11 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
41
38
  data = {},
42
39
  id,
43
40
  inputDisplay = "pills",
44
- inputName,
45
41
  name,
46
42
  returnAllSelected = false,
47
43
  treeData,
48
- onSelect = () => null,
49
- selectedIds,
50
- variant = "multi"
44
+ onSelect = () => {},
45
+ selectedIds
51
46
  } = props
52
47
 
53
48
  const ariaProps = buildAriaProps(aria)
@@ -60,24 +55,21 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
60
55
 
61
56
  const dropdownRef = useRef(null)
62
57
 
63
- // State for whether dropdown is open or closed
64
- const [isDropdownClosed, setIsDropdownClosed] = useState(true)
65
- // State from onchange for textinput, to use for filtering to create typeahead
58
+ //state for whether dropdown is open or closed
59
+ const [isClosed, setIsClosed] = useState(true)
60
+ //state from onchange for textinput, to use for filtering to create typeahead
66
61
  const [filterItem, setFilterItem] = useState("")
67
- // FormattedData with checked and parent_id added
68
- const [formattedData, setFormattedData] = useState([])
69
- // State for the return of returnAllSelected
62
+ //this is essentially the return that the user will get when they use the kit
70
63
  const [returnedArray, setReturnedArray] = useState([])
71
- // State for default return
64
+ //formattedData with checked and parent_id added
65
+ const [formattedData, setFormattedData] = useState([])
66
+ //state for return for default
72
67
  const [defaultReturn, setDefaultReturn] = useState([])
73
- // Get expanded items from treeData
74
- const initialExpandedItems = getExpandedItems(treeData, selectedIds)
75
- // Initialize state with expanded items
76
- const [expanded, setExpanded] = useState(initialExpandedItems)
77
- // State for single select variant input value
78
- const [singleSelectInputValue, setSingleSelectInputValue] = useState("")
79
- // State for single select variant input value
80
- const [singleSelectedItem, setSingleSelectedItem] = useState([])
68
+ // Get expanded items from treeData.
69
+ const initialExpandedItems = getExpandedItems(treeData, selectedIds);
70
+ // Initialize state with expanded items.
71
+ const [expanded, setExpanded] = useState(initialExpandedItems);
72
+
81
73
 
82
74
  useEffect(() => {
83
75
  setFormattedData(addCheckedAndParentProperty(treeData, selectedIds))
@@ -86,15 +78,6 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
86
78
  useEffect(() => {
87
79
  if (returnAllSelected) {
88
80
  setReturnedArray(getCheckedItems(formattedData))
89
- } else if (variant === "single") {
90
- if (selectedIds?.length && !singleSelectedItem.length) {
91
- // The default is the first selectedId if there are more than one
92
- const defaultSelection = filterFormattedDataById(formattedData, selectedIds[0])
93
- setSingleSelectInputValue(defaultSelection[0]?.value)
94
- setDefaultReturn(defaultSelection)
95
- } else {
96
- setDefaultReturn(singleSelectedItem)
97
- }
98
81
  } else {
99
82
  setDefaultReturn(getDefaultCheckedItems(formattedData))
100
83
  }
@@ -104,7 +87,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
104
87
  // Function to handle clicks outside the dropdown
105
88
  const handleClickOutside = (event: any) => {
106
89
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
107
- setIsDropdownClosed(true)
90
+ setIsClosed(true)
108
91
  }
109
92
  }
110
93
  // Attach the event listener
@@ -126,7 +109,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
126
109
  })
127
110
  }
128
111
 
129
- // Iterate over tree, find item and set checked or unchecked
112
+ //iterate over tree, find item and set checked or unchecked
130
113
  const modifyValue = (
131
114
  id: string,
132
115
  tree: { [key: string]: any }[],
@@ -139,20 +122,14 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
139
122
  if (item.id != id) item.children = modifyValue(id, item.children, check)
140
123
  else {
141
124
  item.checked = check
142
-
143
- if (variant === "single") {
144
- // Single select: no children should be checked
145
- item.children = modifyRecursive(item.children, !check)
146
- } else {
147
- item.children = modifyRecursive(item.children, check)
148
- }
125
+ item.children = modifyRecursive(item.children, check)
149
126
  }
150
127
 
151
128
  return item
152
129
  })
153
130
  }
154
131
 
155
- // Clone tree, check items + children
132
+ //clone tree, check items + children
156
133
  const checkItem = (item: { [key: string]: any }) => {
157
134
  const tree = cloneDeep(formattedData)
158
135
  if (returnAllSelected) {
@@ -163,7 +140,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
163
140
  }
164
141
  }
165
142
 
166
- // Clone tree, uncheck items + children
143
+ //clone tree, uncheck items + children
167
144
  const unCheckItem = (item: { [key: string]: any }) => {
168
145
  const tree = cloneDeep(formattedData)
169
146
  if (returnAllSelected) {
@@ -174,7 +151,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
174
151
  }
175
152
  }
176
153
 
177
- // setFormattedData with proper properties
154
+ //setformattedData with proper properties
178
155
  const changeItem = (item: { [key: string]: any }, check: boolean) => {
179
156
  const tree = check ? checkItem(item) : unCheckItem(item)
180
157
  setFormattedData(tree)
@@ -182,12 +159,12 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
182
159
  return tree
183
160
  }
184
161
 
185
- // Function to map over data and add parent_id + depth property to each item
162
+ //function to map over data and add parent_id + depth property to each item
186
163
  const addCheckedAndParentProperty = (
187
164
  treeData: { [key: string]: any }[],
188
165
  selectedIds: string[],
189
166
  parent_id: string = null,
190
- depth = 0,
167
+ depth: number = 0,
191
168
  ) => {
192
169
  if (!Array.isArray(treeData)) {
193
170
  return
@@ -215,12 +192,12 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
215
192
  })
216
193
  }
217
194
 
218
- // Click event for x on form pill
195
+ //click event for x on form pill
219
196
  const handlePillClose = (event: any, clickedItem: { [key: string]: any }) => {
220
- // Prevents the dropdown from closing when clicking on the pill
197
+ // prevents the dropdown from closing when clicking on the pill
221
198
  event.stopPropagation()
222
199
  const updatedTree = changeItem(clickedItem, false)
223
- // Logic for removing items from returnArray or defaultReturn when pills clicked
200
+ //logic for removing items from returnArray or defaultReturn when pills clicked
224
201
  if (returnAllSelected) {
225
202
  onSelect(getCheckedItems(updatedTree))
226
203
  } else {
@@ -228,7 +205,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
228
205
  }
229
206
  }
230
207
 
231
- // Handle click on input wrapper(entire div with pills, typeahead, etc) so it doesn't close when input or form pill is clicked
208
+ //handle click on input wrapper(entire div with pills, typeahead, etc) so it doesn't close when input or form pill is clicked
232
209
  const handleInputWrapperClick = (e: any) => {
233
210
  e.stopPropagation()
234
211
  if (
@@ -237,13 +214,13 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
237
214
  ) {
238
215
  return
239
216
  }
240
- setIsDropdownClosed(!isDropdownClosed)
217
+ setIsClosed(!isClosed)
241
218
  }
242
219
 
243
- // Main function to handle any click inside dropdown
220
+ //Main function to handle any click inside dropdown
244
221
  const handledropdownItemClick = (e: any, check: boolean) => {
245
222
  const clickedItem = e.target.parentNode.id
246
- // Setting filterItem to "" will clear textinput and clear typeahead
223
+ //setting filterItem to "" will clear textinput and clear typeahead
247
224
  setFilterItem("")
248
225
 
249
226
  const filtered = filterFormattedDataById(formattedData, clickedItem)
@@ -255,43 +232,15 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
255
232
  }
256
233
  }
257
234
 
258
- // Single select
259
- const handleRadioButtonClick = (
260
- e: React.ChangeEvent<HTMLInputElement>,
261
- ) => {
262
- const { id: selectedItemID, value: inputText } = e.target
263
- // Reset tree checked state, triggering useEffect
264
- const treeWithNoSelections = modifyRecursive(formattedData, false)
265
- // Update tree with single selection
266
- const treeWithSelectedItem = modifyValue(selectedItemID, treeWithNoSelections, true)
267
- const selectedItem = filterFormattedDataById(treeWithSelectedItem, selectedItemID)
268
-
269
- setFormattedData(treeWithSelectedItem)
270
- setSingleSelectedItem(selectedItem)
271
- setSingleSelectInputValue(inputText)
272
- // Reset the filter to always display dropdown options on click
273
- setFilterItem("")
274
- setIsDropdownClosed(true)
275
-
276
- onSelect(selectedItem)
277
- };
278
-
279
- // Single select: reset the tree state upon typing
280
- const handleRadioInputChange = (inputText: string) => {
281
- modifyRecursive(formattedData, false)
282
- setSingleSelectInputValue(inputText)
283
- setFilterItem(inputText)
284
- };
235
+ const isExpanded = (item: any) => expanded.indexOf(item.id) > -1
285
236
 
286
- const isTreeRowExpanded = (item: any) => expanded.indexOf(item.id) > -1
287
-
288
- // Handle click on chevron toggles in dropdown
237
+ //handle click on chevron toggles in dropdown
289
238
  const handleToggleClick = (id: string, event: React.MouseEvent) => {
290
239
  event.stopPropagation()
291
240
  const clickedItem = filterFormattedDataById(formattedData, id)
292
241
  if (clickedItem) {
293
242
  let expandedArray = [...expanded]
294
- const itemExpanded = isTreeRowExpanded(clickedItem[0])
243
+ const itemExpanded = isExpanded(clickedItem[0])
295
244
 
296
245
  if (itemExpanded)
297
246
  expandedArray = expandedArray.filter((i) => i != clickedItem[0].id)
@@ -310,8 +259,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
310
259
  }
311
260
  return items
312
261
  }
313
-
314
- // Rendering formattedData to UI based on typeahead
262
+ //rendering formattedData to UI based on typeahead
315
263
  const renderNestedOptions = (items: { [key: string]: any }[]) => {
316
264
  return (
317
265
  <ul>
@@ -319,62 +267,42 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
319
267
  items.map((item: { [key: string]: any }) => {
320
268
  return (
321
269
  <div key={item.id}>
322
- <li
323
- className="dropdown_item"
324
- data-name={item.id}
325
- >
326
- <div className="dropdown_item_checkbox_row">
270
+ <li className='dropdown_item' data-name={item.id}>
271
+ <div className='dropdown_item_checkbox_row'>
327
272
  <div
328
- key={isTreeRowExpanded(item) ? "chevron-down" : "chevron-right"}
273
+ key={isExpanded(item) ? "chevron-down" : "chevron-right"}
329
274
  >
330
275
  <CircleIconButton
331
- className={
332
- item.children && item.children.length > 0
333
- ? ""
334
- : "toggle_icon"
335
- }
336
- icon={
337
- isTreeRowExpanded(item) ? "chevron-down" : "chevron-right"
338
- }
339
- onClick={(event: any) =>
340
- handleToggleClick(item.id, event)
341
- }
342
- variant="link"
276
+ icon={
277
+ isExpanded(item) ? "chevron-down" : "chevron-right"
278
+ }
279
+ className={
280
+ item.children && item.children.length > 0
281
+ ? ""
282
+ : "toggle_icon"
283
+ }
284
+ onClick={(event: any) =>
285
+ handleToggleClick(item.id, event)
286
+ }
287
+ variant='link'
343
288
  />
344
289
  </div>
345
- { variant === "single" ? (
346
- <Radio
347
- checked={item.checked}
348
- id={item.id}
349
- label={item.label}
350
- name={inputName}
351
- onChange={(e: React.ChangeEvent<HTMLInputElement>) => (
352
- handleRadioButtonClick(e)
353
- )}
354
- type="radio"
355
- value={item.label}
290
+ <Checkbox text={item.label} id={item.id}>
291
+ <input
292
+ checked={item.checked}
293
+ type='checkbox'
294
+ name={item.label}
295
+ value={item.label}
296
+ onChange={(e) => {
297
+ handledropdownItemClick(e, !item.checked)
298
+ }}
356
299
  />
357
- ) : (
358
- <Checkbox
359
- id={item.id}
360
- text={item.label}
361
- >
362
- <input
363
- checked={item.checked}
364
- name={item.label}
365
- onChange={(e) => {
366
- handledropdownItemClick(e, !item.checked)
367
- }}
368
- type="checkbox"
369
- value={item.label}
370
- />
371
- </Checkbox>
372
- )}
300
+ </Checkbox>
373
301
  </div>
374
- {isTreeRowExpanded(item) &&
302
+ {isExpanded(item) &&
375
303
  item.children &&
376
304
  item.children.length > 0 &&
377
- (variant === "single" || !filterItem) && ( // Show children if expanded is true
305
+ !filterItem && ( // Show children if expanded is true
378
306
  <div>{renderNestedOptions(item.children)}</div>
379
307
  )}
380
308
  </li>
@@ -385,121 +313,68 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
385
313
  )
386
314
  }
387
315
 
316
+
317
+
388
318
  return (
389
- <div
390
- {...ariaProps}
391
- {...dataProps}
392
- className={classes}
393
- id={id}
394
- >
395
- <div
396
- className="wrapper"
397
- ref={dropdownRef}
398
- >
399
- <div
400
- className="input_wrapper"
401
- onClick={handleInputWrapperClick}
402
- >
403
- <div className="input_inner_container">
404
- {variant === "single" && defaultReturn.length !== 0
405
- ? defaultReturn.map((selectedItem) => (
406
- <input
407
- key={selectedItem.id}
408
- name={`${name}[]`}
409
- type="hidden"
410
- value={selectedItem.id}
411
- />
319
+ <div {...ariaProps} {...dataProps} className={classes} id={id}>
320
+ <div ref={dropdownRef} className='wrapper'>
321
+ <div className='input_wrapper' onClick={handleInputWrapperClick}>
322
+ <div className='input_inner_container'>
323
+ {returnedArray.length !== 0 && returnAllSelected
324
+ ? returnedArray.map((item) => (
325
+ <input type='hidden' name={`${name}[]`} value={item.id} />
412
326
  ))
413
327
  : null}
414
328
 
415
- {variant !== "single" && (
416
- <>
417
- {returnAllSelected && returnedArray.length !== 0
418
- ? returnedArray.map((item) => (
419
- <input
420
- key={item.id}
421
- name={`${name}[]`}
422
- type="hidden"
423
- value={item.id}
424
- />
425
- ))
426
- : null}
427
-
428
- {returnAllSelected &&
429
- returnedArray.length !== 0 &&
430
- inputDisplay === "pills"
431
- ? returnedArray.map((item, index) => (
432
- <FormPill
433
- key={index}
434
- onClick={(event: any) => handlePillClose(event, item)}
435
- size="small"
436
- text={item.label}
437
- />
438
- ))
439
- : null}
440
-
441
- {!returnAllSelected &&
442
- defaultReturn.length !== 0 &&
443
- inputDisplay === "pills"
444
- ? defaultReturn.map((item, index) => (
445
- <FormPill
446
- key={index}
447
- onClick={(event: any) => handlePillClose(event, item)}
448
- size="small"
449
- text={item.label}
450
- />
451
- ))
452
- : null}
453
-
454
- {returnAllSelected &&
455
- returnedArray.length !== 0 &&
456
- inputDisplay === "pills" && <br />}
457
-
458
- {!returnAllSelected &&
459
- defaultReturn.length !== 0 &&
460
- inputDisplay === "pills" && <br />}
461
- </>
462
- )}
463
-
329
+ {returnedArray.length !== 0 && inputDisplay === "pills" && returnAllSelected
330
+ ? returnedArray.map((item, index) => (
331
+ <FormPill
332
+ key={index}
333
+ text={item.label}
334
+ size='small'
335
+ onClick={(event: any) => handlePillClose(event, item)}
336
+ />
337
+ ))
338
+ : null}
339
+ {!returnAllSelected &&
340
+ defaultReturn.length !== 0 && inputDisplay === "pills" ?
341
+ defaultReturn.map((item, index) => (
342
+ <FormPill
343
+ key={index}
344
+ text={item.label}
345
+ size='small'
346
+ onClick={(event: any) => handlePillClose(event, item)}
347
+ />
348
+ ))
349
+ : null
350
+ }
351
+ {returnedArray.length !== 0 && returnAllSelected && inputDisplay === "pills" && <br />}
352
+ {defaultReturn.length !== 0 && !returnAllSelected && inputDisplay === "pills" && <br />}
464
353
  <input
465
- id="multiselect_input"
466
- onChange={(e) =>{
467
- variant === "single"
468
- ? handleRadioInputChange(e.target.value)
469
- : setFilterItem(e.target.value)
470
- }}
471
- onClick={() => setIsDropdownClosed(false)}
472
- placeholder={
473
- inputDisplay === "none" && itemsSelectedLength()
474
- ? `${itemsSelectedLength()} ${itemsSelectedLength() === 1 ? "item" : "items"} selected`
475
- : "Start typing..."
476
- }
477
- value={singleSelectInputValue || filterItem}
354
+ id='multiselect_input'
355
+ onChange={(e) => {
356
+ setFilterItem(e.target.value)
357
+ }}
358
+ placeholder={inputDisplay === "none" && itemsSelectedLength() ? (
359
+ `${itemsSelectedLength()} ${itemsSelectedLength() === 1 ? 'item' : 'items'} selected`
360
+ ) : ("Start typing...")}
361
+ value={filterItem}
362
+ onClick={() => setIsClosed(false)}
478
363
  />
479
364
  </div>
480
-
481
- {isDropdownClosed ? (
482
- <div key="chevron-down">
483
- <Icon
484
- icon="chevron-down"
485
- size="xs"
486
- />
365
+ {isClosed ? (
366
+ <div key='chevron-down'>
367
+ <Icon icon='chevron-down' size="xs"/>
487
368
  </div>
488
369
  ) : (
489
- <div key="chevron-up">
490
- <Icon
491
- icon="chevron-up"
492
- size="xs"
493
- />
370
+ <div key='chevron-up'>
371
+ <Icon icon='chevron-up' size="xs"/>
494
372
  </div>
495
373
  )}
496
374
  </div>
497
-
498
- <div className={`dropdown_menu ${isDropdownClosed ? "close" : "open"}`}>
375
+ <div className={`dropdown_menu ${isClosed ? "close" : "open"}`}>
499
376
  {renderNestedOptions(
500
- filterItem
501
- ? findByFilter(formattedData, filterItem)
502
- : formattedData
377
+ filterItem ? findByFilter(formattedData, filterItem) : formattedData
503
378
  )}
504
379
  </div>
505
380
  </div>
@@ -8,7 +8,6 @@
8
8
  label: "People",
9
9
  value: "People",
10
10
  id: "101",
11
- expanded: true,
12
11
  children: [
13
12
  {
14
13
  label: "Talent Acquisition",
@@ -64,8 +63,10 @@
64
63
  ],
65
64
  }] %>
66
65
 
67
- <%= pb_rails("multi_level_select", props: {
68
- id: "multi-level-select-default-rails",
69
- name: "my_array",
70
- tree_data: treeData
71
- }) %>
66
+
67
+
68
+ <%= pb_rails("multi_level_select", props: {
69
+ id: "multi-level-select-default-rails",
70
+ name: "my_array",
71
+ tree_data: treeData
72
+ }) %>
@@ -77,7 +77,7 @@ const MultiLevelSelectSelectedIds = (props) => {
77
77
  console.log("Selected Items with Return All Selected Data", selectedNodes)
78
78
  }
79
79
  returnAllSelected
80
- selectedIds={["energy1", "talent1"]}
80
+ selectedIds={["energy1","talent1"]}
81
81
  treeData={treeData}
82
82
  {...props}
83
83
  />