playbook_ui 16.10.0.pre.alpha.play300617391 → 16.10.0.pre.alpha.play300617418

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 (94) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +2 -0
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +0 -2
  4. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +5 -0
  5. data/app/pb_kits/playbook/pb_checkbox/kit.schema.json +1 -1
  6. data/app/pb_kits/playbook/pb_circle_icon_button/kit.schema.json +1 -1
  7. data/app/pb_kits/playbook/pb_date_time/kit.schema.json +1 -1
  8. data/app/pb_kits/playbook/pb_date_time_stacked/kit.schema.json +1 -1
  9. data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +114 -0
  10. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +13 -4
  11. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_custom_display_disabled_option.html.erb +93 -0
  12. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_custom_display_disabled_option.jsx +127 -0
  13. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_custom_display_disabled_option.md +1 -0
  14. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_disabled.html.erb +10 -0
  15. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_disabled.jsx +37 -0
  16. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_disabled_option.html.erb +10 -0
  17. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_disabled_option.jsx +37 -0
  18. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_disabled_option.md +1 -0
  19. data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +6 -0
  20. data/app/pb_kits/playbook/pb_dropdown/docs/index.js +3 -0
  21. data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +5 -4
  22. data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +6 -1
  23. data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +96 -0
  24. data/app/pb_kits/playbook/pb_dropdown/dropdown_container.html.erb +1 -0
  25. data/app/pb_kits/playbook/pb_dropdown/dropdown_container.rb +2 -0
  26. data/app/pb_kits/playbook/pb_dropdown/dropdown_option.html.erb +2 -2
  27. data/app/pb_kits/playbook/pb_dropdown/dropdown_option.rb +27 -2
  28. data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.html.erb +4 -2
  29. data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.rb +2 -0
  30. data/app/pb_kits/playbook/pb_dropdown/hooks/useHandleOnKeydown.tsx +25 -5
  31. data/app/pb_kits/playbook/pb_dropdown/index.js +50 -0
  32. data/app/pb_kits/playbook/pb_dropdown/keyboard_accessibility.js +11 -1
  33. data/app/pb_kits/playbook/pb_dropdown/kit.schema.json +8 -0
  34. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +15 -4
  35. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +22 -13
  36. data/app/pb_kits/playbook/pb_file_upload/kit.schema.json +1 -1
  37. data/app/pb_kits/playbook/pb_full_screen/_full_screen.scss +77 -0
  38. data/app/pb_kits/playbook/pb_full_screen/_full_screen.tsx +183 -0
  39. data/app/pb_kits/playbook/pb_full_screen/docs/_description.md +1 -0
  40. data/app/pb_kits/playbook/pb_full_screen/docs/_full_screen_content_padding.jsx +68 -0
  41. data/app/pb_kits/playbook/pb_full_screen/docs/_full_screen_content_padding.md +1 -0
  42. data/app/pb_kits/playbook/pb_full_screen/docs/_full_screen_custom_trigger.jsx +71 -0
  43. data/app/pb_kits/playbook/pb_full_screen/docs/_full_screen_custom_trigger.md +1 -0
  44. data/app/pb_kits/playbook/pb_full_screen/docs/_full_screen_default.html.erb +3 -0
  45. data/app/pb_kits/playbook/pb_full_screen/docs/_full_screen_default.jsx +63 -0
  46. data/app/pb_kits/playbook/pb_full_screen/docs/_full_screen_default.md +1 -0
  47. data/app/pb_kits/playbook/pb_full_screen/docs/_full_screen_header_text_styling.jsx +68 -0
  48. data/app/pb_kits/playbook/pb_full_screen/docs/_full_screen_header_text_styling.md +1 -0
  49. data/app/pb_kits/playbook/pb_full_screen/docs/_full_screen_sticky_header.jsx +68 -0
  50. data/app/pb_kits/playbook/pb_full_screen/docs/_full_screen_sticky_header.md +1 -0
  51. data/app/pb_kits/playbook/pb_full_screen/docs/_full_screen_table_and_filter.jsx +149 -0
  52. data/app/pb_kits/playbook/pb_full_screen/docs/_full_screen_table_and_filter.md +1 -0
  53. data/app/pb_kits/playbook/pb_full_screen/docs/_playground.json +155 -0
  54. data/app/pb_kits/playbook/pb_full_screen/docs/_playground.overrides.json +137 -0
  55. data/app/pb_kits/playbook/pb_full_screen/docs/example.yml +14 -0
  56. data/app/pb_kits/playbook/pb_full_screen/docs/index.js +6 -0
  57. data/app/pb_kits/playbook/pb_full_screen/full_screen.html.erb +12 -0
  58. data/app/pb_kits/playbook/pb_full_screen/full_screen.rb +11 -0
  59. data/app/pb_kits/playbook/pb_full_screen/full_screen.test.jsx +237 -0
  60. data/app/pb_kits/playbook/pb_full_screen/kit.schema.json +89 -0
  61. data/app/pb_kits/playbook/pb_full_screen/useFullScreen.ts +15 -0
  62. data/app/pb_kits/playbook/pb_icon/_icon.tsx +22 -11
  63. data/app/pb_kits/playbook/pb_icon/icon.rb +5 -2
  64. data/app/pb_kits/playbook/pb_icon/kit.schema.json +3 -5
  65. data/app/pb_kits/playbook/pb_radio/kit.schema.json +1 -1
  66. data/app/pb_kits/playbook/pb_select/kit.schema.json +1 -1
  67. data/app/pb_kits/playbook/pb_selectable_card/kit.schema.json +1 -1
  68. data/app/pb_kits/playbook/pb_selectable_card_icon/kit.schema.json +1 -1
  69. data/app/pb_kits/playbook/pb_selectable_icon/kit.schema.json +1 -1
  70. data/app/pb_kits/playbook/pb_star_rating/kit.schema.json +1 -1
  71. data/app/pb_kits/playbook/pb_stat_value/kit.schema.json +1 -1
  72. data/app/pb_kits/playbook/pb_text_input/kit.schema.json +2 -2
  73. data/app/pb_kits/playbook/pb_toggle/kit.schema.json +1 -1
  74. data/app/pb_kits/playbook/pb_typeahead/kit.schema.json +1 -1
  75. data/app/pb_kits/playbook/utilities/_border.scss +262 -0
  76. data/app/pb_kits/playbook/utilities/global-props.schema.json +98 -0
  77. data/app/pb_kits/playbook/utilities/globalProps.ts +83 -1
  78. data/app/pb_kits/playbook/utilities/test/globalProps/border.test.js +66 -0
  79. data/dist/chunks/{_pb_line_graph-DYysA_-M.js → _pb_line_graph-BQrN-uXU.js} +1 -1
  80. data/dist/chunks/{_typeahead-CdD0-K3_.js → _typeahead-IofDd4w9.js} +1 -1
  81. data/dist/chunks/globalProps-C04xFof_.js +6 -0
  82. data/dist/chunks/{lib-BQnni8Yf.js → lib-BhWFApsB.js} +1 -1
  83. data/dist/chunks/vendor.js +3 -3
  84. data/dist/menu.yml +7 -0
  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/border.rb +87 -0
  89. data/lib/playbook/classnames.rb +1 -0
  90. data/lib/playbook/kit_base.rb +2 -0
  91. data/lib/playbook/pb_forms_global_props_helper.rb +15 -0
  92. data/lib/playbook/version.rb +1 -1
  93. metadata +42 -6
  94. data/dist/chunks/globalProps-CC-0LNvd.js +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 580a39765f590afc00f4c9fc7cac5d9c5c7c741ce08609400363df3611c15c21
