playbook_ui 14.17.0.pre.alpha.playcdntest7233 → 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 (115) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Utilities/types.ts +1 -1
  3. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +0 -70
  4. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +2 -83
  5. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +7 -20
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -2
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +1 -2
  8. data/app/pb_kits/playbook/pb_background/_background.scss +0 -26
  9. data/app/pb_kits/playbook/pb_background/_background.tsx +3 -5
  10. data/app/pb_kits/playbook/pb_background/background.test.js +0 -5
  11. data/app/pb_kits/playbook/pb_background/docs/example.yml +0 -1
  12. data/app/pb_kits/playbook/pb_background/docs/index.js +0 -1
  13. data/app/pb_kits/playbook/pb_collapsible/__snapshots__/collapsible.test.js.snap +7 -14
  14. data/app/pb_kits/playbook/pb_contact/contact.test.js +7 -7
  15. data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +34 -34
  16. data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +2 -2
  17. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +0 -16
  18. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_inline.html.erb +11 -0
  19. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_inline.jsx +7 -0
  20. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_inline_styles.scss +24 -28
  21. data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.test.js +2 -2
  22. data/app/pb_kits/playbook/pb_date_range_stacked/date_range_stacked.test.js +1 -1
  23. data/app/pb_kits/playbook/pb_draggable/_draggable.scss +20 -43
  24. data/app/pb_kits/playbook/pb_draggable/context/index.tsx +17 -58
  25. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones.jsx +105 -102
  26. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones.md +3 -3
  27. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_colors.jsx +48 -50
  28. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_colors.md +1 -1
  29. data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_with_table.jsx → _draggable_with_table_react.jsx} +1 -1
  30. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table_react.md +1 -3
  31. data/app/pb_kits/playbook/pb_draggable/docs/example.yml +6 -9
  32. data/app/pb_kits/playbook/pb_draggable/docs/index.js +1 -4
  33. data/app/pb_kits/playbook/pb_draggable/draggable.test.jsx +3 -71
  34. data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableContainer.tsx +3 -4
  35. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.jsx +6 -6
  36. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_and_custom_display.jsx +6 -6
  37. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.jsx +6 -6
  38. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display_rails.html.erb +8 -8
  39. data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +3 -3
  40. data/app/pb_kits/playbook/pb_filter/Filter/CurrentFilters.tsx +4 -3
  41. data/app/pb_kits/playbook/pb_filter/Filter/SortMenu.tsx +3 -2
  42. data/app/pb_kits/playbook/pb_form/pb_form_validation.js +1 -1
  43. data/app/pb_kits/playbook/pb_form_group/_form_group.scss +0 -22
  44. data/app/pb_kits/playbook/pb_icon/icon.test.js +9 -9
  45. data/app/pb_kits/playbook/pb_icon_circle/icon_circle.test.js +1 -1
  46. data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.test.js +1 -1
  47. data/app/pb_kits/playbook/pb_icon_value/icon_value.test.js +1 -1
  48. data/app/pb_kits/playbook/pb_label_value/label_value.test.js +1 -1
  49. data/app/pb_kits/playbook/pb_layout/_layout.scss +0 -58
  50. data/app/pb_kits/playbook/pb_layout/_layout.tsx +7 -20
  51. data/app/pb_kits/playbook/pb_layout/docs/example.yml +0 -1
  52. data/app/pb_kits/playbook/pb_layout/docs/index.js +0 -1
  53. data/app/pb_kits/playbook/pb_layout/layout.test.js +0 -4
  54. data/app/pb_kits/playbook/pb_lightbox/hooks/useVisibility.js +1 -1
  55. data/app/pb_kits/playbook/pb_link/link.test.jsx +2 -2
  56. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +1 -2
  57. data/app/pb_kits/playbook/pb_nav/_nav_item.test.js +3 -5
  58. data/app/pb_kits/playbook/pb_stat_change/stat_change.test.js +4 -8
  59. data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating_react.md +1 -1
  60. data/app/pb_kits/playbook/pb_table/docs/example.yml +0 -2
  61. data/app/pb_kits/playbook/pb_table/styles/_headers.scss +7 -19
  62. data/app/pb_kits/playbook/pb_table/styles/_striped.scss +3 -3
  63. data/app/pb_kits/playbook/pb_table/table.rb +1 -13
  64. data/app/pb_kits/playbook/pb_table/table_header.rb +1 -13
  65. data/app/pb_kits/playbook/pb_tooltip/floating_ui.js +282 -0
  66. data/app/pb_kits/playbook/pb_tooltip/index.js +56 -183
  67. data/app/pb_kits/playbook/pb_tooltip/tooltip.html.erb +5 -2
  68. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_highlight.jsx +4 -4
  69. data/app/pb_kits/playbook/pb_typeahead/index.ts +2 -2
  70. data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +5 -2
  71. data/app/pb_kits/playbook/pb_user/user.html.erb +6 -1
  72. data/app/pb_kits/playbook/pb_user_badge/user_badge.html.erb +6 -1
  73. data/app/pb_kits/playbook/utilities/globalProps.ts +1 -1
  74. data/app/pb_kits/playbook/utilities/object.test.js +1 -149
  75. data/app/pb_kits/playbook/utilities/object.ts +42 -124
  76. data/dist/chunks/{_typeahead-C2GOKWtm.js → _typeahead-N-EFroAX.js} +3 -3
  77. data/dist/chunks/_weekday_stacked-Db780bKR.js +45 -0
  78. data/dist/chunks/lib-Co5y3V4K.js +29 -0
  79. data/dist/chunks/{pb_form_validation-BvNy9Bd6.js → pb_form_validation-DMajaRt3.js} +1 -1
  80. data/dist/chunks/vendor.js +1 -1
  81. data/dist/playbook-doc.js +1 -1
  82. data/dist/playbook-rails-react-bindings.js +1 -1
  83. data/dist/playbook-rails.js +1 -1
  84. data/dist/playbook.css +1 -1
  85. data/lib/playbook/kit_base.rb +4 -4
  86. data/lib/playbook/version.rb +2 -2
  87. metadata +19 -33
  88. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_fullscreen.jsx +0 -90
  89. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_fullscreen.md +0 -3
  90. data/app/pb_kits/playbook/pb_background/docs/_background_overlay.jsx +0 -35
  91. data/app/pb_kits/playbook/pb_background/docs/_background_overlay.md +0 -1
  92. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_line.jsx +0 -110
  93. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_line.md +0 -5
  94. data/app/pb_kits/playbook/pb_layout/docs/_layout_bracket.jsx +0 -190
  95. data/app/pb_kits/playbook/pb_layout/docs/_layout_bracket.md +0 -5
  96. data/app/pb_kits/playbook/pb_layout/subcomponents/_game.tsx +0 -90
  97. data/app/pb_kits/playbook/pb_layout/subcomponents/_round.tsx +0 -57
  98. data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_vertical.md +0 -1
  99. data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless.html.erb +0 -34
  100. data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless_rails.md +0 -1
  101. data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating.html.erb +0 -36
  102. data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating_rails.md +0 -1
  103. data/dist/chunks/_weekday_stacked-CFGTPT0O.js +0 -45
  104. data/dist/chunks/lib-BGzBzFZX.js +0 -29
  105. /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_default_react.md → _draggable_default.md} +0 -0
  106. /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_default.html.erb → _draggable_default_rails.html.erb} +0 -0
  107. /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_multiple_containers_react.md → _draggable_multiple_containers.md} +0 -0
  108. /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_multiple_containers.html.erb → _draggable_multiple_containers_rails.html.erb} +0 -0
  109. /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_with_cards_react.md → _draggable_with_cards.md} +0 -0
  110. /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_with_cards.html.erb → _draggable_with_cards_rails.html.erb} +0 -0
  111. /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_with_list_react.md → _draggable_with_list.md} +0 -0
  112. /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_with_list.html.erb → _draggable_with_list_rails.html.erb} +0 -0
  113. /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_with_selectable_list_react.md → _draggable_with_selectable_list.md} +0 -0
  114. /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_with_selectable_list.html.erb → _draggable_with_selectable_list_rails.html.erb} +0 -0
  115. /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_with_table_rails.md → _draggable_with_table.md} +0 -0
