playbook_ui 13.9.0 → 13.10.0.pre.alpha.PLAY1046multilevelsingleselectphase21328

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_default_swift.md +12 -0
  3. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_monogram_swift.md +12 -0
  4. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_props_swift.md +8 -0
  5. data/app/pb_kits/playbook/pb_avatar/docs/example.yml +3 -1
  6. data/app/pb_kits/playbook/pb_background/_background.tsx +103 -52
  7. data/app/pb_kits/playbook/pb_badge/docs/_badge_colors_swift.md +1 -1
  8. data/app/pb_kits/playbook/pb_button/_button.scss +2 -2
  9. data/app/pb_kits/playbook/pb_multi_level_select/_helper_functions.tsx +27 -22
  10. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +6 -1
  11. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +272 -111
  12. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_default.html.erb +6 -7
  13. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_selected_ids.jsx +1 -1
  14. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single.html.erb +73 -0
  15. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single.jsx +87 -0
  16. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single_children_only.html.erb +74 -0
  17. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single_children_only.jsx +88 -0
  18. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +5 -2
  19. data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +3 -1
  20. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +10 -0
  21. data/dist/playbook-rails.js +5 -5
  22. data/lib/playbook/version.rb +2 -2
  23. metadata +14 -8
  24. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_swift.md +0 -82
@@ -3,6 +3,7 @@ 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"
6
7
  import Icon from "../pb_icon/_icon"
7
8
  import FormPill from "../pb_form_pill/_form_pill"
8
9
  import CircleIconButton from "../pb_circle_icon_button/_circle_icon_button"
@@ -24,11 +25,14 @@ type MultiLevelSelectProps = {
24
25
  data?: { [key: string]: string }
25
26
  id?: string
26
27
  inputDisplay?: "pills" | "none"
28
+ inputName?: string
27
29
  name?: string
28
30
  returnAllSelected?: boolean
29
31
  treeData?: { [key: string]: string }[]
30
32
  onSelect?: (prop: { [key: string]: any }) => void
31
33
  selectedIds?: string[]
34
+ ultimateChildrenOnly?: boolean
35
+ variant?: "multi" | "single"
32
36
  } & GlobalProps
33
37
 
34
38
  const MultiLevelSelect = (props: MultiLevelSelectProps) => {
@@ -38,11 +42,14 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
38
42
  data = {},
39
43
  id,
40
44
  inputDisplay = "pills",
45
+ inputName,
41
46
  name,
42
47
  returnAllSelected = false,
43
48
  treeData,
44
- onSelect = () => {},
45
- selectedIds
49
+ onSelect = () => null,
50
+ selectedIds,
51
+ ultimateChildrenOnly = false,
52
+ variant = "multi"
46
53
  } = props
47
54
 
48
55
  const ariaProps = buildAriaProps(aria)
@@ -55,29 +62,61 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
55
62
 
56
63
  const dropdownRef = useRef(null)
57
64
 
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
65
+ // State for whether dropdown is open or closed
66
+ const [isDropdownClosed, setIsDropdownClosed] = useState(true)
67
+ // State from onChange for textinput, to use for filtering to create typeahead
61
68
  const [filterItem, setFilterItem] = useState("")
62
- //this is essentially the return that the user will get when they use the kit
63
- const [returnedArray, setReturnedArray] = useState([])
64
- //formattedData with checked and parent_id added
69
+ // FormattedData with checked and parent_id added
65
70
  const [formattedData, setFormattedData] = useState([])
66
- //state for return for default
71
+ // State for the return of returnAllSelected
72
+ const [returnedArray, setReturnedArray] = useState([])
73
+ // State for default return
67
74
  const [defaultReturn, setDefaultReturn] = 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
