no-frills-ui 0.0.14-alpha.0 → 0.0.14-alpha.10
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.
- package/README.md +63 -24
- package/dist/index.js +3550 -4336
- package/dist/index.js.map +1 -1
- package/lib-esm/components/Accordion/Accordion.d.ts +11 -16
- package/lib-esm/components/Accordion/Accordion.js +25 -29
- package/lib-esm/components/Accordion/Accordion.js.map +1 -1
- package/lib-esm/components/Accordion/AccordionStep.d.ts +22 -22
- package/lib-esm/components/Accordion/AccordionStep.js +111 -109
- package/lib-esm/components/Accordion/AccordionStep.js.map +1 -1
- package/lib-esm/components/Badge/Badge.d.ts +13 -16
- package/lib-esm/components/Badge/Badge.js +31 -51
- package/lib-esm/components/Badge/Badge.js.map +1 -1
- package/lib-esm/components/Button/ActionButton.d.ts +9 -5
- package/lib-esm/components/Button/ActionButton.js +18 -38
- package/lib-esm/components/Button/ActionButton.js.map +1 -1
- package/lib-esm/components/Button/Button.d.ts +9 -5
- package/lib-esm/components/Button/Button.js +18 -40
- package/lib-esm/components/Button/Button.js.map +1 -1
- package/lib-esm/components/Button/IconButton.d.ts +9 -5
- package/lib-esm/components/Button/IconButton.js +18 -42
- package/lib-esm/components/Button/IconButton.js.map +1 -1
- package/lib-esm/components/Button/LinkButton.d.ts +9 -5
- package/lib-esm/components/Button/LinkButton.js +18 -32
- package/lib-esm/components/Button/LinkButton.js.map +1 -1
- package/lib-esm/components/Button/RaisedButton.d.ts +9 -5
- package/lib-esm/components/Button/RaisedButton.js +18 -46
- package/lib-esm/components/Button/RaisedButton.js.map +1 -1
- package/lib-esm/components/Card/Card.d.ts +4 -6
- package/lib-esm/components/Card/Card.js +18 -13
- package/lib-esm/components/Card/Card.js.map +1 -1
- package/lib-esm/components/Chip/Chip.d.ts +8 -3
- package/lib-esm/components/Chip/Chip.js +44 -42
- package/lib-esm/components/Chip/Chip.js.map +1 -1
- package/lib-esm/components/ChipInput/ChipInput.d.ts +31 -0
- package/lib-esm/components/ChipInput/ChipInput.js +198 -0
- package/lib-esm/components/ChipInput/ChipInput.js.map +1 -0
- package/lib-esm/components/ChipInput/index.d.ts +1 -0
- package/lib-esm/components/Dialog/AlertDialog.d.ts +11 -12
- package/lib-esm/components/Dialog/AlertDialog.js +44 -28
- package/lib-esm/components/Dialog/AlertDialog.js.map +1 -1
- package/lib-esm/components/Dialog/ConfirmDialog.d.ts +13 -14
- package/lib-esm/components/Dialog/ConfirmDialog.js +49 -33
- package/lib-esm/components/Dialog/ConfirmDialog.js.map +1 -1
- package/lib-esm/components/Dialog/Dialog.d.ts +40 -18
- package/lib-esm/components/Dialog/Dialog.js +125 -70
- package/lib-esm/components/Dialog/Dialog.js.map +1 -1
- package/lib-esm/components/Dialog/PromptDialog.d.ts +18 -19
- package/lib-esm/components/Dialog/PromptDialog.js +78 -49
- package/lib-esm/components/Dialog/PromptDialog.js.map +1 -1
- package/lib-esm/components/DragAndDrop/DragAndDrop.d.ts +43 -14
- package/lib-esm/components/DragAndDrop/DragAndDrop.js +128 -19
- package/lib-esm/components/DragAndDrop/DragAndDrop.js.map +1 -1
- package/lib-esm/components/DragAndDrop/DragItem.d.ts +41 -0
- package/lib-esm/components/DragAndDrop/DragItem.js +253 -36
- package/lib-esm/components/DragAndDrop/DragItem.js.map +1 -1
- package/lib-esm/components/DragAndDrop/types.d.ts +25 -3
- package/lib-esm/components/DragAndDrop/types.js +9 -6
- package/lib-esm/components/DragAndDrop/types.js.map +1 -1
- package/lib-esm/components/Drawer/Drawer.d.ts +86 -22
- package/lib-esm/components/Drawer/Drawer.js +176 -97
- package/lib-esm/components/Drawer/Drawer.js.map +1 -1
- package/lib-esm/components/Drawer/index.d.ts +1 -1
- package/lib-esm/components/Groups/Group.d.ts +5 -8
- package/lib-esm/components/Groups/Group.js +34 -79
- package/lib-esm/components/Groups/Group.js.map +1 -1
- package/lib-esm/components/Groups/GroupLabel.js +8 -17
- package/lib-esm/components/Groups/GroupLabel.js.map +1 -1
- package/lib-esm/components/Input/Checkbox.d.ts +12 -15
- package/lib-esm/components/Input/Checkbox.js +51 -118
- package/lib-esm/components/Input/Checkbox.js.map +1 -1
- package/lib-esm/components/Input/Dropdown.d.ts +11 -12
- package/lib-esm/components/Input/Dropdown.js +133 -52
- package/lib-esm/components/Input/Dropdown.js.map +1 -1
- package/lib-esm/components/Input/Input.d.ts +3 -3
- package/lib-esm/components/Input/Input.js +61 -109
- package/lib-esm/components/Input/Input.js.map +1 -1
- package/lib-esm/components/Input/Radio.d.ts +4 -8
- package/lib-esm/components/Input/Radio.js +35 -79
- package/lib-esm/components/Input/Radio.js.map +1 -1
- package/lib-esm/components/Input/RadioButton.d.ts +4 -8
- package/lib-esm/components/Input/RadioButton.js +34 -71
- package/lib-esm/components/Input/RadioButton.js.map +1 -1
- package/lib-esm/components/Input/Select.d.ts +6 -13
- package/lib-esm/components/Input/Select.js +75 -122
- package/lib-esm/components/Input/Select.js.map +1 -1
- package/lib-esm/components/Input/TextArea.d.ts +6 -13
- package/lib-esm/components/Input/TextArea.js +64 -108
- package/lib-esm/components/Input/TextArea.js.map +1 -1
- package/lib-esm/components/Input/Toggle.d.ts +4 -9
- package/lib-esm/components/Input/Toggle.js +31 -80
- package/lib-esm/components/Input/Toggle.js.map +1 -1
- package/lib-esm/components/Menu/Menu.d.ts +8 -6
- package/lib-esm/components/Menu/Menu.js +116 -31
- package/lib-esm/components/Menu/Menu.js.map +1 -1
- package/lib-esm/components/Menu/MenuContext.d.ts +11 -5
- package/lib-esm/components/Menu/MenuContext.js +6 -2
- package/lib-esm/components/Menu/MenuContext.js.map +1 -1
- package/lib-esm/components/Menu/MenuItem.d.ts +7 -4
- package/lib-esm/components/Menu/MenuItem.js +46 -47
- package/lib-esm/components/Menu/MenuItem.js.map +1 -1
- package/lib-esm/components/Modal/Modal.d.ts +75 -16
- package/lib-esm/components/Modal/Modal.js +150 -51
- package/lib-esm/components/Modal/Modal.js.map +1 -1
- package/lib-esm/components/Notification/Notification.d.ts +46 -39
- package/lib-esm/components/Notification/Notification.js +80 -87
- package/lib-esm/components/Notification/Notification.js.map +1 -1
- package/lib-esm/components/Notification/NotificationManager.d.ts +19 -5
- package/lib-esm/components/Notification/NotificationManager.js +177 -79
- package/lib-esm/components/Notification/NotificationManager.js.map +1 -1
- package/lib-esm/components/Notification/style.d.ts +6 -3
- package/lib-esm/components/Notification/style.js +64 -140
- package/lib-esm/components/Notification/style.js.map +1 -1
- package/lib-esm/components/Notification/types.d.ts +2 -0
- package/lib-esm/components/Notification/types.js +9 -10
- package/lib-esm/components/Notification/types.js.map +1 -1
- package/lib-esm/components/Popover/Popover.d.ts +21 -20
- package/lib-esm/components/Popover/Popover.js +159 -126
- package/lib-esm/components/Popover/Popover.js.map +1 -1
- package/lib-esm/components/Spinner/Spinner.d.ts +14 -12
- package/lib-esm/components/Spinner/Spinner.js +22 -27
- package/lib-esm/components/Spinner/Spinner.js.map +1 -1
- package/lib-esm/components/Stepper/Step.d.ts +15 -12
- package/lib-esm/components/Stepper/Step.js +18 -25
- package/lib-esm/components/Stepper/Step.js.map +1 -1
- package/lib-esm/components/Stepper/Stepper.d.ts +11 -17
- package/lib-esm/components/Stepper/Stepper.js +104 -102
- package/lib-esm/components/Stepper/Stepper.js.map +1 -1
- package/lib-esm/components/Tabs/Tab.d.ts +10 -16
- package/lib-esm/components/Tabs/Tab.js +9 -15
- package/lib-esm/components/Tabs/Tab.js.map +1 -1
- package/lib-esm/components/Tabs/Tabs.d.ts +11 -22
- package/lib-esm/components/Tabs/Tabs.js +97 -55
- package/lib-esm/components/Tabs/Tabs.js.map +1 -1
- package/lib-esm/components/Toast/Toast.d.ts +34 -7
- package/lib-esm/components/Toast/Toast.js +200 -109
- package/lib-esm/components/Toast/Toast.js.map +1 -1
- package/lib-esm/components/Toast/ToastStory.d.ts +21 -24
- package/lib-esm/components/Tooltip/Tooltip.d.ts +11 -14
- package/lib-esm/components/Tooltip/Tooltip.js +52 -67
- package/lib-esm/components/Tooltip/Tooltip.js.map +1 -1
- package/lib-esm/components/index.d.ts +1 -0
- package/lib-esm/components/index.js +43 -20
- package/lib-esm/components/index.js.map +1 -1
- package/lib-esm/icons/CheckCircle.d.ts +1 -1
- package/lib-esm/icons/CheckCircle.js +22 -4
- package/lib-esm/icons/CheckCircle.js.map +1 -1
- package/lib-esm/icons/Close.d.ts +1 -1
- package/lib-esm/icons/Close.js +22 -4
- package/lib-esm/icons/Close.js.map +1 -1
- package/lib-esm/icons/DragIndicator.d.ts +1 -1
- package/lib-esm/icons/DragIndicator.js +22 -4
- package/lib-esm/icons/DragIndicator.js.map +1 -1
- package/lib-esm/icons/ErrorOutline.d.ts +1 -1
- package/lib-esm/icons/ErrorOutline.js +16 -4
- package/lib-esm/icons/ErrorOutline.js.map +1 -1
- package/lib-esm/icons/ExpandMore.d.ts +1 -1
- package/lib-esm/icons/ExpandMore.js +22 -4
- package/lib-esm/icons/ExpandMore.js.map +1 -1
- package/lib-esm/icons/FiberManualRecord.d.ts +1 -1
- package/lib-esm/icons/FiberManualRecord.js +24 -4
- package/lib-esm/icons/FiberManualRecord.js.map +1 -1
- package/lib-esm/icons/Info.d.ts +1 -1
- package/lib-esm/icons/Info.js +22 -4
- package/lib-esm/icons/Info.js.map +1 -1
- package/lib-esm/icons/ReportProblem.d.ts +1 -1
- package/lib-esm/icons/ReportProblem.js +22 -4
- package/lib-esm/icons/ReportProblem.js.map +1 -1
- package/lib-esm/shared/LayerManager.d.ts +34 -4
- package/lib-esm/shared/LayerManager.js +248 -114
- package/lib-esm/shared/LayerManager.js.map +1 -1
- package/lib-esm/shared/constants.d.ts +58 -27
- package/lib-esm/shared/constants.js +62 -26
- package/lib-esm/shared/constants.js.map +1 -1
- package/lib-esm/shared/styles.d.ts +1 -1
- package/lib-esm/shared/styles.js +21 -24
- package/lib-esm/shared/styles.js.map +1 -1
- package/package.json +130 -72
- package/lib-esm/components/Accordion/index.js +0 -3
- package/lib-esm/components/Accordion/index.js.map +0 -1
- package/lib-esm/components/Badge/index.js +0 -2
- package/lib-esm/components/Badge/index.js.map +0 -1
- package/lib-esm/components/Button/index.js +0 -6
- package/lib-esm/components/Button/index.js.map +0 -1
- package/lib-esm/components/Card/index.js +0 -3
- package/lib-esm/components/Card/index.js.map +0 -1
- package/lib-esm/components/Chip/index.js +0 -2
- package/lib-esm/components/Chip/index.js.map +0 -1
- package/lib-esm/components/Dialog/index.js +0 -5
- package/lib-esm/components/Dialog/index.js.map +0 -1
- package/lib-esm/components/DragAndDrop/index.js +0 -3
- package/lib-esm/components/DragAndDrop/index.js.map +0 -1
- package/lib-esm/components/Drawer/index.js +0 -2
- package/lib-esm/components/Drawer/index.js.map +0 -1
- package/lib-esm/components/Groups/index.js +0 -3
- package/lib-esm/components/Groups/index.js.map +0 -1
- package/lib-esm/components/Input/index.js +0 -9
- package/lib-esm/components/Input/index.js.map +0 -1
- package/lib-esm/components/Menu/index.js +0 -3
- package/lib-esm/components/Menu/index.js.map +0 -1
- package/lib-esm/components/Modal/index.js +0 -2
- package/lib-esm/components/Modal/index.js.map +0 -1
- package/lib-esm/components/Notification/index.js +0 -3
- package/lib-esm/components/Notification/index.js.map +0 -1
- package/lib-esm/components/Popover/index.js +0 -2
- package/lib-esm/components/Popover/index.js.map +0 -1
- package/lib-esm/components/Spinner/index.js +0 -2
- package/lib-esm/components/Spinner/index.js.map +0 -1
- package/lib-esm/components/Stepper/index.js +0 -4
- package/lib-esm/components/Stepper/index.js.map +0 -1
- package/lib-esm/components/Tabs/index.js +0 -3
- package/lib-esm/components/Tabs/index.js.map +0 -1
- package/lib-esm/components/Toast/ToastStory.js +0 -35
- package/lib-esm/components/Toast/ToastStory.js.map +0 -1
- package/lib-esm/components/Toast/index.js +0 -2
- package/lib-esm/components/Toast/index.js.map +0 -1
- package/lib-esm/components/Tooltip/index.js +0 -2
- package/lib-esm/components/Tooltip/index.js.map +0 -1
- package/lib-esm/icons/index.js +0 -9
- package/lib-esm/icons/index.js.map +0 -1
- package/lib-esm/index.js +0 -2
- package/lib-esm/index.js.map +0 -1
|
@@ -1,25 +1,134 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs, Fragment, jsx } from '@emotion/react/jsx-runtime';
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
3
|
import styled from '@emotion/styled';
|
|
4
|
-
import DragItem from './DragItem';
|
|
5
|
-
import { ORIENTATION, DragContext } from './types';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
import DragItem from './DragItem.js';
|
|
5
|
+
import { ORIENTATION, DragContext } from './types.js';
|
|
6
|
+
|
|
7
|
+
/** Container Component */ const Container$6 = /*#__PURE__*/ styled("div", {
|
|
8
|
+
target: "ec7q6t50",
|
|
9
|
+
label: "Container"
|
|
10
|
+
})("flex:1;display:flex;position:relative;flex-wrap:wrap;flex-direction:", (props)=>props.orientation === ORIENTATION.HORIZONTAL ? 'row' : 'column', ";");
|
|
11
|
+
/** Visually hidden but accessible to screen readers */ const VisuallyHidden$2 = /*#__PURE__*/ styled("div", {
|
|
12
|
+
target: "ec7q6t51",
|
|
13
|
+
label: "VisuallyHidden"
|
|
14
|
+
})("position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0;");
|
|
15
|
+
/**
|
|
16
|
+
* A drag and drop container component that enables reordering of child elements.
|
|
17
|
+
*
|
|
18
|
+
* @component
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <DragAndDrop
|
|
22
|
+
* orientation={ORIENTATION.VERTICAL}
|
|
23
|
+
* onDrop={(start, end) => handleReorder(start, end)}
|
|
24
|
+
* showIndicator={true}
|
|
25
|
+
* >
|
|
26
|
+
* <div>Item 1</div>
|
|
27
|
+
* <div>Item 2</div>
|
|
28
|
+
* <div>Item 3</div>
|
|
29
|
+
* </DragAndDrop>
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @param props - The component props
|
|
33
|
+
* @param props.orientation - Determines the layout direction (horizontal or vertical). Defaults to VERTICAL.
|
|
34
|
+
* @param props.onDrop - Callback fired when an item is dropped, receives the start and end indices
|
|
35
|
+
* @param props.showIndicator - Whether to display drag indicators for each list item. Defaults to false.
|
|
36
|
+
* @param props.children - Child elements to be rendered as draggable items
|
|
37
|
+
*
|
|
38
|
+
* @returns A draggable container with reorderable items
|
|
39
|
+
*/ function DragAndDropComponent(props, ref) {
|
|
40
|
+
const { orientation = ORIENTATION.VERTICAL, children, onDrop, showIndicator = false, itemAriaLabelTemplate = 'Item {:position}. Press {:grabKey} to grab, {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop', dragHandleAriaLabel = 'Drag to reorder', grabbedAnnouncementTemplate = 'Item {:position} grabbed. Use {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop, {:cancelKey} to cancel', movedAnnouncementTemplate = 'Item moved to position {:position}', droppedAnnouncementTemplate = 'Item dropped at position {:position}', cancelledAnnouncementTemplate = 'Drag cancelled, item restored to original position', ...rest } = props;
|
|
14
41
|
const [startIndex, setStartIndex] = useState(null);
|
|
15
|
-
const
|
|
16
|
-
|
|
42
|
+
const [originalIndex, setOriginalIndex] = useState(null);
|
|
43
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
44
|
+
const [dragOver, setDragOver] = useState(null);
|
|
45
|
+
const [announcement, setAnnouncement] = useState('');
|
|
46
|
+
const childrenArray = React.Children.toArray(children);
|
|
47
|
+
const totalItems = childrenArray.length;
|
|
48
|
+
/**
|
|
49
|
+
* Replace placeholders in i18n templates
|
|
50
|
+
*/ const replacePlaceholders = (template, data)=>{
|
|
51
|
+
return template.replace(/\{:position\}/g, String(data.position ?? '')).replace(/\{:grabKey\}/g, data.grabKey ?? 'Space').replace(/\{:dropKey\}/g, data.dropKey ?? 'Space').replace(/\{:altDropKey\}/g, data.altDropKey ?? 'Enter').replace(/\{:cancelKey\}/g, data.cancelKey ?? 'Escape').replace(/\{:moveKeys\}/g, data.moveKeys ?? (orientation === ORIENTATION.VERTICAL ? 'Arrow Up/Down' : 'Arrow Left/Right'));
|
|
52
|
+
};
|
|
53
|
+
// i18n configuration object
|
|
54
|
+
const i18n = {
|
|
55
|
+
itemAriaLabelTemplate: itemAriaLabelTemplate ?? 'Item {:position}. Press {:grabKey} to grab, {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop',
|
|
56
|
+
dragHandleAriaLabel: dragHandleAriaLabel ?? 'Drag to reorder',
|
|
57
|
+
grabbedAnnouncementTemplate: grabbedAnnouncementTemplate ?? 'Item {:position} grabbed. Use {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop, {:cancelKey} to cancel',
|
|
58
|
+
movedAnnouncementTemplate: movedAnnouncementTemplate ?? 'Item moved to position {:position}',
|
|
59
|
+
droppedAnnouncementTemplate: droppedAnnouncementTemplate ?? 'Item dropped at position {:position}',
|
|
60
|
+
cancelledAnnouncementTemplate: cancelledAnnouncementTemplate ?? 'Drag cancelled, item restored to original position',
|
|
61
|
+
replacePlaceholders
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Drop handler invoked when a draggable item is released.
|
|
65
|
+
* @param index
|
|
66
|
+
*/ const drop = (index)=>{
|
|
67
|
+
if (startIndex !== null && index !== null) {
|
|
68
|
+
onDrop?.(startIndex, index);
|
|
69
|
+
}
|
|
17
70
|
setStartIndex(null);
|
|
71
|
+
setOriginalIndex(null);
|
|
72
|
+
setIsDragging(false);
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Cancel handler to restore item to original position
|
|
76
|
+
*/ const cancel = ()=>{
|
|
77
|
+
if (originalIndex !== null && startIndex !== null && startIndex !== originalIndex) {
|
|
78
|
+
onDrop?.(startIndex, originalIndex);
|
|
79
|
+
}
|
|
80
|
+
setStartIndex(null);
|
|
81
|
+
setOriginalIndex(null);
|
|
82
|
+
setIsDragging(false);
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Start grab handler to track original position
|
|
86
|
+
*/ const startGrab = (index)=>{
|
|
87
|
+
setStartIndex(index);
|
|
88
|
+
setOriginalIndex(index);
|
|
89
|
+
setIsDragging(true);
|
|
18
90
|
};
|
|
19
|
-
return
|
|
91
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
92
|
+
children: [
|
|
93
|
+
/*#__PURE__*/ jsx(DragContext.Provider, {
|
|
94
|
+
value: {
|
|
95
|
+
startIndex,
|
|
96
|
+
setStartIndex,
|
|
97
|
+
drop,
|
|
98
|
+
onDrop,
|
|
99
|
+
cancel,
|
|
100
|
+
startGrab,
|
|
101
|
+
isDragging,
|
|
102
|
+
setIsDragging,
|
|
103
|
+
setDragOver,
|
|
104
|
+
i18n
|
|
105
|
+
},
|
|
106
|
+
children: /*#__PURE__*/ jsx(Container$6, {
|
|
107
|
+
...rest,
|
|
108
|
+
ref: ref,
|
|
109
|
+
orientation: orientation,
|
|
110
|
+
role: "list",
|
|
111
|
+
children: React.Children.map(childrenArray, (child, index)=>/*#__PURE__*/ jsx(DragItem, {
|
|
112
|
+
index: index,
|
|
113
|
+
orientation: orientation,
|
|
114
|
+
showIndicator: showIndicator,
|
|
115
|
+
dragOver: dragOver,
|
|
116
|
+
totalItems: totalItems,
|
|
117
|
+
setAnnouncement: setAnnouncement,
|
|
118
|
+
children: child
|
|
119
|
+
}))
|
|
120
|
+
})
|
|
121
|
+
}),
|
|
122
|
+
/*#__PURE__*/ jsx(VisuallyHidden$2, {
|
|
123
|
+
role: "status",
|
|
124
|
+
"aria-live": "polite",
|
|
125
|
+
"aria-atomic": "true",
|
|
126
|
+
children: announcement
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
});
|
|
20
130
|
}
|
|
21
|
-
DragAndDrop
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
//# sourceMappingURL=DragAndDrop.js.map
|
|
131
|
+
const DragAndDrop = /*#__PURE__*/ React.forwardRef(DragAndDropComponent);
|
|
132
|
+
|
|
133
|
+
export { DragAndDrop as default };
|
|
134
|
+
//# sourceMappingURL=DragAndDrop.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragAndDrop.js","sourceRoot":"","sources":["../../../src/components/DragAndDrop/DragAndDrop.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAqB,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAWnD,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAA4B;;;;sBAIlC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,KAAK,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ;CAC7F,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,KAAuB;IACvD,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;IAC/D,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAS,IAAI,CAAC,CAAC;IAE3D,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,EAAE;QAC3B,UAAU,KAAK,IAAI,KAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,UAAU,EAAE,KAAK,CAAC,CAAA,CAAC;QACnD,aAAa,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC,CAAA;IAED,OAAO,CAAC,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,UAAU,EAAE,aAAa,EAAE,IAAI,EAAE,YACpE,KAAC,SAAS,IAAC,WAAW,EAAE,WAAW,YAC9B,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAC5C,KAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,YACzE,KAAK,GACC,CACd,CAAC,GACM,GACO,CAAC,CAAC;AAC7B,CAAC;AAED,WAAW,CAAC,YAAY,GAAG;IACvB,WAAW,EAAE,WAAW,CAAC,QAAQ;IACjC,aAAa,EAAE,KAAK;CACvB,CAAA"}
|
|
1
|
+
{"version":3,"file":"DragAndDrop.js","sources":["../../../src/components/DragAndDrop/DragAndDrop.tsx"],"sourcesContent":["import React, { PropsWithChildren, useState } from 'react';\nimport styled from '@emotion/styled';\nimport DragItem from './DragItem';\nimport { ORIENTATION, DragContext } from './types';\n\ntype DragAndDropProps = {\n /**\n * Orientation of the list layout\n * @default ORIENTATION.VERTICAL\n */\n orientation?: ORIENTATION;\n /** Drop event handler */\n onDrop: (start: number, end: number) => void;\n /** Shows drag indicator against each list item\n * @default false\n */\n showIndicator?: boolean;\n /**\n * i18n: Template for item aria-label. Placeholders: {:position}, {:grabKey}, {:moveKeys}, {:dropKey}, {:altDropKey}\n * @default 'Item {:position}. Press {:grabKey} to grab, {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop'\n */\n itemAriaLabelTemplate?: string;\n /** i18n: Aria label for drag handle\n * @default 'Drag to reorder'\n */\n dragHandleAriaLabel?: string;\n /**\n * i18n: Template for grabbed announcement. Placeholders: {:position}, {:moveKeys}, {:dropKey}, {:altDropKey}, {:cancelKey}\n * @default 'Item {:position} grabbed. Use {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop, {:cancelKey} to cancel'\n */\n grabbedAnnouncementTemplate?: string;\n /**\n * i18n: Template for moved announcement. Placeholders: {:position}\n * @default 'Item moved to position {:position}'\n */\n movedAnnouncementTemplate?: string;\n /**\n * i18n: Template for dropped announcement. Placeholders: {:position}\n * @default 'Item dropped at position {:position}'\n */\n droppedAnnouncementTemplate?: string;\n /**\n * i18n: Template for cancelled announcement\n * @default 'Drag cancelled, item restored to original position'\n */\n cancelledAnnouncementTemplate?: string;\n} & PropsWithChildren<unknown>;\n\n/** Container Component */\nconst Container = styled.div<{ orientation: ORIENTATION }>`\n flex: 1;\n display: flex;\n position: relative;\n flex-wrap: wrap;\n flex-direction: ${(props) => (props.orientation === ORIENTATION.HORIZONTAL ? 'row' : 'column')};\n`;\n\n/** Visually hidden but accessible to screen readers */\nconst VisuallyHidden = styled.div`\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border-width: 0;\n`;\n\n/**\n * A drag and drop container component that enables reordering of child elements.\n *\n * @component\n * @example\n * ```tsx\n * <DragAndDrop\n * orientation={ORIENTATION.VERTICAL}\n * onDrop={(start, end) => handleReorder(start, end)}\n * showIndicator={true}\n * >\n * <div>Item 1</div>\n * <div>Item 2</div>\n * <div>Item 3</div>\n * </DragAndDrop>\n * ```\n *\n * @param props - The component props\n * @param props.orientation - Determines the layout direction (horizontal or vertical). Defaults to VERTICAL.\n * @param props.onDrop - Callback fired when an item is dropped, receives the start and end indices\n * @param props.showIndicator - Whether to display drag indicators for each list item. Defaults to false.\n * @param props.children - Child elements to be rendered as draggable items\n *\n * @returns A draggable container with reorderable items\n */\nfunction DragAndDropComponent(props: DragAndDropProps, ref: React.Ref<HTMLDivElement>) {\n const {\n orientation = ORIENTATION.VERTICAL,\n children,\n onDrop,\n showIndicator = false,\n itemAriaLabelTemplate = 'Item {:position}. Press {:grabKey} to grab, {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop',\n dragHandleAriaLabel = 'Drag to reorder',\n grabbedAnnouncementTemplate = 'Item {:position} grabbed. Use {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop, {:cancelKey} to cancel',\n movedAnnouncementTemplate = 'Item moved to position {:position}',\n droppedAnnouncementTemplate = 'Item dropped at position {:position}',\n cancelledAnnouncementTemplate = 'Drag cancelled, item restored to original position',\n ...rest\n } = props;\n const [startIndex, setStartIndex] = useState<number | null>(null);\n const [originalIndex, setOriginalIndex] = useState<number | null>(null);\n const [isDragging, setIsDragging] = useState<boolean>(false);\n const [dragOver, setDragOver] = useState<number | null>(null);\n const [announcement, setAnnouncement] = useState<string | undefined>('');\n const childrenArray = React.Children.toArray(children);\n const totalItems = childrenArray.length;\n\n /**\n * Replace placeholders in i18n templates\n */\n const replacePlaceholders = (\n template: string,\n data: {\n position?: number;\n grabKey?: string;\n dropKey?: string;\n altDropKey?: string;\n cancelKey?: string;\n moveKeys?: string;\n },\n ): string => {\n return template\n .replace(/\\{:position\\}/g, String(data.position ?? ''))\n .replace(/\\{:grabKey\\}/g, data.grabKey ?? 'Space')\n .replace(/\\{:dropKey\\}/g, data.dropKey ?? 'Space')\n .replace(/\\{:altDropKey\\}/g, data.altDropKey ?? 'Enter')\n .replace(/\\{:cancelKey\\}/g, data.cancelKey ?? 'Escape')\n .replace(\n /\\{:moveKeys\\}/g,\n data.moveKeys ??\n (orientation === ORIENTATION.VERTICAL ? 'Arrow Up/Down' : 'Arrow Left/Right'),\n );\n };\n\n // i18n configuration object\n const i18n = {\n itemAriaLabelTemplate:\n itemAriaLabelTemplate ??\n 'Item {:position}. Press {:grabKey} to grab, {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop',\n dragHandleAriaLabel: dragHandleAriaLabel ?? 'Drag to reorder',\n grabbedAnnouncementTemplate:\n grabbedAnnouncementTemplate ??\n 'Item {:position} grabbed. Use {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop, {:cancelKey} to cancel',\n movedAnnouncementTemplate:\n movedAnnouncementTemplate ?? 'Item moved to position {:position}',\n droppedAnnouncementTemplate:\n droppedAnnouncementTemplate ?? 'Item dropped at position {:position}',\n cancelledAnnouncementTemplate:\n cancelledAnnouncementTemplate ?? 'Drag cancelled, item restored to original position',\n replacePlaceholders,\n };\n\n /**\n * Drop handler invoked when a draggable item is released.\n * @param index\n */\n const drop = (index: number | null) => {\n if (startIndex !== null && index !== null) {\n onDrop?.(startIndex, index);\n }\n setStartIndex(null);\n setOriginalIndex(null);\n setIsDragging(false);\n };\n\n /**\n * Cancel handler to restore item to original position\n */\n const cancel = () => {\n if (originalIndex !== null && startIndex !== null && startIndex !== originalIndex) {\n onDrop?.(startIndex, originalIndex);\n }\n setStartIndex(null);\n setOriginalIndex(null);\n setIsDragging(false);\n };\n\n /**\n * Start grab handler to track original position\n */\n const startGrab = (index: number) => {\n setStartIndex(index);\n setOriginalIndex(index);\n setIsDragging(true);\n };\n\n return (\n <>\n <DragContext.Provider\n value={{\n startIndex,\n setStartIndex,\n drop,\n onDrop,\n cancel,\n startGrab,\n isDragging,\n setIsDragging,\n setDragOver,\n i18n,\n }}\n >\n <Container {...rest} ref={ref} orientation={orientation} role=\"list\">\n {React.Children.map(childrenArray, (child, index) => (\n <DragItem\n index={index}\n orientation={orientation}\n showIndicator={showIndicator}\n dragOver={dragOver}\n totalItems={totalItems}\n setAnnouncement={setAnnouncement}\n >\n {child}\n </DragItem>\n ))}\n </Container>\n </DragContext.Provider>\n <VisuallyHidden role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">\n {announcement}\n </VisuallyHidden>\n </>\n );\n}\n\nconst DragAndDrop = React.forwardRef(DragAndDropComponent);\nexport default DragAndDrop;\n"],"names":["Container","styled","props","orientation","ORIENTATION","HORIZONTAL","VisuallyHidden","DragAndDropComponent","ref","VERTICAL","children","onDrop","showIndicator","itemAriaLabelTemplate","dragHandleAriaLabel","grabbedAnnouncementTemplate","movedAnnouncementTemplate","droppedAnnouncementTemplate","cancelledAnnouncementTemplate","rest","startIndex","setStartIndex","useState","originalIndex","setOriginalIndex","isDragging","setIsDragging","dragOver","setDragOver","announcement","setAnnouncement","childrenArray","React","Children","toArray","totalItems","length","replacePlaceholders","template","data","replace","String","position","grabKey","dropKey","altDropKey","cancelKey","moveKeys","i18n","drop","index","cancel","startGrab","_jsxs","_Fragment","_jsx","DragContext","Provider","value","role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C7B,eAAe,CAAC8B,KAAAA,EAAOX,sBACvCK,GAAA,CAACO,QAAAA,EAAAA;4BACGZ,KAAAA,EAAOA,KAAAA;4BACP/C,WAAAA,EAAaA,WAAAA;4BACbS,aAAAA,EAAeA,aAAAA;4BACfe,QAAAA,EAAUA,QAAAA;4BACVQ,UAAAA,EAAYA,UAAAA;4BACZL,eAAAA,EAAiBA,eAAAA;AAEhB+B,4BAAAA,QAAAA,EAAAA;;;;0BAKjBN,GAAA,CAACjD,gBAAAA,EAAAA;gBAAeqD,IAAAA,EAAK,QAAA;gBAASI,WAAAA,EAAU,QAAA;gBAASC,aAAAA,EAAY,MAAA;AACxDnC,gBAAAA,QAAAA,EAAAA;;;;AAIjB;AAEA,MAAMoC,WAAAA,iBAAcjC,KAAAA,CAAMkC,UAAU,CAAC3D,oBAAAA;;;;"}
|
|
@@ -1,9 +1,50 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
2
|
import { ORIENTATION } from './types';
|
|
3
3
|
interface DragItemProps {
|
|
4
|
+
/** Position index of the draggable item */
|
|
4
5
|
index: number;
|
|
6
|
+
/** Orientation of the drag operation (VERTICAL or HORIZONTAL) */
|
|
5
7
|
orientation: ORIENTATION;
|
|
8
|
+
/** Whether to show a drag handle indicator instead of making the entire item draggable */
|
|
6
9
|
showIndicator: boolean;
|
|
10
|
+
/** The index of the item currently being dragged over */
|
|
11
|
+
dragOver: number | null;
|
|
12
|
+
/** Total number of items in the list */
|
|
13
|
+
totalItems: number;
|
|
14
|
+
/** Callback to set announcement for screen readers */
|
|
15
|
+
setAnnouncement: (message?: string) => void;
|
|
7
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* A draggable item component that supports both mouse and touch interactions for drag-and-drop functionality.
|
|
19
|
+
*
|
|
20
|
+
* @component
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* <DragItem
|
|
24
|
+
* index={0}
|
|
25
|
+
* orientation={ORIENTATION.VERTICAL}
|
|
26
|
+
* showIndicator={true}
|
|
27
|
+
* dragOver={-1}
|
|
28
|
+
* >
|
|
29
|
+
* <div>Draggable content</div>
|
|
30
|
+
* </DragItem>
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @param props - The component props
|
|
34
|
+
* @param props.index - The position index of this item in the draggable list
|
|
35
|
+
* @param props.orientation - The orientation of the drag operation (VERTICAL or HORIZONTAL)
|
|
36
|
+
* @param props.showIndicator - Whether to show a drag handle indicator instead of making the entire item draggable
|
|
37
|
+
* @param props.dragOver - The index of the item currently being dragged over
|
|
38
|
+
* @param props.children - The content to be rendered inside the draggable item
|
|
39
|
+
*
|
|
40
|
+
* @remarks
|
|
41
|
+
* - Uses the DragContext to manage drag state across items
|
|
42
|
+
* - Provides visual feedback with borders during drag operations
|
|
43
|
+
* - Supports haptic feedback (vibration) on touch devices
|
|
44
|
+
* - For touch devices, requires a 200ms hold before drag starts
|
|
45
|
+
* - When showIndicator is true, only the drag handle can initiate drag operations
|
|
46
|
+
*
|
|
47
|
+
* @returns A draggable item with optional drag indicator and visual feedback
|
|
48
|
+
*/
|
|
8
49
|
export default function DragItem(props: PropsWithChildren<DragItemProps>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
9
50
|
export {};
|
|
@@ -1,49 +1,266 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useContext,
|
|
1
|
+
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
2
|
+
import { useState, useRef, useContext, useEffect } from 'react';
|
|
3
3
|
import styled from '@emotion/styled';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
4
|
+
import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
|
|
5
|
+
import { DragContext, ORIENTATION } from './types.js';
|
|
6
|
+
import CheckCircle from '../../icons/DragIndicator.js';
|
|
7
|
+
|
|
8
|
+
/** Styled component for the draggable item container */ const Item = /*#__PURE__*/ styled("div", {
|
|
9
|
+
target: "ertl9d70",
|
|
10
|
+
label: "Item"
|
|
11
|
+
})("cursor:", (props)=>props.showIndicator ? 'default' : 'move', ";display:flex;user-select:", (props)=>props.showIndicator ? 'auto' : 'none', ";border-top:2px dashed\n ", (props)=>props.orientation === ORIENTATION.VERTICAL && props.active !== null && props.active > 0 ? getThemeValue(THEME_NAME.PRIMARY) : 'transparent', ";border-bottom:2px dashed\n ", (props)=>props.orientation === ORIENTATION.VERTICAL && props.active !== null && props.active < 0 ? getThemeValue(THEME_NAME.PRIMARY) : 'transparent', ";border-left:2px dashed\n ", (props)=>props.orientation === ORIENTATION.HORIZONTAL && props.active !== null && props.active > 0 ? getThemeValue(THEME_NAME.PRIMARY) : 'transparent', ";border-right:2px dashed\n ", (props)=>props.orientation === ORIENTATION.HORIZONTAL && props.active !== null && props.active < 0 ? getThemeValue(THEME_NAME.PRIMARY) : 'transparent', ";opacity:", (props)=>props.dragging ? 0.5 : 1, ";border-radius:10px;&:focus{box-shadow:0 0 0 4px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";}&:focus:not(:focus-visible){box-shadow:none;}&:focus-visible{box-shadow:0 0 0 4px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";}");
|
|
12
|
+
/** Styled component for the drag handle indicator */ const DragKnob = /*#__PURE__*/ styled("div", {
|
|
13
|
+
target: "ertl9d71",
|
|
14
|
+
label: "DragKnob"
|
|
15
|
+
})("padding-top:8px;cursor:move;touch-action:none;color:", getThemeValue(THEME_NAME.DISABLED), ";");
|
|
16
|
+
/** Container for the children */ const Container$7 = /*#__PURE__*/ styled("div", {
|
|
17
|
+
target: "ertl9d72",
|
|
18
|
+
label: "Container"
|
|
19
|
+
})("flex:1;");
|
|
20
|
+
/**
|
|
21
|
+
* A draggable item component that supports both mouse and touch interactions for drag-and-drop functionality.
|
|
22
|
+
*
|
|
23
|
+
* @component
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <DragItem
|
|
27
|
+
* index={0}
|
|
28
|
+
* orientation={ORIENTATION.VERTICAL}
|
|
29
|
+
* showIndicator={true}
|
|
30
|
+
* dragOver={-1}
|
|
31
|
+
* >
|
|
32
|
+
* <div>Draggable content</div>
|
|
33
|
+
* </DragItem>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @param props - The component props
|
|
37
|
+
* @param props.index - The position index of this item in the draggable list
|
|
38
|
+
* @param props.orientation - The orientation of the drag operation (VERTICAL or HORIZONTAL)
|
|
39
|
+
* @param props.showIndicator - Whether to show a drag handle indicator instead of making the entire item draggable
|
|
40
|
+
* @param props.dragOver - The index of the item currently being dragged over
|
|
41
|
+
* @param props.children - The content to be rendered inside the draggable item
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* - Uses the DragContext to manage drag state across items
|
|
45
|
+
* - Provides visual feedback with borders during drag operations
|
|
46
|
+
* - Supports haptic feedback (vibration) on touch devices
|
|
47
|
+
* - For touch devices, requires a 200ms hold before drag starts
|
|
48
|
+
* - When showIndicator is true, only the drag handle can initiate drag operations
|
|
49
|
+
*
|
|
50
|
+
* @returns A draggable item with optional drag indicator and visual feedback
|
|
51
|
+
*/ function DragItem(props) {
|
|
52
|
+
const { index, orientation, children, showIndicator, dragOver, totalItems, setAnnouncement } = props;
|
|
29
53
|
const [active, setActive] = useState(0);
|
|
54
|
+
const touchTimerRef = useRef(null);
|
|
30
55
|
const context = useContext(DragContext);
|
|
31
|
-
|
|
32
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Vibrate the device for haptic feedback
|
|
58
|
+
* @param duration Duration of the vibration in milliseconds
|
|
59
|
+
*/ const vibrate = (duration)=>{
|
|
60
|
+
if (navigator.vibrate) {
|
|
61
|
+
navigator.vibrate(duration);
|
|
62
|
+
}
|
|
33
63
|
};
|
|
34
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Drag start event handler
|
|
66
|
+
* @param e Event
|
|
67
|
+
*/ const dragStartHandler = ()=>{
|
|
68
|
+
context?.setStartIndex(index);
|
|
69
|
+
context?.setIsDragging(true);
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Drag over event handler
|
|
73
|
+
* @param e Event
|
|
74
|
+
*/ const dragOverHandler = (e)=>{
|
|
35
75
|
e.preventDefault();
|
|
36
76
|
e.stopPropagation();
|
|
37
|
-
|
|
77
|
+
if (context && context.startIndex !== null) {
|
|
78
|
+
setActive(context.startIndex - index);
|
|
79
|
+
}
|
|
38
80
|
};
|
|
39
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Drag leave event handler
|
|
83
|
+
*/ const dragExitHandler = ()=>{
|
|
40
84
|
setActive(0);
|
|
41
85
|
};
|
|
42
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Drop event handler
|
|
88
|
+
* @param e Event
|
|
89
|
+
*/ const dropHandler = (e)=>{
|
|
43
90
|
e.preventDefault();
|
|
44
91
|
setActive(0);
|
|
45
|
-
context
|
|
92
|
+
context?.drop(index);
|
|
93
|
+
context?.setIsDragging(false);
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Touch start event handler
|
|
97
|
+
* @param e Event
|
|
98
|
+
*/ const touchStartHandler = ()=>{
|
|
99
|
+
// Clear any existing timer first
|
|
100
|
+
if (touchTimerRef.current) {
|
|
101
|
+
clearTimeout(touchTimerRef.current);
|
|
102
|
+
}
|
|
103
|
+
touchTimerRef.current = setTimeout(()=>{
|
|
104
|
+
context?.setStartIndex(index);
|
|
105
|
+
context?.setIsDragging(true);
|
|
106
|
+
context?.setDragOver(index);
|
|
107
|
+
document.body.style.overflow = 'hidden';
|
|
108
|
+
vibrate(50);
|
|
109
|
+
}, 200);
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Touch move event handler
|
|
113
|
+
* @param e Event
|
|
114
|
+
* @returns void
|
|
115
|
+
*/ const touchMoveHandler = (e)=>{
|
|
116
|
+
const touch = e.touches[0];
|
|
117
|
+
if (!touch) return;
|
|
118
|
+
if (context?.isDragging) {
|
|
119
|
+
e.preventDefault();
|
|
120
|
+
// get the element under the touch point
|
|
121
|
+
const el = document.elementFromPoint(touch.clientX, touch.clientY);
|
|
122
|
+
const overAttr = el?.closest('[data-drag-index]')?.getAttribute('data-drag-index');
|
|
123
|
+
const overIndex = overAttr != null ? parseInt(overAttr, 10) : null;
|
|
124
|
+
// if we know which index we're over, update visual state
|
|
125
|
+
if (overIndex !== null) {
|
|
126
|
+
context?.setDragOver(overIndex);
|
|
127
|
+
}
|
|
128
|
+
} else if (touchTimerRef.current) {
|
|
129
|
+
clearTimeout(touchTimerRef.current);
|
|
130
|
+
touchTimerRef.current = null;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Touch end event handler
|
|
135
|
+
* @param e Event
|
|
136
|
+
*/ const touchEndHandler = ()=>{
|
|
137
|
+
if (touchTimerRef.current) {
|
|
138
|
+
clearTimeout(touchTimerRef.current);
|
|
139
|
+
touchTimerRef.current = null;
|
|
140
|
+
}
|
|
141
|
+
if (context?.isDragging) {
|
|
142
|
+
context?.drop(dragOver);
|
|
143
|
+
vibrate(50);
|
|
144
|
+
context?.setIsDragging(false);
|
|
145
|
+
document.body.style.overflow = 'auto';
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Keyboard navigation handler for reordering items
|
|
150
|
+
* @param e Keyboard event
|
|
151
|
+
*/ const handleKeyDown = (e)=>{
|
|
152
|
+
const isVertical = orientation === ORIENTATION.VERTICAL;
|
|
153
|
+
const moveUp = isVertical ? 'ArrowUp' : 'ArrowLeft';
|
|
154
|
+
const moveDown = isVertical ? 'ArrowDown' : 'ArrowRight';
|
|
155
|
+
const isGrabbed = context?.isDragging && context?.startIndex === index;
|
|
156
|
+
// Space to grab/drop
|
|
157
|
+
if (e.key === ' ' || e.key === 'Spacebar') {
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
if (isGrabbed) {
|
|
160
|
+
// Drop at current position
|
|
161
|
+
context?.drop(index);
|
|
162
|
+
setAnnouncement(context?.i18n.replacePlaceholders(context?.i18n.droppedAnnouncementTemplate, {
|
|
163
|
+
position: index + 1
|
|
164
|
+
}));
|
|
165
|
+
} else {
|
|
166
|
+
// Grab item
|
|
167
|
+
context?.startGrab(index);
|
|
168
|
+
setAnnouncement(context?.i18n.replacePlaceholders(context?.i18n.grabbedAnnouncementTemplate, {
|
|
169
|
+
position: index + 1
|
|
170
|
+
}));
|
|
171
|
+
}
|
|
172
|
+
} else if (e.key === 'Enter' && isGrabbed) {
|
|
173
|
+
e.preventDefault();
|
|
174
|
+
context?.drop(index);
|
|
175
|
+
setAnnouncement(context?.i18n.replacePlaceholders(context?.i18n.droppedAnnouncementTemplate, {
|
|
176
|
+
position: index + 1
|
|
177
|
+
}));
|
|
178
|
+
} else if (e.key === 'Escape' && isGrabbed) {
|
|
179
|
+
e.preventDefault();
|
|
180
|
+
context?.cancel();
|
|
181
|
+
setAnnouncement(context?.i18n.cancelledAnnouncementTemplate);
|
|
182
|
+
} else if (isGrabbed) {
|
|
183
|
+
if (e.key === moveUp && index > 0 && context.startIndex !== null) {
|
|
184
|
+
e.preventDefault();
|
|
185
|
+
// Move without dropping - just reorder and update startIndex
|
|
186
|
+
const newIndex = index - 1;
|
|
187
|
+
context.onDrop(context.startIndex, newIndex);
|
|
188
|
+
context.setStartIndex(newIndex);
|
|
189
|
+
setAnnouncement(context.i18n.replacePlaceholders(context.i18n.movedAnnouncementTemplate, {
|
|
190
|
+
position: newIndex + 1
|
|
191
|
+
}));
|
|
192
|
+
} else if (e.key === moveDown && index < totalItems - 1 && context.startIndex !== null) {
|
|
193
|
+
e.preventDefault();
|
|
194
|
+
// Move without dropping - just reorder and update startIndex
|
|
195
|
+
const newIndex = index + 1;
|
|
196
|
+
context.onDrop(context.startIndex, newIndex);
|
|
197
|
+
context.setStartIndex(newIndex);
|
|
198
|
+
setAnnouncement(context.i18n.replacePlaceholders(context.i18n.movedAnnouncementTemplate, {
|
|
199
|
+
position: newIndex + 1
|
|
200
|
+
}));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
46
203
|
};
|
|
47
|
-
|
|
204
|
+
/** Cleanup touch timer and body overflow on unmount */ useEffect(()=>{
|
|
205
|
+
return ()=>{
|
|
206
|
+
if (touchTimerRef.current) {
|
|
207
|
+
clearTimeout(touchTimerRef.current);
|
|
208
|
+
touchTimerRef.current = null;
|
|
209
|
+
}
|
|
210
|
+
document.body.style.overflow = 'auto';
|
|
211
|
+
};
|
|
212
|
+
}, []);
|
|
213
|
+
/** Update active state based on dragOver changes */ useEffect(()=>{
|
|
214
|
+
if (context?.isDragging && context?.startIndex !== null && dragOver === index) {
|
|
215
|
+
setActive(context?.startIndex - index);
|
|
216
|
+
} else {
|
|
217
|
+
setActive(0);
|
|
218
|
+
}
|
|
219
|
+
}, [
|
|
220
|
+
dragOver,
|
|
221
|
+
context?.startIndex,
|
|
222
|
+
index,
|
|
223
|
+
context?.isDragging
|
|
224
|
+
]);
|
|
225
|
+
return /*#__PURE__*/ jsxs(Item, {
|
|
226
|
+
draggable: !showIndicator,
|
|
227
|
+
showIndicator: showIndicator,
|
|
228
|
+
active: active,
|
|
229
|
+
dragging: !!(context?.isDragging && context.startIndex === index),
|
|
230
|
+
orientation: orientation,
|
|
231
|
+
"data-drag-index": index,
|
|
232
|
+
tabIndex: 0,
|
|
233
|
+
role: "listitem",
|
|
234
|
+
"aria-label": context?.i18n.replacePlaceholders(context.i18n.itemAriaLabelTemplate, {
|
|
235
|
+
position: index + 1
|
|
236
|
+
}),
|
|
237
|
+
"aria-grabbed": context?.isDragging && context.startIndex === index,
|
|
238
|
+
onKeyDown: handleKeyDown,
|
|
239
|
+
onDragStart: !showIndicator ? dragStartHandler : undefined,
|
|
240
|
+
onDragOver: dragOverHandler,
|
|
241
|
+
onDragLeave: dragExitHandler,
|
|
242
|
+
onDrop: dropHandler,
|
|
243
|
+
onTouchStart: !showIndicator ? touchStartHandler : undefined,
|
|
244
|
+
onTouchMove: touchMoveHandler,
|
|
245
|
+
onTouchEnd: touchEndHandler,
|
|
246
|
+
onTouchCancel: touchEndHandler,
|
|
247
|
+
children: [
|
|
248
|
+
showIndicator && /*#__PURE__*/ jsx(DragKnob, {
|
|
249
|
+
draggable: true,
|
|
250
|
+
role: "button",
|
|
251
|
+
"aria-label": context?.i18n.dragHandleAriaLabel,
|
|
252
|
+
onDragStart: dragStartHandler,
|
|
253
|
+
onTouchStart: touchStartHandler,
|
|
254
|
+
onKeyDown: handleKeyDown,
|
|
255
|
+
tabIndex: -1,
|
|
256
|
+
children: /*#__PURE__*/ jsx(CheckCircle, {})
|
|
257
|
+
}),
|
|
258
|
+
/*#__PURE__*/ jsx(Container$7, {
|
|
259
|
+
children: children
|
|
260
|
+
})
|
|
261
|
+
]
|
|
262
|
+
});
|
|
48
263
|
}
|
|
49
|
-
|
|
264
|
+
|
|
265
|
+
export { DragItem as default };
|
|
266
|
+
//# sourceMappingURL=DragItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragItem.js","sourceRoot":"","sources":["../../../src/components/DragAndDrop/DragItem.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAuC,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzF,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAQ5C,MAAM,IAAI,GAAG,MAAM,CAAC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AC;IAExC,MAAM,gBAAgB,GAAqC,CAAC,CAAC,EAAE,EAAE;QAC7D,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC,CAAA;IAED,MAAM,eAAe,GAAqC,CAAC,CAAC,EAAE,EAAE;QAC5D,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,CAAC,CAAC,eAAe,EAAE,CAAC;QACpB,SAAS,CAAC,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC;IAC1C,CAAC,CAAA;IAED,MAAM,eAAe,GAAqC,GAAG,EAAE;QAC3D,SAAS,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC,CAAA;IAED,MAAM,WAAW,GAAqC,CAAC,CAAC,EAAE,EAAE;QACxD,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,SAAS,CAAC,CAAC,CAAC,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC,CAAA;IAED,OAAO,MAAC,IAAI,IACR,SAAS,EAAE,CAAC,aAAa,EACzB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,CAAC,aAAa,IAAI,gBAAgB,EAC/C,UAAU,EAAE,eAAe,EAC3B,WAAW,EAAE,eAAe,EAC5B,MAAM,EAAE,WAAW,aAElB,aAAa,IAAI,KAAC,QAAQ,IACvB,SAAS,QACT,WAAW,EAAE,gBAAgB,YAChC,KAAC,aAAa,KAAG,GAAW,EAC7B,KAAC,SAAS,cAAE,QAAQ,GAAa,IAC9B,CAAC;AACZ,CAAC"}
|
|
1
|
+
{"version":3,"file":"DragItem.js","sources":["../../../src/components/DragAndDrop/DragItem.tsx"],"sourcesContent":["import {\n DragEventHandler,\n PropsWithChildren,\n useContext,\n useState,\n useEffect,\n TouchEventHandler,\n useRef,\n} from 'react';\nimport styled from '@emotion/styled';\nimport { DragIndicator } from '../../icons';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\nimport { ORIENTATION, DragContext } from './types';\n\ninterface DragItemProps {\n /** Position index of the draggable item */\n index: number;\n /** Orientation of the drag operation (VERTICAL or HORIZONTAL) */\n orientation: ORIENTATION;\n /** Whether to show a drag handle indicator instead of making the entire item draggable */\n showIndicator: boolean;\n /** The index of the item currently being dragged over */\n dragOver: number | null;\n /** Total number of items in the list */\n totalItems: number;\n /** Callback to set announcement for screen readers */\n setAnnouncement: (message?: string) => void;\n}\n\n/** Styled component for the draggable item container */\nconst Item = styled.div<{\n active: number | null;\n orientation: ORIENTATION;\n showIndicator: boolean;\n dragging: boolean;\n}>`\n cursor: ${(props) => (props.showIndicator ? 'default' : 'move')};\n display: flex;\n user-select: ${(props) => (props.showIndicator ? 'auto' : 'none')};\n border-top: 2px dashed\n ${(props) =>\n props.orientation === ORIENTATION.VERTICAL && props.active !== null && props.active > 0\n ? getThemeValue(THEME_NAME.PRIMARY)\n : 'transparent'};\n border-bottom: 2px dashed\n ${(props) =>\n props.orientation === ORIENTATION.VERTICAL && props.active !== null && props.active < 0\n ? getThemeValue(THEME_NAME.PRIMARY)\n : 'transparent'};\n border-left: 2px dashed\n ${(props) =>\n props.orientation === ORIENTATION.HORIZONTAL &&\n props.active !== null &&\n props.active > 0\n ? getThemeValue(THEME_NAME.PRIMARY)\n : 'transparent'};\n border-right: 2px dashed\n ${(props) =>\n props.orientation === ORIENTATION.HORIZONTAL &&\n props.active !== null &&\n props.active < 0\n ? getThemeValue(THEME_NAME.PRIMARY)\n : 'transparent'};\n opacity: ${(props) => (props.dragging ? 0.5 : 1)};\n border-radius: 10px;\n\n &:focus {\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n &:focus:not(:focus-visible) {\n box-shadow: none;\n }\n\n &:focus-visible {\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n`;\n\n/** Styled component for the drag handle indicator */\nconst DragKnob = styled.div`\n padding-top: 8px;\n cursor: move;\n touch-action: none;\n color: ${getThemeValue(THEME_NAME.DISABLED)};\n`;\n\n/** Container for the children */\nconst Container = styled.div`\n flex: 1;\n`;\n\n/**\n * A draggable item component that supports both mouse and touch interactions for drag-and-drop functionality.\n *\n * @component\n * @example\n * ```tsx\n * <DragItem\n * index={0}\n * orientation={ORIENTATION.VERTICAL}\n * showIndicator={true}\n * dragOver={-1}\n * >\n * <div>Draggable content</div>\n * </DragItem>\n * ```\n *\n * @param props - The component props\n * @param props.index - The position index of this item in the draggable list\n * @param props.orientation - The orientation of the drag operation (VERTICAL or HORIZONTAL)\n * @param props.showIndicator - Whether to show a drag handle indicator instead of making the entire item draggable\n * @param props.dragOver - The index of the item currently being dragged over\n * @param props.children - The content to be rendered inside the draggable item\n *\n * @remarks\n * - Uses the DragContext to manage drag state across items\n * - Provides visual feedback with borders during drag operations\n * - Supports haptic feedback (vibration) on touch devices\n * - For touch devices, requires a 200ms hold before drag starts\n * - When showIndicator is true, only the drag handle can initiate drag operations\n *\n * @returns A draggable item with optional drag indicator and visual feedback\n */\nexport default function DragItem(props: PropsWithChildren<DragItemProps>) {\n const { index, orientation, children, showIndicator, dragOver, totalItems, setAnnouncement } =\n props;\n const [active, setActive] = useState<number | null>(0);\n const touchTimerRef = useRef<NodeJS.Timeout | null>(null);\n const context = useContext(DragContext);\n\n /**\n * Vibrate the device for haptic feedback\n * @param duration Duration of the vibration in milliseconds\n */\n const vibrate = (duration: number) => {\n if (navigator.vibrate) {\n navigator.vibrate(duration);\n }\n };\n\n /**\n * Drag start event handler\n * @param e Event\n */\n const dragStartHandler: DragEventHandler<HTMLDivElement> = () => {\n context?.setStartIndex(index);\n context?.setIsDragging(true);\n };\n\n /**\n * Drag over event handler\n * @param e Event\n */\n const dragOverHandler: DragEventHandler<HTMLDivElement> = (e) => {\n e.preventDefault();\n e.stopPropagation();\n if (context && context.startIndex !== null) {\n setActive(context.startIndex - index);\n }\n };\n\n /**\n * Drag leave event handler\n */\n const dragExitHandler: DragEventHandler<HTMLDivElement> = () => {\n setActive(0);\n };\n\n /**\n * Drop event handler\n * @param e Event\n */\n const dropHandler: DragEventHandler<HTMLDivElement> = (e) => {\n e.preventDefault();\n setActive(0);\n context?.drop(index);\n context?.setIsDragging(false);\n };\n\n /**\n * Touch start event handler\n * @param e Event\n */\n const touchStartHandler: TouchEventHandler<HTMLDivElement> = () => {\n // Clear any existing timer first\n if (touchTimerRef.current) {\n clearTimeout(touchTimerRef.current);\n }\n\n touchTimerRef.current = setTimeout(() => {\n context?.setStartIndex(index);\n context?.setIsDragging(true);\n context?.setDragOver(index);\n document.body.style.overflow = 'hidden';\n vibrate(50);\n }, 200);\n };\n\n /**\n * Touch move event handler\n * @param e Event\n * @returns void\n */\n const touchMoveHandler: TouchEventHandler<HTMLDivElement> = (e) => {\n const touch = e.touches[0];\n if (!touch) return;\n\n if (context?.isDragging) {\n e.preventDefault();\n\n // get the element under the touch point\n const el = document.elementFromPoint(\n touch.clientX,\n touch.clientY,\n ) as HTMLElement | null;\n const overAttr = el?.closest('[data-drag-index]')?.getAttribute('data-drag-index');\n const overIndex = overAttr != null ? parseInt(overAttr, 10) : null;\n\n // if we know which index we're over, update visual state\n if (overIndex !== null) {\n context?.setDragOver(overIndex);\n }\n } else if (touchTimerRef.current) {\n clearTimeout(touchTimerRef.current);\n touchTimerRef.current = null;\n }\n };\n\n /**\n * Touch end event handler\n * @param e Event\n */\n const touchEndHandler: TouchEventHandler<HTMLDivElement> = () => {\n if (touchTimerRef.current) {\n clearTimeout(touchTimerRef.current);\n touchTimerRef.current = null;\n }\n\n if (context?.isDragging) {\n context?.drop(dragOver);\n vibrate(50);\n context?.setIsDragging(false);\n document.body.style.overflow = 'auto';\n }\n };\n\n /**\n * Keyboard navigation handler for reordering items\n * @param e Keyboard event\n */\n const handleKeyDown = (e: React.KeyboardEvent) => {\n const isVertical = orientation === ORIENTATION.VERTICAL;\n const moveUp = isVertical ? 'ArrowUp' : 'ArrowLeft';\n const moveDown = isVertical ? 'ArrowDown' : 'ArrowRight';\n\n const isGrabbed = context?.isDragging && context?.startIndex === index;\n\n // Space to grab/drop\n if (e.key === ' ' || e.key === 'Spacebar') {\n e.preventDefault();\n if (isGrabbed) {\n // Drop at current position\n context?.drop(index);\n setAnnouncement(\n context?.i18n.replacePlaceholders(context?.i18n.droppedAnnouncementTemplate, {\n position: index + 1,\n }),\n );\n } else {\n // Grab item\n context?.startGrab(index);\n setAnnouncement(\n context?.i18n.replacePlaceholders(context?.i18n.grabbedAnnouncementTemplate, {\n position: index + 1,\n }),\n );\n }\n }\n // Enter to drop\n else if (e.key === 'Enter' && isGrabbed) {\n e.preventDefault();\n context?.drop(index);\n setAnnouncement(\n context?.i18n.replacePlaceholders(context?.i18n.droppedAnnouncementTemplate, {\n position: index + 1,\n }),\n );\n }\n // Escape to cancel\n else if (e.key === 'Escape' && isGrabbed) {\n e.preventDefault();\n context?.cancel();\n setAnnouncement(context?.i18n.cancelledAnnouncementTemplate);\n }\n // Arrow keys to move while grabbed\n else if (isGrabbed) {\n if (e.key === moveUp && index > 0 && context.startIndex !== null) {\n e.preventDefault();\n // Move without dropping - just reorder and update startIndex\n const newIndex = index - 1;\n context.onDrop(context.startIndex, newIndex);\n context.setStartIndex(newIndex);\n setAnnouncement(\n context.i18n.replacePlaceholders(context.i18n.movedAnnouncementTemplate, {\n position: newIndex + 1,\n }),\n );\n } else if (\n e.key === moveDown &&\n index < totalItems - 1 &&\n context.startIndex !== null\n ) {\n e.preventDefault();\n // Move without dropping - just reorder and update startIndex\n const newIndex = index + 1;\n context.onDrop(context.startIndex, newIndex);\n context.setStartIndex(newIndex);\n setAnnouncement(\n context.i18n.replacePlaceholders(context.i18n.movedAnnouncementTemplate, {\n position: newIndex + 1,\n }),\n );\n }\n }\n };\n\n /** Cleanup touch timer and body overflow on unmount */\n useEffect(() => {\n return () => {\n if (touchTimerRef.current) {\n clearTimeout(touchTimerRef.current);\n touchTimerRef.current = null;\n }\n document.body.style.overflow = 'auto';\n };\n }, []);\n\n /** Update active state based on dragOver changes */\n useEffect(() => {\n if (context?.isDragging && context?.startIndex !== null && dragOver === index) {\n setActive(context?.startIndex - index);\n } else {\n setActive(0);\n }\n }, [dragOver, context?.startIndex, index, context?.isDragging]);\n\n return (\n <Item\n draggable={!showIndicator}\n showIndicator={showIndicator}\n active={active}\n dragging={!!(context?.isDragging && context.startIndex === index)}\n orientation={orientation}\n data-drag-index={index}\n tabIndex={0}\n role=\"listitem\"\n aria-label={context?.i18n.replacePlaceholders(context.i18n.itemAriaLabelTemplate, {\n position: index + 1,\n })}\n aria-grabbed={context?.isDragging && context.startIndex === index}\n onKeyDown={handleKeyDown}\n onDragStart={!showIndicator ? dragStartHandler : undefined}\n onDragOver={dragOverHandler}\n onDragLeave={dragExitHandler}\n onDrop={dropHandler}\n onTouchStart={!showIndicator ? touchStartHandler : undefined}\n onTouchMove={touchMoveHandler}\n onTouchEnd={touchEndHandler}\n onTouchCancel={touchEndHandler}\n >\n {showIndicator && (\n <DragKnob\n draggable\n role=\"button\"\n aria-label={context?.i18n.dragHandleAriaLabel}\n onDragStart={dragStartHandler}\n onTouchStart={touchStartHandler}\n onKeyDown={handleKeyDown}\n tabIndex={-1}\n >\n <DragIndicator />\n </DragKnob>\n )}\n <Container>{children}</Container>\n </Item>\n );\n}\n"],"names":["Item","styled","props","showIndicator","orientation","ORIENTATION","VERTICAL","active","getThemeValue","THEME_NAME","PRIMARY","HORIZONTAL","dragging","PRIMARY_LIGHT","DragKnob","DISABLED","Container","DragItem","index","children","dragOver","totalItems","setAnnouncement","setActive","useState","touchTimerRef","useRef","context","useContext","DragContext","vibrate","duration","navigator","dragStartHandler","setStartIndex","setIsDragging","dragOverHandler","e","preventDefault","stopPropagation","startIndex","dragExitHandler","dropHandler","drop","touchStartHandler","current","clearTimeout","setTimeout","setDragOver","document","body","style","overflow","touchMoveHandler","touch","touches","isDragging","el","elementFromPoint","clientX","clientY","overAttr","closest","getAttribute","overIndex","parseInt","touchEndHandler","handleKeyDown","isVertical","moveUp","moveDown","isGrabbed","key","i18n","replacePlaceholders","droppedAnnouncementTemplate","position","startGrab","grabbedAnnouncementTemplate","cancel","cancelledAnnouncementTemplate","newIndex","onDrop","movedAnnouncementTemplate","useEffect","_jsxs","draggable","data-drag-index","tabIndex","role","aria-label","itemAriaLabelTemplate","aria-grabbed","onKeyDown","onDragStart","undefined","onDragOver","onDragLeave","onTouchStart","onTouchMove","onTouchEnd","onTouchCancel","_jsx","dragHandleAriaLabel","DragIndicator"],"mappings":";;;;;;;AA6BA,yDACA,MAAMA,IAAAA,iBAAOC,MAAAA,CAAAA,KAAAA,EAAAA;;;cAMC,CAACC,KAAAA,GAAWA,KAAAA,CAAMC,aAAa,GAAG,SAAA,GAAY,sCAEzC,CAACD,KAAAA,GAAWA,KAAAA,CAAMC,aAAa,GAAG,MAAA,GAAS,4CAEpD,CAACD,KAAAA,GACCA,KAAAA,CAAME,WAAW,KAAKC,WAAAA,CAAYC,QAAQ,IAAIJ,KAAAA,CAAMK,MAAM,KAAK,IAAA,IAAQL,KAAAA,CAAMK,MAAM,GAAG,CAAA,GAChFC,aAAAA,CAAcC,UAAAA,CAAWC,OAAO,CAAA,GAChC,sDAER,CAACR,KAAAA,GACCA,KAAAA,CAAME,WAAW,KAAKC,WAAAA,CAAYC,QAAQ,IAAIJ,KAAAA,CAAMK,MAAM,KAAK,IAAA,IAAQL,KAAAA,CAAMK,MAAM,GAAG,CAAA,GAChFC,aAAAA,CAAcC,UAAAA,CAAWC,OAAO,CAAA,GAChC,aAAA,EAAA,mCAAA,EAER,CAACR,KAAAA,GACCA,KAAAA,CAAME,WAAW,KAAKC,WAAAA,CAAYM,UAAU,IAC5CT,KAAAA,CAAMK,MAAM,KAAK,IAAA,IACjBL,KAAAA,CAAMK,MAAM,GAAG,CAAA,GACTC,aAAAA,CAAcC,UAAAA,CAAWC,OAAO,CAAA,GAChC,aAAA,EAAA,oCAAA,EAER,CAACR,KAAAA,GACCA,KAAAA,CA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,WAAAA,EAAa7D,gBAAAA;gBACbiE,YAAAA,EAActD,iBAAAA;gBACdiD,SAAAA,EAAW1B,aAAAA;AACXqB,gBAAAA,QAAAA,EAAU,EAAC;AAEX,gBAAA,QAAA,gBAAAc,GAAA,CAACE,WAAAA,EAAAA,EAAAA;;0BAGTF,GAAA,CAACtF,WAAAA,EAAAA;AAAWG,gBAAAA,QAAAA,EAAAA;;;;AAGxB;;;;"}
|
|
@@ -3,7 +3,29 @@ export declare enum ORIENTATION {
|
|
|
3
3
|
VERTICAL = "vertical"
|
|
4
4
|
}
|
|
5
5
|
export declare const DragContext: import("react").Context<{
|
|
6
|
-
startIndex: number;
|
|
6
|
+
startIndex: number | null;
|
|
7
7
|
setStartIndex: (value: number) => void;
|
|
8
|
-
drop: (index: number) => void;
|
|
9
|
-
|
|
8
|
+
drop: (index: number | null) => void;
|
|
9
|
+
onDrop: (start: number, end: number) => void;
|
|
10
|
+
cancel: () => void;
|
|
11
|
+
startGrab: (index: number) => void;
|
|
12
|
+
isDragging: boolean;
|
|
13
|
+
setIsDragging: (value: boolean) => void;
|
|
14
|
+
setDragOver: (value: number) => void;
|
|
15
|
+
i18n: {
|
|
16
|
+
itemAriaLabelTemplate: string;
|
|
17
|
+
dragHandleAriaLabel: string;
|
|
18
|
+
grabbedAnnouncementTemplate: string;
|
|
19
|
+
movedAnnouncementTemplate: string;
|
|
20
|
+
droppedAnnouncementTemplate: string;
|
|
21
|
+
cancelledAnnouncementTemplate: string;
|
|
22
|
+
replacePlaceholders: (template: string, data: {
|
|
23
|
+
position?: number;
|
|
24
|
+
grabKey?: string;
|
|
25
|
+
dropKey?: string;
|
|
26
|
+
altDropKey?: string;
|
|
27
|
+
cancelKey?: string;
|
|
28
|
+
moveKeys?: string;
|
|
29
|
+
}) => string;
|
|
30
|
+
};
|
|
31
|
+
} | null>;
|