4
- data.tar.gz: b8436265466dd1d91e673efc290a3d3d58ceed27bbe4edfb13794549084e6d8d
3
+ metadata.gz: eea9e460fe3172005e0ffb859d2110dfd98731a78012d2e0c980fa030d16e51b
4
+ data.tar.gz: a9ff3972f4b7c8f841626687a74ea0475a3f6e3ccba811df5f3a6d7a4ecd7f6c
5
5
  SHA512:
6
- metadata.gz: 7e6f41d566b0c145b41090f130c2e01ab3826146d642cc462fe849a20810bff5206a3758c996f9ee9aaf791c1967cde4d8b21ba68450813d8f6e9a701ff595b5
7
- data.tar.gz: 962a8d491cb2c4fc14e04561ab56cefab606a3d12f55a9c3ffc2a364f56af30c8ec3a4dd6ec671c9fa1710238219b0de4ce80e3f49ff40b2ec5d981f210adbd9
6
+ metadata.gz: 461c23cf434287c4d6b23afdaa85ac7f66737a9b546652ef7508cf95d06c61b2d3b3b05e7db5f5711a37a5663c8fb967cd7959f3fb32c2bd8d2bce5414252cf8
7
+ data.tar.gz: a854d92ff8049450212c46c721930ba6dac1350107582e06749b240af20efaf7f6debeccfebd10da39c6b323dff1752b08c7f9154c0625fce38ecb56b377b30e
@@ -36,6 +36,7 @@
36
36
  @import 'pb_form/form';