-
75
+ // Get expanded items from treeData
76
+ const initialExpandedItems = getExpandedItems(treeData, selectedIds)
77
+ // Initialize state with expanded items
78
+ const [expanded, setExpanded] = useState(initialExpandedItems)
79
+
80
+ // Single Select specific state
81
+ const [singleSelectedItem, setSingleSelectedItem] = useState({
82
+ id: [],
83
+ value: "",
84
+ item: []
85
+ })
73
86
 
74
87
  useEffect(() => {
75
- setFormattedData(addCheckedAndParentProperty(treeData, selectedIds))
88
+ const formattedData = addCheckedAndParentProperty(
89
+ treeData,
90
+ variant === "single" ? [selectedIds?.[0]] : selectedIds
91
+ )
92
+
93
+ setFormattedData(formattedData)
94
+
95
+ if (variant === "single") {
96
+ // No selectedIds, reset state
97
+ if (selectedIds?.length === 0 || !selectedIds?.length) {
98
+ setSingleSelectedItem({ id: [], value: "", item: []})
99
+ } else {
100
+ // If there is a selectedId but no current item, set the selectedItem
101
+ if (selectedIds?.length !== 0 && !singleSelectedItem.value) {
102
+ const selectedItem = filterFormattedDataById(formattedData, selectedIds[0])
103
+
104
+ if (!selectedItem.length) {
105
+ setSingleSelectedItem({ id: [], value: "", item: []})
106
+ } else {
107
+ const { id, value } = selectedItem[0]
108
+ setSingleSelectedItem({ id: [id], value, item: selectedItem})
109
+ }
110
+ }
111
+ }
112
+ }
76
113
  }, [treeData, selectedIds])
77
114
 
78
115
  useEffect(() => {
79
116
  if (returnAllSelected) {
80
117
  setReturnedArray(getCheckedItems(formattedData))
118
+ } else if (variant === "single") {
119
+ setDefaultReturn(singleSelectedItem.item)
81
120
  } else {
82
121
  setDefaultReturn(getDefaultCheckedItems(formattedData))
83
122
  }
@@ -87,7 +126,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
87
126
  // Function to handle clicks outside the dropdown
88
127
  const handleClickOutside = (event: any) => {
89
128
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
90
- setIsClosed(true)
129
+ setIsDropdownClosed(true)
91
130
  }
92
131
  }
93
132
  // Attach the event listener
@@ -109,7 +148,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
109
148
  })
110
149
  }
111
150
 
112
- //iterate over tree, find item and set checked or unchecked
151
+ // Iterate over tree, find item and set checked or unchecked
113
152
  const modifyValue = (
114
153
  id: string,
115
154
  tree: { [key: string]: any }[],
@@ -122,14 +161,20 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
122
161
  if (item.id != id) item.children = modifyValue(id, item.children, check)
123
162
  else {
124
163
  item.checked = check
125
- item.children = modifyRecursive(item.children, check)
164
+
165
+ if (variant === "single") {
166
+ // Single select: no children should be checked
167
+ item.children = modifyRecursive(item.children, !check)
168
+ } else {
169
+ item.children = modifyRecursive(item.children, check)
170
+ }
126
171
  }
127
172
 
128
173
  return item
129
174
  })
130
175
  }
131
176
 
132
- //clone tree, check items + children
177
+ // Clone tree, check items + children
133
178
  const checkItem = (item: { [key: string]: any }) => {
134
179
  const tree = cloneDeep(formattedData)
135
180
  if (returnAllSelected) {
@@ -140,7 +185,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
140
185
  }
141
186
  }
142
187
 
143
- //clone tree, uncheck items + children
188
+ // Clone tree, uncheck items + children
144
189
  const unCheckItem = (item: { [key: string]: any }) => {
145
190
  const tree = cloneDeep(formattedData)
146
191
  if (returnAllSelected) {
@@ -151,7 +196,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
151
196
  }
152
197
  }
153
198
 