@@ -14,12 +14,12 @@
14
14
  opacity: 1;
15
15
  }
16
16
  &:not(:hover) {
17
- .date-picker-inline-angle-down.cal_icon_wrapper {
17
+ #date-picker-inline-angle-down {
18
18
  svg {
19
19
  display: none;
20
20
  }
21
21
  }
22
- .date-picker-inline-icon-plus.cal_icon_wrapper {
22
+ #date-picker-inline-icon-plus {
23
23
  svg {
24
24
  color: $slate;
25
25
  display: inline-block;
@@ -33,12 +33,12 @@
33
33
  [class^="pb_text_input_kit"] .text_input_wrapper .flatpickr-wrapper .text_input .placeholder {
34
34
  color: $primary;
35
35
  }
36
- .date-picker-inline-angle-down.cal_icon_wrapper {
36
+ #date-picker-inline-angle-down {
37
37
  svg {
38
38
  display: none;
39
39
  }
40
40
  }
41
- .date-picker-inline-icon-plus.cal_icon_wrapper {
41
+ #date-picker-inline-icon-plus {
42
42
  svg {
43
43
  display: inline-block;
44
44
  color: $primary;
@@ -47,34 +47,32 @@
47
47
  }
48
48
  &.show-angle-down-icon {
49
49
  &:not(:hover) {
50
- .date-picker-inline-angle-down.cal_icon_wrapper {
50
+ #date-picker-inline-angle-down {
51
51
  svg {
52
52
  display: inline-block;
53
53
  color: $text_lt_light;
54
54
  }
55
55
  }
56
- .date-picker-inline-icon-plus.cal_icon_wrapper {
56
+ #date-picker-inline-icon-plus {
57
57
  svg {
58
58
  display: none;
59
59
  }
60
60
  }
61
61
  }
62
- .date-picker-inline-icon-plus.cal_icon_wrapper {
62
+ #date-picker-inline-icon-plus {
63
63
  svg {
64
64
  display: none;
65
65
  }
66
66
  }
67
- .date-picker-inline-angle-down.cal_icon_wrapper {
67
+ #date-picker-inline-angle-down {
68
68
  svg {
69
69
  display: inline-block;
70
70
  color: $primary;
71
71
  }
72
72
  }
73
73
  }
74
- .date_picker_input.flatpickr-input,
75
- .date_picker_input.flatpickr-input .active,
76
- .text_input.flatpickr-input,
77
- .text_input.flatpickr-input .active {
74
+ #date-picker-inline,
75
+ #date-picker-inline .active {
78
76
  border: none;
79
77
  padding: 5px 5px 5px 10px;
80
78
  background-color: #FFF;
@@ -84,8 +82,8 @@
84
82
  box-shadow: none;
85
83
  }
86
84
  }
87
- .date-picker-inline-angle-down.cal_icon_wrapper,
88
- .date-picker-inline-icon-plus.cal_icon_wrapper {
85
+ #date-picker-inline-angle-down,
86
+ #date-picker-inline-icon-plus {
89
87
  height: 33px;
90
88
  border: none;
91
89
  }
@@ -98,12 +96,12 @@
98
96
  [class^=pb_date_picker_kit].dark {
99
97
  &.inline-date-picker {
100
98
  &:not(:hover) {
101
- .date-picker-inline-angle-down.cal_icon_wrapper {
99
+ #date-picker-inline-angle-down {
102
100
  svg {
103
101
  display: none;
104
102
  }
105
103
  }
106
- .date-picker-inline-icon-plus.cal_icon_wrapper {
104
+ #date-picker-inline-icon-plus {
107
105
  svg {
108
106
  display: inline-block;
109
107
  color: $white;
@@ -117,12 +115,12 @@
117
115
  [class^="pb_text_input_kit"] .text_input_wrapper .flatpickr-wrapper .text_input .placeholder {
118
116
  color: $white;
119
117
  }
120
- .date-picker-inline-angle-down.cal_icon_wrapper {
118
+ #date-picker-inline-angle-down {
121
119
  svg {
122
120
  display: none;
123
121
  }
124
122
  }
125
- .date-picker-inline-icon-plus.cal_icon_wrapper {
123
+ #date-picker-inline-icon-plus {
126
124
  svg {
127
125
  display: inline-block;
128
126
  color: $white;
@@ -131,34 +129,32 @@
131
129
  }
132
130
  &.show-angle-down-icon {
133
131
  &:not(:hover) {
134
- .date-picker-inline-angle-down.cal_icon_wrapper {
132
+ #date-picker-inline-angle-down {
135
133
  svg {
136
134
  display: inline-block;
137
135
  color: $white;
138
136
  }
139
137
  }
140
- .date-picker-inline-icon-plus.cal_icon_wrapper {
138
+ #date-picker-inline-icon-plus {
141
139
  svg {
142
140
  display: none;
143
141
  }
144
142
  }
145
143
  }
146
- .date-picker-inline-icon-plus.cal_icon_wrapper {
144
+ #date-picker-inline-icon-plus {
147
145
  svg {
148
146
  display: none;
149
147
  }
150
148
  }
151
- .date-picker-inline-angle-down.cal_icon_wrapper {
149
+ #date-picker-inline-angle-down {
152
150
  svg {
153
151
  display: inline-block;
154
152
  color: $white;
155
153
  }
156
154
  }
157
155
  }
158
- .date_picker_input.flatpickr-input,
159
- .date_picker_input.flatpickr-input .active,
160
- .text_input.flatpickr-input,
161
- .text_input.flatpickr-input .active {
156
+ #date-picker-inline,
157
+ #date-picker-inline .active {
162
158
  background-color: rgba($white,.10);
163
159
  border: none;
164
160
  padding: 5px 5px 5px 10px;
@@ -168,8 +164,8 @@
168
164
  box-shadow: none;
169
165
  }
170
166
  }
171
- .date-picker-inline-angle-down.cal_icon_wrapper,
172
- .date-picker-inline-icon-plus.cal_icon_wrapper {
167
+ #date-picker-inline-angle-down,
168
+ #date-picker-inline-icon-plus {
173
169
  height: 33px;
174
170
  border: none;
175
171
  }
@@ -62,7 +62,7 @@ describe("DateRangeInline Kit", () => {
62
62
  )
63
63
 
64
64
  const kit = screen.getByTestId(testId)
65
- const arrow = kit.querySelector('.pb_custom_icon')
65
+ const arrow = kit.querySelector('.pb_icon_kit.fa-fw.fa-long-arrow-right')
66
66
  expect(arrow).toBeInTheDocument()
67
67
  })
68
68
 
@@ -93,7 +93,7 @@ describe("DateRangeInline Kit", () => {
93
93
  )
94
94
 
95
95
  const kit = screen.getByTestId(testId)
96
- const calendar = kit.querySelector('.pb_custom_icon')
96
+ const calendar = kit.querySelector('.pb_icon_kit.fa-fw.fa-calendar-alt')
97
97
  expect(calendar).toBeInTheDocument()
98
98
  })
99
99
 
@@ -58,7 +58,7 @@ describe("DateRangeStacked Kit", () => {
58
58
  )
59
59
 
60
60
  const kit = screen.getByTestId(testId)
61
- const arrowicon = kit.querySelector('.pb_custom_icon')
61
+ const arrowicon = kit.querySelector('.pb_icon_kit.fa-fw.pb_date_range_stacked_arrow')
62
62
  expect(arrowicon).toBeInTheDocument()
63
63
  })
64
64
 
@@ -1,6 +1,5 @@
1
1
  @import "../tokens/colors";
2
2
  @import "../tokens/opacity";
3
- @import "../tokens/border_radius";
4
3
 
5
4
  .pb_draggable_container {
6
5
  .pb_draggable_item {
@@ -35,7 +34,7 @@
35
34
  width: 100%;
36
35
  height: 100%;
37
36
  border: 2px dashed $neutral;
38
- border-radius: $border_radius_sm;
37
+ border-radius: $border-radius-sm;
39
38
  box-sizing: border-box;
40
39
  z-index: 10;
41
40
  pointer-events: none;
@@ -65,7 +64,7 @@
65
64
  width: 100%;
66
65
  height: 100%;
67
66
  background-color: rgba($neutral, $opacity_5);
68
- border-radius: $border_radius_sm;
67
+ border-radius: $border-radius-sm;
69
68
  z-index: 10;
70
69
  pointer-events: none;
71
70
  }
@@ -74,70 +73,48 @@
74
73
  &.drop_zone_color_primary::before { background-color: rgba($primary, $opacity_5); }
75
74
  &.drop_zone_color_purple::before { background-color: rgba($purple, $opacity_5); }
76
75
  }
77
- }
78
- }
79
- // Line default - Vertical orientation (horizontal line for draggable items in vertical layout)
80
- &.line_vertical {
81
- .pb_draggable_item {
82
- position: relative;
76
+
77
+ // Line variant
83
78
  &.drop_zone_line {
84
- // Hide the original content to show the line only (held draggable item should not take up space in drop zone)
85
- position: relative;
86
- z-index: 2;
79
+ // Hide the original content to show the line
87
80
  & > * {
88
81
  opacity: 0;
89
82
  }
90
- height: 4px;
83
+
91
84
  // Style for horizontal line (default)
92
85
  &::before {
93
86
  content: '';
94
87
  position: absolute;
95
88
  left: 0;
96
89
  top: 0;
97
- width: 100%;
98
- height: 4px;
90
+ width: 4px;
91
+ height: 100%;
99
92
  background-color: $neutral;
100
- border-radius: $border_radius_rounded;
93
+ border-radius: 1000px;
101
94
  z-index: 10;
102
95
  pointer-events: none;
103
- transform: translateY(-50%);
104
96
  }
105
- // Apply color variants to the ::before element
97
+
98
+ // Apply color variants
106
99
  &.drop_zone_color_primary::before { background-color: $primary; }
107
100
  &.drop_zone_color_purple::before { background-color: $purple; }
108
101
  }
109
102
  }
110
103
  }
111
- // Line variant - Horizontal orientation (vertical line for draggable items in horizontal layout)
112
- &.line_horizontal {
113
- .pb_draggable_item {
114
- position: relative;
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)
115
111
  &.drop_zone_line {
116
- position: relative;
117
- z-index: 2;
118
- & > * {
119
- opacity: 0;
120
- }
121
- width: 4px;
122
- height: auto;
123
- // Style for vertical line
124
112
  &::before {
125
- content: '';
126
- position: absolute;
113
+ width: 100%;
114
+ height: 4px;
127
115
  left: 0;
128
116
  top: 0;
129
- width: 4px;
130
- height: 100%;
131
- background-color: $neutral;
132
- border-radius: $border_radius_rounded;
133
- z-index: 10;
134
- pointer-events: none;
135
- transform: translateX(-50%);
136
117
  }
137
-
138
- // Apply color variants to the ::before element
139
- &.drop_zone_color_primary::before { background-color: $primary; }
140
- &.drop_zone_color_purple::before { background-color: $purple; }
141
118
  }
142
119
  }
143
120
  }
@@ -1,11 +1,11 @@
1
- import React, { createContext, useReducer, useContext, useEffect, useMemo, useRef, useState } from "react";
1
+ import React, { createContext, useReducer, useContext, useEffect, useMemo } from "react";
2
2
  import { InitialStateType, ActionType, DraggableProviderType } from "./types";
3
3
 
4
4
  const initialState: InitialStateType = {
5
5
  items: [],
6
6
  dragData: { id: "", initialGroup: "" },
7
7
  isDragging: "",
8
- activeContainer: "",
8
+ activeContainer: ""
9
9
  };
10
10
 
11
11
  const reducer = (state: InitialStateType, action: ActionType) => {
@@ -31,23 +31,9 @@ const reducer = (state: InitialStateType, action: ActionType) => {
31
31
  const { dragId, targetId } = action.payload;
32
32
  const newItems = [...state.items];
33
33
  const draggedItem = newItems.find(item => item.id === dragId);
34
- const targetItem = newItems.find(item => item.id === targetId);
35
-
36
- if (!draggedItem || !targetItem || draggedItem.container !== targetItem.container) {
37
- return state;
38
- }
39
-
40
- if (dragId === targetId) {
41
- return state;
42
- }
43
-
44
- const draggedIndex = newItems.findIndex(item => item.id === dragId);
34
+ const draggedIndex = newItems.indexOf(draggedItem);
45
35
  const targetIndex = newItems.findIndex(item => item.id === targetId);
46
36
 
47
- if (draggedIndex === -1 || targetIndex === -1) {
48
- return state;
49
- }
50
-
51
37
  newItems.splice(draggedIndex, 1);
52
38
  newItems.splice(targetIndex, 0, draggedItem);
53
39
 
@@ -62,11 +48,7 @@ const reducer = (state: InitialStateType, action: ActionType) => {
62
48
  const DragContext = createContext<any>({});
63
49
 
64
50
  export const DraggableContext = () => {
65
- const context = useContext(DragContext);
66
- if (context === undefined) {
67
- throw new Error('DraggableContext must be used within a DraggableProvider');
68
- }
69
- return context;
51
+ return useContext(DragContext);
70
52
  };
71
53
 
72
54
  export const DraggableProvider = ({
@@ -81,11 +63,7 @@ export const DraggableProvider = ({
81
63
  dropZone = { type: 'ghost', color: 'neutral', direction: 'vertical' }
82
64
  }: DraggableProviderType) => {
83
65
  const [state, dispatch] = useReducer(reducer, initialState);
84
-
85
- // Store initial items in a ref to use if needed (for consistency when needed in future updates)
86
- const initialItemsRef = useRef(initialItems);
87
- const [isDragging, setIsDragging] = useState(false);
88
-
66
+
89
67
  // Parse dropZone prop - handle both string format (backward compatibility) and object format
90
68
  let dropZoneType = 'ghost';
91
69
  let dropZoneColor = 'neutral';
@@ -108,64 +86,45 @@ export const DraggableProvider = ({
108
86
 
109
87
  useEffect(() => {
110
88
  dispatch({ type: 'SET_ITEMS', payload: initialItems });
111
- initialItemsRef.current = initialItems;
112
89
  }, [initialItems]);
113
90
 
114
91
  useEffect(() => {
115
- if (onReorder) {
116
- onReorder(state.items);
117
- }
118
- }, [state.items, onReorder]);
92
+ onReorder(state.items);
93
+ }, [state.items]);
119
94
 
120
95
  const handleDragStart = (id: string, container: string) => {
121
- setIsDragging(true);
122
- dispatch({ type: 'SET_DRAG_DATA', payload: { id, initialGroup: container } });
96
+ dispatch({ type: 'SET_DRAG_DATA', payload: { id: id, initialGroup: container } });
123
97
  dispatch({ type: 'SET_IS_DRAGGING', payload: id });
124
- dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: container });
125
98
  if (onDragStart) onDragStart(id, container);
126
99
  };
127
100
 
128
101
  const handleDragEnter = (id: string, container: string) => {
129
- if (!isDragging || container !== state.activeContainer) return;
130
-
131
- if (state.dragData.id === id) return;
132
-
133
- const draggedItem = state.items.find(item => item.id === state.dragData.id);
134
- const targetItem = state.items.find(item => item.id === id);
135
-
136
- if (!draggedItem || !targetItem || draggedItem.container !== targetItem.container) {
137
- return;
102
+ if (state.dragData.id !== id) {
103
+ dispatch({ type: 'REORDER_ITEMS', payload: { dragId: state.dragData.id, targetId: id } });
104
+ dispatch({ type: 'SET_DRAG_DATA', payload: { id: state.dragData.id, initialGroup: container } });
138
105
  }
139
-
140
- dispatch({ type: 'REORDER_ITEMS', payload: { dragId: state.dragData.id, targetId: id } });
141
-
142
106
  if (onDragEnter) onDragEnter(id, container);
143
107
  };
144
108
 
145
109
  const handleDragEnd = () => {
146
- setIsDragging(false);
147
110
  dispatch({ type: 'SET_IS_DRAGGING', payload: "" });
148
111
  dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: "" });
149
112
  if (onDragEnd) onDragEnd();
150
113
  };
151
114
 
152
- const handleDrop = (container: string) => {
153
- const draggedItem = state.items.find(item => item.id === state.dragData.id);
154
-
155
- if (draggedItem && draggedItem.container !== container) {
156
- dispatch({ type: 'CHANGE_CATEGORY', payload: { itemId: state.dragData.id, container } });
157
- }
115
+ const changeCategory = (itemId: string, container: string) => {
116
+ dispatch({ type: 'CHANGE_CATEGORY', payload: { itemId, container } });
117
+ };
158
118
 
119
+ const handleDrop = (container: string) => {
159
120
  dispatch({ type: 'SET_IS_DRAGGING', payload: "" });
160
121
  dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: "" });
161
-
162
- setIsDragging(false);
122
+ changeCategory(state.dragData.id, container);
163
123
  if (onDrop) onDrop(container);
164
124
  };
165
125
 
166
126
  const handleDragOver = (e: Event, container: string) => {
167
127
  e.preventDefault();
168
- e.stopPropagation();
169
128
  dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: container });
170
129
  if (onDragOver) onDragOver(e, container);
171
130
  };
@@ -185,7 +144,7 @@ export const DraggableProvider = ({
185
144
  handleDragEnd,
186
145
  handleDrop,
187
146
  handleDragOver
188
- }), [state, dropZoneType, dropZoneColor, dropZoneDirection, handleDragStart, handleDragEnter, handleDragEnd, handleDrop, handleDragOver]);
147
+ }), [state, dropZoneType, dropZoneColor, dropZoneDirection]);
189
148
 
