playbook_ui 14.16.0.pre.rc.6 → 14.17.0.pre.rc.0

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 (113) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +34 -2
  3. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +86 -84
  4. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +2 -2
  5. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +10 -0
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination.jsx +0 -1
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows.html.erb +39 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows.html.erb +33 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows_rails.md +1 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.md +6 -0
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/index.js +1 -1
  13. data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +4 -2
  14. data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +19 -9
  15. data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +38 -1
  16. data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +49 -37
  17. data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +39 -0
  18. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +1 -1
  19. data/app/pb_kits/playbook/pb_button/_button.scss +5 -5
  20. data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.tsx +1 -1
  21. data/app/pb_kits/playbook/pb_draggable/_draggable.scss +115 -5
  22. data/app/pb_kits/playbook/pb_draggable/_draggable.tsx +6 -4
  23. data/app/pb_kits/playbook/pb_draggable/context/index.tsx +35 -9
  24. data/app/pb_kits/playbook/pb_draggable/context/types.ts +35 -28
  25. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones.jsx +184 -0
  26. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones.md +5 -0
  27. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_colors.jsx +97 -0
  28. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_colors.md +1 -0
  29. data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableContainer.tsx +11 -2
  30. data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableItem.tsx +65 -6
  31. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.html.erb +3 -0
  32. data/app/pb_kits/playbook/pb_drawer/docs/example.yml +1 -0
  33. data/app/pb_kits/playbook/pb_filter/Filter/SortMenu.tsx +2 -1
  34. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.scss +2 -2
  35. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +67 -0
  36. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +67 -0
  37. data/app/pb_kits/playbook/pb_gauge/_gauge.tsx +1 -1
  38. data/app/pb_kits/playbook/pb_icon/_icon.scss +8 -1
  39. data/app/pb_kits/playbook/pb_icon/docs/_icon_color.html.erb +10 -4
  40. data/app/pb_kits/playbook/pb_icon/docs/_icon_color.jsx +49 -24
  41. data/app/pb_kits/playbook/pb_icon_button/_icon_button.tsx +4 -1
  42. data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_click.jsx +13 -0
  43. data/app/pb_kits/playbook/pb_icon_button/docs/example.yml +1 -0
  44. data/app/pb_kits/playbook/pb_icon_button/docs/index.js +1 -0
  45. data/app/pb_kits/playbook/pb_lightbox/Carousel/Slide.tsx +1 -1
  46. data/app/pb_kits/playbook/pb_lightbox/Carousel/Slides.tsx +1 -1
  47. data/app/pb_kits/playbook/pb_lightbox/Carousel/Thumbnails.tsx +1 -1
  48. data/app/pb_kits/playbook/pb_line_graph/_line_graph.tsx +1 -1
  49. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +23 -0
  50. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +26 -0
  51. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_error.html.erb +72 -0
  52. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_error.jsx +97 -0
  53. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_label.html.erb +71 -0
  54. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_label.jsx +91 -0
  55. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +4 -0
  56. data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +3 -1
  57. data/app/pb_kits/playbook/pb_multi_level_select/index.js +105 -0
  58. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +10 -0
  59. data/app/pb_kits/playbook/pb_nav/_nav.scss +5 -0
  60. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +29 -11
  61. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default.html.erb +1 -1
  62. data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.html.erb +4 -4
  63. data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.rb +2 -0
  64. data/app/pb_kits/playbook/pb_table/_table.tsx +4 -0
  65. data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless.jsx +50 -0
  66. data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless_react.md +1 -0
  67. data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating.jsx +59 -0
  68. data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating_react.md +1 -0
  69. data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
  70. data/app/pb_kits/playbook/pb_table/docs/index.js +2 -0
  71. data/app/pb_kits/playbook/pb_table/styles/_headers.scss +76 -0
  72. data/app/pb_kits/playbook/pb_table/subcomponents/_table_head.tsx +11 -1
  73. data/app/pb_kits/playbook/pb_table/subcomponents/_table_header.tsx +11 -1
  74. data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +5 -0
  75. data/app/pb_kits/playbook/pb_table/table.test.js +17 -0
  76. data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +1 -1
  77. data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +4 -0
  78. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +3 -0
  79. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_disabled.html.erb +19 -0
  80. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_disabled.jsx +23 -0
  81. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
  82. data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
  83. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +3 -0
  84. data/app/pb_kits/playbook/pb_user/_user.tsx +78 -13
  85. data/app/pb_kits/playbook/pb_user/docs/_user_font_options.html.erb +22 -0
  86. data/app/pb_kits/playbook/pb_user/docs/_user_font_options.jsx +40 -0
  87. data/app/pb_kits/playbook/pb_user/docs/_user_font_options_rails.md +5 -0
  88. data/app/pb_kits/playbook/pb_user/docs/_user_font_options_react.md +5 -0
  89. data/app/pb_kits/playbook/pb_user/docs/example.yml +2 -0
  90. data/app/pb_kits/playbook/pb_user/docs/index.js +1 -0
  91. data/app/pb_kits/playbook/pb_user/user.html.erb +27 -6
  92. data/app/pb_kits/playbook/pb_user/user.rb +17 -1
  93. data/app/pb_kits/playbook/pb_user/user.test.js +182 -1
  94. data/app/pb_kits/playbook/tokens/_colors.scss +1 -4
  95. data/app/pb_kits/playbook/utilities/object.test.js +139 -1
  96. data/app/pb_kits/playbook/utilities/object.ts +86 -0
  97. data/app/pb_kits/playbook/utilities/text.ts +1 -1
  98. data/dist/chunks/_typeahead-N-EFroAX.js +22 -0
  99. data/dist/chunks/_weekday_stacked-Db780bKR.js +45 -0
  100. data/dist/chunks/{lib-BeKPJYlk.js → lib-Co5y3V4K.js} +2 -2
  101. data/dist/chunks/{pb_form_validation-BvDxpfs-.js → pb_form_validation-DMajaRt3.js} +1 -1
  102. data/dist/chunks/vendor.js +1 -1
  103. data/dist/playbook-doc.js +1 -1
  104. data/dist/playbook-rails-react-bindings.js +1 -1
  105. data/dist/playbook-rails.js +1 -1
  106. data/dist/playbook.css +1 -1
  107. data/lib/playbook/forms/builder/multi_level_select_field.rb +2 -0
  108. data/lib/playbook/version.rb +2 -2
  109. metadata +32 -8
  110. data/dist/chunks/_typeahead-CRAPc8k-.js +0 -22
  111. data/dist/chunks/_weekday_stacked-T0kFfioG.js +0 -45
  112. /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows_no_subrows.md → _advanced_table_selectable_rows_no_subrows_react.md} +0 -0
  113. /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows.md → _advanced_table_selectable_rows_react.md} +0 -0
