{"version":3,"sources":["transform-wrapper.ts"],"sourcesContent":["import { Datex } from \"datex-core-legacy/mod.ts\";\nimport type { DOMUtils } from \"./dom-utils.ts\";\nimport type { DOMContext } from \"../dom/DOMContext.ts\";\nimport { allDomTypes } from \"./dom-datex-types.ts\";\n\nfunction appendToFragment(domUtils: DOMUtils, context: DOMContext, fragment: HTMLElement, val: any) {\n\tdomUtils.append(fragment, val);\n\tif (val instanceof context.HTMLElement) {\n\t\tif (val.hasAttribute(\"slot\")) fragment.setAttribute(\"slot\", val.getAttribute(\"slot\"))\n\t}\n}\n\n/**\n * JS interface method definitions to create a transform wrapper for DOM elements\n * @param document \n * @returns \n */\nexport function getTransformWrapper(domUtils: DOMUtils, context: DOMContext) {\n\treturn {\n\t\t// special uix-fragment wrapper for transforms\n\t\twrap_transform(val:any) {\n\t\t\tconst fragment = context.document.createElement(\"uix-fragment\");\n\t\t\tappendToFragment(domUtils, context, fragment, val);\n\t\t\treturn fragment;\n\t\t},\n\t\n\t\tunwrap_transform(val:any) {\n\t\t\t// // remove outer uix-fragment wrapper if present\n\t\t\t// if (val instanceof context.HTMLElement && val.tagName == \"UIX-FRAGMENT\" && val.children.length == 1) {\n\t\t\t// \treturn val.children[0];\n\t\t\t// }\n\t\t\treturn val;\t\n\t\t},\n\n\t\tallow_transform_value(type: Datex.Type) {\n\t\t\treturn type == Datex.Type.std.void || type==Datex.Type.std.null || allDomTypes.has(type.root_type) || type.root_type.name == \"uix\" || \"must be a DOM element\"\n\t\t},\n\t\n\t\thandle_transform(val:any, ptr:Datex.Pointer) {\n\t\t\tconst fragment = ptr.val;\n\t\t\t// no content change\n\t\t\tif (fragment.children.length == 1 && [...fragment.children][0] == val) return;\n\t\n\t\t\tfragment.innerHTML = \"\";\n\t\t\tappendToFragment(domUtils, context, fragment, val);\n\t\t}\n\t}\n}"],"names":["Datex","allDomTypes","appendToFragment","domUtils","context","fragment","val","append","HTMLElement","hasAttribute","setAttribute","getAttribute","getTransformWrapper","wrap_transform","document","createElement","unwrap_transform","allow_transform_value","type","Type","std","void","null","has","root_type","name","handle_transform","ptr","children","length","innerHTML"],"mappings":"AAAA,SAASA,KAAK,QAAQ,2BAA2B;AAGjD,SAASC,WAAW,QAAQ,uBAAuB;AAEnD,SAASC,iBAAiBC,QAAkB,EAAEC,OAAmB,EAAEC,QAAqB,EAAEC,GAAQ;IACjGH,SAASI,MAAM,CAACF,UAAUC,MACtBA,eAAeF,QAAQI,WAAW,IACjCF,IAAIG,YAAY,CAAC,WAASJ,SAASK,YAAY,CAAC,QAAQJ,IAAIK,YAAY,CAAC;AAE/E;AAOA,OAAO,SAASC,oBAAoBT,QAAkB,EAAEC,OAAmB;IAC1E,OAAO;QAENS,gBAAeP,GAAO;YACrB,IAAMD,WAAWD,QAAQU,QAAQ,CAACC,aAAa,CAAC;YAEhD,OADAb,iBAAiBC,UAAUC,SAASC,UAAUC,MACvCD;QACR;QAEAW,kBAAAA,CAAiBV,MAKTA;QAGRW,uBAAAA,CAAsBC,OACdA,QAAQlB,MAAMmB,IAAI,CAACC,GAAG,CAACC,IAAI,IAAIH,QAAMlB,MAAMmB,IAAI,CAACC,GAAG,CAACE,IAAI,IAAIrB,YAAYsB,GAAG,CAACL,KAAKM,SAAS,KAAKN,AAAuB,SAAvBA,KAAKM,SAAS,CAACC,IAAI,IAAa;QAGvIC,kBAAiBpB,GAAO,EAAEqB,GAAiB;YAC1C,IAAMtB,WAAWsB,IAAIrB,GAAG;YAEpBD,CAAAA,AAA4B,KAA5BA,SAASuB,QAAQ,CAACC,MAAM,IAAS;mBAAIxB,SAASuB,QAAQ;aAAC,CAAC,EAAE,IAAItB,GAAE,MAEpED,SAASyB,SAAS,GAAG,IACrB5B,iBAAiBC,UAAUC,SAASC,UAAUC;QAC/C;IACD;AACD","sourceRoot":"/lib/uix-0.4.39/src/uix-dom/datex-bindings/","file":"transform-wrapper.ts"}