playbook_ui 12.26.1 → 12.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_flatpickr_styles.scss +11 -9
  3. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_month_and_year_styles.scss +1 -1
  4. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_week_styles.scss +1 -1
  5. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +1 -1
  6. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +134 -125
  7. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_default.html.erb +17 -17
  8. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_default.jsx +7 -4
  9. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_default.md +2 -2
  10. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_return_all_selected.html.erb +19 -16
  11. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_return_all_selected.jsx +2 -2
  12. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_with_form.html.erb +72 -0
  13. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +1 -0
  14. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.html.erb +7 -3
  15. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +3 -0
  16. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +109 -44
  17. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_validation.html.erb +14 -0
  18. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_validation.jsx +60 -0
  19. data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +3 -1
  20. data/app/pb_kits/playbook/pb_phone_number_input/docs/index.js +1 -0
  21. data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +6 -0
  22. data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.test.js +110 -62
  23. data/app/pb_kits/playbook/pb_rich_text_editor/_trix_styles.scss +2 -2
  24. data/app/pb_kits/playbook/pb_title/_title.scss +1 -1
  25. data/app/pb_kits/playbook/pb_title/_title.tsx +2 -3
  26. data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.html.erb +1 -0
  27. data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.jsx +6 -0
  28. data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.md +1 -2
  29. data/app/pb_kits/playbook/pb_title/title.rb +3 -10
  30. data/app/pb_kits/playbook/pb_title/title.test.js +3 -3
  31. data/app/pb_kits/playbook/utilities/object.ts +3 -0
  32. data/dist/playbook-rails.js +4 -4
  33. data/lib/playbook/forms/builder/intl_telephone_field.rb +12 -0
  34. data/lib/playbook/forms/builder/multi_level_select_field.rb +12 -0
  35. data/lib/playbook/forms/builder.rb +2 -0
  36. data/lib/playbook/version.rb +2 -2
  37. metadata +8 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7fbc9b56c02a9915257f3a1169f85773e8a063c14de44a2492a250f9015dee65
4
- data.tar.gz: f70c024e4feae26b0767595ad538df87eb08e78453a56c6ca22de07552d60d5d
3
+ metadata.gz: c8a90666ee111265053efa8a6306dcf5312bd5db5b1f9ed04f9f308efc4b800c
4
+ data.tar.gz: 5ff43b2f9c0b59121483cb30cfd1fcd24ba8fa02c65381000fb86b8ef5097fa9
5
5
  SHA512:
6
- metadata.gz: e40a155458785168e1fb5f5f63efe8c5bcd7dca3d1b8c618557d86453d5008336454d205330742fc029e6593e05e566610eb853577b42a993934eeb20408ffa5
7
- data.tar.gz: 9acc8dcd73190cc433572b49bdef61cb4e425304125aaf8d5b61c7426f5f4c2a314f1e2b38e9b55a5f37b6f45b56cb8079ec9b82070c461699ae9b2357689a2d
6
+ metadata.gz: 23a90f57292ebf633ef4d2305b4ca7c038abd1bfa8a0a2e8729c5c279522c265b76ca3e8f616076d5483990467baeaec22999d70dec6cb015f9064a64cba7e6a
7
+ data.tar.gz: ca7a82f0e5d3c9de8df3cef5c4913f1dbbd8890b0b29ebfd563f6cb02d5125c664a0a221cb676eb56a68e1f4be7ce26bd1507c0bf7893530a916ccf8e720891d
@@ -1,4 +1,6 @@
1
1
  // Manual Import -- Flatpickr Styles
