playbook_ui 16.1.0.pre.alpha.play264213818 → 16.1.0.pre.alpha.play277814027

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.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +12 -2
  3. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +33 -0
  4. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_background_custom.jsx +71 -0
  5. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_background_custom.md +4 -0
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -1
  8. data/app/pb_kits/playbook/pb_card/docs/_card_light.html.erb +3 -35
  9. data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +14 -5
  10. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default.md +1 -0
  11. data/app/pb_kits/playbook/pb_dialog/_dialog.scss +8 -6
  12. data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +6 -0
  13. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +37 -2
  14. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_blank_selection_rails.md +3 -0
  15. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_blank_selection_react.md +3 -0
  16. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_clearable.html.erb +52 -0
  17. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_clearable.jsx +72 -0
  18. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_clearable.md +5 -0
  19. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_constrain_height.jsx +33 -0
  20. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_constrain_height_rails.html.erb +20 -0
  21. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_constrain_height_rails.md +8 -0
  22. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_constrain_height_react.md +8 -0
  23. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_placeholder.html.erb +9 -0
  24. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_placeholder.jsx +33 -0
  25. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_placeholder.md +3 -0
  26. data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +6 -0
  27. data/app/pb_kits/playbook/pb_dropdown/docs/index.js +4 -1
  28. data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +2 -2
  29. data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +6 -0
  30. data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +94 -0
  31. data/app/pb_kits/playbook/pb_dropdown/dropdown_container.rb +5 -1
  32. data/app/pb_kits/playbook/pb_dropdown/index.js +59 -4
  33. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx +3 -0
  34. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +2 -1
  35. data/app/pb_kits/playbook/pb_filter/Filter/SortMenu.tsx +1 -1
  36. data/app/pb_kits/playbook/pb_filter/docs/_filter_default.html.erb +2 -2
  37. data/app/pb_kits/playbook/pb_filter/docs/_filter_default.jsx +16 -9
  38. data/app/pb_kits/playbook/pb_filter/filter.rb +2 -2
  39. data/app/pb_kits/playbook/pb_form/docs/_form_with_required_indicator.html.erb +2 -0
  40. data/app/pb_kits/playbook/pb_form/pb_form_validation.js +9 -2
  41. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.html.erb +5 -5
  42. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.jsx +4 -4
  43. data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +4 -0
  44. data/app/pb_kits/playbook/pb_passphrase/_passphrase.tsx +20 -5
  45. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.jsx +1 -0
  46. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_required_indicator.html.erb +7 -0
  47. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_required_indicator.jsx +24 -0
  48. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_required_indicator.md +3 -0
  49. data/app/pb_kits/playbook/pb_passphrase/docs/example.yml +2 -0
  50. data/app/pb_kits/playbook/pb_passphrase/docs/index.js +1 -0
  51. data/app/pb_kits/playbook/pb_passphrase/passphrase.rb +2 -0
  52. data/app/pb_kits/playbook/pb_passphrase/passphrase.test.jsx +30 -1
  53. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +3 -0
  54. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_required_indicator.html.erb +5 -0
  55. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_required_indicator.jsx +14 -0
  56. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_required_indicator.md +3 -0
  57. data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +2 -0
  58. data/app/pb_kits/playbook/pb_phone_number_input/docs/index.js +1 -0
  59. data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +3 -0
  60. data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.test.js +34 -3
  61. data/app/pb_kits/playbook/pb_textarea/_textarea.tsx +10 -0
  62. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_default.html.erb +3 -3
  63. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_default.jsx +3 -0
  64. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_default.md +1 -0
  65. data/app/pb_kits/playbook/pb_textarea/textarea.html.erb +25 -9
  66. data/app/pb_kits/playbook/pb_textarea/textarea.rb +7 -1
  67. data/app/pb_kits/playbook/pb_time_picker/_time_picker.tsx +97 -11
  68. data/app/pb_kits/playbook/pb_time_picker/docs/_time_picker_on_handler.jsx +5 -2
  69. data/app/pb_kits/playbook/pb_time_picker/docs/_time_picker_required_indicator.html.erb +6 -0
  70. data/app/pb_kits/playbook/pb_time_picker/docs/_time_picker_required_indicator.jsx +16 -0
  71. data/app/pb_kits/playbook/pb_time_picker/docs/_time_picker_required_indicator.md +3 -0
  72. data/app/pb_kits/playbook/pb_time_picker/docs/example.yml +2 -0
  73. data/app/pb_kits/playbook/pb_time_picker/docs/index.js +1 -0
  74. data/app/pb_kits/playbook/pb_time_picker/time_picker.rb +3 -0
  75. data/app/pb_kits/playbook/pb_time_picker/time_picker.test.jsx +47 -1
  76. data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +24 -1
  77. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +2 -1
  78. data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +4 -1
  79. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_truncated_text.html.erb +1 -1
  80. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_truncated_text.jsx +1 -1
  81. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +4 -0
  82. data/dist/chunks/_typeahead-CWA5wlah.js +1 -0
  83. data/dist/chunks/vendor.js +3 -3
  84. data/dist/menu.yml +2 -2
  85. data/dist/playbook-rails-react-bindings.js +1 -1
  86. data/dist/playbook-rails.js +1 -1
  87. data/dist/playbook.css +1 -1
  88. data/lib/playbook/forms/builder/phone_number_field.rb +9 -0
  89. data/lib/playbook/truncate.rb +1 -1
  90. data/lib/playbook/version.rb +1 -1
  91. metadata +28 -3
  92. data/dist/chunks/_typeahead-B9a6ZsEP.js +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5780d8a980b27fef50be2bd9f824684732373c72b707d5af5f8071c627b878a