190
149
  return (
191
150
  <DragContext.Provider value={contextValue}>{children}</DragContext.Provider>
@@ -60,120 +60,123 @@ const DraggableDropZones = (props) => {
60
60
 
61
61
  return (
62
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
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}
73
86
  marginBottom="xs"
74
- text="Shadow"
75
- textAlign="center"
76
- />
77
- <Draggable.Container
78
- htmlOptions={{style:{ width: "200px"}}}
87
+ padding="xs"
79
88
  {...props}
80
89
  >
81
- {initialShadowState.map(({ id, text }) => (
82
- <Card dragId={id}
83
- draggableItem
84
- key={id}
85
- marginBottom="xs"
86
- padding="xs"
87
- {...props}
90
+ <Flex alignItems="stretch"
91
+ flexDirection="column"
88
92
  >
89
- <Flex alignItems="stretch"
90
- flexDirection="column"
91
- >
92
- <Body
93
- text={text}
94
- {...props}
95
- />
96
- </Flex>
97
- </Card>
98
- ))}
99
- </Draggable.Container>
100
- </DraggableProvider>
101
- </FlexItem>
102
- <FlexItem marginRight="xl">
103
- <DraggableProvider
104
- dropZone={{type: "outline"}}
105
- initialItems={dataOutline}
106
- onReorder={(items) => setInitialOutlineState(items)}
107
- >
108
- <Caption
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}
109
124
  marginBottom="xs"
110
- text="Outline"
111
- textAlign="center"
112
- />
113
- <Draggable.Container
114
- htmlOptions={{style:{ width: "200px"}}}
125
+ padding="xs"
115
126
  {...props}
116
127
  >
117
- {initialOutlineState.map(({ id, text }) => (
118
- <Card
119
- dragId={id}
120
- draggableItem
121
- key={id}
122
- marginBottom="xs"
123
- padding="xs"
124
- {...props}
128
+ <Flex
129
+ alignItems="stretch"
130
+ flexDirection="column"
125
131
  >
126
- <Flex
127
- alignItems="stretch"
128
- flexDirection="column"
129
- >
130
- <Body
131
- text={text}
132
- {...props}
133
- />
134
- </Flex>
135
- </Card>
136
- ))}
137
- </Draggable.Container>
138
- </DraggableProvider>
139
- </FlexItem>
140
- <FlexItem>
141
- <DraggableProvider
142
- dropZone={{type: "line"}}
143
- initialItems={dataLine}
144
- onReorder={(items) => setInitialLineState(items)}
145
- >
146
- <Caption
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}
147
162
  marginBottom="xs"
148
- text="Line"
149
- textAlign="center"
150
- />
151
- <Draggable.Container
152
- htmlOptions={{style:{ width: "200px"}}}
163
+ padding="xs"
153
164
  {...props}
154
165
  >
155
- {initialLineState.map(({ id, text }) => (
156
- <Card dragId={id}
157
- draggableItem
158
- key={id}
159
- marginBottom="xs"
160
- padding="xs"
161
- {...props}
166
+ <Flex alignItems="stretch"
167
+ flexDirection="column"
162
168
  >
163
- <Flex alignItems="stretch"
164
- flexDirection="column"
165
- >
166
- <Body
167
- text={text}
168
- {...props}
169
- />
170
- </Flex>
171
- </Card>
172
- ))}
173
- </Draggable.Container>
174
- </DraggableProvider>
175
- </FlexItem>
176
- </Flex>
169
+ <Body
170
+ text={text}
171
+ {...props}
172
+ />
173
+ </Flex>
174
+ </Card>
175
+ ))}
176
+ </Draggable.Container>
177
+ </DraggableProvider>
178
+ </FlexItem>
179
+ </Flex>
177
180
  </>
178
181
  );
179
182
  };