2
+ @import "./tokens/typography";
3
+
2
4
  .flatpickr-calendar {
3
5
  background: transparent;
4
6
  opacity: 0;
@@ -295,7 +297,7 @@
295
297
  .flatpickr-current-month {
296
298
  font-size: 135%;
297
299
  line-height: inherit;
298
- font-weight: 300;
300
+ font-weight: $light;
299
301
  color: inherit;
300
302
  position: absolute;
301
303
  width: 75%;
@@ -310,7 +312,7 @@
310
312
  }
311
313
  .flatpickr-current-month span.cur-month {
312
314
  font-family: inherit;
313
- font-weight: 700;
315
+ font-weight: $bolder;
314
316
  color: inherit;
315
317
  display: inline-block;
316
318
  margin-left: 0.5ch;
@@ -341,7 +343,7 @@
341
343
  display: inline-block;
342
344
  font-size: inherit;
343
345
  font-family: inherit;
344
- font-weight: 300;
346
+ font-weight: $light;
345
347
  line-height: inherit;
346
348
  height: auto;
347
349
  border: 0;
@@ -371,7 +373,7 @@
371
373
  cursor: pointer;
372
374
  font-size: inherit;
373
375
  font-family: inherit;
374
- font-weight: 300;
376
+ font-weight: $light;
375
377
  height: auto;
376
378
  line-height: inherit;
377
379
  margin: -1px 0 0 0;
@@ -492,7 +494,7 @@ span.flatpickr-weekday {
492
494
  box-sizing: border-box;
493
495
  color: #393939;
494
496
  cursor: pointer;
495
- font-weight: 400;
497
+ font-weight: $regular;
496
498
  width: 14.2857143%;
497
499
  -webkit-flex-basis: 14.2857143%;
498
500
  -ms-flex-preferred-size: 14.2857143%;
@@ -707,11 +709,11 @@ span.flatpickr-weekday {
707
709
  appearance: textfield;
708
710
  }
709
711
  .flatpickr-time input.flatpickr-hour {
710
- font-weight: bold;
712
+ font-weight: $bolder;
711
713
  }
712
714
  .flatpickr-time input.flatpickr-minute,
713
715
  .flatpickr-time input.flatpickr-second {
714
- font-weight: 400;
716
+ font-weight: $regular;
715
717
  }
716
718
  .flatpickr-time input:focus {
717
719
  outline: 0;
@@ -723,7 +725,7 @@ span.flatpickr-weekday {
723
725
  float: left;
724
726
  line-height: inherit;
725
727
  color: #393939;
726
- font-weight: bold;
728
+ font-weight: $bolder;
727
729
  width: 2%;
728
730
  -webkit-user-select: none;
729
731
  -moz-user-select: none;
@@ -738,7 +740,7 @@ span.flatpickr-weekday {
738
740
  width: 18%;
739
741
  cursor: pointer;
740
742
  text-align: center;
741
- font-weight: 400;
743
+ font-weight: $regular;
742
744
  }
743
745
  .flatpickr-time input:hover,
744
746
  .flatpickr-time .flatpickr-am-pm:hover,
@@ -20,7 +20,7 @@
20
20
  color: $text_lt_default;
21
21
  cursor: pointer;
22
22
  display: inline-block;
23
- font-weight: 400;
23
+ font-weight: $regular;
24
24
  margin: 0.5px;
25
25
  justify-content: center;
26
26
  padding: 10px;
@@ -20,7 +20,7 @@
20
20
  color: $text_lt_default;
21
21
  cursor: pointer;
22
22
  display: inline-block;
23
- font-weight: 400;
23
+ font-weight: $regular;
24
24
  margin: 0.5px;
25
25
  justify-content: center;
26
26
  padding: 10px;
@@ -56,7 +56,7 @@ $form_pill_colors: (
56
56
  height: -moz-fit-content;
57
57
  .pb_form_pill_text, .pb_form_pill_close, .pb_form_pill_tag {
58
58
  font-size: 16px;
59
- font-weight: 400;
59
+ font-weight: $regular;
60
60
  }
61
61
  .pb_form_pill_text, .pb_form_pill_tag {
62
62
  line-height: 1.7;
@@ -1,12 +1,12 @@
1
- import React, { useState, useEffect, useRef } from "react";
2
- import classnames from "classnames";
3
- import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props";
4
- import { globalProps, GlobalProps } from "../utilities/globalProps";
5
- import Icon from "../pb_icon/_icon";
6
- import Checkbox from "../pb_checkbox/_checkbox";
7
- import FormPill from "../pb_form_pill/_form_pill";
8
- import CircleIconButton from "../pb_circle_icon_button/_circle_icon_button";
9
- import { cloneDeep } from "lodash";
1
+ import React, { useState, useEffect, useRef } from "react"
2
+ import classnames from "classnames"
3
+ import { globalProps, GlobalProps } from "../utilities/globalProps"
4
+ import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props"
5
+ import Checkbox from "../pb_checkbox/_checkbox"
6
+ import Icon from "../pb_icon/_icon"
7
+ import FormPill from "../pb_form_pill/_form_pill"
8
+ import CircleIconButton from "../pb_circle_icon_button/_circle_icon_button"
9
+ import { cloneDeep } from "lodash"
10
10
 
11
11
  import {
12
12
  getAncestorsOfUnchecked,
@@ -15,17 +15,18 @@ import {
15
15
  getCheckedItems,
16
16
  getDefaultCheckedItems,
17
17
  recursiveCheckParent,
18
- } from "./_helper_functions";
18
+ } from "./_helper_functions"
19
19
 
20
20
  type MultiLevelSelectProps = {
21
- aria?: { [key: string]: string };
22
- className?: string;
23
- data?: { [key: string]: string };
24
- id?: string;
25
- returnAllSelected?: boolean;
26
- treeData?: { [key: string]: string }[];
27
- onSelect?: (prop: { [key: string]: any }) => void;
28
- } & GlobalProps;
21
+ aria?: { [key: string]: string }
22
+ className?: string
23
+ data?: { [key: string]: string }
24
+ id?: string
25
+ name?: string
26
+ returnAllSelected?: boolean
27
+ treeData?: { [key: string]: string }[]
28
+ onSelect?: (prop: { [key: string]: any }) => void
29
+ } & GlobalProps
29
30
 
30
31
  const MultiLevelSelect = (props: MultiLevelSelectProps) => {
31
32
  const {
@@ -33,71 +34,74 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
33
34
  className,
34
35
  data = {},
35
36
  id,
37
+ name,
36
38
  returnAllSelected = false,
37
39
  treeData,
38
40
  onSelect = () => {},
39
- } = props;
41
+ } = props
40
42
 
41
- const ariaProps = buildAriaProps(aria);
42
- const dataProps = buildDataProps(data);
43
+ const ariaProps = buildAriaProps(aria)
44
+ const dataProps = buildDataProps(data)
43
45
  const classes = classnames(
44
46
  buildCss("pb_multi_level_select"),
45
47
  globalProps(props),
46
48
  className
47
- );
49
+ )
50
+
51
+ const dropdownRef = useRef(null)
48
52
 
49
- const dropdownRef = useRef(null);
50
53
 
51
54
  //state for expanded property
52
- const [expanded, setExpanded] = useState([]);
55
+ const [expanded, setExpanded] = useState([])
53
56
  //state for whether dropdown is open or closed
54
- const [isClosed, setIsClosed] = useState(true);
57
+ const [isClosed, setIsClosed] = useState(true)
55
58
  //state from onchange for textinput, to use for filtering to create typeahead
56
- const [filterItem, setFilterItem] = useState("");
59
+ const [filterItem, setFilterItem] = useState("")
57
60
  //this is essentially the return that the user will get when they use the kit
58
- const [returnedArray, setReturnedArray] = useState([]);
61
+ const [returnedArray, setReturnedArray] = useState([])
59
62
  //formattedData with checked and parent_id added
60
- const [formattedData, setFormattedData] = useState([]);
63
+ const [formattedData, setFormattedData] = useState([])
61
64
  //state for return for default
62
- const [defaultReturn, setDefaultReturn] = useState([]);
65
+ const [defaultReturn, setDefaultReturn] = useState([])
66
+
63
67
 
64
68
  useEffect(() => {
65
- setFormattedData(addCheckedAndParentProperty(treeData));
66
- }, [treeData]);
69
+ setFormattedData(addCheckedAndParentProperty(treeData))
70
+ }, [treeData])
67
71
 
68
72
  useEffect(() => {
69
73
  if (returnAllSelected) {
70
- setReturnedArray(getCheckedItems(formattedData));
74
+ setReturnedArray(getCheckedItems(formattedData))
71
75
  } else {
72
- setDefaultReturn(getDefaultCheckedItems(formattedData));
76
+ setDefaultReturn(getDefaultCheckedItems(formattedData))
73
77
  }
74
- }, [formattedData]);
78
+ }, [formattedData])
75
79
 
76
80
  useEffect(() => {
77
81
  // Function to handle clicks outside the dropdown
78
82
  const handleClickOutside = (event: any) => {
79
83
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
80
- setIsClosed(true);
84
+ setIsClosed(true)
81
85
  }
82
- };
86
+ }
83
87
  // Attach the event listener
84
- window.addEventListener("click", handleClickOutside);
88
+ window.addEventListener("click", handleClickOutside)
85
89
  // Clean up the event listener on unmount
86
90
  return () => {
87
- window.removeEventListener("click", handleClickOutside);
88
- };
89
- }, []);
91
+ window.removeEventListener("click", handleClickOutside)
92
+ }
93
+ }, [])
90
94
 
