playbook_ui 15.2.0.pre.alpha.play2318draggablelistnoborder11263 → 15.2.0.pre.alpha.play257911600
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/_playbook.scss +5 -5
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +18 -3
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +56 -14
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +9 -3
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.html.erb +39 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.md +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb +3 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_subrow_headers.html.erb +3 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail_rails.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_column_headers_rails.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_per_row_rails.html.erb +51 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_per_row_rails.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_rails.html.erb +40 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_rails.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling_rails.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling_react.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/index.js +5 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +6 -6
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +6 -6
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +3 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +49 -5
- data/app/pb_kits/playbook/pb_button/_button.scss +6 -0
- data/app/pb_kits/playbook/pb_button/docs/_button_loading.html.erb +7 -3
- data/app/pb_kits/playbook/pb_button/docs/_button_loading.jsx +29 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range_pattern.jsx +1 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.scss +0 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx +5 -3
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_description.md +2 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.rb +4 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.test.js +10 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +1 -1
- data/app/pb_kits/playbook/pb_pb_bar_graph/_pb_bar_graph.tsx +8 -6
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_description.md +3 -0
- data/app/pb_kits/playbook/pb_pb_bar_graph/pb_bar_graph.rb +7 -10
- data/app/pb_kits/playbook/pb_pb_bar_graph/pbbargraph.test.jsx +73 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/_pb_circle_chart.tsx +1 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_description.md +3 -0
- data/app/pb_kits/playbook/pb_pb_circle_chart/pb_circle_chart.rb +7 -10
- data/app/pb_kits/playbook/pb_pb_circle_chart/pb_circle_chart.test.jsx +47 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/_pb_gauge_chart.scss +3 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/_pb_gauge_chart.tsx +69 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_description.md +3 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_color.html.erb +12 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_color.jsx +24 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_color.md +5 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_complex.html.erb +45 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_complex.jsx +119 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_complex.md +1 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_default.html.erb +5 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_default.jsx +17 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_disable_animation.html.erb +12 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_disable_animation.jsx +24 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_full_circle.html.erb +23 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_full_circle.jsx +37 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_height.html.erb +40 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_height.jsx +56 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_live_data.jsx +64 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_min_max.html.erb +27 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_min_max.jsx +40 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_min_max.md +1 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_sizing.html.erb +19 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_sizing.jsx +65 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_sizing.md +3 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_title.html.erb +14 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_title.jsx +27 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_units.html.erb +39 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_units.jsx +58 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_units.md +1 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/example.yml +29 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/index.js +11 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/pbGaugeGraphTheme.ts +91 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/pb_gauge_chart.html.erb +1 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/pb_gauge_chart.rb +25 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/pb_gauge_chart.test.jsx +80 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/_pb_line_graph.scss +3 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/_pb_line_graph.tsx +61 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_description.md +3 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_colors.html.erb +34 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_colors.jsx +52 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_colors.md +5 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_default.html.erb +34 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_default.jsx +45 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_height.html.erb +47 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_height.jsx +64 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_height.md +3 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend.html.erb +24 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend.jsx +37 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_nonclickable.html.erb +39 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_nonclickable.jsx +45 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.html.erb +86 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.jsx +116 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.md +11 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/example.yml +20 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/index.js +6 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/pbLineGraphTheme.ts +125 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.html.erb +1 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.rb +25 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.test.jsx +110 -0
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +105 -22
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/Toolbar.tsx +41 -2
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarDropdown.tsx +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +60 -20
- data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +36 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_attributes.jsx +38 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_attributes.md +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_focus.jsx +34 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_focus.md +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_inline.jsx +37 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_inline.md +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_simple.jsx +37 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_sticky.jsx +38 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_sticky.md +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_templates.jsx +69 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_templates.md +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +8 -2
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +6 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.test.js +127 -1
- data/app/pb_kits/playbook/pb_timeline/_timeline.scss +250 -233
- data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +1 -1
- data/app/pb_kits/playbook/pb_timeline/timeline.test.js +2 -2
- data/app/pb_kits/playbook/tokens/_positioning.scss +1 -0
- data/app/pb_kits/playbook/utilities/_positioning.scss +6 -1
- data/app/pb_kits/playbook/utilities/globalProps.ts +3 -1
- data/dist/chunks/{_line_graph-BxcVBQsJ.js → _line_graph-BnVgr42C.js} +1 -1
- data/dist/chunks/_typeahead-BH_dkgOy.js +6 -0
- data/dist/chunks/{_weekday_stacked-BhPyFGlS.js → _weekday_stacked-B3YOt9GF.js} +3 -3
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +12 -0
- data/dist/playbook-doc.js +2 -2
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/pb_forms_helper.rb +7 -6
- data/lib/playbook/version.rb +1 -1
- data/lib/playbook/z_index.rb +1 -1
- metadata +83 -5
- data/dist/chunks/_typeahead-eZENQ_Y_.js +0 -6
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
<% end %>
|
|
13
13
|
<% object.column_definitions.each_with_index do |column, index| %>
|
|
14
14
|
<% next unless column[:accessor].present? %>
|
|
15
|
-
|
|
15
|
+
<% component_info = object.cell_component_info(column, index, bg_color, font_color) %>
|
|
16
|
+
<%= pb_rails(component_info[:name], props: component_info[:props]) do %>
|
|
16
17
|
<%= pb_rails("flex", props:{ align: "center", justify: object.justify_for(column, index), classname: object.loading ? "loading-cell" : "" }) do %>
|
|
17
18
|
<% if collapsible_trail && index.zero? %>
|
|
18
19
|
<% (1..depth).each do |i| %>
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
<% end %>
|
|
34
35
|
<% if object.row[:children].present? %>
|
|
35
36
|
<button
|
|
36
|
-
id="<%= "#{object.
|
|
37
|
+
id="<%= "#{object.table_id}_#{object.row.object_id}" %>"
|
|
37
38
|
class="gray-icon expand-toggle-icon"
|
|
38
39
|
data-advanced-table="true"
|
|
39
40
|
style="color: <%= button_color %>"
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
module Playbook
|
|
4
4
|
module PbAdvancedTable
|
|
5
5
|
class TableRow < Playbook::KitBase
|
|
6
|
-
prop :
|
|
7
|
-
|
|
6
|
+
prop :table_id, type: Playbook::Props::String,
|
|
7
|
+
default: ""
|
|
8
8
|
prop :column_definitions, type: Playbook::Props::Array,
|
|
9
9
|
default: []
|
|
10
10
|
prop :row
|
|
@@ -46,9 +46,53 @@ module Playbook
|
|
|
46
46
|
classes = %w[id-cell]
|
|
47
47
|
classes << "last-cell" if column[:is_last_in_group]
|
|
48
48
|
classes << "pinned-left" if index.zero? && is_pinned_left && responsive == "scroll"
|
|
49
|
+
|
|
50
|
+
row_style = row_styling.find { |style| style[:row_id].to_s == row_id.to_s }
|
|
51
|
+
row_padding = row_style&.[](:cell_padding)
|
|
52
|
+
|
|
53
|
+
if column[:accessor].present?
|
|
54
|
+
orig_def = find_column_def_by_accessor(column_definitions, column[:accessor])
|
|
55
|
+
column_padding = orig_def[:column_styling][:cell_padding] if orig_def && orig_def[:column_styling].is_a?(Hash) && orig_def[:column_styling][:cell_padding].present?
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
classes << "p_#{row_padding}" if row_padding.present?
|
|
59
|
+
classes << "p_#{column_padding}" if column_padding.present?
|
|
60
|
+
|
|
49
61
|
classes.join(" ")
|
|
50
62
|
end
|
|
51
63
|
|
|
64
|
+
def cell_background_color(column)
|
|
65
|
+
return nil unless column[:accessor].present?
|
|
66
|
+
|
|
67
|
+
orig_def = find_column_def_by_accessor(column_definitions, column[:accessor])
|
|
68
|
+
if orig_def && orig_def[:column_styling].is_a?(Hash) && orig_def[:column_styling][:cell_background_color].present?
|
|
69
|
+
bg_color = orig_def[:column_styling][:cell_background_color]
|
|
70
|
+
if bg_color.respond_to?(:call)
|
|
71
|
+
bg_color.call(row)
|
|
72
|
+
else
|
|
73
|
+
bg_color
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def has_custom_background_color?(column)
|
|
79
|
+
cell_background_color(column).present?
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Uses a regular table/table_cell component if there is no custom background color; if there is a cell_background_color uses a background component with tag "td"
|
|
83
|
+
def cell_component_info(column, index, bg_color, font_color)
|
|
84
|
+
if has_custom_background_color?(column)
|
|
85
|
+
custom_bg_color = cell_background_color(column)
|
|
86
|
+
component_name = "background"
|
|
87
|
+
component_props = { background_color: custom_bg_color, tag: "td", classname: td_classname(column, index) }
|
|
88
|
+
else
|
|
89
|
+
component_name = "table/table_cell"
|
|
90
|
+
component_props = { html_options: { style: { "background-color": bg_color, color: font_color } }, classname: td_classname(column, index) }
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
{ name: component_name, props: component_props }
|
|
94
|
+
end
|
|
95
|
+
|
|
52
96
|
def depth_accessors
|
|
53
97
|
column_definitions.flat_map do |column|
|
|
54
98
|
column[:cellAccessors] if column.key?(:cellAccessors)
|
|
@@ -58,13 +102,13 @@ module Playbook
|
|
|
58
102
|
# Selectable Rows No Subrows - checkboxes in their own first cell
|
|
59
103
|
def render_checkbox_cell
|
|
60
104
|
if selectable_rows
|
|
61
|
-
prefix =
|
|
105
|
+
prefix = table_id ? "#{table_id}-" : ""
|
|
62
106
|
pb_rails("table/table_cell", props: {
|
|
63
107
|
classname: "checkbox-cell",
|
|
64
108
|
}) do
|
|
65
109
|
pb_rails("checkbox", props: {
|
|
66
110
|
id: "#{prefix}select-row-#{row_id || row.object_id}",
|
|
67
|
-
indeterminate_parent: "#{
|
|
111
|
+
indeterminate_parent: "#{table_id ? "#{table_id}-" : ''}select-all-rows",
|
|
68
112
|
name: "#{prefix}select-row-#{row_id || row.object_id}",
|
|
69
113
|
data: {
|
|
70
114
|
row_id: row_id || row.object_id.to_s,
|
|
@@ -78,7 +122,7 @@ module Playbook
|
|
|
78
122
|
# Selectable Rows w/ Subrows - checkboxes part of toggleable first cell
|
|
79
123
|
def render_row_checkbox
|
|
80
124
|
if selectable_rows
|
|
81
|
-
prefix =
|
|
125
|
+
prefix = table_id ? "#{table_id}-" : ""
|
|
82
126
|
indeterminate_parent =
|
|
83
127
|
if depth.zero?
|
|
84
128
|
"#{prefix}select-all-rows"
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
<%= pb_rails("
|
|
2
|
-
<%= pb_rails("button", props: { aria: { label: "Loading" },
|
|
3
|
-
<%= pb_rails("button", props: { aria: { label: "Loading" },
|
|
1
|
+
<%= pb_rails("caption", props: { margin_y: "md", text: "Button variants with loading" }) %>
|
|
2
|
+
<%= pb_rails("button", props: { aria: { label: "Loading" }, loading: true, margin_right: "lg" }) %>
|
|
3
|
+
<%= pb_rails("button", props: { aria: { label: "Loading" }, variant: "secondary", loading: true, margin_right: "lg" }) %>
|
|
4
|
+
<%= pb_rails("button", props: { aria: { label: "Loading" }, variant: "link", loading: true, margin_right: "lg" }) %>
|
|
5
|
+
<%= pb_rails("caption", props: { margin_y: "md", text: "Button sizes with loading" }) %>
|
|
6
|
+
<%= pb_rails("button", props: { aria: { label: "Loading" }, loading: true, size: "sm", margin_right: "lg" }) %>
|
|
7
|
+
<%= pb_rails("button", props: { aria: { label: "Loading" }, loading: true, size: "lg", margin_right: "lg" }) %>
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import Button from "../../pb_button/_button"
|
|
3
|
+
import Caption from "../../pb_caption/_caption"
|
|
3
4
|
|
|
4
5
|
const ButtonLoading = (props) => (
|
|
5
6
|
<div>
|
|
7
|
+
<Caption
|
|
8
|
+
marginY="md"
|
|
9
|
+
text="Button variants with loading"
|
|
10
|
+
/>
|
|
6
11
|
<Button
|
|
7
12
|
aria={{ label: 'Loading' }}
|
|
8
13
|
loading
|
|
@@ -31,6 +36,30 @@ const ButtonLoading = (props) => (
|
|
|
31
36
|
variant="link"
|
|
32
37
|
{...props}
|
|
33
38
|
/>
|
|
39
|
+
<br/>
|
|
40
|
+
<Caption
|
|
41
|
+
marginY="md"
|
|
42
|
+
text="Button sizes with loading"
|
|
43
|
+
/>
|
|
44
|
+
<Button
|
|
45
|
+
aria={{ label: 'Loading' }}
|
|
46
|
+
loading
|
|
47
|
+
marginRight='lg'
|
|
48
|
+
size="sm"
|
|
49
|
+
tabIndex={0}
|
|
50
|
+
text="Small Button"
|
|
51
|
+
{...props}
|
|
52
|
+
/>
|
|
53
|
+
{' '}
|
|
54
|
+
<Button
|
|
55
|
+
aria={{ label: 'Loading' }}
|
|
56
|
+
loading
|
|
57
|
+
marginRight='lg'
|
|
58
|
+
size="lg"
|
|
59
|
+
tabIndex={0}
|
|
60
|
+
text="Small Button"
|
|
61
|
+
{...props}
|
|
62
|
+
/>
|
|
34
63
|
</div>
|
|
35
64
|
)
|
|
36
65
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
2
|
import classnames from "classnames";
|
|
3
3
|
|
|
4
|
-
import { globalProps } from "../utilities/globalProps";
|
|
4
|
+
import { globalProps, GlobalProps } from "../utilities/globalProps";
|
|
5
5
|
import { buildHtmlProps } from "../utilities/props";
|
|
6
6
|
import { VoidCallback } from "../types";
|
|
7
7
|
|
|
@@ -31,7 +31,8 @@ type FixedConfirmationToastProps = {
|
|
|
31
31
|
status?: "success" | "error" | "neutral" | "tip";
|
|
32
32
|
text?: string;
|
|
33
33
|
vertical?: "top" | "bottom";
|
|
34
|
-
|
|
34
|
+
zIndex?: number | string;
|
|
35
|
+
} & GlobalProps
|
|
35
36
|
|
|
36
37
|
const FixedConfirmationToast = (props: FixedConfirmationToastProps): React.ReactElement => {
|
|
37
38
|
const [showToast, toggleToast] = useState(true);
|
|
@@ -50,6 +51,7 @@ const FixedConfirmationToast = (props: FixedConfirmationToastProps): React.React
|
|
|
50
51
|
status = "neutral",
|
|
51
52
|
text,
|
|
52
53
|
vertical,
|
|
54
|
+
zIndex = 'max',
|
|
53
55
|
} = props;
|
|
54
56
|
|
|
55
57
|
const returnedIcon = icon || iconMap[status]
|
|
@@ -59,7 +61,7 @@ const FixedConfirmationToast = (props: FixedConfirmationToastProps): React.React
|
|
|
59
61
|
`pb_fixed_confirmation_toast_kit_${status}${multiLine ? '_multi_line' : ''}`,
|
|
60
62
|
{ [`positioned_toast ${vertical} ${horizontal}`]: vertical && horizontal },
|
|
61
63
|
`${iconClass}`,
|
|
62
|
-
globalProps(props),
|
|
64
|
+
globalProps(props, { zIndex }),
|
|
63
65
|
className
|
|
64
66
|
);
|
|
65
67
|
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
|
|
2
2
|
Fixed Confirmation Toast is used as an alert. Success is used when a user successfully completes an action. Error is used when there is an error and the user cannot proceed. Neutral is used to display information to a user to complete a task.
|
|
3
|
+
|
|
4
|
+
**NOTE**: z index for Fixed Confirmation Toast is set to 'max' by default which has the value of `999999`. the z Index global prop can be used to override this if you want to set it to a different value.
|
|
@@ -60,7 +60,10 @@ module Playbook
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def classname
|
|
63
|
-
|
|
63
|
+
default_z_index = z_index.present? ? "" : " z_index_max"
|
|
64
|
+
# IMPORTANT: the AutoClose class must be the last class in the string for JS to read it correctly
|
|
65
|
+
# Changing the order will break the auto_close functionality
|
|
66
|
+
generate_classname("pb_fixed_confirmation_toast_kit", status, multi_line_class) + close_class + position_class + icon_class + default_z_index + auto_close_class
|
|
64
67
|
end
|
|
65
68
|
end
|
|
66
69
|
end
|
|
@@ -75,4 +75,14 @@ test('renders position when provided', () => {
|
|
|
75
75
|
/>
|
|
76
76
|
);
|
|
77
77
|
expect(container.querySelector('.positioned_toast')).toBeInTheDocument();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('renders max zIndex by default', () => {
|
|
81
|
+
const { container } = render(<FixedConfirmationToast />);
|
|
82
|
+
expect(container.querySelector('.z_index_max')).toBeInTheDocument();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('applies custom zIndex when provided', () => {
|
|
86
|
+
const { container } = render(<FixedConfirmationToast zIndex={10} />);
|
|
87
|
+
expect(container.querySelector('.z_index_10')).toBeInTheDocument();
|
|
78
88
|
});
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
<%= form.typeahead :example_typeahead_validation_react, props: { options: example_typeahead_options, pills: true, label: "Example Typeahead (React Rendered)", placeholder: "Search for a user", required: true, validation: { message: "Please select a color." } } %>
|
|
102
102
|
<%= form.typeahead :example_typeahead_validation_react_2, props: { options: example_typeahead_options, pills: true, label: "Example Typeahead 2 (React Rendered)", placeholder: "Search for a user", required: true } %>
|
|
103
103
|
<%= form.text_field :example_text_field_validation, props: { label: true, required: true } %>
|
|
104
|
-
<%= form.phone_number_field :example_phone_number_field_validation, props: { label: "Example phone field", hidden_inputs: true } %>
|
|
104
|
+
<%= form.phone_number_field :example_phone_number_field_validation, props: { label: "Example phone field", hidden_inputs: true, required: true } %>
|
|
105
105
|
<%= form.email_field :example_email_field_validation, props: { label: true, required: true } %>
|
|
106
106
|
<%= form.number_field :example_number_field_validation, props: { label: true, required: true } %>
|
|
107
107
|
<%= form.search_field :example_project_number_validation, props: { label: true, required: true, validation: { pattern: "[0-9]{2}-[0-9]{5}", message: "Please enter a valid project number (example: 33-12345)." } } %>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useMemo } from "react"
|
|
2
2
|
import { globalProps } from "../utilities/globalProps";
|
|
3
|
-
import { buildAriaProps, buildDataProps, buildHtmlProps } from "../utilities/props";
|
|
3
|
+
import { buildAriaProps, buildDataProps, buildCss, buildHtmlProps } from "../utilities/props";
|
|
4
4
|
import Highcharts from "highcharts"
|
|
5
5
|
import HighchartsReact from "highcharts-react-official"
|
|
6
6
|
|
|
@@ -18,23 +18,25 @@ type PbBarGraphProps = {
|
|
|
18
18
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)};
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const PbBarGraph = ({
|
|
21
|
+
const PbBarGraph = ( props: PbBarGraphProps): React.ReactElement => {
|
|
22
|
+
const {
|
|
22
23
|
aria = {},
|
|
23
24
|
data = {},
|
|
24
25
|
id,
|
|
25
26
|
htmlOptions = {},
|
|
26
27
|
options,
|
|
27
|
-
className
|
|
28
|
-
}
|
|
28
|
+
className,
|
|
29
|
+
} = props
|
|
29
30
|
|
|
30
31
|
const ariaProps = buildAriaProps(aria);
|
|
31
32
|
const dataProps = buildDataProps(data)
|
|
32
33
|
const htmlProps = buildHtmlProps(htmlOptions);
|
|
34
|
+
const classes = classnames(buildCss('pb_pb_bar_graph'), globalProps(props), className)
|
|
33
35
|
|
|
34
36
|
const mergedOptions = useMemo(() => {
|
|
35
37
|
if (!options || typeof options !== "object") {
|
|
36
38
|
// eslint-disable-next-line no-console
|
|
37
|
-
console.error("❌ Invalid options passed to <
|
|
39
|
+
console.error("❌ Invalid options passed to <PbBarGraph />", options)
|
|
38
40
|
return {}
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -46,7 +48,7 @@ const PbBarGraph = ({
|
|
|
46
48
|
<div>
|
|
47
49
|
<HighchartsReact
|
|
48
50
|
containerProps={{
|
|
49
|
-
className: classnames(
|
|
51
|
+
className: classnames(classes),
|
|
50
52
|
id: id,
|
|
51
53
|
...ariaProps,
|
|
52
54
|
...dataProps,
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
This kit is a wrapper around the Highcharts library. It applies styling and default settings but does NOT ship Highcharts. In order to use this kit, 'highcharts' and 'highcharts-react-official' must be installed in your repo. Once done, any prop or functionality provided by Highcharts can be used with this kit without requiring specific props from Playbook. The doc examples below showcase a few common usecases but are not a comprehensive list of all the functionalities possible.
|
|
2
|
+
|
|
3
|
+
See the [highcharts API docs](https://api.highcharts.com/highcharts/) for a comprehensive look at what is possible.
|
|
@@ -4,24 +4,21 @@ module Playbook
|
|
|
4
4
|
module PbPbBarGraph
|
|
5
5
|
class PbBarGraph < ::Playbook::KitBase
|
|
6
6
|
prop :options, default: {}
|
|
7
|
-
prop :container_props, default: {}
|
|
8
7
|
|
|
9
8
|
def react_props
|
|
10
9
|
{
|
|
10
|
+
className: classname,
|
|
11
|
+
data: data,
|
|
11
12
|
options: options,
|
|
12
|
-
|
|
13
|
+
id: id,
|
|
13
14
|
}
|
|
14
15
|
end
|
|
15
16
|
|
|
16
|
-
def container_props_hash
|
|
17
|
-
container_props.merge({
|
|
18
|
-
id: id,
|
|
19
|
-
className: classname,
|
|
20
|
-
}).compact
|
|
21
|
-
end
|
|
22
|
-
|
|
23
17
|
def classname
|
|
24
|
-
|
|
18
|
+
# Highcharts react needs classname attached to the container div,
|
|
19
|
+
# we pass an empty string here to avoid conflicts, classname is built in the TSX
|
|
20
|
+
# We still need generate_classnames to retain ability to pass in custom classnames or global props
|
|
21
|
+
generate_classname("")
|
|
25
22
|
end
|
|
26
23
|
end
|
|
27
24
|
end
|
|
@@ -15,6 +15,41 @@ afterEach(() => {
|
|
|
15
15
|
console.warn.mockRestore();
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
+
const chartData = [{
|
|
19
|
+
name: 'Installation',
|
|
20
|
+
data: [1475, 200, 3000, 654, 656],
|
|
21
|
+
}, {
|
|
22
|
+
name: 'Manufacturing',
|
|
23
|
+
data: [4434, 524, 2320, 440, 500],
|
|
24
|
+
}, {
|
|
25
|
+
name: 'Sales & Distribution',
|
|
26
|
+
data: [3387, 743, 1344, 434, 440],
|
|
27
|
+
}, {
|
|
28
|
+
name: 'Project Development',
|
|
29
|
+
data: [3227, 878, 999, 780, 1000],
|
|
30
|
+
}, {
|
|
31
|
+
name: 'Other',
|
|
32
|
+
data: [1111, 677, 3245, 500, 200],
|
|
33
|
+
}]
|
|
34
|
+
|
|
35
|
+
const chartOptions = {
|
|
36
|
+
series: chartData,
|
|
37
|
+
title: {
|
|
38
|
+
text: 'Solar Employment Growth by Sector, 2010-2016',
|
|
39
|
+
},
|
|
40
|
+
subtitle: {
|
|
41
|
+
text: 'Source: thesolarfoundation.com',
|
|
42
|
+
},
|
|
43
|
+
xAxis: {
|
|
44
|
+
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
|
|
45
|
+
},
|
|
46
|
+
yAxis: {
|
|
47
|
+
title: {
|
|
48
|
+
text: 'Number of Employees',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
|
|
18
53
|
const testId = 'bargraph1';
|
|
19
54
|
|
|
20
55
|
test('bargraph uses exact classname', () => {
|
|
@@ -23,9 +58,46 @@ test('bargraph uses exact classname', () => {
|
|
|
23
58
|
className='super_important_class'
|
|
24
59
|
data={{ testid: testId }}
|
|
25
60
|
id='bar-default'
|
|
61
|
+
options={chartOptions}
|
|
26
62
|
/>
|
|
27
63
|
);
|
|
28
64
|
|
|
29
65
|
const kit = screen.getByTestId(testId);
|
|
30
66
|
expect(kit).toHaveClass('super_important_class');
|
|
31
|
-
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('Kit to apply base classname', () => {
|
|
70
|
+
render(
|
|
71
|
+
<PbBarGraph
|
|
72
|
+
data={{testid: testId}}
|
|
73
|
+
options={chartOptions}
|
|
74
|
+
/>
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
expect(screen.getByTestId(testId)).toHaveClass('pb_pb_bar_graph')
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
test('Kit to apply global props', () => {
|
|
82
|
+
render(
|
|
83
|
+
<PbBarGraph
|
|
84
|
+
data={{testid: testId}}
|
|
85
|
+
margin="lg"
|
|
86
|
+
options={chartOptions}
|
|
87
|
+
/>
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
expect(screen.getByTestId(testId)).toHaveClass('m_lg')
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
test('kit to apply id', () => {
|
|
94
|
+
render(
|
|
95
|
+
<PbBarGraph
|
|
96
|
+
data={{testid: testId}}
|
|
97
|
+
id='bar-graph-id'
|
|
98
|
+
options={chartOptions}
|
|
99
|
+
/>
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
expect(screen.getByTestId(testId)).toHaveAttribute('id', 'bar-graph-id')
|
|
103
|
+
})
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
This kit is a wrapper around the Highcharts library. It applies styling and default settings but does NOT ship Highcharts. In order to use this kit, 'highcharts' and 'highcharts-react-official' must be installed in your repo. Once done, any prop or functionality provided by Highcharts can be used with this kit without requiring specific props from Playbook. The doc examples below showcase a few common usecases but are not a comprehensive list of all the functionalities possible.
|
|
2
|
+
|
|
3
|
+
See the [highcharts API docs](https://api.highcharts.com/highcharts/) for a comprehensive look at what is possible.
|
|
@@ -4,24 +4,21 @@ module Playbook
|
|
|
4
4
|
module PbPbCircleChart
|
|
5
5
|
class PbCircleChart < ::Playbook::KitBase
|
|
6
6
|
prop :options, default: {}
|
|
7
|
-
prop :container_props, default: {}
|
|
8
7
|
|
|
9
8
|
def react_props
|
|
10
9
|
{
|
|
10
|
+
className: classname,
|
|
11
|
+
data: data,
|
|
11
12
|
options: options,
|
|
12
|
-
|
|
13
|
+
id: id,
|
|
13
14
|
}
|
|
14
15
|
end
|
|
15
16
|
|
|
16
|
-
def container_props_hash
|
|
17
|
-
container_props.merge({
|
|
18
|
-
id: id,
|
|
19
|
-
className: classname,
|
|
20
|
-
}).compact
|
|
21
|
-
end
|
|
22
|
-
|
|
23
17
|
def classname
|
|
24
|
-
|
|
18
|
+
# Highcharts react needs classname attached to the container div,
|
|
19
|
+
# we pass an empty string here to avoid conflicts, classname is built in the TSX
|
|
20
|
+
# We still need generate_classnames to retain ability to pass in custom classnames or global props
|
|
21
|
+
generate_classname("")
|
|
25
22
|
end
|
|
26
23
|
end
|
|
27
24
|
end
|
|
@@ -49,3 +49,50 @@ test('Kit to exist', () => {
|
|
|
49
49
|
expect(screen.getByTestId(testId)).toBeInTheDocument()
|
|
50
50
|
})
|
|
51
51
|
|
|
52
|
+
test('Kit to apply base classname', () => {
|
|
53
|
+
render(
|
|
54
|
+
<PbCircleChart
|
|
55
|
+
data={{testid: testId}}
|
|
56
|
+
options={chartOptions}
|
|
57
|
+
/>
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
expect(screen.getByTestId(testId)).toHaveClass('pb_pb_circle_chart')
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
test('Kit to have custom class', () => {
|
|
64
|
+
render(
|
|
65
|
+
<PbCircleChart
|
|
66
|
+
className='custom-class'
|
|
67
|
+
data={{testid: testId}}
|
|
68
|
+
options={chartOptions}
|
|
69
|
+
/>
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
expect(screen.getByTestId(testId)).toHaveClass('custom-class')
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
test('Kit to apply global props', () => {
|
|
76
|
+
render(
|
|
77
|
+
<PbCircleChart
|
|
78
|
+
data={{testid: testId}}
|
|
79
|
+
margin="lg"
|
|
80
|
+
options={chartOptions}
|
|
81
|
+
/>
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
expect(screen.getByTestId(testId)).toHaveClass('m_lg')
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
test('kit to apply id', () => {
|
|
88
|
+
render(
|
|
89
|
+
<PbCircleChart
|
|
90
|
+
data={{testid: testId}}
|
|
91
|
+
id='circle-chart-id'
|
|
92
|
+
options={chartOptions}
|
|
93
|
+
/>
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
expect(screen.getByTestId(testId)).toHaveAttribute('id', 'circle-chart-id')
|
|
97
|
+
})
|
|
98
|
+
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { useMemo } from 'react'
|
|
3
|
+
import classnames from 'classnames'
|
|
4
|
+
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
|
|
5
|
+
import Highcharts from "highcharts"
|
|
6
|
+
import HighchartsReact from "highcharts-react-official"
|
|
7
|
+
import pbGaugeGraphTheme from './pbGaugeGraphTheme'
|
|
8
|
+
import highchartsMore from "highcharts/highcharts-more";
|
|
9
|
+
import solidGauge from "highcharts/modules/solid-gauge";
|
|
10
|
+
import { globalProps } from '../utilities/globalProps'
|
|
11
|
+
|
|
12
|
+
type PbGaugeChartProps = {
|
|
13
|
+
aria?: { [key: string]: string },
|
|
14
|
+
className?: string,
|
|
15
|
+
data?: { [key: string]: string },
|
|
16
|
+
htmlOptions?: { [key: string]: string | number | boolean | (() => void) | ((arg?: Event) => void) },
|
|
17
|
+
id?: string,
|
|
18
|
+
ref?: React.RefObject<any>,
|
|
19
|
+
options: Record<string, unknown>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const PbGaugeChart = (props: PbGaugeChartProps) => {
|
|
23
|
+
const {
|
|
24
|
+
aria = {},
|
|
25
|
+
className,
|
|
26
|
+
data = {},
|
|
27
|
+
htmlOptions = {},
|
|
28
|
+
id,
|
|
29
|
+
ref,
|
|
30
|
+
options = {},
|
|
31
|
+
} = props
|
|
32
|
+
|
|
33
|
+
const ariaProps = buildAriaProps(aria)
|
|
34
|
+
const dataProps = buildDataProps(data)
|
|
35
|
+
const htmlProps = buildHtmlProps(htmlOptions)
|
|
36
|
+
const classes = classnames(buildCss('pb_pb_gauge_chart'), globalProps(props), className)
|
|
37
|
+
|
|
38
|
+
const mergedOptions = useMemo(() => {
|
|
39
|
+
if (!options || typeof options !== "object") {
|
|
40
|
+
// eslint-disable-next-line no-console
|
|
41
|
+
console.error("❌ Invalid options passed to <PbLineGraph />", options)
|
|
42
|
+
return {}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return Highcharts.merge({}, pbGaugeGraphTheme, options)
|
|
46
|
+
}, [options])
|
|
47
|
+
|
|
48
|
+
highchartsMore(Highcharts);
|
|
49
|
+
solidGauge(Highcharts);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div>
|
|
53
|
+
<HighchartsReact
|
|
54
|
+
containerProps={{
|
|
55
|
+
className: classnames(classes),
|
|
56
|
+
id: id,
|
|
57
|
+
ref: ref,
|
|
58
|
+
...ariaProps,
|
|
59
|
+
...dataProps,
|
|
60
|
+
...htmlProps
|
|
61
|
+
}}
|
|
62
|
+
highcharts={Highcharts}
|
|
63
|
+
options={mergedOptions}
|
|
64
|
+
/>
|
|
65
|
+
</div>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default PbGaugeChart
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
This kit is a wrapper around the Highcharts library. It applies styling and default settings but does NOT ship Highcharts. In order to use this kit, 'highcharts' and 'highcharts-react-official' must be installed in your repo. Once done, any prop or functionality provided by Highcharts can be used with this kit without requiring specific props from Playbook. The doc examples below showcase a few common usecases but are not a comprehensive list of all the functionalities possible.
|
|
2
|
+
|
|
3
|
+
See the [highcharts API docs](https://api.highcharts.com/highcharts/) for a comprehensive look at what is possible.
|