playbook_ui 14.12.0.pre.alpha.PBNTR720railscarddraggable5649 → 14.12.0.pre.alpha.PBNTR834advtablemaxHeightstickyheader5932

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 (112) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +1 -0
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +1 -1
  4. data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +11 -4
  5. data/app/pb_kits/playbook/pb_advanced_table/Utilities/ActionBarAnimationHelper.ts +26 -0
  6. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +60 -10
  7. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +37 -21
  8. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +3 -3
  9. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +3 -1
  10. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +1 -1
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.html.erb +33 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading_rails.md +1 -0
  13. data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_loading.md → _advanced_table_loading_react.md} +2 -2
  14. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_responsive.html.erb +38 -0
  15. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.jsx +1 -0
  16. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_react.md +3 -1
  17. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.jsx +55 -0
  18. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_react.md +3 -0
  19. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +3 -0
  20. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -1
  21. data/app/pb_kits/playbook/pb_advanced_table/index.js +9 -6
  22. data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +17 -3
  23. data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +15 -11
  24. data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +14 -3
  25. data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +10 -7
  26. data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +9 -1
  27. data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.html.erb +1 -1
  28. data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.rb +9 -0
  29. data/app/pb_kits/playbook/pb_avatar/_avatar.scss +14 -0
  30. data/app/pb_kits/playbook/pb_avatar/_avatar.tsx +11 -7
  31. data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +6 -7
  32. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_badge_component_overlay.jsx +9 -3
  33. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_circle_icon_component_overlay.jsx +6 -2
  34. data/app/pb_kits/playbook/pb_button/button.rb +1 -1
  35. data/app/pb_kits/playbook/pb_copy_button/_copy_button.scss +4 -0
  36. data/app/pb_kits/playbook/pb_copy_button/_copy_button.tsx +92 -0
  37. data/app/pb_kits/playbook/pb_copy_button/copy_button.html.erb +15 -0
  38. data/app/pb_kits/playbook/pb_copy_button/copy_button.rb +28 -0
  39. data/app/pb_kits/playbook/pb_copy_button/copy_button.test.jsx +64 -0
  40. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_default.html.erb +2 -0
  41. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_default.jsx +21 -0
  42. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_from.html.erb +5 -0
  43. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_from.jsx +45 -0
  44. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_from.md +1 -0
  45. data/app/pb_kits/playbook/pb_copy_button/docs/example.yml +8 -0
  46. data/app/pb_kits/playbook/pb_copy_button/docs/index.js +2 -0
  47. data/app/pb_kits/playbook/pb_copy_button/index.js +47 -0
  48. data/app/pb_kits/playbook/pb_date/_date.tsx +14 -4
  49. data/app/pb_kits/playbook/pb_date/docs/_date_default.jsx +2 -1
  50. data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.jsx +13 -5
  51. data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +1 -6
  52. data/app/pb_kits/playbook/pb_filter/filter.html.erb +1 -5
  53. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_auto_close.html.erb +58 -0
  54. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_auto_close_rails.md +3 -0
  55. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/example.yml +1 -0
  56. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js +7 -5
  57. data/app/pb_kits/playbook/pb_form_group/form_group.html.erb +1 -6
  58. data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +1 -1
  59. data/app/pb_kits/playbook/pb_link/_link.tsx +18 -0
  60. data/app/pb_kits/playbook/pb_link/docs/_link_target.html.erb +15 -0
  61. data/app/pb_kits/playbook/pb_link/docs/_link_target.jsx +29 -0
  62. data/app/pb_kits/playbook/pb_link/docs/example.yml +5 -3
  63. data/app/pb_kits/playbook/pb_link/docs/index.js +2 -1
  64. data/app/pb_kits/playbook/pb_link/link.html.erb +1 -1
  65. data/app/pb_kits/playbook/pb_link/link.rb +6 -0
  66. data/app/pb_kits/playbook/pb_link/link.test.jsx +30 -0
  67. data/app/pb_kits/playbook/pb_progress_step/docs/_progress_step_tooltip.html.erb +6 -6
  68. data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.html.erb +6 -9
  69. data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.jsx +6 -9
  70. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_content.jsx +12 -8
  71. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_content_rails.html.erb +52 -0
  72. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_content_rails.md +0 -0
  73. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_rows_rails.html.erb +52 -0
  74. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_rows_rails.md +3 -0
  75. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table_rails.html.erb +80 -0
  76. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table_rails.md +1 -0
  77. data/app/pb_kits/playbook/pb_table/docs/example.yml +3 -0
  78. data/app/pb_kits/playbook/pb_table/styles/_desktop_collapse.scss +26 -0
  79. data/app/pb_kits/playbook/pb_table/styles/_mobile.scss +0 -1
  80. data/app/pb_kits/playbook/pb_table/styles/_mobile_collapse.scss +25 -0
  81. data/app/pb_kits/playbook/pb_table/styles/_tablet_collapse.scss +25 -0
  82. data/app/pb_kits/playbook/pb_table/table_row.rb +1 -1
  83. data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +3 -1
  84. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_default.html.erb +1 -1
  85. data/app/pb_kits/playbook/pb_tooltip/index.js +45 -27
  86. data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +5 -1
  87. data/app/pb_kits/playbook/pb_user/_user.tsx +3 -0
  88. data/app/pb_kits/playbook/pb_user/docs/_user_light_weight.html.erb +42 -0
  89. data/app/pb_kits/playbook/pb_user/docs/_user_light_weight.jsx +59 -0
  90. data/app/pb_kits/playbook/pb_user/docs/_user_light_weight.md +2 -0
  91. data/app/pb_kits/playbook/pb_user/docs/example.yml +2 -0
  92. data/app/pb_kits/playbook/pb_user/docs/index.js +1 -0
  93. data/app/pb_kits/playbook/pb_user/user.html.erb +1 -1
  94. data/app/pb_kits/playbook/pb_user/user.rb +1 -0
  95. data/app/pb_kits/playbook/pb_user/user.test.js +14 -0
  96. data/dist/chunks/_typeahead-CkemExmL.js +36 -0
  97. data/dist/chunks/_weekday_stacked-DiNLeUtf.js +45 -0
  98. data/dist/chunks/{lib-kMuhBuU7.js → lib-DjpLC8uO.js} +1 -1
  99. data/dist/chunks/{pb_form_validation-DBJ0wZuS.js → pb_form_validation-S56UaHZl.js} +1 -1
  100. data/dist/chunks/vendor.js +1 -1
  101. data/dist/menu.yml +6 -0
  102. data/dist/playbook-doc.js +1 -1
  103. data/dist/playbook-rails-react-bindings.js +1 -1
  104. data/dist/playbook-rails.js +1 -1
  105. data/dist/playbook.css +1 -1
  106. data/lib/playbook/pb_forms_global_props_helper.rb +136 -0
  107. data/lib/playbook/pb_forms_helper.rb +13 -4
  108. data/lib/playbook/version.rb +1 -1
  109. metadata +41 -8
  110. data/dist/chunks/_typeahead-BWwaAo_0.js +0 -36
  111. data/dist/chunks/_weekday_stacked-zyBCd1s8.js +0 -45
  112. /data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/{_fixed_confirmation_toast_auto_close.md → _fixed_confirmation_toast_auto_close_react.md} +0 -0
