@orago/dodo 0.0.1 → 0.0.2
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.
- package/dist/dodo.cjs.map +1 -1
- package/dist/dodo.d.ts +5 -231
- package/dist/dodo.mjs.map +1 -1
- package/dist/util/class.util.cjs.map +1 -1
- package/dist/util/class.util.d.ts +9 -0
- package/dist/util/class.util.mjs.map +1 -1
- package/package.json +60 -60
- package/pnpm-workspace.yaml +1 -1
- package/src/dodo.ts +13 -3
- package/src/util/class.util.ts +2 -1
package/dist/dodo.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dodo.cjs","names":["Base_KiwiStyles","KiwiUtil","Base_KiwiClasses","Base_Kiwi","DodoGlobalPlugins","Emitter","makeCallableInstance","DodoEvents"],"sources":["../src/dodo.ts"],"sourcesContent":["import {\r\n\ttype KiwiItem,\r\n\ttype KiwiUpdate,\r\n\tBase_Kiwi,\r\n\tBase_KiwiClasses,\r\n\tBase_KiwiStyles,\r\n\tElementName,\r\n\tUtil as KiwiUtil,\r\n\tStyleDeclaration,\r\n\tStyleDeclarationPlus,\r\n} from \"@orago/kiwi\";\r\nimport { Emitter } from \"@orago/lib\";\r\nimport { DodoEvents } from \"./dodo-events.js\";\r\nimport { makeCallableInstance } from \"./util/class.util.js\";\r\nimport { DodoGlobalPlugins } from \"./util/plugins-support.js\";\r\n\r\ntype Extractable = Dodo | KiwiItem | { element: HTMLElement } | Node;\r\ntype AppendableItem = Extractable | string | number;\r\ntype Appendable = AppendableItem | boolean | null | undefined;\r\nexport type ChildList = (Appendable | Appendable[])[];\r\n\r\nexport type ResolveElement<Input extends ElementName | Extractable> =\r\n\tInput extends keyof HTMLElementTagNameMap\r\n\t\t? HTMLElementTagNameMap[Input]\r\n\t\t: Input extends HTMLElement\r\n\t\t\t? Input\r\n\t\t\t: Input extends Dodo\r\n\t\t\t\t? Input[\"element\"]\r\n\t\t\t\t: HTMLElement;\r\n\r\nclass DodoStyles<N extends Dodo> extends Base_KiwiStyles {\r\n\tconstructor(public instance: N) {\r\n\t\tsuper();\r\n\t}\r\n\r\n\tpublic nest(run: (arg0: this) => void): this[\"instance\"] {\r\n\t\trun(this);\r\n\t\treturn this.instance;\r\n\t}\r\n\r\n\tpublic call(styles: StyleDeclarationPlus): N;\r\n\tpublic call(value: (arg0: this) => void): N;\r\n\tpublic call(value: StyleDeclarationPlus | ((arg0: this) => void) = {}): N {\r\n\t\tif (typeof value == \"object\") {\r\n\t\t\treturn this.update(value).instance;\r\n\t\t} else if (typeof value == \"function\") {\r\n\t\t\treturn this.nest(value);\r\n\t\t}\r\n\r\n\t\treturn this.instance;\r\n\t}\r\n\r\n\tpublic get(): StyleDeclaration {\r\n\t\tconst style = this.instance.element.style;\r\n\r\n\t\treturn Object.fromEntries(\r\n\t\t\tArray.from(style).map((name) => [\r\n\t\t\t\tname,\r\n\t\t\t\tstyle.getPropertyValue(name),\r\n\t\t\t]),\r\n\t\t);\r\n\t}\r\n\r\n\tupdate(styles: StyleDeclarationPlus): this {\r\n\t\tKiwiUtil.setStyles(styles, (key, value) => {\r\n\t\t\tthis.instance.element.style.setProperty(\r\n\t\t\t\tKiwiUtil.formatAttributeName(\"kebab\", key),\r\n\t\t\t\tvalue,\r\n\t\t\t);\r\n\t\t});\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\tremove(...styles: string[]): this {\r\n\t\tfor (const key of styles) {\r\n\t\t\tthis.instance.element.style.removeProperty(\r\n\t\t\t\tKiwiUtil.formatAttributeName(\"kebab\", key),\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t}\r\n}\r\n\r\nclass DodoClasses<N extends Dodo> extends Base_KiwiClasses {\r\n\tconstructor(public instance: N) {\r\n\t\tsuper();\r\n\t}\r\n\r\n\tpublic nest(run: (arg0: this) => void): this[\"instance\"] {\r\n\t\trun(this);\r\n\t\treturn this.instance;\r\n\t}\r\n\r\n\tpublic call(...classes: string[]): N;\r\n\tpublic call(nest: (arg0: this) => void): N;\r\n\tpublic call(...value: string[] | [(arg0: this) => void]): N {\r\n\t\tlet [first] = value;\r\n\r\n\t\tif (typeof first == \"string\") {\r\n\t\t\treturn this.set(...(value as string[])).instance;\r\n\t\t} else if (typeof first == \"function\") {\r\n\t\t\treturn this.nest(first);\r\n\t\t}\r\n\r\n\t\treturn this.instance;\r\n\t}\r\n\r\n\tpublic get(): string[] {\r\n\t\treturn Array.from(this.instance.element.classList);\r\n\t}\r\n\r\n\thas(...classes: string[]): boolean {\r\n\t\treturn classes.every((classname) =>\r\n\t\t\tthis.instance.element.classList.contains(classname),\r\n\t\t);\r\n\t}\r\n\r\n\tadd(...classes: string[]): this {\r\n\t\tthis.instance.element.classList.add(...KiwiUtil.formatClasses(classes));\r\n\t\treturn this;\r\n\t}\r\n\r\n\tremove(...classes: string[]): this {\r\n\t\tthis.instance.element.classList.remove(\r\n\t\t\t...KiwiUtil.formatClasses(classes),\r\n\t\t);\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\tset(...classes: string[]): this {\r\n\t\tthis.instance.element.className =\r\n\t\t\tKiwiUtil.formatClasses(classes).join(\" \");\r\n\t\treturn this;\r\n\t}\r\n\r\n\ttoggle(classes: string | string[], status: boolean): this {\r\n\t\tconst list = Array.isArray(classes) ? classes : [classes];\r\n\t\tif (status) {\r\n\t\t\tthis.add(...list);\r\n\t\t} else {\r\n\t\t\tthis.remove(...list);\r\n\t\t}\r\n\t\treturn this;\r\n\t}\r\n}\r\n\r\nclass DodoUtil {\r\n\tpublic static fromDataItem(\r\n\t\titem: Omit<KiwiItem, \"children\"> & { children: ChildList },\r\n\t) {\r\n\t\tconst instance = new Dodo(item.tag).update(item.update);\r\n\t\tinstance.append(...DodoUtil.flattenElements(item.children));\r\n\t\treturn instance;\r\n\t}\r\n\r\n\tpublic static extractElement(a: Extractable): HTMLElement {\r\n\t\tif (\"element\" in a) {\r\n\t\t\treturn a.element;\r\n\t\t} else if (a instanceof Dodo) {\r\n\t\t\treturn a.element;\r\n\t\t} else if (\"tag\" in a && \"update\" in a && \"children\" in a) {\r\n\t\t\treturn DodoUtil.fromDataItem(a).element;\r\n\t\t} else {\r\n\t\t\treturn a as HTMLElement;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic static forceElement(a: AppendableItem) {\r\n\t\tif (\r\n\t\t\ttypeof a == \"number\" ||\r\n\t\t\ttypeof a == \"boolean\" ||\r\n\t\t\ttypeof a == \"string\"\r\n\t\t) {\r\n\t\t\treturn document.createTextNode(String(a)) as unknown as HTMLElement;\r\n\t\t} else {\r\n\t\t\treturn DodoUtil.extractElement(a);\r\n\t\t}\r\n\t}\r\n\r\n\tpublic static flattenElements(contents: ChildList): HTMLElement[] {\r\n\t\treturn contents\r\n\t\t\t.flat()\r\n\t\t\t.filter((content) => content != undefined && content !== false)\r\n\t\t\t.map((a) => {\r\n\t\t\t\tif (a == true) a = \"true\";\r\n\t\t\t\treturn DodoUtil.forceElement(a);\r\n\t\t\t});\r\n\t}\r\n\r\n\tpublic static injectItems<T extends HTMLElement>(\r\n\t\tnode: T,\r\n\t\tdirection: \"append\" | \"prepend\" = \"append\",\r\n\t\tobjs: ChildList,\r\n\t): void {\r\n\t\tif (objs.length < 1) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst items = this.flattenElements(objs);\r\n\r\n\t\tfor (const item of items) {\r\n\t\t\tconst extracted =\r\n\t\t\t\ttypeof item === \"string\" ? item : DodoUtil.forceElement(item);\r\n\r\n\t\t\tif (direction === \"append\") {\r\n\t\t\t\tnode.append(extracted);\r\n\t\t\t} else {\r\n\t\t\t\tnode.prepend(extracted);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunction oo<T extends ElementName>(\r\n\ttag: T,\r\n\tprops?: KiwiUpdate | null,\r\n\t...children: ChildList\r\n): Dodo {\r\n\treturn DodoUtil.fromDataItem({\r\n\t\ttag,\r\n\t\tupdate: props ?? {},\r\n\t\tchildren,\r\n\t});\r\n}\r\n\r\n/**\r\n * client sided mode for Orago's-Dom-Libary\r\n */\r\nclass Dodo<H extends HTMLElement = HTMLElement> extends Base_Kiwi {\r\n\tstatic oo = oo;\r\n\tstatic plugins = new DodoGlobalPlugins();\r\n\tpublic static events: Emitter<\r\n\t\t{\r\n\t\t\tinit: (node: Dodo) => void;\r\n\t\t},\r\n\t\ttrue\r\n\t> = new Emitter();\r\n\r\n\telement!: H;\r\n\r\n\tstyle = makeCallableInstance(DodoStyles, [this], \"call\");\r\n\tclass = makeCallableInstance(DodoClasses, [this], \"call\");\r\n\tevents = makeCallableInstance(DodoEvents, [this], \"call\");\r\n\r\n\tconstructor(element: ElementName | Extractable) {\r\n\t\tsuper();\r\n\r\n\t\tif (typeof element === \"string\") {\r\n\t\t\tthis.element = document.createElement(element) as any;\r\n\t\t} else {\r\n\t\t\tthis.element = DodoUtil.extractElement(element) as any;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic update(update: KiwiUpdate): this {\r\n\t\tif (update.id != undefined) {\r\n\t\t\tthis.id(update.id);\r\n\t\t}\r\n\t\tif (update.attributes != undefined) {\r\n\t\t\tthis.attr(update.attributes);\r\n\t\t}\r\n\t\tif (update.dataset != undefined) {\r\n\t\t\tthis.dataset(update.dataset);\r\n\t\t}\r\n\t\tif (update.styles != undefined) {\r\n\t\t\tthis.style(update.styles);\r\n\t\t}\r\n\t\tif (update.classes != undefined) {\r\n\t\t\tthis.class.add(...update.classes);\r\n\t\t}\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic use(plugins: ((node: this) => void)[]): this {\r\n\t\tfor (const plugin of plugins) {\r\n\t\t\tplugin(this);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic attr(\r\n\t\tattributes: Partial<Record<string & {}, string | number>> = {},\r\n\t): this {\r\n\t\tKiwiUtil.setAttributes(\r\n\t\t\tattributes,\r\n\t\t\t(key, value) => this.element.setAttribute(key, value),\r\n\t\t\t(key) => this.element.removeAttribute(key),\r\n\t\t);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic dataset(): Partial<Record<string, string>>;\r\n\tpublic dataset(record: \"clear\" | Partial<Record<string, string>>): this;\r\n\tpublic dataset(record?: \"clear\" | Partial<Record<string, string>>): any {\r\n\t\tif (record == undefined) {\r\n\t\t\treturn this.element.dataset;\r\n\t\t}\r\n\r\n\t\tif (record == \"clear\") {\r\n\t\t\treturn this.dataset(\r\n\t\t\t\tObject.fromEntries(\r\n\t\t\t\t\tObject.keys(this.element.dataset).map((key) => [\r\n\t\t\t\t\t\tKiwiUtil.formatAttributeName(\"camel\", key),\r\n\t\t\t\t\t\tundefined,\r\n\t\t\t\t\t]),\r\n\t\t\t\t),\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tfor (let [key, value] of Object.entries(record)) {\r\n\t\t\tkey = KiwiUtil.formatAttributeName(\"camel\", key);\r\n\t\t\tif (value == undefined) {\r\n\t\t\t\tdelete this.element.dataset[key];\r\n\t\t\t} else {\r\n\t\t\t\tthis.element.dataset[key] = value;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic append(...input: ChildList): this {\r\n\t\tDodoUtil.injectItems(this.element, \"append\", input);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic prepend(...input: ChildList): this {\r\n\t\tDodoUtil.injectItems(this.element, \"prepend\", input);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tprotected $IdGet(): string {\r\n\t\treturn this.element.id;\r\n\t}\r\n\r\n\tprotected $IdSet(value: string): void {\r\n\t\tthis.element.id = value;\r\n\t}\r\n\r\n\tprotected $ValueGet(): string {\r\n\t\tif (\r\n\t\t\tthis.element instanceof HTMLInputElement ||\r\n\t\t\tthis.element instanceof HTMLSelectElement\r\n\t\t) {\r\n\t\t\treturn this.element.value;\r\n\t\t} else if (this.element instanceof HTMLImageElement) {\r\n\t\t\treturn this.element.src;\r\n\t\t} else {\r\n\t\t\treturn this.element.textContent;\r\n\t\t}\r\n\t}\r\n\r\n\tprotected $ValueSet(value: string): this {\r\n\t\tif (\r\n\t\t\tthis.element instanceof HTMLInputElement ||\r\n\t\t\tthis.element instanceof HTMLSelectElement\r\n\t\t) {\r\n\t\t\tthis.element.value = value.toString();\r\n\t\t} else if (this.element instanceof HTMLImageElement) {\r\n\t\t\tthis.element.src = value.toString();\r\n\t\t} else {\r\n\t\t\tthis.element.textContent = value.toString();\r\n\t\t}\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic clear(): this {\r\n\t\tthis.element.innerHTML = \"\";\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic content(...input: ChildList): this {\r\n\t\tthis.clear().append(...input);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic getBounds() {\r\n\t\treturn this.element.getBoundingClientRect();\r\n\t}\r\n}\r\n\r\nexport { Dodo, DodoUtil, oo, type Appendable, type Extractable };\r\n"],"mappings":"qKA8BA,IAAM,EAAN,cAAyCA,EAAAA,eAAgB,CACxD,YAAY,EAAoB,CAC/B,MAAM,EADY,KAAA,SAAA,CAEnB,CAEA,KAAY,EAA6C,CAExD,OADA,EAAI,IAAI,EACD,KAAK,QACb,CAIA,KAAY,EAAuD,CAAC,EAAM,CAOzE,OANI,OAAO,GAAS,SACZ,KAAK,OAAO,CAAK,CAAC,CAAC,SAChB,OAAO,GAAS,WACnB,KAAK,KAAK,CAAK,EAGhB,KAAK,QACb,CAEA,KAA+B,CAC9B,IAAM,EAAQ,KAAK,SAAS,QAAQ,MAEpC,OAAO,OAAO,YACb,MAAM,KAAK,CAAK,CAAC,CAAC,IAAK,GAAS,CAC/B,EACA,EAAM,iBAAiB,CAAI,CAC5B,CAAC,CACF,CACD,CAEA,OAAO,EAAoC,CAQ1C,OAPA,EAAA,KAAS,UAAU,GAAS,EAAK,IAAU,CAC1C,KAAK,SAAS,QAAQ,MAAM,YAC3BC,EAAAA,KAAS,oBAAoB,QAAS,CAAG,EACzC,CACD,CACD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AAO,EAG9B,OAAO,IACR,CAEA,OAAc,GAAG,EAAwB,CAExC,OADA,EAAS,YAAY,KAAK,QAAS,SAAU,CAAK,EAC3C,IACR,CAEA,QAAe,GAAG,EAAwB,CAEzC,OADA,EAAS,YAAY,KAAK,QAAS,UAAW,CAAK,EAC5C,IACR,CAEA,QAA2B,CAC1B,OAAO,KAAK,QAAQ,EACrB,CAEA,OAAiB,EAAqB,CACrC,KAAK,QAAQ,GAAK,CACnB,CAEA,WAA8B,CAS5B,OAPA,KAAK,mBAAmB,kBACxB,KAAK,mBAAmB,kBAEjB,KAAK,QAAQ,MACV,KAAK,mBAAmB,iBAC3B,KAAK,QAAQ,IAEb,KAAK,QAAQ,WAEtB,CAEA,UAAoB,EAAqB,CAWxC,OATC,KAAK,mBAAmB,kBACxB,KAAK,mBAAmB,kBAExB,KAAK,QAAQ,MAAQ,EAAM,SAAS,EAC1B,KAAK,mBAAmB,iBAClC,KAAK,QAAQ,IAAM,EAAM,SAAS,EAElC,KAAK,QAAQ,YAAc,EAAM,SAAS,EAEpC,IACR,CAEA,OAAqB,CAEpB,MADA,MAAK,QAAQ,UAAY,GAClB,IACR,CAEA,QAAe,GAAG,EAAwB,CAEzC,OADA,KAAK,MAAM,CAAC,CAAC,OAAO,GAAG,CAAK,EACrB,IACR,CAEA,WAAmB,CAClB,OAAO,KAAK,QAAQ,sBAAsB,CAC3C,CACD"}
|
|
1
|
+
{"version":3,"file":"dodo.cjs","names":["Base_KiwiStyles","KiwiUtil","Base_KiwiClasses","Base_Kiwi","DodoGlobalPlugins","Emitter","makeCallableInstance","DodoEvents"],"sources":["../src/dodo.ts"],"sourcesContent":["import {\r\n\ttype KiwiItem,\r\n\ttype KiwiUpdate,\r\n\tBase_Kiwi,\r\n\tBase_KiwiClasses,\r\n\tBase_KiwiStyles,\r\n\tElementName,\r\n\tUtil as KiwiUtil,\r\n\tStyleDeclaration,\r\n\tStyleDeclarationPlus,\r\n} from \"@orago/kiwi\";\r\nimport { Emitter } from \"@orago/lib\";\r\nimport { DodoEvents } from \"./dodo-events.js\";\r\nimport { makeCallableInstance } from \"./util/class.util.js\";\r\nimport { DodoGlobalPlugins } from \"./util/plugins-support.js\";\r\n\r\ntype Extractable = Dodo | KiwiItem | { element: HTMLElement } | Node;\r\ntype AppendableItem = Extractable | string | number;\r\ntype Appendable = AppendableItem | boolean | null | undefined;\r\nexport type ChildList = (Appendable | Appendable[])[];\r\n\r\nexport type ResolveElement<Input extends ElementName | Extractable> =\r\n\tInput extends keyof HTMLElementTagNameMap\r\n\t\t? HTMLElementTagNameMap[Input]\r\n\t\t: Input extends HTMLElement\r\n\t\t\t? Input\r\n\t\t\t: Input extends Dodo\r\n\t\t\t\t? Input[\"element\"]\r\n\t\t\t\t: HTMLElement;\r\n\r\nclass DodoStyles<N extends Dodo> extends Base_KiwiStyles {\r\n\tconstructor(public instance: N) {\r\n\t\tsuper();\r\n\t}\r\n\r\n\tpublic nest(run: (arg0: this) => void): this[\"instance\"] {\r\n\t\trun(this);\r\n\t\treturn this.instance;\r\n\t}\r\n\r\n\tpublic call(styles: StyleDeclarationPlus): N;\r\n\tpublic call(value: (arg0: this) => void): N;\r\n\tpublic call(value: StyleDeclarationPlus | ((arg0: this) => void) = {}): N {\r\n\t\tif (typeof value == \"object\") {\r\n\t\t\treturn this.update(value).instance;\r\n\t\t} else if (typeof value == \"function\") {\r\n\t\t\treturn this.nest(value);\r\n\t\t}\r\n\r\n\t\treturn this.instance;\r\n\t}\r\n\r\n\tpublic get(): StyleDeclaration {\r\n\t\tconst style = this.instance.element.style;\r\n\r\n\t\treturn Object.fromEntries(\r\n\t\t\tArray.from(style).map((name) => [\r\n\t\t\t\tname,\r\n\t\t\t\tstyle.getPropertyValue(name),\r\n\t\t\t]),\r\n\t\t);\r\n\t}\r\n\r\n\tupdate(styles: StyleDeclarationPlus): this {\r\n\t\tKiwiUtil.setStyles(styles, (key, value) => {\r\n\t\t\tthis.instance.element.style.setProperty(\r\n\t\t\t\tKiwiUtil.formatAttributeName(\"kebab\", key),\r\n\t\t\t\tvalue,\r\n\t\t\t);\r\n\t\t});\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\tremove(...styles: string[]): this {\r\n\t\tfor (const key of styles) {\r\n\t\t\tthis.instance.element.style.removeProperty(\r\n\t\t\t\tKiwiUtil.formatAttributeName(\"kebab\", key),\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t}\r\n}\r\n\r\nclass DodoClasses<N extends Dodo> extends Base_KiwiClasses {\r\n\tconstructor(public instance: N) {\r\n\t\tsuper();\r\n\t}\r\n\r\n\tpublic nest(run: (arg0: this) => void): this[\"instance\"] {\r\n\t\trun(this);\r\n\t\treturn this.instance;\r\n\t}\r\n\r\n\tpublic call(...classes: string[]): N;\r\n\tpublic call(nest: (arg0: this) => void): N;\r\n\tpublic call(...value: string[] | [(arg0: this) => void]): N {\r\n\t\tlet [first] = value;\r\n\r\n\t\tif (typeof first == \"string\") {\r\n\t\t\treturn this.set(...(value as string[])).instance;\r\n\t\t} else if (typeof first == \"function\") {\r\n\t\t\treturn this.nest(first);\r\n\t\t}\r\n\r\n\t\treturn this.instance;\r\n\t}\r\n\r\n\tpublic get(): string[] {\r\n\t\treturn Array.from(this.instance.element.classList);\r\n\t}\r\n\r\n\thas(...classes: string[]): boolean {\r\n\t\treturn classes.every((classname) =>\r\n\t\t\tthis.instance.element.classList.contains(classname),\r\n\t\t);\r\n\t}\r\n\r\n\tadd(...classes: string[]): this {\r\n\t\tthis.instance.element.classList.add(...KiwiUtil.formatClasses(classes));\r\n\t\treturn this;\r\n\t}\r\n\r\n\tremove(...classes: string[]): this {\r\n\t\tthis.instance.element.classList.remove(\r\n\t\t\t...KiwiUtil.formatClasses(classes),\r\n\t\t);\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\tset(...classes: string[]): this {\r\n\t\tthis.instance.element.className =\r\n\t\t\tKiwiUtil.formatClasses(classes).join(\" \");\r\n\t\treturn this;\r\n\t}\r\n\r\n\ttoggle(classes: string | string[], status: boolean): this {\r\n\t\tconst list = Array.isArray(classes) ? classes : [classes];\r\n\t\tif (status) {\r\n\t\t\tthis.add(...list);\r\n\t\t} else {\r\n\t\t\tthis.remove(...list);\r\n\t\t}\r\n\t\treturn this;\r\n\t}\r\n}\r\n\r\nclass DodoUtil {\r\n\tpublic static fromDataItem(\r\n\t\titem: Omit<KiwiItem, \"children\"> & { children: ChildList },\r\n\t) {\r\n\t\tconst instance = new Dodo(item.tag).update(item.update);\r\n\t\tinstance.append(...DodoUtil.flattenElements(item.children));\r\n\t\treturn instance;\r\n\t}\r\n\r\n\tpublic static extractElement(a: Extractable): HTMLElement {\r\n\t\tif (\"element\" in a) {\r\n\t\t\treturn a.element;\r\n\t\t} else if (a instanceof Dodo) {\r\n\t\t\treturn a.element;\r\n\t\t} else if (\"tag\" in a && \"update\" in a && \"children\" in a) {\r\n\t\t\treturn DodoUtil.fromDataItem(a).element;\r\n\t\t} else {\r\n\t\t\treturn a as HTMLElement;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic static forceElement(a: AppendableItem) {\r\n\t\tif (\r\n\t\t\ttypeof a == \"number\" ||\r\n\t\t\ttypeof a == \"boolean\" ||\r\n\t\t\ttypeof a == \"string\"\r\n\t\t) {\r\n\t\t\treturn document.createTextNode(String(a)) as unknown as HTMLElement;\r\n\t\t} else {\r\n\t\t\treturn DodoUtil.extractElement(a);\r\n\t\t}\r\n\t}\r\n\r\n\tpublic static flattenElements(contents: ChildList): HTMLElement[] {\r\n\t\treturn contents\r\n\t\t\t.flat()\r\n\t\t\t.filter((content) => content != undefined && content !== false)\r\n\t\t\t.map((a) => {\r\n\t\t\t\tif (a == true) a = \"true\";\r\n\t\t\t\treturn DodoUtil.forceElement(a);\r\n\t\t\t});\r\n\t}\r\n\r\n\tpublic static injectItems<T extends HTMLElement>(\r\n\t\tnode: T,\r\n\t\tdirection: \"append\" | \"prepend\" = \"append\",\r\n\t\tobjs: ChildList,\r\n\t): void {\r\n\t\tif (objs.length < 1) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst items = this.flattenElements(objs);\r\n\r\n\t\tfor (const item of items) {\r\n\t\t\tconst extracted =\r\n\t\t\t\ttypeof item === \"string\" ? item : DodoUtil.forceElement(item);\r\n\r\n\t\t\tif (direction === \"append\") {\r\n\t\t\t\tnode.append(extracted);\r\n\t\t\t} else {\r\n\t\t\t\tnode.prepend(extracted);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunction oo<T extends ElementName>(\r\n\ttag: T,\r\n\tprops?: KiwiUpdate | null,\r\n\t...children: ChildList\r\n): Dodo {\r\n\treturn DodoUtil.fromDataItem({\r\n\t\ttag,\r\n\t\tupdate: props ?? {},\r\n\t\tchildren,\r\n\t});\r\n}\r\n\r\n/**\r\n * client sided mode for Orago's-Dom-Libary\r\n */\r\nclass Dodo<H extends HTMLElement = HTMLElement> extends Base_Kiwi {\r\n\tstatic oo = oo;\r\n\tstatic plugins = new DodoGlobalPlugins();\r\n\tpublic static events: Emitter<\r\n\t\t{\r\n\t\t\tinit: (node: Dodo) => void;\r\n\t\t},\r\n\t\ttrue\r\n\t> = new Emitter();\r\n\r\n\telement!: H;\r\n\r\n\tpublic style: ReturnType<\r\n\t\ttypeof makeCallableInstance<typeof DodoStyles, \"call\", DodoStyles<this>>\r\n\t> = makeCallableInstance(DodoStyles, [this], \"call\");\r\n\tclass: ReturnType<\r\n\t\ttypeof makeCallableInstance<\r\n\t\t\ttypeof DodoClasses,\r\n\t\t\t\"call\",\r\n\t\t\tDodoClasses<this>\r\n\t\t>\r\n\t> = makeCallableInstance(DodoClasses, [this], \"call\");\r\n\tevents: ReturnType<\r\n\t\ttypeof makeCallableInstance<typeof DodoEvents, \"call\", DodoEvents<this>>\r\n\t> = makeCallableInstance(DodoEvents, [this], \"call\");\r\n\r\n\tconstructor(element: ElementName | Extractable) {\r\n\t\tsuper();\r\n\r\n\t\tif (typeof element === \"string\") {\r\n\t\t\tthis.element = document.createElement(element) as any;\r\n\t\t} else {\r\n\t\t\tthis.element = DodoUtil.extractElement(element) as any;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic update(update: KiwiUpdate): this {\r\n\t\tif (update.id != undefined) {\r\n\t\t\tthis.id(update.id);\r\n\t\t}\r\n\t\tif (update.attributes != undefined) {\r\n\t\t\tthis.attr(update.attributes);\r\n\t\t}\r\n\t\tif (update.dataset != undefined) {\r\n\t\t\tthis.dataset(update.dataset);\r\n\t\t}\r\n\t\tif (update.styles != undefined) {\r\n\t\t\tthis.style(update.styles);\r\n\t\t}\r\n\t\tif (update.classes != undefined) {\r\n\t\t\tthis.class.add(...update.classes);\r\n\t\t}\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic use(plugins: ((node: this) => void)[]): this {\r\n\t\tfor (const plugin of plugins) {\r\n\t\t\tplugin(this);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic attr(\r\n\t\tattributes: Partial<Record<string & {}, string | number>> = {},\r\n\t): this {\r\n\t\tKiwiUtil.setAttributes(\r\n\t\t\tattributes,\r\n\t\t\t(key, value) => this.element.setAttribute(key, value),\r\n\t\t\t(key) => this.element.removeAttribute(key),\r\n\t\t);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic dataset(): Partial<Record<string, string>>;\r\n\tpublic dataset(record: \"clear\" | Partial<Record<string, string>>): this;\r\n\tpublic dataset(record?: \"clear\" | Partial<Record<string, string>>): any {\r\n\t\tif (record == undefined) {\r\n\t\t\treturn this.element.dataset;\r\n\t\t}\r\n\r\n\t\tif (record == \"clear\") {\r\n\t\t\treturn this.dataset(\r\n\t\t\t\tObject.fromEntries(\r\n\t\t\t\t\tObject.keys(this.element.dataset).map((key) => [\r\n\t\t\t\t\t\tKiwiUtil.formatAttributeName(\"camel\", key),\r\n\t\t\t\t\t\tundefined,\r\n\t\t\t\t\t]),\r\n\t\t\t\t),\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tfor (let [key, value] of Object.entries(record)) {\r\n\t\t\tkey = KiwiUtil.formatAttributeName(\"camel\", key);\r\n\t\t\tif (value == undefined) {\r\n\t\t\t\tdelete this.element.dataset[key];\r\n\t\t\t} else {\r\n\t\t\t\tthis.element.dataset[key] = value;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic append(...input: ChildList): this {\r\n\t\tDodoUtil.injectItems(this.element, \"append\", input);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic prepend(...input: ChildList): this {\r\n\t\tDodoUtil.injectItems(this.element, \"prepend\", input);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tprotected $IdGet(): string {\r\n\t\treturn this.element.id;\r\n\t}\r\n\r\n\tprotected $IdSet(value: string): void {\r\n\t\tthis.element.id = value;\r\n\t}\r\n\r\n\tprotected $ValueGet(): string {\r\n\t\tif (\r\n\t\t\tthis.element instanceof HTMLInputElement ||\r\n\t\t\tthis.element instanceof HTMLSelectElement\r\n\t\t) {\r\n\t\t\treturn this.element.value;\r\n\t\t} else if (this.element instanceof HTMLImageElement) {\r\n\t\t\treturn this.element.src;\r\n\t\t} else {\r\n\t\t\treturn this.element.textContent;\r\n\t\t}\r\n\t}\r\n\r\n\tprotected $ValueSet(value: string): this {\r\n\t\tif (\r\n\t\t\tthis.element instanceof HTMLInputElement ||\r\n\t\t\tthis.element instanceof HTMLSelectElement\r\n\t\t) {\r\n\t\t\tthis.element.value = value.toString();\r\n\t\t} else if (this.element instanceof HTMLImageElement) {\r\n\t\t\tthis.element.src = value.toString();\r\n\t\t} else {\r\n\t\t\tthis.element.textContent = value.toString();\r\n\t\t}\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic clear(): this {\r\n\t\tthis.element.innerHTML = \"\";\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic content(...input: ChildList): this {\r\n\t\tthis.clear().append(...input);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic getBounds() {\r\n\t\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xB,KAAK,mBAAmB,kBAExB,KAAK,QAAQ,MAAQ,EAAM,SAAS,EAC1B,KAAK,mBAAmB,iBAClC,KAAK,QAAQ,IAAM,EAAM,SAAS,EAElC,KAAK,QAAQ,YAAc,EAAM,SAAS,EAEpC,IACR,CAEA,OAAqB,CAEpB,MADA,MAAK,QAAQ,UAAY,GAClB,IACR,CAEA,QAAe,GAAG,EAAwB,CAEzC,OADA,KAAK,MAAM,CAAC,CAAC,OAAO,GAAG,CAAK,EACrB,IACR,CAEA,WAAmB,CAClB,OAAO,KAAK,QAAQ,sBAAsB,CAC3C,CACD"}
|
package/dist/dodo.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DodoEvents } from "./dodo-events.js";
|
|
2
|
+
import { makeCallableInstance } from "./util/class.util.js";
|
|
2
3
|
import { DodoGlobalPlugins } from "./util/plugins-support.js";
|
|
3
4
|
import { Base_Kiwi, Base_KiwiClasses, Base_KiwiStyles, ElementName, KiwiItem, KiwiUpdate, StyleDeclaration, StyleDeclarationPlus } from "@orago/kiwi";
|
|
4
5
|
import { Emitter } from "@orago/lib";
|
|
@@ -53,236 +54,9 @@ declare class Dodo<H extends HTMLElement = HTMLElement> extends Base_Kiwi {
|
|
|
53
54
|
init: (node: Dodo) => void;
|
|
54
55
|
}, true>;
|
|
55
56
|
element: H;
|
|
56
|
-
style:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
} & DodoStyles<Dodo<HTMLElement>>;
|
|
60
|
-
class: {
|
|
61
|
-
(...classes: string[]): Dodo<HTMLElement>;
|
|
62
|
-
(nest: (arg0: DodoClasses<Dodo<HTMLElement>>) => void): Dodo<HTMLElement>;
|
|
63
|
-
} & DodoClasses<Dodo<HTMLElement>>;
|
|
64
|
-
events: ((run: [event: DodoEventKeys, callback: Function][] | {
|
|
65
|
-
[x: string & {}]: ((...ev: any[]) => any) | undefined;
|
|
66
|
-
[x: `on:${string & {}}`]: ((...ev: any[]) => any) | undefined;
|
|
67
|
-
input?: ((...ev: any[]) => any) | undefined;
|
|
68
|
-
"on:input"?: ((...ev: any[]) => any) | undefined;
|
|
69
|
-
progress?: ((...ev: any[]) => any) | undefined;
|
|
70
|
-
"on:progress"?: ((...ev: any[]) => any) | undefined;
|
|
71
|
-
select?: ((...ev: any[]) => any) | undefined;
|
|
72
|
-
"on:select"?: ((...ev: any[]) => any) | undefined;
|
|
73
|
-
resize?: ((...ev: any[]) => any) | undefined;
|
|
74
|
-
"on:resize"?: ((...ev: any[]) => any) | undefined;
|
|
75
|
-
toggle?: ((...ev: any[]) => any) | undefined;
|
|
76
|
-
"on:toggle"?: ((...ev: any[]) => any) | undefined;
|
|
77
|
-
fullscreenchange?: ((...ev: any[]) => any) | undefined;
|
|
78
|
-
"on:fullscreenchange"?: ((...ev: any[]) => any) | undefined;
|
|
79
|
-
fullscreenerror?: ((...ev: any[]) => any) | undefined;
|
|
80
|
-
"on:fullscreenerror"?: ((...ev: any[]) => any) | undefined;
|
|
81
|
-
abort?: ((...ev: any[]) => any) | undefined;
|
|
82
|
-
"on:abort"?: ((...ev: any[]) => any) | undefined;
|
|
83
|
-
animationcancel?: ((...ev: any[]) => any) | undefined;
|
|
84
|
-
"on:animationcancel"?: ((...ev: any[]) => any) | undefined;
|
|
85
|
-
animationend?: ((...ev: any[]) => any) | undefined;
|
|
86
|
-
"on:animationend"?: ((...ev: any[]) => any) | undefined;
|
|
87
|
-
animationiteration?: ((...ev: any[]) => any) | undefined;
|
|
88
|
-
"on:animationiteration"?: ((...ev: any[]) => any) | undefined;
|
|
89
|
-
animationstart?: ((...ev: any[]) => any) | undefined;
|
|
90
|
-
"on:animationstart"?: ((...ev: any[]) => any) | undefined;
|
|
91
|
-
auxclick?: ((...ev: any[]) => any) | undefined;
|
|
92
|
-
"on:auxclick"?: ((...ev: any[]) => any) | undefined;
|
|
93
|
-
beforeinput?: ((...ev: any[]) => any) | undefined;
|
|
94
|
-
"on:beforeinput"?: ((...ev: any[]) => any) | undefined;
|
|
95
|
-
beforematch?: ((...ev: any[]) => any) | undefined;
|
|
96
|
-
"on:beforematch"?: ((...ev: any[]) => any) | undefined;
|
|
97
|
-
beforetoggle?: ((...ev: any[]) => any) | undefined;
|
|
98
|
-
"on:beforetoggle"?: ((...ev: any[]) => any) | undefined;
|
|
99
|
-
blur?: ((...ev: any[]) => any) | undefined;
|
|
100
|
-
"on:blur"?: ((...ev: any[]) => any) | undefined;
|
|
101
|
-
cancel?: ((...ev: any[]) => any) | undefined;
|
|
102
|
-
"on:cancel"?: ((...ev: any[]) => any) | undefined;
|
|
103
|
-
canplay?: ((...ev: any[]) => any) | undefined;
|
|
104
|
-
"on:canplay"?: ((...ev: any[]) => any) | undefined;
|
|
105
|
-
canplaythrough?: ((...ev: any[]) => any) | undefined;
|
|
106
|
-
"on:canplaythrough"?: ((...ev: any[]) => any) | undefined;
|
|
107
|
-
change?: ((...ev: any[]) => any) | undefined;
|
|
108
|
-
"on:change"?: ((...ev: any[]) => any) | undefined;
|
|
109
|
-
click?: ((...ev: any[]) => any) | undefined;
|
|
110
|
-
"on:click"?: ((...ev: any[]) => any) | undefined;
|
|
111
|
-
close?: ((...ev: any[]) => any) | undefined;
|
|
112
|
-
"on:close"?: ((...ev: any[]) => any) | undefined;
|
|
113
|
-
compositionend?: ((...ev: any[]) => any) | undefined;
|
|
114
|
-
"on:compositionend"?: ((...ev: any[]) => any) | undefined;
|
|
115
|
-
compositionstart?: ((...ev: any[]) => any) | undefined;
|
|
116
|
-
"on:compositionstart"?: ((...ev: any[]) => any) | undefined;
|
|
117
|
-
compositionupdate?: ((...ev: any[]) => any) | undefined;
|
|
118
|
-
"on:compositionupdate"?: ((...ev: any[]) => any) | undefined;
|
|
119
|
-
contextlost?: ((...ev: any[]) => any) | undefined;
|
|
120
|
-
"on:contextlost"?: ((...ev: any[]) => any) | undefined;
|
|
121
|
-
contextmenu?: ((...ev: any[]) => any) | undefined;
|
|
122
|
-
"on:contextmenu"?: ((...ev: any[]) => any) | undefined;
|
|
123
|
-
contextrestored?: ((...ev: any[]) => any) | undefined;
|
|
124
|
-
"on:contextrestored"?: ((...ev: any[]) => any) | undefined;
|
|
125
|
-
copy?: ((...ev: any[]) => any) | undefined;
|
|
126
|
-
"on:copy"?: ((...ev: any[]) => any) | undefined;
|
|
127
|
-
cuechange?: ((...ev: any[]) => any) | undefined;
|
|
128
|
-
"on:cuechange"?: ((...ev: any[]) => any) | undefined;
|
|
129
|
-
cut?: ((...ev: any[]) => any) | undefined;
|
|
130
|
-
"on:cut"?: ((...ev: any[]) => any) | undefined;
|
|
131
|
-
dblclick?: ((...ev: any[]) => any) | undefined;
|
|
132
|
-
"on:dblclick"?: ((...ev: any[]) => any) | undefined;
|
|
133
|
-
drag?: ((...ev: any[]) => any) | undefined;
|
|
134
|
-
"on:drag"?: ((...ev: any[]) => any) | undefined;
|
|
135
|
-
dragend?: ((...ev: any[]) => any) | undefined;
|
|
136
|
-
"on:dragend"?: ((...ev: any[]) => any) | undefined;
|
|
137
|
-
dragenter?: ((...ev: any[]) => any) | undefined;
|
|
138
|
-
"on:dragenter"?: ((...ev: any[]) => any) | undefined;
|
|
139
|
-
dragleave?: ((...ev: any[]) => any) | undefined;
|
|
140
|
-
"on:dragleave"?: ((...ev: any[]) => any) | undefined;
|
|
141
|
-
dragover?: ((...ev: any[]) => any) | undefined;
|
|
142
|
-
"on:dragover"?: ((...ev: any[]) => any) | undefined;
|
|
143
|
-
dragstart?: ((...ev: any[]) => any) | undefined;
|
|
144
|
-
"on:dragstart"?: ((...ev: any[]) => any) | undefined;
|
|
145
|
-
drop?: ((...ev: any[]) => any) | undefined;
|
|
146
|
-
"on:drop"?: ((...ev: any[]) => any) | undefined;
|
|
147
|
-
durationchange?: ((...ev: any[]) => any) | undefined;
|
|
148
|
-
"on:durationchange"?: ((...ev: any[]) => any) | undefined;
|
|
149
|
-
emptied?: ((...ev: any[]) => any) | undefined;
|
|
150
|
-
"on:emptied"?: ((...ev: any[]) => any) | undefined;
|
|
151
|
-
ended?: ((...ev: any[]) => any) | undefined;
|
|
152
|
-
"on:ended"?: ((...ev: any[]) => any) | undefined;
|
|
153
|
-
error?: ((...ev: any[]) => any) | undefined;
|
|
154
|
-
"on:error"?: ((...ev: any[]) => any) | undefined;
|
|
155
|
-
focus?: ((...ev: any[]) => any) | undefined;
|
|
156
|
-
"on:focus"?: ((...ev: any[]) => any) | undefined;
|
|
157
|
-
focusin?: ((...ev: any[]) => any) | undefined;
|
|
158
|
-
"on:focusin"?: ((...ev: any[]) => any) | undefined;
|
|
159
|
-
focusout?: ((...ev: any[]) => any) | undefined;
|
|
160
|
-
"on:focusout"?: ((...ev: any[]) => any) | undefined;
|
|
161
|
-
formdata?: ((...ev: any[]) => any) | undefined;
|
|
162
|
-
"on:formdata"?: ((...ev: any[]) => any) | undefined;
|
|
163
|
-
gotpointercapture?: ((...ev: any[]) => any) | undefined;
|
|
164
|
-
"on:gotpointercapture"?: ((...ev: any[]) => any) | undefined;
|
|
165
|
-
invalid?: ((...ev: any[]) => any) | undefined;
|
|
166
|
-
"on:invalid"?: ((...ev: any[]) => any) | undefined;
|
|
167
|
-
keydown?: ((...ev: any[]) => any) | undefined;
|
|
168
|
-
"on:keydown"?: ((...ev: any[]) => any) | undefined;
|
|
169
|
-
keypress?: ((...ev: any[]) => any) | undefined;
|
|
170
|
-
"on:keypress"?: ((...ev: any[]) => any) | undefined;
|
|
171
|
-
keyup?: ((...ev: any[]) => any) | undefined;
|
|
172
|
-
"on:keyup"?: ((...ev: any[]) => any) | undefined;
|
|
173
|
-
load?: ((...ev: any[]) => any) | undefined;
|
|
174
|
-
"on:load"?: ((...ev: any[]) => any) | undefined;
|
|
175
|
-
loadeddata?: ((...ev: any[]) => any) | undefined;
|
|
176
|
-
"on:loadeddata"?: ((...ev: any[]) => any) | undefined;
|
|
177
|
-
loadedmetadata?: ((...ev: any[]) => any) | undefined;
|
|
178
|
-
"on:loadedmetadata"?: ((...ev: any[]) => any) | undefined;
|
|
179
|
-
loadstart?: ((...ev: any[]) => any) | undefined;
|
|
180
|
-
"on:loadstart"?: ((...ev: any[]) => any) | undefined;
|
|
181
|
-
lostpointercapture?: ((...ev: any[]) => any) | undefined;
|
|
182
|
-
"on:lostpointercapture"?: ((...ev: any[]) => any) | undefined;
|
|
183
|
-
mousedown?: ((...ev: any[]) => any) | undefined;
|
|
184
|
-
"on:mousedown"?: ((...ev: any[]) => any) | undefined;
|
|
185
|
-
mouseenter?: ((...ev: any[]) => any) | undefined;
|
|
186
|
-
"on:mouseenter"?: ((...ev: any[]) => any) | undefined;
|
|
187
|
-
mouseleave?: ((...ev: any[]) => any) | undefined;
|
|
188
|
-
"on:mouseleave"?: ((...ev: any[]) => any) | undefined;
|
|
189
|
-
mousemove?: ((...ev: any[]) => any) | undefined;
|
|
190
|
-
"on:mousemove"?: ((...ev: any[]) => any) | undefined;
|
|
191
|
-
mouseout?: ((...ev: any[]) => any) | undefined;
|
|
192
|
-
"on:mouseout"?: ((...ev: any[]) => any) | undefined;
|
|
193
|
-
mouseover?: ((...ev: any[]) => any) | undefined;
|
|
194
|
-
"on:mouseover"?: ((...ev: any[]) => any) | undefined;
|
|
195
|
-
mouseup?: ((...ev: any[]) => any) | undefined;
|
|
196
|
-
"on:mouseup"?: ((...ev: any[]) => any) | undefined;
|
|
197
|
-
paste?: ((...ev: any[]) => any) | undefined;
|
|
198
|
-
"on:paste"?: ((...ev: any[]) => any) | undefined;
|
|
199
|
-
pause?: ((...ev: any[]) => any) | undefined;
|
|
200
|
-
"on:pause"?: ((...ev: any[]) => any) | undefined;
|
|
201
|
-
play?: ((...ev: any[]) => any) | undefined;
|
|
202
|
-
"on:play"?: ((...ev: any[]) => any) | undefined;
|
|
203
|
-
playing?: ((...ev: any[]) => any) | undefined;
|
|
204
|
-
"on:playing"?: ((...ev: any[]) => any) | undefined;
|
|
205
|
-
pointercancel?: ((...ev: any[]) => any) | undefined;
|
|
206
|
-
"on:pointercancel"?: ((...ev: any[]) => any) | undefined;
|
|
207
|
-
pointerdown?: ((...ev: any[]) => any) | undefined;
|
|
208
|
-
"on:pointerdown"?: ((...ev: any[]) => any) | undefined;
|
|
209
|
-
pointerenter?: ((...ev: any[]) => any) | undefined;
|
|
210
|
-
"on:pointerenter"?: ((...ev: any[]) => any) | undefined;
|
|
211
|
-
pointerleave?: ((...ev: any[]) => any) | undefined;
|
|
212
|
-
"on:pointerleave"?: ((...ev: any[]) => any) | undefined;
|
|
213
|
-
pointermove?: ((...ev: any[]) => any) | undefined;
|
|
214
|
-
"on:pointermove"?: ((...ev: any[]) => any) | undefined;
|
|
215
|
-
pointerout?: ((...ev: any[]) => any) | undefined;
|
|
216
|
-
"on:pointerout"?: ((...ev: any[]) => any) | undefined;
|
|
217
|
-
pointerover?: ((...ev: any[]) => any) | undefined;
|
|
218
|
-
"on:pointerover"?: ((...ev: any[]) => any) | undefined;
|
|
219
|
-
pointerrawupdate?: ((...ev: any[]) => any) | undefined;
|
|
220
|
-
"on:pointerrawupdate"?: ((...ev: any[]) => any) | undefined;
|
|
221
|
-
pointerup?: ((...ev: any[]) => any) | undefined;
|
|
222
|
-
"on:pointerup"?: ((...ev: any[]) => any) | undefined;
|
|
223
|
-
ratechange?: ((...ev: any[]) => any) | undefined;
|
|
224
|
-
"on:ratechange"?: ((...ev: any[]) => any) | undefined;
|
|
225
|
-
reset?: ((...ev: any[]) => any) | undefined;
|
|
226
|
-
"on:reset"?: ((...ev: any[]) => any) | undefined;
|
|
227
|
-
scroll?: ((...ev: any[]) => any) | undefined;
|
|
228
|
-
"on:scroll"?: ((...ev: any[]) => any) | undefined;
|
|
229
|
-
scrollend?: ((...ev: any[]) => any) | undefined;
|
|
230
|
-
"on:scrollend"?: ((...ev: any[]) => any) | undefined;
|
|
231
|
-
securitypolicyviolation?: ((...ev: any[]) => any) | undefined;
|
|
232
|
-
"on:securitypolicyviolation"?: ((...ev: any[]) => any) | undefined;
|
|
233
|
-
seeked?: ((...ev: any[]) => any) | undefined;
|
|
234
|
-
"on:seeked"?: ((...ev: any[]) => any) | undefined;
|
|
235
|
-
seeking?: ((...ev: any[]) => any) | undefined;
|
|
236
|
-
"on:seeking"?: ((...ev: any[]) => any) | undefined;
|
|
237
|
-
selectionchange?: ((...ev: any[]) => any) | undefined;
|
|
238
|
-
"on:selectionchange"?: ((...ev: any[]) => any) | undefined;
|
|
239
|
-
selectstart?: ((...ev: any[]) => any) | undefined;
|
|
240
|
-
"on:selectstart"?: ((...ev: any[]) => any) | undefined;
|
|
241
|
-
slotchange?: ((...ev: any[]) => any) | undefined;
|
|
242
|
-
"on:slotchange"?: ((...ev: any[]) => any) | undefined;
|
|
243
|
-
stalled?: ((...ev: any[]) => any) | undefined;
|
|
244
|
-
"on:stalled"?: ((...ev: any[]) => any) | undefined;
|
|
245
|
-
submit?: ((...ev: any[]) => any) | undefined;
|
|
246
|
-
"on:submit"?: ((...ev: any[]) => any) | undefined;
|
|
247
|
-
suspend?: ((...ev: any[]) => any) | undefined;
|
|
248
|
-
"on:suspend"?: ((...ev: any[]) => any) | undefined;
|
|
249
|
-
timeupdate?: ((...ev: any[]) => any) | undefined;
|
|
250
|
-
"on:timeupdate"?: ((...ev: any[]) => any) | undefined;
|
|
251
|
-
touchcancel?: ((...ev: any[]) => any) | undefined;
|
|
252
|
-
"on:touchcancel"?: ((...ev: any[]) => any) | undefined;
|
|
253
|
-
touchend?: ((...ev: any[]) => any) | undefined;
|
|
254
|
-
"on:touchend"?: ((...ev: any[]) => any) | undefined;
|
|
255
|
-
touchmove?: ((...ev: any[]) => any) | undefined;
|
|
256
|
-
"on:touchmove"?: ((...ev: any[]) => any) | undefined;
|
|
257
|
-
touchstart?: ((...ev: any[]) => any) | undefined;
|
|
258
|
-
"on:touchstart"?: ((...ev: any[]) => any) | undefined;
|
|
259
|
-
transitioncancel?: ((...ev: any[]) => any) | undefined;
|
|
260
|
-
"on:transitioncancel"?: ((...ev: any[]) => any) | undefined;
|
|
261
|
-
transitionend?: ((...ev: any[]) => any) | undefined;
|
|
262
|
-
"on:transitionend"?: ((...ev: any[]) => any) | undefined;
|
|
263
|
-
transitionrun?: ((...ev: any[]) => any) | undefined;
|
|
264
|
-
"on:transitionrun"?: ((...ev: any[]) => any) | undefined;
|
|
265
|
-
transitionstart?: ((...ev: any[]) => any) | undefined;
|
|
266
|
-
"on:transitionstart"?: ((...ev: any[]) => any) | undefined;
|
|
267
|
-
volumechange?: ((...ev: any[]) => any) | undefined;
|
|
268
|
-
"on:volumechange"?: ((...ev: any[]) => any) | undefined;
|
|
269
|
-
waiting?: ((...ev: any[]) => any) | undefined;
|
|
270
|
-
"on:waiting"?: ((...ev: any[]) => any) | undefined;
|
|
271
|
-
webkitanimationend?: ((...ev: any[]) => any) | undefined;
|
|
272
|
-
"on:webkitanimationend"?: ((...ev: any[]) => any) | undefined;
|
|
273
|
-
webkitanimationiteration?: ((...ev: any[]) => any) | undefined;
|
|
274
|
-
"on:webkitanimationiteration"?: ((...ev: any[]) => any) | undefined;
|
|
275
|
-
webkitanimationstart?: ((...ev: any[]) => any) | undefined;
|
|
276
|
-
"on:webkitanimationstart"?: ((...ev: any[]) => any) | undefined;
|
|
277
|
-
webkittransitionend?: ((...ev: any[]) => any) | undefined;
|
|
278
|
-
"on:webkittransitionend"?: ((...ev: any[]) => any) | undefined;
|
|
279
|
-
wheel?: ((...ev: any[]) => any) | undefined;
|
|
280
|
-
"on:wheel"?: ((...ev: any[]) => any) | undefined;
|
|
281
|
-
connected?: ((...ev: any[]) => any) | undefined;
|
|
282
|
-
"on:connected"?: ((...ev: any[]) => any) | undefined;
|
|
283
|
-
disconnected?: ((...ev: any[]) => any) | undefined;
|
|
284
|
-
"on:disconnected"?: ((...ev: any[]) => any) | undefined;
|
|
285
|
-
} | ((arg0: DodoEvents<Dodo<HTMLElement>>) => void)) => Dodo<HTMLElement>) & DodoEvents<Dodo<HTMLElement>>;
|
|
57
|
+
style: ReturnType<typeof makeCallableInstance<typeof DodoStyles, "call", DodoStyles<this>>>;
|
|
58
|
+
class: ReturnType<typeof makeCallableInstance<typeof DodoClasses, "call", DodoClasses<this>>>;
|
|
59
|
+
events: ReturnType<typeof makeCallableInstance<typeof DodoEvents, "call", DodoEvents<this>>>;
|
|
286
60
|
constructor(element: ElementName | Extractable);
|
|
287
61
|
update(update: KiwiUpdate): this;
|
|
288
62
|
use(plugins: ((node: this) => void)[]): this;
|
package/dist/dodo.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dodo.mjs","names":["KiwiUtil"],"sources":["../src/dodo.ts"],"sourcesContent":["import {\r\n\ttype KiwiItem,\r\n\ttype KiwiUpdate,\r\n\tBase_Kiwi,\r\n\tBase_KiwiClasses,\r\n\tBase_KiwiStyles,\r\n\tElementName,\r\n\tUtil as KiwiUtil,\r\n\tStyleDeclaration,\r\n\tStyleDeclarationPlus,\r\n} from \"@orago/kiwi\";\r\nimport { Emitter } from \"@orago/lib\";\r\nimport { DodoEvents } from \"./dodo-events.js\";\r\nimport { makeCallableInstance } from \"./util/class.util.js\";\r\nimport { DodoGlobalPlugins } from \"./util/plugins-support.js\";\r\n\r\ntype Extractable = Dodo | KiwiItem | { element: HTMLElement } | Node;\r\ntype AppendableItem = Extractable | string | number;\r\ntype Appendable = AppendableItem | boolean | null | undefined;\r\nexport type ChildList = (Appendable | Appendable[])[];\r\n\r\nexport type ResolveElement<Input extends ElementName | Extractable> =\r\n\tInput extends keyof HTMLElementTagNameMap\r\n\t\t? HTMLElementTagNameMap[Input]\r\n\t\t: Input extends HTMLElement\r\n\t\t\t? Input\r\n\t\t\t: Input extends Dodo\r\n\t\t\t\t? Input[\"element\"]\r\n\t\t\t\t: HTMLElement;\r\n\r\nclass DodoStyles<N extends Dodo> extends Base_KiwiStyles {\r\n\tconstructor(public instance: N) {\r\n\t\tsuper();\r\n\t}\r\n\r\n\tpublic nest(run: (arg0: this) => void): this[\"instance\"] {\r\n\t\trun(this);\r\n\t\treturn this.instance;\r\n\t}\r\n\r\n\tpublic call(styles: StyleDeclarationPlus): N;\r\n\tpublic call(value: (arg0: this) => void): N;\r\n\tpublic call(value: StyleDeclarationPlus | ((arg0: this) => void) = {}): N {\r\n\t\tif (typeof value == \"object\") {\r\n\t\t\treturn this.update(value).instance;\r\n\t\t} else if (typeof value == \"function\") {\r\n\t\t\treturn this.nest(value);\r\n\t\t}\r\n\r\n\t\treturn this.instance;\r\n\t}\r\n\r\n\tpublic get(): StyleDeclaration {\r\n\t\tconst style = this.instance.element.style;\r\n\r\n\t\treturn Object.fromEntries(\r\n\t\t\tArray.from(style).map((name) => [\r\n\t\t\t\tname,\r\n\t\t\t\tstyle.getPropertyValue(name),\r\n\t\t\t]),\r\n\t\t);\r\n\t}\r\n\r\n\tupdate(styles: StyleDeclarationPlus): this {\r\n\t\tKiwiUtil.setStyles(styles, (key, value) => {\r\n\t\t\tthis.instance.element.style.setProperty(\r\n\t\t\t\tKiwiUtil.formatAttributeName(\"kebab\", key),\r\n\t\t\t\tvalue,\r\n\t\t\t);\r\n\t\t});\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\tremove(...styles: string[]): this {\r\n\t\tfor (const key of styles) {\r\n\t\t\tthis.instance.element.style.removeProperty(\r\n\t\t\t\tKiwiUtil.formatAttributeName(\"kebab\", key),\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t}\r\n}\r\n\r\nclass DodoClasses<N extends Dodo> extends Base_KiwiClasses {\r\n\tconstructor(public instance: N) {\r\n\t\tsuper();\r\n\t}\r\n\r\n\tpublic nest(run: (arg0: this) => void): this[\"instance\"] {\r\n\t\trun(this);\r\n\t\treturn this.instance;\r\n\t}\r\n\r\n\tpublic call(...classes: string[]): N;\r\n\tpublic call(nest: (arg0: this) => void): N;\r\n\tpublic call(...value: string[] | [(arg0: this) => void]): N {\r\n\t\tlet [first] = value;\r\n\r\n\t\tif (typeof first == \"string\") {\r\n\t\t\treturn this.set(...(value as string[])).instance;\r\n\t\t} else if (typeof first == \"function\") {\r\n\t\t\treturn this.nest(first);\r\n\t\t}\r\n\r\n\t\treturn this.instance;\r\n\t}\r\n\r\n\tpublic get(): string[] {\r\n\t\treturn Array.from(this.instance.element.classList);\r\n\t}\r\n\r\n\thas(...classes: string[]): boolean {\r\n\t\treturn classes.every((classname) =>\r\n\t\t\tthis.instance.element.classList.contains(classname),\r\n\t\t);\r\n\t}\r\n\r\n\tadd(...classes: string[]): this {\r\n\t\tthis.instance.element.classList.add(...KiwiUtil.formatClasses(classes));\r\n\t\treturn this;\r\n\t}\r\n\r\n\tremove(...classes: string[]): this {\r\n\t\tthis.instance.element.classList.remove(\r\n\t\t\t...KiwiUtil.formatClasses(classes),\r\n\t\t);\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\tset(...classes: string[]): this {\r\n\t\tthis.instance.element.className =\r\n\t\t\tKiwiUtil.formatClasses(classes).join(\" \");\r\n\t\treturn this;\r\n\t}\r\n\r\n\ttoggle(classes: string | string[], status: boolean): this {\r\n\t\tconst list = Array.isArray(classes) ? classes : [classes];\r\n\t\tif (status) {\r\n\t\t\tthis.add(...list);\r\n\t\t} else {\r\n\t\t\tthis.remove(...list);\r\n\t\t}\r\n\t\treturn this;\r\n\t}\r\n}\r\n\r\nclass DodoUtil {\r\n\tpublic static fromDataItem(\r\n\t\titem: Omit<KiwiItem, \"children\"> & { children: ChildList },\r\n\t) {\r\n\t\tconst instance = new Dodo(item.tag).update(item.update);\r\n\t\tinstance.append(...DodoUtil.flattenElements(item.children));\r\n\t\treturn instance;\r\n\t}\r\n\r\n\tpublic static extractElement(a: Extractable): HTMLElement {\r\n\t\tif (\"element\" in a) {\r\n\t\t\treturn a.element;\r\n\t\t} else if (a instanceof Dodo) {\r\n\t\t\treturn a.element;\r\n\t\t} else if (\"tag\" in a && \"update\" in a && \"children\" in a) {\r\n\t\t\treturn DodoUtil.fromDataItem(a).element;\r\n\t\t} else {\r\n\t\t\treturn a as HTMLElement;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic static forceElement(a: AppendableItem) {\r\n\t\tif (\r\n\t\t\ttypeof a == \"number\" ||\r\n\t\t\ttypeof a == \"boolean\" ||\r\n\t\t\ttypeof a == \"string\"\r\n\t\t) {\r\n\t\t\treturn document.createTextNode(String(a)) as unknown as HTMLElement;\r\n\t\t} else {\r\n\t\t\treturn DodoUtil.extractElement(a);\r\n\t\t}\r\n\t}\r\n\r\n\tpublic static flattenElements(contents: ChildList): HTMLElement[] {\r\n\t\treturn contents\r\n\t\t\t.flat()\r\n\t\t\t.filter((content) => content != undefined && content !== false)\r\n\t\t\t.map((a) => {\r\n\t\t\t\tif (a == true) a = \"true\";\r\n\t\t\t\treturn DodoUtil.forceElement(a);\r\n\t\t\t});\r\n\t}\r\n\r\n\tpublic static injectItems<T extends HTMLElement>(\r\n\t\tnode: T,\r\n\t\tdirection: \"append\" | \"prepend\" = \"append\",\r\n\t\tobjs: ChildList,\r\n\t): void {\r\n\t\tif (objs.length < 1) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst items = this.flattenElements(objs);\r\n\r\n\t\tfor (const item of items) {\r\n\t\t\tconst extracted =\r\n\t\t\t\ttypeof item === \"string\" ? item : DodoUtil.forceElement(item);\r\n\r\n\t\t\tif (direction === \"append\") {\r\n\t\t\t\tnode.append(extracted);\r\n\t\t\t} else {\r\n\t\t\t\tnode.prepend(extracted);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunction oo<T extends ElementName>(\r\n\ttag: T,\r\n\tprops?: KiwiUpdate | null,\r\n\t...children: ChildList\r\n): Dodo {\r\n\treturn DodoUtil.fromDataItem({\r\n\t\ttag,\r\n\t\tupdate: props ?? {},\r\n\t\tchildren,\r\n\t});\r\n}\r\n\r\n/**\r\n * client sided mode for Orago's-Dom-Libary\r\n */\r\nclass Dodo<H extends HTMLElement = HTMLElement> extends Base_Kiwi {\r\n\tstatic oo = oo;\r\n\tstatic plugins = new DodoGlobalPlugins();\r\n\tpublic static events: Emitter<\r\n\t\t{\r\n\t\t\tinit: (node: Dodo) => void;\r\n\t\t},\r\n\t\ttrue\r\n\t> = new Emitter();\r\n\r\n\telement!: H;\r\n\r\n\tstyle = makeCallableInstance(DodoStyles, [this], \"call\");\r\n\tclass = makeCallableInstance(DodoClasses, [this], \"call\");\r\n\tevents = makeCallableInstance(DodoEvents, [this], \"call\");\r\n\r\n\tconstructor(element: ElementName | Extractable) {\r\n\t\tsuper();\r\n\r\n\t\tif (typeof element === \"string\") {\r\n\t\t\tthis.element = document.createElement(element) as any;\r\n\t\t} else {\r\n\t\t\tthis.element = DodoUtil.extractElement(element) as any;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic update(update: KiwiUpdate): this {\r\n\t\tif (update.id != undefined) {\r\n\t\t\tthis.id(update.id);\r\n\t\t}\r\n\t\tif (update.attributes != undefined) {\r\n\t\t\tthis.attr(update.attributes);\r\n\t\t}\r\n\t\tif (update.dataset != undefined) {\r\n\t\t\tthis.dataset(update.dataset);\r\n\t\t}\r\n\t\tif (update.styles != undefined) {\r\n\t\t\tthis.style(update.styles);\r\n\t\t}\r\n\t\tif (update.classes != undefined) {\r\n\t\t\tthis.class.add(...update.classes);\r\n\t\t}\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic use(plugins: ((node: this) => void)[]): this {\r\n\t\tfor (const plugin of plugins) {\r\n\t\t\tplugin(this);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic attr(\r\n\t\tattributes: Partial<Record<string & {}, string | number>> = {},\r\n\t): this {\r\n\t\tKiwiUtil.setAttributes(\r\n\t\t\tattributes,\r\n\t\t\t(key, value) => this.element.setAttribute(key, value),\r\n\t\t\t(key) => this.element.removeAttribute(key),\r\n\t\t);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic dataset(): Partial<Record<string, string>>;\r\n\tpublic dataset(record: \"clear\" | Partial<Record<string, string>>): this;\r\n\tpublic dataset(record?: \"clear\" | Partial<Record<string, string>>): any {\r\n\t\tif (record == undefined) {\r\n\t\t\treturn this.element.dataset;\r\n\t\t}\r\n\r\n\t\tif (record == \"clear\") {\r\n\t\t\treturn this.dataset(\r\n\t\t\t\tObject.fromEntries(\r\n\t\t\t\t\tObject.keys(this.element.dataset).map((key) => [\r\n\t\t\t\t\t\tKiwiUtil.formatAttributeName(\"camel\", key),\r\n\t\t\t\t\t\tundefined,\r\n\t\t\t\t\t]),\r\n\t\t\t\t),\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tfor (let [key, value] of Object.entries(record)) {\r\n\t\t\tkey = KiwiUtil.formatAttributeName(\"camel\", key);\r\n\t\t\tif (value == undefined) {\r\n\t\t\t\tdelete this.element.dataset[key];\r\n\t\t\t} else {\r\n\t\t\t\tthis.element.dataset[key] = value;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic append(...input: ChildList): this {\r\n\t\tDodoUtil.injectItems(this.element, \"append\", input);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic prepend(...input: ChildList): this {\r\n\t\tDodoUtil.injectItems(this.element, \"prepend\", input);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tprotected $IdGet(): string {\r\n\t\treturn this.element.id;\r\n\t}\r\n\r\n\tprotected $IdSet(value: string): void {\r\n\t\tthis.element.id = value;\r\n\t}\r\n\r\n\tprotected $ValueGet(): string {\r\n\t\tif (\r\n\t\t\tthis.element instanceof HTMLInputElement ||\r\n\t\t\tthis.element instanceof HTMLSelectElement\r\n\t\t) {\r\n\t\t\treturn this.element.value;\r\n\t\t} else if (this.element instanceof HTMLImageElement) {\r\n\t\t\treturn this.element.src;\r\n\t\t} else {\r\n\t\t\treturn this.element.textContent;\r\n\t\t}\r\n\t}\r\n\r\n\tprotected $ValueSet(value: string): this {\r\n\t\tif (\r\n\t\t\tthis.element instanceof HTMLInputElement ||\r\n\t\t\tthis.element instanceof HTMLSelectElement\r\n\t\t) {\r\n\t\t\tthis.element.value = value.toString();\r\n\t\t} else if (this.element instanceof HTMLImageElement) {\r\n\t\t\tthis.element.src = value.toString();\r\n\t\t} else {\r\n\t\t\tthis.element.textContent = value.toString();\r\n\t\t}\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic clear(): this {\r\n\t\tthis.element.innerHTML = \"\";\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic content(...input: ChildList): this {\r\n\t\tthis.clear().append(...input);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic getBounds() {\r\n\t\treturn this.element.getBoundingClientRect();\r\n\t}\r\n}\r\n\r\nexport { Dodo, DodoUtil, oo, type Appendable, type Extractable };\r\n"],"mappings":"6SA8BA,IAAM,EAAN,cAAyC,CAAgB,CACxD,YAAY,EAAoB,CAC/B,MAAM,EADY,KAAA,SAAA,CAEnB,CAEA,KAAY,EAA6C,CAExD,OADA,EAAI,IAAI,EACD,KAAK,QACb,CAIA,KAAY,EAAuD,CAAC,EAAM,CAOzE,OANI,OAAO,GAAS,SACZ,KAAK,OAAO,CAAK,CAAC,CAAC,SAChB,OAAO,GAAS,WACnB,KAAK,KAAK,CAAK,EAGhB,KAAK,QACb,CAEA,KAA+B,CAC9B,IAAM,EAAQ,KAAK,SAAS,QAAQ,MAEpC,OAAO,OAAO,YACb,MAAM,KAAK,CAAK,CAAC,CAAC,IAAK,GAAS,CAC/B,EACA,EAAM,iBAAiB,CAAI,CAC5B,CAAC,CACF,CACD,CAEA,OAAO,EAAoC,CAQ1C,OAPA,EAAS,UAAU,GAAS,EAAK,IAAU,CAC1C,KAAK,SAAS,QAAQ,MAAM,YAC3BA,EAAS,oBAAoB,QAAS,CAAG,EACzC,CACD,CACD,CAAC,EAEM,IACR,CAEA,OAAO,GAAG,EAAwB,CACjC,IAAK,IAAM,KAAO,EACjB,KAAK,SAAS,QAAQ,MAAM,eAC3BA,EAAS,oBAAoB,QAAS,CAAG,CAC1C,EAGD,OAAO,IACR,CACD,EAEM,EAAN,cAA0C,CAAiB,CAC1D,YAAY,EAAoB,CAC/B,MAA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B,kBAEjB,KAAK,QAAQ,MACV,KAAK,mBAAmB,iBAC3B,KAAK,QAAQ,IAEb,KAAK,QAAQ,WAEtB,CAEA,UAAoB,EAAqB,CAWxC,OATC,KAAK,mBAAmB,kBACxB,KAAK,mBAAmB,kBAExB,KAAK,QAAQ,MAAQ,EAAM,SAAS,EAC1B,KAAK,mBAAmB,iBAClC,KAAK,QAAQ,IAAM,EAAM,SAAS,EAElC,KAAK,QAAQ,YAAc,EAAM,SAAS,EAEpC,IACR,CAEA,OAAqB,CAEpB,MADA,MAAK,QAAQ,UAAY,GAClB,IACR,CAEA,QAAe,GAAG,EAAwB,CAEzC,OADA,KAAK,MAAM,CAAC,CAAC,OAAO,GAAG,CAAK,EACrB,IACR,CAEA,WAAmB,CAClB,OAAO,KAAK,QAAQ,sBAAsB,CAC3C,CACD"}
|
|
1
|
+
{"version":3,"file":"dodo.mjs","names":["KiwiUtil"],"sources":["../src/dodo.ts"],"sourcesContent":["import {\r\n\ttype KiwiItem,\r\n\ttype KiwiUpdate,\r\n\tBase_Kiwi,\r\n\tBase_KiwiClasses,\r\n\tBase_KiwiStyles,\r\n\tElementName,\r\n\tUtil as KiwiUtil,\r\n\tStyleDeclaration,\r\n\tStyleDeclarationPlus,\r\n} from \"@orago/kiwi\";\r\nimport { Emitter } from \"@orago/lib\";\r\nimport { DodoEvents } from \"./dodo-events.js\";\r\nimport { makeCallableInstance } from \"./util/class.util.js\";\r\nimport { DodoGlobalPlugins } from \"./util/plugins-support.js\";\r\n\r\ntype Extractable = Dodo | KiwiItem | { element: HTMLElement } | Node;\r\ntype AppendableItem = Extractable | string | number;\r\ntype Appendable = AppendableItem | boolean | null | undefined;\r\nexport type ChildList = (Appendable | Appendable[])[];\r\n\r\nexport type ResolveElement<Input extends ElementName | Extractable> =\r\n\tInput extends keyof HTMLElementTagNameMap\r\n\t\t? HTMLElementTagNameMap[Input]\r\n\t\t: Input extends HTMLElement\r\n\t\t\t? Input\r\n\t\t\t: Input extends Dodo\r\n\t\t\t\t? Input[\"element\"]\r\n\t\t\t\t: HTMLElement;\r\n\r\nclass DodoStyles<N extends Dodo> extends Base_KiwiStyles {\r\n\tconstructor(public instance: N) {\r\n\t\tsuper();\r\n\t}\r\n\r\n\tpublic nest(run: (arg0: this) => void): this[\"instance\"] {\r\n\t\trun(this);\r\n\t\treturn this.instance;\r\n\t}\r\n\r\n\tpublic call(styles: StyleDeclarationPlus): N;\r\n\tpublic call(value: (arg0: this) => void): N;\r\n\tpublic call(value: StyleDeclarationPlus | ((arg0: this) => void) = {}): N {\r\n\t\tif (typeof value == \"object\") {\r\n\t\t\treturn this.update(value).instance;\r\n\t\t} else if (typeof value == \"function\") {\r\n\t\t\treturn this.nest(value);\r\n\t\t}\r\n\r\n\t\treturn this.instance;\r\n\t}\r\n\r\n\tpublic get(): StyleDeclaration {\r\n\t\tconst style = this.instance.element.style;\r\n\r\n\t\treturn Object.fromEntries(\r\n\t\t\tArray.from(style).map((name) => [\r\n\t\t\t\tname,\r\n\t\t\t\tstyle.getPropertyValue(name),\r\n\t\t\t]),\r\n\t\t);\r\n\t}\r\n\r\n\tupdate(styles: StyleDeclarationPlus): this {\r\n\t\tKiwiUtil.setStyles(styles, (key, value) => {\r\n\t\t\tthis.instance.element.style.setProperty(\r\n\t\t\t\tKiwiUtil.formatAttributeName(\"kebab\", key),\r\n\t\t\t\tvalue,\r\n\t\t\t);\r\n\t\t});\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\tremove(...styles: string[]): this {\r\n\t\tfor (const key of styles) {\r\n\t\t\tthis.instance.element.style.removeProperty(\r\n\t\t\t\tKiwiUtil.formatAttributeName(\"kebab\", key),\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t}\r\n}\r\n\r\nclass DodoClasses<N extends Dodo> extends Base_KiwiClasses {\r\n\tconstructor(public instance: N) {\r\n\t\tsuper();\r\n\t}\r\n\r\n\tpublic nest(run: (arg0: this) => void): this[\"instance\"] {\r\n\t\trun(this);\r\n\t\treturn this.instance;\r\n\t}\r\n\r\n\tpublic call(...classes: string[]): N;\r\n\tpublic call(nest: (arg0: this) => void): N;\r\n\tpublic call(...value: string[] | [(arg0: this) => void]): N {\r\n\t\tlet [first] = value;\r\n\r\n\t\tif (typeof first == \"string\") {\r\n\t\t\treturn this.set(...(value as string[])).instance;\r\n\t\t} else if (typeof first == \"function\") {\r\n\t\t\treturn this.nest(first);\r\n\t\t}\r\n\r\n\t\treturn this.instance;\r\n\t}\r\n\r\n\tpublic get(): string[] {\r\n\t\treturn Array.from(this.instance.element.classList);\r\n\t}\r\n\r\n\thas(...classes: string[]): boolean {\r\n\t\treturn classes.every((classname) =>\r\n\t\t\tthis.instance.element.classList.contains(classname),\r\n\t\t);\r\n\t}\r\n\r\n\tadd(...classes: string[]): this {\r\n\t\tthis.instance.element.classList.add(...KiwiUtil.formatClasses(classes));\r\n\t\treturn this;\r\n\t}\r\n\r\n\tremove(...classes: string[]): this {\r\n\t\tthis.instance.element.classList.remove(\r\n\t\t\t...KiwiUtil.formatClasses(classes),\r\n\t\t);\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\tset(...classes: string[]): this {\r\n\t\tthis.instance.element.className =\r\n\t\t\tKiwiUtil.formatClasses(classes).join(\" \");\r\n\t\treturn this;\r\n\t}\r\n\r\n\ttoggle(classes: string | string[], status: boolean): this {\r\n\t\tconst list = Array.isArray(classes) ? classes : [classes];\r\n\t\tif (status) {\r\n\t\t\tthis.add(...list);\r\n\t\t} else {\r\n\t\t\tthis.remove(...list);\r\n\t\t}\r\n\t\treturn this;\r\n\t}\r\n}\r\n\r\nclass DodoUtil {\r\n\tpublic static fromDataItem(\r\n\t\titem: Omit<KiwiItem, \"children\"> & { children: ChildList },\r\n\t) {\r\n\t\tconst instance = new Dodo(item.tag).update(item.update);\r\n\t\tinstance.append(...DodoUtil.flattenElements(item.children));\r\n\t\treturn instance;\r\n\t}\r\n\r\n\tpublic static extractElement(a: Extractable): HTMLElement {\r\n\t\tif (\"element\" in a) {\r\n\t\t\treturn a.element;\r\n\t\t} else if (a instanceof Dodo) {\r\n\t\t\treturn a.element;\r\n\t\t} else if (\"tag\" in a && \"update\" in a && \"children\" in a) {\r\n\t\t\treturn DodoUtil.fromDataItem(a).element;\r\n\t\t} else {\r\n\t\t\treturn a as HTMLElement;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic static forceElement(a: AppendableItem) {\r\n\t\tif (\r\n\t\t\ttypeof a == \"number\" ||\r\n\t\t\ttypeof a == \"boolean\" ||\r\n\t\t\ttypeof a == \"string\"\r\n\t\t) {\r\n\t\t\treturn document.createTextNode(String(a)) as unknown as HTMLElement;\r\n\t\t} else {\r\n\t\t\treturn DodoUtil.extractElement(a);\r\n\t\t}\r\n\t}\r\n\r\n\tpublic static flattenElements(contents: ChildList): HTMLElement[] {\r\n\t\treturn contents\r\n\t\t\t.flat()\r\n\t\t\t.filter((content) => content != undefined && content !== false)\r\n\t\t\t.map((a) => {\r\n\t\t\t\tif (a == true) a = \"true\";\r\n\t\t\t\treturn DodoUtil.forceElement(a);\r\n\t\t\t});\r\n\t}\r\n\r\n\tpublic static injectItems<T extends HTMLElement>(\r\n\t\tnode: T,\r\n\t\tdirection: \"append\" | \"prepend\" = \"append\",\r\n\t\tobjs: ChildList,\r\n\t): void {\r\n\t\tif (objs.length < 1) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst items = this.flattenElements(objs);\r\n\r\n\t\tfor (const item of items) {\r\n\t\t\tconst extracted =\r\n\t\t\t\ttypeof item === \"string\" ? item : DodoUtil.forceElement(item);\r\n\r\n\t\t\tif (direction === \"append\") {\r\n\t\t\t\tnode.append(extracted);\r\n\t\t\t} else {\r\n\t\t\t\tnode.prepend(extracted);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunction oo<T extends ElementName>(\r\n\ttag: T,\r\n\tprops?: KiwiUpdate | null,\r\n\t...children: ChildList\r\n): Dodo {\r\n\treturn DodoUtil.fromDataItem({\r\n\t\ttag,\r\n\t\tupdate: props ?? {},\r\n\t\tchildren,\r\n\t});\r\n}\r\n\r\n/**\r\n * client sided mode for Orago's-Dom-Libary\r\n */\r\nclass Dodo<H extends HTMLElement = HTMLElement> extends Base_Kiwi {\r\n\tstatic oo = oo;\r\n\tstatic plugins = new DodoGlobalPlugins();\r\n\tpublic static events: Emitter<\r\n\t\t{\r\n\t\t\tinit: (node: Dodo) => void;\r\n\t\t},\r\n\t\ttrue\r\n\t> = new Emitter();\r\n\r\n\telement!: H;\r\n\r\n\tpublic style: ReturnType<\r\n\t\ttypeof makeCallableInstance<typeof DodoStyles, \"call\", DodoStyles<this>>\r\n\t> = makeCallableInstance(DodoStyles, [this], \"call\");\r\n\tclass: ReturnType<\r\n\t\ttypeof makeCallableInstance<\r\n\t\t\ttypeof DodoClasses,\r\n\t\t\t\"call\",\r\n\t\t\tDodoClasses<this>\r\n\t\t>\r\n\t> = makeCallableInstance(DodoClasses, [this], \"call\");\r\n\tevents: ReturnType<\r\n\t\ttypeof makeCallableInstance<typeof DodoEvents, \"call\", DodoEvents<this>>\r\n\t> = makeCallableInstance(DodoEvents, [this], \"call\");\r\n\r\n\tconstructor(element: ElementName | Extractable) {\r\n\t\tsuper();\r\n\r\n\t\tif (typeof element === \"string\") {\r\n\t\t\tthis.element = document.createElement(element) as any;\r\n\t\t} else {\r\n\t\t\tthis.element = DodoUtil.extractElement(element) as any;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic update(update: KiwiUpdate): this {\r\n\t\tif (update.id != undefined) {\r\n\t\t\tthis.id(update.id);\r\n\t\t}\r\n\t\tif (update.attributes != undefined) {\r\n\t\t\tthis.attr(update.attributes);\r\n\t\t}\r\n\t\tif (update.dataset != undefined) {\r\n\t\t\tthis.dataset(update.dataset);\r\n\t\t}\r\n\t\tif (update.styles != undefined) {\r\n\t\t\tthis.style(update.styles);\r\n\t\t}\r\n\t\tif (update.classes != undefined) {\r\n\t\t\tthis.class.add(...update.classes);\r\n\t\t}\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic use(plugins: ((node: this) => void)[]): this {\r\n\t\tfor (const plugin of plugins) {\r\n\t\t\tplugin(this);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic attr(\r\n\t\tattributes: Partial<Record<string & {}, string | number>> = {},\r\n\t): this {\r\n\t\tKiwiUtil.setAttributes(\r\n\t\t\tattributes,\r\n\t\t\t(key, value) => this.element.setAttribute(key, value),\r\n\t\t\t(key) => this.element.removeAttribute(key),\r\n\t\t);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic dataset(): Partial<Record<string, string>>;\r\n\tpublic dataset(record: \"clear\" | Partial<Record<string, string>>): this;\r\n\tpublic dataset(record?: \"clear\" | Partial<Record<string, string>>): any {\r\n\t\tif (record == undefined) {\r\n\t\t\treturn this.element.dataset;\r\n\t\t}\r\n\r\n\t\tif (record == \"clear\") {\r\n\t\t\treturn this.dataset(\r\n\t\t\t\tObject.fromEntries(\r\n\t\t\t\t\tObject.keys(this.element.dataset).map((key) => [\r\n\t\t\t\t\t\tKiwiUtil.formatAttributeName(\"camel\", key),\r\n\t\t\t\t\t\tundefined,\r\n\t\t\t\t\t]),\r\n\t\t\t\t),\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tfor (let [key, value] of Object.entries(record)) {\r\n\t\t\tkey = KiwiUtil.formatAttributeName(\"camel\", key);\r\n\t\t\tif (value == undefined) {\r\n\t\t\t\tdelete this.element.dataset[key];\r\n\t\t\t} else {\r\n\t\t\t\tthis.element.dataset[key] = value;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic append(...input: ChildList): this {\r\n\t\tDodoUtil.injectItems(this.element, \"append\", input);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic prepend(...input: ChildList): this {\r\n\t\tDodoUtil.injectItems(this.element, \"prepend\", input);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tprotected $IdGet(): string {\r\n\t\treturn this.element.id;\r\n\t}\r\n\r\n\tprotected $IdSet(value: string): void {\r\n\t\tthis.element.id = value;\r\n\t}\r\n\r\n\tprotected $ValueGet(): string {\r\n\t\tif (\r\n\t\t\tthis.element instanceof HTMLInputElement ||\r\n\t\t\tthis.element instanceof HTMLSelectElement\r\n\t\t) {\r\n\t\t\treturn this.element.value;\r\n\t\t} else if (this.element instanceof HTMLImageElement) {\r\n\t\t\treturn this.element.src;\r\n\t\t} else {\r\n\t\t\treturn this.element.textContent;\r\n\t\t}\r\n\t}\r\n\r\n\tprotected $ValueSet(value: string): this {\r\n\t\tif (\r\n\t\t\tthis.element instanceof HTMLInputElement ||\r\n\t\t\tthis.element instanceof HTMLSelectElement\r\n\t\t) {\r\n\t\t\tthis.element.value = value.toString();\r\n\t\t} else if (this.element instanceof HTMLImageElement) {\r\n\t\t\tthis.element.src = value.toString();\r\n\t\t} else {\r\n\t\t\tthis.element.textContent = value.toString();\r\n\t\t}\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic clear(): this {\r\n\t\tthis.element.innerHTML = \"\";\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic content(...input: ChildList): this {\r\n\t\tthis.clear().append(...input);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic getBounds() {\r\n\t\treturn this.element.getBoundingClientRect();\r\n\t}\r\n}\r\n\r\nexport { Dodo, DodoUtil, oo, type Appendable, type Extractable };\r\n"],"mappings":"6SA8BA,IAAM,EAAN,cAAyC,CAAgB,CACxD,YAAY,EAAoB,CAC/B,MAAM,EADY,KAAA,SAAA,CAEnB,CAEA,KAAY,EAA6C,CAExD,OADA,EAAI,IAAI,EACD,KAAK,QACb,CAIA,KAAY,EAAuD,CAAC,EAAM,CAOzE,OANI,OAAO,GAAS,SACZ,KAAK,OAAO,CAAK,CAAC,CAAC,SAChB,OAAO,GAAS,WACnB,KAAK,KAAK,CAAK,EAGhB,KAAK,QACb,CAEA,KAA+B,CAC9B,IAAM,EAAQ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K,GAAI,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAM,EAC7C,EAAMA,EAAS,oBAAoB,QAAS,CAAG,EAC3C,GAAS,KACZ,OAAO,KAAK,QAAQ,QAAQ,GAE5B,KAAK,QAAQ,QAAQ,GAAO,EAG9B,OAAO,IACR,CAEA,OAAc,GAAG,EAAwB,CAExC,OADA,EAAS,YAAY,KAAK,QAAS,SAAU,CAAK,EAC3C,IACR,CAEA,QAAe,GAAG,EAAwB,CAEzC,OADA,EAAS,YAAY,KAAK,QAAS,UAAW,CAAK,EAC5C,IACR,CAEA,QAA2B,CAC1B,OAAO,KAAK,QAAQ,EACrB,CAEA,OAAiB,EAAqB,CACrC,KAAK,QAAQ,GAAK,CACnB,CAEA,WAA8B,CAS5B,OAPA,KAAK,mBAAmB,kBACxB,KAAK,mBAAmB,kBAEjB,KAAK,QAAQ,MACV,KAAK,mBAAmB,iBAC3B,KAAK,QAAQ,IAEb,KAAK,QAAQ,WAEtB,CAEA,UAAoB,EAAqB,CAWxC,OATC,KAAK,mBAAmB,kBACxB,KAAK,mBAAmB,kBAExB,KAAK,QAAQ,MAAQ,EAAM,SAAS,EAC1B,KAAK,mBAAmB,iBAClC,KAAK,QAAQ,IAAM,EAAM,SAAS,EAElC,KAAK,QAAQ,YAAc,EAAM,SAAS,EAEpC,IACR,CAEA,OAAqB,CAEpB,MADA,MAAK,QAAQ,UAAY,GAClB,IACR,CAEA,QAAe,GAAG,EAAwB,CAEzC,OADA,KAAK,MAAM,CAAC,CAAC,OAAO,GAAG,CAAK,EACrB,IACR,CAEA,WAAmB,CAClB,OAAO,KAAK,QAAQ,sBAAsB,CAC3C,CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.util.cjs","names":[],"sources":["../../src/util/class.util.ts"],"sourcesContent":["type OverloadedCallable<T> = T extends (...args: any[]) => any\r\n\t? T\r\n\t: T extends { (...args: any[]): any }\r\n\t\t? T\r\n\t\t: never;\r\n\r\ntype CallableInstance<\r\n\tTClass extends InstanceType<new (...args: any[]) => any>,\r\n\tK extends keyof TClass,\r\n> = TClass extends { [P in K]: infer F }\r\n\t? OverloadedCallable<F> & TClass\r\n\t: never;\r\n\r\ntype CallableInstanceFn<\r\n\tTClass extends InstanceType<new (...args: any[]) => any>,\r\n\tFN extends (...args: any[]) => any,\r\n> = OverloadedCallable<FN> & TClass;\r\n\r\nfunction withCalling<\r\n\tTClass extends new (...args: any[]) => any,\r\n\tTInstance extends InstanceType<TClass>,\r\n\tFN extends (...args: any[]) => any,\r\n>(instance: TInstance, callback: FN): CallableInstanceFn<TInstance, FN> {\r\n\tconst callable = callback as CallableInstanceFn<TInstance, FN>;\r\n\tObject.setPrototypeOf(callable, instance.constructor.prototype);\r\n\tObject.assign(callable, instance);\r\n\treturn callable;\r\n}\r\n\r\nfunction makeCallableInstance<\r\n\tTClass extends new (...args: any[]) => any,\r\n\tK extends keyof InstanceType<TClass>,\r\n>(\r\n\tClass: TClass,\r\n\targs: ConstructorParameters<TClass>,\r\n\tinvoke: K,\r\n): CallableInstance<
|
|
1
|
+
{"version":3,"file":"class.util.cjs","names":[],"sources":["../../src/util/class.util.ts"],"sourcesContent":["type OverloadedCallable<T> = T extends (...args: any[]) => any\r\n\t? T\r\n\t: T extends { (...args: any[]): any }\r\n\t\t? T\r\n\t\t: never;\r\n\r\ntype CallableInstance<\r\n\tTClass extends InstanceType<new (...args: any[]) => any>,\r\n\tK extends keyof TClass,\r\n> = TClass extends { [P in K]: infer F }\r\n\t? OverloadedCallable<F> & TClass\r\n\t: never;\r\n\r\ntype CallableInstanceFn<\r\n\tTClass extends InstanceType<new (...args: any[]) => any>,\r\n\tFN extends (...args: any[]) => any,\r\n> = OverloadedCallable<FN> & TClass;\r\n\r\nfunction withCalling<\r\n\tTClass extends new (...args: any[]) => any,\r\n\tTInstance extends InstanceType<TClass>,\r\n\tFN extends (...args: any[]) => any,\r\n>(instance: TInstance, callback: FN): CallableInstanceFn<TInstance, FN> {\r\n\tconst callable = callback as CallableInstanceFn<TInstance, FN>;\r\n\tObject.setPrototypeOf(callable, instance.constructor.prototype);\r\n\tObject.assign(callable, instance);\r\n\treturn callable;\r\n}\r\n\r\nfunction makeCallableInstance<\r\n\tTClass extends new (...args: any[]) => any,\r\n\tK extends keyof InstanceType<TClass>,\r\n\tOut extends InstanceType<TClass>,\r\n>(\r\n\tClass: TClass,\r\n\targs: ConstructorParameters<TClass>,\r\n\tinvoke: K,\r\n): CallableInstance<Out, K> {\r\n\tconst instance = new Class(...args);\r\n\treturn withCalling(instance, instance[invoke].bind(instance));\r\n}\r\n\r\nexport { makeCallableInstance, withCalling };\r\n"],"mappings":"AAkBA,SAAS,EAIP,EAAqB,EAAiD,CACvE,IAAM,EAAW,EAGjB,OAFA,OAAO,eAAe,EAAU,EAAS,YAAY,SAAS,EAC9D,OAAO,OAAO,EAAU,CAAQ,EACzB,CACR,CAEA,SAAS,EAKR,EACA,EACA,EAC2B,CAC3B,IAAM,EAAW,IAAI,EAAM,GAAG,CAAI,EAClC,OAAO,EAAY,EAAU,EAAS,EAAO,CAAC,KAAK,CAAQ,CAAC,CAC7D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/util/class.util.d.ts
|
|
2
|
+
type OverloadedCallable<T> = T extends ((...args: any[]) => any) ? T : T extends {
|
|
3
|
+
(...args: any[]): any;
|
|
4
|
+
} ? T : never;
|
|
5
|
+
type CallableInstance<TClass extends InstanceType<new (...args: any[]) => any>, K extends keyof TClass> = TClass extends { [P in K]: infer F; } ? OverloadedCallable<F> & TClass : never;
|
|
6
|
+
declare function makeCallableInstance<TClass extends new (...args: any[]) => any, K extends keyof InstanceType<TClass>, Out extends InstanceType<TClass>>(Class: TClass, args: ConstructorParameters<TClass>, invoke: K): CallableInstance<Out, K>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { makeCallableInstance };
|
|
9
|
+
//# sourceMappingURL=class.util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.util.mjs","names":[],"sources":["../../src/util/class.util.ts"],"sourcesContent":["type OverloadedCallable<T> = T extends (...args: any[]) => any\r\n\t? T\r\n\t: T extends { (...args: any[]): any }\r\n\t\t? T\r\n\t\t: never;\r\n\r\ntype CallableInstance<\r\n\tTClass extends InstanceType<new (...args: any[]) => any>,\r\n\tK extends keyof TClass,\r\n> = TClass extends { [P in K]: infer F }\r\n\t? OverloadedCallable<F> & TClass\r\n\t: never;\r\n\r\ntype CallableInstanceFn<\r\n\tTClass extends InstanceType<new (...args: any[]) => any>,\r\n\tFN extends (...args: any[]) => any,\r\n> = OverloadedCallable<FN> & TClass;\r\n\r\nfunction withCalling<\r\n\tTClass extends new (...args: any[]) => any,\r\n\tTInstance extends InstanceType<TClass>,\r\n\tFN extends (...args: any[]) => any,\r\n>(instance: TInstance, callback: FN): CallableInstanceFn<TInstance, FN> {\r\n\tconst callable = callback as CallableInstanceFn<TInstance, FN>;\r\n\tObject.setPrototypeOf(callable, instance.constructor.prototype);\r\n\tObject.assign(callable, instance);\r\n\treturn callable;\r\n}\r\n\r\nfunction makeCallableInstance<\r\n\tTClass extends new (...args: any[]) => any,\r\n\tK extends keyof InstanceType<TClass>,\r\n>(\r\n\tClass: TClass,\r\n\targs: ConstructorParameters<TClass>,\r\n\tinvoke: K,\r\n): CallableInstance<
|
|
1
|
+
{"version":3,"file":"class.util.mjs","names":[],"sources":["../../src/util/class.util.ts"],"sourcesContent":["type OverloadedCallable<T> = T extends (...args: any[]) => any\r\n\t? T\r\n\t: T extends { (...args: any[]): any }\r\n\t\t? T\r\n\t\t: never;\r\n\r\ntype CallableInstance<\r\n\tTClass extends InstanceType<new (...args: any[]) => any>,\r\n\tK extends keyof TClass,\r\n> = TClass extends { [P in K]: infer F }\r\n\t? OverloadedCallable<F> & TClass\r\n\t: never;\r\n\r\ntype CallableInstanceFn<\r\n\tTClass extends InstanceType<new (...args: any[]) => any>,\r\n\tFN extends (...args: any[]) => any,\r\n> = OverloadedCallable<FN> & TClass;\r\n\r\nfunction withCalling<\r\n\tTClass extends new (...args: any[]) => any,\r\n\tTInstance extends InstanceType<TClass>,\r\n\tFN extends (...args: any[]) => any,\r\n>(instance: TInstance, callback: FN): CallableInstanceFn<TInstance, FN> {\r\n\tconst callable = callback as CallableInstanceFn<TInstance, FN>;\r\n\tObject.setPrototypeOf(callable, instance.constructor.prototype);\r\n\tObject.assign(callable, instance);\r\n\treturn callable;\r\n}\r\n\r\nfunction makeCallableInstance<\r\n\tTClass extends new (...args: any[]) => any,\r\n\tK extends keyof InstanceType<TClass>,\r\n\tOut extends InstanceType<TClass>,\r\n>(\r\n\tClass: TClass,\r\n\targs: ConstructorParameters<TClass>,\r\n\tinvoke: K,\r\n): CallableInstance<Out, K> {\r\n\tconst instance = new Class(...args);\r\n\treturn withCalling(instance, instance[invoke].bind(instance));\r\n}\r\n\r\nexport { makeCallableInstance, withCalling };\r\n"],"mappings":"AAkBA,SAAS,EAIP,EAAqB,EAAiD,CACvE,IAAM,EAAW,EAGjB,OAFA,OAAO,eAAe,EAAU,EAAS,YAAY,SAAS,EAC9D,OAAO,OAAO,EAAU,CAAQ,EACzB,CACR,CAEA,SAAS,EAKR,EACA,EACA,EAC2B,CAC3B,IAAM,EAAW,IAAI,EAAM,GAAG,CAAI,EAClC,OAAO,EAAY,EAAU,EAAS,EAAO,CAAC,KAAK,CAAQ,CAAC,CAC7D"}
|
package/package.json
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@orago/dodo",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Dear Orago's Dom Objects",
|
|
5
|
-
"main": "./dist/index.mjs",
|
|
6
|
-
"types": "./dist/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "tsdown"
|
|
9
|
-
},
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"types": "./dist/index.d.ts",
|
|
13
|
-
"import": "./dist/index.mjs",
|
|
14
|
-
"require": "./dist/index.cjs"
|
|
15
|
-
},
|
|
16
|
-
"./plugins": {
|
|
17
|
-
"types": "./dist/plugins/index.d.ts",
|
|
18
|
-
"import": "./dist/plugins/index.mjs",
|
|
19
|
-
"require": "./dist/plugins/index.cjs"
|
|
20
|
-
},
|
|
21
|
-
"./server": {
|
|
22
|
-
"types": "./dist/server/index.d.ts",
|
|
23
|
-
"import": "./dist/server/index.mjs",
|
|
24
|
-
"require": "./dist/server/index.cjs"
|
|
25
|
-
},
|
|
26
|
-
"./jsx-runtime": {
|
|
27
|
-
"types": "./dist/jsx-runtime.d.ts",
|
|
28
|
-
"import": "./dist/jsx-runtime.mjs",
|
|
29
|
-
"require": "./dist/jsx-runtime.cjs"
|
|
30
|
-
},
|
|
31
|
-
"./jsx-dev-runtime": {
|
|
32
|
-
"types": "./dist/jsx-runtime.d.ts",
|
|
33
|
-
"import": "./dist/jsx-runtime.mjs",
|
|
34
|
-
"require": "./dist/jsx-runtime.cjs"
|
|
35
|
-
},
|
|
36
|
-
"./*": {
|
|
37
|
-
"types": "./dist/*.d.ts",
|
|
38
|
-
"import": "./dist/*.mjs",
|
|
39
|
-
"require": "./dist/*.cjs"
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
"typesVersions": {
|
|
43
|
-
"*": {
|
|
44
|
-
"*": [
|
|
45
|
-
"./src/*"
|
|
46
|
-
]
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
"author": "Orago",
|
|
50
|
-
"license": "ISC",
|
|
51
|
-
"dependencies": {
|
|
52
|
-
"@orago/kiwi": "^0.0.
|
|
53
|
-
"@orago/lib": "^0.0.47"
|
|
54
|
-
},
|
|
55
|
-
"devDependencies": {
|
|
56
|
-
"@types/node": "^26.1.2",
|
|
57
|
-
"tsdown": "^0.22.14",
|
|
58
|
-
"typescript": "^5.3.3",
|
|
59
|
-
"vite": "^7.1.7"
|
|
60
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@orago/dodo",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Dear Orago's Dom Objects",
|
|
5
|
+
"main": "./dist/index.mjs",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsdown"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
15
|
+
},
|
|
16
|
+
"./plugins": {
|
|
17
|
+
"types": "./dist/plugins/index.d.ts",
|
|
18
|
+
"import": "./dist/plugins/index.mjs",
|
|
19
|
+
"require": "./dist/plugins/index.cjs"
|
|
20
|
+
},
|
|
21
|
+
"./server": {
|
|
22
|
+
"types": "./dist/server/index.d.ts",
|
|
23
|
+
"import": "./dist/server/index.mjs",
|
|
24
|
+
"require": "./dist/server/index.cjs"
|
|
25
|
+
},
|
|
26
|
+
"./jsx-runtime": {
|
|
27
|
+
"types": "./dist/jsx-runtime.d.ts",
|
|
28
|
+
"import": "./dist/jsx-runtime.mjs",
|
|
29
|
+
"require": "./dist/jsx-runtime.cjs"
|
|
30
|
+
},
|
|
31
|
+
"./jsx-dev-runtime": {
|
|
32
|
+
"types": "./dist/jsx-runtime.d.ts",
|
|
33
|
+
"import": "./dist/jsx-runtime.mjs",
|
|
34
|
+
"require": "./dist/jsx-runtime.cjs"
|
|
35
|
+
},
|
|
36
|
+
"./*": {
|
|
37
|
+
"types": "./dist/*.d.ts",
|
|
38
|
+
"import": "./dist/*.mjs",
|
|
39
|
+
"require": "./dist/*.cjs"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"typesVersions": {
|
|
43
|
+
"*": {
|
|
44
|
+
"*": [
|
|
45
|
+
"./src/*"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"author": "Orago",
|
|
50
|
+
"license": "ISC",
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@orago/kiwi": "^0.0.5",
|
|
53
|
+
"@orago/lib": "^0.0.47"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^26.1.2",
|
|
57
|
+
"tsdown": "^0.22.14",
|
|
58
|
+
"typescript": "^5.3.3",
|
|
59
|
+
"vite": "^7.1.7"
|
|
60
|
+
}
|
|
61
61
|
}
|
package/pnpm-workspace.yaml
CHANGED
package/src/dodo.ts
CHANGED
|
@@ -240,9 +240,19 @@ class Dodo<H extends HTMLElement = HTMLElement> extends Base_Kiwi {
|
|
|
240
240
|
|
|
241
241
|
element!: H;
|
|
242
242
|
|
|
243
|
-
style
|
|
244
|
-
|
|
245
|
-
|
|
243
|
+
public style: ReturnType<
|
|
244
|
+
typeof makeCallableInstance<typeof DodoStyles, "call", DodoStyles<this>>
|
|
245
|
+
> = makeCallableInstance(DodoStyles, [this], "call");
|
|
246
|
+
class: ReturnType<
|
|
247
|
+
typeof makeCallableInstance<
|
|
248
|
+
typeof DodoClasses,
|
|
249
|
+
"call",
|
|
250
|
+
DodoClasses<this>
|
|
251
|
+
>
|
|
252
|
+
> = makeCallableInstance(DodoClasses, [this], "call");
|
|
253
|
+
events: ReturnType<
|
|
254
|
+
typeof makeCallableInstance<typeof DodoEvents, "call", DodoEvents<this>>
|
|
255
|
+
> = makeCallableInstance(DodoEvents, [this], "call");
|
|
246
256
|
|
|
247
257
|
constructor(element: ElementName | Extractable) {
|
|
248
258
|
super();
|
package/src/util/class.util.ts
CHANGED
|
@@ -30,11 +30,12 @@ function withCalling<
|
|
|
30
30
|
function makeCallableInstance<
|
|
31
31
|
TClass extends new (...args: any[]) => any,
|
|
32
32
|
K extends keyof InstanceType<TClass>,
|
|
33
|
+
Out extends InstanceType<TClass>,
|
|
33
34
|
>(
|
|
34
35
|
Class: TClass,
|
|
35
36
|
args: ConstructorParameters<TClass>,
|
|
36
37
|
invoke: K,
|
|
37
|
-
): CallableInstance<
|
|
38
|
+
): CallableInstance<Out, K> {
|
|
38
39
|
const instance = new Class(...args);
|
|
39
40
|
return withCalling(instance, instance[invoke].bind(instance));
|
|
40
41
|
}
|