{"version":3,"file":"moveable.cjs.js","sources":["../src/InnerMoveable.tsx","../src/consts.ts","../src/MoveableManager.tsx","../src/Moveable.tsx","../src/utils.ts","../src/index.umd.ts"],"sourcesContent":["import * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport Moveable, { MoveableProps } from \"react-moveable\";\nimport { ref } from \"framework-utils\";\n\nexport default class InnerMoveable extends React.Component {\n public state: any = {};\n public moveable!: Moveable;\n constructor(props: any) {\n super(props);\n this.state = this.props;\n }\n public render() {\n return createPortal(, this.state.parentElement);\n }\n}\n","import { MOVEABLE_PROPS_MAP } from \"react-compat-moveable\";\nimport { MOVEABLE_PROPS, MOVEABLE_METHODS, MOVEABLE_EVENTS } from \"react-moveable\";\n\nexport const PROPERTIES: string[] = MOVEABLE_PROPS;\nexport const METHODS: string[] = MOVEABLE_METHODS;\nexport const EVENTS: string[] = MOVEABLE_EVENTS;\nexport const PROPS_MAP: Record = MOVEABLE_PROPS_MAP;\n","import { ref, Properties } from \"framework-utils\";\nimport * as React from \"react\";\nimport { render } from \"react-dom\";\nimport InnerMoveable from \"./InnerMoveable\";\nimport {\n MoveableInterface,\n MoveableOptions, MoveableProperties,\n} from \"react-moveable/types\";\nimport { camelize, isArray } from \"@daybrush/utils\";\nimport { MoveableEventsParameters } from \"./types\";\nimport { PROPERTIES, EVENTS, METHODS } from \"./consts\";\nimport EventEmitter from \"@scena/event-emitter\";\n/**\n * Moveable is Draggable! Resizable! Scalable! Rotatable!\n * @sort 1\n * @alias Moveable\n * @extends EventEmitter\n */\n@Properties(METHODS, (prototype, property) => {\n if (prototype[property]) {\n return;\n }\n prototype[property] = function(...args: any[]) {\n const self = this.getMoveable();\n\n if (!self || !self[property]) {\n return;\n }\n return self[property](...args);\n };\n})\n@Properties(PROPERTIES, (prototype, property) => {\n Object.defineProperty(prototype, property, {\n get() {\n return this.getMoveable().props[property];\n },\n set(value) {\n this.setState({\n [property]: value,\n });\n },\n enumerable: true,\n configurable: true,\n });\n})\nclass MoveableManager extends EventEmitter {\n private innerMoveable!: InnerMoveable | null;\n private tempElement: HTMLElement | null = document.createElement(\"div\");\n\n /**\n *\n */\n constructor(parentElement: HTMLElement | SVGElement, options: MoveableOptions = {}) {\n super();\n const nextOptions = { ...options };\n\n const events: any = {};\n\n EVENTS.forEach(name => {\n events[camelize(`on ${name}`)] = (e: any) => this.trigger(name, e);\n });\n\n render(\n ,\n this.tempElement,\n );\n const target = nextOptions.target!;\n if (isArray(target) && target.length > 1) {\n this.updateRect();\n }\n }\n public setState(state: Partial, callback?: () => any) {\n this.innerMoveable!.setState(state, callback);\n }\n public forceUpdate(callback?: () => any) {\n this.innerMoveable!.forceUpdate(callback);\n }\n public dragStart(e: MouseEvent | TouchEvent) {\n const innerMoveable = this.innerMoveable;\n if ((innerMoveable as any).$_timer) {\n this.forceUpdate();\n }\n this.getMoveable().dragStart(e);\n }\n public destroy() {\n render(null as any, this.tempElement!);\n this.off();\n this.tempElement = null;\n this.innerMoveable = null;\n }\n private getMoveable() {\n return this.innerMoveable!.moveable;\n }\n}\n\ninterface MoveableManager extends MoveableInterface, MoveableProperties {\n}\n\nexport default MoveableManager;\n","import MoveableManager from \"./MoveableManager\";\n\nexport default class Moveable extends MoveableManager {}\n","import { Able, DefaultProps } from \"react-moveable/types\";\nimport { getElementInfo as getElementInfoFunction, makeAble as makeAbleFunction } from \"react-moveable\";\n\nexport function getElementInfo(\n target: SVGElement | HTMLElement,\n container?: SVGElement | HTMLElement | null,\n rootContainer?: SVGElement | HTMLElement | null | undefined,\n) {\n return getElementInfoFunction(target, container, rootContainer);\n};\nexport function makeAble<\n Name extends string,\n AbleObject extends Partial>,\n Props extends DefaultProps,\n>(name: Name, able: AbleObject) {\n return makeAbleFunction(name, able);\n}\n","import Moveable, * as modules from \"./index\";\n\nfor (const name in modules) {\n (Moveable as any)[name] = (modules as any)[name];\n}\n\nexport default Moveable;\n"],"names":["__extends","props","_super","_this","state","createPortal","React","Moveable","ref","parentElement","PROPERTIES","MOVEABLE_PROPS","METHODS","MOVEABLE_METHODS","EVENTS","MOVEABLE_EVENTS","PROPS_MAP","MOVEABLE_PROPS_MAP","options","document","createElement","nextOptions","events","forEach","name","camelize","e","trigger","render","InnerMoveable","tempElement","target","isArray","length","updateRect","callback","innerMoveable","setState","forceUpdate","$_timer","getMoveable","dragStart","off","moveable","MoveableManager","Properties","prototype","property","_i","args","self","Object","defineProperty","get","set","value","_a","enumerable","configurable","EventEmitter","getElementInfo","container","rootContainer","getElementInfoFunction","makeAble","able","makeAbleFunction","modules"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA;;;AAA2CA,EAAAA,gCAAA;;AAGvC,wBAAA,CAAYC,KAAZ;AAAA,gBACIC,WAAA,KAAA,EAAMD,KAAN,SADJ;;AAFOE,IAAAA,WAAA,GAAa,EAAb;AAIHA,IAAAA,KAAI,CAACC,KAAL,GAAaD,KAAI,CAACF,KAAlB;;AACH;;;;AACM,gBAAA,GAAP;AACI,WAAOI,kBAAY,CAACC,mBAAA,CAACC,UAAD;AAAUC,MAAAA,GAAG,EAAEA,kBAAG,CAAC,IAAD,EAAO,UAAP;OAAwB,KAAKJ,MAA/C,CAAD,EAA2D,KAAKA,KAAL,CAAWK,aAAtE,CAAnB;AACH,GAFM;;AAGX,sBAAA;AAAC,EAV0CH,gBAA3C;;ACFO,IAAMI,UAAU,GAAaC,yBAA7B;AACP,AAAO,IAAMC,OAAO,GAAaC,2BAA1B;AACP,AAAO,IAAMC,MAAM,GAAaC,0BAAzB;AACP,AAAO,IAAMC,SAAS,GAAwBC,6BAAvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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