@@ -8,13 +8,24 @@ module Playbook
8
8
  prop :enable_toggle_expansion, type: Playbook::Props::Enum,
9
9
  values: %w[all header none],
10
10
  default: "header"
11
+ prop :loading, type: Playbook::Props::Boolean,
12
+ default: false
13
+ prop :responsive, type: Playbook::Props::Enum,
14
+ values: %w[none scroll],
15
+ default: "scroll"
11
16
 
12
17
  def classname
13
- generate_classname("pb_advanced_table_header", "pb_table_thead", separator: " ")
18
+ additional_classes = []
19
+ additional_classes << "advanced-table-responsive-#{responsive} pinned-left" if responsive == "scroll"
20
+
21
+ generate_classname("pb_advanced_table_header", "pb_table_thead", *additional_classes, separator: " ")
14
22
  end
15
23
 
16
- def th_classname
17
- generate_classname("table-header-cells", separator: " ")
24
+ def th_classname(is_first_column: false)
25
+ additional_classes = []
26
+ additional_classes << "pinned-left" if is_first_column && responsive == "scroll"
27
+
28
+ generate_classname("table-header-cells", *additional_classes, separator: " ")
18
29
  end
19
30
 
20
31
  def header_rows
@@ -1,8 +1,8 @@
1
1
  <%= pb_content_tag(:tr) do %>
2
2
  <% object.column_definitions.each_with_index do |column, index| %>
3
3
  <% next unless column[:accessor].present? %>