37
37
  @import 'pb_form_group/form_group';
38
38
  @import 'pb_form_pill/form_pill';
39
+ @import 'pb_full_screen/full_screen';
39
40
  @import 'pb_hashtag/hashtag';
40
41
  @import 'pb_highlight/highlight';
41
42
  @import 'pb_home_address_street/home_address_street';
@@ -128,3 +129,4 @@
128
129
  @import 'utilities/vertical_align';
129
130
  @import 'utilities/height';
130
131
  @import 'utilities/gap';
132
+ @import 'utilities/border';
@@ -84,13 +84,11 @@ export const CustomCell = ({
84
84
  >
85
85
  {row.getIsExpanded() ? (
86
86
  <Icon cursor="pointer"
87
- htmlOptions={{ style: { width: "100", height: "100" } }}
88
87
  icon="circle-play"
89
88
  rotation={90}
90
89
  />
91
90
  ) : (
92
91
  <Icon cursor="pointer"
93
- htmlOptions={{ style: { width: "100", height: "100" } }}
94
92
  icon="circle-play"
95
93
  />
96
94
  )}
@@ -475,6 +475,11 @@
475
475
  width: 18px;
476
476
  height: 18px;
477
477
  border-radius: 50%;
478
+
479
+ .pb_custom_icon {
480
+ width: 17px !important;
481
+ height: 17px !important;
482
+ }
478
483
  }
479
484
 
480
485
  .header-sort-button {
@@ -106,7 +106,7 @@
106
106
  "platforms": [
107
107
  "rails"
108
108
  ],
109
- "type": "string"
109
+ "type": "GenericObject"
110
110
  },
111
111
  "required": {
112
112
  "platforms": [
@@ -106,7 +106,7 @@
106
106
  "platforms": [
107
107
  "rails"
108
108
  ],
109
- "type": "string"
109
+ "type": "GenericObject"
110
110
  }
111
111
  },
112
112
  "globalProps": true,
@@ -72,7 +72,7 @@
72
72
  "platforms": [
73
73
  "rails"
74
74
  ],
75
- "type": "string"
75
+ "type": "Date"
76
76
  },
