playbook_ui 16.10.0.pre.alpha.PLAY3059dialogpopoverportalingfullscreen17455 → 16.10.0.pre.alpha.PLAY3088figmacodeconnecttrial17604

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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +19 -6
  3. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +17 -12
  4. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +3 -0
  5. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +26 -1
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_both.jsx +57 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_both_react.md +1 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_bottom.jsx +57 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_bottom_react.md +1 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_react.md +2 -2
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +3 -2
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +3 -1
  13. data/app/pb_kits/playbook/pb_draggable/_draggable.scss +3 -0
  14. data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableItem.tsx +53 -29
  15. data/app/pb_kits/playbook/pb_draggable/touchDrag.test.js +46 -0
  16. data/app/pb_kits/playbook/pb_draggable/utilities/touchDrag.ts +272 -54
  17. data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_remove_replace.html.erb +66 -0
  18. data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_remove_replace.jsx +53 -0
  19. data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_remove_replace.md +5 -0
  20. data/app/pb_kits/playbook/pb_file_upload/docs/example.yml +3 -1
  21. data/app/pb_kits/playbook/pb_file_upload/docs/index.js +1 -0
  22. data/app/pb_kits/playbook/pb_nav/_item.tsx +3 -2
  23. data/app/pb_kits/playbook/pb_nav/_nav.tsx +1 -1
  24. data/app/pb_kits/playbook/pb_nav/docs/_playground.json +117 -213
  25. data/app/pb_kits/playbook/pb_nav/docs/_playground.overrides.json +127 -319
  26. data/app/pb_kits/playbook/pb_nav/kit.schema.json +2 -1
  27. data/app/pb_kits/playbook/pb_nav/navTypes.ts +1 -1
  28. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.scss +1 -1
  29. data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +2 -2
  30. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_error.html.erb +1 -1
  31. data/app/pb_kits/playbook/pb_title/docs/Title.figma.ts +44 -0
  32. data/app/pb_kits/playbook/pb_title/docs/Title.figma.tsx +39 -0
  33. data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +45 -0
  34. data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +144 -0
  35. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +25 -1
  36. data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +29 -85
  37. data/app/pb_kits/playbook/pb_typeahead/components/PillRenderer.tsx +187 -0
  38. data/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.tsx +236 -10
  39. data/app/pb_kits/playbook/pb_typeahead/docs/_playground.json +8 -2
  40. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default.jsx +11 -513
  41. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills.html.erb +39 -0
  42. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills.jsx +63 -0
  43. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills.md +7 -0
  44. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills_rails.md +7 -0
  45. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
  46. data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
  47. data/app/pb_kits/playbook/pb_typeahead/kit.schema.json +24 -0
  48. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +9 -0
  49. data/dist/chunks/{_typeahead-COksV0jV.js → _typeahead-DjVWQJpA.js} +2 -2
  50. data/dist/chunks/vendor.js +2 -2
  51. data/dist/menu.yml +1 -1
  52. data/dist/playbook-rails-react-bindings.js +1 -1
  53. data/dist/playbook-rails.js +1 -1
  54. data/dist/playbook.css +1 -1
  55. data/lib/playbook/version.rb +1 -1
  56. metadata +17 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03ca6b840b6dae7ae012850c4eb9cfde2a485fcc28f9507ec52bf63390b681b4
4
- data.tar.gz: 1c097a794fd858c7ff9a71808aab92b98f4a5e7a8d16a893216ece681dd9d903
3
+ metadata.gz: 3751d64092566ad3cf09621e4f4e79b29dddec14351aef0591f3d2e07e88f94f
4
+ data.tar.gz: c5b899dc4757a061c45705b4502fac3c8312cc99e5ec77f33492df76338f634a
5
5
  SHA512:
6
- metadata.gz: 4491d7b653e2f5f713095670061af2d3dd4bf09aecf0d9e08ea7787cc706e30592b7d001bb413f80403096f447162ffa189c0a032bbfaf400cb6a96a6aae8a5b
7
- data.tar.gz: 1119d2f7c778f4bc2e7b63cc758b34914f686a180b14abb9d3a15cbe43fc2338657b600b8107c0acae30fbb8c4b53b28c2f628c2a570d0db7b9a584c1f686fd9
6
+ metadata.gz: 53da6b3099eefcbc5d00ea84e58c52d6dab20ac28f1fb44d7b604e307d554939758541115851569a8bb6641082c23724c19f0d6be19eb4a2162e4c7db65c4c08
7
+ data.tar.gz: 26a265e2834cf967732666edec0f1ea5f8b34248ef984051aa7b93ca0aa5a73a15e4f04562b74ed1ad35ef83766eee4d15f5f518b5c512a38c8763c0238ac2c1
@@ -162,20 +162,26 @@ export const RegularTableView = ({
162
162
  );
163
163
 
164
164
  // Row pinning
165
- function PinnedRow({ row }: { row: Row<any> }) {
165
+ function PinnedRow({ row, position }: { row: Row<any>; position: 'top' | 'bottom' }) {
166
166
  const customRowStyle = getRowStyle(rowStyling, row);
167
+ const bottomRowsCount = table.getBottomRows().length;
168
+
167
169
  return (
168
170
  <tr
169
- className={classnames(
170
- `pinned-row`,
171
- )}
171
+ className={classnames('pinned-row', {
172
+ 'pinned-row-bottom': position === 'bottom',
173
+ })}
172
174
  style={{
173
175
  backgroundColor: customRowStyle?.backgroundColor ? customRowStyle?.backgroundColor : 'white',
174
176
  color: customRowStyle?.fontColor,
175
177
  position: 'sticky',
176
178
  top:
177
- row.getIsPinned() === 'top'
178
- ? `${row.getPinnedIndex() * rowHeight + headerHeight + actionBarHeight}px`
179
+ position === 'top'
180
+ ? `${row.getPinnedIndex() * rowHeight + headerHeight + actionBarHeight}px`
181
+ : undefined,
182
+ bottom:
183
+ position === 'bottom'
184
+ ? `${(bottomRowsCount - 1 - row.getPinnedIndex()) * rowHeight}px`
179
185
  : undefined,
180
186
  zIndex: '3',
181
187
  fontWeight: getFontWeight(customRowStyle),
@@ -201,6 +207,7 @@ export const RegularTableView = ({
201
207
  <>
202
208
  {pinnedRows && table.getTopRows().map((row: Row<GenericObject>) => (
203
209
  <PinnedRow key={row.id}
210
+ position="top"
204
211
  row={row}
205
212
  />
206
213
  ))}
@@ -274,6 +281,12 @@ export const RegularTableView = ({
274
281
  </React.Fragment>
275
282
  );
276
283
  })}
284
+ {pinnedRows && table.getBottomRows().map((row: Row<GenericObject>) => (
285
+ <PinnedRow key={row.id}
286
+ position="bottom"
287
+ row={row}
288
+ />
289
+ ))}
277
290
  </>
278
291
  );
279
292
  }
@@ -72,6 +72,7 @@ export function useTableState({
72
72
  const [localColumnVisibility, setLocalColumnVisibility] = useState({});
73
73
  const [localRowPinning, setLocalRowPinning] = useState<RowPinningState>({
74
74
  top: [],
75
+ bottom: [],
75
76
  });
76
77
  // Manage local state to preserve current page index when inlineRowLoading is enabled so it does not boot table to page 1
77
78
  // We can extend this for more usecases, but for now scoping it only for inlineRowLoading
@@ -235,22 +236,26 @@ export function useTableState({
235
236
  // Handle row pinning changes
236
237
  useEffect(() => {
237
238
  const topPins = pinnedRows?.value?.top ?? [];
238
- if (topPins.length === 0) {
239
- onRowPinningChange({ top: [] });
240
- return;
241
- }
239
+ const bottomPins = pinnedRows?.value?.bottom ?? [];
240
+
242
241
  const rows = table.getRowModel().rows;
243
242
  const collectAllDescendantIds = (subs: Row<GenericObject>[]): string[] =>
244
243
  subs.flatMap(r => [r.id, ...collectAllDescendantIds(r.subRows)]);
245
- const allPinned: string[] = [];
246
- topPins.forEach(id => {
247
- const parent = rows.find(r => r.id === id && r.depth === 0);
248
- if (parent) {
249
- allPinned.push(parent.id, ...collectAllDescendantIds(parent.subRows));
250
- }
244
+ const expandPins = (ids: string[]): string[] => {
245
+ const allPinned: string[] = [];
246
+ ids.forEach(id => {
247
+ const parent = rows.find(r => r.id === id && r.depth === 0);
248
+ if (parent) {
249
+ allPinned.push(parent.id, ...collectAllDescendantIds(parent.subRows));
250
+ }
251
+ });
252
+ return allPinned;
253
+ };
254
+ onRowPinningChange({
255
+ top: expandPins(topPins),
256
+ bottom: expandPins(bottomPins),
251
257
  });
252
- onRowPinningChange({ top: allPinned });
253
- }, [table, pinnedRows?.value?.top?.join(',')]);
258
+ }, [table, pinnedRows?.value?.top?.join(','), pinnedRows?.value?.bottom?.join(',')]);
254
259
 
255
260
  // Set pagination state when pagination is enabled
256
261
  useEffect(() => {
@@ -747,6 +747,9 @@
747
747
  // Row Pinning - React uses inline style; Rails passes same style via html_options from table_body
748
748
  .pinned-row {
749
749
  box-shadow: 0 4px 10px 0 rgba($shadow, 0.16) !important;
750
+ &.pinned-row-bottom {
751
+ box-shadow: 0 -3px 8px 0 rgba($shadow, 0.1) !important;
752
+ }
750
753
  }
751
754
 
752
755
  // For Rails, we can't target the &:last-child since collapsed rows are display: none;
@@ -696,7 +696,7 @@ test("customRenderer prop functions as expected", () => {
696
696
  expect(pill).toBeInTheDocument()
697
697
  })
698
698
 
699
- test("pinnedRows prop renders pinned rows at top", () => {
699
+ test("pinnedRows prop renders top pinned rows at top", () => {
700
700
  const pinnedRowsControl = {
701
701
  value: { top: ["1", "3"] },
702
702
  onChange: jest.fn()
@@ -721,6 +721,31 @@ test("pinnedRows prop renders pinned rows at top", () => {
721
721
  expect(firstPinnedRow).toHaveStyle("background-color: white")
722
722
  })
723
723
 
724
+ test("pinnedRows prop renders bottom pinned rows at bottom", () => {
725
+ const pinnedRowsControl = {
726
+ value: { bottom: ["1", "3"] },
727
+ onChange: jest.fn()
728
+ }
729
+
730
+ render(
731
+ <AdvancedTable
732
+ columnDefinitions={columnDefinitions}
733
+ data={{ testid: testId }}
734
+ pinnedRows={pinnedRowsControl}
735
+ tableData={MOCK_DATA_WITH_ID}
736
+ />
737
+ )
738
+
739
+ const kit = screen.getByTestId(testId)
740
+ const pinnedRows = kit.querySelectorAll(".pinned-row-bottom")
741
+
742
+ expect(pinnedRows).toHaveLength(2)
743
+
744
+ const lastPinnedRow = pinnedRows[0]
745
+ expect(lastPinnedRow).toHaveStyle("position: sticky")
746
+ expect(lastPinnedRow).toHaveStyle("background-color: white")
747
+ })
748
+
724
749
  test("columnStyling.headerAlignment aligns header as expected", () => {
725
750
  const styledColumnDefs = [
726
751
  {
@@ -0,0 +1,57 @@
1
+ import React, { useState } from "react"
2
+ import AdvancedTable from '../_advanced_table'
3
+ import MOCK_DATA_WITH_ID from "./advanced_table_mock_data_with_id.json"
4
+
5
+ const AdvancedTableRowPinningBoth = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ cellAccessors: ["quarter", "month", "day"],
11
+ },
12
+ {
13
+ accessor: "newEnrollments",
14
+ label: "New Enrollments",
15
+ },
16
+ {
17
+ accessor: "scheduledMeetings",
18
+ label: "Scheduled Meetings",
19
+ },
20
+ {
21
+ accessor: "attendanceRate",
22
+ label: "Attendance Rate",
23
+ },
24
+ {
25
+ accessor: "completedClasses",
26
+ label: "Completed Classes",
27
+ },
28
+ {
29
+ accessor: "classCompletionRate",
30
+ label: "Class Completion Rate",
31
+ },
32
+ {
33
+ accessor: "graduatedStudents",
34
+ label: "Graduated Students",
35
+ },
36
+ ]
37
+
38
+ const [pinnedRows, setPinnedRows] = useState({top: ["8"], bottom: ["1"]})
39
+
40
+ return (
41
+ <div>
42
+ <AdvancedTable
43
+ columnDefinitions={columnDefinitions}
44
+ maxHeight="xs"
45
+ pinnedRows={{value: pinnedRows, onChange: setPinnedRows}}
46
+ tableData={MOCK_DATA_WITH_ID}
47
+ tableProps={{sticky: true}}
48
+ {...props}
49
+ >
50
+ <AdvancedTable.Header enableSorting />
51
+ <AdvancedTable.Body />
52
+ </AdvancedTable>
53
+ </div>
54
+ )
55
+ }
56
+
57
+ export default AdvancedTableRowPinningBoth
@@ -0,0 +1 @@
1
+ This code snippet demonstrates `pinnedRows` taking an array of row ids to both the `top` and `bottom` properties.
@@ -0,0 +1,57 @@
1
+ import React, { useState } from "react"
2
+ import AdvancedTable from '../_advanced_table'
3
+ import MOCK_DATA_WITH_ID from "./advanced_table_mock_data_with_id.json"
4
+
5
+ const AdvancedTableRowPinningBottom = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ cellAccessors: ["quarter", "month", "day"],
11
+ },
12
+ {
13
+ accessor: "newEnrollments",
14
+ label: "New Enrollments",
15
+ },
16
+ {
17
+ accessor: "scheduledMeetings",
18
+ label: "Scheduled Meetings",
19
+ },
20
+ {
21
+ accessor: "attendanceRate",
22
+ label: "Attendance Rate",
23
+ },
24
+ {
25
+ accessor: "completedClasses",
26
+ label: "Completed Classes",
27
+ },
28
+ {
29
+ accessor: "classCompletionRate",
30
+ label: "Class Completion Rate",
31
+ },
32
+ {
33
+ accessor: "graduatedStudents",
34
+ label: "Graduated Students",
35
+ },
36
+ ]
37
+
38
+ const [pinnedRows, setPinnedRows] = useState({bottom: ["8"]})
39
+
40
+ return (
41
+ <div>
42
+ <AdvancedTable
43
+ columnDefinitions={columnDefinitions}
44
+ maxHeight="xs"
45
+ pinnedRows={{value: pinnedRows, onChange: setPinnedRows}}
46
+ tableData={MOCK_DATA_WITH_ID}
47
+ tableProps={{sticky: true}}
48
+ {...props}
49
+ >
50
+ <AdvancedTable.Header enableSorting />
51
+ <AdvancedTable.Body />
52
+ </AdvancedTable>
53
+ </div>
54
+ )
55
+ }
56
+
57
+ export default AdvancedTableRowPinningBottom
@@ -0,0 +1 @@
1
+ This code snippet demonstrates `pinnedRows` taking an array of row ids to the `bottom` property.
@@ -1,7 +1,7 @@
1
- Use the `pinnedRows` prop to pin specific rows to the top of an Advanced Table. Pinned rows will remain at the top when scrolling through table data and will not change position if sorting is used.
1
+ Use the `pinnedRows` prop to pin specific rows to the top or bottom of an Advanced Table. Pinned rows will remain at the top or bottom when scrolling through table data and will not change position if sorting is used.
2
2
 
3
3
  **NOTE:**
4
4
  - Sticky header required: Pinned rows must be used with `sticky: true` via `tableProps` (works with both responsive and non-responsive tables)
5
5
  - Row ids required: Each object within the `tableData` Array must contain a unique id in order to attach an id to all Rows for this to function.
6
- - `pinnedRows` takes an array of row ids to the `top` property as shown in the code snippet below.
6
+ - `pinnedRows` takes an array of row ids to the `top` or `bottom` property, or both. `top` is shown in the code snippet below.
7
7
  - For expandable rows, use the parent id in `pinnedRows`, all its children will automatically be pinned with it. If id for a child is passed in without parent being pinned, nothing will be pinned.
@@ -67,7 +67,9 @@ examples:
67
67
  - advanced_table_column_headers_custom_cell: Multi-Header Columns with Custom Cells
68
68
  - advanced_table_column_headers_vertical_border: Multi-Header Columns with Vertical Borders
69
69
  - advanced_table_no_subrows: Table with No Subrows or Expansion
70
- - advanced_table_pinned_rows: Pinned Rows
70
+ - advanced_table_pinned_rows: Pinned Rows (Top)
71
+ - advanced_table_pinned_rows_bottom: Pinned Rows (Bottom)
72
+ - advanced_table_pinned_rows_both: Pinned Rows (Both)
71
73
  - advanced_table_selectable_rows: Selectable Rows
72
74
  - advanced_table_selectable_rows_no_subrows_react: Selectable Rows (No Subrows)
73
75
  - advanced_table_selectable_rows_actions: Selectable Rows (With Actions)
@@ -89,5 +91,4 @@ examples:
89
91
  - advanced_table_column_styling_background_multi: Column Styling Background Color with Multiple Headers
90
92
  - advanced_table_padding_control: Padding Control using Column Styling
91
93
  - advanced_table_column_border_color: Column Group Border Color
92
- - advanced_table_fullscreen: Fullscreen
93
94
  - advanced_table_infinite_scroll: Infinite Scroll
@@ -52,4 +52,6 @@ export { default as AdvancedTableColumnStylingBackground } from './_advanced_tab
52
52
  export { default as AdvancedTableColumnStylingBackgroundMulti } from './_advanced_table_column_styling_background_multi.jsx'
53
53
  export { default as AdvancedTableColumnStylingBackgroundCustom } from './_advanced_table_column_styling_background_custom.jsx'
54
54
  export { default as AdvancedTableCascadeCollapse } from './_advanced_table_cascade_collapse.jsx'
55
- export { default as AdvancedTableSortParentOnly } from './_advanced_table_sort_parent_only.jsx'
55
+ export { default as AdvancedTableSortParentOnly } from './_advanced_table_sort_parent_only.jsx'
56
+ export { default as AdvancedTablePinnedRowsBottom } from './_advanced_table_pinned_rows_bottom.jsx'
57
+ export { default as AdvancedTablePinnedRowsBoth } from './_advanced_table_pinned_rows_both.jsx'
@@ -9,6 +9,9 @@
9
9
  }
10
10
 
11
11
  &.is_touch_active {
12
+ user-select: none;
13
+ -webkit-user-select: none;
14
+
12
15
  .pb_draggable_handle,
13
16
  .card_draggable_handle {
14
17
  color: $text_lt_default;
@@ -9,7 +9,7 @@ import {
9
9
  import { globalProps } from "../../utilities/globalProps";
10
10
  import { DraggableContext } from "../context";
11
11
  import { noop } from '../../utilities/object'
12
- import { bindTouchDrag, isTouchDragDevice } from "../utilities/touchDrag";
12
+ import { bindMousePointerDrag, bindTouchDrag, isTouchDragDevice } from "../utilities/touchDrag";
13
13
 
14
14
  type DraggableItemProps = {
15
15
  aria?: { [key: string]: string };
@@ -27,6 +27,10 @@ type DraggableItemProps = {
27
27
  onDragStart?: () => void,
28
28
  onDrop?: () => void,
29
29
  dragId?: string;
30
+ /** Whole-item pointer drag (e.g. Typeahead pills without a grip). Disables HTML5 drag. */
31
+ pointerDrag?: boolean;
32
+ /** Handle-only pointer drag (e.g. Typeahead pills with a grip). Disables HTML5 drag. */
33
+ handlePointerDrag?: boolean;
30
34
  tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div' | 'tr' | 'th' | 'td' | 'thead' | 'col' | 'tbody',
31
35
  };
32
36
 
@@ -48,6 +52,8 @@ const DraggableItem = (props: DraggableItemProps) => {
48
52
  onDragOver = noop,
49
53
  onDragStart = noop,
50
54
  onDrop = noop,
55
+ pointerDrag = false,
56
+ handlePointerDrag = false,
51
57
  } = props;
52
58
 
53
59
  const {
@@ -59,11 +65,11 @@ const DraggableItem = (props: DraggableItemProps) => {
59
65
  handleDragOver,
60
66
  dropZone = 'ghost',
61
67
  dropZoneColor = 'neutral',
62
- direction = 'horizontal'
63
68
  } = DraggableContext();
64
69
 
65
70
  const itemRef = React.useRef<HTMLElement>(null);
66
71
  const [useTouchDrag, setUseTouchDrag] = React.useState(false);
72
+ const [usePointerMouseDrag, setUsePointerMouseDrag] = React.useState(false);
67
73
  const handlersRef = React.useRef({
68
74
  handleDragStart,
69
75
  handleDragEnter,
@@ -90,9 +96,36 @@ const DraggableItem = (props: DraggableItemProps) => {
90
96
  onDragEnd,
91
97
  };
92
98
 
93
- React.useEffect(() => {
94
- setUseTouchDrag(isTouchDragDevice());
95
- }, []);
99
+ const dragHandlers = React.useMemo(() => ({
100
+ onDragStart: (id: string, itemContainer?: string) => {
101
+ handlersRef.current.handleDragStart(id, itemContainer);
102
+ handlersRef.current.onDragStart();
103
+ },
104
+ onDragEnter: (targetDragId: string, targetContainer?: string) => {
105
+ handlersRef.current.handleDragEnter(targetDragId, targetContainer);
106
+ handlersRef.current.onDragEnter();
107
+ },
108
+ onDragOver: (event: Event, targetContainer?: string) => {
109
+ handlersRef.current.handleDragOver(event, targetContainer);
110
+ handlersRef.current.onDragOver();
111
+ },
112
+ onDrop: (dropContainer?: string) => {
113
+ handlersRef.current.handleDrop(dropContainer);
114
+ handlersRef.current.onDrop();
115
+ },
116
+ onDragEnd: () => {
117
+ handlersRef.current.handleDragEnd();
118
+ handlersRef.current.onDragEnd();
119
+ },
120
+ }), []);
121
+
122
+ React.useLayoutEffect(() => {
123
+ const touchMode = isTouchDragDevice();
124
+
125
+ setUseTouchDrag(touchMode);
126
+ // Pointer drag is opt-in only — regular Draggable items keep HTML5 drag on the whole item.
127
+ setUsePointerMouseDrag(!touchMode && (pointerDrag || handlePointerDrag));
128
+ }, [dragId, container, children, pointerDrag, handlePointerDrag]);
96
129
 
97
130
  React.useEffect(() => {
98
131
  if (!useTouchDrag || !itemRef.current || !dragId) return;
@@ -101,30 +134,21 @@ const DraggableItem = (props: DraggableItemProps) => {
101
134
  dragId,
102
135
  container,
103
136
  itemElement: itemRef.current,
104
- handlers: {
105
- onDragStart: (id, itemContainer) => {
106
- handlersRef.current.handleDragStart(id, itemContainer);
107
- handlersRef.current.onDragStart();
108
- },
109
- onDragEnter: (targetDragId, targetContainer) => {
110
- handlersRef.current.handleDragEnter(targetDragId, targetContainer);
111
- handlersRef.current.onDragEnter();
112
- },
113
- onDragOver: (event, targetContainer) => {
114
- handlersRef.current.handleDragOver(event, targetContainer);
115
- handlersRef.current.onDragOver();
116
- },
117
- onDrop: (dropContainer) => {
118
- handlersRef.current.handleDrop(dropContainer);
119
- handlersRef.current.onDrop();
120
- },
121
- onDragEnd: () => {
122
- handlersRef.current.handleDragEnd();
123
- handlersRef.current.onDragEnd();
124
- },
125
- },
137
+ handlers: dragHandlers,
138
+ });
139
+ }, [useTouchDrag, dragId, container, dragHandlers]);
140
+
141
+ React.useEffect(() => {
142
+ if (!usePointerMouseDrag || !itemRef.current || !dragId) return;
143
+
144
+ return bindMousePointerDrag({
145
+ dragId,
146
+ container,
147
+ itemElement: itemRef.current,
148
+ handlers: dragHandlers,
149
+ allowWholeItem: pointerDrag,
126
150
  });
127
- }, [useTouchDrag, dragId, container]);
151
+ }, [usePointerMouseDrag, dragId, container, dragHandlers, pointerDrag]);
128
152
 
129
153
  const ariaProps = buildAriaProps(aria);
130
154
  const dataProps = buildDataProps(data);
@@ -188,7 +212,7 @@ const DraggableItem = (props: DraggableItemProps) => {
188
212
  {...htmlProps}
189
213
  className={classes}
190
214
  data-pb-drag-id={dragId}
191
- draggable={!useTouchDrag}
215
+ draggable={!useTouchDrag && !usePointerMouseDrag}
192
216
  id={id}
193
217
  key={dragId}
194
218
  onDrag={onDrag}
@@ -35,4 +35,50 @@ describe("touchDrag utilities", () => {
35
35
  const item = document.querySelector(".pb_draggable_item");
36
36
  expect(getContainerFromElement(item)).toBe("To Do");
37
37
  });
38
+
39
+ test("resolvePointerDragTarget uses sibling slots when pointer stays on dragged pill", () => {
40
+ document.body.innerHTML = `
41
+ <div class="pb_draggable_container" data-pb-drag-container="typeahead-pills">
42
+ <div class="pb_draggable_item" data-pb-drag-id="b"></div>
43
+ <div class="pb_draggable_item" data-pb-drag-id="c"></div>
44
+ <div class="pb_draggable_item" data-pb-drag-id="a"></div>
45
+ </div>
46
+ `;
47
+
48
+ const rects = {
49
+ b: { left: 0, width: 100 },
50
+ c: { left: 100, width: 100 },
51
+ a: { left: 200, width: 100 },
52
+ };
53
+
54
+ document.querySelectorAll(".pb_draggable_item").forEach((item) => {
55
+ const id = item.getAttribute("data-pb-drag-id");
56
+ item.getBoundingClientRect = () => ({
57
+ left: rects[id].left,
58
+ width: rects[id].width,
59
+ right: rects[id].left + rects[id].width,
60
+ top: 0,
61
+ bottom: 20,
62
+ height: 20,
63
+ x: rects[id].left,
64
+ y: 0,
65
+ toJSON: () => ({}),
66
+ });
67
+ });
68
+
69
+ const { resolvePointerDragTarget } = require("./utilities/touchDrag");
70
+
71
+ document.elementFromPoint = () => document.querySelector('[data-pb-drag-id="a"]');
72
+ document.elementsFromPoint = () => [document.querySelector('[data-pb-drag-id="a"]')];
73
+
74
+ expect(resolvePointerDragTarget(250, 10, "a")).toEqual({
75
+ targetDragId: null,
76
+ targetContainer: "typeahead-pills",
77
+ });
78
+
79
+ expect(resolvePointerDragTarget(120, 10, "a")).toEqual({
80
+ targetDragId: "c",
81
+ targetContainer: "typeahead-pills",
82
+ });
83
+ });
38
84
  });