91
95
  const modifyRecursive = (tree: { [key: string]: any }[], check: boolean) => {
92
96
  if (!Array.isArray(tree)) {
93
- return;
97
+ return
94
98
  }
95
99
  return tree.map((item: { [key: string]: any }) => {
96
- item.checked = check;
97
- item.children = modifyRecursive(item.children, check);
98
- return item;
99
- });
100
- };
100
+ item.checked = check
101
+ item.children = modifyRecursive(item.children, check)
102
+ return item
103
+ })
104
+ }
101
105
 
102
106
  //iterate over tree, find item and set checked or unchecked
103
107
  const modifyValue = (
@@ -106,48 +110,48 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
106
110
  check: boolean
107
111
  ) => {
108
112
  if (!Array.isArray(tree)) {
109
- return;
113
+ return
110
114
  }
111
115
  return tree.map((item: any) => {
112
- if (item.id != id) item.children = modifyValue(id, item.children, check);
116
+ if (item.id != id) item.children = modifyValue(id, item.children, check)
113
117
  else {
114
- item.checked = check;
115
- item.children = modifyRecursive(item.children, check);
118
+ item.checked = check
119
+ item.children = modifyRecursive(item.children, check)
116
120
  }
117
121
 
118
- return item;
119
- });
120
- };
122
+ return item
123
+ })
124
+ }
121
125
 