154
- //setformattedData with proper properties
199
+ // setFormattedData with proper properties
155
200
  const changeItem = (item: { [key: string]: any }, check: boolean) => {
156
201
  const tree = check ? checkItem(item) : unCheckItem(item)
157
202
  setFormattedData(tree)
@@ -159,12 +204,12 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
159
204
  return tree
160
205
  }
161
206
 
162
- //function to map over data and add parent_id + depth property to each item
207
+ // Function to map over data and add parent_id + depth property to each item
163
208
  const addCheckedAndParentProperty = (
164
209
  treeData: { [key: string]: any }[],
165
210
  selectedIds: string[],
166
211
  parent_id: string = null,
167
- depth: number = 0,
212
+ depth = 0,
168
213
  ) => {
169
214
  if (!Array.isArray(treeData)) {
170
215
  return
@@ -172,7 +217,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
172
217
  return treeData.map((item: { [key: string]: any } | any) => {
173
218
  const newItem = {
174
219
  ...item,
175
- checked: selectedIds && selectedIds.length && selectedIds.includes(item.id),
220
+ checked: Boolean(selectedIds && selectedIds.length && selectedIds.includes(item.id)),
176
221
  parent_id,
177
222
  depth,
178
223
  }
@@ -192,12 +237,12 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
192
237
  })
193
238
  }
194
239
 
195
- //click event for x on form pill
240
+ // Click event for x on form pill
196
241
  const handlePillClose = (event: any, clickedItem: { [key: string]: any }) => {
197
- // prevents the dropdown from closing when clicking on the pill
242
+ // Prevents the dropdown from closing when clicking on the pill
198
243
  event.stopPropagation()
199
244
  const updatedTree = changeItem(clickedItem, false)
200
- //logic for removing items from returnArray or defaultReturn when pills clicked
245
+ // Logic for removing items from returnArray or defaultReturn when pills clicked
201
246
  if (returnAllSelected) {
202
247
  onSelect(getCheckedItems(updatedTree))
203
248
  } else {
@@ -205,7 +250,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
205
250
  }
206
251
  }
207
252
 
208
- //handle click on input wrapper(entire div with pills, typeahead, etc) so it doesn't close when input or form pill is clicked
253
+ // Handle click on input wrapper(entire div with pills, typeahead, etc) so it doesn't close when input or form pill is clicked
209
254
  const handleInputWrapperClick = (e: any) => {
210
255
  e.stopPropagation()
211
256
  if (
@@ -214,13 +259,13 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
214
259
  ) {
215
260
  return
216
261
  }
217
- setIsClosed(!isClosed)
262
+ setIsDropdownClosed(!isDropdownClosed)
218
263
  }
219
264
 
220
- //Main function to handle any click inside dropdown
265
+ // Main function to handle any click inside dropdown
221
266
  const handledropdownItemClick = (e: any, check: boolean) => {
222
267
  const clickedItem = e.target.parentNode.id
223
- //setting filterItem to "" will clear textinput and clear typeahead
268
+ // Setting filterItem to "" will clear textinput and clear typeahead
224
269
  setFilterItem("")
225
270
 
226
271
  const filtered = filterFormattedDataById(formattedData, clickedItem)
@@ -232,15 +277,45 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
232
277
  }
233
278
  }
234
279
 
235
- const isExpanded = (item: any) => expanded.indexOf(item.id) > -1
280
+ // Single select
281
+ const handleRadioButtonClick = (
282
+ e: React.ChangeEvent<HTMLInputElement>,
283
+ ) => {
284
+ const { id, value: inputText } = e.target
285
+ // The radio button needs a unique ID, this grabs the ID before the hyphen
286
+ const selectedItemID = id.match(/^[^-]*/)[0]
287
+ // Reset tree checked state, triggering useEffect
288
+ const treeWithNoSelections = modifyRecursive(formattedData, false)
289
+ // Update tree with single selection
290
+ const treeWithSelectedItem = modifyValue(selectedItemID, treeWithNoSelections, true)
291
+ const selectedItem = filterFormattedDataById(treeWithSelectedItem, selectedItemID)
292
+
293
+ setFormattedData(treeWithSelectedItem)
294
+ setSingleSelectedItem({id: [selectedItemID], value: inputText, item: selectedItem})
295
+ // Reset the filter to always display dropdown options on click
296
+ setFilterItem("")
297
+ setIsDropdownClosed(true)
298
+
299
+ onSelect(selectedItem)
300
+ };
301
+
302
+ // Single select: reset the tree state upon typing
303
+ const handleRadioInputChange = (inputText: string) => {
304
+ modifyRecursive(formattedData, false)
305
+ setDefaultReturn([])
306
+ setSingleSelectedItem({id: [], value: inputText, item: []})
307
+ setFilterItem(inputText)
308
+ };
236
309
 
