no-frills-ui 0.0.14-alpha.8 → 0.0.14-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- package/dist/index.js +841 -710
- package/dist/index.js.map +1 -1
- package/lib-esm/components/Accordion/Accordion.d.ts +9 -13
- package/lib-esm/components/Accordion/Accordion.js +3 -10
- 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 +33 -28
- 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 +10 -20
- 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 -3
- 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 +17 -5
- 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 -3
- 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 -3
- 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 -3
- 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 +16 -3
- package/lib-esm/components/Card/Card.js.map +1 -1
- package/lib-esm/components/Chip/Chip.d.ts +2 -2
- package/lib-esm/components/Chip/Chip.js +14 -8
- package/lib-esm/components/Chip/Chip.js.map +1 -1
- package/lib-esm/components/ChipInput/ChipInput.d.ts +28 -39
- package/lib-esm/components/ChipInput/ChipInput.js +35 -36
- package/lib-esm/components/ChipInput/ChipInput.js.map +1 -1
- package/lib-esm/components/Dialog/AlertDialog.d.ts +11 -12
- package/lib-esm/components/Dialog/AlertDialog.js +4 -11
- 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 +4 -12
- package/lib-esm/components/Dialog/ConfirmDialog.js.map +1 -1
- package/lib-esm/components/Dialog/Dialog.d.ts +8 -14
- package/lib-esm/components/Dialog/Dialog.js +11 -9
- 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 +10 -18
- package/lib-esm/components/Dialog/PromptDialog.js.map +1 -1
- package/lib-esm/components/DragAndDrop/DragAndDrop.d.ts +37 -59
- package/lib-esm/components/DragAndDrop/DragAndDrop.js +23 -26
- package/lib-esm/components/DragAndDrop/DragAndDrop.js.map +1 -1
- package/lib-esm/components/DragAndDrop/DragItem.d.ts +2 -2
- package/lib-esm/components/DragAndDrop/DragItem.js +40 -38
- package/lib-esm/components/DragAndDrop/DragItem.js.map +1 -1
- package/lib-esm/components/DragAndDrop/types.d.ts +3 -3
- package/lib-esm/components/DragAndDrop/types.js.map +1 -1
- package/lib-esm/components/Drawer/Drawer.d.ts +24 -31
- package/lib-esm/components/Drawer/Drawer.js +49 -45
- package/lib-esm/components/Drawer/Drawer.js.map +1 -1
- package/lib-esm/components/Groups/Group.d.ts +6 -8
- package/lib-esm/components/Groups/Group.js +12 -10
- package/lib-esm/components/Groups/Group.js.map +1 -1
- package/lib-esm/components/Input/Checkbox.d.ts +12 -15
- package/lib-esm/components/Input/Checkbox.js +30 -26
- package/lib-esm/components/Input/Checkbox.js.map +1 -1
- package/lib-esm/components/Input/Dropdown.d.ts +8 -18
- package/lib-esm/components/Input/Dropdown.js +42 -17
- package/lib-esm/components/Input/Dropdown.js.map +1 -1
- package/lib-esm/components/Input/Input.d.ts +8 -3
- package/lib-esm/components/Input/Input.js +20 -19
- 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 +16 -13
- 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 +15 -12
- 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 +21 -18
- 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 +29 -24
- 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 +12 -10
- package/lib-esm/components/Input/Toggle.js.map +1 -1
- package/lib-esm/components/Menu/Menu.d.ts +4 -14
- package/lib-esm/components/Menu/Menu.js +24 -16
- package/lib-esm/components/Menu/Menu.js.map +1 -1
- package/lib-esm/components/Menu/MenuContext.d.ts +4 -4
- package/lib-esm/components/Menu/MenuContext.js +1 -0
- package/lib-esm/components/Menu/MenuContext.js.map +1 -1
- package/lib-esm/components/Menu/MenuItem.d.ts +10 -4
- package/lib-esm/components/Menu/MenuItem.js +19 -5
- package/lib-esm/components/Menu/MenuItem.js.map +1 -1
- package/lib-esm/components/Modal/Modal.d.ts +17 -23
- package/lib-esm/components/Modal/Modal.js +37 -34
- package/lib-esm/components/Modal/Modal.js.map +1 -1
- package/lib-esm/components/Notification/Notification.d.ts +39 -34
- package/lib-esm/components/Notification/Notification.js +16 -39
- package/lib-esm/components/Notification/Notification.js.map +1 -1
- package/lib-esm/components/Notification/NotificationManager.d.ts +4 -4
- package/lib-esm/components/Notification/NotificationManager.js +18 -14
- package/lib-esm/components/Notification/NotificationManager.js.map +1 -1
- package/lib-esm/components/Notification/index.d.ts +1 -0
- package/lib-esm/components/Notification/style.d.ts +2 -3
- package/lib-esm/components/Notification/style.js +11 -11
- package/lib-esm/components/Notification/style.js.map +1 -1
- package/lib-esm/components/Popover/Popover.d.ts +21 -20
- package/lib-esm/components/Popover/Popover.js +42 -44
- package/lib-esm/components/Popover/Popover.js.map +1 -1
- package/lib-esm/components/Spinner/Spinner.d.ts +14 -15
- package/lib-esm/components/Spinner/Spinner.js +12 -13
- 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 +10 -8
- 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 +25 -23
- 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 +0 -8
- 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 +39 -31
- package/lib-esm/components/Tabs/Tabs.js.map +1 -1
- package/lib-esm/components/Toast/Toast.d.ts +7 -7
- package/lib-esm/components/Toast/Toast.js +13 -12
- 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 +11 -21
- package/lib-esm/components/Tooltip/Tooltip.js.map +1 -1
- package/lib-esm/icons/CheckCircle.js +2 -2
- package/lib-esm/icons/CheckCircle.js.map +1 -1
- package/lib-esm/icons/ErrorOutline.js +2 -2
- package/lib-esm/icons/ErrorOutline.js.map +1 -1
- package/lib-esm/icons/Info.js +2 -2
- package/lib-esm/icons/Info.js.map +1 -1
- package/lib-esm/icons/ReportProblem.js +2 -2
- package/lib-esm/icons/ReportProblem.js.map +1 -1
- package/lib-esm/index.js +43 -0
- package/lib-esm/shared/LayerManager.d.ts +5 -4
- package/lib-esm/shared/LayerManager.js +123 -111
- package/lib-esm/shared/LayerManager.js.map +1 -1
- package/lib-esm/shared/styles.js +4 -4
- package/lib-esm/shared/styles.js.map +1 -1
- package/package.json +66 -31
- package/lib-esm/components/index.js +0 -43
- /package/lib-esm/{components/index.js.map → index.js.map} +0 -0
|
@@ -1,69 +1,47 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { ORIENTATION } from './types';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
|
|
3
|
+
declare const DragAndDrop: React.ForwardRefExoticComponent<{
|
|
4
|
+
/**
|
|
5
|
+
* Orientation of the list layout
|
|
6
|
+
* @default ORIENTATION.VERTICAL
|
|
7
|
+
*/
|
|
8
|
+
orientation?: ORIENTATION;
|
|
6
9
|
/** Drop event handler */
|
|
7
10
|
onDrop: (start: number, end: number) => void;
|
|
8
|
-
/** Shows drag indicator against each list item
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
/** Shows drag indicator against each list item
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
showIndicator?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* i18n: Template for item aria-label. Placeholders: {:position}, {:grabKey}, {:moveKeys}, {:dropKey}, {:altDropKey}
|
|
17
|
+
* @default 'Item {:position}. Press {:grabKey} to grab, {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop'
|
|
18
|
+
*/
|
|
11
19
|
itemAriaLabelTemplate?: string;
|
|
12
|
-
/** i18n: Aria label for drag handle
|
|
20
|
+
/** i18n: Aria label for drag handle
|
|
21
|
+
* @default 'Drag to reorder'
|
|
22
|
+
*/
|
|
13
23
|
dragHandleAriaLabel?: string;
|
|
14
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* i18n: Template for grabbed announcement. Placeholders: {:position}, {:moveKeys}, {:dropKey}, {:altDropKey}, {:cancelKey}
|
|
26
|
+
* @default 'Item {:position} grabbed. Use {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop, {:cancelKey} to cancel'
|
|
27
|
+
*/
|
|
15
28
|
grabbedAnnouncementTemplate?: string;
|
|
16
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* i18n: Template for moved announcement. Placeholders: {:position}
|
|
31
|
+
* @default 'Item moved to position {:position}'
|
|
32
|
+
*/
|
|
17
33
|
movedAnnouncementTemplate?: string;
|
|
18
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* i18n: Template for dropped announcement. Placeholders: {:position}
|
|
36
|
+
* @default 'Item dropped at position {:position}'
|
|
37
|
+
*/
|
|
19
38
|
droppedAnnouncementTemplate?: string;
|
|
20
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* i18n: Template for cancelled announcement
|
|
41
|
+
* @default 'Drag cancelled, item restored to original position'
|
|
42
|
+
*/
|
|
21
43
|
cancelledAnnouncementTemplate?: string;
|
|
22
|
-
} &
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
* @component
|
|
27
|
-
* @example
|
|
28
|
-
* ```tsx
|
|
29
|
-
* <DragAndDrop
|
|
30
|
-
* orientation={ORIENTATION.VERTICAL}
|
|
31
|
-
* onDrop={(start, end) => handleReorder(start, end)}
|
|
32
|
-
* showIndicator={true}
|
|
33
|
-
* >
|
|
34
|
-
* <div>Item 1</div>
|
|
35
|
-
* <div>Item 2</div>
|
|
36
|
-
* <div>Item 3</div>
|
|
37
|
-
* </DragAndDrop>
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* @param {DragAndDropProps} props - The component props
|
|
41
|
-
* @param {ORIENTATION} props.orientation - Determines the layout direction (horizontal or vertical). Defaults to VERTICAL.
|
|
42
|
-
* @param {(start: number, end: number) => void} props.onDrop - Callback fired when an item is dropped, receives the start and end indices
|
|
43
|
-
* @param {boolean} props.showIndicator - Whether to display drag indicators for each list item. Defaults to false.
|
|
44
|
-
* @param {React.ReactNode} props.children - Child elements to be rendered as draggable items
|
|
45
|
-
*
|
|
46
|
-
* @returns {JSX.Element} A draggable container with reorderable items
|
|
47
|
-
*/
|
|
48
|
-
declare function DragAndDrop(props: DragAndDropProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
49
|
-
declare namespace DragAndDrop {
|
|
50
|
-
var defaultProps: {
|
|
51
|
-
/** Orientation of the list layout */
|
|
52
|
-
orientation: ORIENTATION;
|
|
53
|
-
/** Whether to display drag indicators for each list item */
|
|
54
|
-
showIndicator: boolean;
|
|
55
|
-
/** Default item aria-label template */
|
|
56
|
-
itemAriaLabelTemplate: string;
|
|
57
|
-
/** Default drag handle aria-label */
|
|
58
|
-
dragHandleAriaLabel: string;
|
|
59
|
-
/** Default grabbed announcement template */
|
|
60
|
-
grabbedAnnouncementTemplate: string;
|
|
61
|
-
/** Default moved announcement template */
|
|
62
|
-
movedAnnouncementTemplate: string;
|
|
63
|
-
/** Default dropped announcement template */
|
|
64
|
-
droppedAnnouncementTemplate: string;
|
|
65
|
-
/** Default cancelled announcement template */
|
|
66
|
-
cancelledAnnouncementTemplate: string;
|
|
67
|
-
};
|
|
68
|
-
}
|
|
44
|
+
} & {
|
|
45
|
+
children?: React.ReactNode | undefined;
|
|
46
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
69
47
|
export default DragAndDrop;
|
|
@@ -2,14 +2,14 @@ import { jsxs, Fragment, jsx } from '@emotion/react/jsx-runtime';
|
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
3
|
import styled from '@emotion/styled';
|
|
4
4
|
import DragItem from './DragItem.js';
|
|
5
|
-
import {
|
|
5
|
+
import { ORIENTATION, DragContext } from './types.js';
|
|
6
6
|
|
|
7
|
-
/** Container Component */ const Container = /*#__PURE__*/ styled("div", {
|
|
8
|
-
target: "
|
|
7
|
+
/** Container Component */ const Container$6 = /*#__PURE__*/ styled("div", {
|
|
8
|
+
target: "e18d6tqk0",
|
|
9
9
|
label: "Container"
|
|
10
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 = /*#__PURE__*/ styled("div", {
|
|
12
|
-
target: "
|
|
11
|
+
/** Visually hidden but accessible to screen readers */ const VisuallyHidden$2 = /*#__PURE__*/ styled("div", {
|
|
12
|
+
target: "e18d6tqk1",
|
|
13
13
|
label: "VisuallyHidden"
|
|
14
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
15
|
/**
|
|
@@ -29,15 +29,19 @@ import { DragContext, ORIENTATION } from './types.js';
|
|
|
29
29
|
* </DragAndDrop>
|
|
30
30
|
* ```
|
|
31
31
|
*
|
|
32
|
-
* @param
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
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
37
|
*
|
|
38
|
-
* @returns
|
|
39
|
-
*/
|
|
40
|
-
|
|
38
|
+
* @returns A draggable container with reorderable items
|
|
39
|
+
*/ /**
|
|
40
|
+
* DragAndDrop Component
|
|
41
|
+
* @param props - Component props
|
|
42
|
+
* @param ref - Ref forwarded to the underlying HTMLDivElement
|
|
43
|
+
*/ function DragAndDropComponent(props, ref) {
|
|
44
|
+
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;
|
|
41
45
|
const [startIndex, setStartIndex] = useState(null);
|
|
42
46
|
const [originalIndex, setOriginalIndex] = useState(null);
|
|
43
47
|
const [isDragging, setIsDragging] = useState(false);
|
|
@@ -64,7 +68,7 @@ import { DragContext, ORIENTATION } from './types.js';
|
|
|
64
68
|
* Drop handler invoked when a draggable item is released.
|
|
65
69
|
* @param index
|
|
66
70
|
*/ const drop = (index)=>{
|
|
67
|
-
if (startIndex !== null) {
|
|
71
|
+
if (startIndex !== null && index !== null) {
|
|
68
72
|
onDrop?.(startIndex, index);
|
|
69
73
|
}
|
|
70
74
|
setStartIndex(null);
|
|
@@ -103,7 +107,9 @@ import { DragContext, ORIENTATION } from './types.js';
|
|
|
103
107
|
setDragOver,
|
|
104
108
|
i18n
|
|
105
109
|
},
|
|
106
|
-
children: /*#__PURE__*/ jsx(Container, {
|
|
110
|
+
children: /*#__PURE__*/ jsx(Container$6, {
|
|
111
|
+
...rest,
|
|
112
|
+
ref: ref,
|
|
107
113
|
orientation: orientation,
|
|
108
114
|
role: "list",
|
|
109
115
|
children: React.Children.map(childrenArray, (child, index)=>/*#__PURE__*/ jsx(DragItem, {
|
|
@@ -117,7 +123,7 @@ import { DragContext, ORIENTATION } from './types.js';
|
|
|
117
123
|
}))
|
|
118
124
|
})
|
|
119
125
|
}),
|
|
120
|
-
/*#__PURE__*/ jsx(VisuallyHidden, {
|
|
126
|
+
/*#__PURE__*/ jsx(VisuallyHidden$2, {
|
|
121
127
|
role: "status",
|
|
122
128
|
"aria-live": "polite",
|
|
123
129
|
"aria-atomic": "true",
|
|
@@ -126,16 +132,7 @@ import { DragContext, ORIENTATION } from './types.js';
|
|
|
126
132
|
]
|
|
127
133
|
});
|
|
128
134
|
}
|
|
129
|
-
DragAndDrop
|
|
130
|
-
/** Orientation of the list layout */ orientation: ORIENTATION.VERTICAL,
|
|
131
|
-
/** Whether to display drag indicators for each list item */ showIndicator: false,
|
|
132
|
-
/** Default item aria-label template */ itemAriaLabelTemplate: 'Item {:position}. Press {:grabKey} to grab, {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop',
|
|
133
|
-
/** Default drag handle aria-label */ dragHandleAriaLabel: 'Drag to reorder',
|
|
134
|
-
/** Default grabbed announcement template */ grabbedAnnouncementTemplate: 'Item {:position} grabbed. Use {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop, {:cancelKey} to cancel',
|
|
135
|
-
/** Default moved announcement template */ movedAnnouncementTemplate: 'Item moved to position {:position}',
|
|
136
|
-
/** Default dropped announcement template */ droppedAnnouncementTemplate: 'Item dropped at position {:position}',
|
|
137
|
-
/** Default cancelled announcement template */ cancelledAnnouncementTemplate: 'Drag cancelled, item restored to original position'
|
|
138
|
-
};
|
|
135
|
+
const DragAndDrop = /*#__PURE__*/ React.forwardRef(DragAndDropComponent);
|
|
139
136
|
|
|
140
137
|
export { DragAndDrop as default };
|
|
141
138
|
//# sourceMappingURL=DragAndDrop.js.map
|
|
@@ -1 +1 @@
|
|
|
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 /** Orientation of the list layout */\n orientation: ORIENTATION;\n /** Drop event handler */\n onDrop: (start: number, end: number) => void;\n /** Shows drag indicator against each list item */\n showIndicator: boolean;\n /** i18n: Template for item aria-label. Placeholders: {:position}, {:grabKey}, {:moveKeys}, {:dropKey}, {:altDropKey} */\n itemAriaLabelTemplate?: string;\n /** i18n: Aria label for drag handle */\n dragHandleAriaLabel?: string;\n /** i18n: Template for grabbed announcement. Placeholders: {:position}, {:moveKeys}, {:dropKey}, {:altDropKey}, {:cancelKey} */\n grabbedAnnouncementTemplate?: string;\n /** i18n: Template for moved announcement. Placeholders: {:position} */\n movedAnnouncementTemplate?: string;\n /** i18n: Template for dropped announcement. Placeholders: {:position} */\n droppedAnnouncementTemplate?: string;\n /** i18n: Template for cancelled announcement */\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 {DragAndDropProps} props - The component props\n * @param {ORIENTATION} props.orientation - Determines the layout direction (horizontal or vertical). Defaults to VERTICAL.\n * @param {(start: number, end: number) => void} props.onDrop - Callback fired when an item is dropped, receives the start and end indices\n * @param {boolean} props.showIndicator - Whether to display drag indicators for each list item. Defaults to false.\n * @param {React.ReactNode} props.children - Child elements to be rendered as draggable items\n *\n * @returns {JSX.Element} A draggable container with reorderable items\n */\nexport default function DragAndDrop(props: DragAndDropProps) {\n const {\n orientation,\n children,\n onDrop,\n showIndicator,\n itemAriaLabelTemplate,\n dragHandleAriaLabel,\n grabbedAnnouncementTemplate,\n movedAnnouncementTemplate,\n droppedAnnouncementTemplate,\n cancelledAnnouncementTemplate,\n } = props;\n const [startIndex, setStartIndex] = useState<number>(null);\n const [originalIndex, setOriginalIndex] = useState<number>(null);\n const [isDragging, setIsDragging] = useState<boolean>(false);\n const [dragOver, setDragOver] = useState<number>(null);\n const [announcement, setAnnouncement] = useState('');\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) => {\n if (startIndex !== 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 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\nDragAndDrop.defaultProps = {\n /** Orientation of the list layout */\n orientation: ORIENTATION.VERTICAL,\n /** Whether to display drag indicators for each list item */\n showIndicator: false,\n /** Default item aria-label template */\n itemAriaLabelTemplate:\n 'Item {:position}. Press {:grabKey} to grab, {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop',\n /** Default drag handle aria-label */\n dragHandleAriaLabel: 'Drag to reorder',\n /** Default grabbed announcement template */\n grabbedAnnouncementTemplate:\n 'Item {:position} grabbed. Use {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop, {:cancelKey} to cancel',\n /** Default moved announcement template */\n movedAnnouncementTemplate: 'Item moved to position {:position}',\n /** Default dropped announcement template */\n droppedAnnouncementTemplate: 'Item dropped at position {:position}',\n /** Default cancelled announcement template */\n cancelledAnnouncementTemplate: 'Drag cancelled, item restored to original position',\n};\n"],"names":["Container","styled","props","orientation","ORIENTATION","HORIZONTAL","VisuallyHidden","DragAndDrop","children","onDrop","showIndicator","itemAriaLabelTemplate","dragHandleAriaLabel","grabbedAnnouncementTemplate","movedAnnouncementTemplate","droppedAnnouncementTemplate","cancelledAnnouncementTemplate","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","VERTICAL","i18n","drop","index","cancel","startGrab","_jsxs","_Fragment","_jsx","DragContext","Provider","value","role","map","child","DragItem","aria-live","aria-atomic","defaultProps"],"mappings":";;;;;;AA0BA,2BACA,MAAMA,SAAAA,iBAAYC,MAAAA,CAAAA,KAAAA,EAAAA;;;AAKI,CAAA,CAAA,CAAA,sEAAA,EAAA,CAACC,QAAWA,KAAAA,CAAMC,WAAW,KAAKC,WAAAA,CAAYC,UAAU,GAAG,KAAA,GAAQ,QAAA,EAAA,GAAA,CAAA;AAGzF,wDACA,MAAMC,cAAAA,iBAAiBL,MAAAA,CAAAA,KAAAA,EAAAA;;;;AAYvB;;;;;;;;;;;;;;;;;;;;;;;;IAyBe,SAASM,WAAAA,CAAYL,KAAuB,EAAA;IACvD,MAAM,EACFC,WAAW,EACXK,QAAQ,EACRC,MAAM,EACNC,aAAa,EACbC,qBAAqB,EACrBC,mBAAmB,EACnBC,2BAA2B,EAC3BC,yBAAyB,EACzBC,2BAA2B,EAC3BC,6BAA6B,EAChC,GAAGd,KAAAA;AACJ,IAAA,MAAM,CAACe,UAAAA,EAAYC,aAAAA,CAAc,GAAGC,QAAAA,CAAiB,IAAA,CAAA;AACrD,IAAA,MAAM,CAACC,aAAAA,EAAeC,gBAAAA,CAAiB,GAAGF,QAAAA,CAAiB,IAAA,CAAA;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AAA;AACAqB,oBAAAA;AACJ,iBAAA;AAEA,gBAAA,QAAA,gBAAAO,GAAA,CAACrD,SAAAA,EAAAA;oBAAUG,WAAAA,EAAaA,WAAAA;oBAAasD,IAAAA,EAAK,MAAA;8BACrC5B,KAAAA,CAAMC,QAAQ,CAAC4B,GAAG,CAAC9B,eAAe,CAAC+B,KAAAA,EAAOX,sBACvCK,GAAA,CAACO,QAAAA,EAAAA;4BACGZ,KAAAA,EAAOA,KAAAA;4BACP7C,WAAAA,EAAaA,WAAAA;4BACbO,aAAAA,EAAeA,aAAAA;4BACfc,QAAAA,EAAUA,QAAAA;4BACVQ,UAAAA,EAAYA,UAAAA;4BACZL,eAAAA,EAAiBA,eAAAA;AAEhBgC,4BAAAA,QAAAA,EAAAA;;;;0BAKjBN,GAAA,CAAC/C,cAAAA,EAAAA;gBAAemD,IAAAA,EAAK,QAAA;gBAASI,WAAAA,EAAU,QAAA;gBAASC,aAAAA,EAAY,MAAA;AACxDpC,gBAAAA,QAAAA,EAAAA;;;;AAIjB;AAEAnB,WAAAA,CAAYwD,YAAY,GAAG;0CAEvB5D,WAAAA,EAAaC,WAAAA,CAAYyC,QAAQ;AACjC,iEACAnC,aAAAA,EAAe,KAAA;AACf,4CACAC,qBAAAA,EACI,sGAAA;AACJ,0CACAC,mBAAAA,EAAqB,iBAAA;AACrB,iDACAC,2BAAAA,EACI,gHAAA;AACJ,+CACAC,yBAAAA,EAA2B,oCAAA;AAC3B,iDACAC,2BAAAA,EAA6B,sCAAA;AAC7B,mDACAC,6BAAAA,EAA+B;AACnC,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 */\n/**\n * DragAndDrop Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLDivElement\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","map","child","DragItem","aria-live","aria-atomic","DragAndDrop","forwardRef"],"mappings":";;;;;;AAgDA,2BACA,MAAMA,WAAAA,iBAAYC,MAAAA,CAAAA,KAAAA,EAAAA;;;AAKI,CAAA,CAAA,CAAA,sEAAA,EAAA,CAACC,QAAWA,KAAAA,CAAMC,WAAW,KAAKC,WAAAA,CAAYC,UAAU,GAAG,KAAA,GAAQ,QAAA,EAAA,GAAA,CAAA;AAGzF,wDACA,MAAMC,gBAAAA,iBAAiBL,MAAAA,CAAAA,KAAAA,EAAAA;;;;AAYvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BC,IACD,SAASM,oBAAAA,CAAqBL,KAAuB,EAAEM,GAA8B,EAAA;AACjF,IAAA,MAAM,EACFL,WAAA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A,iBAAcjC,KAAAA,CAAMkC,UAAU,CAAC3D,oBAAAA;;;;"}
|
|
@@ -8,11 +8,11 @@ interface DragItemProps {
|
|
|
8
8
|
/** Whether to show a drag handle indicator instead of making the entire item draggable */
|
|
9
9
|
showIndicator: boolean;
|
|
10
10
|
/** The index of the item currently being dragged over */
|
|
11
|
-
dragOver: number;
|
|
11
|
+
dragOver: number | null;
|
|
12
12
|
/** Total number of items in the list */
|
|
13
13
|
totalItems: number;
|
|
14
14
|
/** Callback to set announcement for screen readers */
|
|
15
|
-
setAnnouncement: (message
|
|
15
|
+
setAnnouncement: (message?: string) => void;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* A draggable item component that supports both mouse and touch interactions for drag-and-drop functionality.
|
|
@@ -6,15 +6,15 @@ import { DragContext, ORIENTATION } from './types.js';
|
|
|
6
6
|
import CheckCircle from '../../icons/DragIndicator.js';
|
|
7
7
|
|
|
8
8
|
/** Styled component for the draggable item container */ const Item = /*#__PURE__*/ styled("div", {
|
|
9
|
-
target: "
|
|
9
|
+
target: "ertl9d70",
|
|
10
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 > 0 ? getThemeValue(THEME_NAME.PRIMARY) : 'transparent', ";border-bottom:2px dashed\n ", (props)=>props.orientation === ORIENTATION.VERTICAL && props.active < 0 ? getThemeValue(THEME_NAME.PRIMARY) : 'transparent', ";border-left:2px dashed\n ", (props)=>props.orientation === ORIENTATION.HORIZONTAL && props.active > 0 ? getThemeValue(THEME_NAME.PRIMARY) : 'transparent', ";border-right:2px dashed\n ", (props)=>props.orientation === ORIENTATION.HORIZONTAL && 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), ";}");
|
|
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
12
|
/** Styled component for the drag handle indicator */ const DragKnob = /*#__PURE__*/ styled("div", {
|
|
13
|
-
target: "
|
|
13
|
+
target: "ertl9d71",
|
|
14
14
|
label: "DragKnob"
|
|
15
15
|
})("padding-top:8px;cursor:move;touch-action:none;color:", getThemeValue(THEME_NAME.DISABLED), ";");
|
|
16
|
-
/** Container for the children */ const Container = /*#__PURE__*/ styled("div", {
|
|
17
|
-
target: "
|
|
16
|
+
/** Container for the children */ const Container$7 = /*#__PURE__*/ styled("div", {
|
|
17
|
+
target: "ertl9d72",
|
|
18
18
|
label: "Container"
|
|
19
19
|
})("flex:1;");
|
|
20
20
|
/**
|
|
@@ -65,8 +65,8 @@ import CheckCircle from '../../icons/DragIndicator.js';
|
|
|
65
65
|
* Drag start event handler
|
|
66
66
|
* @param e Event
|
|
67
67
|
*/ const dragStartHandler = ()=>{
|
|
68
|
-
context
|
|
69
|
-
context
|
|
68
|
+
context?.setStartIndex(index);
|
|
69
|
+
context?.setIsDragging(true);
|
|
70
70
|
};
|
|
71
71
|
/**
|
|
72
72
|
* Drag over event handler
|
|
@@ -74,7 +74,9 @@ import CheckCircle from '../../icons/DragIndicator.js';
|
|
|
74
74
|
*/ const dragOverHandler = (e)=>{
|
|
75
75
|
e.preventDefault();
|
|
76
76
|
e.stopPropagation();
|
|
77
|
-
|
|
77
|
+
if (context && context.startIndex !== null) {
|
|
78
|
+
setActive(context.startIndex - index);
|
|
79
|
+
}
|
|
78
80
|
};
|
|
79
81
|
/**
|
|
80
82
|
* Drag leave event handler
|
|
@@ -87,8 +89,8 @@ import CheckCircle from '../../icons/DragIndicator.js';
|
|
|
87
89
|
*/ const dropHandler = (e)=>{
|
|
88
90
|
e.preventDefault();
|
|
89
91
|
setActive(0);
|
|
90
|
-
context
|
|
91
|
-
context
|
|
92
|
+
context?.drop(index);
|
|
93
|
+
context?.setIsDragging(false);
|
|
92
94
|
};
|
|
93
95
|
/**
|
|
94
96
|
* Touch start event handler
|
|
@@ -99,9 +101,9 @@ import CheckCircle from '../../icons/DragIndicator.js';
|
|
|
99
101
|
clearTimeout(touchTimerRef.current);
|
|
100
102
|
}
|
|
101
103
|
touchTimerRef.current = setTimeout(()=>{
|
|
102
|
-
context
|
|
103
|
-
context
|
|
104
|
-
context
|
|
104
|
+
context?.setStartIndex(index);
|
|
105
|
+
context?.setIsDragging(true);
|
|
106
|
+
context?.setDragOver(index);
|
|
105
107
|
document.body.style.overflow = 'hidden';
|
|
106
108
|
vibrate(50);
|
|
107
109
|
}, 200);
|
|
@@ -113,7 +115,7 @@ import CheckCircle from '../../icons/DragIndicator.js';
|
|
|
113
115
|
*/ const touchMoveHandler = (e)=>{
|
|
114
116
|
const touch = e.touches[0];
|
|
115
117
|
if (!touch) return;
|
|
116
|
-
if (context
|
|
118
|
+
if (context?.isDragging) {
|
|
117
119
|
e.preventDefault();
|
|
118
120
|
// get the element under the touch point
|
|
119
121
|
const el = document.elementFromPoint(touch.clientX, touch.clientY);
|
|
@@ -121,7 +123,7 @@ import CheckCircle from '../../icons/DragIndicator.js';
|
|
|
121
123
|
const overIndex = overAttr != null ? parseInt(overAttr, 10) : null;
|
|
122
124
|
// if we know which index we're over, update visual state
|
|
123
125
|
if (overIndex !== null) {
|
|
124
|
-
context
|
|
126
|
+
context?.setDragOver(overIndex);
|
|
125
127
|
}
|
|
126
128
|
} else if (touchTimerRef.current) {
|
|
127
129
|
clearTimeout(touchTimerRef.current);
|
|
@@ -136,10 +138,10 @@ import CheckCircle from '../../icons/DragIndicator.js';
|
|
|
136
138
|
clearTimeout(touchTimerRef.current);
|
|
137
139
|
touchTimerRef.current = null;
|
|
138
140
|
}
|
|
139
|
-
if (context
|
|
140
|
-
context
|
|
141
|
+
if (context?.isDragging) {
|
|
142
|
+
context?.drop(dragOver);
|
|
141
143
|
vibrate(50);
|
|
142
|
-
context
|
|
144
|
+
context?.setIsDragging(false);
|
|
143
145
|
document.body.style.overflow = 'auto';
|
|
144
146
|
}
|
|
145
147
|
};
|
|
@@ -150,35 +152,35 @@ import CheckCircle from '../../icons/DragIndicator.js';
|
|
|
150
152
|
const isVertical = orientation === ORIENTATION.VERTICAL;
|
|
151
153
|
const moveUp = isVertical ? 'ArrowUp' : 'ArrowLeft';
|
|
152
154
|
const moveDown = isVertical ? 'ArrowDown' : 'ArrowRight';
|
|
153
|
-
const isGrabbed = context
|
|
155
|
+
const isGrabbed = context?.isDragging && context?.startIndex === index;
|
|
154
156
|
// Space to grab/drop
|
|
155
157
|
if (e.key === ' ' || e.key === 'Spacebar') {
|
|
156
158
|
e.preventDefault();
|
|
157
159
|
if (isGrabbed) {
|
|
158
160
|
// Drop at current position
|
|
159
|
-
context
|
|
160
|
-
setAnnouncement(context
|
|
161
|
+
context?.drop(index);
|
|
162
|
+
setAnnouncement(context?.i18n.replacePlaceholders(context?.i18n.droppedAnnouncementTemplate, {
|
|
161
163
|
position: index + 1
|
|
162
164
|
}));
|
|
163
165
|
} else {
|
|
164
166
|
// Grab item
|
|
165
|
-
context
|
|
166
|
-
setAnnouncement(context
|
|
167
|
+
context?.startGrab(index);
|
|
168
|
+
setAnnouncement(context?.i18n.replacePlaceholders(context?.i18n.grabbedAnnouncementTemplate, {
|
|
167
169
|
position: index + 1
|
|
168
170
|
}));
|
|
169
171
|
}
|
|
170
172
|
} else if (e.key === 'Enter' && isGrabbed) {
|
|
171
173
|
e.preventDefault();
|
|
172
|
-
context
|
|
173
|
-
setAnnouncement(context
|
|
174
|
+
context?.drop(index);
|
|
175
|
+
setAnnouncement(context?.i18n.replacePlaceholders(context?.i18n.droppedAnnouncementTemplate, {
|
|
174
176
|
position: index + 1
|
|
175
177
|
}));
|
|
176
178
|
} else if (e.key === 'Escape' && isGrabbed) {
|
|
177
179
|
e.preventDefault();
|
|
178
|
-
context
|
|
179
|
-
setAnnouncement(context
|
|
180
|
+
context?.cancel();
|
|
181
|
+
setAnnouncement(context?.i18n.cancelledAnnouncementTemplate);
|
|
180
182
|
} else if (isGrabbed) {
|
|
181
|
-
if (e.key === moveUp && index > 0) {
|
|
183
|
+
if (e.key === moveUp && index > 0 && context.startIndex !== null) {
|
|
182
184
|
e.preventDefault();
|
|
183
185
|
// Move without dropping - just reorder and update startIndex
|
|
184
186
|
const newIndex = index - 1;
|
|
@@ -187,7 +189,7 @@ import CheckCircle from '../../icons/DragIndicator.js';
|
|
|
187
189
|
setAnnouncement(context.i18n.replacePlaceholders(context.i18n.movedAnnouncementTemplate, {
|
|
188
190
|
position: newIndex + 1
|
|
189
191
|
}));
|
|
190
|
-
} else if (e.key === moveDown && index < totalItems - 1) {
|
|
192
|
+
} else if (e.key === moveDown && index < totalItems - 1 && context.startIndex !== null) {
|
|
191
193
|
e.preventDefault();
|
|
192
194
|
// Move without dropping - just reorder and update startIndex
|
|
193
195
|
const newIndex = index + 1;
|
|
@@ -209,30 +211,30 @@ import CheckCircle from '../../icons/DragIndicator.js';
|
|
|
209
211
|
};
|
|
210
212
|
}, []);
|
|
211
213
|
/** Update active state based on dragOver changes */ useEffect(()=>{
|
|
212
|
-
if (context
|
|
213
|
-
setActive(context
|
|
214
|
+
if (context?.isDragging && context?.startIndex !== null && dragOver === index) {
|
|
215
|
+
setActive(context?.startIndex - index);
|
|
214
216
|
} else {
|
|
215
217
|
setActive(0);
|
|
216
218
|
}
|
|
217
219
|
}, [
|
|
218
220
|
dragOver,
|
|
219
|
-
context
|
|
221
|
+
context?.startIndex,
|
|
220
222
|
index,
|
|
221
|
-
context
|
|
223
|
+
context?.isDragging
|
|
222
224
|
]);
|
|
223
225
|
return /*#__PURE__*/ jsxs(Item, {
|
|
224
226
|
draggable: !showIndicator,
|
|
225
227
|
showIndicator: showIndicator,
|
|
226
228
|
active: active,
|
|
227
|
-
dragging: context
|
|
229
|
+
dragging: !!(context?.isDragging && context.startIndex === index),
|
|
228
230
|
orientation: orientation,
|
|
229
231
|
"data-drag-index": index,
|
|
230
232
|
tabIndex: 0,
|
|
231
233
|
role: "listitem",
|
|
232
|
-
"aria-label": context
|
|
234
|
+
"aria-label": context?.i18n.replacePlaceholders(context.i18n.itemAriaLabelTemplate, {
|
|
233
235
|
position: index + 1
|
|
234
236
|
}),
|
|
235
|
-
"aria-grabbed": context
|
|
237
|
+
"aria-grabbed": context?.isDragging && context.startIndex === index,
|
|
236
238
|
onKeyDown: handleKeyDown,
|
|
237
239
|
onDragStart: !showIndicator ? dragStartHandler : undefined,
|
|
238
240
|
onDragOver: dragOverHandler,
|
|
@@ -246,14 +248,14 @@ import CheckCircle from '../../icons/DragIndicator.js';
|
|
|
246
248
|
showIndicator && /*#__PURE__*/ jsx(DragKnob, {
|
|
247
249
|
draggable: true,
|
|
248
250
|
role: "button",
|
|
249
|
-
"aria-label": context
|
|
251
|
+
"aria-label": context?.i18n.dragHandleAriaLabel,
|
|
250
252
|
onDragStart: dragStartHandler,
|
|
251
253
|
onTouchStart: touchStartHandler,
|
|
252
254
|
onKeyDown: handleKeyDown,
|
|
253
255
|
tabIndex: -1,
|
|
254
256
|
children: /*#__PURE__*/ jsx(CheckCircle, {})
|
|
255
257
|
}),
|
|
256
|
-
/*#__PURE__*/ jsx(Container, {
|
|
258
|
+
/*#__PURE__*/ jsx(Container$7, {
|
|
257
259
|
children: children
|
|
258
260
|
})
|
|
259
261
|
]
|
|
@@ -1 +1 @@
|
|
|
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;\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;\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 > 0\n ? getThemeValue(THEME_NAME.PRIMARY)\n : 'transparent'};\n border-bottom: 2px dashed\n ${(props) =>\n props.orientation === ORIENTATION.VERTICAL && props.active < 0\n ? getThemeValue(THEME_NAME.PRIMARY)\n : 'transparent'};\n border-left: 2px dashed\n ${(props) =>\n props.orientation === ORIENTATION.HORIZONTAL && props.active > 0\n ? getThemeValue(THEME_NAME.PRIMARY)\n : 'transparent'};\n border-right: 2px dashed\n ${(props) =>\n props.orientation === ORIENTATION.HORIZONTAL && 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(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 setActive(context.startIndex - index);\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) {\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 (e.key === moveDown && index < totalItems - 1) {\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 && 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,MAAMC,aAAa,GAAG,YAAY,MAAA,EAAA,4BAAA,EAEzC,CAACD,QAAWA,KAAAA,CAAMC,aAAa,GAAG,MAAA,GAAS,MAAA,EAAA,kCAAA,EAEpD,CAACD,KAAAA,GACCA,KAAAA,CAAME,WAAW,KAAKC,WAAAA,CAAYC,QAAQ,IAAIJ,KAAAA,CAAMK,MAAM,GAAG,CAAA,GACvDC,cAAcC,UAAAA,CAAWC,OAAO,IAChC,aAAA,EAAA,qCAAA,EAER,CAACR,QACCA,KAAAA,CAAME,WAAW,KAAKC,WAAAA,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,EAAY/D,OAAAA,CAAQ8C,IAAI,CAAC8B,mBAAmB;gBAC5CT,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,SAAAA,EAAAA;AAAWG,gBAAAA,QAAAA,EAAAA;;;;AAGxB;;;;"}
|
|
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,GA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