77
77
  "timezone": {
78
78
  "platforms": [
@@ -44,7 +44,7 @@
44
44
  "platforms": [
45
45
  "rails"
46
46
  ],
47
- "type": "string"
47
+ "type": "Date"
48
48
  },
49
49
  "timezone": {
50
50
  "platforms": [
@@ -10,6 +10,61 @@
10
10
  @import "./scss_partials/dropdown_animation";
11
11
  @import "dropdown_mixin";
12
12
 
13
+ @mixin dropdown-disabled-typography($color) {
14
+ .pb_body_kit,
15
+ .pb_body_kit_default,
16
+ .pb_body_kit_light,
17
+ .pb_body_kit_lighter,
18
+ .pb_body_kit_link,
19
+ .pb_body_kit_success,
20
+ .pb_body_kit_error,
21
+ .pb_body_kit_neutral,
22
+ .pb_body_kit_positive,
23
+ .pb_body_kit_negative,
24
+ .pb_caption_kit,
25
+ .pb_caption_kit_xs,
26
+ .pb_caption_kit_sm,
27
+ .pb_caption_kit_md,
28
+ .pb_caption_kit_base,
29
+ .pb_caption_kit_lg,
30
+ .pb_caption_kit_xl,
31
+ .pb_title_kit,
32
+ .pb_detail_kit,
33
+ .pb_detail_kit_color_light,
34
+ .pb_detail_kit_color_default,
35
+ .pb_detail_kit_color_lighter,
36
+ .pb_detail_kit_color_link,
37
+ .pb_detail_kit_color_error,
38
+ .pb_detail_kit_color_success,
39
+ .pb_link_kit,
40
+ .pb_link_kit_underline,
41
+ a {
42
+ color: $color !important;
43
+ }
44
+
45
+
46
+ @each $caption-color, $caption-value in $pb_caption_colors {
47
+ .pb_caption_kit_xs_#{$caption-color},
48
+ .pb_caption_kit_sm_#{$caption-color},
49
+ .pb_caption_kit_md_#{$caption-color},
50
+ .pb_caption_kit_base_#{$caption-color},
51
+ .pb_caption_kit_lg_#{$caption-color},
52
+ .pb_caption_kit_xl_#{$caption-color} {
53
+ color: $color !important;
54
+ }
55
+ }
56
+
57
+
58
+ @each $link-color, $link-value in $pb_link_colors {
59
+ .pb_link_kit_#{$link-color},
60
+ .pb_link_kit_#{$link-color}_underline,
61
+ .pb_link_kit_#{$link-color}_disabled,
62
+ .pb_link_kit_#{$link-color}_underline_disabled {
63
+ color: $color !important;
64
+ }
65
+ }
66
+ }
67
+
13
68
  .pb_dropdown_default,
14
69
  .pb_dropdown_subtle,
15
70
  .pb_dropdown_quickpick,
@@ -50,6 +105,17 @@
50
105
  color: $input_text_default;
51
106
  }
52
107
  }
108
+
109
+ .dropdown_input:disabled {
110
+ background-color: $input_background_disabled;
111
+ color: $input_text_disabled;
112
+ cursor: default;
113
+ }
114
+
115
+ .dropdown_input:disabled::placeholder {
116
+ color: $input_text_disabled;
117
+ }
118
+
53
119
  &:focus {
54
120
  box-shadow: 0px 0px 0 1px $status_border_primary !important;
55
121
  outline: unset;
@@ -145,6 +211,20 @@
145
211
  }
146
212
  }
147
213
  }
214
+
215
+ // Disabled state
216
+ &.disabled {
217
+ cursor: not-allowed;
218
+ // background-color: $input_background_disabled;
219
+ color: $input_text_disabled;
220
+ border-color: $input_border_disabled;
221
+ pointer-events: none;
222
+ @include dropdown-disabled-typography($input_text_disabled);
223
+ &:hover,
224
+ &:focus {
225
+ background-color: $input_background_disabled;
226
+ }
227
+ }
148
228
  }
149
229
 
150
230
  .dropdown_option_wrapper {
@@ -376,6 +456,40 @@
376
456
  background-color: $primary;
377
457
  border-bottom: rgba($white, 0.15);
378
458
  }