122
126
  //clone tree, check items + children
123
127
  const checkItem = (item: { [key: string]: any }) => {
124
- const tree = cloneDeep(formattedData);
128
+ const tree = cloneDeep(formattedData)
125
129
  if (returnAllSelected) {
126
- return modifyValue(item.id, tree, true);
130
+ return modifyValue(item.id, tree, true)
127
131
  } else {
128
- const checkedTree = modifyValue(item.id, tree, true);
129
- return recursiveCheckParent(item, checkedTree);
132
+ const checkedTree = modifyValue(item.id, tree, true)
133
+ return recursiveCheckParent(item, checkedTree)
130
134
  }
131
- };
135
+ }
132
136
 
133
137
  //clone tree, uncheck items + children
134
138
  const unCheckItem = (item: { [key: string]: any }) => {
135
- const tree = cloneDeep(formattedData);
139
+ const tree = cloneDeep(formattedData)
136
140
  if (returnAllSelected) {
137
- return modifyValue(item.id, tree, false);
141
+ return modifyValue(item.id, tree, false)
138
142
  } else {
139
- const uncheckedTree = modifyValue(item.id, tree, false);
140
- return getAncestorsOfUnchecked(uncheckedTree, item);
143
+ const uncheckedTree = modifyValue(item.id, tree, false)
144
+ return getAncestorsOfUnchecked(uncheckedTree, item)
141
145
  }
142
- };
146
+ }
143
147
 
144
148
  //setformattedData with proper properties