237
- //handle click on chevron toggles in dropdown
310
+ const isTreeRowExpanded = (item: any) => expanded.indexOf(item.id) > -1
311
+
312
+ // Handle click on chevron toggles in dropdown
238
313
  const handleToggleClick = (id: string, event: React.MouseEvent) => {
239
314
  event.stopPropagation()
240
315
  const clickedItem = filterFormattedDataById(formattedData, id)
241
316
  if (clickedItem) {
242
317
  let expandedArray = [...expanded]
243
- const itemExpanded = isExpanded(clickedItem[0])
318
+ const itemExpanded = isTreeRowExpanded(clickedItem[0])
244
319
 
245
320
  if (itemExpanded)
246
321
  expandedArray = expandedArray.filter((i) => i != clickedItem[0].id)
@@ -259,7 +334,19 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
259
334
  }
260
335
  return items
261
336
  }
262
- //rendering formattedData to UI based on typeahead
337
+
338
+ const singleHiddenInstances = document.querySelectorAll('.singleHidden');
339
+
340
+ singleHiddenInstances.forEach(singleHiddenInstance => {
341
+
342
+ const siblingElement = singleHiddenInstance.nextElementSibling as HTMLElement;
343
+ if (siblingElement && siblingElement.classList.contains('pb_radio_button')) {
344
+ siblingElement.style.display = 'none';
345
+ }
346
+ });
347
+
348
+
349
+ // Rendering formattedData to UI based on typeahead
263
350
  const renderNestedOptions = (items: { [key: string]: any }[]) => {
264
351
  return (
265
352
  <ul>
@@ -267,42 +354,63 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
267
354
  items.map((item: { [key: string]: any }) => {
268
355
  return (
269
356
  <div key={item.id}>
270
- <li className='dropdown_item' data-name={item.id}>
271
- <div className='dropdown_item_checkbox_row'>
357
+ <li
358
+ className="dropdown_item"
359
+ data-name={item.id}
360
+ >
361
+ <div className="dropdown_item_checkbox_row">
272
362
  <div
273
- key={isExpanded(item) ? "chevron-down" : "chevron-right"}
363
+ key={isTreeRowExpanded(item) ? "chevron-down" : "chevron-right"}
274
364
  >
275
365
  <CircleIconButton
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'
366
+ className={
367
+ item.children && item.children.length > 0
368
+ ? ""
369
+ : "toggle_icon"
370
+ }
371
+ icon={
372
+ isTreeRowExpanded(item) ? "chevron-down" : "chevron-right"
373
+ }
374
+ onClick={(event: any) =>
375
+ handleToggleClick(item.id, event)
376
+ }
377
+ variant="link"
288
378
  />
289
379
  </div>
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
- }}
380
+ { variant === "single" ? (
381
+ <Radio
382
+ checked={item.checked}
383
+ class={ultimateChildrenOnly ? item.children ? "singleHidden" : "" : null}
384
+ id={`${item.id}-${item.label}`}
385
+ label={item.label}
386
+ name={inputName}
387
+ onChange={(e: React.ChangeEvent<HTMLInputElement>) => (
388
+ handleRadioButtonClick(e)
389
+ )}
390
+ type="radio"
391
+ value={item.label}
299
392
  />
300
- </Checkbox>
393
+ ) : (
394
+ <Checkbox
395
+ id={item.id}
396
+ text={item.label}
397
+ >
398
+ <input
399
+ checked={item.checked}
400
+ name={item.label}
401
+ onChange={(e) => {
402
+ handledropdownItemClick(e, !item.checked)
403
+ }}
404
+ type="checkbox"
405
+ value={item.label}
406
+ />
407
+ </Checkbox>
408
+ )}
301
409
  </div>
302
- {isExpanded(item) &&
410
+ {isTreeRowExpanded(item) &&
303
411
  item.children &&
304
412
  item.children.length > 0 &&
305
- !filterItem && ( // Show children if expanded is true
413
+ (variant === "single" || !filterItem) && ( // Show children if expanded is true
306
414
  <div>{renderNestedOptions(item.children)}</div>
307
415
  )}
308
416
  </li>
@@ -313,68 +421,121 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
313
421
  )
314
422
  }
315
423
 
316
-
317
-
318
424
  return (
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} />
326
- ))
327
- : null}
328
-
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)}
425
+ <div
426
+ {...ariaProps}
427
+ {...dataProps}
428
+ className={classes}
429
+ id={id}
430
+ >
431
+ <div
432
+ className="wrapper"
433
+ ref={dropdownRef}
434
+ >
435
+ <div
436
+ className="input_wrapper"
437
+ onClick={handleInputWrapperClick}
438
+ >
439
+ <div className="input_inner_container">
440
+ {variant === "single" && defaultReturn.length !== 0
441
+ ? defaultReturn.map((selectedItem) => (
442
+ <input
443
+ key={selectedItem.id}
444
+ name={`${name}[]`}
445
+ type="hidden"
446
+ value={selectedItem.id}
336
447
  />
337
448
  ))
338
449
  : 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 />}
