no-frills-ui 0.0.14-alpha.1 → 0.0.14-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/README.md +28 -22
  2. package/dist/index.js +3418 -2772
  3. package/dist/index.js.map +1 -1
  4. package/lib-esm/components/Accordion/Accordion.d.ts +11 -16
  5. package/lib-esm/components/Accordion/Accordion.js +25 -29
  6. package/lib-esm/components/Accordion/Accordion.js.map +1 -1
  7. package/lib-esm/components/Accordion/AccordionStep.d.ts +22 -22
  8. package/lib-esm/components/Accordion/AccordionStep.js +111 -109
  9. package/lib-esm/components/Accordion/AccordionStep.js.map +1 -1
  10. package/lib-esm/components/Badge/Badge.d.ts +13 -16
  11. package/lib-esm/components/Badge/Badge.js +31 -51
  12. package/lib-esm/components/Badge/Badge.js.map +1 -1
  13. package/lib-esm/components/Button/ActionButton.d.ts +9 -5
  14. package/lib-esm/components/Button/ActionButton.js +18 -38
  15. package/lib-esm/components/Button/ActionButton.js.map +1 -1
  16. package/lib-esm/components/Button/Button.d.ts +9 -5
  17. package/lib-esm/components/Button/Button.js +18 -40
  18. package/lib-esm/components/Button/Button.js.map +1 -1
  19. package/lib-esm/components/Button/IconButton.d.ts +9 -5
  20. package/lib-esm/components/Button/IconButton.js +18 -42
  21. package/lib-esm/components/Button/IconButton.js.map +1 -1
  22. package/lib-esm/components/Button/LinkButton.d.ts +9 -5
  23. package/lib-esm/components/Button/LinkButton.js +18 -32
  24. package/lib-esm/components/Button/LinkButton.js.map +1 -1
  25. package/lib-esm/components/Button/RaisedButton.d.ts +9 -5
  26. package/lib-esm/components/Button/RaisedButton.js +18 -46
  27. package/lib-esm/components/Button/RaisedButton.js.map +1 -1
  28. package/lib-esm/components/Card/Card.d.ts +4 -6
  29. package/lib-esm/components/Card/Card.js +18 -13
  30. package/lib-esm/components/Card/Card.js.map +1 -1
  31. package/lib-esm/components/Chip/Chip.d.ts +6 -3
  32. package/lib-esm/components/Chip/Chip.js +44 -43
  33. package/lib-esm/components/Chip/Chip.js.map +1 -1
  34. package/lib-esm/components/ChipInput/ChipInput.d.ts +28 -30
  35. package/lib-esm/components/ChipInput/ChipInput.js +121 -139
  36. package/lib-esm/components/ChipInput/ChipInput.js.map +1 -1
  37. package/lib-esm/components/Dialog/AlertDialog.d.ts +11 -12
  38. package/lib-esm/components/Dialog/AlertDialog.js +44 -28
  39. package/lib-esm/components/Dialog/AlertDialog.js.map +1 -1
  40. package/lib-esm/components/Dialog/ConfirmDialog.d.ts +13 -14
  41. package/lib-esm/components/Dialog/ConfirmDialog.js +49 -33
  42. package/lib-esm/components/Dialog/ConfirmDialog.js.map +1 -1
  43. package/lib-esm/components/Dialog/Dialog.d.ts +40 -18
  44. package/lib-esm/components/Dialog/Dialog.js +125 -70
  45. package/lib-esm/components/Dialog/Dialog.js.map +1 -1
  46. package/lib-esm/components/Dialog/PromptDialog.d.ts +18 -19
  47. package/lib-esm/components/Dialog/PromptDialog.js +78 -49
  48. package/lib-esm/components/Dialog/PromptDialog.js.map +1 -1
  49. package/lib-esm/components/DragAndDrop/DragAndDrop.d.ts +43 -41
  50. package/lib-esm/components/DragAndDrop/DragAndDrop.js +104 -31
  51. package/lib-esm/components/DragAndDrop/DragAndDrop.js.map +1 -1
  52. package/lib-esm/components/DragAndDrop/DragItem.d.ts +5 -1
  53. package/lib-esm/components/DragAndDrop/DragItem.js +171 -92
  54. package/lib-esm/components/DragAndDrop/DragItem.js.map +1 -1
  55. package/lib-esm/components/DragAndDrop/types.d.ts +22 -3
  56. package/lib-esm/components/DragAndDrop/types.js +9 -6
  57. package/lib-esm/components/DragAndDrop/types.js.map +1 -1
  58. package/lib-esm/components/Drawer/Drawer.d.ts +86 -22
  59. package/lib-esm/components/Drawer/Drawer.js +176 -97
  60. package/lib-esm/components/Drawer/Drawer.js.map +1 -1
  61. package/lib-esm/components/Drawer/index.d.ts +1 -1
  62. package/lib-esm/components/Groups/Group.d.ts +5 -8
  63. package/lib-esm/components/Groups/Group.js +34 -79
  64. package/lib-esm/components/Groups/Group.js.map +1 -1
  65. package/lib-esm/components/Groups/GroupLabel.js +8 -17
  66. package/lib-esm/components/Groups/GroupLabel.js.map +1 -1
  67. package/lib-esm/components/Input/Checkbox.d.ts +12 -15
  68. package/lib-esm/components/Input/Checkbox.js +51 -118
  69. package/lib-esm/components/Input/Checkbox.js.map +1 -1
  70. package/lib-esm/components/Input/Dropdown.d.ts +11 -12
  71. package/lib-esm/components/Input/Dropdown.js +133 -52
  72. package/lib-esm/components/Input/Dropdown.js.map +1 -1
  73. package/lib-esm/components/Input/Input.d.ts +3 -3
  74. package/lib-esm/components/Input/Input.js +61 -109
  75. package/lib-esm/components/Input/Input.js.map +1 -1
  76. package/lib-esm/components/Input/Radio.d.ts +4 -8
  77. package/lib-esm/components/Input/Radio.js +35 -79
  78. package/lib-esm/components/Input/Radio.js.map +1 -1
  79. package/lib-esm/components/Input/RadioButton.d.ts +4 -8
  80. package/lib-esm/components/Input/RadioButton.js +34 -71
  81. package/lib-esm/components/Input/RadioButton.js.map +1 -1
  82. package/lib-esm/components/Input/Select.d.ts +6 -13
  83. package/lib-esm/components/Input/Select.js +75 -122
  84. package/lib-esm/components/Input/Select.js.map +1 -1
  85. package/lib-esm/components/Input/TextArea.d.ts +6 -13
  86. package/lib-esm/components/Input/TextArea.js +64 -108
  87. package/lib-esm/components/Input/TextArea.js.map +1 -1
  88. package/lib-esm/components/Input/Toggle.d.ts +4 -9
  89. package/lib-esm/components/Input/Toggle.js +31 -80
  90. package/lib-esm/components/Input/Toggle.js.map +1 -1
  91. package/lib-esm/components/Menu/Menu.d.ts +8 -6
  92. package/lib-esm/components/Menu/Menu.js +116 -31
  93. package/lib-esm/components/Menu/Menu.js.map +1 -1
  94. package/lib-esm/components/Menu/MenuContext.d.ts +11 -5
  95. package/lib-esm/components/Menu/MenuContext.js +6 -2
  96. package/lib-esm/components/Menu/MenuContext.js.map +1 -1
  97. package/lib-esm/components/Menu/MenuItem.d.ts +7 -4
  98. package/lib-esm/components/Menu/MenuItem.js +46 -47
  99. package/lib-esm/components/Menu/MenuItem.js.map +1 -1
  100. package/lib-esm/components/Modal/Modal.d.ts +75 -16
  101. package/lib-esm/components/Modal/Modal.js +146 -51
  102. package/lib-esm/components/Modal/Modal.js.map +1 -1
  103. package/lib-esm/components/Notification/Notification.d.ts +46 -39
  104. package/lib-esm/components/Notification/Notification.js +80 -87
  105. package/lib-esm/components/Notification/Notification.js.map +1 -1
  106. package/lib-esm/components/Notification/NotificationManager.d.ts +19 -5
  107. package/lib-esm/components/Notification/NotificationManager.js +177 -79
  108. package/lib-esm/components/Notification/NotificationManager.js.map +1 -1
  109. package/lib-esm/components/Notification/style.d.ts +6 -3
  110. package/lib-esm/components/Notification/style.js +64 -140
  111. package/lib-esm/components/Notification/style.js.map +1 -1
  112. package/lib-esm/components/Notification/types.d.ts +2 -0
  113. package/lib-esm/components/Notification/types.js +9 -10
  114. package/lib-esm/components/Notification/types.js.map +1 -1
  115. package/lib-esm/components/Popover/Popover.d.ts +21 -20
  116. package/lib-esm/components/Popover/Popover.js +159 -126
  117. package/lib-esm/components/Popover/Popover.js.map +1 -1
  118. package/lib-esm/components/Spinner/Spinner.d.ts +14 -12
  119. package/lib-esm/components/Spinner/Spinner.js +22 -27
  120. package/lib-esm/components/Spinner/Spinner.js.map +1 -1
  121. package/lib-esm/components/Stepper/Step.d.ts +15 -12
  122. package/lib-esm/components/Stepper/Step.js +18 -25
  123. package/lib-esm/components/Stepper/Step.js.map +1 -1
  124. package/lib-esm/components/Stepper/Stepper.d.ts +11 -17
  125. package/lib-esm/components/Stepper/Stepper.js +104 -102
  126. package/lib-esm/components/Stepper/Stepper.js.map +1 -1
  127. package/lib-esm/components/Tabs/Tab.d.ts +10 -16
  128. package/lib-esm/components/Tabs/Tab.js +9 -15
  129. package/lib-esm/components/Tabs/Tab.js.map +1 -1
  130. package/lib-esm/components/Tabs/Tabs.d.ts +11 -22
  131. package/lib-esm/components/Tabs/Tabs.js +96 -55
  132. package/lib-esm/components/Tabs/Tabs.js.map +1 -1
  133. package/lib-esm/components/Toast/Toast.d.ts +34 -7
  134. package/lib-esm/components/Toast/Toast.js +200 -109
  135. package/lib-esm/components/Toast/Toast.js.map +1 -1
  136. package/lib-esm/components/Toast/ToastStory.d.ts +21 -24
  137. package/lib-esm/components/Tooltip/Tooltip.d.ts +11 -14
  138. package/lib-esm/components/Tooltip/Tooltip.js +52 -67
  139. package/lib-esm/components/Tooltip/Tooltip.js.map +1 -1
  140. package/lib-esm/components/index.d.ts +1 -0
  141. package/lib-esm/icons/CheckCircle.d.ts +1 -1
  142. package/lib-esm/icons/CheckCircle.js +22 -4
  143. package/lib-esm/icons/CheckCircle.js.map +1 -1
  144. package/lib-esm/icons/Close.d.ts +1 -1
  145. package/lib-esm/icons/Close.js +22 -4
  146. package/lib-esm/icons/Close.js.map +1 -1
  147. package/lib-esm/icons/DragIndicator.d.ts +1 -1
  148. package/lib-esm/icons/DragIndicator.js +22 -4
  149. package/lib-esm/icons/DragIndicator.js.map +1 -1
  150. package/lib-esm/icons/ErrorOutline.d.ts +1 -1
  151. package/lib-esm/icons/ErrorOutline.js +16 -4
  152. package/lib-esm/icons/ErrorOutline.js.map +1 -1
  153. package/lib-esm/icons/ExpandMore.d.ts +1 -1
  154. package/lib-esm/icons/ExpandMore.js +22 -4
  155. package/lib-esm/icons/ExpandMore.js.map +1 -1
  156. package/lib-esm/icons/FiberManualRecord.d.ts +1 -1
  157. package/lib-esm/icons/FiberManualRecord.js +24 -4
  158. package/lib-esm/icons/FiberManualRecord.js.map +1 -1
  159. package/lib-esm/icons/Info.d.ts +1 -1
  160. package/lib-esm/icons/Info.js +22 -4
  161. package/lib-esm/icons/Info.js.map +1 -1
  162. package/lib-esm/icons/ReportProblem.d.ts +1 -1
  163. package/lib-esm/icons/ReportProblem.js +22 -4
  164. package/lib-esm/icons/ReportProblem.js.map +1 -1
  165. package/lib-esm/index.js +43 -2
  166. package/lib-esm/index.js.map +1 -1
  167. package/lib-esm/shared/LayerManager.d.ts +34 -4
  168. package/lib-esm/shared/LayerManager.js +248 -114
  169. package/lib-esm/shared/LayerManager.js.map +1 -1
  170. package/lib-esm/shared/constants.d.ts +58 -27
  171. package/lib-esm/shared/constants.js +62 -26
  172. package/lib-esm/shared/constants.js.map +1 -1
  173. package/lib-esm/shared/styles.d.ts +1 -1
  174. package/lib-esm/shared/styles.js +21 -24
  175. package/lib-esm/shared/styles.js.map +1 -1
  176. package/package.json +130 -74
  177. package/lib-esm/components/Accordion/index.js +0 -3
  178. package/lib-esm/components/Accordion/index.js.map +0 -1
  179. package/lib-esm/components/Badge/index.js +0 -2
  180. package/lib-esm/components/Badge/index.js.map +0 -1
  181. package/lib-esm/components/Button/index.js +0 -6
  182. package/lib-esm/components/Button/index.js.map +0 -1
  183. package/lib-esm/components/Card/index.js +0 -3
  184. package/lib-esm/components/Card/index.js.map +0 -1
  185. package/lib-esm/components/Chip/index.js +0 -2
  186. package/lib-esm/components/Chip/index.js.map +0 -1
  187. package/lib-esm/components/ChipInput/index.js +0 -2
  188. package/lib-esm/components/ChipInput/index.js.map +0 -1
  189. package/lib-esm/components/Dialog/index.js +0 -5
  190. package/lib-esm/components/Dialog/index.js.map +0 -1
  191. package/lib-esm/components/DragAndDrop/index.js +0 -3
  192. package/lib-esm/components/DragAndDrop/index.js.map +0 -1
  193. package/lib-esm/components/Drawer/index.js +0 -2
  194. package/lib-esm/components/Drawer/index.js.map +0 -1
  195. package/lib-esm/components/Groups/index.js +0 -3
  196. package/lib-esm/components/Groups/index.js.map +0 -1
  197. package/lib-esm/components/Input/index.js +0 -9
  198. package/lib-esm/components/Input/index.js.map +0 -1
  199. package/lib-esm/components/Menu/index.js +0 -3
  200. package/lib-esm/components/Menu/index.js.map +0 -1
  201. package/lib-esm/components/Modal/index.js +0 -2
  202. package/lib-esm/components/Modal/index.js.map +0 -1
  203. package/lib-esm/components/Notification/index.js +0 -3
  204. package/lib-esm/components/Notification/index.js.map +0 -1
  205. package/lib-esm/components/Popover/index.js +0 -2
  206. package/lib-esm/components/Popover/index.js.map +0 -1
  207. package/lib-esm/components/Spinner/index.js +0 -2
  208. package/lib-esm/components/Spinner/index.js.map +0 -1
  209. package/lib-esm/components/Stepper/index.js +0 -4
  210. package/lib-esm/components/Stepper/index.js.map +0 -1
  211. package/lib-esm/components/Tabs/index.js +0 -3
  212. package/lib-esm/components/Tabs/index.js.map +0 -1
  213. package/lib-esm/components/Toast/ToastStory.js +0 -35
  214. package/lib-esm/components/Toast/ToastStory.js.map +0 -1
  215. package/lib-esm/components/Toast/index.js +0 -2
  216. package/lib-esm/components/Toast/index.js.map +0 -1
  217. package/lib-esm/components/Tooltip/index.js +0 -2
  218. package/lib-esm/components/Tooltip/index.js.map +0 -1
  219. package/lib-esm/components/index.js +0 -20
  220. package/lib-esm/components/index.js.map +0 -1
  221. package/lib-esm/icons/index.js +0 -9
  222. package/lib-esm/icons/index.js.map +0 -1