@@ -1,48 +1,60 @@
1
1
  <%= pb_content_tag(:tr) do %>
2
- <% object.column_definitions.each_with_index do |column, index| %>
3
- <% next unless column[:accessor].present? %>
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
- <% if collapsible_trail && index.zero? %>
7
- <% (1..depth).each do |i| %>
8
- <% additional_offset = i > 1 ? (i - 1) * 0.25 : 0 %>
9
- <% left_offset = i * 1.0 + additional_offset %>
10
- <div class="collapsible-trail" style="left: <%= left_offset %>em"></div>
11
- <% end %>
2
+ <% has_separate_checkbox = object.selectable_rows && object.enable_toggle_expansion == "none" %>
3
+ <% if has_separate_checkbox %>
4
+ <%= object.render_checkbox_cell %>
5
+ <% end %>
6
+ <% object.column_definitions.each_with_index do |column, index| %>
7
+ <% next unless column[:accessor].present? %>
8
+ <%= pb_rails("table/table_cell", props: { classname:object.td_classname(column, index)}) do %>
9
+ <%= pb_rails("flex", props:{ align: "center", justify: index.zero? ? "start" : "end", classname: object.loading ? "loading-cell" : "" }) do %>
10
+ <% if collapsible_trail && index.zero? %>
11
+ <% (1..depth).each do |i| %>
12
+ <% additional_offset = i > 1 ? (i - 1) * 0.25 : 0 %>
13
+ <% left_offset = i * 1.0 + additional_offset %>
14
+ <div class="collapsible-trail" style="left: <%= left_offset %>em"></div>
12
15
  <% end %>