4
- <%= pb_rails("table/table_cell", props: { classname:object.td_classname(column)}) do %>
5
- <%= pb_rails("flex", props:{ align: "center", justify: index.zero? ? "start" : "end" }) do %>
4
+ <%= pb_rails("table/table_cell", props: { classname:object.td_classname(column, index)}) do %>
5
+ <%= pb_rails("flex", props:{ align: "center", justify: index.zero? ? "start" : "end", classname: object.loading ? "loading-cell" : "" }) do %>
6
6
  <% if collapsible_trail && index.zero? %>
7
7
  <% (1..depth).each do |i| %>
8
8
  <% additional_offset = i > 1 ? (i - 1) * 0.25 : 0 %>
@@ -14,10 +14,13 @@
14
14
  <div style="padding-left: <%= depth * 1.25 %>em">
15
15
  <%= pb_rails("flex", props:{align: "center", column_gap: "xs"}) do %>
16
16
  <% if index.zero? && object.row[:children].present? %>
17
- <button id="<%= "#{object.id}_#{object.row.object_id}" %>" class="gray-icon expand-toggle-icon" data-advanced-table="true" >
18
- <%= pb_rails("icon", props: { id: "advanced-table_open_icon", icon: "circle-play", cursor: "pointer" }) %>
19
- <%= pb_rails("icon", props: { id: "advanced-table_close_icon", display: "none", icon: "circle-play", cursor: "pointer", rotation: 90 }) %>
20
- </button>
17
+ <button
18
+ id="<%= "#{object.id}_#{object.row.object_id}" %>"
19
+ class="gray-icon expand-toggle-icon"
20
+ data-advanced-table="true">
21
+ <%= pb_rails("icon", props: { id: "advanced-table_open_icon", icon: "circle-play", cursor: "pointer" }) %>
22
+ <%= pb_rails("icon", props: { id: "advanced-table_close_icon", display: "none", icon: "circle-play", cursor: "pointer", rotation: 90 }) %>
23
+ </button>
21
24
  <% end %>
22
25
  <%= pb_rails("flex/flex_item", props:{padding_left: index.zero? && object.row[:children].present? ? "none" : "xs"}) do %>
23
26
  <% if column[:custom_renderer].present? %>
@@ -42,4 +45,4 @@
42
45
  <% end %>
43
46
  <% end %>
44
47
  <% end %>
45
- <% end %>
48
+ <% end %>
@@ -13,6 +13,13 @@ module Playbook
13
13
  default: true
14
14
  prop :table_data_attributes, type: Playbook::Props::HashProp,
15
15
  default: {}
16
+ prop :loading, type: Playbook::Props::Boolean,
17
+ default: false
18
+ prop :responsive, type: Playbook::Props::Enum,
19
+ values: %w[none scroll],
20
+ default: "scroll"
21
+ prop :is_pinned_left, type: Playbook::Props::Boolean,
22
+ default: false
16
23
 
17
24
  def data
18
25
  Hash(prop(:data)).merge(table_data_attributes)
@@ -22,9 +29,10 @@ module Playbook
22
29
  generate_classname("pb_table_tr", "bg-white", subrow_depth_classname, separator: " ")
23
30
  end
24
31
 
25
- def td_classname(column)
32
+ def td_classname(column, index)
26
33
  classes = %w[id-cell chrome-styles]
27
34
  classes << "last-cell" if column[:is_last_in_group]
35
+ classes << "pinned-left" if index.zero? && is_pinned_left && responsive == "scroll"
28
36
  classes.join(" ")
29
37
  end
30
38
 
@@ -1,6 +1,6 @@
1
1
  <%= pb_content_tag(:tr) do %>
2
2
  <% object.column_definitions.each_with_index do |column, index| %>
3
- <%= pb_rails("table/table_cell", props: { classname: "id-cell chrome-styles"}) do %>
3
+ <%= pb_rails("table/table_cell", props: { classname: object.td_classname(index) }) do %>
4
4
  <%= pb_rails("flex", props:{ align: "center", justify: "start" }) do %>
5
5
  <% if collapsible_trail && index.zero? %>
6
6
  <% (1..depth).each do |i| %>
@@ -16,6 +16,9 @@ module Playbook
16
16
  default: true
17
17
  prop :subrow_data_attributes, type: Playbook::Props::HashProp,
18
18
  default: {}
