@react-aria/dnd 3.11.2 → 3.11.4

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.
@@ -61,7 +61,7 @@ const $2dccaca1f4baa446$export$905ab40ac2179daa = /*#__PURE__*/ (0, ($parcel$int
61
61
  return /*#__PURE__*/ (0, ($parcel$interopDefault($l6JIF$react))).createElement("div", {
62
62
  style: {
63
63
  zIndex: -100,
64
- position: 'absolute',
64
+ position: 'fixed',
65
65
  top: 0,
66
66
  left: -100000
67
67
  },
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAeM,MAAM,0DAEb,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC,SAAS,YAAY,KAAuB,EAAE,GAA6C;IAC1G,IAAI,SAAS,MAAM,QAAQ;IAC3B,IAAI,CAAC,UAAU,YAAY,GAAG,CAAA,GAAA,qBAAO,EAAsB;IAC3D,IAAI,SAAS,CAAA,GAAA,mBAAK,EAAyB;IAC3C,IAAI,MAAM,CAAA,GAAA,mBAAK,EAAwD;IAEvE,CAAA,GAAA,gCAAkB,EAAE,KAAK,IAAM,CAAC,OAAmB;YACjD,qFAAqF;YACrF,kGAAkG;YAElG,IAAI,SAAS,OAAO;YACpB,IAAI;YACJ,IAAI;YACJ,IAAI;YAEJ,IAAI,UAAU,OAAO,WAAW,YAAY,aAAa,QAAQ;gBAC/D,UAAU,OAAO,OAAO;gBACxB,UAAU,OAAO,CAAC;gBAClB,UAAU,OAAO,CAAC;YACpB,OACE,UAAU;YAGZ,CAAA,GAAA,yBAAQ,EAAE;gBACR,YAAY;YACd;YAEA,+CAA+C;YAC/C,SAAS,OAAO,OAAO,EAAE,SAAS;YAElC,kFAAkF;YAClF,IAAI,OAAO,GAAG,sBAAsB;gBAClC,YAAY;YACd;QACF,GAAG;QAAC;KAAO;IAEX,CAAA,GAAA,sBAAQ,EAAE;QACR,OAAO;YACL,IAAI,IAAI,OAAO,EACb,qBAAqB,IAAI,OAAO;QAEpC;IACF,GAAG,EAAE;IAEL,IAAI,CAAC,UACH,OAAO;IAGT,qBACE,0DAAC;QAAI,OAAO;YAAC,QAAQ;YAAM,UAAU;YAAY,KAAK;YAAG,MAAM;QAAO;QAAG,KAAK;OAC3E;AAGP","sources":["packages/@react-aria/dnd/src/DragPreview.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DragItem, DragPreviewRenderer} from '@react-types/shared';\nimport {flushSync} from 'react-dom';\nimport React, {ForwardedRef, JSX, useEffect, useImperativeHandle, useRef, useState} from 'react';\n\nexport interface DragPreviewProps {\n /**\n * A render function which returns a preview element, or an object containing the element\n * and a custom offset. If an object is returned, the provided `x` and `y` values will be\n * used as the drag preview offset instead of the default calculation.\n */\n children: (items: DragItem[]) => JSX.Element | {element: JSX.Element, x: number, y: number} | null\n}\n\nexport const DragPreview:\n React.ForwardRefExoticComponent<DragPreviewProps & React.RefAttributes<DragPreviewRenderer | null>> =\nReact.forwardRef(function DragPreview(props: DragPreviewProps, ref: ForwardedRef<DragPreviewRenderer | null>) {\n let render = props.children;\n let [children, setChildren] = useState<JSX.Element | null>(null);\n let domRef = useRef<HTMLDivElement | null>(null);\n let raf = useRef<ReturnType<typeof requestAnimationFrame> | undefined>(undefined);\n\n useImperativeHandle(ref, () => (items: DragItem[], callback: (node: HTMLElement | null, x?: number, y?: number) => void) => {\n // This will be called during the onDragStart event by useDrag. We need to render the\n // preview synchronously before this event returns so we can call event.dataTransfer.setDragImage.\n\n let result = render(items);\n let element: JSX.Element | null;\n let offsetX: number | undefined;\n let offsetY: number | undefined;\n\n if (result && typeof result === 'object' && 'element' in result) {\n element = result.element;\n offsetX = result.x;\n offsetY = result.y;\n } else {\n element = result as JSX.Element | null;\n }\n\n flushSync(() => {\n setChildren(element);\n });\n\n // Yield back to useDrag to set the drag image.\n callback(domRef.current, offsetX, offsetY);\n\n // Remove the preview from the DOM after a frame so the browser has time to paint.\n raf.current = requestAnimationFrame(() => {\n setChildren(null);\n });\n }, [render]);\n\n useEffect(() => {\n return () => {\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n }\n };\n }, []);\n\n if (!children) {\n return null;\n }\n\n return (\n <div style={{zIndex: -100, position: 'absolute', top: 0, left: -100000}} ref={domRef}>\n {children}\n </div>\n );\n});\n"],"names":[],"version":3,"file":"DragPreview.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAeM,MAAM,0DAEb,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC,SAAS,YAAY,KAAuB,EAAE,GAA6C;IAC1G,IAAI,SAAS,MAAM,QAAQ;IAC3B,IAAI,CAAC,UAAU,YAAY,GAAG,CAAA,GAAA,qBAAO,EAAsB;IAC3D,IAAI,SAAS,CAAA,GAAA,mBAAK,EAAyB;IAC3C,IAAI,MAAM,CAAA,GAAA,mBAAK,EAAwD;IAEvE,CAAA,GAAA,gCAAkB,EAAE,KAAK,IAAM,CAAC,OAAmB;YACjD,qFAAqF;YACrF,kGAAkG;YAElG,IAAI,SAAS,OAAO;YACpB,IAAI;YACJ,IAAI;YACJ,IAAI;YAEJ,IAAI,UAAU,OAAO,WAAW,YAAY,aAAa,QAAQ;gBAC/D,UAAU,OAAO,OAAO;gBACxB,UAAU,OAAO,CAAC;gBAClB,UAAU,OAAO,CAAC;YACpB,OACE,UAAU;YAGZ,CAAA,GAAA,yBAAQ,EAAE;gBACR,YAAY;YACd;YAEA,+CAA+C;YAC/C,SAAS,OAAO,OAAO,EAAE,SAAS;YAElC,kFAAkF;YAClF,IAAI,OAAO,GAAG,sBAAsB;gBAClC,YAAY;YACd;QACF,GAAG;QAAC;KAAO;IAEX,CAAA,GAAA,sBAAQ,EAAE;QACR,OAAO;YACL,IAAI,IAAI,OAAO,EACb,qBAAqB,IAAI,OAAO;QAEpC;IACF,GAAG,EAAE;IAEL,IAAI,CAAC,UACH,OAAO;IAGT,qBACE,0DAAC;QAAI,OAAO;YAAC,QAAQ;YAAM,UAAU;YAAS,KAAK;YAAG,MAAM;QAAO;QAAG,KAAK;OACxE;AAGP","sources":["packages/@react-aria/dnd/src/DragPreview.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DragItem, DragPreviewRenderer} from '@react-types/shared';\nimport {flushSync} from 'react-dom';\nimport React, {ForwardedRef, JSX, useEffect, useImperativeHandle, useRef, useState} from 'react';\n\nexport interface DragPreviewProps {\n /**\n * A render function which returns a preview element, or an object containing the element\n * and a custom offset. If an object is returned, the provided `x` and `y` values will be\n * used as the drag preview offset instead of the default calculation.\n */\n children: (items: DragItem[]) => JSX.Element | {element: JSX.Element, x: number, y: number} | null\n}\n\nexport const DragPreview:\n React.ForwardRefExoticComponent<DragPreviewProps & React.RefAttributes<DragPreviewRenderer | null>> =\nReact.forwardRef(function DragPreview(props: DragPreviewProps, ref: ForwardedRef<DragPreviewRenderer | null>) {\n let render = props.children;\n let [children, setChildren] = useState<JSX.Element | null>(null);\n let domRef = useRef<HTMLDivElement | null>(null);\n let raf = useRef<ReturnType<typeof requestAnimationFrame> | undefined>(undefined);\n\n useImperativeHandle(ref, () => (items: DragItem[], callback: (node: HTMLElement | null, x?: number, y?: number) => void) => {\n // This will be called during the onDragStart event by useDrag. We need to render the\n // preview synchronously before this event returns so we can call event.dataTransfer.setDragImage.\n\n let result = render(items);\n let element: JSX.Element | null;\n let offsetX: number | undefined;\n let offsetY: number | undefined;\n\n if (result && typeof result === 'object' && 'element' in result) {\n element = result.element;\n offsetX = result.x;\n offsetY = result.y;\n } else {\n element = result as JSX.Element | null;\n }\n\n flushSync(() => {\n setChildren(element);\n });\n\n // Yield back to useDrag to set the drag image.\n callback(domRef.current, offsetX, offsetY);\n\n // Remove the preview from the DOM after a frame so the browser has time to paint.\n raf.current = requestAnimationFrame(() => {\n setChildren(null);\n });\n }, [render]);\n\n useEffect(() => {\n return () => {\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n }\n };\n }, []);\n\n if (!children) {\n return null;\n }\n\n return (\n <div style={{zIndex: -100, position: 'fixed', top: 0, left: -100000}} ref={domRef}>\n {children}\n </div>\n );\n});\n"],"names":[],"version":3,"file":"DragPreview.main.js.map"}
@@ -51,7 +51,7 @@ const $ad0e3f3d9c50e4ba$export$905ab40ac2179daa = /*#__PURE__*/ (0, $eLjnH$react
51
51
  return /*#__PURE__*/ (0, $eLjnH$react).createElement("div", {
52
52
  style: {
53
53
  zIndex: -100,
54
- position: 'absolute',
54
+ position: 'fixed',
55
55
  top: 0,
56
56
  left: -100000
57
57
  },
@@ -51,7 +51,7 @@ const $ad0e3f3d9c50e4ba$export$905ab40ac2179daa = /*#__PURE__*/ (0, $eLjnH$react
51
51
  return /*#__PURE__*/ (0, $eLjnH$react).createElement("div", {
52
52
  style: {
53
53
  zIndex: -100,
54
- position: 'absolute',
54
+ position: 'fixed',
55
55
  top: 0,
56
56
  left: -100000
57
57
  },
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAeM,MAAM,0DAEb,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC,SAAS,YAAY,KAAuB,EAAE,GAA6C;IAC1G,IAAI,SAAS,MAAM,QAAQ;IAC3B,IAAI,CAAC,UAAU,YAAY,GAAG,CAAA,GAAA,eAAO,EAAsB;IAC3D,IAAI,SAAS,CAAA,GAAA,aAAK,EAAyB;IAC3C,IAAI,MAAM,CAAA,GAAA,aAAK,EAAwD;IAEvE,CAAA,GAAA,0BAAkB,EAAE,KAAK,IAAM,CAAC,OAAmB;YACjD,qFAAqF;YACrF,kGAAkG;YAElG,IAAI,SAAS,OAAO;YACpB,IAAI;YACJ,IAAI;YACJ,IAAI;YAEJ,IAAI,UAAU,OAAO,WAAW,YAAY,aAAa,QAAQ;gBAC/D,UAAU,OAAO,OAAO;gBACxB,UAAU,OAAO,CAAC;gBAClB,UAAU,OAAO,CAAC;YACpB,OACE,UAAU;YAGZ,CAAA,GAAA,gBAAQ,EAAE;gBACR,YAAY;YACd;YAEA,+CAA+C;YAC/C,SAAS,OAAO,OAAO,EAAE,SAAS;YAElC,kFAAkF;YAClF,IAAI,OAAO,GAAG,sBAAsB;gBAClC,YAAY;YACd;QACF,GAAG;QAAC;KAAO;IAEX,CAAA,GAAA,gBAAQ,EAAE;QACR,OAAO;YACL,IAAI,IAAI,OAAO,EACb,qBAAqB,IAAI,OAAO;QAEpC;IACF,GAAG,EAAE;IAEL,IAAI,CAAC,UACH,OAAO;IAGT,qBACE,gCAAC;QAAI,OAAO;YAAC,QAAQ;YAAM,UAAU;YAAY,KAAK;YAAG,MAAM;QAAO;QAAG,KAAK;OAC3E;AAGP","sources":["packages/@react-aria/dnd/src/DragPreview.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DragItem, DragPreviewRenderer} from '@react-types/shared';\nimport {flushSync} from 'react-dom';\nimport React, {ForwardedRef, JSX, useEffect, useImperativeHandle, useRef, useState} from 'react';\n\nexport interface DragPreviewProps {\n /**\n * A render function which returns a preview element, or an object containing the element\n * and a custom offset. If an object is returned, the provided `x` and `y` values will be\n * used as the drag preview offset instead of the default calculation.\n */\n children: (items: DragItem[]) => JSX.Element | {element: JSX.Element, x: number, y: number} | null\n}\n\nexport const DragPreview:\n React.ForwardRefExoticComponent<DragPreviewProps & React.RefAttributes<DragPreviewRenderer | null>> =\nReact.forwardRef(function DragPreview(props: DragPreviewProps, ref: ForwardedRef<DragPreviewRenderer | null>) {\n let render = props.children;\n let [children, setChildren] = useState<JSX.Element | null>(null);\n let domRef = useRef<HTMLDivElement | null>(null);\n let raf = useRef<ReturnType<typeof requestAnimationFrame> | undefined>(undefined);\n\n useImperativeHandle(ref, () => (items: DragItem[], callback: (node: HTMLElement | null, x?: number, y?: number) => void) => {\n // This will be called during the onDragStart event by useDrag. We need to render the\n // preview synchronously before this event returns so we can call event.dataTransfer.setDragImage.\n\n let result = render(items);\n let element: JSX.Element | null;\n let offsetX: number | undefined;\n let offsetY: number | undefined;\n\n if (result && typeof result === 'object' && 'element' in result) {\n element = result.element;\n offsetX = result.x;\n offsetY = result.y;\n } else {\n element = result as JSX.Element | null;\n }\n\n flushSync(() => {\n setChildren(element);\n });\n\n // Yield back to useDrag to set the drag image.\n callback(domRef.current, offsetX, offsetY);\n\n // Remove the preview from the DOM after a frame so the browser has time to paint.\n raf.current = requestAnimationFrame(() => {\n setChildren(null);\n });\n }, [render]);\n\n useEffect(() => {\n return () => {\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n }\n };\n }, []);\n\n if (!children) {\n return null;\n }\n\n return (\n <div style={{zIndex: -100, position: 'absolute', top: 0, left: -100000}} ref={domRef}>\n {children}\n </div>\n );\n});\n"],"names":[],"version":3,"file":"DragPreview.module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAeM,MAAM,0DAEb,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC,SAAS,YAAY,KAAuB,EAAE,GAA6C;IAC1G,IAAI,SAAS,MAAM,QAAQ;IAC3B,IAAI,CAAC,UAAU,YAAY,GAAG,CAAA,GAAA,eAAO,EAAsB;IAC3D,IAAI,SAAS,CAAA,GAAA,aAAK,EAAyB;IAC3C,IAAI,MAAM,CAAA,GAAA,aAAK,EAAwD;IAEvE,CAAA,GAAA,0BAAkB,EAAE,KAAK,IAAM,CAAC,OAAmB;YACjD,qFAAqF;YACrF,kGAAkG;YAElG,IAAI,SAAS,OAAO;YACpB,IAAI;YACJ,IAAI;YACJ,IAAI;YAEJ,IAAI,UAAU,OAAO,WAAW,YAAY,aAAa,QAAQ;gBAC/D,UAAU,OAAO,OAAO;gBACxB,UAAU,OAAO,CAAC;gBAClB,UAAU,OAAO,CAAC;YACpB,OACE,UAAU;YAGZ,CAAA,GAAA,gBAAQ,EAAE;gBACR,YAAY;YACd;YAEA,+CAA+C;YAC/C,SAAS,OAAO,OAAO,EAAE,SAAS;YAElC,kFAAkF;YAClF,IAAI,OAAO,GAAG,sBAAsB;gBAClC,YAAY;YACd;QACF,GAAG;QAAC;KAAO;IAEX,CAAA,GAAA,gBAAQ,EAAE;QACR,OAAO;YACL,IAAI,IAAI,OAAO,EACb,qBAAqB,IAAI,OAAO;QAEpC;IACF,GAAG,EAAE;IAEL,IAAI,CAAC,UACH,OAAO;IAGT,qBACE,gCAAC;QAAI,OAAO;YAAC,QAAQ;YAAM,UAAU;YAAS,KAAK;YAAG,MAAM;QAAO;QAAG,KAAK;OACxE;AAGP","sources":["packages/@react-aria/dnd/src/DragPreview.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DragItem, DragPreviewRenderer} from '@react-types/shared';\nimport {flushSync} from 'react-dom';\nimport React, {ForwardedRef, JSX, useEffect, useImperativeHandle, useRef, useState} from 'react';\n\nexport interface DragPreviewProps {\n /**\n * A render function which returns a preview element, or an object containing the element\n * and a custom offset. If an object is returned, the provided `x` and `y` values will be\n * used as the drag preview offset instead of the default calculation.\n */\n children: (items: DragItem[]) => JSX.Element | {element: JSX.Element, x: number, y: number} | null\n}\n\nexport const DragPreview:\n React.ForwardRefExoticComponent<DragPreviewProps & React.RefAttributes<DragPreviewRenderer | null>> =\nReact.forwardRef(function DragPreview(props: DragPreviewProps, ref: ForwardedRef<DragPreviewRenderer | null>) {\n let render = props.children;\n let [children, setChildren] = useState<JSX.Element | null>(null);\n let domRef = useRef<HTMLDivElement | null>(null);\n let raf = useRef<ReturnType<typeof requestAnimationFrame> | undefined>(undefined);\n\n useImperativeHandle(ref, () => (items: DragItem[], callback: (node: HTMLElement | null, x?: number, y?: number) => void) => {\n // This will be called during the onDragStart event by useDrag. We need to render the\n // preview synchronously before this event returns so we can call event.dataTransfer.setDragImage.\n\n let result = render(items);\n let element: JSX.Element | null;\n let offsetX: number | undefined;\n let offsetY: number | undefined;\n\n if (result && typeof result === 'object' && 'element' in result) {\n element = result.element;\n offsetX = result.x;\n offsetY = result.y;\n } else {\n element = result as JSX.Element | null;\n }\n\n flushSync(() => {\n setChildren(element);\n });\n\n // Yield back to useDrag to set the drag image.\n callback(domRef.current, offsetX, offsetY);\n\n // Remove the preview from the DOM after a frame so the browser has time to paint.\n raf.current = requestAnimationFrame(() => {\n setChildren(null);\n });\n }, [render]);\n\n useEffect(() => {\n return () => {\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n }\n };\n }, []);\n\n if (!children) {\n return null;\n }\n\n return (\n <div style={{zIndex: -100, position: 'fixed', top: 0, left: -100000}} ref={domRef}>\n {children}\n </div>\n );\n});\n"],"names":[],"version":3,"file":"DragPreview.module.js.map"}
@@ -76,23 +76,26 @@ function $6e16de4c92a0f271$var$nextDropTarget(keyboardDelegate, collection, targ
76
76
  {
77
77
  // If this is the last sibling in a level, traverse to the parent.
78
78
  let targetNode = collection.getItem(target.key);
79
- if (targetNode && targetNode.nextKey == null && targetNode.parentKey != null) {
79
+ let nextItemInSameLevel = (targetNode === null || targetNode === void 0 ? void 0 : targetNode.nextKey) != null ? collection.getItem(targetNode.nextKey) : null;
80
+ while(nextItemInSameLevel != null && nextItemInSameLevel.type !== 'item')nextItemInSameLevel = nextItemInSameLevel.nextKey != null ? collection.getItem(nextItemInSameLevel.nextKey) : null;
81
+ if (targetNode && nextItemInSameLevel == null && targetNode.parentKey != null) {
80
82
  // If the parent item has an item after it, use the "before" position.
81
83
  let parentNode = collection.getItem(targetNode.parentKey);
82
- if ((parentNode === null || parentNode === void 0 ? void 0 : parentNode.nextKey) != null) return {
84
+ const nextNode = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.nextKey) != null ? collection.getItem(parentNode.nextKey) : null;
85
+ if ((nextNode === null || nextNode === void 0 ? void 0 : nextNode.type) === 'item') return {
83
86
  type: 'item',
84
- key: parentNode.nextKey,
87
+ key: nextNode.key,
85
88
  dropPosition: 'before'
86
89
  };
87
- if (parentNode) return {
90
+ if ((parentNode === null || parentNode === void 0 ? void 0 : parentNode.type) === 'item') return {
88
91
  type: 'item',
89
92
  key: parentNode.key,
90
93
  dropPosition: 'after'
91
94
  };
92
95
  }
93
- if ((targetNode === null || targetNode === void 0 ? void 0 : targetNode.nextKey) != null) return {
96
+ if (nextItemInSameLevel) return {
94
97
  type: 'item',
95
- key: targetNode.nextKey,
98
+ key: nextItemInSameLevel.key,
96
99
  dropPosition: 'on'
97
100
  };
98
101
  }
@@ -111,8 +114,9 @@ function $6e16de4c92a0f271$var$previousDropTarget(keyboardDelegate, collection,
111
114
  let prevKey = null;
112
115
  let lastKey = (_keyboardDelegate_getLastKey = keyboardDelegate.getLastKey) === null || _keyboardDelegate_getLastKey === void 0 ? void 0 : _keyboardDelegate_getLastKey.call(keyboardDelegate);
113
116
  while(lastKey != null){
114
- prevKey = lastKey;
115
117
  let node = collection.getItem(lastKey);
118
+ if ((node === null || node === void 0 ? void 0 : node.type) !== 'item') break;
119
+ prevKey = lastKey;
116
120
  lastKey = node === null || node === void 0 ? void 0 : node.parentKey;
117
121
  }
118
122
  if (prevKey != null) return {
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAGO,SAAS,0CACd,gBAAkC,EAClC,UAAqC,EACrC,MAAqC,EACrC,SAA2C,EAC3C,MAAM,KAAK,EACX,OAAO,KAAK;IAEZ,OAAQ;QACN,KAAK;YACH,OAAO,MACH,qCAAe,kBAAkB,YAAY,QAAQ,MAAM,UAC3D,yCAAmB,kBAAkB,YAAY,QAAQ,MAAM;QACrE,KAAK;YACH,OAAO,MACH,yCAAmB,kBAAkB,YAAY,QAAQ,MAAM,WAC/D,qCAAe,kBAAkB,YAAY,QAAQ,MAAM;QACjE,KAAK;YACH,OAAO,yCAAmB,kBAAkB,YAAY,QAAQ;QAClE,KAAK;YACH,OAAO,qCAAe,kBAAkB,YAAY,QAAQ;IAChE;AACF;AAEA,SAAS,qCACP,gBAAkC,EAClC,UAAqC,EACrC,MAAqC,EACrC,OAAO,KAAK,EACZ,aAAsC,IAAI;IAE1C,IAAI,CAAC,QACH,OAAO;QACL,MAAM;IACR;IAGF,IAAI,OAAO,IAAI,KAAK,QAAQ;YACZ;YAAA;QAAd,IAAI,UAAU,CAAA,kCAAA,gCAAA,iBAAiB,WAAW,cAA5B,oDAAA,mCAAA,+BAAA,4CAAA,iCAAoC;QAClD,IAAI,WAAW,MACb,OAAO;YACL,MAAM;YACN,KAAK;YACL,cAAc;QAChB;QAGF,OAAO;IACT;IAEA,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AAK,UAAU,GAAG;YAClB,cAAc;QAChB;IAEJ;IAEA,OAAO;AACT","sources":["packages/@react-aria/dnd/src/DropTargetKeyboardNavigation.ts"],"sourcesContent":["import {Collection, DropTarget, Key, KeyboardDelegate, Node} from '@react-types/shared';\nimport {getChildNodes} from '@react-stately/collections';\n\nexport function navigate(\n keyboardDelegate: KeyboardDelegate,\n collection: Collection<Node<unknown>>,\n target: DropTarget | null | undefined,\n direction: 'left' | 'right' | 'up' | 'down',\n rtl = false,\n wrap = false\n): DropTarget | null {\n switch (direction) {\n case 'left':\n return rtl \n ? nextDropTarget(keyboardDelegate, collection, target, wrap, 'left')\n : previousDropTarget(keyboardDelegate, collection, target, wrap, 'left');\n case 'right':\n return rtl \n ? previousDropTarget(keyboardDelegate, collection, target, wrap, 'right')\n : nextDropTarget(keyboardDelegate, collection, target, wrap, 'right');\n case 'up':\n return previousDropTarget(keyboardDelegate, collection, target, wrap);\n case 'down':\n return nextDropTarget(keyboardDelegate, collection, target, wrap);\n }\n}\n\nfunction nextDropTarget(\n keyboardDelegate: KeyboardDelegate,\n collection: Collection<Node<unknown>>,\n target: DropTarget | null | undefined,\n wrap = false,\n horizontal: 'left' | 'right' | null = null\n): DropTarget | null {\n if (!target) {\n return {\n type: 'root'\n };\n }\n\n if (target.type === 'root') {\n let nextKey = keyboardDelegate.getFirstKey?.() ?? null;\n if (nextKey != null) {\n return {\n type: 'item',\n key: nextKey,\n dropPosition: 'before'\n };\n }\n\n return null;\n }\n\n if (target.type === 'item') {\n let nextKey: Key | null | undefined = null;\n if (horizontal) {\n nextKey = horizontal === 'right' ? keyboardDelegate.getKeyRightOf?.(target.key) : keyboardDelegate.getKeyLeftOf?.(target.key);\n } else {\n nextKey = keyboardDelegate.getKeyBelow?.(target.key);\n }\n let nextCollectionKey = collection.getKeyAfter(target.key);\n\n // If the keyboard delegate did not move to the next key in the collection,\n // jump to that key with the same drop position. Otherwise, try the other\n // drop positions on the current key first.\n if (nextKey != null && nextKey !== nextCollectionKey) {\n return {\n type: 'item',\n key: nextKey,\n dropPosition: target.dropPosition\n };\n }\n \n switch (target.dropPosition) {\n case 'before': {\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'on'\n };\n }\n case 'on': {\n // If there are nested items, traverse to them prior to the \"after\" position of this target.\n // If the next key is on the same level, then its \"before\" position is equivalent to this item's \"after\" position.\n let targetNode = collection.getItem(target.key);\n let nextNode = nextKey != null ? collection.getItem(nextKey) : null;\n if (targetNode && nextNode && nextNode.level >= targetNode.level) {\n return {\n type: 'item',\n key: nextNode.key,\n dropPosition: 'before'\n };\n }\n\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'after'\n };\n }\n case 'after': {\n // If this is the last sibling in a level, traverse to the parent.\n let targetNode = collection.getItem(target.key); \n if (targetNode && targetNode.nextKey == null && targetNode.parentKey != null) {\n // If the parent item has an item after it, use the \"before\" position.\n let parentNode = collection.getItem(targetNode.parentKey);\n if (parentNode?.nextKey != null) {\n return {\n type: 'item',\n key: parentNode.nextKey,\n dropPosition: 'before'\n };\n }\n\n if (parentNode) {\n return {\n type: 'item',\n key: parentNode.key,\n dropPosition: 'after'\n };\n }\n }\n\n if (targetNode?.nextKey != null) {\n return {\n type: 'item',\n key: targetNode.nextKey,\n dropPosition: 'on'\n };\n }\n }\n }\n }\n\n if (wrap) {\n return {\n type: 'root'\n };\n }\n\n return null;\n}\n\nfunction previousDropTarget(\n keyboardDelegate: KeyboardDelegate,\n collection: Collection<Node<unknown>>,\n target: DropTarget | null | undefined,\n wrap = false,\n horizontal: 'left' | 'right' | null = null\n): DropTarget | null {\n // Start after the last root-level item.\n if (!target || (wrap && target.type === 'root')) {\n // Keyboard delegate gets the deepest item but we want the shallowest.\n let prevKey: Key | null = null;\n let lastKey = keyboardDelegate.getLastKey?.();\n while (lastKey != null) {\n prevKey = lastKey;\n let node = collection.getItem(lastKey);\n lastKey = node?.parentKey;\n }\n\n if (prevKey != null) {\n return {\n type: 'item',\n key: prevKey,\n dropPosition: 'after'\n };\n }\n\n return null;\n }\n\n if (target.type === 'item') {\n let prevKey: Key | null | undefined = null;\n if (horizontal) {\n prevKey = horizontal === 'left' ? keyboardDelegate.getKeyLeftOf?.(target.key) : keyboardDelegate.getKeyRightOf?.(target.key);\n } else {\n prevKey = keyboardDelegate.getKeyAbove?.(target.key);\n }\n let prevCollectionKey = collection.getKeyBefore(target.key);\n\n // If the keyboard delegate did not move to the next key in the collection,\n // jump to that key with the same drop position. Otherwise, try the other\n // drop positions on the current key first.\n if (prevKey != null && prevKey !== prevCollectionKey) {\n return {\n type: 'item',\n key: prevKey,\n dropPosition: target.dropPosition\n };\n }\n\n switch (target.dropPosition) {\n case 'before': {\n // Move after the last child of the previous item.\n let targetNode = collection.getItem(target.key);\n if (targetNode && targetNode.prevKey != null) {\n let lastChild = getLastChild(collection, targetNode.prevKey);\n if (lastChild) {\n return lastChild;\n }\n }\n\n if (prevKey != null) {\n return {\n type: 'item',\n key: prevKey,\n dropPosition: 'on'\n };\n }\n\n return {\n type: 'root'\n };\n }\n case 'on': {\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'before'\n };\n }\n case 'after': {\n // Move after the last child of this item.\n let lastChild = getLastChild(collection, target.key);\n if (lastChild) {\n return lastChild;\n }\n\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'on'\n };\n }\n }\n }\n\n if (target.type !== 'root') {\n return {\n type: 'root'\n };\n }\n\n return null;\n}\n\nfunction getLastChild(collection: Collection<Node<unknown>>, key: Key): DropTarget | null {\n // getChildNodes still returns child tree items even when the item is collapsed.\n // Checking if the next item has a greater level is a silly way to determine if the item is expanded.\n let targetNode = collection.getItem(key);\n let nextKey = collection.getKeyAfter(key);\n let nextNode = nextKey != null ? collection.getItem(nextKey) : null;\n if (targetNode && nextNode && nextNode.level > targetNode.level) {\n let children = getChildNodes(targetNode, collection);\n let lastChild: Node<unknown> | null = null;\n for (let child of children) {\n if (child.type === 'item') {\n lastChild = child;\n }\n }\n\n if (lastChild) {\n return {\n type: 'item',\n key: lastChild.key,\n dropPosition: 'after'\n };\n }\n }\n\n return null;\n}\n"],"names":[],"version":3,"file":"DropTargetKeyboardNavigation.main.js.map"}
1
+ {"mappings":";;;;;;;;;AAGO,SAAS,0CACd,gBAAkC,EAClC,UAAqC,EACrC,MAAqC,EACrC,SAA2C,EAC3C,MAAM,KAAK,EACX,OAAO,KAAK;IAEZ,OAAQ;QACN,KAAK;YACH,OAAO,MACH,qCAAe,kBAAkB,YAAY,QAAQ,MAAM,UAC3D,yCAAmB,kBAAkB,YAAY,QAAQ,MAAM;QACrE,KAAK;YACH,OAAO,MACH,yCAAmB,kBAAkB,YAAY,QAAQ,MAAM,WAC/D,qCAAe,kBAAkB,YAAY,QAAQ,MAAM;QACjE,KAAK;YACH,OAAO,yCAAmB,kBAAkB,YAAY,QAAQ;QAClE,KAAK;YACH,OAAO,qCAAe,kBAAkB,YAAY,QAAQ;IAChE;AACF;AAEA,SAAS,qCACP,gBAAkC,EAClC,UAAqC,EACrC,MAAqC,EACrC,OAAO,KAAK,EACZ,aAAsC,IAAI;IAE1C,IAAI,CAAC,QACH,OAAO;QACL,MAAM;IACR;IAGF,IAAI,OAAO,IAAI,KAAK,QAAQ;YACZ;YAAA;QAAd,IAAI,UAAU,CAAA,kCAAA,gCAAA,iBAAiB,WAAW,cAA5B,oDAAA,mCAAA,+BAAA,4CAAA,iCAAoC;QAClD,IAAI,WAAW,MACb,OAAO;YACL,MAAM;YACN,KAAK;YACL,cAAc;QAChB;QAGF,OAAO;IACT;IAEA,IAAI,OAAO,IAAI,KAAK,QAAQ;YAGW,iCAA+C,gCAExE;QAJZ,IAAI,UAAkC;QACtC,IAAI,YACF,UAAU,eAAe,WAAU,kCAAA,iBAAiB,aAAa,cAA9B,sDAAA,qCAAA,kBAAiC,OAAO,GAAG,KAAI,iCAAA,iBAAiB,YAAY,cAA7B,qDAAA,oCAAA,kBAAgC,OAAO,GAAG;aAE5H,WAAU,gCAAA,iBAAiB,WAAW,cAA5B,oDAAA,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AI,SAAS,SAChB,IAAI,MAAM,IAAI,KAAK,QACjB,YAAY;QAIhB,IAAI,WACF,OAAO;YACL,MAAM;YACN,KAAK,UAAU,GAAG;YAClB,cAAc;QAChB;IAEJ;IAEA,OAAO;AACT","sources":["packages/@react-aria/dnd/src/DropTargetKeyboardNavigation.ts"],"sourcesContent":["import {Collection, DropTarget, Key, KeyboardDelegate, Node} from '@react-types/shared';\nimport {getChildNodes} from '@react-stately/collections';\n\nexport function navigate(\n keyboardDelegate: KeyboardDelegate,\n collection: Collection<Node<unknown>>,\n target: DropTarget | null | undefined,\n direction: 'left' | 'right' | 'up' | 'down',\n rtl = false,\n wrap = false\n): DropTarget | null {\n switch (direction) {\n case 'left':\n return rtl \n ? nextDropTarget(keyboardDelegate, collection, target, wrap, 'left')\n : previousDropTarget(keyboardDelegate, collection, target, wrap, 'left');\n case 'right':\n return rtl \n ? previousDropTarget(keyboardDelegate, collection, target, wrap, 'right')\n : nextDropTarget(keyboardDelegate, collection, target, wrap, 'right');\n case 'up':\n return previousDropTarget(keyboardDelegate, collection, target, wrap);\n case 'down':\n return nextDropTarget(keyboardDelegate, collection, target, wrap);\n }\n}\n\nfunction nextDropTarget(\n keyboardDelegate: KeyboardDelegate,\n collection: Collection<Node<unknown>>,\n target: DropTarget | null | undefined,\n wrap = false,\n horizontal: 'left' | 'right' | null = null\n): DropTarget | null {\n if (!target) {\n return {\n type: 'root'\n };\n }\n\n if (target.type === 'root') {\n let nextKey = keyboardDelegate.getFirstKey?.() ?? null;\n if (nextKey != null) {\n return {\n type: 'item',\n key: nextKey,\n dropPosition: 'before'\n };\n }\n\n return null;\n }\n\n if (target.type === 'item') {\n let nextKey: Key | null | undefined = null;\n if (horizontal) {\n nextKey = horizontal === 'right' ? keyboardDelegate.getKeyRightOf?.(target.key) : keyboardDelegate.getKeyLeftOf?.(target.key);\n } else {\n nextKey = keyboardDelegate.getKeyBelow?.(target.key);\n }\n let nextCollectionKey = collection.getKeyAfter(target.key);\n\n // If the keyboard delegate did not move to the next key in the collection,\n // jump to that key with the same drop position. Otherwise, try the other\n // drop positions on the current key first.\n if (nextKey != null && nextKey !== nextCollectionKey) {\n return {\n type: 'item',\n key: nextKey,\n dropPosition: target.dropPosition\n };\n }\n \n switch (target.dropPosition) {\n case 'before': {\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'on'\n };\n }\n case 'on': {\n // If there are nested items, traverse to them prior to the \"after\" position of this target.\n // If the next key is on the same level, then its \"before\" position is equivalent to this item's \"after\" position.\n let targetNode = collection.getItem(target.key);\n let nextNode = nextKey != null ? collection.getItem(nextKey) : null;\n if (targetNode && nextNode && nextNode.level >= targetNode.level) {\n return {\n type: 'item',\n key: nextNode.key,\n dropPosition: 'before'\n };\n }\n\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'after'\n };\n }\n case 'after': {\n // If this is the last sibling in a level, traverse to the parent.\n let targetNode = collection.getItem(target.key);\n let nextItemInSameLevel = targetNode?.nextKey != null ? collection.getItem(targetNode.nextKey) : null;\n while (nextItemInSameLevel != null && nextItemInSameLevel.type !== 'item') {\n nextItemInSameLevel = nextItemInSameLevel.nextKey != null ? collection.getItem(nextItemInSameLevel.nextKey) : null;\n }\n \n if (targetNode && nextItemInSameLevel == null && targetNode.parentKey != null) {\n // If the parent item has an item after it, use the \"before\" position.\n let parentNode = collection.getItem(targetNode.parentKey);\n const nextNode = parentNode?.nextKey != null ? collection.getItem(parentNode.nextKey) : null;\n if (nextNode?.type === 'item') {\n return {\n type: 'item',\n key: nextNode.key,\n dropPosition: 'before'\n };\n }\n\n if (parentNode?.type === 'item') {\n return {\n type: 'item',\n key: parentNode.key,\n dropPosition: 'after'\n };\n }\n }\n\n if (nextItemInSameLevel) {\n return {\n type: 'item',\n key: nextItemInSameLevel.key,\n dropPosition: 'on'\n };\n }\n }\n }\n }\n\n if (wrap) {\n return {\n type: 'root'\n };\n }\n\n return null;\n}\n\nfunction previousDropTarget(\n keyboardDelegate: KeyboardDelegate,\n collection: Collection<Node<unknown>>,\n target: DropTarget | null | undefined,\n wrap = false,\n horizontal: 'left' | 'right' | null = null\n): DropTarget | null {\n // Start after the last root-level item.\n if (!target || (wrap && target.type === 'root')) {\n // Keyboard delegate gets the deepest item but we want the shallowest.\n let prevKey: Key | null = null;\n let lastKey = keyboardDelegate.getLastKey?.();\n while (lastKey != null) {\n let node = collection.getItem(lastKey);\n if (node?.type !== 'item') {\n break;\n }\n prevKey = lastKey;\n lastKey = node?.parentKey;\n }\n\n if (prevKey != null) {\n return {\n type: 'item',\n key: prevKey,\n dropPosition: 'after'\n };\n }\n\n return null;\n }\n\n if (target.type === 'item') {\n let prevKey: Key | null | undefined = null;\n if (horizontal) {\n prevKey = horizontal === 'left' ? keyboardDelegate.getKeyLeftOf?.(target.key) : keyboardDelegate.getKeyRightOf?.(target.key);\n } else {\n prevKey = keyboardDelegate.getKeyAbove?.(target.key);\n }\n let prevCollectionKey = collection.getKeyBefore(target.key);\n\n // If the keyboard delegate did not move to the next key in the collection,\n // jump to that key with the same drop position. Otherwise, try the other\n // drop positions on the current key first.\n if (prevKey != null && prevKey !== prevCollectionKey) {\n return {\n type: 'item',\n key: prevKey,\n dropPosition: target.dropPosition\n };\n }\n\n switch (target.dropPosition) {\n case 'before': {\n // Move after the last child of the previous item.\n let targetNode = collection.getItem(target.key);\n if (targetNode && targetNode.prevKey != null) {\n let lastChild = getLastChild(collection, targetNode.prevKey);\n if (lastChild) {\n return lastChild;\n }\n }\n\n if (prevKey != null) {\n return {\n type: 'item',\n key: prevKey,\n dropPosition: 'on'\n };\n }\n\n return {\n type: 'root'\n };\n }\n case 'on': {\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'before'\n };\n }\n case 'after': {\n // Move after the last child of this item.\n let lastChild = getLastChild(collection, target.key);\n if (lastChild) {\n return lastChild;\n }\n\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'on'\n };\n }\n }\n }\n\n if (target.type !== 'root') {\n return {\n type: 'root'\n };\n }\n\n return null;\n}\n\nfunction getLastChild(collection: Collection<Node<unknown>>, key: Key): DropTarget | null {\n // getChildNodes still returns child tree items even when the item is collapsed.\n // Checking if the next item has a greater level is a silly way to determine if the item is expanded.\n let targetNode = collection.getItem(key);\n let nextKey = collection.getKeyAfter(key);\n let nextNode = nextKey != null ? collection.getItem(nextKey) : null;\n if (targetNode && nextNode && nextNode.level > targetNode.level) {\n let children = getChildNodes(targetNode, collection);\n let lastChild: Node<unknown> | null = null;\n for (let child of children) {\n if (child.type === 'item') {\n lastChild = child;\n }\n }\n\n if (lastChild) {\n return {\n type: 'item',\n key: lastChild.key,\n dropPosition: 'after'\n };\n }\n }\n\n return null;\n}\n"],"names":[],"version":3,"file":"DropTargetKeyboardNavigation.main.js.map"}
@@ -70,23 +70,26 @@ function $e154566cef11553b$var$nextDropTarget(keyboardDelegate, collection, targ
70
70
  {
71
71
  // If this is the last sibling in a level, traverse to the parent.
72
72
  let targetNode = collection.getItem(target.key);
73
- if (targetNode && targetNode.nextKey == null && targetNode.parentKey != null) {
73
+ let nextItemInSameLevel = (targetNode === null || targetNode === void 0 ? void 0 : targetNode.nextKey) != null ? collection.getItem(targetNode.nextKey) : null;
74
+ while(nextItemInSameLevel != null && nextItemInSameLevel.type !== 'item')nextItemInSameLevel = nextItemInSameLevel.nextKey != null ? collection.getItem(nextItemInSameLevel.nextKey) : null;
75
+ if (targetNode && nextItemInSameLevel == null && targetNode.parentKey != null) {
74
76
  // If the parent item has an item after it, use the "before" position.
75
77
  let parentNode = collection.getItem(targetNode.parentKey);
76
- if ((parentNode === null || parentNode === void 0 ? void 0 : parentNode.nextKey) != null) return {
78
+ const nextNode = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.nextKey) != null ? collection.getItem(parentNode.nextKey) : null;
79
+ if ((nextNode === null || nextNode === void 0 ? void 0 : nextNode.type) === 'item') return {
77
80
  type: 'item',
78
- key: parentNode.nextKey,
81
+ key: nextNode.key,
79
82
  dropPosition: 'before'
80
83
  };
81
- if (parentNode) return {
84
+ if ((parentNode === null || parentNode === void 0 ? void 0 : parentNode.type) === 'item') return {
82
85
  type: 'item',
83
86
  key: parentNode.key,
84
87
  dropPosition: 'after'
85
88
  };
86
89
  }
87
- if ((targetNode === null || targetNode === void 0 ? void 0 : targetNode.nextKey) != null) return {
90
+ if (nextItemInSameLevel) return {
88
91
  type: 'item',
89
- key: targetNode.nextKey,
92
+ key: nextItemInSameLevel.key,
90
93
  dropPosition: 'on'
91
94
  };
92
95
  }
@@ -105,8 +108,9 @@ function $e154566cef11553b$var$previousDropTarget(keyboardDelegate, collection,
105
108
  let prevKey = null;
106
109
  let lastKey = (_keyboardDelegate_getLastKey = keyboardDelegate.getLastKey) === null || _keyboardDelegate_getLastKey === void 0 ? void 0 : _keyboardDelegate_getLastKey.call(keyboardDelegate);
107
110
  while(lastKey != null){
108
- prevKey = lastKey;
109
111
  let node = collection.getItem(lastKey);
112
+ if ((node === null || node === void 0 ? void 0 : node.type) !== 'item') break;
113
+ prevKey = lastKey;
110
114
  lastKey = node === null || node === void 0 ? void 0 : node.parentKey;
111
115
  }
112
116
  if (prevKey != null) return {
@@ -70,23 +70,26 @@ function $e154566cef11553b$var$nextDropTarget(keyboardDelegate, collection, targ
70
70
  {
71
71
  // If this is the last sibling in a level, traverse to the parent.
72
72
  let targetNode = collection.getItem(target.key);
73
- if (targetNode && targetNode.nextKey == null && targetNode.parentKey != null) {
73
+ let nextItemInSameLevel = (targetNode === null || targetNode === void 0 ? void 0 : targetNode.nextKey) != null ? collection.getItem(targetNode.nextKey) : null;
74
+ while(nextItemInSameLevel != null && nextItemInSameLevel.type !== 'item')nextItemInSameLevel = nextItemInSameLevel.nextKey != null ? collection.getItem(nextItemInSameLevel.nextKey) : null;
75
+ if (targetNode && nextItemInSameLevel == null && targetNode.parentKey != null) {
74
76
  // If the parent item has an item after it, use the "before" position.
75
77
  let parentNode = collection.getItem(targetNode.parentKey);
76
- if ((parentNode === null || parentNode === void 0 ? void 0 : parentNode.nextKey) != null) return {
78
+ const nextNode = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.nextKey) != null ? collection.getItem(parentNode.nextKey) : null;
79
+ if ((nextNode === null || nextNode === void 0 ? void 0 : nextNode.type) === 'item') return {
77
80
  type: 'item',
78
- key: parentNode.nextKey,
81
+ key: nextNode.key,
79
82
  dropPosition: 'before'
80
83
  };
81
- if (parentNode) return {
84
+ if ((parentNode === null || parentNode === void 0 ? void 0 : parentNode.type) === 'item') return {
82
85
  type: 'item',
83
86
  key: parentNode.key,
84
87
  dropPosition: 'after'
85
88
  };
86
89
  }
87
- if ((targetNode === null || targetNode === void 0 ? void 0 : targetNode.nextKey) != null) return {
90
+ if (nextItemInSameLevel) return {
88
91
  type: 'item',
89
- key: targetNode.nextKey,
92
+ key: nextItemInSameLevel.key,
90
93
  dropPosition: 'on'
91
94
  };
92
95
  }
@@ -105,8 +108,9 @@ function $e154566cef11553b$var$previousDropTarget(keyboardDelegate, collection,
105
108
  let prevKey = null;
106
109
  let lastKey = (_keyboardDelegate_getLastKey = keyboardDelegate.getLastKey) === null || _keyboardDelegate_getLastKey === void 0 ? void 0 : _keyboardDelegate_getLastKey.call(keyboardDelegate);
107
110
  while(lastKey != null){
108
- prevKey = lastKey;
109
111
  let node = collection.getItem(lastKey);
112
+ if ((node === null || node === void 0 ? void 0 : node.type) !== 'item') break;
113
+ prevKey = lastKey;
110
114
  lastKey = node === null || node === void 0 ? void 0 : node.parentKey;
111
115
  }
112
116
  if (prevKey != null) return {
@@ -1 +1 @@
1
- {"mappings":";;;AAGO,SAAS,0CACd,gBAAkC,EAClC,UAAqC,EACrC,MAAqC,EACrC,SAA2C,EAC3C,MAAM,KAAK,EACX,OAAO,KAAK;IAEZ,OAAQ;QACN,KAAK;YACH,OAAO,MACH,qCAAe,kBAAkB,YAAY,QAAQ,MAAM,UAC3D,yCAAmB,kBAAkB,YAAY,QAAQ,MAAM;QACrE,KAAK;YACH,OAAO,MACH,yCAAmB,kBAAkB,YAAY,QAAQ,MAAM,WAC/D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;gBACF;QACF;IACF;IAEA,IAAI,OAAO,IAAI,KAAK,QAClB,OAAO;QACL,MAAM;IACR;IAGF,OAAO;AACT;AAEA,SAAS,mCAAa,UAAqC,EAAE,GAAQ;IACnE,gFAAgF;IAChF,qGAAqG;IACrG,IAAI,aAAa,WAAW,OAAO,CAAC;IACpC,IAAI,UAAU,WAAW,WAAW,CAAC;IACrC,IAAI,WAAW,WAAW,OAAO,WAAW,OAAO,CAAC,WAAW;IAC/D,IAAI,cAAc,YAAY,SAAS,KAAK,GAAG,WAAW,KAAK,EAAE;QAC/D,IAAI,WAAW,CAAA,GAAA,oBAAY,EAAE,YAAY;QACzC,IAAI,YAAkC;QACtC,KAAK,IAAI,SAAS,SAChB,IAAI,MAAM,IAAI,KAAK,QACjB,YAAY;QAIhB,IAAI,WACF,OAAO;YACL,MAAM;YACN,KAAK,UAAU,GAAG;YAClB,cAAc;QAChB;IAEJ;IAEA,OAAO;AACT","sources":["packages/@react-aria/dnd/src/DropTargetKeyboardNavigation.ts"],"sourcesContent":["import {Collection, DropTarget, Key, KeyboardDelegate, Node} from '@react-types/shared';\nimport {getChildNodes} from '@react-stately/collections';\n\nexport function navigate(\n keyboardDelegate: KeyboardDelegate,\n collection: Collection<Node<unknown>>,\n target: DropTarget | null | undefined,\n direction: 'left' | 'right' | 'up' | 'down',\n rtl = false,\n wrap = false\n): DropTarget | null {\n switch (direction) {\n case 'left':\n return rtl \n ? nextDropTarget(keyboardDelegate, collection, target, wrap, 'left')\n : previousDropTarget(keyboardDelegate, collection, target, wrap, 'left');\n case 'right':\n return rtl \n ? previousDropTarget(keyboardDelegate, collection, target, wrap, 'right')\n : nextDropTarget(keyboardDelegate, collection, target, wrap, 'right');\n case 'up':\n return previousDropTarget(keyboardDelegate, collection, target, wrap);\n case 'down':\n return nextDropTarget(keyboardDelegate, collection, target, wrap);\n }\n}\n\nfunction nextDropTarget(\n keyboardDelegate: KeyboardDelegate,\n collection: Collection<Node<unknown>>,\n target: DropTarget | null | undefined,\n wrap = false,\n horizontal: 'left' | 'right' | null = null\n): DropTarget | null {\n if (!target) {\n return {\n type: 'root'\n };\n }\n\n if (target.type === 'root') {\n let nextKey = keyboardDelegate.getFirstKey?.() ?? null;\n if (nextKey != null) {\n return {\n type: 'item',\n key: nextKey,\n dropPosition: 'before'\n };\n }\n\n return null;\n }\n\n if (target.type === 'item') {\n let nextKey: Key | null | undefined = null;\n if (horizontal) {\n nextKey = horizontal === 'right' ? keyboardDelegate.getKeyRightOf?.(target.key) : keyboardDelegate.getKeyLeftOf?.(target.key);\n } else {\n nextKey = keyboardDelegate.getKeyBelow?.(target.key);\n }\n let nextCollectionKey = collection.getKeyAfter(target.key);\n\n // If the keyboard delegate did not move to the next key in the collection,\n // jump to that key with the same drop position. Otherwise, try the other\n // drop positions on the current key first.\n if (nextKey != null && nextKey !== nextCollectionKey) {\n return {\n type: 'item',\n key: nextKey,\n dropPosition: target.dropPosition\n };\n }\n \n switch (target.dropPosition) {\n case 'before': {\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'on'\n };\n }\n case 'on': {\n // If there are nested items, traverse to them prior to the \"after\" position of this target.\n // If the next key is on the same level, then its \"before\" position is equivalent to this item's \"after\" position.\n let targetNode = collection.getItem(target.key);\n let nextNode = nextKey != null ? collection.getItem(nextKey) : null;\n if (targetNode && nextNode && nextNode.level >= targetNode.level) {\n return {\n type: 'item',\n key: nextNode.key,\n dropPosition: 'before'\n };\n }\n\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'after'\n };\n }\n case 'after': {\n // If this is the last sibling in a level, traverse to the parent.\n let targetNode = collection.getItem(target.key); \n if (targetNode && targetNode.nextKey == null && targetNode.parentKey != null) {\n // If the parent item has an item after it, use the \"before\" position.\n let parentNode = collection.getItem(targetNode.parentKey);\n if (parentNode?.nextKey != null) {\n return {\n type: 'item',\n key: parentNode.nextKey,\n dropPosition: 'before'\n };\n }\n\n if (parentNode) {\n return {\n type: 'item',\n key: parentNode.key,\n dropPosition: 'after'\n };\n }\n }\n\n if (targetNode?.nextKey != null) {\n return {\n type: 'item',\n key: targetNode.nextKey,\n dropPosition: 'on'\n };\n }\n }\n }\n }\n\n if (wrap) {\n return {\n type: 'root'\n };\n }\n\n return null;\n}\n\nfunction previousDropTarget(\n keyboardDelegate: KeyboardDelegate,\n collection: Collection<Node<unknown>>,\n target: DropTarget | null | undefined,\n wrap = false,\n horizontal: 'left' | 'right' | null = null\n): DropTarget | null {\n // Start after the last root-level item.\n if (!target || (wrap && target.type === 'root')) {\n // Keyboard delegate gets the deepest item but we want the shallowest.\n let prevKey: Key | null = null;\n let lastKey = keyboardDelegate.getLastKey?.();\n while (lastKey != null) {\n prevKey = lastKey;\n let node = collection.getItem(lastKey);\n lastKey = node?.parentKey;\n }\n\n if (prevKey != null) {\n return {\n type: 'item',\n key: prevKey,\n dropPosition: 'after'\n };\n }\n\n return null;\n }\n\n if (target.type === 'item') {\n let prevKey: Key | null | undefined = null;\n if (horizontal) {\n prevKey = horizontal === 'left' ? keyboardDelegate.getKeyLeftOf?.(target.key) : keyboardDelegate.getKeyRightOf?.(target.key);\n } else {\n prevKey = keyboardDelegate.getKeyAbove?.(target.key);\n }\n let prevCollectionKey = collection.getKeyBefore(target.key);\n\n // If the keyboard delegate did not move to the next key in the collection,\n // jump to that key with the same drop position. Otherwise, try the other\n // drop positions on the current key first.\n if (prevKey != null && prevKey !== prevCollectionKey) {\n return {\n type: 'item',\n key: prevKey,\n dropPosition: target.dropPosition\n };\n }\n\n switch (target.dropPosition) {\n case 'before': {\n // Move after the last child of the previous item.\n let targetNode = collection.getItem(target.key);\n if (targetNode && targetNode.prevKey != null) {\n let lastChild = getLastChild(collection, targetNode.prevKey);\n if (lastChild) {\n return lastChild;\n }\n }\n\n if (prevKey != null) {\n return {\n type: 'item',\n key: prevKey,\n dropPosition: 'on'\n };\n }\n\n return {\n type: 'root'\n };\n }\n case 'on': {\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'before'\n };\n }\n case 'after': {\n // Move after the last child of this item.\n let lastChild = getLastChild(collection, target.key);\n if (lastChild) {\n return lastChild;\n }\n\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'on'\n };\n }\n }\n }\n\n if (target.type !== 'root') {\n return {\n type: 'root'\n };\n }\n\n return null;\n}\n\nfunction getLastChild(collection: Collection<Node<unknown>>, key: Key): DropTarget | null {\n // getChildNodes still returns child tree items even when the item is collapsed.\n // Checking if the next item has a greater level is a silly way to determine if the item is expanded.\n let targetNode = collection.getItem(key);\n let nextKey = collection.getKeyAfter(key);\n let nextNode = nextKey != null ? collection.getItem(nextKey) : null;\n if (targetNode && nextNode && nextNode.level > targetNode.level) {\n let children = getChildNodes(targetNode, collection);\n let lastChild: Node<unknown> | null = null;\n for (let child of children) {\n if (child.type === 'item') {\n lastChild = child;\n }\n }\n\n if (lastChild) {\n return {\n type: 'item',\n key: lastChild.key,\n dropPosition: 'after'\n };\n }\n }\n\n return null;\n}\n"],"names":[],"version":3,"file":"DropTargetKeyboardNavigation.module.js.map"}
1
+ {"mappings":";;;AAGO,SAAS,0CACd,gBAAkC,EAClC,UAAqC,EACrC,MAAqC,EACrC,SAA2C,EAC3C,MAAM,KAAK,EACX,OAAO,KAAK;IAEZ,OAAQ;QACN,KAAK;YACH,OAAO,MACH,qCAAe,kBAAkB,YAAY,QAAQ,MAAM,UAC3D,yCAAmB,kBAAkB,YAAY,QAAQ,MAAM;QACrE,KAAK;YACH,OAAO,MACH,yCAAmB,kBAAkB,YAAY,QAAQ,MAAM,WAC/D,qCAAe,kBAAkB,YAAY,QAAQ,MAAM;QACjE,KAAK;YACH,OAAO,yCAAmB,kBAAkB,YAAY,QAAQ;QAClE,KAAK;YACH,OAAO,qCAAe,kBAAkB,YAAY,QAAQ;IAChE;AACF;AAEA,SAAS,qCACP,gBAAkC,EAClC,UAAqC,EACrC,MAAqC,EACrC,OAAO,KAAK,EACZ,aAAsC,IAAI;IAE1C,IAAI,CAAC,QACH,OAAO;QACL,MAAM;IACR;IAGF,IAAI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,IAAI,WACF,OAAO;oBAGT,OAAO;wBACL,MAAM;wBACN,KAAK,OAAO,GAAG;wBACf,cAAc;oBAChB;gBACF;QACF;IACF;IAEA,IAAI,OAAO,IAAI,KAAK,QAClB,OAAO;QACL,MAAM;IACR;IAGF,OAAO;AACT;AAEA,SAAS,mCAAa,UAAqC,EAAE,GAAQ;IACnE,gFAAgF;IAChF,qGAAqG;IACrG,IAAI,aAAa,WAAW,OAAO,CAAC;IACpC,IAAI,UAAU,WAAW,WAAW,CAAC;IACrC,IAAI,WAAW,WAAW,OAAO,WAAW,OAAO,CAAC,WAAW;IAC/D,IAAI,cAAc,YAAY,SAAS,KAAK,GAAG,WAAW,KAAK,EAAE;QAC/D,IAAI,WAAW,CAAA,GAAA,oBAAY,EAAE,YAAY;QACzC,IAAI,YAAkC;QACtC,KAAK,IAAI,SAAS,SAChB,IAAI,MAAM,IAAI,KAAK,QACjB,YAAY;QAIhB,IAAI,WACF,OAAO;YACL,MAAM;YACN,KAAK,UAAU,GAAG;YAClB,cAAc;QAChB;IAEJ;IAEA,OAAO;AACT","sources":["packages/@react-aria/dnd/src/DropTargetKeyboardNavigation.ts"],"sourcesContent":["import {Collection, DropTarget, Key, KeyboardDelegate, Node} from '@react-types/shared';\nimport {getChildNodes} from '@react-stately/collections';\n\nexport function navigate(\n keyboardDelegate: KeyboardDelegate,\n collection: Collection<Node<unknown>>,\n target: DropTarget | null | undefined,\n direction: 'left' | 'right' | 'up' | 'down',\n rtl = false,\n wrap = false\n): DropTarget | null {\n switch (direction) {\n case 'left':\n return rtl \n ? nextDropTarget(keyboardDelegate, collection, target, wrap, 'left')\n : previousDropTarget(keyboardDelegate, collection, target, wrap, 'left');\n case 'right':\n return rtl \n ? previousDropTarget(keyboardDelegate, collection, target, wrap, 'right')\n : nextDropTarget(keyboardDelegate, collection, target, wrap, 'right');\n case 'up':\n return previousDropTarget(keyboardDelegate, collection, target, wrap);\n case 'down':\n return nextDropTarget(keyboardDelegate, collection, target, wrap);\n }\n}\n\nfunction nextDropTarget(\n keyboardDelegate: KeyboardDelegate,\n collection: Collection<Node<unknown>>,\n target: DropTarget | null | undefined,\n wrap = false,\n horizontal: 'left' | 'right' | null = null\n): DropTarget | null {\n if (!target) {\n return {\n type: 'root'\n };\n }\n\n if (target.type === 'root') {\n let nextKey = keyboardDelegate.getFirstKey?.() ?? null;\n if (nextKey != null) {\n return {\n type: 'item',\n key: nextKey,\n dropPosition: 'before'\n };\n }\n\n return null;\n }\n\n if (target.type === 'item') {\n let nextKey: Key | null | undefined = null;\n if (horizontal) {\n nextKey = horizontal === 'right' ? keyboardDelegate.getKeyRightOf?.(target.key) : keyboardDelegate.getKeyLeftOf?.(target.key);\n } else {\n nextKey = keyboardDelegate.getKeyBelow?.(target.key);\n }\n let nextCollectionKey = collection.getKeyAfter(target.key);\n\n // If the keyboard delegate did not move to the next key in the collection,\n // jump to that key with the same drop position. Otherwise, try the other\n // drop positions on the current key first.\n if (nextKey != null && nextKey !== nextCollectionKey) {\n return {\n type: 'item',\n key: nextKey,\n dropPosition: target.dropPosition\n };\n }\n \n switch (target.dropPosition) {\n case 'before': {\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'on'\n };\n }\n case 'on': {\n // If there are nested items, traverse to them prior to the \"after\" position of this target.\n // If the next key is on the same level, then its \"before\" position is equivalent to this item's \"after\" position.\n let targetNode = collection.getItem(target.key);\n let nextNode = nextKey != null ? collection.getItem(nextKey) : null;\n if (targetNode && nextNode && nextNode.level >= targetNode.level) {\n return {\n type: 'item',\n key: nextNode.key,\n dropPosition: 'before'\n };\n }\n\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'after'\n };\n }\n case 'after': {\n // If this is the last sibling in a level, traverse to the parent.\n let targetNode = collection.getItem(target.key);\n let nextItemInSameLevel = targetNode?.nextKey != null ? collection.getItem(targetNode.nextKey) : null;\n while (nextItemInSameLevel != null && nextItemInSameLevel.type !== 'item') {\n nextItemInSameLevel = nextItemInSameLevel.nextKey != null ? collection.getItem(nextItemInSameLevel.nextKey) : null;\n }\n \n if (targetNode && nextItemInSameLevel == null && targetNode.parentKey != null) {\n // If the parent item has an item after it, use the \"before\" position.\n let parentNode = collection.getItem(targetNode.parentKey);\n const nextNode = parentNode?.nextKey != null ? collection.getItem(parentNode.nextKey) : null;\n if (nextNode?.type === 'item') {\n return {\n type: 'item',\n key: nextNode.key,\n dropPosition: 'before'\n };\n }\n\n if (parentNode?.type === 'item') {\n return {\n type: 'item',\n key: parentNode.key,\n dropPosition: 'after'\n };\n }\n }\n\n if (nextItemInSameLevel) {\n return {\n type: 'item',\n key: nextItemInSameLevel.key,\n dropPosition: 'on'\n };\n }\n }\n }\n }\n\n if (wrap) {\n return {\n type: 'root'\n };\n }\n\n return null;\n}\n\nfunction previousDropTarget(\n keyboardDelegate: KeyboardDelegate,\n collection: Collection<Node<unknown>>,\n target: DropTarget | null | undefined,\n wrap = false,\n horizontal: 'left' | 'right' | null = null\n): DropTarget | null {\n // Start after the last root-level item.\n if (!target || (wrap && target.type === 'root')) {\n // Keyboard delegate gets the deepest item but we want the shallowest.\n let prevKey: Key | null = null;\n let lastKey = keyboardDelegate.getLastKey?.();\n while (lastKey != null) {\n let node = collection.getItem(lastKey);\n if (node?.type !== 'item') {\n break;\n }\n prevKey = lastKey;\n lastKey = node?.parentKey;\n }\n\n if (prevKey != null) {\n return {\n type: 'item',\n key: prevKey,\n dropPosition: 'after'\n };\n }\n\n return null;\n }\n\n if (target.type === 'item') {\n let prevKey: Key | null | undefined = null;\n if (horizontal) {\n prevKey = horizontal === 'left' ? keyboardDelegate.getKeyLeftOf?.(target.key) : keyboardDelegate.getKeyRightOf?.(target.key);\n } else {\n prevKey = keyboardDelegate.getKeyAbove?.(target.key);\n }\n let prevCollectionKey = collection.getKeyBefore(target.key);\n\n // If the keyboard delegate did not move to the next key in the collection,\n // jump to that key with the same drop position. Otherwise, try the other\n // drop positions on the current key first.\n if (prevKey != null && prevKey !== prevCollectionKey) {\n return {\n type: 'item',\n key: prevKey,\n dropPosition: target.dropPosition\n };\n }\n\n switch (target.dropPosition) {\n case 'before': {\n // Move after the last child of the previous item.\n let targetNode = collection.getItem(target.key);\n if (targetNode && targetNode.prevKey != null) {\n let lastChild = getLastChild(collection, targetNode.prevKey);\n if (lastChild) {\n return lastChild;\n }\n }\n\n if (prevKey != null) {\n return {\n type: 'item',\n key: prevKey,\n dropPosition: 'on'\n };\n }\n\n return {\n type: 'root'\n };\n }\n case 'on': {\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'before'\n };\n }\n case 'after': {\n // Move after the last child of this item.\n let lastChild = getLastChild(collection, target.key);\n if (lastChild) {\n return lastChild;\n }\n\n return {\n type: 'item',\n key: target.key,\n dropPosition: 'on'\n };\n }\n }\n }\n\n if (target.type !== 'root') {\n return {\n type: 'root'\n };\n }\n\n return null;\n}\n\nfunction getLastChild(collection: Collection<Node<unknown>>, key: Key): DropTarget | null {\n // getChildNodes still returns child tree items even when the item is collapsed.\n // Checking if the next item has a greater level is a silly way to determine if the item is expanded.\n let targetNode = collection.getItem(key);\n let nextKey = collection.getKeyAfter(key);\n let nextNode = nextKey != null ? collection.getItem(nextKey) : null;\n if (targetNode && nextNode && nextNode.level > targetNode.level) {\n let children = getChildNodes(targetNode, collection);\n let lastChild: Node<unknown> | null = null;\n for (let child of children) {\n if (child.type === 'item') {\n lastChild = child;\n }\n }\n\n if (lastChild) {\n return {\n type: 'item',\n key: lastChild.key,\n dropPosition: 'after'\n };\n }\n }\n\n return null;\n}\n"],"names":[],"version":3,"file":"DropTargetKeyboardNavigation.module.js.map"}
@@ -21,9 +21,9 @@ module.exports = {
21
21
  one: ()=>`${formatter.number(args.count)} elemento seleccionado`,
22
22
  other: ()=>`${formatter.number(args.count)} elementos seleccionados`
23
23
  })}.`,
24
- "dragStartedKeyboard": `Se ha empezado a arrastrar. Pulse el tabulador para ir al p\xfablico destinatario donde se vaya a colocar y, a continuaci\xf3n, pulse Intro para soltar, o pulse Escape para cancelar.`,
25
- "dragStartedTouch": `Se ha empezado a arrastrar. Vaya al p\xfablico destinatario donde se vaya a colocar y, a continuaci\xf3n, pulse dos veces para soltar.`,
26
- "dragStartedVirtual": `Se ha empezado a arrastrar. Vaya al p\xfablico destinatario donde se vaya a colocar y, a continuaci\xf3n, haga clic o pulse Intro para soltar.`,
24
+ "dragStartedKeyboard": `Se ha empezado a arrastrar. Pulse el tabulador para ir al destino donde se vaya a colocar y, a continuaci\xf3n, pulse Intro para soltar, o pulse Escape para cancelar.`,
25
+ "dragStartedTouch": `Se ha empezado a arrastrar. Vaya al destino donde se vaya a colocar y, a continuaci\xf3n, pulse dos veces para soltar.`,
26
+ "dragStartedVirtual": `Se ha empezado a arrastrar. Vaya al destino donde se vaya a colocar y, a continuaci\xf3n, haga clic o pulse Intro para soltar.`,
27
27
  "dropCanceled": `Se ha cancelado la colocaci\xf3n.`,
28
28
  "dropComplete": `Colocaci\xf3n finalizada.`,
29
29
  "dropDescriptionKeyboard": `Pulse Intro para soltar. Pulse Escape para cancelar el arrastre.`,
@@ -1 +1 @@
1
- {"mappings":"AAAA,iBAAiB;IAAG,2BAA2B,CAAC,qCAAqC,CAAC;IACpF,8BAA8B,CAAC,qCAAqC,CAAC;IACrE,4BAA4B,CAAC,2CAA2C,CAAC;IACzE,wBAAwB,CAAC,yCAAyC,CAAC;IACnE,0BAA0B,CAAC,mCAAmC,CAAC;IAC/D,YAAY,CAAC,OAAS,CAAC,UAAU,EAAE,KAAK,QAAQ,EAAE;IAClD,qBAAqB,CAAC,MAAM,YAAc,CAAC,UAAU,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE;YAAC,KAAK,IAAM,GAAG,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,sBAAsB,CAAC;YAAE,OAAO,IAAM,GAAG,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,wBAAwB,CAAC;QAAA,IAAI;IACnO,wBAAwB,CAAC,MAAM,YAAc,CAAC,2BAA2B,EAAE,UAAU,MAAM,CAAC,KA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rE,eAAe,CAAC,OAAS,CAAC,uBAAoB,EAAE,KAAK,QAAQ,EAAE;IAC/D,gBAAgB,CAAC,OAAS,CAAC,kBAAkB,EAAE,KAAK,QAAQ,EAAE;IAC9D,iBAAiB,CAAC,OAAS,CAAC,eAAe,EAAE,KAAK,cAAc,CAAC,GAAG,EAAE,KAAK,aAAa,EAAE;AAC5F","sources":["packages/@react-aria/dnd/intl/es-ES.json"],"sourcesContent":["{\n \"dragDescriptionKeyboard\": \"Pulse Intro para empezar a arrastrar.\",\n \"dragDescriptionKeyboardAlt\": \"Pulse Intro para empezar a arrastrar.\",\n \"dragDescriptionLongPress\": \"Mantenga pulsado para comenzar a arrastrar.\",\n \"dragDescriptionTouch\": \"Pulse dos veces para iniciar el arrastre.\",\n \"dragDescriptionVirtual\": \"Haga clic para iniciar el arrastre.\",\n \"dragItem\": \"Arrastrar {itemText}\",\n \"dragSelectedItems\": \"Arrastrar {count, plural, one {# elemento seleccionado} other {# elementos seleccionados}}\",\n \"dragSelectedKeyboard\": \"Pulse Intro para arrastrar {count, plural, one {# elemento seleccionado} other {# elementos seleccionados}}.\",\n \"dragSelectedKeyboardAlt\": \"Pulse Alt + Intro para arrastrar {count, plural, one {# elemento seleccionado} other {# elementos seleccionados}}.\",\n \"dragSelectedLongPress\": \"Mantenga pulsado para arrastrar {count, plural, one {# elemento seleccionado} other {# elementos seleccionados}}.\",\n \"dragStartedKeyboard\": \"Se ha empezado a arrastrar. Pulse el tabulador para ir al público destinatario donde se vaya a colocar y, a continuación, pulse Intro para soltar, o pulse Escape para cancelar.\",\n \"dragStartedTouch\": \"Se ha empezado a arrastrar. Vaya al público destinatario donde se vaya a colocar y, a continuación, pulse dos veces para soltar.\",\n \"dragStartedVirtual\": \"Se ha empezado a arrastrar. Vaya al público destinatario donde se vaya a colocar y, a continuación, haga clic o pulse Intro para soltar.\",\n \"dropCanceled\": \"Se ha cancelado la colocación.\",\n \"dropComplete\": \"Colocación finalizada.\",\n \"dropDescriptionKeyboard\": \"Pulse Intro para soltar. Pulse Escape para cancelar el arrastre.\",\n \"dropDescriptionTouch\": \"Pulse dos veces para soltar.\",\n \"dropDescriptionVirtual\": \"Haga clic para soltar.\",\n \"dropIndicator\": \"indicador de colocación\",\n \"dropOnItem\": \"Soltar en {itemText}\",\n \"dropOnRoot\": \"Soltar en\",\n \"endDragKeyboard\": \"Arrastrando. Pulse Intro para cancelar el arrastre.\",\n \"endDragTouch\": \"Arrastrando. Pulse dos veces para cancelar el arrastre.\",\n \"endDragVirtual\": \"Arrastrando. Haga clic para cancelar el arrastre.\",\n \"insertAfter\": \"Insertar después de {itemText}\",\n \"insertBefore\": \"Insertar antes de {itemText}\",\n \"insertBetween\": \"Insertar entre {beforeItemText} y {afterItemText}\"\n}\n"],"names":[],"version":3,"file":"es-ES.main.js.map"}
1
+ {"mappings":"AAAA,iBAAiB;IAAG,2BAA2B,CAAC,qCAAqC,CAAC;IACpF,8BAA8B,CAAC,qCAAqC,CAAC;IACrE,4BAA4B,CAAC,2CAA2C,CAAC;IACzE,wBAAwB,CAAC,yCAAyC,CAAC;IACnE,0BAA0B,CAAC,mCAAmC,CAAC;IAC/D,YAAY,CAAC,OAAS,CAAC,UAAU,EAAE,KAAK,QAAQ,EAAE;IAClD,qBAAqB,CAAC,MAAM,YAAc,CAAC,UAAU,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE;YAAC,KAAK,IAAM,GAAG,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,sBAAsB,CAAC;YAAE,OAAO,IAAM,GAAG,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,wBAAwB,CAAC;QAAA,IAAI;IACnO,wBAAwB,CAAC,MAAM,YAAc,CAAC,2BAA2B,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE;YAAC,KAAK,IAAM,GAAG,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,sBAAsB,CAAC;YAAE,OAAO,IAAM,GAAG,UAAU,MAAM,CAAC,KAAK,K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AAiB,CAAC,OAAS,CAAC,eAAe,EAAE,KAAK,cAAc,CAAC,GAAG,EAAE,KAAK,aAAa,EAAE;AAC5F","sources":["packages/@react-aria/dnd/intl/es-ES.json"],"sourcesContent":["{\n \"dragDescriptionKeyboard\": \"Pulse Intro para empezar a arrastrar.\",\n \"dragDescriptionKeyboardAlt\": \"Pulse Intro para empezar a arrastrar.\",\n \"dragDescriptionLongPress\": \"Mantenga pulsado para comenzar a arrastrar.\",\n \"dragDescriptionTouch\": \"Pulse dos veces para iniciar el arrastre.\",\n \"dragDescriptionVirtual\": \"Haga clic para iniciar el arrastre.\",\n \"dragItem\": \"Arrastrar {itemText}\",\n \"dragSelectedItems\": \"Arrastrar {count, plural, one {# elemento seleccionado} other {# elementos seleccionados}}\",\n \"dragSelectedKeyboard\": \"Pulse Intro para arrastrar {count, plural, one {# elemento seleccionado} other {# elementos seleccionados}}.\",\n \"dragSelectedKeyboardAlt\": \"Pulse Alt + Intro para arrastrar {count, plural, one {# elemento seleccionado} other {# elementos seleccionados}}.\",\n \"dragSelectedLongPress\": \"Mantenga pulsado para arrastrar {count, plural, one {# elemento seleccionado} other {# elementos seleccionados}}.\",\n \"dragStartedKeyboard\": \"Se ha empezado a arrastrar. Pulse el tabulador para ir al destino donde se vaya a colocar y, a continuación, pulse Intro para soltar, o pulse Escape para cancelar.\",\n \"dragStartedTouch\": \"Se ha empezado a arrastrar. Vaya al destino donde se vaya a colocar y, a continuación, pulse dos veces para soltar.\",\n \"dragStartedVirtual\": \"Se ha empezado a arrastrar. Vaya al destino donde se vaya a colocar y, a continuación, haga clic o pulse Intro para soltar.\",\n \"dropCanceled\": \"Se ha cancelado la colocación.\",\n \"dropComplete\": \"Colocación finalizada.\",\n \"dropDescriptionKeyboard\": \"Pulse Intro para soltar. Pulse Escape para cancelar el arrastre.\",\n \"dropDescriptionTouch\": \"Pulse dos veces para soltar.\",\n \"dropDescriptionVirtual\": \"Haga clic para soltar.\",\n \"dropIndicator\": \"indicador de colocación\",\n \"dropOnItem\": \"Soltar en {itemText}\",\n \"dropOnRoot\": \"Soltar en\",\n \"endDragKeyboard\": \"Arrastrando. Pulse Intro para cancelar el arrastre.\",\n \"endDragTouch\": \"Arrastrando. Pulse dos veces para cancelar el arrastre.\",\n \"endDragVirtual\": \"Arrastrando. Haga clic para cancelar el arrastre.\",\n \"insertAfter\": \"Insertar después de {itemText}\",\n \"insertBefore\": \"Insertar antes de {itemText}\",\n \"insertBetween\": \"Insertar entre {beforeItemText} y {afterItemText}\"\n}\n"],"names":[],"version":3,"file":"es-ES.main.js.map"}
package/dist/es-ES.mjs CHANGED
@@ -22,9 +22,9 @@ $204b5c01bd3acf26$exports = {
22
22
  one: ()=>`${formatter.number(args.count)} elemento seleccionado`,
23
23
  other: ()=>`${formatter.number(args.count)} elementos seleccionados`
24
24
  })}.`,
25
- "dragStartedKeyboard": `Se ha empezado a arrastrar. Pulse el tabulador para ir al p\xfablico destinatario donde se vaya a colocar y, a continuaci\xf3n, pulse Intro para soltar, o pulse Escape para cancelar.`,
26
- "dragStartedTouch": `Se ha empezado a arrastrar. Vaya al p\xfablico destinatario donde se vaya a colocar y, a continuaci\xf3n, pulse dos veces para soltar.`,
27
- "dragStartedVirtual": `Se ha empezado a arrastrar. Vaya al p\xfablico destinatario donde se vaya a colocar y, a continuaci\xf3n, haga clic o pulse Intro para soltar.`,
25
+ "dragStartedKeyboard": `Se ha empezado a arrastrar. Pulse el tabulador para ir al destino donde se vaya a colocar y, a continuaci\xf3n, pulse Intro para soltar, o pulse Escape para cancelar.`,
26
+ "dragStartedTouch": `Se ha empezado a arrastrar. Vaya al destino donde se vaya a colocar y, a continuaci\xf3n, pulse dos veces para soltar.`,
27
+ "dragStartedVirtual": `Se ha empezado a arrastrar. Vaya al destino donde se vaya a colocar y, a continuaci\xf3n, haga clic o pulse Intro para soltar.`,
28
28
  "dropCanceled": `Se ha cancelado la colocaci\xf3n.`,
29
29
  "dropComplete": `Colocaci\xf3n finalizada.`,
30
30
  "dropDescriptionKeyboard": `Pulse Intro para soltar. Pulse Escape para cancelar el arrastre.`,
@@ -22,9 +22,9 @@ $204b5c01bd3acf26$exports = {
22
22
  one: ()=>`${formatter.number(args.count)} elemento seleccionado`,
23
23
  other: ()=>`${formatter.number(args.count)} elementos seleccionados`
24
24
  })}.`,
25
- "dragStartedKeyboard": `Se ha empezado a arrastrar. Pulse el tabulador para ir al p\xfablico destinatario donde se vaya a colocar y, a continuaci\xf3n, pulse Intro para soltar, o pulse Escape para cancelar.`,
26
- "dragStartedTouch": `Se ha empezado a arrastrar. Vaya al p\xfablico destinatario donde se vaya a colocar y, a continuaci\xf3n, pulse dos veces para soltar.`,
27
- "dragStartedVirtual": `Se ha empezado a arrastrar. Vaya al p\xfablico destinatario donde se vaya a colocar y, a continuaci\xf3n, haga clic o pulse Intro para soltar.`,
25
+ "dragStartedKeyboard": `Se ha empezado a arrastrar. Pulse el tabulador para ir al destino donde se vaya a colocar y, a continuaci\xf3n, pulse Intro para soltar, o pulse Escape para cancelar.`,
26
+ "dragStartedTouch": `Se ha empezado a arrastrar. Vaya al destino donde se vaya a colocar y, a continuaci\xf3n, pulse dos veces para soltar.`,
27
+ "dragStartedVirtual": `Se ha empezado a arrastrar. Vaya al destino donde se vaya a colocar y, a continuaci\xf3n, haga clic o pulse Intro para soltar.`,
28
28
  "dropCanceled": `Se ha cancelado la colocaci\xf3n.`,
29
29
  "dropComplete": `Colocaci\xf3n finalizada.`,
30
30
  "dropDescriptionKeyboard": `Pulse Intro para soltar. Pulse Escape para cancelar el arrastre.`,
@@ -1 +1 @@
1
- {"mappings":";AAAA,4BAAiB;IAAG,2BAA2B,CAAC,qCAAqC,CAAC;IACpF,8BAA8B,CAAC,qCAAqC,CAAC;IACrE,4BAA4B,CAAC,2CAA2C,CAAC;IACzE,wBAAwB,CAAC,yCAAyC,CAAC;IACnE,0BAA0B,CAAC,mCAAmC,CAAC;IAC/D,YAAY,CAAC,OAAS,CAAC,UAAU,EAAE,KAAK,QAAQ,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,CAAC,gEAAgE,CAAC;IAC7F,wBAAwB,CAAC,4BAA4B,CAAC;IACtD,0BAA0B,CAAC,sBAAsB,CAAC;IAClD,iBAAiB,CAAC,0BAAuB,CAAC;IAC1C,cAAc,CAAC,OAAS,CAAC,UAAU,EAAE,KAAK,QAAQ,EAAE;IACpD,cAAc,CAAC,SAAS,CAAC;IACzB,mBAAmB,CAAC,mDAAmD,CAAC;IACxE,gBAAgB,CAAC,uDAAuD,CAAC;IACzE,kBAAkB,CAAC,iDAAiD,CAAC;IACrE,eAAe,CAAC,OAAS,CAAC,uBAAoB,EAAE,KAAK,QAAQ,EAAE;IAC/D,gBAAgB,CAAC,OAAS,CAAC,kBAAkB,EAAE,KAAK,QAAQ,EAAE;IAC9D,iBAAiB,CAAC,OAAS,CAAC,eAAe,EAAE,KAAK,cAAc,CAAC,GAAG,EAAE,KAAK,aAAa,EAAE;AAC5F","sources":["packages/@react-aria/dnd/intl/es-ES.json"],"sourcesContent":["{\n \"dragDescriptionKeyboard\": \"Pulse Intro para empezar a arrastrar.\",\n \"dragDescriptionKeyboardAlt\": \"Pulse Intro para empezar a arrastrar.\",\n \"dragDescriptionLongPress\": \"Mantenga pulsado para comenzar a arrastrar.\",\n \"dragDescriptionTouch\": \"Pulse dos veces para iniciar el arrastre.\",\n \"dragDescriptionVirtual\": \"Haga clic para iniciar el arrastre.\",\n \"dragItem\": \"Arrastrar {itemText}\",\n \"dragSelectedItems\": \"Arrastrar {count, plural, one {# elemento seleccionado} other {# elementos seleccionados}}\",\n \"dragSelectedKeyboard\": \"Pulse Intro para arrastrar {count, plural, one {# elemento seleccionado} other {# elementos seleccionados}}.\",\n \"dragSelectedKeyboardAlt\": \"Pulse Alt + Intro para arrastrar {count, plural, one {# elemento seleccionado} other {# elementos seleccionados}}.\",\n \"dragSelectedLongPress\": \"Mantenga pulsado para arrastrar {count, plural, one {# elemento seleccionado} other {# elementos seleccionados}}.\",\n \"dragStartedKeyboard\": \"Se ha empezado a arrastrar. Pulse el tabulador para ir al público destinatario donde se vaya a colocar y, a continuación, pulse Intro para soltar, o pulse Escape para cancelar.\",\n \"dragStartedTouch\": \"Se ha empezado a arrastrar. Vaya al público destinatario donde se vaya a colocar y, a continuación, pulse dos veces para soltar.\",\n \"dragStartedVirtual\": \"Se ha empezado a arrastrar. Vaya al público destinatario donde se vaya a colocar y, a continuación, haga clic o pulse Intro para soltar.\",\n \"dropCanceled\": \"Se ha cancelado la colocación.\",\n \"dropComplete\": \"Colocación finalizada.\",\n \"dropDescriptionKeyboard\": \"Pulse Intro para soltar. Pulse Escape para cancelar el arrastre.\",\n \"dropDescriptionTouch\": \"Pulse dos veces para soltar.\",\n \"dropDescriptionVirtual\": \"Haga clic para soltar.\",\n \"dropIndicator\": \"indicador de colocación\",\n \"dropOnItem\": \"Soltar en {itemText}\",\n \"dropOnRoot\": \"Soltar en\",\n \"endDragKeyboard\": \"Arrastrando. Pulse Intro para cancelar el arrastre.\",\n \"endDragTouch\": \"Arrastrando. Pulse dos veces para cancelar el arrastre.\",\n \"endDragVirtual\": \"Arrastrando. Haga clic para cancelar el arrastre.\",\n \"insertAfter\": \"Insertar después de {itemText}\",\n \"insertBefore\": \"Insertar antes de {itemText}\",\n \"insertBetween\": \"Insertar entre {beforeItemText} y {afterItemText}\"\n}\n"],"names":[],"version":3,"file":"es-ES.module.js.map"}
1
+ {"mappings":";AAAA,4BAAiB;IAAG,2BAA2B,CAAC,qCAAqC,CAAC;IACpF,8BAA8B,CAAC,qCAAqC,CAAC;IACrE,4BAA4B,CAAC,2CAA2C,CAAC;IACzE,wBAAwB,CAAC,yCAAyC,CAAC;IACnE,0BAA0B,CAAC,mCAAmC,CAAC;IAC/D,YAAY,CAAC,OAAS,CAAC,UAAU,EAAE,KAAK,QAAQ,EAAE;IAClD,qBAAqB,CAAC,MAAM,YAAc,CAAC,UAAU,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE;YAAC,KAAK,IAAM,GAAG,UAAU,MAAM,CAAC,KAAK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c,CAAC,OAAS,CAAC,UAAU,EAAE,KAAK,QAAQ,EAAE;IACpD,cAAc,CAAC,SAAS,CAAC;IACzB,mBAAmB,CAAC,mDAAmD,CAAC;IACxE,gBAAgB,CAAC,uDAAuD,CAAC;IACzE,kBAAkB,CAAC,iDAAiD,CAAC;IACrE,eAAe,CAAC,OAAS,CAAC,uBAAoB,EAAE,KAAK,QAAQ,EAAE;IAC/D,gBAAgB,CAAC,OAAS,CAAC,kBAAkB,EAAE,KAAK,QAAQ,EAAE;IAC9D,iBAAiB,CAAC,OAAS,CAAC,eAAe,EAAE,KAAK,cAAc,CAAC,GAAG,EAAE,KAAK,aAAa,EAAE;AAC5F","sources":["packages/@react-aria/dnd/intl/es-ES.json"],"sourcesContent":["{\n \"dragDescriptionKeyboard\": \"Pulse Intro para empezar a arrastrar.\",\n \"dragDescriptionKeyboardAlt\": \"Pulse Intro para empezar a arrastrar.\",\n \"dragDescriptionLongPress\": \"Mantenga pulsado para comenzar a arrastrar.\",\n \"dragDescriptionTouch\": \"Pulse dos veces para iniciar el arrastre.\",\n \"dragDescriptionVirtual\": \"Haga clic para iniciar el arrastre.\",\n \"dragItem\": \"Arrastrar {itemText}\",\n \"dragSelectedItems\": \"Arrastrar {count, plural, one {# elemento seleccionado} other {# elementos seleccionados}}\",\n \"dragSelectedKeyboard\": \"Pulse Intro para arrastrar {count, plural, one {# elemento seleccionado} other {# elementos seleccionados}}.\",\n \"dragSelectedKeyboardAlt\": \"Pulse Alt + Intro para arrastrar {count, plural, one {# elemento seleccionado} other {# elementos seleccionados}}.\",\n \"dragSelectedLongPress\": \"Mantenga pulsado para arrastrar {count, plural, one {# elemento seleccionado} other {# elementos seleccionados}}.\",\n \"dragStartedKeyboard\": \"Se ha empezado a arrastrar. Pulse el tabulador para ir al destino donde se vaya a colocar y, a continuación, pulse Intro para soltar, o pulse Escape para cancelar.\",\n \"dragStartedTouch\": \"Se ha empezado a arrastrar. Vaya al destino donde se vaya a colocar y, a continuación, pulse dos veces para soltar.\",\n \"dragStartedVirtual\": \"Se ha empezado a arrastrar. Vaya al destino donde se vaya a colocar y, a continuación, haga clic o pulse Intro para soltar.\",\n \"dropCanceled\": \"Se ha cancelado la colocación.\",\n \"dropComplete\": \"Colocación finalizada.\",\n \"dropDescriptionKeyboard\": \"Pulse Intro para soltar. Pulse Escape para cancelar el arrastre.\",\n \"dropDescriptionTouch\": \"Pulse dos veces para soltar.\",\n \"dropDescriptionVirtual\": \"Haga clic para soltar.\",\n \"dropIndicator\": \"indicador de colocación\",\n \"dropOnItem\": \"Soltar en {itemText}\",\n \"dropOnRoot\": \"Soltar en\",\n \"endDragKeyboard\": \"Arrastrando. Pulse Intro para cancelar el arrastre.\",\n \"endDragTouch\": \"Arrastrando. Pulse dos veces para cancelar el arrastre.\",\n \"endDragVirtual\": \"Arrastrando. Haga clic para cancelar el arrastre.\",\n \"insertAfter\": \"Insertar después de {itemText}\",\n \"insertBefore\": \"Insertar antes de {itemText}\",\n \"insertBetween\": \"Insertar entre {beforeItemText} y {afterItemText}\"\n}\n"],"names":[],"version":3,"file":"es-ES.module.js.map"}
@@ -100,13 +100,7 @@ function $74f3dedaa4d234b4$export$2314ca2a3e892862(options) {
100
100
  if (isDisabled) return;
101
101
  return (0, $gAFdr$reactariautils.chain)($74f3dedaa4d234b4$var$addGlobalEventListener('beforecopy', onBeforeCopy), $74f3dedaa4d234b4$var$addGlobalEventListener('copy', onCopy), $74f3dedaa4d234b4$var$addGlobalEventListener('beforecut', onBeforeCut), $74f3dedaa4d234b4$var$addGlobalEventListener('cut', onCut), $74f3dedaa4d234b4$var$addGlobalEventListener('beforepaste', onBeforePaste), $74f3dedaa4d234b4$var$addGlobalEventListener('paste', onPaste));
102
102
  }, [
103
- isDisabled,
104
- onBeforeCopy,
105
- onCopy,
106
- onBeforeCut,
107
- onCut,
108
- onBeforePaste,
109
- onPaste
103
+ isDisabled
110
104
  ]);
111
105
  return {
112
106
  clipboardProps: focusProps
@@ -1 +1 @@
1
- {"mapp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ent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {chain, useEffectEvent} from '@react-aria/utils';\nimport {DOMAttributes, DragItem, DropItem} from '@react-types/shared';\nimport {readFromDataTransfer, writeToDataTransfer} from './utils';\nimport {useEffect, useRef} from 'react';\nimport {useFocus} from '@react-aria/interactions';\n\nexport interface ClipboardProps {\n /** A function that returns the items to copy. */\n getItems?: (details: {action: 'cut' | 'copy'}) => DragItem[],\n /** Handler that is called when the user triggers a copy interaction. */\n onCopy?: () => void,\n /** Handler that is called when the user triggers a cut interaction. */\n onCut?: () => void,\n /** Handler that is called when the user triggers a paste interaction. */\n onPaste?: (items: DropItem[]) => void,\n /** Whether the clipboard is disabled. */\n isDisabled?: boolean\n}\n\nexport interface ClipboardResult {\n /** Props for the element that will handle clipboard events. */\n clipboardProps: DOMAttributes\n}\n\nconst globalEvents = new Map();\nfunction addGlobalEventListener(event, fn) {\n let eventData = globalEvents.get(event);\n if (!eventData) {\n let handlers = new Set<(e: Event) => void>();\n let listener = (e) => {\n for (let handler of handlers) {\n handler(e);\n }\n };\n\n eventData = {listener, handlers};\n globalEvents.set(event, eventData);\n\n document.addEventListener(event, listener);\n }\n\n eventData.handlers.add(fn);\n return () => {\n eventData.handlers.delete(fn);\n if (eventData.handlers.size === 0) {\n document.removeEventListener(event, eventData.listener);\n globalEvents.delete(event);\n }\n };\n}\n\n/**\n * Handles clipboard interactions for a focusable element. Supports items of multiple\n * data types, and integrates with the operating system native clipboard.\n */\nexport function useClipboard(options: ClipboardProps): ClipboardResult {\n let {isDisabled} = options;\n let isFocusedRef = useRef(false);\n let {focusProps} = useFocus({\n onFocusChange: (isFocused) => {\n isFocusedRef.current = isFocused;\n }\n });\n\n let onBeforeCopy = useEffectEvent((e: ClipboardEvent) => {\n // Enable the \"Copy\" menu item in Safari if this element is focused and copying is supported.\n if (isFocusedRef.current && options.getItems) {\n e.preventDefault();\n }\n });\n\n let onCopy = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.getItems) {\n return;\n }\n\n e.preventDefault();\n if (e.clipboardData) {\n writeToDataTransfer(e.clipboardData, options.getItems({action: 'copy'}));\n options.onCopy?.();\n }\n });\n\n let onBeforeCut = useEffectEvent((e: ClipboardEvent) => {\n if (isFocusedRef.current && options.onCut && options.getItems) {\n e.preventDefault();\n }\n });\n\n let onCut = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.onCut || !options.getItems) {\n return;\n }\n\n e.preventDefault();\n if (e.clipboardData) {\n writeToDataTransfer(e.clipboardData, options.getItems({action: 'cut'}));\n options.onCut();\n }\n });\n\n let onBeforePaste = useEffectEvent((e: ClipboardEvent) => {\n // Unfortunately, e.clipboardData.types is not available in this event so we always\n // have to enable the Paste menu item even if the type of data is unsupported.\n if (isFocusedRef.current && options.onPaste) {\n e.preventDefault();\n }\n });\n\n let onPaste = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.onPaste) {\n return;\n }\n\n e.preventDefault();\n if (e.clipboardData) {\n let items = readFromDataTransfer(e.clipboardData);\n options.onPaste(items);\n }\n });\n\n useEffect(() => {\n if (isDisabled) {\n return;\n }\n return chain(\n addGlobalEventListener('beforecopy', onBeforeCopy),\n addGlobalEventListener('copy', onCopy),\n addGlobalEventListener('beforecut', onBeforeCut),\n addGlobalEventListener('cut', onCut),\n addGlobalEventListener('beforepaste', onBeforePaste),\n addGlobalEventListener('paste', onPaste)\n );\n }, [isDisabled, onBeforeCopy, onCopy, onBeforeCut, onCut, onBeforePaste, onPaste]);\n\n return {\n clipboardProps: focusProps\n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.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {chain, useEffectEvent} from '@react-aria/utils';\nimport {DOMAttributes, DragItem, DropItem} from '@react-types/shared';\nimport {readFromDataTransfer, writeToDataTransfer} from './utils';\nimport {useEffect, useRef} from 'react';\nimport {useFocus} from '@react-aria/interactions';\n\nexport interface ClipboardProps {\n /** A function that returns the items to copy. */\n getItems?: (details: {action: 'cut' | 'copy'}) => DragItem[],\n /** Handler that is called when the user triggers a copy interaction. */\n onCopy?: () => void,\n /** Handler that is called when the user triggers a cut interaction. */\n onCut?: () => void,\n /** Handler that is called when the user triggers a paste interaction. */\n onPaste?: (items: DropItem[]) => void,\n /** Whether the clipboard is disabled. */\n isDisabled?: boolean\n}\n\nexport interface ClipboardResult {\n /** Props for the element that will handle clipboard events. */\n clipboardProps: DOMAttributes\n}\n\nconst globalEvents = new Map();\nfunction addGlobalEventListener(event, fn) {\n let eventData = globalEvents.get(event);\n if (!eventData) {\n let handlers = new Set<(e: Event) => void>();\n let listener = (e) => {\n for (let handler of handlers) {\n handler(e);\n }\n };\n\n eventData = {listener, handlers};\n globalEvents.set(event, eventData);\n\n document.addEventListener(event, listener);\n }\n\n eventData.handlers.add(fn);\n return () => {\n eventData.handlers.delete(fn);\n if (eventData.handlers.size === 0) {\n document.removeEventListener(event, eventData.listener);\n globalEvents.delete(event);\n }\n };\n}\n\n/**\n * Handles clipboard interactions for a focusable element. Supports items of multiple\n * data types, and integrates with the operating system native clipboard.\n */\nexport function useClipboard(options: ClipboardProps): ClipboardResult {\n let {isDisabled} = options;\n let isFocusedRef = useRef(false);\n let {focusProps} = useFocus({\n onFocusChange: (isFocused) => {\n isFocusedRef.current = isFocused;\n }\n });\n\n let onBeforeCopy = useEffectEvent((e: ClipboardEvent) => {\n // Enable the \"Copy\" menu item in Safari if this element is focused and copying is supported.\n if (isFocusedRef.current && options.getItems) {\n e.preventDefault();\n }\n });\n\n let onCopy = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.getItems) {\n return;\n }\n\n e.preventDefault();\n if (e.clipboardData) {\n writeToDataTransfer(e.clipboardData, options.getItems({action: 'copy'}));\n options.onCopy?.();\n }\n });\n\n let onBeforeCut = useEffectEvent((e: ClipboardEvent) => {\n if (isFocusedRef.current && options.onCut && options.getItems) {\n e.preventDefault();\n }\n });\n\n let onCut = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.onCut || !options.getItems) {\n return;\n }\n\n e.preventDefault();\n if (e.clipboardData) {\n writeToDataTransfer(e.clipboardData, options.getItems({action: 'cut'}));\n options.onCut();\n }\n });\n\n let onBeforePaste = useEffectEvent((e: ClipboardEvent) => {\n // Unfortunately, e.clipboardData.types is not available in this event so we always\n // have to enable the Paste menu item even if the type of data is unsupported.\n if (isFocusedRef.current && options.onPaste) {\n e.preventDefault();\n }\n });\n\n let onPaste = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.onPaste) {\n return;\n }\n\n e.preventDefault();\n if (e.clipboardData) {\n let items = readFromDataTransfer(e.clipboardData);\n options.onPaste(items);\n }\n });\n\n useEffect(() => {\n if (isDisabled) {\n return;\n }\n return chain(\n addGlobalEventListener('beforecopy', onBeforeCopy),\n addGlobalEventListener('copy', onCopy),\n addGlobalEventListener('beforecut', onBeforeCut),\n addGlobalEventListener('cut', onCut),\n addGlobalEventListener('beforepaste', onBeforePaste),\n addGlobalEventListener('paste', onPaste)\n );\n }, [isDisabled]);\n\n return {\n clipboardProps: focusProps\n };\n}\n"],"names":[],"version":3,"file":"useClipboard.main.js.map"}
@@ -94,13 +94,7 @@ function $9fcc7f0d70d084ee$export$2314ca2a3e892862(options) {
94
94
  if (isDisabled) return;
95
95
  return (0, $9Tt78$chain)($9fcc7f0d70d084ee$var$addGlobalEventListener('beforecopy', onBeforeCopy), $9fcc7f0d70d084ee$var$addGlobalEventListener('copy', onCopy), $9fcc7f0d70d084ee$var$addGlobalEventListener('beforecut', onBeforeCut), $9fcc7f0d70d084ee$var$addGlobalEventListener('cut', onCut), $9fcc7f0d70d084ee$var$addGlobalEventListener('beforepaste', onBeforePaste), $9fcc7f0d70d084ee$var$addGlobalEventListener('paste', onPaste));
96
96
  }, [
97
- isDisabled,
98
- onBeforeCopy,
99
- onCopy,
100
- onBeforeCut,
101
- onCut,
102
- onBeforePaste,
103
- onPaste
97
+ isDisabled
104
98
  ]);
105
99
  return {
106
100
  clipboardProps: focusProps
@@ -94,13 +94,7 @@ function $9fcc7f0d70d084ee$export$2314ca2a3e892862(options) {
94
94
  if (isDisabled) return;
95
95
  return (0, $9Tt78$chain)($9fcc7f0d70d084ee$var$addGlobalEventListener('beforecopy', onBeforeCopy), $9fcc7f0d70d084ee$var$addGlobalEventListener('copy', onCopy), $9fcc7f0d70d084ee$var$addGlobalEventListener('beforecut', onBeforeCut), $9fcc7f0d70d084ee$var$addGlobalEventListener('cut', onCut), $9fcc7f0d70d084ee$var$addGlobalEventListener('beforepaste', onBeforePaste), $9fcc7f0d70d084ee$var$addGlobalEventListener('paste', onPaste));
96
96
  }, [
97
- isDisabled,
98
- onBeforeCopy,
99
- onCopy,
100
- onBeforeCut,
101
- onCut,
102
- onBeforePaste,
103
- onPaste
97
+ isDisabled
104
98
  ]);
105
99
  return {
106
100
  clipboardProps: focusProps
@@ -1 +1 @@
1
- {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AA0BD,MAAM,qCAAe,IAAI;AACzB,SAAS,6CAAuB,KAAK,EAAE,EAAE;IACvC,IAAI,YAAY,mCAAa,GAAG,CAAC;IACjC,IAAI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Ac;IAEpB;IAEA,IAAI,QAAQ,CAAA,GAAA,qBAAa,EAAE,CAAC;QAC1B,IAAI,CAAC,aAAa,OAAO,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,QAAQ,QAAQ,EAC9D;QAGF,EAAE,cAAc;QAChB,IAAI,EAAE,aAAa,EAAE;YACnB,CAAA,GAAA,yCAAkB,EAAE,EAAE,aAAa,EAAE,QAAQ,QAAQ,CAAC;gBAAC,QAAQ;YAAK;YACpE,QAAQ,KAAK;QACf;IACF;IAEA,IAAI,gBAAgB,CAAA,GAAA,qBAAa,EAAE,CAAC;QAClC,mFAAmF;QACnF,8EAA8E;QAC9E,IAAI,aAAa,OAAO,IAAI,QAAQ,OAAO,EACzC,EAAE,cAAc;IAEpB;IAEA,IAAI,UAAU,CAAA,GAAA,qBAAa,EAAE,CAAC;QAC5B,IAAI,CAAC,aAAa,OAAO,IAAI,CAAC,QAAQ,OAAO,EAC3C;QAGF,EAAE,cAAc;QAChB,IAAI,EAAE,aAAa,EAAE;YACnB,IAAI,QAAQ,CAAA,GAAA,yCAAmB,EAAE,EAAE,aAAa;YAChD,QAAQ,OAAO,CAAC;QAClB;IACF;IAEA,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,YACF;QAEF,OAAO,CAAA,GAAA,YAAI,EACT,6CAAuB,cAAc,eACrC,6CAAuB,QAAQ,SAC/B,6CAAuB,aAAa,cACpC,6CAAuB,OAAO,QAC9B,6CAAuB,eAAe,gBACtC,6CAAuB,SAAS;IAEpC,GAAG;QAAC;QAAY;QAAc;QAAQ;QAAa;QAAO;QAAe;KAAQ;IAEjF,OAAO;QACL,gBAAgB;IAClB;AACF","sources":["packages/@react-aria/dnd/src/useClipboard.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {chain, useEffectEvent} from '@react-aria/utils';\nimport {DOMAttributes, DragItem, DropItem} from '@react-types/shared';\nimport {readFromDataTransfer, writeToDataTransfer} from './utils';\nimport {useEffect, useRef} from 'react';\nimport {useFocus} from '@react-aria/interactions';\n\nexport interface ClipboardProps {\n /** A function that returns the items to copy. */\n getItems?: (details: {action: 'cut' | 'copy'}) => DragItem[],\n /** Handler that is called when the user triggers a copy interaction. */\n onCopy?: () => void,\n /** Handler that is called when the user triggers a cut interaction. */\n onCut?: () => void,\n /** Handler that is called when the user triggers a paste interaction. */\n onPaste?: (items: DropItem[]) => void,\n /** Whether the clipboard is disabled. */\n isDisabled?: boolean\n}\n\nexport interface ClipboardResult {\n /** Props for the element that will handle clipboard events. */\n clipboardProps: DOMAttributes\n}\n\nconst globalEvents = new Map();\nfunction addGlobalEventListener(event, fn) {\n let eventData = globalEvents.get(event);\n if (!eventData) {\n let handlers = new Set<(e: Event) => void>();\n let listener = (e) => {\n for (let handler of handlers) {\n handler(e);\n }\n };\n\n eventData = {listener, handlers};\n globalEvents.set(event, eventData);\n\n document.addEventListener(event, listener);\n }\n\n eventData.handlers.add(fn);\n return () => {\n eventData.handlers.delete(fn);\n if (eventData.handlers.size === 0) {\n document.removeEventListener(event, eventData.listener);\n globalEvents.delete(event);\n }\n };\n}\n\n/**\n * Handles clipboard interactions for a focusable element. Supports items of multiple\n * data types, and integrates with the operating system native clipboard.\n */\nexport function useClipboard(options: ClipboardProps): ClipboardResult {\n let {isDisabled} = options;\n let isFocusedRef = useRef(false);\n let {focusProps} = useFocus({\n onFocusChange: (isFocused) => {\n isFocusedRef.current = isFocused;\n }\n });\n\n let onBeforeCopy = useEffectEvent((e: ClipboardEvent) => {\n // Enable the \"Copy\" menu item in Safari if this element is focused and copying is supported.\n if (isFocusedRef.current && options.getItems) {\n e.preventDefault();\n }\n });\n\n let onCopy = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.getItems) {\n return;\n }\n\n e.preventDefault();\n if (e.clipboardData) {\n writeToDataTransfer(e.clipboardData, options.getItems({action: 'copy'}));\n options.onCopy?.();\n }\n });\n\n let onBeforeCut = useEffectEvent((e: ClipboardEvent) => {\n if (isFocusedRef.current && options.onCut && options.getItems) {\n e.preventDefault();\n }\n });\n\n let onCut = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.onCut || !options.getItems) {\n return;\n }\n\n e.preventDefault();\n if (e.clipboardData) {\n writeToDataTransfer(e.clipboardData, options.getItems({action: 'cut'}));\n options.onCut();\n }\n });\n\n let onBeforePaste = useEffectEvent((e: ClipboardEvent) => {\n // Unfortunately, e.clipboardData.types is not available in this event so we always\n // have to enable the Paste menu item even if the type of data is unsupported.\n if (isFocusedRef.current && options.onPaste) {\n e.preventDefault();\n }\n });\n\n let onPaste = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.onPaste) {\n return;\n }\n\n e.preventDefault();\n if (e.clipboardData) {\n let items = readFromDataTransfer(e.clipboardData);\n options.onPaste(items);\n }\n });\n\n useEffect(() => {\n if (isDisabled) {\n return;\n }\n return chain(\n addGlobalEventListener('beforecopy', onBeforeCopy),\n addGlobalEventListener('copy', onCopy),\n addGlobalEventListener('beforecut', onBeforeCut),\n addGlobalEventListener('cut', onCut),\n addGlobalEventListener('beforepaste', onBeforePaste),\n addGlobalEventListener('paste', onPaste)\n );\n }, [isDisabled, onBeforeCopy, onCopy, onBeforeCut, onCut, onBeforePaste, onPaste]);\n\n return {\n clipboardProps: focusProps\n };\n}\n"],"names":[],"version":3,"file":"useClipboard.module.js.map"}
1
+ {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AA0BD,MAAM,qCAAe,IAAI;AACzB,SAAS,6CAAuB,KAAK,EAAE,EAAE;IACvC,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KAAK,IAAI,QAAQ,QAAQ,EAC3D,EAAE,cAAc;IAEpB;IAEA,IAAI,QAAQ,CAAA,GAAA,qBAAa,EAAE,CAAC;QAC1B,IAAI,CAAC,aAAa,OAAO,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,QAAQ,QAAQ,EAC9D;QAGF,EAAE,cAAc;QAChB,IAAI,EAAE,aAAa,EAAE;YACnB,CAAA,GAAA,yCAAkB,EAAE,EAAE,aAAa,EAAE,QAAQ,QAAQ,CAAC;gBAAC,QAAQ;YAAK;YACpE,QAAQ,KAAK;QACf;IACF;IAEA,IAAI,gBAAgB,CAAA,GAAA,qBAAa,EAAE,CAAC;QAClC,mFAAmF;QACnF,8EAA8E;QAC9E,IAAI,aAAa,OAAO,IAAI,QAAQ,OAAO,EACzC,EAAE,cAAc;IAEpB;IAEA,IAAI,UAAU,CAAA,GAAA,qBAAa,EAAE,CAAC;QAC5B,IAAI,CAAC,aAAa,OAAO,IAAI,CAAC,QAAQ,OAAO,EAC3C;QAGF,EAAE,cAAc;QAChB,IAAI,EAAE,aAAa,EAAE;YACnB,IAAI,QAAQ,CAAA,GAAA,yCAAmB,EAAE,EAAE,aAAa;YAChD,QAAQ,OAAO,CAAC;QAClB;IACF;IAEA,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,YACF;QAEF,OAAO,CAAA,GAAA,YAAI,EACT,6CAAuB,cAAc,eACrC,6CAAuB,QAAQ,SAC/B,6CAAuB,aAAa,cACpC,6CAAuB,OAAO,QAC9B,6CAAuB,eAAe,gBACtC,6CAAuB,SAAS;IAEpC,GAAG;QAAC;KAAW;IAEf,OAAO;QACL,gBAAgB;IAClB;AACF","sources":["packages/@react-aria/dnd/src/useClipboard.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {chain, useEffectEvent} from '@react-aria/utils';\nimport {DOMAttributes, DragItem, DropItem} from '@react-types/shared';\nimport {readFromDataTransfer, writeToDataTransfer} from './utils';\nimport {useEffect, useRef} from 'react';\nimport {useFocus} from '@react-aria/interactions';\n\nexport interface ClipboardProps {\n /** A function that returns the items to copy. */\n getItems?: (details: {action: 'cut' | 'copy'}) => DragItem[],\n /** Handler that is called when the user triggers a copy interaction. */\n onCopy?: () => void,\n /** Handler that is called when the user triggers a cut interaction. */\n onCut?: () => void,\n /** Handler that is called when the user triggers a paste interaction. */\n onPaste?: (items: DropItem[]) => void,\n /** Whether the clipboard is disabled. */\n isDisabled?: boolean\n}\n\nexport interface ClipboardResult {\n /** Props for the element that will handle clipboard events. */\n clipboardProps: DOMAttributes\n}\n\nconst globalEvents = new Map();\nfunction addGlobalEventListener(event, fn) {\n let eventData = globalEvents.get(event);\n if (!eventData) {\n let handlers = new Set<(e: Event) => void>();\n let listener = (e) => {\n for (let handler of handlers) {\n handler(e);\n }\n };\n\n eventData = {listener, handlers};\n globalEvents.set(event, eventData);\n\n document.addEventListener(event, listener);\n }\n\n eventData.handlers.add(fn);\n return () => {\n eventData.handlers.delete(fn);\n if (eventData.handlers.size === 0) {\n document.removeEventListener(event, eventData.listener);\n globalEvents.delete(event);\n }\n };\n}\n\n/**\n * Handles clipboard interactions for a focusable element. Supports items of multiple\n * data types, and integrates with the operating system native clipboard.\n */\nexport function useClipboard(options: ClipboardProps): ClipboardResult {\n let {isDisabled} = options;\n let isFocusedRef = useRef(false);\n let {focusProps} = useFocus({\n onFocusChange: (isFocused) => {\n isFocusedRef.current = isFocused;\n }\n });\n\n let onBeforeCopy = useEffectEvent((e: ClipboardEvent) => {\n // Enable the \"Copy\" menu item in Safari if this element is focused and copying is supported.\n if (isFocusedRef.current && options.getItems) {\n e.preventDefault();\n }\n });\n\n let onCopy = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.getItems) {\n return;\n }\n\n e.preventDefault();\n if (e.clipboardData) {\n writeToDataTransfer(e.clipboardData, options.getItems({action: 'copy'}));\n options.onCopy?.();\n }\n });\n\n let onBeforeCut = useEffectEvent((e: ClipboardEvent) => {\n if (isFocusedRef.current && options.onCut && options.getItems) {\n e.preventDefault();\n }\n });\n\n let onCut = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.onCut || !options.getItems) {\n return;\n }\n\n e.preventDefault();\n if (e.clipboardData) {\n writeToDataTransfer(e.clipboardData, options.getItems({action: 'cut'}));\n options.onCut();\n }\n });\n\n let onBeforePaste = useEffectEvent((e: ClipboardEvent) => {\n // Unfortunately, e.clipboardData.types is not available in this event so we always\n // have to enable the Paste menu item even if the type of data is unsupported.\n if (isFocusedRef.current && options.onPaste) {\n e.preventDefault();\n }\n });\n\n let onPaste = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.onPaste) {\n return;\n }\n\n e.preventDefault();\n if (e.clipboardData) {\n let items = readFromDataTransfer(e.clipboardData);\n options.onPaste(items);\n }\n });\n\n useEffect(() => {\n if (isDisabled) {\n return;\n }\n return chain(\n addGlobalEventListener('beforecopy', onBeforeCopy),\n addGlobalEventListener('copy', onCopy),\n addGlobalEventListener('beforecut', onBeforeCut),\n addGlobalEventListener('cut', onCut),\n addGlobalEventListener('beforepaste', onBeforePaste),\n addGlobalEventListener('paste', onPaste)\n );\n }, [isDisabled]);\n\n return {\n clipboardProps: focusProps\n };\n}\n"],"names":[],"version":3,"file":"useClipboard.module.js.map"}
@@ -221,12 +221,7 @@ function $1ca228bc9257ca16$export$ccdee5eaf73cf661(options) {
221
221
  });
222
222
  }, [
223
223
  isDisabled,
224
- ref,
225
- getDropOperationKeyboard,
226
- onDropEnter,
227
- onDropExit,
228
- onKeyboardDrop,
229
- onDropActivate
224
+ ref
230
225
  ]);
231
226
  let { dropProps: dropProps } = (0, $419982e205c8e8dc$exports.useVirtualDrop)();
232
227
  if (isDisabled) return {
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAsDD,MAAM,8CAAwB;AAMvB,SAAS,0CAAQ,OAAoB;IAC1C,IAAI,iBAAC,aAAa,cAAE,UAAU,EAAC,GAAG;IAClC,IAAI,CAAC,cAAc,cAAc,GAAG,CAAA,GAAA,qBAAO,EAAE;IAC7C,IAAI,QAAQ,CAAA,GAAA,mBAAK,EAOd;QACD,GAAG;QACH,GAAG;QACH,kBAAkB,IAAI;QACtB,YAAY;QACZ,mBAAmB,CAAA,GAAA,wCAAa,EAAE,GAAG;QACrC,mBAAmB;IACrB,GAAG,OAAO;IAEV,IAAI,gBAAgB,CAAC;QACnB,cAAc;QAEd,IAAI,OAAO,QAAQ,WAAW,KAAK,YAAY;YAC7C,IAAI,OAAO,AAAC,EAAE,aAAa,CAAiB,qBAAqB;YACjE,QAAQ,WAAW,CAAC;gBAClB,MAAM;gBACN,GAAG,EAAE,OAAO,GAAG,KAAK,CAAC;gBACrB,GAAG,EAAE,OAAO,GAAG,KAAK,CAAC;YACvB;QACF;IACF;IAEA,IAAI,eAAe,CAAC;QAClB,cAAc;QAEd,IAAI,OAAO,QAAQ,UAAU,KAAK,YAAY;YAC5C,IAAI,OAAO,AAAC,EAAE,aAAa,CAAiB,qBAAqB;YACjE,QAAQ,UAAU,CAAC;gBACjB,MAAM;gBACN,GAAG,EAAE,OAAO,GAAG,KAAK,CAAC;gBACrB,GAAG,EAAE,OAAO,GAAG,KAAK,CAAC;YACvB;QACF;IACF;IAEA,IAAI,aAAa,CAAC;QAChB,EAAE,cAAc;QAChB,EAAE,eAAe;QAEjB,IAAI,oBAAoB,2CAAqB;QAC7C,IAAI,EAAE,OAAO,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,CAA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EACV,oBAAoB,CAAA,GAAA,wCAAa,EAAE,IAAI;QAGzC,IAAI,EAAE,QAAQ,EACZ,oBAAoB,CAAA,GAAA,wCAAa,EAAE,IAAI;QAGzC,IAAI,EAAE,OAAO,EACX,oBAAoB,CAAA,GAAA,wCAAa,EAAE,IAAI;IAE3C;IAEA,IAAI,kBACF,OAAO,oBAAoB;IAG7B,OAAO;AACT;AAEA,SAAS,+CAAyB,qBAAqC;IACrE,IAAI,oBAA0C,EAAE;IAChD,IAAI,wBAAwB,CAAA,GAAA,wCAAa,EAAE,IAAI,EAC7C,kBAAkB,IAAI,CAAC;IAGzB,IAAI,wBAAwB,CAAA,GAAA,wCAAa,EAAE,IAAI,EAC7C,kBAAkB,IAAI,CAAC;IAGzB,IAAI,wBAAwB,CAAA,GAAA,wCAAa,EAAE,IAAI,EAC7C,kBAAkB,IAAI,CAAC;IAGzB,OAAO;AACT;AAEA,SAAS,uCAAiB,iBAAiC,EAAE,SAAwB;IACnF,IAAI,KAAK,CAAA,GAAA,wCAAa,CAAC,CAAC,UAAU;IAClC,OAAO,oBAAoB,KAAK,YAAY;AAC9C","sources":["packages/@react-aria/dnd/src/useDrop.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {DOMAttributes, DropActivateEvent, DropEnterEvent, DropEvent, DropExitEvent, DropMoveEvent, DropOperation, FocusableElement, DragTypes as IDragTypes, RefObject} from '@react-types/shared';\nimport {DragEvent, useRef, useState} from 'react';\nimport * as DragManager from './DragManager';\nimport {DragTypes, globalAllowedDropOperations, globalDndState, readFromDataTransfer, setGlobalDnDState, setGlobalDropEffect} from './utils';\nimport {DROP_EFFECT_TO_DROP_OPERATION, DROP_OPERATION, DROP_OPERATION_ALLOWED, DROP_OPERATION_TO_DROP_EFFECT} from './constants';\nimport {isIPad, isMac, useEffectEvent, useLayoutEffect} from '@react-aria/utils';\nimport {useVirtualDrop} from './useVirtualDrop';\n\nexport interface DropOptions {\n /** A ref for the droppable element. */\n ref: RefObject<FocusableElement | null>,\n /**\n * A function returning the drop operation to be performed when items matching the given types are dropped\n * on the drop target.\n */\n getDropOperation?: (types: IDragTypes, allowedOperations: DropOperation[]) => DropOperation,\n /** A function that returns the drop operation for a specific point within the target. */\n getDropOperationForPoint?: (types: IDragTypes, allowedOperations: DropOperation[], x: number, y: number) => DropOperation,\n /** Handler that is called when a valid drag enters the drop target. */\n onDropEnter?: (e: DropEnterEvent) => void,\n /** Handler that is called when a valid drag is moved within the drop target. */\n onDropMove?: (e: DropMoveEvent) => void,\n /**\n * Handler that is called after a valid drag is held over the drop target for a period of time.\n * This typically opens the item so that the user can drop within it.\n */\n onDropActivate?: (e: DropActivateEvent) => void,\n /** Handler that is called when a valid drag exits the drop target. */\n onDropExit?: (e: DropExitEvent) => void,\n /** Handler that is called when a valid drag is dropped on the drop target. */\n onDrop?: (e: DropEvent) => void,\n /**\n * Whether the item has an explicit focusable drop affordance to initiate accessible drag and drop mode.\n * If true, the dropProps will omit these event handlers, and they will be applied to dropButtonProps instead.\n */\n hasDropButton?: boolean,\n /**\n * Whether the drop target is disabled. If true, the drop target will not accept any drops.\n */\n isDisabled?: boolean\n}\n\nexport interface DropResult {\n /** Props for the droppable element. */\n dropProps: DOMAttributes,\n /** Whether the drop target is currently focused or hovered. */\n isDropTarget: boolean,\n /** Props for the explicit drop button affordance, if any. */\n dropButtonProps?: AriaButtonProps\n}\n\nconst DROP_ACTIVATE_TIMEOUT = 800;\n\n/**\n * Handles drop interactions for an element, with support for traditional mouse and touch\n * based drag and drop, in addition to full parity for keyboard and screen reader users.\n */\nexport function useDrop(options: DropOptions): DropResult {\n let {hasDropButton, isDisabled} = options;\n let [isDropTarget, setDropTarget] = useState(false);\n let state = useRef<{\n x: number,\n y: number,\n dragOverElements: Set<Element>,\n dropEffect: DataTransfer['dropEffect'],\n allowedOperations: DROP_OPERATION,\n dropActivateTimer: ReturnType<typeof setTimeout> | undefined\n }>({\n x: 0,\n y: 0,\n dragOverElements: new Set<Element>(),\n dropEffect: 'none',\n allowedOperations: DROP_OPERATION.all,\n dropActivateTimer: undefined\n }).current;\n\n let fireDropEnter = (e: DragEvent) => {\n setDropTarget(true);\n\n if (typeof options.onDropEnter === 'function') {\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n options.onDropEnter({\n type: 'dropenter',\n x: e.clientX - rect.x,\n y: e.clientY - rect.y\n });\n }\n };\n\n let fireDropExit = (e: DragEvent) => {\n setDropTarget(false);\n\n if (typeof options.onDropExit === 'function') {\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n options.onDropExit({\n type: 'dropexit',\n x: e.clientX - rect.x,\n y: e.clientY - rect.y\n });\n }\n };\n\n let onDragOver = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n\n let allowedOperations = getAllowedOperations(e);\n if (e.clientX === state.x && e.clientY === state.y && allowedOperations === state.allowedOperations) {\n e.dataTransfer.dropEffect = state.dropEffect;\n return;\n }\n\n state.x = e.clientX;\n state.y = e.clientY;\n\n let prevDropEffect = state.dropEffect;\n\n // Update drop effect if allowed drop operations changed (e.g. user pressed modifier key).\n if (allowedOperations !== state.allowedOperations) {\n let allowedOps = allowedOperationsToArray(allowedOperations);\n let dropOperation = allowedOps[0];\n if (typeof options.getDropOperation === 'function') {\n let types = new DragTypes(e.dataTransfer);\n dropOperation = getDropOperation(allowedOperations, options.getDropOperation(types, allowedOps));\n }\n state.dropEffect = DROP_OPERATION_TO_DROP_EFFECT[dropOperation] || 'none';\n }\n\n if (typeof options.getDropOperationForPoint === 'function') {\n let types = new DragTypes(e.dataTransfer);\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n let dropOperation = getDropOperation(\n allowedOperations,\n options.getDropOperationForPoint(types, allowedOperationsToArray(allowedOperations), state.x - rect.x, state.y - rect.y)\n );\n state.dropEffect = DROP_OPERATION_TO_DROP_EFFECT[dropOperation] || 'none';\n }\n\n state.allowedOperations = allowedOperations;\n e.dataTransfer.dropEffect = state.dropEffect;\n\n // If the drop operation changes, update state and fire events appropriately.\n if (state.dropEffect === 'none' && prevDropEffect !== 'none') {\n fireDropExit(e);\n } else if (state.dropEffect !== 'none' && prevDropEffect === 'none') {\n fireDropEnter(e);\n }\n\n if (typeof options.onDropMove === 'function' && state.dropEffect !== 'none') {\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n options.onDropMove({\n type: 'dropmove',\n x: state.x - rect.x,\n y: state.y - rect.y\n });\n }\n\n clearTimeout(state.dropActivateTimer);\n\n if (options.onDropActivate && typeof options.onDropActivate === 'function' && state.dropEffect !== 'none') {\n let onDropActivateOptions = options.onDropActivate;\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n state.dropActivateTimer = setTimeout(() => {\n onDropActivateOptions({\n type: 'dropactivate',\n x: state.x - rect.x,\n y: state.y - rect.y\n });\n }, DROP_ACTIVATE_TIMEOUT);\n }\n };\n\n let onDragEnter = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n state.dragOverElements.add(e.target as Element);\n if (state.dragOverElements.size > 1) {\n return;\n }\n\n let allowedOperationsBits = getAllowedOperations(e);\n let allowedOperations = allowedOperationsToArray(allowedOperationsBits);\n let dropOperation = allowedOperations[0];\n\n if (typeof options.getDropOperation === 'function') {\n let types = new DragTypes(e.dataTransfer);\n dropOperation = getDropOperation(allowedOperationsBits, options.getDropOperation(types, allowedOperations));\n }\n\n if (typeof options.getDropOperationForPoint === 'function') {\n let types = new DragTypes(e.dataTransfer);\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n dropOperation = getDropOperation(\n allowedOperationsBits,\n options.getDropOperationForPoint(types, allowedOperations, e.clientX - rect.x, e.clientY - rect.y)\n );\n }\n\n state.x = e.clientX;\n state.y = e.clientY;\n state.allowedOperations = allowedOperationsBits;\n state.dropEffect = DROP_OPERATION_TO_DROP_EFFECT[dropOperation] || 'none';\n e.dataTransfer.dropEffect = state.dropEffect;\n\n if (dropOperation !== 'cancel') {\n fireDropEnter(e);\n }\n };\n\n let onDragLeave = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n\n // We would use e.relatedTarget to detect if the drag is still inside the drop target,\n // but it is always null in WebKit. https://bugs.webkit.org/show_bug.cgi?id=66547\n // Instead, we track all of the targets of dragenter events in a set, and remove them\n // in dragleave. When the set becomes empty, we've left the drop target completely.\n // We must also remove any elements that are no longer in the DOM, because dragleave\n // events will never be fired for these. This can happen, for example, with drop\n // indicators between items, which disappear when the drop target changes.\n\n state.dragOverElements.delete(e.target as Element);\n for (let element of state.dragOverElements) {\n if (!e.currentTarget.contains(element)) {\n state.dragOverElements.delete(element);\n }\n }\n\n if (state.dragOverElements.size > 0) {\n return;\n }\n\n if (state.dropEffect !== 'none') {\n fireDropExit(e);\n }\n\n clearTimeout(state.dropActivateTimer);\n };\n\n let onDrop = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n // Track drop effect in global state for Chrome Android. https://bugs.chromium.org/p/chromium/issues/detail?id=1353951\n // Android onDragEnd always returns \"none\" as its drop effect.\n setGlobalDropEffect(state.dropEffect);\n\n if (typeof options.onDrop === 'function') {\n let dropOperation = DROP_EFFECT_TO_DROP_OPERATION[state.dropEffect];\n let items = readFromDataTransfer(e.dataTransfer);\n\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n let event: DropEvent = {\n type: 'drop',\n x: e.clientX - rect.x,\n y: e.clientY - rect.y,\n items,\n dropOperation\n };\n\n options.onDrop(event);\n }\n\n let dndStateSnapshot = {...globalDndState};\n state.dragOverElements.clear();\n fireDropExit(e);\n clearTimeout(state.dropActivateTimer);\n // If there wasn't a collection being tracked as a dragged collection, then we are in a case where a non RSP drag is dropped on a\n // RSP collection and thus we don't need to preserve the global drop effect\n if (dndStateSnapshot.draggingCollectionRef == null) {\n setGlobalDropEffect(undefined);\n } else {\n // Otherwise we need to preserve the global dnd state for onDragEnd's isInternal check.\n // At the moment fireDropExit may clear dropCollectionRef (i.e. useDroppableCollection's provided onDropExit, required to clear dropCollectionRef when exiting a valid drop target)\n setGlobalDnDState(dndStateSnapshot);\n }\n };\n\n let onDropEnter = useEffectEvent((e: DropEnterEvent) => {\n if (typeof options.onDropEnter === 'function') {\n options.onDropEnter(e);\n }\n });\n\n let onDropExit = useEffectEvent((e: DropExitEvent) => {\n if (typeof options.onDropExit === 'function') {\n options.onDropExit(e);\n }\n });\n\n let onDropActivate = useEffectEvent((e: DropActivateEvent) => {\n if (typeof options.onDropActivate === 'function') {\n options.onDropActivate(e);\n }\n });\n\n let onKeyboardDrop = useEffectEvent((e: DropEvent) => {\n if (typeof options.onDrop === 'function') {\n options.onDrop(e);\n }\n });\n\n let getDropOperationKeyboard = useEffectEvent((types: IDragTypes, allowedOperations: DropOperation[]) => {\n if (options.getDropOperation) {\n return options.getDropOperation(types, allowedOperations);\n }\n\n return allowedOperations[0];\n });\n\n let {ref} = options;\n useLayoutEffect(() => {\n if (isDisabled || !ref.current) {\n return;\n }\n return DragManager.registerDropTarget({\n element: ref.current,\n getDropOperation: getDropOperationKeyboard,\n onDropEnter(e) {\n setDropTarget(true);\n onDropEnter(e);\n },\n onDropExit(e) {\n setDropTarget(false);\n onDropExit(e);\n },\n onDrop: onKeyboardDrop,\n onDropActivate\n });\n }, [isDisabled, ref, getDropOperationKeyboard, onDropEnter, onDropExit, onKeyboardDrop, onDropActivate]);\n\n let {dropProps} = useVirtualDrop();\n if (isDisabled) {\n return {\n dropProps: {},\n dropButtonProps: {isDisabled: true},\n isDropTarget: false\n };\n }\n return {\n dropProps: {\n ...(!hasDropButton && dropProps),\n onDragEnter,\n onDragOver,\n onDragLeave,\n onDrop\n },\n dropButtonProps: {...(hasDropButton && dropProps)},\n isDropTarget\n };\n}\n\nfunction getAllowedOperations(e: DragEvent) {\n let allowedOperations = DROP_OPERATION_ALLOWED[e.dataTransfer.effectAllowed];\n\n // WebKit always sets effectAllowed to \"copyMove\" on macOS, and \"all\" on iOS, regardless of what was\n // set during the dragstart event: https://bugs.webkit.org/show_bug.cgi?id=178058\n //\n // Android Chrome also sets effectAllowed to \"copyMove\" in all cases: https://bugs.chromium.org/p/chromium/issues/detail?id=1359182\n //\n // If the drag started within the page, we can use a global variable to get the real allowed operations.\n // This needs to be intersected with the actual effectAllowed, which may have been filtered based on modifier keys.\n // Unfortunately, this means that link operations do not work at all in Safari.\n if (globalAllowedDropOperations) {\n allowedOperations &= globalAllowedDropOperations;\n }\n\n // Chrome and Safari on macOS will automatically filter effectAllowed when pressing modifier keys,\n // allowing the user to switch between move, link, and copy operations. Firefox on macOS and all\n // Windows browsers do not do this, so do it ourselves instead. The exact keys are platform dependent.\n // https://ux.stackexchange.com/questions/83748/what-are-the-most-common-modifier-keys-for-dragging-objects-with-a-mouse\n //\n // Note that none of these modifiers are ever set in WebKit due to a bug: https://bugs.webkit.org/show_bug.cgi?id=77465\n // However, Safari does update effectAllowed correctly, so we can just rely on that.\n let allowedModifiers = DROP_OPERATION.none;\n if (isMac()) {\n if (e.altKey) {\n allowedModifiers |= DROP_OPERATION.copy;\n }\n\n // Chrome and Safari both use the Control key for link, even though Finder uses Command + Option.\n // iPadOS doesn't support link operations and will not fire the drop event at all if dropEffect is set to link.\n // https://bugs.webkit.org/show_bug.cgi?id=244701\n if (e.ctrlKey && !isIPad()) {\n allowedModifiers |= DROP_OPERATION.link;\n }\n\n if (e.metaKey) {\n allowedModifiers |= DROP_OPERATION.move;\n }\n } else {\n if (e.altKey) {\n allowedModifiers |= DROP_OPERATION.link;\n }\n\n if (e.shiftKey) {\n allowedModifiers |= DROP_OPERATION.move;\n }\n\n if (e.ctrlKey) {\n allowedModifiers |= DROP_OPERATION.copy;\n }\n }\n\n if (allowedModifiers) {\n return allowedOperations & allowedModifiers;\n }\n\n return allowedOperations;\n}\n\nfunction allowedOperationsToArray(allowedOperationsBits: DROP_OPERATION) {\n let allowedOperations: Array<DropOperation> = [];\n if (allowedOperationsBits & DROP_OPERATION.move) {\n allowedOperations.push('move');\n }\n\n if (allowedOperationsBits & DROP_OPERATION.copy) {\n allowedOperations.push('copy');\n }\n\n if (allowedOperationsBits & DROP_OPERATION.link) {\n allowedOperations.push('link');\n }\n\n return allowedOperations;\n}\n\nfunction getDropOperation(allowedOperations: DROP_OPERATION, operation: DropOperation) {\n let op = DROP_OPERATION[operation];\n return allowedOperations & op ? operation : 'cancel';\n}\n"],"names":[],"version":3,"file":"useDrop.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAsDD,MAAM,8CAAwB;AAMvB,SAAS,0CAAQ,OAAoB;IAC1C,IAAI,iBAAC,aAAa,cAAE,UAAU,EAAC,GAAG;IAClC,IAAI,CAAC,cAAc,cAAc,GAAG,CAAA,GAAA,qBAAO,EAAE;IAC7C,IAAI,QAAQ,CAAA,GAAA,mBAAK,EAOd;QACD,GAAG;QACH,GAAG;QACH,kBAAkB,IAAI;QACtB,YAAY;QACZ,mBAAmB,CAAA,GAAA,wCAAa,EAAE,GAAG;QACrC,mBAAmB;IACrB,GAAG,OAAO;IAEV,IAAI,gBAAgB,CAAC;QACnB,cAAc;QAEd,IAAI,OAAO,QAAQ,WAAW,KAAK,YAAY;YAC7C,IAAI,OAAO,AAAC,EAAE,aAAa,CAAiB,qBAAqB;YACjE,QAAQ,WAAW,CAAC;gBAClB,MAAM;gBACN,GAAG,EAAE,OAAO,GAAG,KAAK,CAAC;gBACrB,GAAG,EAAE,OAAO,GAAG,KAAK,CAAC;YACvB;QACF;IACF;IAEA,IAAI,eAAe,CAAC;QAClB,cAAc;QAEd,IAAI,O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AC1C,IAAI,CAAA,GAAA,2BAAI,KAAK;QACX,IAAI,EAAE,MAAM,EACV,oBAAoB,CAAA,GAAA,wCAAa,EAAE,IAAI;QAGzC,iGAAiG;QACjG,+GAA+G;QAC/G,iDAAiD;QACjD,IAAI,EAAE,OAAO,IAAI,CAAC,CAAA,GAAA,4BAAK,KACrB,oBAAoB,CAAA,GAAA,wCAAa,EAAE,IAAI;QAGzC,IAAI,EAAE,OAAO,EACX,oBAAoB,CAAA,GAAA,wCAAa,EAAE,IAAI;IAE3C,OAAO;QACL,IAAI,EAAE,MAAM,EACV,oBAAoB,CAAA,GAAA,wCAAa,EAAE,IAAI;QAGzC,IAAI,EAAE,QAAQ,EACZ,oBAAoB,CAAA,GAAA,wCAAa,EAAE,IAAI;QAGzC,IAAI,EAAE,OAAO,EACX,oBAAoB,CAAA,GAAA,wCAAa,EAAE,IAAI;IAE3C;IAEA,IAAI,kBACF,OAAO,oBAAoB;IAG7B,OAAO;AACT;AAEA,SAAS,+CAAyB,qBAAqC;IACrE,IAAI,oBAA0C,EAAE;IAChD,IAAI,wBAAwB,CAAA,GAAA,wCAAa,EAAE,IAAI,EAC7C,kBAAkB,IAAI,CAAC;IAGzB,IAAI,wBAAwB,CAAA,GAAA,wCAAa,EAAE,IAAI,EAC7C,kBAAkB,IAAI,CAAC;IAGzB,IAAI,wBAAwB,CAAA,GAAA,wCAAa,EAAE,IAAI,EAC7C,kBAAkB,IAAI,CAAC;IAGzB,OAAO;AACT;AAEA,SAAS,uCAAiB,iBAAiC,EAAE,SAAwB;IACnF,IAAI,KAAK,CAAA,GAAA,wCAAa,CAAC,CAAC,UAAU;IAClC,OAAO,oBAAoB,KAAK,YAAY;AAC9C","sources":["packages/@react-aria/dnd/src/useDrop.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {DOMAttributes, DropActivateEvent, DropEnterEvent, DropEvent, DropExitEvent, DropMoveEvent, DropOperation, FocusableElement, DragTypes as IDragTypes, RefObject} from '@react-types/shared';\nimport {DragEvent, useRef, useState} from 'react';\nimport * as DragManager from './DragManager';\nimport {DragTypes, globalAllowedDropOperations, globalDndState, readFromDataTransfer, setGlobalDnDState, setGlobalDropEffect} from './utils';\nimport {DROP_EFFECT_TO_DROP_OPERATION, DROP_OPERATION, DROP_OPERATION_ALLOWED, DROP_OPERATION_TO_DROP_EFFECT} from './constants';\nimport {isIPad, isMac, useEffectEvent, useLayoutEffect} from '@react-aria/utils';\nimport {useVirtualDrop} from './useVirtualDrop';\n\nexport interface DropOptions {\n /** A ref for the droppable element. */\n ref: RefObject<FocusableElement | null>,\n /**\n * A function returning the drop operation to be performed when items matching the given types are dropped\n * on the drop target.\n */\n getDropOperation?: (types: IDragTypes, allowedOperations: DropOperation[]) => DropOperation,\n /** A function that returns the drop operation for a specific point within the target. */\n getDropOperationForPoint?: (types: IDragTypes, allowedOperations: DropOperation[], x: number, y: number) => DropOperation,\n /** Handler that is called when a valid drag enters the drop target. */\n onDropEnter?: (e: DropEnterEvent) => void,\n /** Handler that is called when a valid drag is moved within the drop target. */\n onDropMove?: (e: DropMoveEvent) => void,\n /**\n * Handler that is called after a valid drag is held over the drop target for a period of time.\n * This typically opens the item so that the user can drop within it.\n */\n onDropActivate?: (e: DropActivateEvent) => void,\n /** Handler that is called when a valid drag exits the drop target. */\n onDropExit?: (e: DropExitEvent) => void,\n /** Handler that is called when a valid drag is dropped on the drop target. */\n onDrop?: (e: DropEvent) => void,\n /**\n * Whether the item has an explicit focusable drop affordance to initiate accessible drag and drop mode.\n * If true, the dropProps will omit these event handlers, and they will be applied to dropButtonProps instead.\n */\n hasDropButton?: boolean,\n /**\n * Whether the drop target is disabled. If true, the drop target will not accept any drops.\n */\n isDisabled?: boolean\n}\n\nexport interface DropResult {\n /** Props for the droppable element. */\n dropProps: DOMAttributes,\n /** Whether the drop target is currently focused or hovered. */\n isDropTarget: boolean,\n /** Props for the explicit drop button affordance, if any. */\n dropButtonProps?: AriaButtonProps\n}\n\nconst DROP_ACTIVATE_TIMEOUT = 800;\n\n/**\n * Handles drop interactions for an element, with support for traditional mouse and touch\n * based drag and drop, in addition to full parity for keyboard and screen reader users.\n */\nexport function useDrop(options: DropOptions): DropResult {\n let {hasDropButton, isDisabled} = options;\n let [isDropTarget, setDropTarget] = useState(false);\n let state = useRef<{\n x: number,\n y: number,\n dragOverElements: Set<Element>,\n dropEffect: DataTransfer['dropEffect'],\n allowedOperations: DROP_OPERATION,\n dropActivateTimer: ReturnType<typeof setTimeout> | undefined\n }>({\n x: 0,\n y: 0,\n dragOverElements: new Set<Element>(),\n dropEffect: 'none',\n allowedOperations: DROP_OPERATION.all,\n dropActivateTimer: undefined\n }).current;\n\n let fireDropEnter = (e: DragEvent) => {\n setDropTarget(true);\n\n if (typeof options.onDropEnter === 'function') {\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n options.onDropEnter({\n type: 'dropenter',\n x: e.clientX - rect.x,\n y: e.clientY - rect.y\n });\n }\n };\n\n let fireDropExit = (e: DragEvent) => {\n setDropTarget(false);\n\n if (typeof options.onDropExit === 'function') {\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n options.onDropExit({\n type: 'dropexit',\n x: e.clientX - rect.x,\n y: e.clientY - rect.y\n });\n }\n };\n\n let onDragOver = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n\n let allowedOperations = getAllowedOperations(e);\n if (e.clientX === state.x && e.clientY === state.y && allowedOperations === state.allowedOperations) {\n e.dataTransfer.dropEffect = state.dropEffect;\n return;\n }\n\n state.x = e.clientX;\n state.y = e.clientY;\n\n let prevDropEffect = state.dropEffect;\n\n // Update drop effect if allowed drop operations changed (e.g. user pressed modifier key).\n if (allowedOperations !== state.allowedOperations) {\n let allowedOps = allowedOperationsToArray(allowedOperations);\n let dropOperation = allowedOps[0];\n if (typeof options.getDropOperation === 'function') {\n let types = new DragTypes(e.dataTransfer);\n dropOperation = getDropOperation(allowedOperations, options.getDropOperation(types, allowedOps));\n }\n state.dropEffect = DROP_OPERATION_TO_DROP_EFFECT[dropOperation] || 'none';\n }\n\n if (typeof options.getDropOperationForPoint === 'function') {\n let types = new DragTypes(e.dataTransfer);\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n let dropOperation = getDropOperation(\n allowedOperations,\n options.getDropOperationForPoint(types, allowedOperationsToArray(allowedOperations), state.x - rect.x, state.y - rect.y)\n );\n state.dropEffect = DROP_OPERATION_TO_DROP_EFFECT[dropOperation] || 'none';\n }\n\n state.allowedOperations = allowedOperations;\n e.dataTransfer.dropEffect = state.dropEffect;\n\n // If the drop operation changes, update state and fire events appropriately.\n if (state.dropEffect === 'none' && prevDropEffect !== 'none') {\n fireDropExit(e);\n } else if (state.dropEffect !== 'none' && prevDropEffect === 'none') {\n fireDropEnter(e);\n }\n\n if (typeof options.onDropMove === 'function' && state.dropEffect !== 'none') {\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n options.onDropMove({\n type: 'dropmove',\n x: state.x - rect.x,\n y: state.y - rect.y\n });\n }\n\n clearTimeout(state.dropActivateTimer);\n\n if (options.onDropActivate && typeof options.onDropActivate === 'function' && state.dropEffect !== 'none') {\n let onDropActivateOptions = options.onDropActivate;\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n state.dropActivateTimer = setTimeout(() => {\n onDropActivateOptions({\n type: 'dropactivate',\n x: state.x - rect.x,\n y: state.y - rect.y\n });\n }, DROP_ACTIVATE_TIMEOUT);\n }\n };\n\n let onDragEnter = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n state.dragOverElements.add(e.target as Element);\n if (state.dragOverElements.size > 1) {\n return;\n }\n\n let allowedOperationsBits = getAllowedOperations(e);\n let allowedOperations = allowedOperationsToArray(allowedOperationsBits);\n let dropOperation = allowedOperations[0];\n\n if (typeof options.getDropOperation === 'function') {\n let types = new DragTypes(e.dataTransfer);\n dropOperation = getDropOperation(allowedOperationsBits, options.getDropOperation(types, allowedOperations));\n }\n\n if (typeof options.getDropOperationForPoint === 'function') {\n let types = new DragTypes(e.dataTransfer);\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n dropOperation = getDropOperation(\n allowedOperationsBits,\n options.getDropOperationForPoint(types, allowedOperations, e.clientX - rect.x, e.clientY - rect.y)\n );\n }\n\n state.x = e.clientX;\n state.y = e.clientY;\n state.allowedOperations = allowedOperationsBits;\n state.dropEffect = DROP_OPERATION_TO_DROP_EFFECT[dropOperation] || 'none';\n e.dataTransfer.dropEffect = state.dropEffect;\n\n if (dropOperation !== 'cancel') {\n fireDropEnter(e);\n }\n };\n\n let onDragLeave = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n\n // We would use e.relatedTarget to detect if the drag is still inside the drop target,\n // but it is always null in WebKit. https://bugs.webkit.org/show_bug.cgi?id=66547\n // Instead, we track all of the targets of dragenter events in a set, and remove them\n // in dragleave. When the set becomes empty, we've left the drop target completely.\n // We must also remove any elements that are no longer in the DOM, because dragleave\n // events will never be fired for these. This can happen, for example, with drop\n // indicators between items, which disappear when the drop target changes.\n\n state.dragOverElements.delete(e.target as Element);\n for (let element of state.dragOverElements) {\n if (!e.currentTarget.contains(element)) {\n state.dragOverElements.delete(element);\n }\n }\n\n if (state.dragOverElements.size > 0) {\n return;\n }\n\n if (state.dropEffect !== 'none') {\n fireDropExit(e);\n }\n\n clearTimeout(state.dropActivateTimer);\n };\n\n let onDrop = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n // Track drop effect in global state for Chrome Android. https://bugs.chromium.org/p/chromium/issues/detail?id=1353951\n // Android onDragEnd always returns \"none\" as its drop effect.\n setGlobalDropEffect(state.dropEffect);\n\n if (typeof options.onDrop === 'function') {\n let dropOperation = DROP_EFFECT_TO_DROP_OPERATION[state.dropEffect];\n let items = readFromDataTransfer(e.dataTransfer);\n\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n let event: DropEvent = {\n type: 'drop',\n x: e.clientX - rect.x,\n y: e.clientY - rect.y,\n items,\n dropOperation\n };\n\n options.onDrop(event);\n }\n\n let dndStateSnapshot = {...globalDndState};\n state.dragOverElements.clear();\n fireDropExit(e);\n clearTimeout(state.dropActivateTimer);\n // If there wasn't a collection being tracked as a dragged collection, then we are in a case where a non RSP drag is dropped on a\n // RSP collection and thus we don't need to preserve the global drop effect\n if (dndStateSnapshot.draggingCollectionRef == null) {\n setGlobalDropEffect(undefined);\n } else {\n // Otherwise we need to preserve the global dnd state for onDragEnd's isInternal check.\n // At the moment fireDropExit may clear dropCollectionRef (i.e. useDroppableCollection's provided onDropExit, required to clear dropCollectionRef when exiting a valid drop target)\n setGlobalDnDState(dndStateSnapshot);\n }\n };\n\n let onDropEnter = useEffectEvent((e: DropEnterEvent) => {\n if (typeof options.onDropEnter === 'function') {\n options.onDropEnter(e);\n }\n });\n\n let onDropExit = useEffectEvent((e: DropExitEvent) => {\n if (typeof options.onDropExit === 'function') {\n options.onDropExit(e);\n }\n });\n\n let onDropActivate = useEffectEvent((e: DropActivateEvent) => {\n if (typeof options.onDropActivate === 'function') {\n options.onDropActivate(e);\n }\n });\n\n let onKeyboardDrop = useEffectEvent((e: DropEvent) => {\n if (typeof options.onDrop === 'function') {\n options.onDrop(e);\n }\n });\n\n let getDropOperationKeyboard = useEffectEvent((types: IDragTypes, allowedOperations: DropOperation[]) => {\n if (options.getDropOperation) {\n return options.getDropOperation(types, allowedOperations);\n }\n\n return allowedOperations[0];\n });\n\n let {ref} = options;\n useLayoutEffect(() => {\n if (isDisabled || !ref.current) {\n return;\n }\n return DragManager.registerDropTarget({\n element: ref.current,\n getDropOperation: getDropOperationKeyboard,\n onDropEnter(e) {\n setDropTarget(true);\n onDropEnter(e);\n },\n onDropExit(e) {\n setDropTarget(false);\n onDropExit(e);\n },\n onDrop: onKeyboardDrop,\n onDropActivate\n });\n }, [isDisabled, ref]);\n\n let {dropProps} = useVirtualDrop();\n if (isDisabled) {\n return {\n dropProps: {},\n dropButtonProps: {isDisabled: true},\n isDropTarget: false\n };\n }\n return {\n dropProps: {\n ...(!hasDropButton && dropProps),\n onDragEnter,\n onDragOver,\n onDragLeave,\n onDrop\n },\n dropButtonProps: {...(hasDropButton && dropProps)},\n isDropTarget\n };\n}\n\nfunction getAllowedOperations(e: DragEvent) {\n let allowedOperations = DROP_OPERATION_ALLOWED[e.dataTransfer.effectAllowed];\n\n // WebKit always sets effectAllowed to \"copyMove\" on macOS, and \"all\" on iOS, regardless of what was\n // set during the dragstart event: https://bugs.webkit.org/show_bug.cgi?id=178058\n //\n // Android Chrome also sets effectAllowed to \"copyMove\" in all cases: https://bugs.chromium.org/p/chromium/issues/detail?id=1359182\n //\n // If the drag started within the page, we can use a global variable to get the real allowed operations.\n // This needs to be intersected with the actual effectAllowed, which may have been filtered based on modifier keys.\n // Unfortunately, this means that link operations do not work at all in Safari.\n if (globalAllowedDropOperations) {\n allowedOperations &= globalAllowedDropOperations;\n }\n\n // Chrome and Safari on macOS will automatically filter effectAllowed when pressing modifier keys,\n // allowing the user to switch between move, link, and copy operations. Firefox on macOS and all\n // Windows browsers do not do this, so do it ourselves instead. The exact keys are platform dependent.\n // https://ux.stackexchange.com/questions/83748/what-are-the-most-common-modifier-keys-for-dragging-objects-with-a-mouse\n //\n // Note that none of these modifiers are ever set in WebKit due to a bug: https://bugs.webkit.org/show_bug.cgi?id=77465\n // However, Safari does update effectAllowed correctly, so we can just rely on that.\n let allowedModifiers = DROP_OPERATION.none;\n if (isMac()) {\n if (e.altKey) {\n allowedModifiers |= DROP_OPERATION.copy;\n }\n\n // Chrome and Safari both use the Control key for link, even though Finder uses Command + Option.\n // iPadOS doesn't support link operations and will not fire the drop event at all if dropEffect is set to link.\n // https://bugs.webkit.org/show_bug.cgi?id=244701\n if (e.ctrlKey && !isIPad()) {\n allowedModifiers |= DROP_OPERATION.link;\n }\n\n if (e.metaKey) {\n allowedModifiers |= DROP_OPERATION.move;\n }\n } else {\n if (e.altKey) {\n allowedModifiers |= DROP_OPERATION.link;\n }\n\n if (e.shiftKey) {\n allowedModifiers |= DROP_OPERATION.move;\n }\n\n if (e.ctrlKey) {\n allowedModifiers |= DROP_OPERATION.copy;\n }\n }\n\n if (allowedModifiers) {\n return allowedOperations & allowedModifiers;\n }\n\n return allowedOperations;\n}\n\nfunction allowedOperationsToArray(allowedOperationsBits: DROP_OPERATION) {\n let allowedOperations: Array<DropOperation> = [];\n if (allowedOperationsBits & DROP_OPERATION.move) {\n allowedOperations.push('move');\n }\n\n if (allowedOperationsBits & DROP_OPERATION.copy) {\n allowedOperations.push('copy');\n }\n\n if (allowedOperationsBits & DROP_OPERATION.link) {\n allowedOperations.push('link');\n }\n\n return allowedOperations;\n}\n\nfunction getDropOperation(allowedOperations: DROP_OPERATION, operation: DropOperation) {\n let op = DROP_OPERATION[operation];\n return allowedOperations & op ? operation : 'cancel';\n}\n"],"names":[],"version":3,"file":"useDrop.main.js.map"}
package/dist/useDrop.mjs CHANGED
@@ -215,12 +215,7 @@ function $5c06e4929e123553$export$ccdee5eaf73cf661(options) {
215
215
  });
216
216
  }, [
217
217
  isDisabled,
218
- ref,
219
- getDropOperationKeyboard,
220
- onDropEnter,
221
- onDropExit,
222
- onKeyboardDrop,
223
- onDropActivate
218
+ ref
224
219
  ]);
225
220
  let { dropProps: dropProps } = (0, $224594fe3e57ff1e$export$62447ad3d2ec7da6)();
226
221
  if (isDisabled) return {
@@ -215,12 +215,7 @@ function $5c06e4929e123553$export$ccdee5eaf73cf661(options) {
215
215
  });
216
216
  }, [
217
217
  isDisabled,
218
- ref,
219
- getDropOperationKeyboard,
220
- onDropEnter,
221
- onDropExit,
222
- onKeyboardDrop,
223
- onDropActivate
218
+ ref
224
219
  ]);
225
220
  let { dropProps: dropProps } = (0, $224594fe3e57ff1e$export$62447ad3d2ec7da6)();
226
221
  if (isDisabled) return {
@@ -1 +1 @@
1
- {"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAsDD,MAAM,8CAAwB;AAMvB,SAAS,0CAAQ,OAAoB;IAC1C,IAAI,iBAAC,aAAa,cAAE,UAAU,EAAC,GAAG;IAClC,IAAI,CAAC,cAAc,cAAc,GAAG,CAAA,GAAA,eAAO,EAAE;IAC7C,IAAI,QAAQ,CAAA,GAAA,aAAK,EAOd;QACD,GAAG;QACH,GAAG;QACH,kBAAkB,IAAI;QACtB,YAAY;QACZ,mBAAmB,CAAA,GAAA,yCAAa,EAAE,GAAG;QACrC,mBAAmB;IACrB,GAAG,OAAO;IAEV,IAAI,gBAAgB,CAAC;QACnB,cAAc;QAEd,IAAI,OAAO,QAAQ,WAAW,KAAK,YAAY;YAC7C,IAAI,OAAO,AAAC,EAAE,aAAa,CAAiB,qBAAqB;YACjE,QAAQ,WAAW,CAAC;gBAClB,MAAM;gBACN,GAAG,EAAE,OAAO,GAAG,KAAK,CAAC;gBACrB,GAAG,EAAE,OAAO,GAAG,KAAK,CAAC;YACvB;QACF;IACF;IAEA,IAAI,eAAe,CAAC;QAClB,cAAc;QAEd,IAAI,OAAO,QAAQ,UAAU,KAAK,YAAY;YAC5C,IAAI,OAAO,AAAC,EAAE,aAAa,CAAiB,qBAAqB;YACjE,QAAQ,UAAU,CAAC;gBACjB,MAAM;gBACN,GAAG,EAAE,OAAO,GAAG,KAAK,CAAC;gBACrB,GAAG,EAAE,OAAO,GAAG,KAAK,CAAC;YACvB;QACF;IACF;IAEA,IAAI,aAAa,CAAC;QAChB,EAAE,cAAc;QAChB,EAAE,eAAe;QAEjB,IAAI,oBAAoB,2CAAqB;QAC7C,IAAI,EAAE,OAAO,KAAK,MAAM,CAAC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3C,OAAO;QACL,IAAI,EAAE,MAAM,EACV,oBAAoB,CAAA,GAAA,yCAAa,EAAE,IAAI;QAGzC,IAAI,EAAE,QAAQ,EACZ,oBAAoB,CAAA,GAAA,yCAAa,EAAE,IAAI;QAGzC,IAAI,EAAE,OAAO,EACX,oBAAoB,CAAA,GAAA,yCAAa,EAAE,IAAI;IAE3C;IAEA,IAAI,kBACF,OAAO,oBAAoB;IAG7B,OAAO;AACT;AAEA,SAAS,+CAAyB,qBAAqC;IACrE,IAAI,oBAA0C,EAAE;IAChD,IAAI,wBAAwB,CAAA,GAAA,yCAAa,EAAE,IAAI,EAC7C,kBAAkB,IAAI,CAAC;IAGzB,IAAI,wBAAwB,CAAA,GAAA,yCAAa,EAAE,IAAI,EAC7C,kBAAkB,IAAI,CAAC;IAGzB,IAAI,wBAAwB,CAAA,GAAA,yCAAa,EAAE,IAAI,EAC7C,kBAAkB,IAAI,CAAC;IAGzB,OAAO;AACT;AAEA,SAAS,uCAAiB,iBAAiC,EAAE,SAAwB;IACnF,IAAI,KAAK,CAAA,GAAA,yCAAa,CAAC,CAAC,UAAU;IAClC,OAAO,oBAAoB,KAAK,YAAY;AAC9C","sources":["packages/@react-aria/dnd/src/useDrop.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {DOMAttributes, DropActivateEvent, DropEnterEvent, DropEvent, DropExitEvent, DropMoveEvent, DropOperation, FocusableElement, DragTypes as IDragTypes, RefObject} from '@react-types/shared';\nimport {DragEvent, useRef, useState} from 'react';\nimport * as DragManager from './DragManager';\nimport {DragTypes, globalAllowedDropOperations, globalDndState, readFromDataTransfer, setGlobalDnDState, setGlobalDropEffect} from './utils';\nimport {DROP_EFFECT_TO_DROP_OPERATION, DROP_OPERATION, DROP_OPERATION_ALLOWED, DROP_OPERATION_TO_DROP_EFFECT} from './constants';\nimport {isIPad, isMac, useEffectEvent, useLayoutEffect} from '@react-aria/utils';\nimport {useVirtualDrop} from './useVirtualDrop';\n\nexport interface DropOptions {\n /** A ref for the droppable element. */\n ref: RefObject<FocusableElement | null>,\n /**\n * A function returning the drop operation to be performed when items matching the given types are dropped\n * on the drop target.\n */\n getDropOperation?: (types: IDragTypes, allowedOperations: DropOperation[]) => DropOperation,\n /** A function that returns the drop operation for a specific point within the target. */\n getDropOperationForPoint?: (types: IDragTypes, allowedOperations: DropOperation[], x: number, y: number) => DropOperation,\n /** Handler that is called when a valid drag enters the drop target. */\n onDropEnter?: (e: DropEnterEvent) => void,\n /** Handler that is called when a valid drag is moved within the drop target. */\n onDropMove?: (e: DropMoveEvent) => void,\n /**\n * Handler that is called after a valid drag is held over the drop target for a period of time.\n * This typically opens the item so that the user can drop within it.\n */\n onDropActivate?: (e: DropActivateEvent) => void,\n /** Handler that is called when a valid drag exits the drop target. */\n onDropExit?: (e: DropExitEvent) => void,\n /** Handler that is called when a valid drag is dropped on the drop target. */\n onDrop?: (e: DropEvent) => void,\n /**\n * Whether the item has an explicit focusable drop affordance to initiate accessible drag and drop mode.\n * If true, the dropProps will omit these event handlers, and they will be applied to dropButtonProps instead.\n */\n hasDropButton?: boolean,\n /**\n * Whether the drop target is disabled. If true, the drop target will not accept any drops.\n */\n isDisabled?: boolean\n}\n\nexport interface DropResult {\n /** Props for the droppable element. */\n dropProps: DOMAttributes,\n /** Whether the drop target is currently focused or hovered. */\n isDropTarget: boolean,\n /** Props for the explicit drop button affordance, if any. */\n dropButtonProps?: AriaButtonProps\n}\n\nconst DROP_ACTIVATE_TIMEOUT = 800;\n\n/**\n * Handles drop interactions for an element, with support for traditional mouse and touch\n * based drag and drop, in addition to full parity for keyboard and screen reader users.\n */\nexport function useDrop(options: DropOptions): DropResult {\n let {hasDropButton, isDisabled} = options;\n let [isDropTarget, setDropTarget] = useState(false);\n let state = useRef<{\n x: number,\n y: number,\n dragOverElements: Set<Element>,\n dropEffect: DataTransfer['dropEffect'],\n allowedOperations: DROP_OPERATION,\n dropActivateTimer: ReturnType<typeof setTimeout> | undefined\n }>({\n x: 0,\n y: 0,\n dragOverElements: new Set<Element>(),\n dropEffect: 'none',\n allowedOperations: DROP_OPERATION.all,\n dropActivateTimer: undefined\n }).current;\n\n let fireDropEnter = (e: DragEvent) => {\n setDropTarget(true);\n\n if (typeof options.onDropEnter === 'function') {\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n options.onDropEnter({\n type: 'dropenter',\n x: e.clientX - rect.x,\n y: e.clientY - rect.y\n });\n }\n };\n\n let fireDropExit = (e: DragEvent) => {\n setDropTarget(false);\n\n if (typeof options.onDropExit === 'function') {\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n options.onDropExit({\n type: 'dropexit',\n x: e.clientX - rect.x,\n y: e.clientY - rect.y\n });\n }\n };\n\n let onDragOver = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n\n let allowedOperations = getAllowedOperations(e);\n if (e.clientX === state.x && e.clientY === state.y && allowedOperations === state.allowedOperations) {\n e.dataTransfer.dropEffect = state.dropEffect;\n return;\n }\n\n state.x = e.clientX;\n state.y = e.clientY;\n\n let prevDropEffect = state.dropEffect;\n\n // Update drop effect if allowed drop operations changed (e.g. user pressed modifier key).\n if (allowedOperations !== state.allowedOperations) {\n let allowedOps = allowedOperationsToArray(allowedOperations);\n let dropOperation = allowedOps[0];\n if (typeof options.getDropOperation === 'function') {\n let types = new DragTypes(e.dataTransfer);\n dropOperation = getDropOperation(allowedOperations, options.getDropOperation(types, allowedOps));\n }\n state.dropEffect = DROP_OPERATION_TO_DROP_EFFECT[dropOperation] || 'none';\n }\n\n if (typeof options.getDropOperationForPoint === 'function') {\n let types = new DragTypes(e.dataTransfer);\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n let dropOperation = getDropOperation(\n allowedOperations,\n options.getDropOperationForPoint(types, allowedOperationsToArray(allowedOperations), state.x - rect.x, state.y - rect.y)\n );\n state.dropEffect = DROP_OPERATION_TO_DROP_EFFECT[dropOperation] || 'none';\n }\n\n state.allowedOperations = allowedOperations;\n e.dataTransfer.dropEffect = state.dropEffect;\n\n // If the drop operation changes, update state and fire events appropriately.\n if (state.dropEffect === 'none' && prevDropEffect !== 'none') {\n fireDropExit(e);\n } else if (state.dropEffect !== 'none' && prevDropEffect === 'none') {\n fireDropEnter(e);\n }\n\n if (typeof options.onDropMove === 'function' && state.dropEffect !== 'none') {\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n options.onDropMove({\n type: 'dropmove',\n x: state.x - rect.x,\n y: state.y - rect.y\n });\n }\n\n clearTimeout(state.dropActivateTimer);\n\n if (options.onDropActivate && typeof options.onDropActivate === 'function' && state.dropEffect !== 'none') {\n let onDropActivateOptions = options.onDropActivate;\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n state.dropActivateTimer = setTimeout(() => {\n onDropActivateOptions({\n type: 'dropactivate',\n x: state.x - rect.x,\n y: state.y - rect.y\n });\n }, DROP_ACTIVATE_TIMEOUT);\n }\n };\n\n let onDragEnter = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n state.dragOverElements.add(e.target as Element);\n if (state.dragOverElements.size > 1) {\n return;\n }\n\n let allowedOperationsBits = getAllowedOperations(e);\n let allowedOperations = allowedOperationsToArray(allowedOperationsBits);\n let dropOperation = allowedOperations[0];\n\n if (typeof options.getDropOperation === 'function') {\n let types = new DragTypes(e.dataTransfer);\n dropOperation = getDropOperation(allowedOperationsBits, options.getDropOperation(types, allowedOperations));\n }\n\n if (typeof options.getDropOperationForPoint === 'function') {\n let types = new DragTypes(e.dataTransfer);\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n dropOperation = getDropOperation(\n allowedOperationsBits,\n options.getDropOperationForPoint(types, allowedOperations, e.clientX - rect.x, e.clientY - rect.y)\n );\n }\n\n state.x = e.clientX;\n state.y = e.clientY;\n state.allowedOperations = allowedOperationsBits;\n state.dropEffect = DROP_OPERATION_TO_DROP_EFFECT[dropOperation] || 'none';\n e.dataTransfer.dropEffect = state.dropEffect;\n\n if (dropOperation !== 'cancel') {\n fireDropEnter(e);\n }\n };\n\n let onDragLeave = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n\n // We would use e.relatedTarget to detect if the drag is still inside the drop target,\n // but it is always null in WebKit. https://bugs.webkit.org/show_bug.cgi?id=66547\n // Instead, we track all of the targets of dragenter events in a set, and remove them\n // in dragleave. When the set becomes empty, we've left the drop target completely.\n // We must also remove any elements that are no longer in the DOM, because dragleave\n // events will never be fired for these. This can happen, for example, with drop\n // indicators between items, which disappear when the drop target changes.\n\n state.dragOverElements.delete(e.target as Element);\n for (let element of state.dragOverElements) {\n if (!e.currentTarget.contains(element)) {\n state.dragOverElements.delete(element);\n }\n }\n\n if (state.dragOverElements.size > 0) {\n return;\n }\n\n if (state.dropEffect !== 'none') {\n fireDropExit(e);\n }\n\n clearTimeout(state.dropActivateTimer);\n };\n\n let onDrop = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n // Track drop effect in global state for Chrome Android. https://bugs.chromium.org/p/chromium/issues/detail?id=1353951\n // Android onDragEnd always returns \"none\" as its drop effect.\n setGlobalDropEffect(state.dropEffect);\n\n if (typeof options.onDrop === 'function') {\n let dropOperation = DROP_EFFECT_TO_DROP_OPERATION[state.dropEffect];\n let items = readFromDataTransfer(e.dataTransfer);\n\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n let event: DropEvent = {\n type: 'drop',\n x: e.clientX - rect.x,\n y: e.clientY - rect.y,\n items,\n dropOperation\n };\n\n options.onDrop(event);\n }\n\n let dndStateSnapshot = {...globalDndState};\n state.dragOverElements.clear();\n fireDropExit(e);\n clearTimeout(state.dropActivateTimer);\n // If there wasn't a collection being tracked as a dragged collection, then we are in a case where a non RSP drag is dropped on a\n // RSP collection and thus we don't need to preserve the global drop effect\n if (dndStateSnapshot.draggingCollectionRef == null) {\n setGlobalDropEffect(undefined);\n } else {\n // Otherwise we need to preserve the global dnd state for onDragEnd's isInternal check.\n // At the moment fireDropExit may clear dropCollectionRef (i.e. useDroppableCollection's provided onDropExit, required to clear dropCollectionRef when exiting a valid drop target)\n setGlobalDnDState(dndStateSnapshot);\n }\n };\n\n let onDropEnter = useEffectEvent((e: DropEnterEvent) => {\n if (typeof options.onDropEnter === 'function') {\n options.onDropEnter(e);\n }\n });\n\n let onDropExit = useEffectEvent((e: DropExitEvent) => {\n if (typeof options.onDropExit === 'function') {\n options.onDropExit(e);\n }\n });\n\n let onDropActivate = useEffectEvent((e: DropActivateEvent) => {\n if (typeof options.onDropActivate === 'function') {\n options.onDropActivate(e);\n }\n });\n\n let onKeyboardDrop = useEffectEvent((e: DropEvent) => {\n if (typeof options.onDrop === 'function') {\n options.onDrop(e);\n }\n });\n\n let getDropOperationKeyboard = useEffectEvent((types: IDragTypes, allowedOperations: DropOperation[]) => {\n if (options.getDropOperation) {\n return options.getDropOperation(types, allowedOperations);\n }\n\n return allowedOperations[0];\n });\n\n let {ref} = options;\n useLayoutEffect(() => {\n if (isDisabled || !ref.current) {\n return;\n }\n return DragManager.registerDropTarget({\n element: ref.current,\n getDropOperation: getDropOperationKeyboard,\n onDropEnter(e) {\n setDropTarget(true);\n onDropEnter(e);\n },\n onDropExit(e) {\n setDropTarget(false);\n onDropExit(e);\n },\n onDrop: onKeyboardDrop,\n onDropActivate\n });\n }, [isDisabled, ref, getDropOperationKeyboard, onDropEnter, onDropExit, onKeyboardDrop, onDropActivate]);\n\n let {dropProps} = useVirtualDrop();\n if (isDisabled) {\n return {\n dropProps: {},\n dropButtonProps: {isDisabled: true},\n isDropTarget: false\n };\n }\n return {\n dropProps: {\n ...(!hasDropButton && dropProps),\n onDragEnter,\n onDragOver,\n onDragLeave,\n onDrop\n },\n dropButtonProps: {...(hasDropButton && dropProps)},\n isDropTarget\n };\n}\n\nfunction getAllowedOperations(e: DragEvent) {\n let allowedOperations = DROP_OPERATION_ALLOWED[e.dataTransfer.effectAllowed];\n\n // WebKit always sets effectAllowed to \"copyMove\" on macOS, and \"all\" on iOS, regardless of what was\n // set during the dragstart event: https://bugs.webkit.org/show_bug.cgi?id=178058\n //\n // Android Chrome also sets effectAllowed to \"copyMove\" in all cases: https://bugs.chromium.org/p/chromium/issues/detail?id=1359182\n //\n // If the drag started within the page, we can use a global variable to get the real allowed operations.\n // This needs to be intersected with the actual effectAllowed, which may have been filtered based on modifier keys.\n // Unfortunately, this means that link operations do not work at all in Safari.\n if (globalAllowedDropOperations) {\n allowedOperations &= globalAllowedDropOperations;\n }\n\n // Chrome and Safari on macOS will automatically filter effectAllowed when pressing modifier keys,\n // allowing the user to switch between move, link, and copy operations. Firefox on macOS and all\n // Windows browsers do not do this, so do it ourselves instead. The exact keys are platform dependent.\n // https://ux.stackexchange.com/questions/83748/what-are-the-most-common-modifier-keys-for-dragging-objects-with-a-mouse\n //\n // Note that none of these modifiers are ever set in WebKit due to a bug: https://bugs.webkit.org/show_bug.cgi?id=77465\n // However, Safari does update effectAllowed correctly, so we can just rely on that.\n let allowedModifiers = DROP_OPERATION.none;\n if (isMac()) {\n if (e.altKey) {\n allowedModifiers |= DROP_OPERATION.copy;\n }\n\n // Chrome and Safari both use the Control key for link, even though Finder uses Command + Option.\n // iPadOS doesn't support link operations and will not fire the drop event at all if dropEffect is set to link.\n // https://bugs.webkit.org/show_bug.cgi?id=244701\n if (e.ctrlKey && !isIPad()) {\n allowedModifiers |= DROP_OPERATION.link;\n }\n\n if (e.metaKey) {\n allowedModifiers |= DROP_OPERATION.move;\n }\n } else {\n if (e.altKey) {\n allowedModifiers |= DROP_OPERATION.link;\n }\n\n if (e.shiftKey) {\n allowedModifiers |= DROP_OPERATION.move;\n }\n\n if (e.ctrlKey) {\n allowedModifiers |= DROP_OPERATION.copy;\n }\n }\n\n if (allowedModifiers) {\n return allowedOperations & allowedModifiers;\n }\n\n return allowedOperations;\n}\n\nfunction allowedOperationsToArray(allowedOperationsBits: DROP_OPERATION) {\n let allowedOperations: Array<DropOperation> = [];\n if (allowedOperationsBits & DROP_OPERATION.move) {\n allowedOperations.push('move');\n }\n\n if (allowedOperationsBits & DROP_OPERATION.copy) {\n allowedOperations.push('copy');\n }\n\n if (allowedOperationsBits & DROP_OPERATION.link) {\n allowedOperations.push('link');\n }\n\n return allowedOperations;\n}\n\nfunction getDropOperation(allowedOperations: DROP_OPERATION, operation: DropOperation) {\n let op = DROP_OPERATION[operation];\n return allowedOperations & op ? operation : 'cancel';\n}\n"],"names":[],"version":3,"file":"useDrop.module.js.map"}
1
+ {"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAsDD,MAAM,8CAAwB;AAMvB,SAAS,0CAAQ,OAAoB;IAC1C,IAAI,iBAAC,aAAa,cAAE,UAAU,EAAC,GAAG;IAClC,IAAI,CAAC,cAAc,cAAc,GAAG,CAAA,GAAA,eAAO,EAAE;IAC7C,IAAI,QAAQ,CAAA,GAAA,aAAK,EAOd;QACD,GAAG;QACH,GAAG;QACH,kBAAkB,IAAI;QACtB,YAAY;QACZ,mBAAmB,CAAA,GAAA,yCAAa,EAAE,GAAG;QACrC,mBAAmB;IACrB,GAAG,OAAO;IAEV,IAAI,gBAAgB,CAAC;QACnB,cAAc;QAEd,IAAI,OAAO,QAAQ,WAAW,KAAK,YAAY;YAC7C,IAAI,OAAO,AAAC,EAAE,aAAa,CAAiB,qBAAqB;YACjE,QAAQ,WAAW,CAAC;gBAClB,MAAM;gBACN,GAAG,EAAE,OAAO,GAAG,KAAK,CAAC;gBACrB,GAAG,EAAE,OAAO,GAAG,KAAK,CAAC;YACvB;QACF;IACF;IAEA,IAAI,eAAe,CAAC;QA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A,yCAAa,EAAE,IAAI;IAC1C,IAAI,CAAA,GAAA,YAAI,KAAK;QACX,IAAI,EAAE,MAAM,EACV,oBAAoB,CAAA,GAAA,yCAAa,EAAE,IAAI;QAGzC,iGAAiG;QACjG,+GAA+G;QAC/G,iDAAiD;QACjD,IAAI,EAAE,OAAO,IAAI,CAAC,CAAA,GAAA,aAAK,KACrB,oBAAoB,CAAA,GAAA,yCAAa,EAAE,IAAI;QAGzC,IAAI,EAAE,OAAO,EACX,oBAAoB,CAAA,GAAA,yCAAa,EAAE,IAAI;IAE3C,OAAO;QACL,IAAI,EAAE,MAAM,EACV,oBAAoB,CAAA,GAAA,yCAAa,EAAE,IAAI;QAGzC,IAAI,EAAE,QAAQ,EACZ,oBAAoB,CAAA,GAAA,yCAAa,EAAE,IAAI;QAGzC,IAAI,EAAE,OAAO,EACX,oBAAoB,CAAA,GAAA,yCAAa,EAAE,IAAI;IAE3C;IAEA,IAAI,kBACF,OAAO,oBAAoB;IAG7B,OAAO;AACT;AAEA,SAAS,+CAAyB,qBAAqC;IACrE,IAAI,oBAA0C,EAAE;IAChD,IAAI,wBAAwB,CAAA,GAAA,yCAAa,EAAE,IAAI,EAC7C,kBAAkB,IAAI,CAAC;IAGzB,IAAI,wBAAwB,CAAA,GAAA,yCAAa,EAAE,IAAI,EAC7C,kBAAkB,IAAI,CAAC;IAGzB,IAAI,wBAAwB,CAAA,GAAA,yCAAa,EAAE,IAAI,EAC7C,kBAAkB,IAAI,CAAC;IAGzB,OAAO;AACT;AAEA,SAAS,uCAAiB,iBAAiC,EAAE,SAAwB;IACnF,IAAI,KAAK,CAAA,GAAA,yCAAa,CAAC,CAAC,UAAU;IAClC,OAAO,oBAAoB,KAAK,YAAY;AAC9C","sources":["packages/@react-aria/dnd/src/useDrop.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {DOMAttributes, DropActivateEvent, DropEnterEvent, DropEvent, DropExitEvent, DropMoveEvent, DropOperation, FocusableElement, DragTypes as IDragTypes, RefObject} from '@react-types/shared';\nimport {DragEvent, useRef, useState} from 'react';\nimport * as DragManager from './DragManager';\nimport {DragTypes, globalAllowedDropOperations, globalDndState, readFromDataTransfer, setGlobalDnDState, setGlobalDropEffect} from './utils';\nimport {DROP_EFFECT_TO_DROP_OPERATION, DROP_OPERATION, DROP_OPERATION_ALLOWED, DROP_OPERATION_TO_DROP_EFFECT} from './constants';\nimport {isIPad, isMac, useEffectEvent, useLayoutEffect} from '@react-aria/utils';\nimport {useVirtualDrop} from './useVirtualDrop';\n\nexport interface DropOptions {\n /** A ref for the droppable element. */\n ref: RefObject<FocusableElement | null>,\n /**\n * A function returning the drop operation to be performed when items matching the given types are dropped\n * on the drop target.\n */\n getDropOperation?: (types: IDragTypes, allowedOperations: DropOperation[]) => DropOperation,\n /** A function that returns the drop operation for a specific point within the target. */\n getDropOperationForPoint?: (types: IDragTypes, allowedOperations: DropOperation[], x: number, y: number) => DropOperation,\n /** Handler that is called when a valid drag enters the drop target. */\n onDropEnter?: (e: DropEnterEvent) => void,\n /** Handler that is called when a valid drag is moved within the drop target. */\n onDropMove?: (e: DropMoveEvent) => void,\n /**\n * Handler that is called after a valid drag is held over the drop target for a period of time.\n * This typically opens the item so that the user can drop within it.\n */\n onDropActivate?: (e: DropActivateEvent) => void,\n /** Handler that is called when a valid drag exits the drop target. */\n onDropExit?: (e: DropExitEvent) => void,\n /** Handler that is called when a valid drag is dropped on the drop target. */\n onDrop?: (e: DropEvent) => void,\n /**\n * Whether the item has an explicit focusable drop affordance to initiate accessible drag and drop mode.\n * If true, the dropProps will omit these event handlers, and they will be applied to dropButtonProps instead.\n */\n hasDropButton?: boolean,\n /**\n * Whether the drop target is disabled. If true, the drop target will not accept any drops.\n */\n isDisabled?: boolean\n}\n\nexport interface DropResult {\n /** Props for the droppable element. */\n dropProps: DOMAttributes,\n /** Whether the drop target is currently focused or hovered. */\n isDropTarget: boolean,\n /** Props for the explicit drop button affordance, if any. */\n dropButtonProps?: AriaButtonProps\n}\n\nconst DROP_ACTIVATE_TIMEOUT = 800;\n\n/**\n * Handles drop interactions for an element, with support for traditional mouse and touch\n * based drag and drop, in addition to full parity for keyboard and screen reader users.\n */\nexport function useDrop(options: DropOptions): DropResult {\n let {hasDropButton, isDisabled} = options;\n let [isDropTarget, setDropTarget] = useState(false);\n let state = useRef<{\n x: number,\n y: number,\n dragOverElements: Set<Element>,\n dropEffect: DataTransfer['dropEffect'],\n allowedOperations: DROP_OPERATION,\n dropActivateTimer: ReturnType<typeof setTimeout> | undefined\n }>({\n x: 0,\n y: 0,\n dragOverElements: new Set<Element>(),\n dropEffect: 'none',\n allowedOperations: DROP_OPERATION.all,\n dropActivateTimer: undefined\n }).current;\n\n let fireDropEnter = (e: DragEvent) => {\n setDropTarget(true);\n\n if (typeof options.onDropEnter === 'function') {\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n options.onDropEnter({\n type: 'dropenter',\n x: e.clientX - rect.x,\n y: e.clientY - rect.y\n });\n }\n };\n\n let fireDropExit = (e: DragEvent) => {\n setDropTarget(false);\n\n if (typeof options.onDropExit === 'function') {\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n options.onDropExit({\n type: 'dropexit',\n x: e.clientX - rect.x,\n y: e.clientY - rect.y\n });\n }\n };\n\n let onDragOver = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n\n let allowedOperations = getAllowedOperations(e);\n if (e.clientX === state.x && e.clientY === state.y && allowedOperations === state.allowedOperations) {\n e.dataTransfer.dropEffect = state.dropEffect;\n return;\n }\n\n state.x = e.clientX;\n state.y = e.clientY;\n\n let prevDropEffect = state.dropEffect;\n\n // Update drop effect if allowed drop operations changed (e.g. user pressed modifier key).\n if (allowedOperations !== state.allowedOperations) {\n let allowedOps = allowedOperationsToArray(allowedOperations);\n let dropOperation = allowedOps[0];\n if (typeof options.getDropOperation === 'function') {\n let types = new DragTypes(e.dataTransfer);\n dropOperation = getDropOperation(allowedOperations, options.getDropOperation(types, allowedOps));\n }\n state.dropEffect = DROP_OPERATION_TO_DROP_EFFECT[dropOperation] || 'none';\n }\n\n if (typeof options.getDropOperationForPoint === 'function') {\n let types = new DragTypes(e.dataTransfer);\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n let dropOperation = getDropOperation(\n allowedOperations,\n options.getDropOperationForPoint(types, allowedOperationsToArray(allowedOperations), state.x - rect.x, state.y - rect.y)\n );\n state.dropEffect = DROP_OPERATION_TO_DROP_EFFECT[dropOperation] || 'none';\n }\n\n state.allowedOperations = allowedOperations;\n e.dataTransfer.dropEffect = state.dropEffect;\n\n // If the drop operation changes, update state and fire events appropriately.\n if (state.dropEffect === 'none' && prevDropEffect !== 'none') {\n fireDropExit(e);\n } else if (state.dropEffect !== 'none' && prevDropEffect === 'none') {\n fireDropEnter(e);\n }\n\n if (typeof options.onDropMove === 'function' && state.dropEffect !== 'none') {\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n options.onDropMove({\n type: 'dropmove',\n x: state.x - rect.x,\n y: state.y - rect.y\n });\n }\n\n clearTimeout(state.dropActivateTimer);\n\n if (options.onDropActivate && typeof options.onDropActivate === 'function' && state.dropEffect !== 'none') {\n let onDropActivateOptions = options.onDropActivate;\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n state.dropActivateTimer = setTimeout(() => {\n onDropActivateOptions({\n type: 'dropactivate',\n x: state.x - rect.x,\n y: state.y - rect.y\n });\n }, DROP_ACTIVATE_TIMEOUT);\n }\n };\n\n let onDragEnter = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n state.dragOverElements.add(e.target as Element);\n if (state.dragOverElements.size > 1) {\n return;\n }\n\n let allowedOperationsBits = getAllowedOperations(e);\n let allowedOperations = allowedOperationsToArray(allowedOperationsBits);\n let dropOperation = allowedOperations[0];\n\n if (typeof options.getDropOperation === 'function') {\n let types = new DragTypes(e.dataTransfer);\n dropOperation = getDropOperation(allowedOperationsBits, options.getDropOperation(types, allowedOperations));\n }\n\n if (typeof options.getDropOperationForPoint === 'function') {\n let types = new DragTypes(e.dataTransfer);\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n dropOperation = getDropOperation(\n allowedOperationsBits,\n options.getDropOperationForPoint(types, allowedOperations, e.clientX - rect.x, e.clientY - rect.y)\n );\n }\n\n state.x = e.clientX;\n state.y = e.clientY;\n state.allowedOperations = allowedOperationsBits;\n state.dropEffect = DROP_OPERATION_TO_DROP_EFFECT[dropOperation] || 'none';\n e.dataTransfer.dropEffect = state.dropEffect;\n\n if (dropOperation !== 'cancel') {\n fireDropEnter(e);\n }\n };\n\n let onDragLeave = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n\n // We would use e.relatedTarget to detect if the drag is still inside the drop target,\n // but it is always null in WebKit. https://bugs.webkit.org/show_bug.cgi?id=66547\n // Instead, we track all of the targets of dragenter events in a set, and remove them\n // in dragleave. When the set becomes empty, we've left the drop target completely.\n // We must also remove any elements that are no longer in the DOM, because dragleave\n // events will never be fired for these. This can happen, for example, with drop\n // indicators between items, which disappear when the drop target changes.\n\n state.dragOverElements.delete(e.target as Element);\n for (let element of state.dragOverElements) {\n if (!e.currentTarget.contains(element)) {\n state.dragOverElements.delete(element);\n }\n }\n\n if (state.dragOverElements.size > 0) {\n return;\n }\n\n if (state.dropEffect !== 'none') {\n fireDropExit(e);\n }\n\n clearTimeout(state.dropActivateTimer);\n };\n\n let onDrop = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n // Track drop effect in global state for Chrome Android. https://bugs.chromium.org/p/chromium/issues/detail?id=1353951\n // Android onDragEnd always returns \"none\" as its drop effect.\n setGlobalDropEffect(state.dropEffect);\n\n if (typeof options.onDrop === 'function') {\n let dropOperation = DROP_EFFECT_TO_DROP_OPERATION[state.dropEffect];\n let items = readFromDataTransfer(e.dataTransfer);\n\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n let event: DropEvent = {\n type: 'drop',\n x: e.clientX - rect.x,\n y: e.clientY - rect.y,\n items,\n dropOperation\n };\n\n options.onDrop(event);\n }\n\n let dndStateSnapshot = {...globalDndState};\n state.dragOverElements.clear();\n fireDropExit(e);\n clearTimeout(state.dropActivateTimer);\n // If there wasn't a collection being tracked as a dragged collection, then we are in a case where a non RSP drag is dropped on a\n // RSP collection and thus we don't need to preserve the global drop effect\n if (dndStateSnapshot.draggingCollectionRef == null) {\n setGlobalDropEffect(undefined);\n } else {\n // Otherwise we need to preserve the global dnd state for onDragEnd's isInternal check.\n // At the moment fireDropExit may clear dropCollectionRef (i.e. useDroppableCollection's provided onDropExit, required to clear dropCollectionRef when exiting a valid drop target)\n setGlobalDnDState(dndStateSnapshot);\n }\n };\n\n let onDropEnter = useEffectEvent((e: DropEnterEvent) => {\n if (typeof options.onDropEnter === 'function') {\n options.onDropEnter(e);\n }\n });\n\n let onDropExit = useEffectEvent((e: DropExitEvent) => {\n if (typeof options.onDropExit === 'function') {\n options.onDropExit(e);\n }\n });\n\n let onDropActivate = useEffectEvent((e: DropActivateEvent) => {\n if (typeof options.onDropActivate === 'function') {\n options.onDropActivate(e);\n }\n });\n\n let onKeyboardDrop = useEffectEvent((e: DropEvent) => {\n if (typeof options.onDrop === 'function') {\n options.onDrop(e);\n }\n });\n\n let getDropOperationKeyboard = useEffectEvent((types: IDragTypes, allowedOperations: DropOperation[]) => {\n if (options.getDropOperation) {\n return options.getDropOperation(types, allowedOperations);\n }\n\n return allowedOperations[0];\n });\n\n let {ref} = options;\n useLayoutEffect(() => {\n if (isDisabled || !ref.current) {\n return;\n }\n return DragManager.registerDropTarget({\n element: ref.current,\n getDropOperation: getDropOperationKeyboard,\n onDropEnter(e) {\n setDropTarget(true);\n onDropEnter(e);\n },\n onDropExit(e) {\n setDropTarget(false);\n onDropExit(e);\n },\n onDrop: onKeyboardDrop,\n onDropActivate\n });\n }, [isDisabled, ref]);\n\n let {dropProps} = useVirtualDrop();\n if (isDisabled) {\n return {\n dropProps: {},\n dropButtonProps: {isDisabled: true},\n isDropTarget: false\n };\n }\n return {\n dropProps: {\n ...(!hasDropButton && dropProps),\n onDragEnter,\n onDragOver,\n onDragLeave,\n onDrop\n },\n dropButtonProps: {...(hasDropButton && dropProps)},\n isDropTarget\n };\n}\n\nfunction getAllowedOperations(e: DragEvent) {\n let allowedOperations = DROP_OPERATION_ALLOWED[e.dataTransfer.effectAllowed];\n\n // WebKit always sets effectAllowed to \"copyMove\" on macOS, and \"all\" on iOS, regardless of what was\n // set during the dragstart event: https://bugs.webkit.org/show_bug.cgi?id=178058\n //\n // Android Chrome also sets effectAllowed to \"copyMove\" in all cases: https://bugs.chromium.org/p/chromium/issues/detail?id=1359182\n //\n // If the drag started within the page, we can use a global variable to get the real allowed operations.\n // This needs to be intersected with the actual effectAllowed, which may have been filtered based on modifier keys.\n // Unfortunately, this means that link operations do not work at all in Safari.\n if (globalAllowedDropOperations) {\n allowedOperations &= globalAllowedDropOperations;\n }\n\n // Chrome and Safari on macOS will automatically filter effectAllowed when pressing modifier keys,\n // allowing the user to switch between move, link, and copy operations. Firefox on macOS and all\n // Windows browsers do not do this, so do it ourselves instead. The exact keys are platform dependent.\n // https://ux.stackexchange.com/questions/83748/what-are-the-most-common-modifier-keys-for-dragging-objects-with-a-mouse\n //\n // Note that none of these modifiers are ever set in WebKit due to a bug: https://bugs.webkit.org/show_bug.cgi?id=77465\n // However, Safari does update effectAllowed correctly, so we can just rely on that.\n let allowedModifiers = DROP_OPERATION.none;\n if (isMac()) {\n if (e.altKey) {\n allowedModifiers |= DROP_OPERATION.copy;\n }\n\n // Chrome and Safari both use the Control key for link, even though Finder uses Command + Option.\n // iPadOS doesn't support link operations and will not fire the drop event at all if dropEffect is set to link.\n // https://bugs.webkit.org/show_bug.cgi?id=244701\n if (e.ctrlKey && !isIPad()) {\n allowedModifiers |= DROP_OPERATION.link;\n }\n\n if (e.metaKey) {\n allowedModifiers |= DROP_OPERATION.move;\n }\n } else {\n if (e.altKey) {\n allowedModifiers |= DROP_OPERATION.link;\n }\n\n if (e.shiftKey) {\n allowedModifiers |= DROP_OPERATION.move;\n }\n\n if (e.ctrlKey) {\n allowedModifiers |= DROP_OPERATION.copy;\n }\n }\n\n if (allowedModifiers) {\n return allowedOperations & allowedModifiers;\n }\n\n return allowedOperations;\n}\n\nfunction allowedOperationsToArray(allowedOperationsBits: DROP_OPERATION) {\n let allowedOperations: Array<DropOperation> = [];\n if (allowedOperationsBits & DROP_OPERATION.move) {\n allowedOperations.push('move');\n }\n\n if (allowedOperationsBits & DROP_OPERATION.copy) {\n allowedOperations.push('copy');\n }\n\n if (allowedOperationsBits & DROP_OPERATION.link) {\n allowedOperations.push('link');\n }\n\n return allowedOperations;\n}\n\nfunction getDropOperation(allowedOperations: DROP_OPERATION, operation: DropOperation) {\n let op = DROP_OPERATION[operation];\n return allowedOperations & op ? operation : 'cancel';\n}\n"],"names":[],"version":3,"file":"useDrop.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/dnd",
3
- "version": "3.11.2",
3
+ "version": "3.11.4",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -27,15 +27,15 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@internationalized/string": "^3.2.7",
30
- "@react-aria/i18n": "^3.12.12",
31
- "@react-aria/interactions": "^3.25.5",
30
+ "@react-aria/i18n": "^3.12.14",
31
+ "@react-aria/interactions": "^3.26.0",
32
32
  "@react-aria/live-announcer": "^3.4.4",
33
- "@react-aria/overlays": "^3.29.1",
34
- "@react-aria/utils": "^3.30.1",
35
- "@react-stately/collections": "^3.12.7",
36
- "@react-stately/dnd": "^3.7.0",
37
- "@react-types/button": "^3.14.0",
38
- "@react-types/shared": "^3.32.0",
33
+ "@react-aria/overlays": "^3.31.0",
34
+ "@react-aria/utils": "^3.32.0",
35
+ "@react-stately/collections": "^3.12.8",
36
+ "@react-stately/dnd": "^3.7.2",
37
+ "@react-types/button": "^3.14.1",
38
+ "@react-types/shared": "^3.32.1",
39
39
  "@swc/helpers": "^0.5.0"
40
40
  },
41
41
  "peerDependencies": {
@@ -45,5 +45,5 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
- "gitHead": "ed4815e15c9d1659208fa687e8c3a094879854bb"
48
+ "gitHead": "4d838da5bfe36abb35aed166995a9ef63825370f"
49
49
  }
@@ -74,7 +74,7 @@ React.forwardRef(function DragPreview(props: DragPreviewProps, ref: ForwardedRef
74
74
  }
75
75
 
76
76
  return (
77
- <div style={{zIndex: -100, position: 'absolute', top: 0, left: -100000}} ref={domRef}>
77
+ <div style={{zIndex: -100, position: 'fixed', top: 0, left: -100000}} ref={domRef}>
78
78
  {children}
79
79
  </div>
80
80
  );
@@ -100,19 +100,25 @@ function nextDropTarget(
100
100
  }
101
101
  case 'after': {
102
102
  // If this is the last sibling in a level, traverse to the parent.
103
- let targetNode = collection.getItem(target.key);
104
- if (targetNode && targetNode.nextKey == null && targetNode.parentKey != null) {
103
+ let targetNode = collection.getItem(target.key);
104
+ let nextItemInSameLevel = targetNode?.nextKey != null ? collection.getItem(targetNode.nextKey) : null;
105
+ while (nextItemInSameLevel != null && nextItemInSameLevel.type !== 'item') {
106
+ nextItemInSameLevel = nextItemInSameLevel.nextKey != null ? collection.getItem(nextItemInSameLevel.nextKey) : null;
107
+ }
108
+
109
+ if (targetNode && nextItemInSameLevel == null && targetNode.parentKey != null) {
105
110
  // If the parent item has an item after it, use the "before" position.
106
111
  let parentNode = collection.getItem(targetNode.parentKey);
107
- if (parentNode?.nextKey != null) {
112
+ const nextNode = parentNode?.nextKey != null ? collection.getItem(parentNode.nextKey) : null;
113
+ if (nextNode?.type === 'item') {
108
114
  return {
109
115
  type: 'item',
110
- key: parentNode.nextKey,
116
+ key: nextNode.key,
111
117
  dropPosition: 'before'
112
118
  };
113
119
  }
114
120
 
115
- if (parentNode) {
121
+ if (parentNode?.type === 'item') {
116
122
  return {
117
123
  type: 'item',
118
124
  key: parentNode.key,
@@ -121,10 +127,10 @@ function nextDropTarget(
121
127
  }
122
128
  }
123
129
 
124
- if (targetNode?.nextKey != null) {
130
+ if (nextItemInSameLevel) {
125
131
  return {
126
132
  type: 'item',
127
- key: targetNode.nextKey,
133
+ key: nextItemInSameLevel.key,
128
134
  dropPosition: 'on'
129
135
  };
130
136
  }
@@ -154,8 +160,11 @@ function previousDropTarget(
154
160
  let prevKey: Key | null = null;
155
161
  let lastKey = keyboardDelegate.getLastKey?.();
156
162
  while (lastKey != null) {
157
- prevKey = lastKey;
158
163
  let node = collection.getItem(lastKey);
164
+ if (node?.type !== 'item') {
165
+ break;
166
+ }
167
+ prevKey = lastKey;
159
168
  lastKey = node?.parentKey;
160
169
  }
161
170
 
@@ -143,7 +143,7 @@ export function useClipboard(options: ClipboardProps): ClipboardResult {
143
143
  addGlobalEventListener('beforepaste', onBeforePaste),
144
144
  addGlobalEventListener('paste', onPaste)
145
145
  );
146
- }, [isDisabled, onBeforeCopy, onCopy, onBeforeCut, onCut, onBeforePaste, onPaste]);
146
+ }, [isDisabled]);
147
147
 
148
148
  return {
149
149
  clipboardProps: focusProps
package/src/useDrop.ts CHANGED
@@ -339,7 +339,7 @@ export function useDrop(options: DropOptions): DropResult {
339
339
  onDrop: onKeyboardDrop,
340
340
  onDropActivate
341
341
  });
342
- }, [isDisabled, ref, getDropOperationKeyboard, onDropEnter, onDropExit, onKeyboardDrop, onDropActivate]);
342
+ }, [isDisabled, ref]);
343
343
 
344
344
  let {dropProps} = useVirtualDrop();
345
345
  if (isDisabled) {