Icard/angular-clarity-master(work.../node_modules/ngx-drag-drop/fesm2022/ngx-drag-drop.mjs.map

1 line
50 KiB
Plaintext
Raw Normal View History

2024-07-16 14:55:36 +00:00
{"version":3,"file":"ngx-drag-drop.mjs","sources":["../../../projects/dnd/src/lib/dnd-utils.ts","../../../projects/dnd/src/lib/dnd-state.ts","../../../projects/dnd/src/lib/dnd-draggable.directive.ts","../../../projects/dnd/src/lib/dnd-dropzone.directive.ts","../../../projects/dnd/src/lib/dnd-handle.directive.ts","../../../projects/dnd/src/lib/dnd.module.ts","../../../projects/dnd/src/public-api.ts","../../../projects/dnd/src/ngx-drag-drop.ts"],"sourcesContent":["import { DropEffect, EffectAllowed } from './dnd-types';\n\nexport interface DragDropData {\n data?: any;\n type?: string;\n}\n\nexport interface DndEvent extends DragEvent {\n _dndUsingHandle?: boolean;\n _dndDropzoneActive?: true;\n}\n\nexport type DndDragImageOffsetFunction = (\n event: DragEvent,\n dragImage: Element\n) => { x: number; y: number };\n\nexport const DROP_EFFECTS = ['move', 'copy', 'link'] as DropEffect[];\n\nexport const CUSTOM_MIME_TYPE = 'application/x-dnd';\nexport const JSON_MIME_TYPE = 'application/json';\nexport const MSIE_MIME_TYPE = 'Text';\n\nfunction mimeTypeIsCustom(mimeType: string) {\n return mimeType.substr(0, CUSTOM_MIME_TYPE.length) === CUSTOM_MIME_TYPE;\n}\n\nexport function getWellKnownMimeType(event: DragEvent): string | null {\n if (event.dataTransfer) {\n const types = event.dataTransfer.types;\n\n // IE 9 workaround.\n if (!types) {\n return MSIE_MIME_TYPE;\n }\n\n for (let i = 0; i < types.length; i++) {\n if (\n types[i] === MSIE_MIME_TYPE ||\n types[i] === JSON_MIME_TYPE ||\n mimeTypeIsCustom(types[i])\n ) {\n return types[i];\n }\n }\n }\n\n return null;\n}\n\nexport function setDragData(\n event: DragEvent,\n data: DragDropData,\n effectAllowed: EffectAllowed\n): void {\n // Internet Explorer and Microsoft Edge don't support custom mime types, see design doc:\n // https://github.com/marceljuenemann/angular-drag-and-drop-lists/wiki/Data-Transfer-Design\n const mimeType = CUSTOM_MIME_TYPE + (data.type ? '-' + data.type : '');\n\n const dataString = JSON.stringify(data);\n\n try {\n event.dataTransfer?.setData(mimeType, dataString);\n } catch (e) {\n // Setting a custom MIME type did not work, we are probably in IE or Edge.\n try {\n event.dataTransfer?.setData(JSON_MIME_TYPE, dataString);\n } catch (e) {\n // We are in Internet Explorer and can only use the Text MIME type. Also note that IE\n // does not allow changing the cursor in the dragover event, therefore we have to choose\n // the one we want to display now by setting effectAllowed.\n const effectsAllowed = filterEffects(DROP_EFFECTS, effectAllowed);\n if (event.dataTransfer) {\n event.dataTransfer.effectAllowed = effectsAllowed[0];\n }\n\n event.dataTransfer?.setData(MSIE_MIME_TYPE, dataString);\n }\n }\n}\n\nexport function getDropData(\n event: DragEvent,\n dragIsExternal: boolean\n): DragDropData {\n // check if the mime type is well known\n const mimeType = getWellKnownMimeType(event);\n\n // drag did not originate from [dndDraggable]\n if (dragIsExternal === true) {\n if (mimeType !== null && mimeTypeIsCustom(mimeType)) {\n // the type of content is well known and safe to handle\n return JSON.parse(event.dataTransfer?.getData(mimeType) ?? '{}');\n }\n\n // the contained data is unknown, let user handle it\n return {};\n }\n\n if (mimeType !== null) {\n // the type of content is well known and safe to handle\n return JSON.parse(event.dataTransfer?.getData(mimeType) ?? '{}');\n }\n\n // the contained data is unknown, let user handle it\n return {};\n}\n\nexport function filterEffects(\n effects: DropEffect[],\n allowed: EffectAllowed | DropEffect\n): DropEffect[] {\n if (allowed === 'all' || allowed === 'uninitialized') {\n return effects;\n }\n\n return effects.filter(function (effect) {\n return allowed.toLowerCase().indexOf(effect) !== -1;\n });\n}\n\nexport function getDirectChildElement(\n parentElement: Element,\n childElement: Element\n): Elemen