459
+
460
+ &.disabled {
461
+ cursor: not-allowed;
462
+ background-color: $input_background_disabled_dark;
463
+ color: $input_text_disabled_dark;
464
+ border-color: $input_border_disabled_dark;
465
+ pointer-events: none;
466
+ @include dropdown-disabled-typography($input_text_disabled_dark);
467
+ &:hover,
468
+ &:focus {
469
+ background-color: $input_background_disabled_dark;
470
+ }
471
+ }
472
+ }
473
+ }
474
+ }
475
+
476
+ &.disabled {
477
+ .dropdown_wrapper {
478
+ .dropdown_trigger_wrapper,
479
+ .dropdown_trigger_wrapper_focus,
480
+ .dropdown_trigger_wrapper_focus_select_only,
481
+ .dropdown_trigger_wrapper_select_only {
482
+ background-color: $input_background_disabled;
483
+ box-shadow: none !important;
484
+ cursor: default !important;
485
+ opacity: 0.5;
486
+ pointer-events: none;
487
+
488
+ input {
489
+ background-color: $input_background_disabled;
490
+ color: $input_text_disabled;
491
+ cursor: default !important;
492
+ }
379
493
  }
380
494
  }
381
495
  }
@@ -93,6 +93,7 @@ type DropdownProps = {
93
93
  closeOnClick?: "outside" | "inside" | "any";
94
94
  constrainHeight?: boolean;
95
95
  customQuickPickDates?: CustomQuickPickDates;
96
+ disabled?: boolean;
96
97
  formPillProps?: GenericObject;
97
98
  dark?: boolean;
98
99
  data?: { [key: string]: string };
@@ -139,6 +140,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
139
140
  dark = false,
140
141
  data = {},
141
142
  defaultValue = {},
143
+ disabled = false,
142
144
  error,
143
145
  htmlOptions = {},
144
146
  id,
@@ -164,6 +166,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
164
166
  const separatorsClass = separators ? '' : 'separators_hidden'
165
167
  const classes = classnames(
166
168
  buildCss("pb_dropdown", variant, separatorsClass),
169
+ disabled && "disabled",
167
170
  globalProps(props),
168
171
  className
169
172
  );
@@ -174,7 +177,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
174
177
  : (options || []);
175
178
  // ----------------------------------------------------------
176
179
 
177
- const [isDropDownClosed, setIsDropDownClosed, toggleDropdown] = useDropdown(isClosed);
180
+ const [isDropDownClosed, setIsDropDownClosed, toggleDropdown] = useDropdown(disabled ? true : isClosed);
178
181
 
179
182
  // Use a suffix for the trigger ID to avoid conflict with the outer div's id
180
183
  const sanitizeForId = (str: string) =>
@@ -228,6 +231,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
228
231
 
229
232
  const handleLabelClick = (e: React.MouseEvent) => {
230
233
  e.stopPropagation();
234
+ if (disabled) return;
231
235
  if (selectId) {
232
236
  const trigger = document.getElementById(selectId);
233
237
  if (trigger) trigger.focus();
@@ -269,8 +273,8 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
269
273
 
270
274
  // dropdown to toggle with external control
271
275
  useEffect(() => {
272
- setIsDropDownClosed(isClosed)
273
- }, [isClosed])
276
+ setIsDropDownClosed(disabled ? true : isClosed)
277
+ }, [disabled, isClosed])
274
278
 
275
279
  const blankSelectionOption: GenericObject = blankSelection ? [{ label: blankSelection, value: "" }] : [];
276
280
  const optionsWithBlankSelection = blankSelectionOption.concat(dropdownOptions);
@@ -330,12 +334,14 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
330
334
 
331
335
 
332
336
  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
337
+ if (disabled) return;
333
338
  setFilterItem(e.target.value);
334
339
  setIsDropDownClosed(false);
335
340
  };
336
341
 
337
342
 
338
343
  const handleOptionClick = (clickedItem: GenericObject) => {
344
+ if (disabled) return;
339
345
  const shouldCloseOnClick = closeOnClick === "any" || closeOnClick === "inside";
340
346
 
341
347
  if (multiSelect) {
@@ -378,11 +384,13 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
378
384
  };
379
385
 
380
386
  const handleWrapperClick = () => {
387
+ if (disabled) return;
381
388
  autocomplete && inputRef?.current?.focus();
382
389
  toggleDropdown();
383
390
  };
384
391
 
385
392
  const handleBackspace = () => {
393
+ if (disabled) return;
386
394
  if (multiSelect) {
387
395
  setSelected([]);
388
396
  onSelect && onSelect([]);
@@ -502,6 +510,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
502
510
  blankSelection,
503
511
  clearable,
504
512
  dropdownContainerRef,
513
+ disabled,
505
514
  error,
506
515
  errorId,
507
516
  filterItem,
@@ -564,7 +573,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
564
573
  }
565
574
  }, 0);