@@ -1,35 +1,22 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
- import { useContext, useState, useEffect } from 'react';
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 constants from '../../shared/constants';
5
- import { ORIENTATION, DragContext } from './types';
6
- import { DragIndicator } from '../../icons';
7
- /** Styled component for the draggable item container */
8
- const Item = styled.div `
9
- cursor: ${props => props.showIndicator ? 'default' : 'move'};
10
- display: flex;
11
- user-select: ${props => props.showIndicator ? 'auto' : 'none'};
12
- border-top: 2px solid ${props => props.orientation === ORIENTATION.VERTICAL && props.active > 0
13
- ? constants.PRIMARY : 'transparent'};
14
- border-bottom: 2px solid ${props => props.orientation === ORIENTATION.VERTICAL && props.active < 0
15
- ? constants.PRIMARY : 'transparent'};
16
- border-left: 2px solid ${props => props.orientation === ORIENTATION.HORIZONTAL && props.active > 0
17
- ? constants.PRIMARY : 'transparent'};
18
- border-right: 2px solid ${props => props.orientation === ORIENTATION.HORIZONTAL && props.active < 0
19
- ? constants.PRIMARY : 'transparent'};
20
- opacity: ${props => props.dragging ? 0.5 : 1};
21
- `;
22
- /** Styled component for the drag handle indicator */
23
- const DragKnob = styled.div `
24
- padding-top: 8px;
25
- cursor: move;
26
- touch-action: none;
27
- color: var(--disabled, ${constants.DISABLED});
28
- `;
29
- /** Container for the children */
30
- const Container = styled.div `
31
- flex: 1;
32
- `;
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;");
33
20
  /**
34
21
  * A draggable item component that supports both mouse and touch interactions for drag-and-drop functionality.
35
22
  *
@@ -61,17 +48,15 @@ const Container = styled.div `
61
48
  * - When showIndicator is true, only the drag handle can initiate drag operations
62
49
  *
63
50
  * @returns A draggable item with optional drag indicator and visual feedback
64
- */
65
- export default function DragItem(props) {
66
- const { index, orientation, children, showIndicator, dragOver } = props;
51
+ */ function DragItem(props) {
52
+ const { index, orientation, children, showIndicator, dragOver, totalItems, setAnnouncement } = props;
67
53
  const [active, setActive] = useState(0);
68
- const [touchTimer, setTouchTimer] = useState(null);
54
+ const touchTimerRef = useRef(null);
69
55
  const context = useContext(DragContext);
70
56
  /**
71
57
  * Vibrate the device for haptic feedback
72
58
  * @param duration Duration of the vibration in milliseconds
73
- */
74
- const vibrate = (duration) => {
59
+ */ const vibrate = (duration)=>{
75
60
  if (navigator.vibrate) {
76
61
  navigator.vibrate(duration);
77
62
  }
@@ -79,109 +64,203 @@ export default function DragItem(props) {
79
64
  /**
80
65
  * Drag start event handler
81
66
  * @param e Event
82
- */
83
- const dragStartHandler = (e) => {
84
- context.setStartIndex(index);
85
- context.setIsDragging(true);
67
+ */ const dragStartHandler = ()=>{
68
+ context?.setStartIndex(index);
69
+ context?.setIsDragging(true);
86
70
  };
87
71
  /**
88
72
  * Drag over event handler
89
73
  * @param e Event
90
- */
91
- const dragOverHandler = (e) => {
74
+ */ const dragOverHandler = (e)=>{
92
75
  e.preventDefault();
93
76
  e.stopPropagation();
94
- setActive(context.startIndex - index);
77
+ if (context && context.startIndex !== null) {
78
+ setActive(context.startIndex - index);
79
+ }
95
80
  };
96
81
  /**
97
82
  * Drag leave event handler
98
- */
99
- const dragExitHandler = () => {
83
+ */ const dragExitHandler = ()=>{
100
84
  setActive(0);
101
85
  };
102
86
  /**
103
87
  * Drop event handler
104
88
  * @param e Event
105
- */
106
- const dropHandler = (e) => {
89
+ */ const dropHandler = (e)=>{
107
90
  e.preventDefault();
108
91
  setActive(0);
109
- context.drop(index);
110
- context.setIsDragging(false);
92
+ context?.drop(index);
93
+ context?.setIsDragging(false);
111
94
  };
112
95
  /**
113
96
  * Touch start event handler
114
97
  * @param e Event
115
- */
116
- const touchStartHandler = (e) => {
117
- const timer = setTimeout(() => {
118
- context.setStartIndex(index);
119
- context.setIsDragging(true);
120
- context.setDragOver(index);
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);
121
107
  document.body.style.overflow = 'hidden';
122
108
  vibrate(50);
123
109
  }, 200);
124
- setTouchTimer(timer);
125
110
  };
126
111
  /**
127
112
  * Touch move event handler
128
113
  * @param e Event
129
114
  * @returns void
130
- */
131
- const touchMoveHandler = (e) => {
132
- var _a;
115
+ */ const touchMoveHandler = (e)=>{
133
116
  const touch = e.touches[0];
134
- if (!touch)
135
- return;
136
- if (context.isDragging) {
117
+ if (!touch) return;
118
+ if (context?.isDragging) {
137
119
  e.preventDefault();
138
120
  // get the element under the touch point
139
121
  const el = document.elementFromPoint(touch.clientX, touch.clientY);
140
- const overAttr = (_a = el === null || el === void 0 ? void 0 : el.closest('[data-drag-index]')) === null || _a === void 0 ? void 0 : _a.getAttribute('data-drag-index');
122
+ const overAttr = el?.closest('[data-drag-index]')?.getAttribute('data-drag-index');
141
123
  const overIndex = overAttr != null ? parseInt(overAttr, 10) : null;
142
124
  // if we know which index we're over, update visual state
143
125
  if (overIndex !== null) {
144
- context.setDragOver(overIndex);
126
+ context?.setDragOver(overIndex);
145
127
  }
146
- }
147
- else if (touchTimer) {
148
- clearTimeout(touchTimer);
149
- setTouchTimer(null);
128
+ } else if (touchTimerRef.current) {
129
+ clearTimeout(touchTimerRef.current);
130
+ touchTimerRef.current = null;
150
131
  }
151
132
  };
152
133
  /**
153
134
  * Touch end event handler
154
135
  * @param e Event
155
- */
156
- const touchEndHandler = (e) => {
157
- if (touchTimer) {
158
- clearTimeout(touchTimer);
159
- setTouchTimer(null);
136
+ */ const touchEndHandler = ()=>{
137
+ if (touchTimerRef.current) {
138
+ clearTimeout(touchTimerRef.current);
139
+ touchTimerRef.current = null;
160
140
  }
161
- if (context.isDragging) {
162
- context.drop(dragOver);
141
+ if (context?.isDragging) {
142
+ context?.drop(dragOver);
163
143
  vibrate(50);
164
- context.setIsDragging(false);
144
+ context?.setIsDragging(false);
165
145
  document.body.style.overflow = 'auto';
166
146
  }
167
147
  };
168
- /** Cleanup touch timer on unmount */
169
- useEffect(() => {
170
- return () => {
171
- if (touchTimer)
172
- clearTimeout(touchTimer);
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
+ }
203
+ };
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
+ }
173
210
  document.body.style.overflow = 'auto';
174
211
  };
175
- }, [touchTimer]);
176
- /** Update active state based on dragOver changes */
177
- useEffect(() => {
178
- if (context.isDragging && dragOver === index) {
179
- setActive(context.startIndex - index);
180
- }
181
- else {
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 {
182
217
  setActive(0);
183
218
  }
184
- }, [dragOver, context.startIndex, index, context.isDragging]);
185
- return _jsxs(Item, { draggable: !showIndicator, showIndicator: showIndicator, active: active, dragging: context.isDragging && context.startIndex === index, orientation: orientation, "data-drag-index": index, onDragStart: !showIndicator ? dragStartHandler : undefined, onDragOver: dragOverHandler, onDragLeave: dragExitHandler, onDrop: dropHandler, onTouchStart: !showIndicator ? touchStartHandler : undefined, onTouchMove: touchMoveHandler, onTouchEnd: touchEndHandler, onTouchCancel: touchEndHandler, children: [showIndicator && _jsx(DragKnob, { draggable: true, onDragStart: dragStartHandler, onTouchStart: touchStartHandler, children: _jsx(DragIndicator, {}) }), _jsx(Container, { children: children })] });
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
+ });
186
263
  }
187
- //# sourceMappingURL=DragItem.js.map
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,SAAS,EAAqB,MAAM,OAAO,CAAC;AACvH,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;AAa5C,wDAAwD;AACxD,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAuF;cAChG,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM;;mBAE5C,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;4BACrC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,KAAK,WAAW,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;IAC3F,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa;+BACZ,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,KAAK,WAAW,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;IAC9F,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa;6BACd,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,KAAK,WAAW,CAAC,UAAU,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;IAC9F,CAAC,CA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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,G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SAAAA;QACnDI,WAAAA,EAAa9C,gBAAAA;QACb+C,UAAAA,EAAYlC,eAAAA;QACZmC,aAAAA,EAAenC,eAAAA;;AAEd/D,YAAAA,aAAAA,kBACGmG,GAAA,CAACxF,QAAAA,EAAAA;gBACGwE,SAAS,EAAA,IAAA;gBACTG,IAAAA,EAAK,QAAA;AACLC,gBAAAA,YAAAA,EAAY/D,SAAS8C,IAAAA,CAAK8B,mBAAAA;gBAC1BT,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,10 +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;
8
+ drop: (index: number | null) => void;
9
+ onDrop: (start: number, end: number) => void;
10
+ cancel: () => void;
11
+ startGrab: (index: number) => void;
9
12
  isDragging: boolean;
10
13
  setIsDragging: (value: boolean) => void;
11
14
  setDragOver: (value: number) => void;
12
- }>;
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>;
@@ -1,8 +1,11 @@
1
- import { createContext } from "react";
2
- export var ORIENTATION;
3
- (function (ORIENTATION) {
1
+ import { createContext } from 'react';
2
+
3
+ var ORIENTATION = /*#__PURE__*/ function(ORIENTATION) {
4
4
  ORIENTATION["HORIZONTAL"] = "horizontal";
5
5
  ORIENTATION["VERTICAL"] = "vertical";
6
- })(ORIENTATION || (ORIENTATION = {}));
7
- export const DragContext = createContext(null);
8
- //# sourceMappingURL=types.js.map
6
+ return ORIENTATION;
7
+ }({});
8
+ const DragContext = createContext(null);
9
+
10
+ export { DragContext, ORIENTATION };
11
+ //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/DragAndDrop/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACnB,wCAAuB,CAAA;IACvB,oCAAmB,CAAA;AACvB,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAOrC,IAAI,CAAC,CAAC"}
1
+ {"version":3,"file":"types.js","sources":["../../../src/components/DragAndDrop/types.ts"],"sourcesContent":["import { createContext } from 'react';\n\nexport enum ORIENTATION {\n HORIZONTAL = 'horizontal',\n VERTICAL = 'vertical',\n}\n\nexport const DragContext = createContext<{\n startIndex: number | null;\n setStartIndex: (value: number) => void;\n drop: (index: number | null) => void;\n onDrop: (start: number, end: number) => void;\n cancel: () => void;\n startGrab: (index: number) => void;\n isDragging: boolean;\n setIsDragging: (value: boolean) => void;\n setDragOver: (value: number) => void;\n i18n: {\n itemAriaLabelTemplate: string;\n dragHandleAriaLabel: string;\n grabbedAnnouncementTemplate: string;\n movedAnnouncementTemplate: string;\n droppedAnnouncementTemplate: string;\n cancelledAnnouncementTemplate: string;\n 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 };\n} | null>(null);\n"],"names":["ORIENTATION","DragContext","createContext"],"mappings":";;AAEO,IAAA,WAAKA,iBAAAA,SAAAA,WAAAA,EAAAA;;;AAAAA,IAAAA,OAAAA,WAAAA;AAGX,CAAA,CAAA,EAAA;AAEM,MAAMC,WAAAA,GAAcC,aAAAA,CA6BjB,IAAA;;;;"}
@@ -1,47 +1,111 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  export { Header as DrawerHeader, Body as DrawerBody, Footer as DrawerFooter, } from '../../shared/styles';
4
3
  export declare enum DRAWER_POSITION {
5
4
  LEFT = "LEFT",
6
5
  RIGHT = "RIGHT",
7
6
  BOTTOM = "BOTTOM"
8
7
  }
9
- type DrawerProps = PropTypes.InferProps<typeof Drawer.propTypes>;
8
+ type DrawerProps = {
9
+ /** Opens the drawer */
10
+ open: boolean;
11
+ /** position of the drawer */
12
+ position: DRAWER_POSITION;
13
+ /** size of the drawer */
14
+ size?: string;
15
+ /** Shows an overlay behind the drawer. */
16
+ overlay?: boolean;
17
+ /** Closes the drawer on esc */
18
+ closeOnEsc?: boolean;
19
+ /** Closes the drawer on overlay click */
20
+ closeOnOverlayClick?: boolean;
21
+ /** Call back function called when the drawer closes. */
22
+ onClose?: () => void;
23
+ /** Ref to the drawer element */
24
+ forwardRef?: React.Ref<HTMLDivElement> | React.MutableRefObject<HTMLDivElement | null>;
25
+ };
10
26
  interface DrawerState {
11
27
  open: boolean;
12
28
  }
29
+ /**
30
+ * Drawer component
31
+ *
32
+ * A panel that slides in from the edge of the screen.
33
+ * It sits on top of the application content and is often used for navigation or details.
34
+ *
35
+ * Accessibility:
36
+ * - Implements ARIA `role="dialog"` and `aria-modal="true"`.
37
+ * - Traps focus effectively within the drawer while open.
38
+ * - Restores focus to the triggering element upon closure.
39
+ * - Supports closing via ESC key and overlay click.
40
+ */
13
41
  export default class Drawer extends React.Component<React.PropsWithChildren<DrawerProps>, DrawerState> {
14
42
  state: {
15
43
  open: boolean;
16
44
  };
17
- static propTypes: {
18
- /** Opens the drawer */
19
- open: PropTypes.Validator<boolean>;
20
- /** position of the drawer */
21
- position: PropTypes.Requireable<DRAWER_POSITION>;
22
- /** size of the drawer */
23
- size: PropTypes.Requireable<string>;
24
- /** Shows an overlay behind the drawer. */
25
- overlay: PropTypes.Requireable<boolean>;
26
- /** Closes the drawer on esc */
27
- closeOnEsc: PropTypes.Requireable<boolean>;
28
- /** Closes the drawer on overlay click */
29
- closeOnOverlayClick: PropTypes.Requireable<boolean>;
30
- /** Call back function called when the drawer closes. */
31
- onClose: PropTypes.Requireable<(...args: any[]) => any>;
32
- };
33
45
  static defaultProps: {
34
46
  overlay: boolean;
35
47
  position: DRAWER_POSITION;
36
48
  closeOnEsc: boolean;
37
49
  closeOnOverlayClick: boolean;
38
50
  };
51
+ /**
52
+ * Syncs state with props.
53
+ */
39
54
  static getDerivedStateFromProps(props: DrawerProps): {
40
55
  open: boolean;
41
- };
42
- private layer;
43
- private closeCallback;
56
+ } | null;
57
+ private layer?;
58
+ private closeCallback?;
59
+ /**
60
+ * Internal close handler.
61
+ * Restores focus and calls the external onClose callback.
62
+ */
44
63
  private onClose;
64
+ private lastFocusedElement;
65
+ private drawerRef;
66
+ /**
67
+ * Retrieves all focusable elements within the drawer.
68
+ */
69
+ private getFocusableElements;
70
+ /**
71
+ * Handles keydown events to implement the focus trap.
72
+ * Traps Tab and Shift+Tab within the drawer.
73
+ */
74
+ private handleKeyDown;
75
+ /**
76
+ * Lifecycle method to save the currently focused element when the drawer mounts while open.
77
+ */
78
+ componentDidMount(): void;
79
+ /**
80
+ * Lifecycle method to restore focus when the drawer unmounts.
81
+ */
82
+ componentWillUnmount(): void;
83
+ /**
84
+ * Restores focus to the element that was focused before the drawer opened.
85
+ */
86
+ private restoreFocus;
87
+ /**
88
+ * Callback ref to capture the Drawer DOM element.
89
+ * Triggers initial focus setting when the element mounts.
90
+ */
91
+ private setDrawerRef;
92
+ /**
93
+ * Sets initial focus within the drawer.
94
+ * Tries to focus the header first, then the first interactive element, or falls back to the container.
95
+ */
96
+ private setInitialFocus;
97
+ /**
98
+ * Lifecycle method to handle Drawer updates.
99
+ * Manages opening/closing logic via LayerManager and focus preservation.
100
+ */
45
101
  getSnapshotBeforeUpdate(prevProps: DrawerProps): void;
46
- render(): import("@emotion/react/jsx-runtime").JSX.Element;
102
+ /**
103
+ * Sets the ref prop passed to the Drawer Container component.
104
+ * @param node
105
+ */
106
+ setRefProp: (node: HTMLDivElement | null) => void;
107
+ /**
108
+ * Renders the Drawer component via the LayerManager portal.
109
+ */
110
+ render(): import("@emotion/react/jsx-runtime").JSX.Element | null;
47
111
  }