16
+ <% end %>
13
17
 
14
- <div style="padding-left: <%= depth * 1.25 %>em">
15
- <%= pb_rails("flex", props:{align: "center", column_gap: "xs"}) do %>
16
- <% if index.zero? && object.row[:children].present? %>
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>
18
+ <div style="padding-left: <%= depth * 1.25 %>em">
19
+ <%= pb_rails("flex", props:{align: "center", column_gap: "xs"}) do %>
20
+ <% if index.zero? %>
21
+ <% has_integrated_checkbox = object.selectable_rows && object.enable_toggle_expansion != "none" %>
22
+ <% if has_integrated_checkbox %>
23
+ <%= pb_rails("flex/flex_item", props: { padding_right: "xs" }) do %>
24
+ <%= object.render_row_checkbox %>
25
+ <% end %>
24
26
  <% end %>
25
- <%= pb_rails("flex/flex_item", props:{padding_left: index.zero? && object.row[:children].present? ? "none" : "xs"}) do %>
26
- <% if column[:custom_renderer].present? %>
27
- <%= raw(column[:custom_renderer].call(object.row, custom_renderer_value(column, index))) %>
28
- <% elsif index.zero? %>
29
- <% if object.depth.zero? %>
30
- <%= object.row[column[:accessor].to_sym] %>
31
- <% else %>
32
- <% object.depth_accessors.each_with_index do |item, accessor_index| %>
33
- <% if object.depth - 1 == accessor_index %>
34
- <% key = item.to_sym %>
35
- <%= object.row[key] %>
36
- <% end %>
27
+ <% if object.row[:children].present? %>
28
+ <button
29
+ id="<%= "#{object.id}_#{object.row.object_id}" %>"
30
+ class="gray-icon expand-toggle-icon"
31
+ data-advanced-table="true">
32
+ <%= pb_rails("icon", props: { id: "advanced-table_open_icon", icon: "circle-play", cursor: "pointer" }) %>
33
+ <%= pb_rails("icon", props: { id: "advanced-table_close_icon", display: "none", icon: "circle-play", cursor: "pointer", rotation: 90 }) %>
34
+ </button>
35
+ <% end %>
36
+ <% end %>
37
+ <%= pb_rails("flex/flex_item", props:{padding_left: index.zero? && (object.row[:children].present? || has_integrated_checkbox) ? "none" : "xs"}) do %>
38
+ <% if column[:custom_renderer].present? %>
39
+ <%= raw(column[:custom_renderer].call(object.row, custom_renderer_value(column, index))) %>
40
+ <% elsif index.zero? %>
41
+ <% if object.depth.zero? %>
42
+ <%= object.row[column[:accessor].to_sym] %>
43
+ <% else %>
44
+ <% object.depth_accessors.each_with_index do |item, accessor_index| %>
45
+ <% if object.depth - 1 == accessor_index %>
46
+ <% key = item.to_sym %>
47
+ <%= object.row[key] %>
37
48
  <% end %>
38
49
  <% end %>
39
- <% else %>
40
- <%= object.row[column[:accessor].to_sym] %>
41
50
  <% end %>
51
+ <% else %>
52
+ <%= object.row[column[:accessor].to_sym] %>
42
53
  <% end %>
43
54
  <% end %>
44
- </div>
45
- <% end %>
55
+ <% end %>
56
+ </div>
46
57
  <% end %>
47
58
  <% end %>
48
- <% end %>
59
+ <% end %>
60
+ <% end %>
@@ -20,6 +20,13 @@ module Playbook
20
20
  default: "scroll"
