playbook_ui 14.23.0 → 14.24.0.pre.alpha.PLAY2116datepickercursorfix9610
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 +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +7 -6
- data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +4 -1
- data/app/pb_kits/playbook/pb_advanced_table/Components/SortIconButton.tsx +24 -25
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +10 -10
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +11 -13
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +7 -4
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +112 -2
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +13 -7
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +14 -2
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +90 -0
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table_action_bar.js +16 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_vertical_border.html.erb +43 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_vertical_border.jsx +64 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control.jsx +60 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_per_row.jsx +57 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_per_row.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling.html.erb +46 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling_rails.md +7 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header_rails.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_per_column.jsx +55 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_per_column.md +6 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_per_column_for_multi_column.jsx +80 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_per_column_for_multi_column.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header.jsx +107 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_rails.html.erb +51 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_rails.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +9 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +6 -0
- data/app/pb_kits/playbook/pb_advanced_table/flat_advanced_table.js +4 -11
- data/app/pb_kits/playbook/pb_advanced_table/index.js +108 -125
- data/app/pb_kits/playbook/pb_advanced_table/scss_partials/advanced_table_sticky_mixin.scss +7 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +7 -4
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +5 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +46 -4
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +13 -4
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +24 -5
- data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.rb +1 -1
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.md +1 -1
- data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +12 -1
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.html.erb +1 -1
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate_rails.md +2 -1
- data/app/pb_kits/playbook/pb_checkbox/index.js +218 -26
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.md +1 -1
- data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.html.erb +10 -1
- data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.rb +2 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_input_options.html.erb +24 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_input_options.md +3 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_date/_date.tsx +5 -3
- data/app/pb_kits/playbook/pb_date/date.html.erb +6 -6
- data/app/pb_kits/playbook/pb_date/date.rb +2 -0
- data/app/pb_kits/playbook/pb_date/docs/_date_with_show_current_year.html.erb +4 -0
- data/app/pb_kits/playbook/pb_date/docs/_date_with_show_current_year.jsx +17 -0
- data/app/pb_kits/playbook/pb_date/docs/_date_with_show_current_year.md +1 -0
- data/app/pb_kits/playbook/pb_date/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_date/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +19 -0
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +1 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default.html.erb +1 -1
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default.jsx +1 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +17 -1
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +6 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown_mixin.scss +36 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_active_style_options.jsx +90 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_active_style_options_react.md +4 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_radio_options.jsx +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_radio_options_react.md +1 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +3 -2
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +24 -0
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +11 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx +2 -2
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_no_icon.html.erb +22 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_no_icon.jsx +43 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_no_icon.md +1 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.html.erb +2 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.rb +1 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.test.js +6 -0
- data/app/pb_kits/playbook/pb_gauge/docs/_description.md +1 -0
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_colors.jsx +32 -15
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_colors_react.md +2 -0
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_complex.jsx +35 -9
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_complex_react.md +1 -0
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_default.jsx +26 -14
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_disable_animation.jsx +32 -15
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_full_circle.jsx +45 -17
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_height.jsx +59 -22
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_live_data.jsx +40 -9
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_min_max.jsx +50 -18
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_sizing.jsx +31 -18
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_title.jsx +34 -17
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_units.jsx +64 -23
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_units_react.md +1 -0
- data/app/pb_kits/playbook/pb_gauge/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_gauge/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_gauge/gaugeTheme.ts +7 -1
- data/app/pb_kits/playbook/pb_line_graph/docs/_description.md +1 -3
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_colors.jsx +36 -17
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_colors_react.md +3 -0
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_default.jsx +31 -16
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_height.jsx +63 -31
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_height.md +3 -0
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend.jsx +35 -16
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_nonclickable.jsx +41 -16
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.jsx +107 -62
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.md +4 -7
- data/app/pb_kits/playbook/pb_line_graph/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_line_graph/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_line_graph/lineGraphTheme.ts +16 -1
- data/app/pb_kits/playbook/pb_multi_level_select/_helper_functions.tsx +18 -9
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +3 -1
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.html.erb +75 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.jsx +94 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.md +3 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -1
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +3 -0
- data/app/pb_kits/playbook/pb_pagination/_pagination.test.jsx +212 -0
- data/app/pb_kits/playbook/pb_pagination/_pagination.tsx +12 -1
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_default_rails.md +3 -1
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_default_react.md +3 -1
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_external_control.jsx +112 -0
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_external_control_react.md +3 -0
- data/app/pb_kits/playbook/pb_pagination/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_pagination/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +14 -1
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_strict_mode.html.erb +10 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_strict_mode.jsx +26 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_strict_mode.md +3 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +3 -0
- data/app/pb_kits/playbook/pb_select/select.rb +4 -2
- data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.html.erb +1 -0
- data/app/pb_kits/playbook/pb_table/styles/_vertical_border.scss +49 -1
- data/app/pb_kits/playbook/pb_text_input/text_input.rb +15 -0
- data/dist/chunks/_line_graph-Bs1q77QJ.js +1 -0
- data/dist/chunks/_typeahead-DDDKDPZS.js +6 -0
- data/dist/chunks/_weekday_stacked-DkFv7FEh.js +37 -0
- data/dist/chunks/lib-CY5ZPzic.js +29 -0
- data/dist/chunks/{pb_form_validation-B7kuYG-_.js → pb_form_validation-D3b0JKHH.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +4 -11
- 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/version.rb +2 -2
- metadata +53 -26
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_pb_styles.jsx +0 -30
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_pb_styles.md +0 -1
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_pb_styles.jsx +0 -52
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_pb_styles.md +0 -1
- data/app/pb_kits/playbook/pb_walkthrough/_walkthrough.scss +0 -0
- data/app/pb_kits/playbook/pb_walkthrough/_walkthrough.tsx +0 -202
- data/app/pb_kits/playbook/pb_walkthrough/docs/_walkthrough_continuous.jsx +0 -69
- data/app/pb_kits/playbook/pb_walkthrough/docs/_walkthrough_default.jsx +0 -71
- data/app/pb_kits/playbook/pb_walkthrough/docs/_walkthrough_multi_beacon.jsx +0 -110
- data/app/pb_kits/playbook/pb_walkthrough/docs/_walkthrough_no_beacon.jsx +0 -76
- data/app/pb_kits/playbook/pb_walkthrough/docs/_walkthrough_no_overlay.jsx +0 -76
- data/app/pb_kits/playbook/pb_walkthrough/docs/_walkthrough_styled.jsx +0 -76
- data/app/pb_kits/playbook/pb_walkthrough/docs/example.yml +0 -10
- data/app/pb_kits/playbook/pb_walkthrough/docs/index.js +0 -6
- data/app/pb_kits/playbook/pb_walkthrough/walkthrough.test.jsx +0 -34
- data/dist/chunks/_circle_chart-D01WLw-z.js +0 -1
- data/dist/chunks/_typeahead-mrBE9f17.js +0 -22
- data/dist/chunks/_weekday_stacked-_LSSbN1y.js +0 -45
- data/dist/chunks/lib-CHh_1-Oj.js +0 -29
- /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_row_styling.md → _advanced_table_row_styling_react.md} +0 -0
- /data/app/pb_kits/playbook/pb_gauge/docs/{_gauge_colors.md → _gauge_colors_rails.md} +0 -0
- /data/app/pb_kits/playbook/pb_gauge/docs/{_gauge_complex.md → _gauge_complex_rails.md} +0 -0
- /data/app/pb_kits/playbook/pb_line_graph/docs/{_line_graph_colors.md → _line_graph_colors_rails.md} +0 -0
@@ -3,6 +3,8 @@
|
|
3
3
|
module Playbook
|
4
4
|
module PbAdvancedTable
|
5
5
|
class TableHeader < Playbook::KitBase
|
6
|
+
prop :id, type: Playbook::Props::String,
|
7
|
+
default: ""
|
6
8
|
prop :column_definitions, type: Playbook::Props::Array,
|
7
9
|
default: []
|
8
10
|
prop :enable_toggle_expansion, type: Playbook::Props::Enum,
|
@@ -56,8 +58,10 @@ module Playbook
|
|
56
58
|
classname: additional_classes.join(" "),
|
57
59
|
}) do
|
58
60
|
pb_rails("checkbox", props: {
|
59
|
-
id: "select-all-rows",
|
60
|
-
|
61
|
+
id: "#{id ? "#{id}-" : ''}select-all-rows",
|
62
|
+
indeterminate_main: true,
|
63
|
+
indeterminate_main_labels: ["", ""],
|
64
|
+
name: "#{id ? "#{id}-" : ''}select-all-rows",
|
61
65
|
})
|
62
66
|
end
|
63
67
|
end
|
@@ -67,8 +71,10 @@ module Playbook
|
|
67
71
|
def render_select_all_checkbox
|
68
72
|
if selectable_rows
|
69
73
|
pb_rails("checkbox", props: {
|
70
|
-
id: "select-all-rows",
|
71
|
-
|
74
|
+
id: "#{id ? "#{id}-" : ''}select-all-rows",
|
75
|
+
indeterminate_main: true,
|
76
|
+
indeterminate_main_labels: ["", ""],
|
77
|
+
name: "#{id ? "#{id}-" : ''}select-all-rows",
|
72
78
|
data: {
|
73
79
|
action: "click->pb-advanced-table#toggleAllRowSelection",
|
74
80
|
},
|
@@ -76,6 +82,30 @@ module Playbook
|
|
76
82
|
end
|
77
83
|
end
|
78
84
|
|
85
|
+
# Get original column definition for custom rendering
|
86
|
+
def find_original_column_def(accessor)
|
87
|
+
find_column_def_by_accessor(column_definitions, accessor)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Check if a header cell has a custom renderer
|
91
|
+
def has_header_renderer?(cell)
|
92
|
+
return false unless cell[:accessor].present?
|
93
|
+
|
94
|
+
original_def = find_original_column_def(cell[:accessor])
|
95
|
+
original_def && original_def[:header].present?
|
96
|
+
end
|
97
|
+
|
98
|
+
# Render custom header content
|
99
|
+
def render_header(cell)
|
100
|
+
return cell[:label] unless has_header_renderer?(cell)
|
101
|
+
|
102
|
+
original_def = find_original_column_def(cell[:accessor])
|
103
|
+
custom_renderer = original_def[:header]
|
104
|
+
|
105
|
+
# Call the custom renderer with the cell data and label
|
106
|
+
custom_renderer.call(cell, cell[:label])
|
107
|
+
end
|
108
|
+
|
79
109
|
private
|
80
110
|
|
81
111
|
def compute_max_depth(columns)
|
@@ -148,6 +178,18 @@ module Playbook
|
|
148
178
|
end
|
149
179
|
wrapped
|
150
180
|
end
|
181
|
+
|
182
|
+
def find_column_def_by_accessor(defs, target_accessor)
|
183
|
+
defs.each do |col|
|
184
|
+
return col if col[:accessor] == target_accessor
|
185
|
+
|
186
|
+
if col[:columns].is_a?(Array)
|
187
|
+
found = find_column_def_by_accessor(col[:columns], target_accessor)
|
188
|
+
return found if found
|
189
|
+
end
|
190
|
+
end
|
191
|
+
nil
|
192
|
+
end
|
151
193
|
end
|
152
194
|
end
|
153
195
|
end
|
@@ -1,3 +1,10 @@
|
|
1
|
+
<%
|
2
|
+
row_style = object.row_styling.find { |style| style[:row_id].to_s == object.row_id.to_s }
|
3
|
+
button_color = row_style&.[](:expand_button_color)
|
4
|
+
bg_color = row_style&.[](:background_color)
|
5
|
+
font_color = row_style&.[](:font_color)
|
6
|
+
%>
|
7
|
+
|
1
8
|
<%= pb_content_tag(:tr) do %>
|
2
9
|
<% has_separate_checkbox = object.selectable_rows && object.enable_toggle_expansion == "none" %>
|
3
10
|
<% if has_separate_checkbox %>
|
@@ -5,7 +12,7 @@
|
|
5
12
|
<% end %>
|
6
13
|
<% object.column_definitions.each_with_index do |column, index| %>
|
7
14
|
<% next unless column[:accessor].present? %>
|
8
|
-
<%= pb_rails("table/table_cell", props: { classname:object.td_classname(column, index)}) do %>
|
15
|
+
<%= pb_rails("table/table_cell", props: { html_options: { style: { "background-color": bg_color, color: font_color } }, classname:object.td_classname(column, index)}) do %>
|
9
16
|
<%= pb_rails("flex", props:{ align: "center", justify: object.justify_for(column, index), classname: object.loading ? "loading-cell" : "" }) do %>
|
10
17
|
<% if collapsible_trail && index.zero? %>
|
11
18
|
<% (1..depth).each do |i| %>
|
@@ -28,13 +35,15 @@
|
|
28
35
|
<button
|
29
36
|
id="<%= "#{object.id}_#{object.row.object_id}" %>"
|
30
37
|
class="gray-icon expand-toggle-icon"
|
31
|
-
data-advanced-table="true"
|
38
|
+
data-advanced-table="true"
|
39
|
+
style="color: <%= button_color %>"
|
40
|
+
>
|
32
41
|
<%= pb_rails("icon", props: { id: "advanced-table_open_icon", icon: "circle-play", cursor: "pointer" }) %>
|
33
|
-
<%= pb_rails("icon", props: { id: "advanced-table_close_icon", icon: "circle-play
|
42
|
+
<%= pb_rails("icon", props: { id: "advanced-table_close_icon", icon: "circle-play", cursor: "pointer", rotation: 90 }) %>
|
34
43
|
</button>
|
35
44
|
<% end %>
|
36
45
|
<% end %>
|
37
|
-
<%= pb_rails("flex/flex_item") do %>
|
46
|
+
<%= pb_rails("flex/flex_item") do %>
|
38
47
|
<% if column[:custom_renderer].present? %>
|
39
48
|
<%= raw(column[:custom_renderer].call(object.row, custom_renderer_value(column, index))) %>
|
40
49
|
<% elsif index.zero? %>
|
@@ -27,6 +27,12 @@ module Playbook
|
|
27
27
|
prop :enable_toggle_expansion, type: Playbook::Props::Enum,
|
28
28
|
values: %w[all header none],
|
29
29
|
default: "header"
|
30
|
+
prop :row_styling, type: Playbook::Props::Array,
|
31
|
+
default: []
|
32
|
+
prop :last_row, type: Playbook::Props::Boolean,
|
33
|
+
default: false
|
34
|
+
prop :immediate_parent_row_id, type: Playbook::Props::String,
|
35
|
+
default: ""
|
30
36
|
|
31
37
|
def data
|
32
38
|
Hash(prop(:data)).merge(table_data_attributes)
|
@@ -37,7 +43,7 @@ module Playbook
|
|
37
43
|
end
|
38
44
|
|
39
45
|
def td_classname(column, index)
|
40
|
-
classes = %w[id-cell
|
46
|
+
classes = %w[id-cell]
|
41
47
|
classes << "last-cell" if column[:is_last_in_group]
|
42
48
|
classes << "pinned-left" if index.zero? && is_pinned_left && responsive == "scroll"
|
43
49
|
classes.join(" ")
|
@@ -52,12 +58,14 @@ module Playbook
|
|
52
58
|
# Selectable Rows No Subrows - checkboxes in their own first cell
|
53
59
|
def render_checkbox_cell
|
54
60
|
if selectable_rows
|
61
|
+
prefix = id ? "#{id}-" : ""
|
55
62
|
pb_rails("table/table_cell", props: {
|
56
63
|
classname: "checkbox-cell",
|
57
64
|
}) do
|
58
65
|
pb_rails("checkbox", props: {
|
59
|
-
id: "select-row-#{row_id || row.object_id}",
|
60
|
-
|
66
|
+
id: "#{prefix}select-row-#{row_id || row.object_id}",
|
67
|
+
indeterminate_parent: "#{id ? "#{id}-" : ''}select-all-rows",
|
68
|
+
name: "#{prefix}select-row-#{row_id || row.object_id}",
|
61
69
|
data: {
|
62
70
|
row_id: row_id || row.object_id.to_s,
|
63
71
|
flat_advanced_table_select: true,
|
@@ -70,9 +78,20 @@ module Playbook
|
|
70
78
|
# Selectable Rows w/ Subrows - checkboxes part of toggleable first cell
|
71
79
|
def render_row_checkbox
|
72
80
|
if selectable_rows
|
81
|
+
prefix = id ? "#{id}-" : ""
|
82
|
+
indeterminate_parent =
|
83
|
+
if depth.zero?
|
84
|
+
"#{prefix}select-all-rows"
|
85
|
+
else
|
86
|
+
"#{prefix}select-row-#{immediate_parent_row_id}"
|
87
|
+
end
|
88
|
+
|
73
89
|
pb_rails("checkbox", props: {
|
74
|
-
id: "select-row-#{row_id || row.object_id}",
|
75
|
-
|
90
|
+
id: "#{prefix}select-row-#{row_id || row.object_id}",
|
91
|
+
indeterminate_main: !last_row,
|
92
|
+
indeterminate_main_labels: ["", ""],
|
93
|
+
indeterminate_parent: indeterminate_parent,
|
94
|
+
name: "#{prefix}select-row-#{row_id || row.object_id}",
|
76
95
|
data: {
|
77
96
|
row_id: row_id || row.object_id.to_s,
|
78
97
|
},
|
@@ -1,7 +1,7 @@
|
|
1
1
|
##### Prop
|
2
2
|
|
3
3
|
`align` **Type**: String | **Values**: left | center | right (defaults to center)
|
4
|
-
`verticalAlign` **Type**: String | **Values**: top | middle | bottom (defaults
|
4
|
+
`verticalAlign` **Type**: String | **Values**: top | middle | bottom (defaults to bottom)
|
5
5
|
`layout` **Type**: String | **Values**: horizontal | vertical | proximate (defaults to horizontal)
|
6
6
|
`x` **Type**: Number (defaults to 0)
|
7
7
|
`y` **Type**: Number (defaults to 0)
|
@@ -6,6 +6,8 @@ module Playbook
|
|
6
6
|
prop :error, type: Playbook::Props::Boolean, default: false
|
7
7
|
prop :checked, type: Playbook::Props::Boolean, default: false
|
8
8
|
prop :indeterminate_main, type: Playbook::Props::Boolean, default: false
|
9
|
+
prop :indeterminate_main_labels, type: Playbook::Props::Array,
|
10
|
+
default: []
|
9
11
|
prop :indeterminate_parent
|
10
12
|
prop :text
|
11
13
|
prop :value
|
@@ -49,10 +51,19 @@ module Playbook
|
|
49
51
|
end
|
50
52
|
|
51
53
|
def data
|
52
|
-
Hash(prop(:data)).merge(
|
54
|
+
base_data = Hash(prop(:data)).merge(
|
53
55
|
pb_checkbox_indeterminate_main: indeterminate_main,
|
54
56
|
pb_checkbox_indeterminate_parent: indeterminate_parent
|
55
57
|
)
|
58
|
+
|
59
|
+
if indeterminate_main && indeterminate_main_labels.size == 2
|
60
|
+
base_data.merge!(
|
61
|
+
pb_checkbox_indeterminate_main_label_check: indeterminate_main_labels[0],
|
62
|
+
pb_checkbox_indeterminate_main_label_uncheck: indeterminate_main_labels[1]
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
base_data
|
56
67
|
end
|
57
68
|
|
58
69
|
private
|
@@ -9,10 +9,10 @@
|
|
9
9
|
<tr>
|
10
10
|
<th>
|
11
11
|
<%= pb_rails("checkbox", props: {
|
12
|
-
text: "Uncheck All",
|
13
12
|
value: "checkbox-value",
|
14
13
|
name: "main-checkbox",
|
15
14
|
indeterminate_main: true,
|
15
|
+
indeterminate_main_labels: ["Check All Ice Cream", "Uncheck All Ice Cream"],
|
16
16
|
id: "indeterminate-checkbox"
|
17
17
|
}) %>
|
18
18
|
</th>
|
@@ -1 +1,2 @@
|
|
1
|
-
If you want to use indeterminate, "check/uncheck all" checkboxes, add `indeterminate_main: true` and an `id` to the main checkbox. Then, add an `indeterminate_parent` prop with the main checkbox's `id` to the children checkboxes.
|
1
|
+
If you want to use indeterminate, "check/uncheck all" checkboxes, add `indeterminate_main: true` and an `id` to the main checkbox. Then, add an `indeterminate_parent` prop with the main checkbox's `id` to the children checkboxes.
|
2
|
+
If you want to customize the main checkbox labels, set an array `indeterminate_main_labels` with "Check All" and "Uncheck All" labels.
|
@@ -10,47 +10,239 @@ export default class PbCheckbox extends PbEnhancedElement {
|
|
10
10
|
connect() {
|
11
11
|
const mainCheckboxWrapper = this.element;
|
12
12
|
const mainCheckbox = mainCheckboxWrapper.querySelector('input')
|
13
|
-
const
|
13
|
+
const directChildCheckboxes = document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${this.element.id}"] input[type="checkbox"]`);
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
const
|
18
|
-
|
19
|
-
|
15
|
+
// Helper function to get all descendant checkboxes
|
16
|
+
const getAllDescendantCheckboxes = () => {
|
17
|
+
const descendants = [];
|
18
|
+
const queue = [...directChildCheckboxes];
|
19
|
+
|
20
|
+
// Breadth-first search to find all nested descendants
|
21
|
+
while (queue.length > 0) {
|
22
|
+
const checkbox = queue.shift();
|
23
|
+
descendants.push(checkbox);
|
24
|
+
|
25
|
+
// Find children of this checkbox
|
26
|
+
const checkboxWrapper = checkbox.closest('[data-pb-checkbox-indeterminate-main="true"]');
|
27
|
+
if (checkboxWrapper) {
|
28
|
+
const childCheckboxes = document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${checkboxWrapper.id}"] input[type="checkbox"]`);
|
29
|
+
queue.push(...childCheckboxes);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
// Also include any non-"main" checkboxes that have this as a parent
|
34
|
+
const nonMainChildCheckboxes = document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${this.element.id}"] input[type="checkbox"]`);
|
35
|
+
nonMainChildCheckboxes.forEach(cb => {
|
36
|
+
if (!descendants.includes(cb)) {
|
37
|
+
descendants.push(cb);
|
38
|
+
}
|
39
|
+
});
|
40
|
+
|
41
|
+
return descendants;
|
42
|
+
};
|
43
|
+
|
44
|
+
// Helper function to determine checkbox state
|
45
|
+
const getCheckboxState = (checkboxes) => {
|
46
|
+
const checkedCount = checkboxes.filter(cb => cb.checked).length;
|
47
|
+
const totalCount = checkboxes.length;
|
20
48
|
|
21
|
-
|
22
|
-
|
23
|
-
|
49
|
+
return {
|
50
|
+
allChecked: checkedCount === totalCount,
|
51
|
+
noneChecked: checkedCount === 0,
|
52
|
+
indeterminate: !(checkedCount === totalCount || checkedCount === 0),
|
53
|
+
checkedCount,
|
54
|
+
totalCount
|
55
|
+
};
|
56
|
+
};
|
24
57
|
|
25
|
-
|
26
|
-
|
58
|
+
// Helper function to update checkbox visual state
|
59
|
+
const updateCheckboxVisualState = (checkbox, isIndeterminate, isChecked) => {
|
60
|
+
checkbox.indeterminate = isIndeterminate;
|
61
|
+
checkbox.checked = isChecked;
|
62
|
+
};
|
27
63
|
|
28
|
-
|
29
|
-
|
30
|
-
const
|
64
|
+
// Helper function to update checkbox label and icons
|
65
|
+
const updateCheckboxLabelAndIcons = (wrapper, isIndeterminate, checkedCount) => {
|
66
|
+
const checkAllLabel = wrapper.dataset.pbCheckboxIndeterminateMainLabelCheck ?? 'Check All';
|
67
|
+
const uncheckAllLabel = wrapper.dataset.pbCheckboxIndeterminateMainLabelUncheck ?? 'Uncheck All';
|
68
|
+
const text = checkedCount === 0 ? checkAllLabel : uncheckAllLabel;
|
31
69
|
|
32
|
-
// Update
|
33
|
-
|
70
|
+
// Update label
|
71
|
+
const bodyKitElement = wrapper.getElementsByClassName('pb_body_kit')[0];
|
72
|
+
if (bodyKitElement) {
|
73
|
+
bodyKitElement.textContent = text;
|
74
|
+
}
|
34
75
|
|
35
|
-
//
|
36
|
-
|
37
|
-
|
76
|
+
// Update icons
|
77
|
+
const iconSpan = wrapper.querySelector('[data-pb-checkbox-icon-span]');
|
78
|
+
if (iconSpan) {
|
79
|
+
const iconClassToAdd = isIndeterminate ? 'pb_checkbox_indeterminate' : 'pb_checkbox_checkmark';
|
80
|
+
const iconClassToRemove = isIndeterminate ? 'pb_checkbox_checkmark' : 'pb_checkbox_indeterminate';
|
81
|
+
iconSpan.classList.add(iconClassToAdd);
|
82
|
+
iconSpan.classList.remove(iconClassToRemove);
|
83
|
+
}
|
38
84
|
|
39
|
-
// Toggle
|
40
|
-
|
41
|
-
|
85
|
+
// Toggle icon visibility
|
86
|
+
const indeterminateIcon = wrapper.getElementsByClassName("indeterminate_icon")[0];
|
87
|
+
const checkIcon = wrapper.getElementsByClassName("check_icon")[0];
|
88
|
+
|
89
|
+
if (indeterminateIcon) {
|
90
|
+
indeterminateIcon.classList.toggle('hidden', !isIndeterminate);
|
91
|
+
}
|
92
|
+
if (checkIcon) {
|
93
|
+
checkIcon.classList.toggle('hidden', isIndeterminate);
|
94
|
+
}
|
95
|
+
};
|
96
|
+
|
97
|
+
// Main function to update this checkbox's state
|
98
|
+
const updateMainCheckbox = () => {
|
99
|
+
const allDescendantCheckboxes = getAllDescendantCheckboxes();
|
100
|
+
const state = getCheckboxState(allDescendantCheckboxes);
|
101
|
+
|
102
|
+
updateCheckboxVisualState(mainCheckbox, state.indeterminate, state.allChecked);
|
103
|
+
updateCheckboxLabelAndIcons(mainCheckboxWrapper, state.indeterminate, state.checkedCount);
|
104
|
+
};
|
105
|
+
|
106
|
+
// Function to update parent checkboxes recursively
|
107
|
+
const updateParentCheckboxes = () => {
|
108
|
+
const parentId = mainCheckboxWrapper.dataset.pbCheckboxIndeterminateParent;
|
109
|
+
if (parentId) {
|
110
|
+
const parentCheckbox = document.getElementById(parentId);
|
111
|
+
if (parentCheckbox) {
|
112
|
+
const parentWrapper = parentCheckbox.closest('[data-pb-checkbox-indeterminate-main="true"]');
|
113
|
+
if (parentWrapper) {
|
114
|
+
const parentInstance = parentWrapper.pbCheckboxInstance;
|
115
|
+
if (parentInstance && parentInstance.updateMainCheckbox) {
|
116
|
+
parentInstance.updateMainCheckbox();
|
117
|
+
parentInstance.updateParentCheckboxes();
|
118
|
+
}
|
119
|
+
}
|
120
|
+
}
|
121
|
+
}
|
42
122
|
};
|
43
123
|
|
44
|
-
//
|
124
|
+
// Function to update non-main checkboxes when their children change
|
125
|
+
const setupNonMainCheckboxUpdates = () => {
|
126
|
+
const allCheckboxesWithChildren = document.querySelectorAll('input[type="checkbox"]');
|
127
|
+
allCheckboxesWithChildren.forEach(cb => {
|
128
|
+
const checkboxWrapper = cb.closest('[data-pb-checkbox-indeterminate-main="true"]');
|
129
|
+
if (checkboxWrapper && checkboxWrapper !== mainCheckboxWrapper) {
|
130
|
+
return; // Skip different "main" checkboxes
|
131
|
+
}
|
132
|
+
|
133
|
+
const childCheckboxes = document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${cb.id}"] input[type="checkbox"]`);
|
134
|
+
if (childCheckboxes.length > 0) {
|
135
|
+
childCheckboxes.forEach(childCb => {
|
136
|
+
childCb.addEventListener('change', () => {
|
137
|
+
const state = getCheckboxState(Array.from(childCheckboxes));
|
138
|
+
updateCheckboxVisualState(cb, state.indeterminate, state.allChecked);
|
139
|
+
|
140
|
+
// Trigger updates on all main checkboxes that might be affected
|
141
|
+
const mainCheckboxes = document.querySelectorAll('[data-pb-checkbox-indeterminate-main="true"]');
|
142
|
+
mainCheckboxes.forEach(mainCb => {
|
143
|
+
const mainInstance = mainCb.pbCheckboxInstance;
|
144
|
+
if (mainInstance && mainInstance.updateMainCheckbox) {
|
145
|
+
setTimeout(() => {
|
146
|
+
mainInstance.updateMainCheckbox();
|
147
|
+
}, 0);
|
148
|
+
}
|
149
|
+
});
|
150
|
+
});
|
151
|
+
});
|
152
|
+
}
|
153
|
+
});
|
154
|
+
};
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
// Initialize checkbox state
|
45
159
|
updateMainCheckbox();
|
46
160
|
|
47
|
-
|
48
|
-
|
161
|
+
// Handle main checkbox change - propagate to all descendants
|
162
|
+
mainCheckbox.addEventListener('change', function() {
|
163
|
+
const allDescendantCheckboxes = getAllDescendantCheckboxes();
|
164
|
+
const state = getCheckboxState(allDescendantCheckboxes);
|
165
|
+
|
166
|
+
if (state.indeterminate) {
|
167
|
+
// If indeterminate, uncheck all descendants and the parent
|
168
|
+
allDescendantCheckboxes.forEach(cb => {
|
169
|
+
cb.checked = false;
|
170
|
+
// Dispatch custom event for programmatic changes- change styles in advanced table
|
171
|
+
cb.dispatchEvent(new Event('checkbox-programmatic-change', { bubbles: true }));
|
172
|
+
});
|
173
|
+
this.checked = false;
|
174
|
+
} else {
|
175
|
+
// Otherwise, set all descendants to the same state as this checkbox
|
176
|
+
allDescendantCheckboxes.forEach(cb => {
|
177
|
+
cb.checked = this.checked;
|
178
|
+
// Dispatch custom event for programmatic changes- change styles in advanced table
|
179
|
+
cb.dispatchEvent(new Event('checkbox-programmatic-change', { bubbles: true }));
|
180
|
+
});
|
181
|
+
}
|
182
|
+
|
183
|
+
// Update this checkbox first, then parents after a delay
|
49
184
|
updateMainCheckbox();
|
185
|
+
setTimeout(() => {
|
186
|
+
updateParentCheckboxes();
|
187
|
+
}, 0);
|
188
|
+
|
189
|
+
// Also trigger updates on all main checkboxes to ensure proper state propagation
|
190
|
+
triggerAllMainCheckboxUpdates();
|
50
191
|
});
|
51
192
|
|
52
|
-
|
193
|
+
// Handle child checkbox changes
|
194
|
+
directChildCheckboxes.forEach(cb => {
|
53
195
|
cb.addEventListener('change', updateMainCheckbox);
|
54
196
|
});
|
197
|
+
|
198
|
+
// Handle deeper descendant changes
|
199
|
+
const allDescendantCheckboxes = getAllDescendantCheckboxes();
|
200
|
+
allDescendantCheckboxes.forEach(cb => {
|
201
|
+
if (!Array.from(directChildCheckboxes).includes(cb)) {
|
202
|
+
cb.addEventListener('change', updateMainCheckbox);
|
203
|
+
}
|
204
|
+
});
|
205
|
+
|
206
|
+
// Handle non-main child checkboxes
|
207
|
+
const allChildCheckboxes = document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${this.element.id}"] input[type="checkbox"]`);
|
208
|
+
allChildCheckboxes.forEach(cb => {
|
209
|
+
if (!allDescendantCheckboxes.includes(cb)) {
|
210
|
+
cb.addEventListener('change', updateMainCheckbox);
|
211
|
+
}
|
212
|
+
});
|
213
|
+
|
214
|
+
// Also trigger updates on all main checkboxes when any checkbox changes
|
215
|
+
let updateTimeout = null;
|
216
|
+
const triggerAllMainCheckboxUpdates = () => {
|
217
|
+
// Debounce the updates to prevent excessive calls
|
218
|
+
if (updateTimeout) {
|
219
|
+
clearTimeout(updateTimeout);
|
220
|
+
}
|
221
|
+
updateTimeout = setTimeout(() => {
|
222
|
+
const mainCheckboxes = document.querySelectorAll('[data-pb-checkbox-indeterminate-main="true"]');
|
223
|
+
mainCheckboxes.forEach(mainCb => {
|
224
|
+
const mainInstance = mainCb.pbCheckboxInstance;
|
225
|
+
if (mainInstance && mainInstance.updateMainCheckbox) {
|
226
|
+
mainInstance.updateMainCheckbox();
|
227
|
+
}
|
228
|
+
});
|
229
|
+
}, 10); // Small delay to batch updates
|
230
|
+
};
|
231
|
+
|
232
|
+
// Store the original updateMainCheckbox function and create a new one that also triggers updates
|
233
|
+
const originalUpdateMainCheckbox = updateMainCheckbox;
|
234
|
+
const enhancedUpdateMainCheckbox = () => {
|
235
|
+
originalUpdateMainCheckbox();
|
236
|
+
triggerAllMainCheckboxUpdates();
|
237
|
+
};
|
238
|
+
|
239
|
+
// Replace the updateMainCheckbox function
|
240
|
+
mainCheckboxWrapper.pbCheckboxInstance = {
|
241
|
+
updateMainCheckbox: enhancedUpdateMainCheckbox,
|
242
|
+
updateParentCheckboxes
|
243
|
+
};
|
244
|
+
|
245
|
+
// Setup updates for non-main checkboxes with children
|
246
|
+
setupNonMainCheckboxUpdates();
|
55
247
|
}
|
56
248
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
##### Prop
|
2
2
|
|
3
3
|
`align` **Type**: String | **Values**: left | center | right (defaults to center)
|
4
|
-
`verticalAlign` **Type**: String | **Values**: top | middle | bottom (defaults
|
4
|
+
`verticalAlign` **Type**: String | **Values**: top | middle | bottom (defaults to bottom)
|
5
5
|
`layout` **Type**: String | **Values**: horizontal | vertical | proximate (defaults to horizontal)
|
6
6
|
`x` **Type**: Number (defaults to 0)
|
7
7
|
`y` **Type**: Number (defaults to 0)
|
@@ -1,5 +1,14 @@
|
|
1
1
|
<%= pb_content_tag do %>
|
2
|
-
<%= pb_rails("button", props: {
|
2
|
+
<%= pb_rails("button", props: {
|
3
|
+
type: object.type,
|
4
|
+
loading: object.loading,
|
5
|
+
link: object.link,
|
6
|
+
new_window: object.new_window,
|
7
|
+
variant: object.variant,
|
8
|
+
target: object.target,
|
9
|
+
disabled: object.disabled,
|
10
|
+
dark: object.dark
|
11
|
+
}.merge(object.input_options)) do %>
|
3
12
|
<%= pb_rails("icon", props: {icon: object.icon, fixed_width: true, dark: object.dark}) %>
|
4
13
|
<% end %>
|
5
14
|
<% end %>
|
@@ -21,6 +21,8 @@ module Playbook
|
|
21
21
|
prop :size, type: Playbook::Props::Enum,
|
22
22
|
values: %w[default sm],
|
23
23
|
default: "default"
|
24
|
+
prop :input_options, type: Playbook::Props::HashProp,
|
25
|
+
default: {}
|
24
26
|
|
25
27
|
def classname
|
26
28
|
generate_classname("pb_circle_icon_button_kit") + size_class
|
data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_input_options.html.erb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
<%= pb_rails("circle_icon_button", props: {
|
2
|
+
icon: "plus",
|
3
|
+
input_options: {
|
4
|
+
data: { "test-id": "add-button", remote: true },
|
5
|
+
}
|
6
|
+
}) %>
|
7
|
+
<br/>
|
8
|
+
<%= pb_rails("circle_icon_button", props: {
|
9
|
+
icon: "pen",
|
10
|
+
variant: "secondary",
|
11
|
+
input_options: {
|
12
|
+
data: { "test-id": "edit-button" },
|
13
|
+
classname: "custom-secondary-button-class"
|
14
|
+
}
|
15
|
+
}) %>
|
16
|
+
<br/>
|
17
|
+
<%= pb_rails("circle_icon_button", props: {
|
18
|
+
icon: "user",
|
19
|
+
variant: "link",
|
20
|
+
input_options: {
|
21
|
+
data: { "test-id": "user-button" },
|
22
|
+
id: "user-button-id"
|
23
|
+
}
|
24
|
+
}) %>
|
@@ -0,0 +1,3 @@
|
|
1
|
+
Use the `input_options` prop to pass additional attributes directly to the internal Playbook Button component. While the wrapper div has access to the standard `data` prop from KitBase, `input_options` allows you to attach attributes specifically to the internal button element.
|
2
|
+
|
3
|
+
This is particularly useful when you need data attributes or other HTML attributes to apply to the button itself.
|
@@ -19,6 +19,7 @@ type PbDateProps = {
|
|
19
19
|
htmlOptions?: { [key: string]: string | number | boolean | (() => void) };
|
20
20
|
id?: string;
|
21
21
|
showDayOfWeek?: boolean;
|
22
|
+
showCurrentYear?: boolean;
|
22
23
|
showIcon?: boolean;
|
23
24
|
size?: "sm" | "md" | "lg";
|
24
25
|
unstyled?: boolean;
|
@@ -35,6 +36,7 @@ const PbDate = (props: PbDateProps): React.ReactElement => {
|
|
35
36
|
htmlOptions = {},
|
36
37
|
id,
|
37
38
|
showDayOfWeek = false,
|
39
|
+
showCurrentYear = false,
|
38
40
|
showIcon = false,
|
39
41
|
size = "md",
|
40
42
|
unstyled = false,
|
@@ -90,7 +92,7 @@ const PbDate = (props: PbDateProps): React.ReactElement => {
|
|
90
92
|
{month} {day}
|
91
93
|
</span>
|
92
94
|
|
93
|
-
{currentYear
|
95
|
+
{(currentYear !== year || showCurrentYear) && <span>{`, ${year}`}</span>}
|
94
96
|
</span>
|
95
97
|
</>
|
96
98
|
: size == "md" || size == "lg"
|
@@ -124,7 +126,7 @@ const PbDate = (props: PbDateProps): React.ReactElement => {
|
|
124
126
|
<span>
|
125
127
|
{month} {day}
|
126
128
|
</span>
|
127
|
-
{currentYear
|
129
|
+
{(currentYear !== year || showCurrentYear) && <span>{`, ${year}`}</span>}
|
128
130
|
</Title>
|
129
131
|
)
|
130
132
|
: (
|
@@ -158,7 +160,7 @@ const PbDate = (props: PbDateProps): React.ReactElement => {
|
|
158
160
|
<Caption dark={dark}
|
159
161
|
tag="span">
|
160
162
|
{month} {day}
|
161
|
-
{currentYear
|
163
|
+
{(currentYear !== year || showCurrentYear) && <>{`, ${year}`}</>}
|
162
164
|
</Caption>
|
163
165
|
</>
|
164
166
|
)}
|