playbook_ui 16.10.0.pre.alpha.PLAY3053advancedtablebottompinnedrowsreact17469 → 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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows.jsx +2 -19
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_both.jsx +57 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_both_react.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_bottom.jsx +57 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_bottom_react.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_react.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +3 -1
- data/app/pb_kits/playbook/pb_dialog/_dialog.tsx +18 -3
- data/app/pb_kits/playbook/pb_draggable/_draggable.scss +3 -0
- data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableItem.tsx +53 -29
- data/app/pb_kits/playbook/pb_draggable/touchDrag.test.js +46 -0
- data/app/pb_kits/playbook/pb_draggable/utilities/touchDrag.ts +272 -54
- data/app/pb_kits/playbook/pb_full_screen/_full_screen.scss +15 -0
- data/app/pb_kits/playbook/pb_full_screen/_full_screen.tsx +21 -6
- data/app/pb_kits/playbook/pb_full_screen/context/_full_screen_context.tsx +9 -0
- data/app/pb_kits/playbook/pb_full_screen/docs/_full_screen_table_and_filter.jsx +1 -1
- data/app/pb_kits/playbook/pb_full_screen/docs/_full_screen_table_and_filter.md +1 -1
- data/app/pb_kits/playbook/pb_full_screen/full_screen.test.jsx +17 -0
- data/app/pb_kits/playbook/pb_nav/_item.tsx +3 -2
- data/app/pb_kits/playbook/pb_nav/_nav.tsx +1 -1
- data/app/pb_kits/playbook/pb_nav/docs/_playground.json +117 -213
- data/app/pb_kits/playbook/pb_nav/docs/_playground.overrides.json +127 -319
- data/app/pb_kits/playbook/pb_nav/kit.schema.json +2 -1
- data/app/pb_kits/playbook/pb_nav/navTypes.ts +1 -1
- data/app/pb_kits/playbook/pb_popover/_popover.tsx +13 -8
- data/app/pb_kits/playbook/pb_popover/popover.test.js +36 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.scss +1 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +2 -2
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_error.html.erb +1 -1
- data/app/pb_kits/playbook/pb_title/docs/Title.figma.ts +44 -0
- data/app/pb_kits/playbook/pb_title/docs/Title.figma.tsx +39 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +45 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +144 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +25 -1
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +29 -85
- data/app/pb_kits/playbook/pb_typeahead/components/PillRenderer.tsx +187 -0
- data/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.tsx +236 -10
- data/app/pb_kits/playbook/pb_typeahead/docs/_playground.json +8 -2
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills.html.erb +39 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills.jsx +63 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills.md +7 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills_rails.md +7 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_typeahead/kit.schema.json +24 -0
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +9 -0
- data/app/pb_kits/playbook/utilities/floatingPortalHosts.ts +38 -3
- data/dist/chunks/{_pb_line_graph-C2H9vs_8.js → _pb_line_graph-Gn_9RYbf.js} +1 -1
- data/dist/chunks/{_typeahead-Du8dRYaM.js → _typeahead-DjVWQJpA.js} +2 -2
- data/dist/chunks/{globalProps-DIAZ03-L.js → globalProps-CVEUyQe6.js} +1 -1
- data/dist/chunks/{lib-ZHDedNfP.js → lib-CYrXqTdQ.js} +2 -2
- data/dist/chunks/vendor.js +3 -3
- data/dist/menu.yml +1 -1
- 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 +1 -1
- metadata +18 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3751d64092566ad3cf09621e4f4e79b29dddec14351aef0591f3d2e07e88f94f
|
|
4
|
+
data.tar.gz: c5b899dc4757a061c45705b4502fac3c8312cc99e5ec77f33492df76338f634a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 53da6b3099eefcbc5d00ea84e58c52d6dab20ac28f1fb44d7b604e307d554939758541115851569a8bb6641082c23724c19f0d6be19eb4a2162e4c7db65c4c08
|
|
7
|
+
data.tar.gz: 26a265e2834cf967732666edec0f1ea5f8b34248ef984051aa7b93ca0aa5a73a15e4f04562b74ed1ad35ef83766eee4d15f5f518b5c512a38c8763c0238ac2c1
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { useState } from "react"
|
|
2
2
|
import AdvancedTable from '../_advanced_table'
|
|
3
3
|
import MOCK_DATA_WITH_ID from "./advanced_table_mock_data_with_id.json"
|
|
4
|
-
import Caption from "../../pb_caption/_caption"
|
|
5
4
|
|
|
6
5
|
const AdvancedTableRowPinning = (props) => {
|
|
7
6
|
const columnDefinitions = [
|
|
@@ -36,30 +35,14 @@ const AdvancedTableRowPinning = (props) => {
|
|
|
36
35
|
},
|
|
37
36
|
]
|
|
38
37
|
|
|
39
|
-
const [
|
|
40
|
-
const [pinnedRowsBottom, setPinnedRowsBottom] = useState({bottom: ["8"]})
|
|
38
|
+
const [pinnedRows, setPinnedRows] = useState({top: ["8"]})
|
|
41
39
|
|
|
42
40
|
return (
|
|
43
41
|
<div>
|
|
44
|
-
<Caption text="Pinned Rows Top" />
|
|
45
42
|
<AdvancedTable
|
|
46
43
|
columnDefinitions={columnDefinitions}
|
|
47
44
|
maxHeight="xs"
|
|
48
|
-
pinnedRows={{value:
|
|
49
|
-
tableData={MOCK_DATA_WITH_ID}
|
|
50
|
-
tableProps={{sticky: true}}
|
|
51
|
-
{...props}
|
|
52
|
-
>
|
|
53
|
-
<AdvancedTable.Header enableSorting />
|
|
54
|
-
<AdvancedTable.Body />
|
|
55
|
-
</AdvancedTable>
|
|
56
|
-
<Caption marginTop="md"
|
|
57
|
-
text="Pinned Rows Bottom"
|
|
58
|
-
/>
|
|
59
|
-
<AdvancedTable
|
|
60
|
-
columnDefinitions={columnDefinitions}
|
|
61
|
-
maxHeight="xs"
|
|
62
|
-
pinnedRows={{value: pinnedRowsBottom, onChange: setPinnedRowsBottom}}
|
|
45
|
+
pinnedRows={{value: pinnedRows, onChange: setPinnedRows}}
|
|
63
46
|
tableData={MOCK_DATA_WITH_ID}
|
|
64
47
|
tableProps={{sticky: true}}
|
|
65
48
|
{...props}
|
|
@@ -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.
|
|
@@ -3,5 +3,5 @@ Use the `pinnedRows` prop to pin specific rows to the top or bottom of an Advanc
|
|
|
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` or `bottom` property
|
|
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)
|
|
@@ -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'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable react/jsx-handler-names */
|
|
2
2
|
/* eslint-disable react/no-multi-comp */
|
|
3
3
|
|
|
4
|
-
import React, { useState, useCallback } from "react";
|
|
4
|
+
import React, { useState, useCallback, useContext } from "react";
|
|
5
5
|
import classnames from "classnames";
|
|
6
6
|
import Modal from "react-modal";
|
|
7
7
|
|
|
@@ -17,7 +17,13 @@ import Flex from "../pb_flex/_flex";
|
|
|
17
17
|
import IconCircle from "../pb_icon_circle/_icon_circle";
|
|
18
18
|
import Title from "../pb_title/_title";
|
|
19
19
|
import { DialogContext, DialogContextValue } from "./_dialog_context";
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
PB_FLOATING_OWNER_ATTR,
|
|
22
|
+
PB_MODAL_ABOVE_FULLSCREEN_Z_INDEX,
|
|
23
|
+
isPortaledFloatingKitInteraction,
|
|
24
|
+
resolveFullscreenOverlayForElement,
|
|
25
|
+
} from "../utilities/floatingPortalHosts";
|
|
26
|
+
import { FullScreenContext } from "../pb_full_screen/context/_full_screen_context";
|
|
21
27
|
|
|
22
28
|
type DialogProps = {
|
|
23
29
|
aria?: { [key: string]: string };
|
|
@@ -95,6 +101,15 @@ const Dialog = (props: DialogProps): React.ReactElement => {
|
|
|
95
101
|
|
|
96
102
|
const dynamicInlineProps = globalInlineProps(props);
|
|
97
103
|
|
|
104
|
+
const { active: isInsideFullscreen } = useContext(FullScreenContext);
|
|
105
|
+
|
|
106
|
+
const modalStyles = {
|
|
107
|
+
overlay: isInsideFullscreen
|
|
108
|
+
? { zIndex: PB_MODAL_ABOVE_FULLSCREEN_Z_INDEX }
|
|
109
|
+
: undefined,
|
|
110
|
+
content: dynamicInlineProps,
|
|
111
|
+
};
|
|
112
|
+
|
|
98
113
|
const wrapperClasses = classnames(
|
|
99
114
|
buildCss("pb_dialog_wrapper"),
|
|
100
115
|
);
|
|
@@ -194,7 +209,7 @@ const Dialog = (props: DialogProps): React.ReactElement => {
|
|
|
194
209
|
overlayClassName={overlayClassNames}
|
|
195
210
|
portalClassName={portalClassName}
|
|
196
211
|
shouldCloseOnOverlayClick={shouldCloseOnOverlayClick && !loading}
|
|
197
|
-
style={
|
|
212
|
+
style={modalStyles}
|
|
198
213
|
>
|
|
199
214
|
<div className="pb_dialog_scroll_region">
|
|
200
215
|
{title && !status ? <Dialog.Header closeable={closeable}>{title}</Dialog.Header> : null}
|
|
@@ -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.
|
|
94
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
}, [
|
|
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
|
});
|