21
21
  prop :is_pinned_left, type: Playbook::Props::Boolean,
22
22
  default: false
23
+ prop :selectable_rows, type: Playbook::Props::Boolean,
24
+ default: false
25
+ prop :row_id, type: Playbook::Props::String,
26
+ default: ""
27
+ prop :enable_toggle_expansion, type: Playbook::Props::Enum,
28
+ values: %w[all header none],
29
+ default: "header"
23
30
 
24
31
  def data
25
32
  Hash(prop(:data)).merge(table_data_attributes)
@@ -42,6 +49,38 @@ module Playbook
42
49
  end.compact
43
50
  end
44
51
 
52
+ # Selectable Rows No Subrows - checkboxes in their own first cell
53
+ def render_checkbox_cell
54
+ if selectable_rows
55
+ pb_rails("table/table_cell", props: {
56
+ classname: "checkbox-cell",
57
+ }) do
58
+ pb_rails("checkbox", props: {
59
+ id: "select-row-#{row_id || row.object_id}",
60
+ name: "select-row-#{row_id || row.object_id}",
61
+ data: {
62
+ row_id: row_id || row.object_id.to_s,
63
+ action: "click->pb-advanced-table#toggleRowSelection",
64
+ },
65
+ })
66
+ end
67
+ end
68
+ end
69
+
70
+ # Selectable Rows w/ Subrows - checkboxes part of toggleable first cell
71
+ def render_row_checkbox
72
+ if selectable_rows
73
+ pb_rails("checkbox", props: {
74
+ id: "select-row-#{row_id || row.object_id}",
75
+ name: "select-row-#{row_id || row.object_id}",
76
+ data: {
77
+ row_id: row_id || row.object_id.to_s,
78
+ action: "click->pb-advanced-table#toggleRowSelection",
79
+ },
80
+ })
81
+ end
82
+ end
83
+
45
84
  private
46
85
 
47
86
  def custom_renderer_value(column, index)
@@ -7,7 +7,7 @@ import Highcharts from "highcharts";
7
7
  import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
8
8
  import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
9
9
  import mapColors from "../pb_dashboard/pbChartsColorsHelper";
10
- import { merge } from 'lodash'
10
+ import { merge } from '../utilities/object'
11
11
 
12
12
  import classnames from "classnames";
13
13
 
@@ -63,11 +63,6 @@ $pb_button_sizes: (
63
63
  color: $text_lt_lighter;
64
64
  }
65
65
 
66
- // Disabled =================
67
- &[class*=_disabled] {
68
- @include pb_button_disabled;
69
- }
70
-
71
66
  // Block ====================