4
- data.tar.gz: b304d2a4a3bd2a77b73ba7e95b70f5aff9bd6b1f4b78ed99a494712666ce6a1a
3
+ metadata.gz: 1ba1ccdd547ffbb9a3028c4f7ebe9c545e978f3a156cb09f8d23f72be12ca8e5
4
+ data.tar.gz: c99e2ee648ba1e7a07f2312a927705a23b2c0d231d25e6d9f7ff896c1994cc47
5
5
  SHA512:
6
- metadata.gz: c8133ed39e3328aa2e76508e31c51e7ff0c81103c99f8c2324367333e2168ea08610f59fdff5d1bef97d3372637ee29150ee3d6541d83c3cea7417414bed5481
7
- data.tar.gz: f5488d8e0b060a56590d3c390d832a1760d9bd7e1b97a02afc0958c9252ae67f9667f2856d2ff70d3cdfc8fe71658aa2135bccef62f154e68a1db7f2a20fa807
6
+ metadata.gz: d3cd8f6f1ce697e21eba5d9e2825d2b9e405282cde1f2944dae69b6bf159c643e10ed0726cd88015fbf15c4da6727408afb25b318c8196bcc58457c976cb7bf2
7
+ data.tar.gz: 2d7b6db05ed92ce9a0d2c0f8a4bfcb374f4bea28e4807b1591d38a1a792902ba45bd086e4b36dc696330187142185f6995f566bec7d4b3e851363571bd2d7c76
@@ -66,8 +66,18 @@ const TableCellRenderer = ({
66
66
  // Find the "owning" colDefinition by accessor. Needed for multi column logic
67
67
  const colDef = findColumnDefByAccessor(columnDefinitions ?? [], column.id)
68
68
  const cellAlignment = colDef?.columnStyling?.cellAlignment ?? "right"
69
- const cellFontColor = colDef?.columnStyling?.fontColor
70
- const cellBackgroundColor = colDef?.columnStyling?.cellBackgroundColor
69
+
70
+ // Support function-based styling for conditional rendering
71
+ const cellFontColorValue = colDef?.columnStyling?.fontColor
72
+ const cellFontColor = typeof cellFontColorValue === 'function'
73
+ ? cellFontColorValue(row)
74
+ : cellFontColorValue
75
+
76
+ const cellBackgroundColorValue = colDef?.columnStyling?.cellBackgroundColor
77
+ const cellBackgroundColor = typeof cellBackgroundColorValue === 'function'
78
+ ? cellBackgroundColorValue(row)
79
+ : cellBackgroundColorValue
80
+
71
81
  const paddingValue = colDef?.columnStyling?.cellPadding ?? customRowStyle?.cellPadding
72
82
  const paddingClass = paddingValue ? `p_${paddingValue}` : undefined
73
83
 
@@ -920,6 +920,39 @@ test("columnStyling.backgroundColor works as excpected", () => {
920
920
  expect(firstEnrollmentCell).toHaveStyle({ backgroundColor: colors.error_subtle });
921
921
  });
922
922
 
923
+ test("columnStyling.cellBackgroundColor works as expected with function", () => {
924
+ const styledColumnDefs = [
925
+ {
926
+ accessor: "year",
927
+ label: "Year",
928
+ cellAccessors: ["quarter", "month", "day"],
929
+ },
930
+ {
931
+ accessor: "newEnrollments",
932
+ label: "New Enrollments",
933
+ columnStyling:{
934
+ cellBackgroundColor: (row) => row.original.newEnrollments > 15 ? colors.success_subtle : colors.error_subtle,
935
+ fontColor: (row) => row.original.newEnrollments > 15 ? colors.success : colors.error,
936
+ },
937
+ },
938
+ {
939
+ accessor: "scheduledMeetings",
940
+ label: "Scheduled Meetings",
941
+ },
942
+ ];
943
+
944
+ render(
945
+ <AdvancedTable
946
+ columnDefinitions={styledColumnDefs}
947
+ data={{ testid: testId }}
948
+ tableData={MOCK_DATA}
949
+ />
950
+ );
951
+
952
+ const firstEnrollmentCell = screen.getAllByText("20")[0].closest("td");
953
+ expect(firstEnrollmentCell).toHaveStyle({ backgroundColor: colors.success_subtle, color: colors.success });
954
+ });
955
+
923
956
  test("columnStyling.headerBackgroundColor works as excpected", () => {
924
957
  const styledColumnDefs = [
925
958
  {
@@ -0,0 +1,71 @@
1
+ import React from "react"
2
+ import AdvancedTable from '../_advanced_table'
3
+ import colors from '../../tokens/exports/_colors.module.scss'
4
+ import MOCK_DATA from "./advanced_table_mock_data.json"
5
+ import Flex from '../../pb_flex/_flex'
6
+ import Title from '../../pb_title/_title'
7
+ import Body from '../../pb_body/_body'
8
+
9
+
10
+ const AdvancedTableColumnStylingBackgroundCustom = (props) => {
11
+ const columnDefinitions = [
12
+ {
13
+ accessor: "year",
14
+ label: "Year",
15
+ cellAccessors: ["quarter", "month", "day"],
16
+ customRenderer: (row, value) => (
17
+ <Flex flexDirection="column">
18
+ <Title size={4}
19
+ text={value}
20
+ />
21
+ <Body text="lorem ipsum" />
22
+ <Body text="lorem ipsum" />
23
+ </Flex>
24
+ ),
25
+ },
26
+ {
27
+ accessor: "newEnrollments",
28
+ label: "New Enrollments",
29
+ columnStyling:{
30
+ cellBackgroundColor: (row) => row.original.newEnrollments > 15 ? colors.success_subtle : colors.error_subtle,
31
+ fontColor: (row) => row.original.newEnrollments > 15 ? colors.success : colors.error,
32
+ },
33
+ },
34
+ {
35
+ accessor: "scheduledMeetings",
36
+ label: "Scheduled Meetings",
37
+ columnStyling:{
38
+ cellBackgroundColor: (row) => row.original.scheduledMeetings >= 15 ? colors.info_subtle : colors.warning_subtle
39
+ },
40
+ },
41
+ {
42
+ accessor: "attendanceRate",
43
+ label: "Attendance Rate",
44
+ columnStyling:{cellBackgroundColor: colors.info, headerBackgroundColor: colors.info, fontColor: colors.white, headerFontColor: colors.white},
45
+ },
46
+ {
47
+ accessor: "completedClasses",
48
+ label: "Completed Classes",
49
+ },
50
+ {
51
+ accessor: "classCompletionRate",
52
+ label: "Class Completion Rate",
53
+ },
54
+ {
55
+ accessor: "graduatedStudents",
56
+ label: "Graduated Students",
57
+ },
58
+ ]
59
+
60
+ return (
61
+ <div>
62
+ <AdvancedTable
63
+ columnDefinitions={columnDefinitions}
64
+ tableData={MOCK_DATA}
65
+ {...props}
66
+ />
67
+ </div>
68
+ )
69
+ }
70
+
71
+ export default AdvancedTableColumnStylingBackgroundCustom
@@ -0,0 +1,4 @@
1
+ `cellBackgroundColor` and `fontColor` can also accept functions for conditional styling based on row data. The function receives the row object and returns a color value.
2
+
3
+ See the code snippet below for more details.
4
+
@@ -78,6 +78,7 @@ examples:
78
78
  - advanced_table_column_styling: Column Styling
79
79
  - advanced_table_column_styling_column_headers: Column Styling with Multiple Headers
80
80
  - advanced_table_column_styling_background: Column Styling Background Color
81
+ - advanced_table_column_styling_background_custom: Column Styling Background Color (Custom)
81
82
  - advanced_table_column_styling_background_multi: Column Styling Background Color with Multiple Headers
82
83
  - advanced_table_padding_control: Padding Control using Column Styling
83
84
  - advanced_table_column_border_color: Column Group Border Color
@@ -47,4 +47,5 @@ export { default as AdvancedTableSortPerColumnForMultiColumn } from './_advanced
47
47
  export { default as AdvancedTablePaddingControl } from './_advanced_table_padding_control.jsx'
48
48
  export { default as AdvancedTablePaddingControlPerRow } from './_advanced_table_padding_control_per_row.jsx'
49
49
  export { default as AdvancedTableColumnStylingBackground } from './_advanced_table_column_styling_background.jsx'
50
- export { default as AdvancedTableColumnStylingBackgroundMulti } from './_advanced_table_column_styling_background_multi.jsx'
50
+ export { default as AdvancedTableColumnStylingBackgroundMulti } from './_advanced_table_column_styling_background_multi.jsx'
51
+ export { default as AdvancedTableColumnStylingBackgroundCustom } from './_advanced_table_column_styling_background_custom.jsx'
@@ -1,36 +1,4 @@
1
- <%= pb_rails("flex", props: {
2
- gap: "md",
3
- orientation: "column"
4
- }) do %>
5
-
6
- <%= pb_rails("caption", props: { text: "flex direction responsive: row on md + xl, column as default" }) %>
7
- <%= pb_rails("card", props: {
8
- flex_direction: { default: "column", md: "row", xl:"row" }
9
- }) do %>
10
- <%= pb_rails("body", props: { text: "Item 1", color: "default" }) %>
11
- <%= pb_rails("body", props: { text: "Item 2", color: "default" }) %>
12
- <%= pb_rails("body", props: { text: "Item 3", color: "default" }) %>
13
- <% end %>
14
-
15
- <%= pb_rails("caption", props: { text: "align items responsive: start on default, center on md, end on lg" }) %>
16
- <%= pb_rails("card", props: {
17
- display: "flex",
18
- flex_direction: "row",
19
- align_items: { default: "start", md: "center", lg: "end" },
20
- }) do %>
21
- <%= pb_rails("card", props: {height:"xs" }) do %> Card 1 <% end %>
22
- <%= pb_rails("card", props: { height:"sm" }) do %> Card 2 <% end %>
23
- <%= pb_rails("card", props: { height:"xs" }) do %> Card 3 <% end %>
24
- <% end %>
25
-
26
- <%= pb_rails("caption", props: { text: "Text Align responsive: left on default, center on md, right on lg" }) %>
27
- <%= pb_rails("card", props: {
28
- text_align: { default: "left", md: "center", lg: "right" },
29
- width: "100%"
30
- }) do %>
31
- <%= pb_rails("body", props: { }) do %> text 1 <% end %>
32
- <%= pb_rails("body", props: { }) do %> text 2 <% end %>
33
- <%= pb_rails("body", props: { }) do %> text 3 <% end %>
34
- <% end %>
1
+ <%= pb_rails("card", props: {
2
+ }) do %>
3
+ Card content
35
4
  <% end %>
36
-
@@ -40,7 +40,7 @@ type DatePickerProps = {
40
40
  maxDate: string,
41
41
  minDate: string,
42
42
  name: string,
43
- pickerId?: string,
43
+ pickerId: string,
44
44
  placeholder?: string,
45
45
  positionElement?: HTMLElement | null,
46
46
  scrollContainer?: string,
@@ -196,6 +196,8 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
196
196
 
197
197
  const angleDown = getAllIcons()["angleDown"].icon as unknown as { [key: string]: SVGElement }
198
198
 
199
+ const errorId = error ? `${pickerId}-error` : undefined
200
+
199
201
  return (
200
202
  <div
201
203
  {...ariaProps}
@@ -211,14 +213,18 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
211
213
  >
212
214
 
213
215
  {!hideLabel && (
214
- <Caption
215
- className="pb_date_picker_kit_label"
216
- text={label}
217
- />
216
+ <label htmlFor={pickerId}>
217
+ <Caption
218
+ className="pb_date_picker_kit_label"
219
+ text={label}
220
+ />
221
+ </label>
218
222
  )}
219
223
  <>
220
224
  <div className="date_picker_input_wrapper">
221
225
  <input
226
+ aria-describedby={errorId}
227
+ aria-invalid={!!error}
222
228
  autoComplete="off"
223
229
  className="date_picker_input"
224
230
  disabled={disableInput}
@@ -232,6 +238,9 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
232
238
 
233
239
  {error &&
234
240
  <Body
241
+ aria={{ atomic: "true", live: "polite" }}
242
+ htmlOptions={{ role: "alert" }}
243
+ id={errorId}
235
244
  status="negative"
236
245
  text={error}
237
246
  variant={null}
@@ -0,0 +1 @@
1
+ `pickerId`/`picker_id` is a **required prop** to instantiate the Date Picker. The presence of `pickerId`/`picker_id` in your Date Picker also associates the label with the input, providing the ability to focus the Date Picker by clicking the label.
@@ -135,6 +135,8 @@
135
135
  position: sticky;
136
136
  top: 0;
137
137
  background-color: $white;
138
+ border-top-left-radius: $border_radius_md;
139
+ border-top-right-radius: $border_radius_md;
138
140
  z-index: $z_8;
139
141
  }
140
142
 
@@ -256,7 +258,7 @@
256
258
  }
257
259
  &.full_height_left {
258
260
  justify-content: flex-start;
259
-
261
+
260
262
  .pb_dialog {
261
263
  border-radius: 0;
262
264
  height: 100%;
@@ -302,7 +304,7 @@
302
304
 
303
305
  &.full_height_center {
304
306
  justify-content: center;
305
-
307
+
306
308
  .pb_dialog {
307
309
  border-radius: 0;
308
310
  height: 100%;
@@ -346,7 +348,7 @@
346
348
 
347
349
  &.full_height_right {
348
350
  justify-content: flex-end;
349
-
351
+
350
352
  .pb_dialog {
351
353
  border-radius: 0;
352
354
  height: 100%;
@@ -417,7 +419,7 @@
417
419
  margin: unset !important;
418
420
  margin-right: auto !important;
419
421
  }
420
-
422
+
421
423
  .pb_dialog {
422
424
  border-radius: 0;
423
425
  height: 100% !important;
@@ -463,7 +465,7 @@
463
465
 
464
466
  &.full_height_center {
465
467
  justify-content: center;
466
-
468
+
467
469
  .pb_dialog {
468
470
  border-radius: 0;
469
471
  height: 100% !important;
@@ -510,7 +512,7 @@
510
512
  margin: unset !important;
511
513
  margin-left: auto !important;
512
514
  }
513
-
515
+
514
516
  .pb_dialog {
515
517
  border-radius: 0;
516
518
  height: 100% !important;
@@ -76,6 +76,12 @@
76
76
  z-index: $z_1;
77
77
  width: 100%;
78
78
 
79
+ &.constrain_height {
80
+ overflow-y: auto;
81
+ overflow-x: hidden;
82
+ max-height: 18em;
83
+ }
84
+
79
85
  .pb_dropdown_option,
80
86
  .pb_dropdown_option_list,
81
87
  .pb_dropdown_option_selected,
@@ -36,6 +36,8 @@ type DropdownProps = {
36
36
  blankSelection?: string;
37
37
  children?: React.ReactChild[] | React.ReactChild | React.ReactElement[];
38
38
  className?: string;
39
+ clearable?: boolean;
40
+ constrainHeight?: boolean;
39
41
  customQuickPickDates?: CustomQuickPickDates;
40
42
  formPillProps?: GenericObject;
41
43
  dark?: boolean;
@@ -49,6 +51,7 @@ type DropdownProps = {
49
51
  multiSelect?: boolean;
50
52
  onSelect?: (arg: GenericObject) => null;
51
53
  options?: GenericObject;
54
+ placeholder?: string;
52
55
  separators?: boolean;
53
56
  variant?: "default" | "subtle" | "quickpick";
54
57
  rangeEndsToday?: boolean;
@@ -74,6 +77,8 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
74
77
  blankSelection = '',
75
78
  children,
76
79
  className,
80
+ clearable = true,
81
+ constrainHeight = false,
77
82
  customQuickPickDates,
78
83
  dark = false,
79
84
  data = {},
@@ -87,6 +92,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
87
92
  formPillProps,
88
93
  onSelect,
89
94
  options,
95
+ placeholder,
90
96
  rangeEndsToday = false,
91
97
  controlsStartId,
92
98
  controlsEndId,
@@ -211,6 +217,34 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
211
217
  }
212
218
  }, [isDropDownClosed]);
213
219
 
220
+ // Auto-position dropdown above/below based on available space
221
+ useEffect(() => {
222
+ if (!isDropDownClosed && dropdownContainerRef.current) {
223
+ const container = dropdownContainerRef.current;
224
+ const wrapper = container.closest('.dropdown_wrapper') as HTMLElement;
225
+ if (!wrapper) return;
226
+
227
+ const wrapperRect = wrapper.getBoundingClientRect();
228
+ const h = container.getBoundingClientRect().height || container.scrollHeight;
229
+ const spaceBelow = window.innerHeight - wrapperRect.bottom;
230
+ const spaceAbove = wrapperRect.top;
231
+
232
+ // If not enough space below but enough space above, position above
233
+ if (spaceBelow < h + 10 && spaceAbove >= h + 10) {
234
+ container.style.top = "auto";
235
+ container.style.bottom = "calc(100% + 5px)";
236
+ container.style.marginTop = "0";
237
+ container.style.marginBottom = "0";
238
+ } else {
239
+ // Default: position below
240
+ container.style.top = "";
241
+ container.style.bottom = "";
242
+ container.style.marginTop = "";
243
+ container.style.marginBottom = "";
244
+ }
245
+ }
246
+ }, [isDropDownClosed, dropdownContainerRef]);
247
+
214
248
 
215
249
  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
216
250
  setFilterItem(e.target.value);
@@ -375,6 +409,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
375
409
  value={{
376
410
  activeStyle,
377
411
  autocomplete,
412
+ clearable,
378
413
  dropdownContainerRef,
379
414
  filteredOptions,
380
415
  filterItem,
@@ -426,8 +461,8 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
426
461
  </>
427
462
  ) : (
428
463
  <>
429
- <DropdownTrigger />
430
- <DropdownContainer>
464
+ <DropdownTrigger placeholder={placeholder} />
465
+ <DropdownContainer constrainHeight={constrainHeight}>
431
466
  {optionsWithBlankSelection &&
432
467
  optionsWithBlankSelection?.map((option: GenericObject) => (
433
468
  <DropdownOption key={option.id}
@@ -0,0 +1,3 @@
1
+ The `blank_selection` prop adds a blank option at the top of the dropdown options list. This allows users to explicitly clear their selection by choosing the blank option.
2
+
3
+ The blank selection option appears as the first item in the dropdown and has an empty value (`id: ""`, `value: ""`). When selected, it effectively clears the dropdown selection.
@@ -0,0 +1,3 @@
1
+ The `blankSelection` prop adds a blank option at the top of the dropdown options list. This allows users to explicitly clear their selection by choosing the blank option.
2
+
3
+ The blank selection option appears as the first item in the dropdown and has an empty value (`id: ""`, `value: ""`). When selected, it effectively clears the dropdown selection.
@@ -0,0 +1,52 @@
1
+ <%
2
+ options = [
3
+ { label: 'United States', value: 'unitedStates', id: 'us' },
4
+ { label: 'Canada', value: 'canada', id: 'ca' },
5
+ { label: 'Pakistan', value: 'pakistan', id: 'pk' },
6
+ ]
7
+ %>
8
+
9
+ <%= pb_rails("dropdown", props: {
10
+ id: "date-range-quickpick-reset-closeable",
11
+ label: "Quick Pick",
12
+ variant: "quickpick",
13
+ clearable: false
14
+ }) %>
15
+
16
+ <%= pb_rails("button", props: {
17
+ margin_y: "md",
18
+ text: "Reset",
19
+ html_options: {
20
+ onclick: "handleReset()"
21
+ }
22
+ }) %>
23
+
24
+ <%= pb_rails("dropdown", props: {
25
+ id: "closeable-default",
26
+ options: options,
27
+ clearable: false,
28
+ default_value: options.last,
29
+ margin_bottom: "md",
30
+ label: "Default"
31
+ }) %>
32
+
33
+ <%= pb_rails("dropdown", props: {
34
+ id: "closeable-subtle",
35
+ options: options,
36
+ clearable: false,
37
+ default_value: options.second,
38
+ variant: "subtle",
39
+ separators: false,
40
+ label: "Subtle"
41
+ }) %>
42
+
43
+ <script>
44
+ function handleReset() {
45
+ const dropdown = document.querySelector("#date-range-quickpick-reset-closeable[data-pb-dropdown]");
46
+ const instance = dropdown?._pbDropdownInstance;
47
+
48
+ if (instance) {
49
+ instance.clearSelection();
50
+ }
51
+ }
52
+ </script>
@@ -0,0 +1,72 @@
1
+ import React, { useRef } from 'react'
2
+
3
+ import Button from '../../pb_button/_button'
4
+ import Dropdown from '../../pb_dropdown/_dropdown'
5
+
6
+ const DropdownWithClearable = (props) => {
7
+ const dropdownRef = useRef(null)
8
+
9
+ const options = [
10
+ {
11
+ label: "United States",
12
+ value: "unitedStates",
13
+ id: "us"
14
+ },
15
+ {
16
+ label: "Canada",
17
+ value: "canada",
18
+ id: "ca"
19
+ },
20
+ {
21
+ label: "Pakistan",
22
+ value: "pakistan",
23
+ id: "pk"
24
+ }
25
+ ]
26
+
27
+ const handleReset = () => {
28
+ if (dropdownRef.current) {
29
+ dropdownRef.current.clearSelected()
30
+ }
31
+ }
32
+
33
+ return (
34
+ <>
35
+ <Dropdown
36
+ clearable={false}
37
+ label="Quick Pick"
38
+ onSelect={() => {}}
39
+ ref={dropdownRef}
40
+ variant="quickpick"
41
+ {...props}
42
+ />
43
+ <Button
44
+ marginY="md"
45
+ onClick={handleReset}
46
+ text="Reset"
47
+ />
48
+
49
+ <Dropdown
50
+ clearable={false}
51
+ defaultValue={options[options.length - 1]}
52
+ label="Default"
53
+ marginBottom="md"
54
+ options={options}
55
+ variant="default"
56
+ {...props}
57
+ />
58
+
59
+ <Dropdown
60
+ clearable={false}
61
+ defaultValue={options[1]}
62
+ label="Subtle"
63
+ options={options}
64
+ separators={false}
65
+ variant="subtle"
66
+ {...props}
67
+ />
68
+ </>
69
+ )
70
+ }
71
+
72
+ export default DropdownWithClearable
@@ -0,0 +1,5 @@
1
+ The `clearable` prop controls whether the clear (X) button appears in the dropdown. When set to `false`, the clear button is hidden.
2
+
3
+ This is useful in two scenarios:
4
+ 1. When you have a separate "Reset" or "Defaults" button that handles clearing the selection (as shown in the Quick Pick example)
5
+ 2. When you don't want to provide any way to clear the selection (as shown in the Default and Subtle examples)
@@ -0,0 +1,33 @@
1
+ import React from 'react'
2
+ import Dropdown from '../../pb_dropdown/_dropdown'
3
+
4
+ const DropdownWithConstrainHeight = (props) => {
5
+ // Create a long list of options to demonstrate height constraint
6
+ const options = Array.from({ length: 30 }, (_, i) => ({
7
+ label: `Option ${i + 1}`,
8
+ value: `option_${i + 1}`,
9
+ id: `opt_${i + 1}`
10
+ }))
11
+
12
+ return (
13
+ <>
14
+ <Dropdown
15
+ data={{ testid: "dropdown-no-constrain" }}
16
+ label="Without Constrain Height (Default)"
17
+ marginBottom="md"
18
+ options={options}
19
+ {...props}
20
+ />
21
+
22
+ <Dropdown
23
+ constrainHeight
24
+ data={{ testid: "dropdown-constrain" }}
25
+ label="With Constrain Height"
26
+ options={options}
27
+ {...props}
28
+ />
29
+ </>
30
+ )
31
+ }
32
+
33
+ export default DropdownWithConstrainHeight
@@ -0,0 +1,20 @@
1
+ <%
2
+ # Create a long list of options to demonstrate height constraint
3
+ options = (1..30).map do |i|
4
+ { label: "Option #{i}", value: "option_#{i}", id: "opt_#{i}" }
5
+ end
6
+ %>
7
+
8
+ <%= pb_rails("dropdown", props: {
9
+ id: "dropdown-no-constrain",
10
+ options: options,
11
+ label: "Without Constrain Height (Default)",
12
+ margin_bottom: "md"
13
+ }) %>
14
+
15
+ <%= pb_rails("dropdown", props: {
16
+ id: "dropdown-constrain",
17
+ options: options,
18
+ constrain_height: true,
19
+ label: "With Constrain Height"
20
+ }) %>
@@ -0,0 +1,8 @@
1
+ The `constrain_height` prop limits the dropdown container height to 18em and enables vertical scrolling when the content exceeds this height. This prevents long dropdown lists from rendering off-screen.
2
+
3
+ When `constrain_height` is `true`, the dropdown will:
4
+ - Have a maximum height of 18em
5
+ - Show a scrollbar when content exceeds the max height
6
+ - Prevent the dropdown from extending beyond the viewport
7
+
8
+ This is particularly useful for dropdowns with many options, such as long lists or quickpick variants with many date range options.
@@ -0,0 +1,8 @@
1
+ The `constrainHeight` prop limits the dropdown container height to 18em and enables vertical scrolling when the content exceeds this height. This prevents long dropdown lists from rendering off-screen.
2
+
3
+ When `constrainHeight` is `true`, the dropdown will:
4
+ - Have a maximum height of 18em
5
+ - Show a scrollbar when content exceeds the max height
6
+ - Prevent the dropdown from extending beyond the viewport
7
+
8
+ This is particularly useful for dropdowns with many options, such as long lists or quickpick variants with many date range options.
@@ -0,0 +1,9 @@
1
+ <%
2
+ options = [
3
+ { label: 'United States', value: 'unitedStates', id: 'us' },
4
+ { label: 'Canada', value: 'canada', id: 'ca' },
5
+ { label: 'Pakistan', value: 'pakistan', id: 'pk' },
6
+ ]
7
+ %>
8
+
9
+ <%= pb_rails("dropdown", props: { options: options, placeholder: "Choose a country" }) %>