145
149
  const changeItem = (item: { [key: string]: any }, check: boolean) => {
146
- const tree = check ? checkItem(item) : unCheckItem(item);
147
- setFormattedData(tree);
150
+ const tree = check ? checkItem(item) : unCheckItem(item)
151
+ setFormattedData(tree)
148
152
 
149
- return tree;
150
- };
153
+ return tree
154
+ }
151
155
 
152
156
  //function to map over data and add parent_id + depth property to each item
153
157
  const addCheckedAndParentProperty = (
@@ -156,87 +160,86 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
156
160
  depth: number = 0
157
161
  ) => {
158
162
  if (!Array.isArray(treeData)) {
159
- return;
163
+ return
160
164
  }
161
165
  return treeData.map((item: { [key: string]: any } | any) => {
162
166
  const newItem = {
163
167
  ...item,
164
168
  parent_id,
165
169
  depth,
166
- };
170
+ }
167
171
  if (newItem.children && newItem.children.length > 0) {
168
172
  const children =
169
173
  item.checked && !returnAllSelected
170
174
  ? modifyRecursive(item.children, true)
171
- : item.children;
175
+ : item.children
172
176
  newItem.children = addCheckedAndParentProperty(
173
177
  children,
174
178
  newItem.id,
175
179
  depth + 1
176
- );
180
+ )
177
181
  }
178
- return newItem;
179
- });
180
- };
182
+ return newItem
183
+ })
184
+ }
181
185
 
182
186
  //click event for x on form pill
183
187
  const handlePillClose = (event: any, clickedItem: { [key: string]: any }) => {
184
188
  // prevents the dropdown from closing when clicking on the pill
185
- event.stopPropagation();
186
- const updatedTree = changeItem(clickedItem, false);
189
+ event.stopPropagation()
190
+ const updatedTree = changeItem(clickedItem, false)
187
191
  //logic for removing items from returnArray or defaultReturn when pills clicked
188
192
  if (returnAllSelected) {
189
- onSelect(getCheckedItems(updatedTree));
193
+ onSelect(getCheckedItems(updatedTree))
190
194
  } else {
191
- onSelect(getDefaultCheckedItems(updatedTree));
195
+ onSelect(getDefaultCheckedItems(updatedTree))
192
196
  }
193
- };
197
+ }
194
198
 
195
199
  //handle click on input wrapper(entire div with pills, typeahead, etc) so it doesn't close when input or form pill is clicked
196
200
  const handleInputWrapperClick = (e: any) => {
197
- e.stopPropagation();
201
+ e.stopPropagation()
198
202
  if (
199
203
  e.target.id === "multiselect_input" ||
200
204
  e.target.classList.contains("pb_form_pill_tag")
201
205
  ) {
202
- return;
206
+ return
203
207
  }
204
- setIsClosed(!isClosed);
205
- };
208
+ setIsClosed(!isClosed)
209
+ }
206
210
 
207
211
  //Main function to handle any click inside dropdown
208
212
  const handledropdownItemClick = (e: any, check: boolean) => {
209
- const clickedItem = e.target.parentNode.id;
213
+ const clickedItem = e.target.parentNode.id
210
214
  //setting filterItem to "" will clear textinput and clear typeahead
211
- setFilterItem("");
215
+ setFilterItem("")
212
216
 
213
- const filtered = filterFormattedDataById(formattedData, clickedItem);
214
- const updatedTree = changeItem(filtered[0], check);
215
- console.log(updatedTree);
217
+ const filtered = filterFormattedDataById(formattedData, clickedItem)
218
+ const updatedTree = changeItem(filtered[0], check)
216
219
  if (returnAllSelected) {
217
- onSelect(getCheckedItems(updatedTree));
220
+ onSelect(getCheckedItems(updatedTree))
218
221
  } else {
219
- onSelect(getDefaultCheckedItems(updatedTree));
222
+ onSelect(getDefaultCheckedItems(updatedTree))
220
223
  }
221
- };
224
+ }
222
225
 
223
- const isExpanded = (item: any) => expanded.indexOf(item.id) > -1;
226
+ const isExpanded = (item: any) => expanded.indexOf(item.id) > -1
224
227
 