450
+
451
+ {variant !== "single" && (
452
+ <>
453
+ {returnAllSelected && returnedArray.length !== 0
454
+ ? returnedArray.map((item) => (
455
+ <input
456
+ key={item.id}
457
+ name={`${name}[]`}
458
+ type="hidden"
459
+ value={item.id}
460
+ />
461
+ ))
462
+ : null}
463
+
464
+ {returnAllSelected &&
465
+ returnedArray.length !== 0 &&
466
+ inputDisplay === "pills"
467
+ ? returnedArray.map((item, index) => (
468
+ <FormPill
469
+ key={index}
470
+ onClick={(event: any) => handlePillClose(event, item)}
471
+ size="small"
472
+ text={item.label}
473
+ />
474
+ ))
475
+ : null}
476
+
477
+ {!returnAllSelected &&
478
+ defaultReturn.length !== 0 &&
479
+ inputDisplay === "pills"
480
+ ? defaultReturn.map((item, index) => (
481
+ <FormPill
482
+ key={index}
483
+ onClick={(event: any) => handlePillClose(event, item)}
484
+ size="small"
485
+ text={item.label}
486
+ />
487
+ ))
488
+ : null}
489
+
490
+ {returnAllSelected &&
491
+ returnedArray.length !== 0 &&
492
+ inputDisplay === "pills" && <br />}
493
+
494
+ {!returnAllSelected &&
495
+ defaultReturn.length !== 0 &&
496
+ inputDisplay === "pills" && <br />}
497
+ </>
498
+ )}
499
+
353
500
  <input
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)}
501
+ id="multiselect_input"
502
+ onChange={(e) =>{
503
+ variant === "single"
504
+ ? handleRadioInputChange(e.target.value)
505
+ : setFilterItem(e.target.value)
506
+ }}
507
+ onClick={() => setIsDropdownClosed(false)}
508
+ placeholder={
509
+ inputDisplay === "none" && itemsSelectedLength()
510
+ ? `${itemsSelectedLength()} ${itemsSelectedLength() === 1 ? "item" : "items"} selected`
511
+ : "Start typing..."
512
+ }
513
+ value={singleSelectedItem.value || filterItem}
363
514
  />