72
67
  &[class*=_block] {
73
68
  @include pb_button_block;
@@ -83,6 +78,11 @@ $pb_button_sizes: (
83
78
  @include pb_button_danger;
84
79
  }
85
80
 
81
+ // Disabled =================
82
+ &[class*=_disabled] {
83
+ @include pb_button_disabled;
84
+ }
85
+
86
86
  // Dark Variants =============
87
87
  &.dark {
88
88
  &[class*=_primary] {
@@ -10,7 +10,7 @@ import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
10
10
  import mapColors from "../pb_dashboard/pbChartsColorsHelper";
11
11
  import { globalProps } from "../utilities/globalProps";
12
12
  import { buildAriaProps, buildDataProps, buildHtmlProps } from "../utilities/props";
13
- import { merge } from 'lodash'
13
+ import { merge } from '../utilities/object'
14
14
 
15
15
  type CircleChartProps = {
16
16
  align?: "left" | "right" | "center";
@@ -2,10 +2,120 @@
2
2
  @import "../tokens/opacity";
3
3
 
4
4
  .pb_draggable_container {
5
- .is_dragging {
6
- opacity: $opacity_4;
7
- }
8
- .pb_draggable_item:hover {
9
- cursor: grab;
5
+ .pb_draggable_item {
6
+ &:hover {
7
+ cursor: grab;
8
+ }
9
+
10
+ &.is_dragging {
11
+ position: relative;
12
+
13
+ // Ghost variant - show the item at 50% opacity. Default behavior.
14
+ &.drop_zone_ghost {
15
+ opacity: $opacity_4;
16
+ }
17
+
18
+ // Outline variant
19
+ &.drop_zone_outline {
20
+ // Create a container for the outline
21
+ position: relative;
22
+
23
+ // Make content invisible
24
+ & > * {
25
+ opacity: 0;
26
+ }
27
+
28
+ // Add outline
29
+ &::before {
30
+ content: '';
31
+ position: absolute;
32
+ top: 0;
33
+ left: 0;
34
+ width: 100%;
35
+ height: 100%;
36
+ border: 2px dashed $neutral;
37
+ border-radius: $border-radius-sm;
38
+ box-sizing: border-box;
39
+ z-index: 10;
40
+ pointer-events: none;
41
+ }
42
+
43
+ // Apply color variants to the ::before element
44
+ &.drop_zone_color_primary::before { border-color: $primary; }
45
+ &.drop_zone_color_purple::before { border-color: $purple; }
46
+ }
47
+
48
+ // Shadow variant
49
+ &.drop_zone_shadow {
50
+ // Create a container for the shadow
51
+ position: relative;
52
+
53
+ // Make content invisible
54
+ & > * {
55
+ opacity: 0;
56
+ }
57
+
58
+ // Add shadow background
59
+ &::before {
60
+ content: '';
61
+ position: absolute;
62
+ top: 0;
63
+ left: 0;
64
+ width: 100%;
65
+ height: 100%;
66
+ background-color: rgba($neutral, $opacity_5);
67
+ border-radius: $border-radius-sm;
68
+ z-index: 10;
69
+ pointer-events: none;
70
+ }
71
+
72
+ // Apply rgba color variants to the ::before element
73
+ &.drop_zone_color_primary::before { background-color: rgba($primary, $opacity_5); }
74
+ &.drop_zone_color_purple::before { background-color: rgba($purple, $opacity_5); }
75
+ }
76
+
77
+ // Line variant
78
+ &.drop_zone_line {
79
+ // Hide the original content to show the line
80
+ & > * {
81
+ opacity: 0;
82
+ }
83
+
84
+ // Style for horizontal line (default)
85
+ &::before {
86
+ content: '';
87
+ position: absolute;
88
+ left: 0;
89
+ top: 0;
90
+ width: 4px;
91
+ height: 100%;
92
+ background-color: $neutral;
93
+ border-radius: 1000px;
94
+ z-index: 10;
95
+ pointer-events: none;
96
+ }
97
+
98
+ // Apply color variants
99
+ &.drop_zone_color_primary::before { background-color: $primary; }
100
+ &.drop_zone_color_purple::before { background-color: $purple; }
101
+ }
102
+ }
10
103
  }
11
104
  }
105
+
106
+ // Support for vertical layouts (horizontal line)
107
+ .pb_draggable_container.vertical {
108
+ .pb_draggable_item {
109
+ &.is_dragging {
110
+ // Line variant for vertical layouts (horizontal line)
111
+ &.drop_zone_line {
112
+ &::before {
113
+ width: 100%;
114
+ height: 4px;
115
+ left: 0;
116
+ top: 0;
117
+ }
118
+ }
119
+ }
120
+ }
121
+ }
@@ -10,6 +10,8 @@ type DraggableProps = {
10
10
  className?: string;
11
11
  children?: React.ReactNode;
12
12
  data?: { [key: string]: string };
13
+ dropZone?: 'ghost' | 'outline' | 'shadow' | 'line';
14
+ dropZoneColor?: 'primary' | 'neutral' | 'purple';
13
15
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
14
16
  id?: string;
15
17
  };
@@ -24,7 +26,6 @@ const Draggable = (props: DraggableProps) => {
24
26
  id,
25
27
  } = props;
26
28
 
27
-
28
29
  const ariaProps = buildAriaProps(aria);
29
30
  const dataProps = buildDataProps(data);
30
31
  const htmlProps = buildHtmlProps(htmlOptions);
@@ -36,10 +37,11 @@ const Draggable = (props: DraggableProps) => {
36
37
  );
37
38
 
38
39
  return (
39
- <div {...ariaProps}
40
- {...dataProps}
40
+ <div
41
+ {...ariaProps}
42
+ {...dataProps}
41
43
  {...htmlProps}
42
- className={classes}
44
+ className={classes}
43
45
  id={id}
44
46
  >
45
47
  {children}
@@ -51,18 +51,39 @@ export const DraggableContext = () => {
51
51
  return useContext(DragContext);
52
52
  };
53
53
 
54
- export const DraggableProvider = ({
55
- children,
56
- initialItems,
54
+ export const DraggableProvider = ({
55
+ children,
56
+ initialItems,
57
57
  onReorder,
58
- onDragStart,
59
- onDragEnter,
60
- onDragEnd,
61
- onDrop,
62
- onDragOver
58
+ onDragStart,
59
+ onDragEnter,
60
+ onDragEnd,
61
+ onDrop,
62
+ onDragOver,
63
+ dropZone = { type: 'ghost', color: 'neutral', direction: 'vertical' }
63
64
  }: DraggableProviderType) => {
64
65
  const [state, dispatch] = useReducer(reducer, initialState);
65
66
 
67
+ // Parse dropZone prop - handle both string format (backward compatibility) and object format
68
+ let dropZoneType = 'ghost';
69
+ let dropZoneColor = 'neutral';
70
+ let dropZoneDirection = 'vertical';
71
+
72
+ if (typeof dropZone === 'string') {
73
+ // Legacy format - just the type is provided as a string
74
+ dropZoneType = dropZone;
75
+ } else {
76
+ // New object format
77
+ dropZoneType = dropZone.type || 'ghost';
78
+ // Line default is set to primary. Other types default to neutral.
79
+ dropZoneColor = dropZone.type === 'line' ? (dropZone.color || 'primary') : (dropZone.color || 'neutral');
80
+
81
+ // Only use direction if the type is 'line'
82
+ if (dropZoneType === 'line') {
83
+ dropZoneDirection = dropZone.direction || 'vertical';
84
+ }
85
+ }
86
+
66
87
  useEffect(() => {
67
88
  dispatch({ type: 'SET_ITEMS', payload: initialItems });
68
89
  }, [initialItems]);
@@ -108,17 +129,22 @@ export const DraggableProvider = ({
108
129
  if (onDragOver) onDragOver(e, container);
109
130
  };
110
131
 
132
+ // Include direction in contextValue only if type is 'line'
111
133
  const contextValue = useMemo(() => ({
112
134
  items: state.items,
113
135
  dragData: state.dragData,
114
136
  isDragging: state.isDragging,
115
137
  activeContainer: state.activeContainer,
138
+ dropZone: dropZoneType,
139
+ dropZoneColor,
140
+ // Only include direction when type is 'line'
141
+ ...(dropZoneType === 'line' ? { direction: dropZoneDirection } : {}),
116
142
  handleDragStart,
117
143
  handleDragEnter,
118
144
  handleDragEnd,
119
145
  handleDrop,
120
146
  handleDragOver
121
- }), [state]);
147
+ }), [state, dropZoneType, dropZoneColor, dropZoneDirection]);
122
148
 
123
149
  return (
124
150
  <DragContext.Provider value={contextValue}>{children}</DragContext.Provider>
@@ -1,31 +1,38 @@
1
1
  export interface ItemType {
2
- id: string;
3
- container: string;
4
- [key: string]: any;
5
- }
6
-
7
- export interface InitialStateType {
8
- items: ItemType[];
9
- dragData: { id: string; initialGroup: string };
10
- isDragging: string;
11
- activeContainer: string;
2
+ id: string;
3
+ container: string;
4
+ [key: string]: any;
5
+ }
6
+
7
+ export interface InitialStateType {
8
+ items: ItemType[];
9
+ dragData: { id: string; initialGroup: string };
10
+ isDragging: string;
11
+ activeContainer: string;
12
+ }
13
+
14
+ export type ActionType =
15
+ | { type: 'SET_ITEMS'; payload: ItemType[] }
16
+ | { type: 'SET_DRAG_DATA'; payload: { id: string; initialGroup: string } }
17
+ | { type: 'SET_IS_DRAGGING'; payload: string }
18
+ | { type: 'SET_ACTIVE_CONTAINER'; payload: string }
19
+ | { type: 'CHANGE_CATEGORY'; payload: { itemId: string; container: string } }
20
+ | { type: 'REORDER_ITEMS'; payload: { dragId: string; targetId: string } };
21
+
22
+ export interface DropZoneConfig {
23
+ type?: 'ghost' | 'outline' | 'shadow' | 'line';
24
+ color?: 'primary' | 'neutral' | 'purple';
25
+ direction?: 'horizontal' | 'vertical';
12
26
  }
13
-
14
- export type ActionType =
15
- | { type: 'SET_ITEMS'; payload: ItemType[] }
16
- | { type: 'SET_DRAG_DATA'; payload: { id: string; initialGroup: string } }
17
- | { type: 'SET_IS_DRAGGING'; payload: string }
18
- | { type: 'SET_ACTIVE_CONTAINER'; payload: string }
19
- | { type: 'CHANGE_CATEGORY'; payload: { itemId: string; container: string } }
20
- | { type: 'REORDER_ITEMS'; payload: { dragId: string; targetId: string } };
21
27
 
22
- export interface DraggableProviderType {
23
- children: React.ReactNode;
24
- initialItems: ItemType[];
25
- onReorder: (items: ItemType[]) => void;
26
- onDragStart?: (id: string, container: string) => void;
27
- onDragEnter?: (id: string, container: string) => void;
28
- onDragEnd?: () => void;
29
- onDrop?: (container: string) => void;
30
- onDragOver?: (e: Event, container: string) => void;
31
- }
28
+ export interface DraggableProviderType {
29
+ children: React.ReactNode;
30
+ initialItems: ItemType[];
31
+ onReorder: (items: ItemType[]) => void;
32
+ onDragStart?: (id: string, container: string) => void;
33
+ onDragEnter?: (id: string, container: string) => void;
34
+ onDragEnd?: () => void;
35
+ onDrop?: (container: string) => void;
36
+ onDragOver?: (e: Event, container: string) => void;
37
+ dropZone?: DropZoneConfig | string; // Can accept string for backward compatibility
38
+ }
@@ -0,0 +1,184 @@
1
+ import React, { useState } from "react";
2
+ import Body from '../../pb_body/_body'
3
+ import Flex from '../../pb_flex/_flex'
4
+ import FlexItem from '../../pb_flex/_flex_item'
5
+ import Card from '../../pb_card/_card'
6
+ import Caption from '../../pb_caption/_caption'
7
+ import Draggable from '../../pb_draggable/_draggable'
8
+ import { DraggableProvider } from '../../pb_draggable/context'
9
+
10
+ // Initial items to be dragged
11
+ const dataShadow = [
12
+ {
13
+ id: "51",
14
+ text: "Task 1",
15
+ },
16
+ {
17
+ id: "52",
18
+ text: "Task 2",
19
+ },
20
+ {
21
+ id: "53",
22
+ text: "Task 3",
23
+ },
24
+ ];
25
+
26
+ const dataOutline = [
27
+ {
28
+ id: "61",
29
+ text: "Task 1",
30
+ },
31
+ {
32
+ id: "62",
33
+ text: "Task 2",
34
+ },
35
+ {
36
+ id: "63",
37
+ text: "Task 3",
38
+ },
39
+ ];
40
+
41
+ const dataLine = [
42
+ {
43
+ id: "71",
44
+ text: "Task 1",
45
+ },
46
+ {
47
+ id: "72",
48
+ text: "Task 2",
49
+ },
50
+ {
51
+ id: "73",
52
+ text: "Task 3",
53
+ },
54
+ ];
55
+
56
+ const DraggableDropZones = (props) => {
57
+ const [initialShadowState, setInitialShadowState] = useState(dataShadow);
58
+ const [initialOutlineState, setInitialOutlineState] = useState(dataOutline);
59
+ const [initialLineState, setInitialLineState] = useState(dataLine);
60
+
61
+ return (
62
+ <>
63
+ <Flex justify="between"
64
+ {...props}
65
+ >
66
+ <FlexItem marginRight="xl">
67
+ <DraggableProvider
68
+ dropZone={{type: "shadow"}}
69
+ initialItems={dataShadow}
70
+ onReorder={(items) => setInitialShadowState(items)}
71
+ >
72
+ <Caption
73
+ marginBottom="xs"
74
+ textAlign="center"
75
+ >
76
+ {"Shadow"}
77
+ </Caption>
78
+ <Draggable.Container
79
+ htmlOptions={{style:{ width: "200px"}}}
80
+ {...props}
81
+ >
82
+ {initialShadowState.map(({ id, text }) => (
83
+ <Card dragId={id}
84
+ draggableItem
85
+ key={id}
86
+ marginBottom="xs"
87
+ padding="xs"
88
+ {...props}
89
+ >
90
+ <Flex alignItems="stretch"
91
+ flexDirection="column"
92
+ >
93
+ <Body
94
+ text={text}
95
+ {...props}
96
+ />
97
+ </Flex>
98
+ </Card>
99
+ ))}
100
+ </Draggable.Container>
101
+ </DraggableProvider>
102
+ </FlexItem>
103
+ <FlexItem marginRight="xl">
104
+ <DraggableProvider
105
+ dropZone={{type: "outline"}}
106
+ initialItems={dataOutline}
107
+ onReorder={(items) => setInitialOutlineState(items)}
108
+ >
109
+ <Caption
110
+ marginBottom="xs"
111
+ textAlign="center"
112
+ >
113
+ {"Outline"}
114
+ </Caption>
115
+ <Draggable.Container
116
+ htmlOptions={{style:{ width: "200px"}}}
117
+ {...props}
118
+ >
119
+ {initialOutlineState.map(({ id, text }) => (
120
+ <Card
121
+ dragId={id}
122
+ draggableItem
123
+ key={id}
124
+ marginBottom="xs"
125
+ padding="xs"
126
+ {...props}
127
+ >
128
+ <Flex
129
+ alignItems="stretch"
130
+ flexDirection="column"
131
+ >
132
+ <Body
133
+ text={text}
134
+ {...props}
135
+ />
136
+ </Flex>
137
+ </Card>
138
+ ))}
139
+ </Draggable.Container>
140
+ </DraggableProvider>
141
+ </FlexItem>
142
+ <FlexItem>
143
+ <DraggableProvider
144
+ dropZone={{type: "line"}}
145
+ initialItems={dataLine}
146
+ onReorder={(items) => setInitialLineState(items)}
147
+ >
148
+ <Caption
149
+ marginBottom="xs"
150
+ textAlign="center"
151
+ >
152
+ {"Line"}
153
+ </Caption>
154
+ <Draggable.Container
155
+ htmlOptions={{style:{ width: "200px"}}}
156
+ {...props}
157
+ >
158
+ {initialLineState.map(({ id, text }) => (
159
+ <Card dragId={id}
160
+ draggableItem
161
+ key={id}
162
+ marginBottom="xs"
163
+ padding="xs"
164
+ {...props}
165
+ >
166
+ <Flex alignItems="stretch"
167
+ flexDirection="column"
168
+ >
169
+ <Body
170
+ text={text}
171
+ {...props}
172
+ />
173
+ </Flex>
174
+ </Card>
175
+ ))}
176
+ </Draggable.Container>
177
+ </DraggableProvider>
178
+ </FlexItem>
179
+ </Flex>
180
+ </>
181
+ );
182
+ };
183
+
184
+ export default DraggableDropZones;