19
+ prop :responsive, type: Playbook::Props::Enum,
20
+ values: %w[none scroll],
21
+ default: "scroll"
19
22
 
20
23
  def data
21
24
  Hash(prop(:data)).merge(subrow_data_attributes)
@@ -25,6 +28,12 @@ module Playbook
25
28
  generate_classname("pb_table_tr", "bg-silver", "pb_subrow_header", subrow_depth_classname, separator: " ")
26
29
  end
27
30
 
31
+ def td_classname(index)
32
+ classes = %w[id-cell chrome-styles]
33
+ classes << "pinned-left" if index.zero? && responsive == "scroll"
34
+ classes.join(" ")
35
+ end
36
+
28
37
  private
29
38
 
30
39
  def subrow_depth_classname
@@ -27,6 +27,9 @@ $avatar-sizes: (
27
27
  flex-basis: $size;
28
28
 
29
29
  & > [class^=pb_flex_kit] {
30
+ [class^=pb_card_kit] {
31
+ padding: 2px;
32
+ }
30
33
  [class^=pb_card_kit].overlay_bottom_center,
31
34
  [class^=pb_card_kit].overlay_top_center {
32
35
  left: 50%;
@@ -52,6 +55,10 @@ $avatar-sizes: (
52
55
  flex-grow: 0;
53
56
  flex-basis: $size;
54
57
 
58
+ .dark & {
59
+ background: $text_dk_light;
60
+ }
61
+
55
62
  &::before {
56
63
  content: attr(data-initials);
57
64
  width: 100%;
@@ -78,4 +85,11 @@ $avatar-sizes: (
78
85
  }
79
86
  }
80
87
  }
88
+
89
+ &.dark {
90
+ [class^=pb_card_kit] {
91
+ position: absolute;
92
+ padding: 2px;
93
+ }
94
+ }
81
95
  }
@@ -23,8 +23,8 @@ export type AvatarProps = {
23
23
  variant?: string,
24
24
  icon?: string
25
25
  },
26
- data?: {[key: string]: string},
27
26
  dark?: boolean,
27
+ data?: {[key: string]: string},
28
28
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
29
29
  id?: string,
30
30
  imageAlt?: string,
@@ -71,13 +71,13 @@ const Avatar = (props: AvatarProps): React.ReactElement => {
71
71
 
72
72
  const canShowImage = imageUrl && !error
73
73
 
74
- const onlineStatusSize =
74
+ const onlineStatusSize =
75
75
  ['xxs', 'xs'].includes(size) ? 'sm' :
76
76
  ['sm', 'md'].includes(size) ? 'md' :
77
77
  ['lg', 'xl'].includes(size) ? 'lg' :
78
78
  'sm';
79
79
 
80
- const onlineStatusPositionProps = (["xxs", "xs", "sm"].includes(size)) ?
80
+ const onlineStatusPositionProps = (["xxs", "xs", "sm"].includes(size)) ?
81
81
  {
82
82
  top: { inset: true, value: "0" },
83
83
  right: { inset: false, value: "xxs" }
@@ -96,10 +96,10 @@ const Avatar = (props: AvatarProps): React.ReactElement => {
96
96
  id={id}
97
97
  >
98
98
  {componentOverlay ? (
99
- <Flex display="display_inline_block"
99
+ <Flex display="display_inline_block"
100
100
  position="relative"
101
101
  >
102
- <div className="avatar_wrapper"
102
+ <div className="avatar_wrapper"
103
103
  data-initials={initials}
104
104
  >
105
105
  {canShowImage && (
@@ -115,12 +115,14 @@ const Avatar = (props: AvatarProps): React.ReactElement => {
115
115
  <Card
116
116
  borderNone
117
117
  borderRadius="rounded"
118
+ dark={dark}
118
119
  padding="none"
119
120
  position="absolute"
120
121
  {...getPlacementProps(componentOverlay.placement, size)}
121
122
  >
122
-
123
+
123
124
  <Badge
125
+ dark={dark}
124
126
  rounded
125
127
  text={componentOverlay.text}
126
128
  variant={componentOverlay.variant as "error" | "info" | "neutral" | "primary" | "success" | "warning" | "notification"}
@@ -131,11 +133,13 @@ const Avatar = (props: AvatarProps): React.ReactElement => {
131
133
  <Card
132
134
  borderNone
133
135
  borderRadius="rounded"
136
+ dark={dark}
134
137
  htmlOptions={{style: {padding:"2px"}}}
135
138
  position="absolute"
136
139
  {...getPlacementProps(componentOverlay.placement, size)}
137
140
  >
138
141
  <IconCircle
142
+ dark={dark}
139
143
  icon={componentOverlay.icon}
140
144
  size="xxs"
141
145
  variant={componentOverlay.variant as "default" | "royal" | "blue" | "purple" | "teal" | "red" | "yellow" | "orange" | "green"}
@@ -145,7 +149,7 @@ const Avatar = (props: AvatarProps): React.ReactElement => {
145
149
  </Flex>
146
150
  ) : (
147
151
  <>
148
- <div className="avatar_wrapper"
152
+ <div className="avatar_wrapper"
149
153
  data-initials={initials}
150
154
  >
151
155
  {canShowImage && (
@@ -1,22 +1,22 @@
1
1
 
2
2
  <%= object.pb_content_tag(:div, data: object.data.merge(initials: object.initials)) do %>
3
3
  <% if object.component_overlay && object.component_overlay[:component] == "icon_circle" %>
4
- <%= pb_rails("flex", props: {display: "display_inline_block", position: "relative" }) do %>
4
+ <%= pb_rails("flex", props: { display: "display_inline_block", position: "relative" }) do %>
5
5
  <%= content_tag(:div, data: { initials: object.initials }, class: "avatar_wrapper") do %>
6
6
  <%= pb_rails("image", props: { alt: object.alt_text, url: object.image_url, on_error: object.handle_img_error }) if object.image_url.present? %>
7
7
  <% end %>
8
- <%= pb_rails("card", props: { border_none: true, border_radius: "rounded", html_options: { style: "padding: 2px" }, position: "absolute" }.merge(specific_placement_style)) do %>
8
+ <%= pb_rails("card", props: { border_none: true, border_radius: "rounded", dark: object.dark, position: "absolute" }.merge(specific_placement_style)) do %>
9
9
 
10
- <%= pb_rails("icon_circle", props: { size: "xxs", icon: object.component_overlay[:icon], variant: object.component_overlay[:variant] }) %>
10
+ <%= pb_rails("icon_circle", props: { dark: object.dark, size: "xxs", icon: object.component_overlay[:icon], variant: object.component_overlay[:variant] }) %>
11
11
  <% end %>
12
12
  <% end %>
13
13
  <% elsif object.component_overlay && object.component_overlay[:component] == "badge" %>
14
- <%= pb_rails("flex", props: {display: "display_inline_block", position: "relative" }) do %>
14
+ <%= pb_rails("flex", props: { display: "display_inline_block", position: "relative" }) do %>
15
15
  <%= content_tag(:div, data: { initials: object.initials }, class: "avatar_wrapper") do %>
16
16
  <%= pb_rails("image", props: { alt: object.alt_text, url: object.image_url, on_error: object.handle_img_error }) if object.image_url.present? %>
17
17
  <% end %>
18
- <%= pb_rails("card", props: { border_none: true, border_radius: "rounded", padding: "none", position: "absolute" }.merge(specific_placement_style)) do %>
19
- <%= pb_rails("badge", props: { rounded: true, text: object.component_overlay[:text], variant: object.component_overlay[:variant] }) %>
18
+ <%= pb_rails("card", props: { border_none: true, border_radius: "rounded", dark: object.dark, padding: "none", position: "absolute" }.merge(specific_placement_style)) do %>
19
+ <%= pb_rails("badge", props: { dark: object.dark, rounded: true, text: object.component_overlay[:text], variant: object.component_overlay[:variant] }) %>
20
20
  <% end %>
21
21
  <% end %>
22
22
  <% else %>
@@ -26,4 +26,3 @@
26
26
  <%= pb_rails("online_status", props: object.online_status_props) if object.status %>
27
27
  <% end %>
28
28
  <% end %>
29
-
@@ -1,18 +1,19 @@
1
1
  import React from "react";
2
2
  import { Avatar } from 'playbook-ui'
3
3
 
4
- const AvatarBadgeComponentOverlay = () => {
4
+ const AvatarBadgeComponentOverlay = (props) => {
5
5
  return (
6
6
  <div>
7
7
  <Avatar
8
8
  componentOverlay={{
9
9
  component: "badge",
10
10
  placement: "bottom-right",
11
- text: "12"
11
+ text: "12",
12
12
  }}
13
13
  imageUrl="https://randomuser.me/api/portraits/men/44.jpg"
14
14
  marginBottom="sm"
15
15
  size="sm"
16
+ {...props}
16
17
  />
17
18
 
18
19
  <Avatar
@@ -24,6 +25,8 @@ const AvatarBadgeComponentOverlay = () => {
24
25
  imageUrl="https://randomuser.me/api/portraits/men/44.jpg"
25
26
  marginBottom="sm"
26
27
  size="md"
28
+ {...props}
29
+
27
30
  />
28
31
 
29
32
  <Avatar
@@ -36,6 +39,8 @@ const AvatarBadgeComponentOverlay = () => {
36
39
  imageUrl="https://randomuser.me/api/portraits/men/44.jpg"
37
40
  marginBottom="sm"
38
41
  size="lg"
42
+ {...props}
43
+
39
44
  />
40
45
 
41
46
  <Avatar
@@ -48,7 +53,8 @@ const AvatarBadgeComponentOverlay = () => {
48
53
  imageUrl="https://randomuser.me/api/portraits/men/44.jpg"
49
54
  marginBottom="sm"
50
55
  size="xl"
51
- />
56
+ {...props}
57
+ />
52
58
  </div>
53
59
  )
54
60
  }
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { Avatar } from 'playbook-ui'
3
3
 
4
- const AvatarCircleIconComponentOverlay = () => {
4
+ const AvatarCircleIconComponentOverlay = (props) => {
5
5
  return (
6
6
  <div>
7
7
  <Avatar
@@ -14,6 +14,7 @@ const AvatarCircleIconComponentOverlay = () => {
14
14
  imageUrl="https://randomuser.me/api/portraits/men/44.jpg"
15
15
  marginBottom="sm"
16
16
  size="sm"
17
+ {...props}
17
18
  />
18
19
 
19
20
  <Avatar
@@ -26,6 +27,7 @@ const AvatarCircleIconComponentOverlay = () => {
26
27
  imageUrl="https://randomuser.me/api/portraits/men/44.jpg"
27
28
  marginBottom="sm"
28
29
  size="md"
30
+ {...props}
29
31
  />
30
32
 
31
33
  <Avatar
@@ -38,6 +40,7 @@ const AvatarCircleIconComponentOverlay = () => {
38
40
  imageUrl="https://randomuser.me/api/portraits/men/44.jpg"
39
41
  marginBottom="sm"
40
42
  size="lg"
43
+ {...props}
41
44
  />
42
45
 
43
46
  <Avatar
@@ -50,7 +53,8 @@ const AvatarCircleIconComponentOverlay = () => {
50
53
  imageUrl="https://randomuser.me/api/portraits/men/44.jpg"
51
54
  marginBottom="sm"
52
55
  size="xl"
53
- />
56
+ {...props}
57
+ />
54
58
  </div>
55
59
  )
56
60
  }
@@ -65,7 +65,7 @@ module Playbook
65
65
  end
66
66
 
67
67
  def tag
68
- link ? "a" : "button"
68
+ link && !disabled ? "a" : "button"
69
69
  end
70
70
 
71
71
  def valid_emoji(icon)
@@ -0,0 +1,4 @@
1
+ .pb_copy_button_kit {
2
+ width: fit-content;
3
+ height: fit-content;
4
+ }
@@ -0,0 +1,92 @@
1
+
2
+ import React, { useState } from 'react'
3
+ import classnames from 'classnames'
4
+ import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
5
+ import { globalProps } from '../utilities/globalProps'
6
+
7
+ import Button from '../pb_button/_button'
8
+ import Tooltip from '../pb_tooltip/_tooltip'
9
+
10
+ type CopyButtonProps = {
11
+ aria?: { [key: string]: string },
12
+ className?: string,
13
+ data?: { [key: string]: string },
14
+ id?: string,
15
+ from?: string,
16
+ text?: string,
17
+ tooltipPlacement?: "top" | "right" | "bottom" | "left",
18
+ tooltipText?: string,
19
+ value?: string,
20
+ }
21
+
22
+ const CopyButton = (props: CopyButtonProps) => {
23
+ const {
24
+ aria = {},
25
+ className,
26
+ data = {},
27
+ from = '',
28
+ id,
29
+ text= 'Copy',
30
+ tooltipPlacement= 'bottom',
31
+ tooltipText = 'Copied!',
32
+ value = '',
33
+ } = props
34
+
35
+ const [copied, setCopied] = useState(false)
36
+
37
+ const ariaProps = buildAriaProps(aria)
38
+ const dataProps = buildDataProps(data)
39
+ const classes = classnames(buildCss('pb_copy_button_kit'), globalProps(props), className)
40
+
41
+ const copy = () => {
42
+ if (!from && !value) {
43
+ return
44
+ }
45
+
46
+ if (value) {
47
+ navigator.clipboard.writeText(value)
48
+ } else if (from) {
49
+ const copyElement = document.getElementById(from);
50
+ let copyText = copyElement?.innerText
51
+
52
+ if (copyElement instanceof HTMLTextAreaElement || copyElement instanceof HTMLInputElement) {
53
+ copyText = copyElement.value;
54
+ }
55
+
56
+ if (copyText) {
57
+ navigator.clipboard.writeText(copyText)
58
+ }
59
+ }
60
+
61
+ setCopied(true)
62
+
63
+ setTimeout(() => {
64
+ setCopied(false)
65
+ }, 1000);
66
+ }
67
+
68
+ return (
69
+ <div
70
+ {...ariaProps}
71
+ {...dataProps}
72
+ className={classes}
73
+ id={id}
74
+ >
75
+ <Tooltip
76
+ forceOpenTooltip={copied}
77
+ placement={tooltipPlacement}
78
+ showTooltip={false}
79
+ text={tooltipText}
80
+ >
81
+ <Button
82
+ icon='copy'
83
+ onClick={copy}
84
+ >
85
+ { text }
86
+ </Button>
87
+ </Tooltip>
88
+ </div>
89
+ )
90
+ }
91
+
92
+ export default CopyButton
@@ -0,0 +1,15 @@
1
+ <%= pb_content_tag do %>
2
+ <%= pb_rails("button", props: { icon: "copy" }) do %>
3
+ <%= object.text %>
4
+ <% end %>
5
+ <% if object.id %>
6
+ <%= pb_rails("tooltip", props: {
7
+ trigger_element_selector: "##{object.id}",
8
+ position: object.tooltip_position,
9
+ tooltip_id: "#{object.id}_tooltip",
10
+ trigger_method: "click"
11
+ }) do %>
12
+ <%= object.tooltip_text %>
13
+ <% end %>
14
+ <% end %>
15
+ <% end %>
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbCopyButton
5
+ class CopyButton < ::Playbook::KitBase
6
+ prop :text
7
+ prop :tooltip_position,
8
+ type: Playbook::Props::Enum,
9
+ values: %w[top right bottom left],
10
+ default: "top"
11
+ prop :tooltip_text, type: Playbook::Props::String,
12
+ default: "Copied!"
13
+ prop :value
14
+ prop :from
15
+
16
+ def classname
17
+ generate_classname("pb_copy_button_kit")
18
+ end
19
+
20
+ def data
21
+ Hash(values[:data]).merge(
22
+ "copy-value": value,
23
+ "from": from
24
+ )
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import { CopyButton } from 'playbook-ui'
3
+ import { ensureAccessible, renderKit, render, fireEvent, screen } from '../utilities/test-utils'
4
+
5
+ const props = {
6
+ data: { testid: 'default', value: 'copy' }
7
+ }
8
+
9
+ test('returns namespaced class name', () => {
10
+ const kit = renderKit(CopyButton, props)
11
+ expect(kit).toBeInTheDocument()
12
+ expect(kit).toHaveClass('pb_copy_button_kit')
13
+ })
14
+
15
+ it('should be accessible', async () => {
16
+ ensureAccessible(CopyButton, props)
17
+ })
18
+
19
+ // It's difficult to actually use navigator.clipboard.readText, so we mock
20
+ it('copies the value to clipboard and pastes it into an input', async () => {
21
+ Object.defineProperty(global, 'navigator', {
22
+ value: {
23
+ clipboard: {
24
+ writeText: jest.fn().mockResolvedValueOnce(undefined),
25
+ },
26
+ },
27
+ writable: true,
28
+ })
29
+
30
+ render(<CopyButton {...props} />)
31
+
32
+ const copyButton = screen.getByTestId('default')
33
+ fireEvent.click(copyButton)
34
+
35
+ await navigator.clipboard.writeText('copy')
36
+
37
+ expect(navigator.clipboard.writeText).toHaveBeenCalledWith("copy");
38
+ })
39
+
40
+ test('passes text and tooltip props to button', () => {
41
+ render(
42
+ <CopyButton
43
+ data={{ testid: 'text-test' }}
44
+ text={"text"}
45
+ tooltipPlacement="right"
46
+ tooltipText="Text copied!"
47
+ value="copy"
48
+ />
49
+ )
50
+
51
+ const content = screen.getByText("text")
52
+ expect(content).toHaveTextContent("text")
53
+
54
+ const kit = screen.getByTestId('text-test')
55
+ const button = kit.querySelector('.pb_button_kit_primary_inline_enabled')
56
+ expect(button).toBeInTheDocument()
57
+
58
+ fireEvent.click(button)
59
+ const tooltipContent = screen.getByText("Text copied!")
60
+ expect(tooltipContent).toHaveTextContent("Text copied!")
61
+
62
+ const tooltip = kit.querySelector('.pb_tooltip_kit')
63
+ expect(tooltip).toBeInTheDocument()
64
+ })
@@ -0,0 +1,2 @@
1
+ <%= pb_rails("copy_button", props: { id: "default-copy-button", text: "Copy Text", value: "Playbook makes it easy to support bleeding edge, or legacy systems. Use Playbook’s 200+ components and end-to-end design language to create simple, intuitive and beautiful experiences with ease." } ) %>
2
+ <%= pb_rails("textarea", props: { margin_top: "xs", placeholder: "Copy and paste here" }) %>
@@ -0,0 +1,21 @@
1
+ import React from 'react'
2
+ import { CopyButton, Textarea } from 'playbook-ui'
3
+
4
+ const CopyButtonDefault = (props) => (
5
+ <div>
6
+ <CopyButton
7
+ {...props}
8
+ text="Copy Text"
9
+ tooltipPlacement="right"
10
+ tooltipText="Text copied!"
11
+ value="Playbook makes it easy to support bleeding edge, or legacy systems. Use Playbook’s 200+ components and end-to-end design language to create simple, intuitive and beautiful experiences with ease."
12
+ />
13
+
14
+ <Textarea
15
+ {...props}
16
+ placeholder="Copy and paste here"
17
+ />
18
+ </div>
19
+ )
20
+
21
+ export default CopyButtonDefault
@@ -0,0 +1,5 @@
1
+ <%= pb_rails("body", props: { id: "body", text: "Copy this body text!"}) %>
2
+ <%= pb_rails("copy_button", props: { text: "Copy Body text", from: "body", id: "copy-body-button" }) %>
3
+ <%= pb_rails("text_input", props: { margin_top: "xs", placeholder: "Copy and paste here" }) %>
4
+ <%= pb_rails("copy_button", props: { text: "Copy Text Input", from: "copy-input", id: "copy-input-button" }) %>
5
+ <%= pb_rails("text_input", props: { margin_top: "xs", id: "copy-input" , value: "Copy and paste here" }) %>
@@ -0,0 +1,45 @@
1
+ import React, { useState } from 'react'
2
+ import { CopyButton, Body, TextInput, Textarea } from 'playbook-ui'
3
+
4
+ const CopyButtonFrom = (props) => {
5
+ const [text, setText] = useState("Copy this text input text")
6
+
7
+ const handleChange = (event) => {
8
+ setText(event.target.value);
9
+ }
10
+
11
+ return (<div>
12
+ <Body id="body">Copy this body text!</Body>
13
+ <CopyButton
14
+ {...props}
15
+ from="body"
16
+ marginBottom="sm"
17
+ text="Copy Body text"
18
+ tooltipPlacement="right"
19
+ tooltipText="Body text copied!"
20
+ />
21
+
22
+ <TextInput
23
+ {...props}
24
+ id="textinput"
25
+ onChange={handleChange}
26
+ value={text}
27
+ />
28
+ <CopyButton
29
+ {...props}
30
+ from="textinput"
31
+ marginBottom="sm"
32
+ text="Copy Text Input"
33
+ tooltipPlacement="right"
34
+ tooltipText="Text input copied!"
35
+ />
36
+
37
+ <Textarea
38
+ {...props}
39
+ placeholder="Copy and paste here"
40
+ />
41
+ </div>
42
+ )
43
+ }
44
+
45
+ export default CopyButtonFrom
@@ -0,0 +1 @@
1
+ Provide an element's ID as the `from` parameter, and its text will be copied. If the element is an input, its `value` will be copied; otherwise, the `innerText` will be used. Additionally, if a `value` prop is provided, it will override the content from the `from` element and be copied instead.