225
228
  //handle click on chevron toggles in dropdown
226
229
  const handleToggleClick = (id: string, event: React.MouseEvent) => {
227
- event.stopPropagation();
228
- const clickedItem = filterFormattedDataById(formattedData, id);
230
+ event.stopPropagation()
231
+ const clickedItem = filterFormattedDataById(formattedData, id)
229
232
  if (clickedItem) {
230
- let expandedArray = [...expanded];
231
- const itemExpanded = isExpanded(clickedItem[0]);
233
+ let expandedArray = [...expanded]
234
+ const itemExpanded = isExpanded(clickedItem[0])
232
235
 
233
236
  if (itemExpanded)
234
- expandedArray = expandedArray.filter((i) => i != clickedItem[0].id);
235
- else expandedArray.push(clickedItem[0].id);
237
+ expandedArray = expandedArray.filter((i) => i != clickedItem[0].id)
238
+ else expandedArray.push(clickedItem[0].id)
236
239
 
237
- setExpanded(expandedArray);
240
+ setExpanded(expandedArray)
238
241
  }
239
- };
242
+ }
240
243
 
241
244
  //rendering formattedData to UI based on typeahead
242
245
  const renderNestedOptions = (items: { [key: string]: any }[]) => {
@@ -245,9 +248,9 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
245
248
  {Array.isArray(items) &&
246
249
  items.map((item: { [key: string]: any }) => {
247
250
  return (
248
- <>
249
- <li key={item.id} className="dropdown_item" data-name={item.id}>
250
- <div className="dropdown_item_checkbox_row">
251
+ <div key={item.id}>
252
+ <li className='dropdown_item' data-name={item.id}>
253
+ <div className='dropdown_item_checkbox_row'>
251
254
  <div
252
255
  key={isExpanded(item) ? "chevron-down" : "chevron-right"}
253
256
  >
@@ -263,17 +266,17 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
263
266
  onClick={(event: any) =>
264
267
  handleToggleClick(item.id, event)
265
268
  }
266
- variant="link"
269
+ variant='link'
267
270
  />
268
271
  </div>
269
272
  <Checkbox text={item.label} id={item.id}>
270
273
  <input
271
274
  checked={item.checked}
272
- type="checkbox"
275
+ type='checkbox'
273
276
  name={item.label}
274
277
  value={item.label}
275
278
  onChange={(e) => {
276
- handledropdownItemClick(e, !item.checked);
279
+ handledropdownItemClick(e, !item.checked)
277
280
  }}
278
281
  />
279
282
  </Checkbox>
@@ -285,24 +288,30 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
285
288
  <div>{renderNestedOptions(item.children)}</div>
286
289
  )}
287
290
  </li>
288
- </>
289
- );
291
+ </div>
292
+ )
290
293
  })}
291
294
  </ul>
292
- );
293
- };
295
+ )
296
+ }
294
297
 
295
298
  return (
296
299
  <div {...ariaProps} {...dataProps} className={classes} id={id}>
297
- <div ref={dropdownRef} className="wrapper">
298
- <div className="input_wrapper" onClick={handleInputWrapperClick}>
299
- <div className="input_inner_container">
300
+ <div ref={dropdownRef} className='wrapper'>
301
+ <div className='input_wrapper' onClick={handleInputWrapperClick}>
302
+ <div className='input_inner_container'>
303
+ {returnedArray.length !== 0 && returnAllSelected
304
+ ? returnedArray.map((item) => (
305
+ <input type='hidden' name={`${name}[]`} value={item.id} />
306
+ ))
307
+ : null}
308
+
300
309
  {returnedArray.length !== 0 && returnAllSelected
301
310
  ? returnedArray.map((item, index) => (
302
311
  <FormPill
303
312
  key={index}
304
313
  text={item.label}
305
- size="small"
314
+ size='small'
306
315
  onClick={(event: any) => handlePillClose(event, item)}
307
316
  />
308
317
  ))
@@ -313,29 +322,29 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
313
322
  <FormPill
314
323
  key={index}
315
324
  text={item.label}
316
- size="small"
325
+ size='small'
317
326
  onClick={(event: any) => handlePillClose(event, item)}
318
327
  />
319
328
  ))}