566
575
  }}
567
- onFocus={() => setIsInputFocused(true)}
576
+ onFocus={() => !disabled && setIsInputFocused(true)}
568
577
  ref={dropdownRef}
569
578
  >
570
579
  {children ? (
@@ -0,0 +1,93 @@
1
+ <%
2
+ options = [
3
+ {
4
+ label: "Jasper Furniss",
5
+ value: "jasperFurniss",
6
+ territory: "PHL",
7
+ title: "Lead UX Engineer",
8
+ id: "jasper-furniss",
9
+ status: "Offline"
10
+ },
11
+ {
12
+ label: "Ramon Ruiz",
13
+ value: "ramonRuiz",
14
+ territory: "PHL",
15
+ title: "Senior UX Designer",
16
+ id: "ramon-ruiz",
17
+ status: "Unavailable",
18
+ disabled: true
19
+ },
20
+ {
21
+ label: "Carlos Lima",
22
+ value: "carlosLima",
23
+ territory: "PHL",
24
+ title: "Nitro Developer",
25
+ id: "carlos-lima",
26
+ status: "Online"
27
+ },
28
+ {
29
+ label: "Courtney Long",
30
+ value: "courtneyLong",
31
+ territory: "PHL",
32
+ title: "Lead UX Designer",
33
+ id: "courtney-long",
34
+ status: "Online"
35
+ }
36
+ ]
37
+ %>
38
+
39
+ <%
40
+ custom_display = capture do
41
+ pb_rails("flex", props: { align: "center" }) do
42
+ concat(pb_rails("avatar", props: { name: "", size: "xs", id: "dropdown-avatar" }))
43
+ concat(pb_rails("body", props: { text: "", size: "xs", margin_x: "xs", id: "dropdown-avatar-name" }))
44
+ concat(pb_rails("badge", props: { text: "", id: "dropdown-avatar-status" }))
45
+ end
46
+ end
47
+ %>
48
+
49
+ <%= pb_rails("dropdown", props: { id: "user-dropdown-disabled-options", options: options }) do %>
50
+ <%= pb_rails("dropdown/dropdown_trigger", props: { placeholder: "Select a User", custom_display: custom_display }) %>
51
+ <%= pb_rails("dropdown/dropdown_container") do %>
52
+ <% options.each do |option| %>
53
+ <%= pb_rails("dropdown/dropdown_option", props: { option: option }) do %>
54
+ <%= pb_rails("flex", props: { align: "center", justify: "between" }) do %>
55
+ <%= pb_rails("flex/flex_item") do %>
56
+ <%= pb_rails("user", props: { name: option[:label], align: "left", avatar: true, orientation: "horizontal", territory: option[:territory], title: option[:title] }) %>
57
+ <% end %>
58
+ <%= pb_rails("flex/flex_item") do %>
59
+ <%= pb_rails("badge", props: { rounded: true, dark: true, text: option[:status], variant: option[:status] == "Offline" ? "neutral" : option[:status] == "Online" ? "success" : "warning" }) %>
60
+ <% end %>
61
+ <% end %>
62
+ <% end %>
63
+ <% end %>
64
+ <% end %>
65
+ <% end %>
66
+
67
+ <script>
68
+ document.addEventListener("pb:dropdown:selected", (e) => {
69
+ if (e.target.id !== "user-dropdown-disabled-options") return;
70
+
71
+ const option = e.detail;
72
+ const dropdown = e.target;
73
+ const display = dropdown.querySelector("[data-dropdown-trigger-custom-display]");
74
+ if (!display) return;
75
+
76
+ const nameEl = display.querySelector("#dropdown-avatar-name");
77
+ if (nameEl) nameEl.textContent = option.label;
78
+
79
+ const avatarWrapper = display.querySelector("#dropdown-avatar .avatar_wrapper");
80
+ if (avatarWrapper) {
81
+ const initials = (option.label[0] + option.label.split(" ").pop()[0]).toUpperCase();
82
+ avatarWrapper.dataset.name = option.label;
83
+ avatarWrapper.setAttribute("data-initials", initials);
84
+ }
85
+
86
+ const badgeEl = display.querySelector("#dropdown-avatar-status");
87
+ const variant = option.status === "Online" ? "success" : option.status === "Offline" ? "neutral" : "warning";
88
+ if (badgeEl) {
89
+ badgeEl.querySelector("span").textContent = option.status;
90
+ badgeEl.className = `pb_badge_kit_${variant}`;
91
+ }
92
+ });
93
+ </script>
@@ -0,0 +1,127 @@
1
+ import React, { useState } from 'react'
2
+
3
+ import Dropdown from '../../pb_dropdown/_dropdown'
4
+ import Badge from '../../pb_badge/_badge'
5
+ import Flex from '../../pb_flex/_flex'
6
+ import FlexItem from '../../pb_flex/_flex_item'
7
+ import Avatar from '../../pb_avatar/_avatar'
8
+ import User from '../../pb_user/_user'
9
+ import Body from '../../pb_body/_body'
10
+
11
+ const DropdownCustomDisplayDisabledOption = (props) => {
12
+ const [selectedOption, setSelectedOption] = useState();
13
+
14
+ const options = [
15
+ {
16
+ label: "Jasper Furniss",
17
+ value: "jasperFurniss",
18
+ territory: "PHL",
19
+ title: "Lead UX Engineer",
20
+ id: "jasper-furniss",
21
+ status: "Offline"
22
+ },
23
+ {
24
+ label: "Ramon Ruiz",
25
+ value: "ramonRuiz",
26
+ territory: "PHL",
27
+ title: "Senior UX Designer",
28
+ id: "ramon-ruiz",
29
+ status: "Unavailable",
30
+ disabled: true
31
+ },
32
+ {
33
+ label: "Carlos Lima",
34
+ value: "carlosLima",
35
+ territory: "PHL",
36
+ title: "Nitro Developer",
37
+ id: "carlos-lima",
38
+ status: "Online"
39
+ },
40
+ {
41
+ label: "Courtney Long",
42
+ value: "courtneyLong",
43
+ territory: "PHL",
44
+ title: "Lead UX Designer",
45
+ id: "courtney-long",
46
+ status: "Online"
47
+ }
48
+ ];
49
+
50
+ const CustomDisplay = () => {
51
+ return (
52
+ <>
53
+ {
54
+ selectedOption && (
55
+ <Flex align="center">
56
+ <Avatar
57
+ name={selectedOption.label}
58
+ size="xs"
59
+ />
60
+ <Body
61
+ marginX="xs"
62
+ text={selectedOption.label}
63
+ />
64
+ <Badge
65
+ text={selectedOption.status}
66
+ variant={selectedOption.status == "Offline" ? "neutral" : selectedOption.status == "Online" ? "success" : "warning"}
67
+ />
68
+ </Flex>
69
+ )
70
+ }
71
+ </>
72
+ )
73
+ };
74
+
75
+
76
+ return (
77
+ <div>
78
+ <Dropdown
79
+ onSelect={(selectedItem) => setSelectedOption(selectedItem)}
80
+ options={options}
81
+ {...props}
82
+ >
83
+ <Dropdown.Trigger customDisplay={<CustomDisplay/>}
84
+ placeholder="Select a User"
85
+ />
86
+ {options.map((option) => (
87
+ <Dropdown.Option key={option.id}
88
+ option={option}
89
+ >
90
+ <Flex
91
+ align="center"
92
+ justify="between"
93
+ >
94
+ <FlexItem>
95
+ <User
96
+ align="left"
97
+ avatar
98
+ name={option.label}
99
+ orientation="horizontal"
100
+ territory={option.territory}
101
+ title={option.title}
102
+ />
103
+ </FlexItem>
104
+ <FlexItem>
105
+ <Badge dark
106
+ rounded
107
+ text={option.status}
108
+ variant={`${
109
+ option.status === "Offline"
110
+ ? "neutral"
111
+ : option.status === "Unavailable"
112
+ ? "warning"
113
+ : option.status === "Online"
114
+ ? "success"
115
+ : "warning"
116
+ }`}
117
+ />
118
+ </FlexItem>
119
+ </Flex>
120
+ </Dropdown.Option>
121
+ ))}
122
+ </Dropdown>
123
+ </div>
124
+ )
125
+ }
126
+
127
+ export default DropdownCustomDisplayDisabledOption
@@ -0,0 +1 @@
1
+ To disable individual items in the `options`, include `disabled: true` within the object on the option that you want disabled. See the code snippet below for an example of how to do this.
@@ -0,0 +1,10 @@
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
+
10
+ <%= pb_rails("dropdown", props: {id: "dropdown-disabled", disabled: true,label: "Default Dropdown", options: options}) %>
@@ -0,0 +1,37 @@
1
+ import React from 'react'
2
+ import Dropdown from '../_dropdown'
3
+
4
+ const DropdownDisabled = (props) => {
5
+
6
+ const options = [
7
+ {
8
+ label: "United States",
9
+ value: "unitedStates",
10
+ id: "us"
11
+ },
12
+ {
13
+ label: "Canada",
14
+ value: "canada",
15
+ id: "ca"
16
+ },
17
+ {
18
+ label: "Pakistan",
19
+ value: "pakistan",
20
+ id: "pk"
21
+ }
22
+ ];
23
+
24
+
25
+ return (
26
+ <div>
27
+ <Dropdown
28
+ disabled
29
+ label="Default Dropdown"
30
+ options={options}
31
+ {...props}
32
+ />
33
+ </div>
34
+ )
35
+ }
36
+
37
+ export default DropdownDisabled
@@ -0,0 +1,10 @@
1
+ <%
2
+ options = [
3
+ { label: "Available Option", value: "available", id: "available-option" },
4
+ { label: "Coming Soon", value: "coming-soon", id: "coming-soon", disabled: true },
5
+ { label: "Another Available", value: "another-available", id: "another-available" },
6
+ { label: "Locked Feature", value: "locked-feature", id: "locked-feature", disabled: true },
7
+ ]
8
+ %>
9
+
10
+ <%= pb_rails("dropdown", props: { label: "Disabled Options", options: options }) %>
@@ -0,0 +1,37 @@
1
+ import React, { useState } from 'react'
2
+
3
+ import Dropdown from '../../pb_dropdown/_dropdown'
4
+ import Caption from '../../pb_caption/_caption'
5
+
6
+ const DropdownDisabledOption = (props) => {
7
+ const [selectedOption, setSelectedOption] = useState()
8
+
9
+ const options = [
10
+ { label: 'Available Option', value: 'available', id: 'available-option' },
11
+ { label: 'Coming Soon', value: 'coming-soon', id: 'coming-soon', disabled: true },
12
+ { label: 'Another Available', value: 'another-available', id: 'another-available' },
13
+ { label: 'Locked Feature', value: 'locked-feature', id: 'locked-feature', disabled: true },
14
+ ]
15
+
16
+ return (
17
+ <div>
18
+ <Caption
19
+ text="Select an option. Disabled options remain visible but cannot be selected."
20
+ />
21
+ <Dropdown
22
+ onSelect={(selectedItem) => setSelectedOption(selectedItem)}
23
+ options={options}
24
+ placeholder="Choose an option"
25
+ {...props}
26
+ />
27
+ {selectedOption && (
28
+ <Caption
29
+ marginTop="xs"
30
+ text={`Selected: ${selectedOption.label}`}
31
+ />
32
+ )}
33
+ </div>
34
+ )
35
+ }
36
+
37
+ export default DropdownDisabledOption
@@ -0,0 +1 @@
1
+ To disable individual items in the `options`, include `disabled: true` within the object on the option that you want disabled. See the code snippet below for an example of how to do this.