364
515
  </div>
365
- {isClosed ? (
366
- <div key='chevron-down'>
367
- <Icon icon='chevron-down' size="xs"/>
516
+
517
+ {isDropdownClosed ? (
518
+ <div key="chevron-down">
519
+ <Icon
520
+ icon="chevron-down"
521
+ size="xs"
522
+ />
368
523
  </div>
369
524
  ) : (
370
- <div key='chevron-up'>
371
- <Icon icon='chevron-up' size="xs"/>
525
+ <div key="chevron-up">
526
+ <Icon
527
+ icon="chevron-up"
528
+ size="xs"
529
+ />
372
530
  </div>
373
531
  )}
374
532
  </div>
375
- <div className={`dropdown_menu ${isClosed ? "close" : "open"}`}>
533
+
534
+ <div className={`dropdown_menu ${isDropdownClosed ? "close" : "open"}`}>
376
535
  {renderNestedOptions(
377
- filterItem ? findByFilter(formattedData, filterItem) : formattedData
536
+ filterItem
537
+ ? findByFilter(formattedData, filterItem)
538
+ : formattedData
378
539
  )}
379
540
  </div>
380
541
  </div>
@@ -8,6 +8,7 @@
8
8
  label: "People",
9
9
  value: "People",
10
10
  id: "101",
11
+ expanded: true,
11
12
  children: [
12
13
  {
13
14
  label: "Talent Acquisition",
@@ -63,10 +64,8 @@
63
64
  ],
64
65
  }] %>
65
66
 
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
- }) %>
67
+ <%= pb_rails("multi_level_select", props: {
68
+ id: "multi-level-select-default-rails",
69
+ name: "my_array",
70
+ tree_data: treeData
71
+ }) %>
@@ -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
  />
@@ -0,0 +1,73 @@
1
+ <% treeData = [{
2
+ label: "Power Home Remodeling",
3
+ value: "Power Home Remodeling",
4
+ id: "200",
5
+ expanded: true,
6
+ children: [
7
+ {
8
+ label: "People",
9
+ value: "People",
10
+ id: "201",
11
+ expanded: true,
12
+ children: [
13
+ {
14
+ label: "Talent Acquisition",
15
+ value: "Talent Acquisition",
16
+ id: "202",
17
+ },
18
+ {
19
+ label: "Business Affairs",
20
+ value: "Business Affairs",
21
+ id: "203",
22
+ children: [
23
+ {
24
+ label: "Initiatives",
25
+ value: "Initiatives",
26
+ id: "204",
27
+ },
28
+ {
29
+ label: "Learning & Development",
30
+ value: "Learning & Development",
31
+ id: "205",
32
+ },
33
+ ],
34
+ },
35
+ {
36
+ label: "People Experience",
37
+ value: "People Experience",
38
+ id: "206",
39
+ },
40
+ ],
41
+ },
42
+ {
43
+ label: "Contact Center",
44
+ value: "Contact Center",
45
+ id: "207",
46
+ children: [
47
+ {
48
+ label: "Appointment Management",
49
+ value: "Appointment Management",
50
+ id: "208",
51
+ },
52
+ {
53
+ label: "Customer Service",
54
+ value: "Customer Service",
55
+ id: "209",
56
+ },
57
+ {
58
+ label: "Energy",
59
+ value: "Energy",
60
+ id: "210",
61
+ },
62
+ ],
63
+ },
64
+ ],
65
+ }] %>
66
+
67
+ <%= pb_rails("multi_level_select", props: {
68
+ id: "multi-level-select-single-rails",
69
+ name: "my_single_select_array",
70
+ tree_data: treeData,
71
+ input_name: "Power",
72
+ variant: "single"
73
+ }) %>