320
329
  {returnedArray.length !== 0 && returnAllSelected && <br />}
321
330
  {defaultReturn.length !== 0 && !returnAllSelected && <br />}
322
331
  <input
323
- id="multiselect_input"
332
+ id='multiselect_input'
324
333
  onChange={(e) => {
325
- setFilterItem(e.target.value);
334
+ setFilterItem(e.target.value)
326
335
  }}
327
- placeholder="Start typing..."
336
+ placeholder='Start typing...'
328
337
  value={filterItem}
329
338
  onClick={() => setIsClosed(false)}
330
339
  />
331
340
  </div>
332
341
  {isClosed ? (
333
- <div key="chevron-down">
334
- <Icon icon="chevron-down" />
342
+ <div key='chevron-down'>
343
+ <Icon icon='chevron-down' />
335
344
  </div>
336
345
  ) : (
337
- <div key="chevron-up">
338
- <Icon icon="chevron-up" />
346
+ <div key='chevron-up'>
347
+ <Icon icon='chevron-up' />
339
348
  </div>
340
349
  )}
341
350
  </div>
@@ -346,7 +355,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
346
355
  </div>
347
356
  </div>
348
357
  </div>
349
- );
350
- };
358
+ )
359
+ }
351
360
 
352
- export default MultiLevelSelect;
361
+ export default MultiLevelSelect
@@ -1,72 +1,72 @@
1
1
  <% treeData = [{
2
2
  label: "Power Home Remodeling",
3
3
  value: "Power Home Remodeling",
4
- id: "powerhome1",
4
+ id: "100",
5
5
  expanded: true,
6
6
  children: [
7
7
  {
8
8
  label: "People",
9
9
  value: "People",
10
- id: "people1",
10
+ id: "101",
11
11
  children: [
12
12
  {
13
13
  label: "Talent Acquisition",
14
14
  value: "Talent Acquisition",
15
- id: "talent1",
15
+ id: "102",
16
16
  },
17
17
  {
18
18
  label: "Business Affairs",
19
19
  value: "Business Affairs",
20
- id: "business1",
20
+ id: "103",
21
21
  children: [
22
22
  {
23
23
  label: "Initiatives",
24
24
  value: "Initiatives",
25
- id: "initiative1",
25
+ id: "104",
26
26
  },
27
27
  {
28
28
  label: "Learning & Development",
29
29
  value: "Learning & Development",
30
- id: "development1",
30
+ id: "105",
31
31
  },
32
32
  ],
33
33
  },
34
34
  {
35
35
  label: "People Experience",
36
36
  value: "People Experience",
37
- id: "experience1",
37
+ id: "106",
38
38
  },
39
39
  ],
40
40
  },
41
41
  {
42
42
  label: "Contact Center",
43
43
  value: "Contact Center",
44
- id: "contact1",
44
+ id: "107",
45
45
  children: [
46
46
  {
47
47
  label: "Appointment Management",
48
48
  value: "Appointment Management",
49
- id: "appointment1",
49
+ id: "108",
50
50
  },
51
51
  {
52
52
  label: "Customer Service",
53
53
  value: "Customer Service",
54
- id: "customer1",
54
+ id: "109",
55
55
  },
56
56
  {
57
57
  label: "Energy",
58
58
  value: "Energy",
59
- id: "energy1",
59
+ id: "110",
60
60
  },
61
61
  ],
62
62
  },
63
63
  ],
64
- }] %>
64
+ }] %>
65
65
 
66
66
 
67
- <%= pb_rails("multi_level_select", props: {
68
- id: "default-multi-level-select",
69
- tree_data:treeData
70
- }) %>
71
-
72
67
 
68
+ <%= pb_rails("multi_level_select", props: {
69
+ id: "multi-level-select-default-rails",
70
+ name: "my_array",
71
+ tree_data: treeData
72
+ }) %>