@orago/dodo 0.0.17 → 0.0.18

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.
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../dodo.cjs");function t(e,t){if(t!=null){e.update(t);for(let n in t){let r=t[n];if(n.startsWith(`on:`)&&typeof r==`function`){let t=n.slice(3).toLowerCase();e.events.on(t,r)}}}}var n=class n extends e.Dodo{static{this.use=e=>n=>t(n,e)}constructor(e,t){super(e),this.use([n.use(t)])}};function r(t,r,i){return r?.children!=null&&(r.children=Array.isArray(r.children)?e.DodoUtil.flattenElements(r.children??[]):e.DodoUtil.flattenElements([r.children])),typeof t==`function`?new t(r):e.oo(t).use([n.use(r)]).append(...r?.children??[])}const i=r;function a(...t){let n=document.createDocumentFragment(),r=e.DodoUtil.flattenElements(t);for(let e of r)n.appendChild(e);return n}const o=a,s=(e,t,n,i,a,o)=>r(e,t,n);exports.DodoJSX=n,exports.Fragment=o,exports.JsxFragment=a,exports.dodoJsxApply=t,exports.jsx=r,exports.jsxDEV=s,exports.jsxs=i;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../dodo.cjs");let t=require("@orago/kiwi/utilities");function n(e,t){if(t!=null){e.update(t);for(let n in t){let r=t[n];if(n.startsWith(`on:`)&&typeof r==`function`){let t=n.slice(3).toLowerCase();e.events.on(t,r)}}}}var r=class t extends e.Dodo{static{this.use=e=>t=>n(t,e)}constructor(e,n){super(e),this.use([t.use(n)])}};function i(n,i,a){return i?.children!=null&&(i.children=Array.isArray(i.children)?e.DodoUtil.flattenElements(i.children??[]):e.DodoUtil.flattenElements([i.children])),typeof i?.class==`string`&&(i.class=(0,t.formatClasses)([i.class])),typeof n==`function`?new n(i):e.oo(n).use([r.use(i)]).append(...i?.children??[])}const a=i;function o(...t){let n=document.createDocumentFragment(),r=e.DodoUtil.flattenElements(t);for(let e of r)n.appendChild(e);return n}const s=o,c=(e,t,n,r,a,o)=>i(e,t,n);exports.DodoJSX=r,exports.Fragment=s,exports.JsxFragment=o,exports.dodoJsxApply=n,exports.jsx=i,exports.jsxDEV=c,exports.jsxs=a;
2
2
  //# sourceMappingURL=jsx-runtime.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-runtime.cjs","names":["Dodo","DodoUtil","oo"],"sources":["../../src/util/jsx-runtime.ts"],"sourcesContent":["// polyfill for jsx\r\nimport {\r\n\tAppendable,\r\n\tChildList,\r\n\tDodo,\r\n\tDodoUpdate,\r\n\tDodoUtil,\r\n\too,\r\n} from \"../dodo.js\";\r\n\r\nexport type DodoJsxProps = DodoUpdate & {\r\n\t[K in keyof HTMLElementEventMap as `on:${K}`]?: (\r\n\t\tthis: Dodo,\r\n\t\tev: HTMLElementEventMap[K],\r\n\t) => any;\r\n};\r\n\r\nexport type DodoJsxSource =\r\n\t| (DodoJsxProps & { children?: Appendable | ChildList })\r\n\t| null\r\n\t| undefined;\r\n\r\ndeclare global {\r\n\tnamespace JSX {\r\n\t\texport type Element = ReturnType<typeof oo>;\r\n\t\texport type IntrinsicElements = {\r\n\t\t\t[K in keyof HTMLElementTagNameMap]: DodoJsxSource;\r\n\t\t};\r\n\t}\r\n}\r\n\r\nexport function dodoJsxApply(dodo: Dodo, update?: DodoJsxSource) {\r\n\tif (update == undefined) return;\r\n\tdodo.update(update);\r\n\r\n\tconst on_pre: string = \"on:\";\r\n\tfor (const key in update) {\r\n\t\tconst p = update[key as keyof typeof update];\r\n\t\tif (key.startsWith(on_pre) && typeof p === \"function\") {\r\n\t\t\tconst event = key.slice(on_pre.length).toLowerCase();\r\n\t\t\tdodo.events.on(event, p as EventListener);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport class DodoJSX extends Dodo {\r\n\tstatic use = (update?: DodoJsxSource) => (dodo: Dodo) =>\r\n\t\tdodoJsxApply(dodo, update);\r\n\r\n\tconstructor(type: keyof HTMLElementTagNameMap, props: DodoJsxProps) {\r\n\t\tsuper(type);\r\n\t\tthis.use([DodoJSX.use(props)]);\r\n\t}\r\n}\r\n\r\nexport function jsx(type: any, props: DodoJsxSource, key: any) {\r\n\tif (props?.children != undefined) {\r\n\t\tif (Array.isArray(props.children)) {\r\n\t\t\tprops.children = DodoUtil.flattenElements(props.children ?? []);\r\n\t\t} else {\r\n\t\t\tprops.children = DodoUtil.flattenElements([props.children]);\r\n\t\t}\r\n\t}\r\n\r\n\tif (typeof type === \"function\") {\r\n\t\treturn new type(props);\r\n\t}\r\n\r\n\treturn oo(type)\r\n\t\t.use([DodoJSX.use(props)])\r\n\t\t.append(...(props?.children ?? []));\r\n}\r\n\r\nexport const jsxs = jsx;\r\n\r\nexport function JsxFragment(...children: ChildList): DocumentFragment {\r\n\tconst frag = document.createDocumentFragment();\r\n\tconst items = DodoUtil.flattenElements(children);\r\n\tfor (const item of items) frag.appendChild(item);\r\n\treturn frag;\r\n}\r\nexport const Fragment = JsxFragment;\r\n\r\nexport const jsxDEV = (\r\n\ttype: any,\r\n\tprops: DodoJsxProps,\r\n\tkey: any,\r\n\tisStatic: any,\r\n\tsource: any,\r\n\tself: any,\r\n) => {\r\n\treturn jsx(type, props, key);\r\n};\r\n"],"mappings":"kGA+BA,SAAgB,EAAa,EAAY,EAAwB,CAC5D,MAAU,KACd,GAAK,OAAO,CAAM,EAGlB,IAAK,IAAM,KAAO,EAAQ,CACzB,IAAM,EAAI,EAAO,GACjB,GAAI,EAAI,WAAW,KAAM,GAAK,OAAO,GAAM,WAAY,CACtD,IAAM,EAAQ,EAAI,MAAM,CAAa,CAAC,CAAC,YAAY,EACnD,EAAK,OAAO,GAAG,EAAO,CAAkB,CACzC,CACD,CATkB,CAUnB,CAEA,IAAa,EAAb,MAAa,UAAgBA,EAAAA,IAAK,QACnB,KAAA,IAAA,GAA4B,GACzC,EAAa,EAAM,CAAM,EAE1B,YAAY,EAAmC,EAAqB,CACnE,MAAM,CAAI,EACV,KAAK,IAAI,CAAC,EAAQ,IAAI,CAAK,CAAC,CAAC,CAC9B,CACD,EAEA,SAAgB,EAAI,EAAW,EAAsB,EAAU,CAa9D,OAZI,GAAO,UAAY,OACtB,AAGC,EAAM,SAHH,MAAM,QAAQ,EAAM,QAAQ,EACdC,EAAAA,SAAS,gBAAgB,EAAM,UAAY,CAAC,CAAC,EAE7CA,EAAAA,SAAS,gBAAgB,CAAC,EAAM,QAAQ,CAAC,GAIxD,OAAO,GAAS,WACZ,IAAI,EAAK,CAAK,EAGfC,EAAAA,GAAG,CAAI,CAAC,CACb,IAAI,CAAC,EAAQ,IAAI,CAAK,CAAC,CAAC,CAAC,CACzB,OAAO,GAAI,GAAO,UAAY,CAAC,CAAE,CACpC,CAEA,MAAa,EAAO,EAEpB,SAAgB,EAAY,GAAG,EAAuC,CACrE,IAAM,EAAO,SAAS,uBAAuB,EACvC,EAAQD,EAAAA,SAAS,gBAAgB,CAAQ,EAC/C,IAAK,IAAM,KAAQ,EAAO,EAAK,YAAY,CAAI,EAC/C,OAAO,CACR,CACA,MAAa,EAAW,EAEX,GACZ,EACA,EACA,EACA,EACA,EACA,IAEO,EAAI,EAAM,EAAO,CAAG"}
1
+ {"version":3,"file":"jsx-runtime.cjs","names":["Dodo","DodoUtil","formatClasses","oo"],"sources":["../../src/util/jsx-runtime.ts"],"sourcesContent":["// polyfill for jsx\r\nimport { formatClasses } from \"@orago/kiwi/utilities\";\r\nimport {\r\n\tAppendable,\r\n\tChildList,\r\n\tDodo,\r\n\tDodoUpdate,\r\n\tDodoUtil,\r\n\too,\r\n} from \"../dodo.js\";\r\n\r\nexport type DodoJsxProps = DodoUpdate & {\r\n\t[K in keyof HTMLElementEventMap as `on:${K}`]?: (\r\n\t\tthis: Dodo,\r\n\t\tev: HTMLElementEventMap[K],\r\n\t) => any;\r\n};\r\n\r\nexport type DodoJsxSource =\r\n\t| (Omit<DodoJsxProps, \"class\"> & {\r\n\t\t\tchildren?: Appendable | ChildList;\r\n\t\t\tclass?: string | string[];\r\n\t })\r\n\t| null\r\n\t| undefined;\r\n\r\ndeclare global {\r\n\tnamespace JSX {\r\n\t\texport type Element = ReturnType<typeof oo>;\r\n\t\texport type IntrinsicElements = {\r\n\t\t\t[K in keyof HTMLElementTagNameMap]: DodoJsxSource;\r\n\t\t};\r\n\t}\r\n}\r\n\r\nexport function dodoJsxApply(dodo: Dodo, update?: DodoJsxProps) {\r\n\tif (update == undefined) return;\r\n\r\n\tdodo.update(update);\r\n\r\n\tconst on_pre: string = \"on:\";\r\n\tfor (const key in update) {\r\n\t\tconst p = update[key as keyof typeof update];\r\n\t\tif (key.startsWith(on_pre) && typeof p === \"function\") {\r\n\t\t\tconst event = key.slice(on_pre.length).toLowerCase();\r\n\t\t\tdodo.events.on(event, p as EventListener);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport class DodoJSX extends Dodo {\r\n\tstatic use = (update?: DodoJsxProps) => (dodo: Dodo) =>\r\n\t\tdodoJsxApply(dodo, update);\r\n\r\n\tconstructor(type: keyof HTMLElementTagNameMap, props: DodoJsxProps) {\r\n\t\tsuper(type);\r\n\t\tthis.use([DodoJSX.use(props)]);\r\n\t}\r\n}\r\n\r\nexport function jsx(type: any, props: DodoJsxSource, key: any) {\r\n\tif (props?.children != undefined) {\r\n\t\tif (Array.isArray(props.children)) {\r\n\t\t\tprops.children = DodoUtil.flattenElements(props.children ?? []);\r\n\t\t} else {\r\n\t\t\tprops.children = DodoUtil.flattenElements([props.children]);\r\n\t\t}\r\n\t}\r\n\r\n\tif (typeof props?.class == \"string\") {\r\n\t\tprops.class = formatClasses([props.class]);\r\n\t}\r\n\r\n\tif (typeof type === \"function\") {\r\n\t\treturn new type(props);\r\n\t}\r\n\r\n\treturn oo(type)\r\n\t\t.use([DodoJSX.use(props as DodoJsxProps)])\r\n\t\t.append(...(props?.children ?? []));\r\n}\r\n\r\nexport const jsxs = jsx;\r\n\r\nexport function JsxFragment(...children: ChildList): DocumentFragment {\r\n\tconst frag = document.createDocumentFragment();\r\n\tconst items = DodoUtil.flattenElements(children);\r\n\tfor (const item of items) frag.appendChild(item);\r\n\treturn frag;\r\n}\r\nexport const Fragment = JsxFragment;\r\n\r\nexport const jsxDEV = (\r\n\ttype: any,\r\n\tprops: DodoJsxProps,\r\n\tkey: any,\r\n\tisStatic: any,\r\n\tsource: any,\r\n\tself: any,\r\n) => {\r\n\treturn jsx(type, props, key);\r\n};\r\n"],"mappings":"yIAmCA,SAAgB,EAAa,EAAY,EAAuB,CAC3D,MAAU,KAEd,GAAK,OAAO,CAAM,EAGlB,IAAK,IAAM,KAAO,EAAQ,CACzB,IAAM,EAAI,EAAO,GACjB,GAAI,EAAI,WAAW,KAAM,GAAK,OAAO,GAAM,WAAY,CACtD,IAAM,EAAQ,EAAI,MAAM,CAAa,CAAC,CAAC,YAAY,EACnD,EAAK,OAAO,GAAG,EAAO,CAAkB,CACzC,CACD,CATkB,CAUnB,CAEA,IAAa,EAAb,MAAa,UAAgBA,EAAAA,IAAK,QACnB,KAAA,IAAA,GAA2B,GACxC,EAAa,EAAM,CAAM,EAE1B,YAAY,EAAmC,EAAqB,CACnE,MAAM,CAAI,EACV,KAAK,IAAI,CAAC,EAAQ,IAAI,CAAK,CAAC,CAAC,CAC9B,CACD,EAEA,SAAgB,EAAI,EAAW,EAAsB,EAAU,CAiB9D,OAhBI,GAAO,UAAY,OACtB,AAGC,EAAM,SAHH,MAAM,QAAQ,EAAM,QAAQ,EACdC,EAAAA,SAAS,gBAAgB,EAAM,UAAY,CAAC,CAAC,EAE7CA,EAAAA,SAAS,gBAAgB,CAAC,EAAM,QAAQ,CAAC,GAIxD,OAAO,GAAO,OAAS,WAC1B,EAAM,OAAA,EAAQC,EAAAA,cAAAA,CAAc,CAAC,EAAM,KAAK,CAAC,GAGtC,OAAO,GAAS,WACZ,IAAI,EAAK,CAAK,EAGfC,EAAAA,GAAG,CAAI,CAAC,CACb,IAAI,CAAC,EAAQ,IAAI,CAAqB,CAAC,CAAC,CAAC,CACzC,OAAO,GAAI,GAAO,UAAY,CAAC,CAAE,CACpC,CAEA,MAAa,EAAO,EAEpB,SAAgB,EAAY,GAAG,EAAuC,CACrE,IAAM,EAAO,SAAS,uBAAuB,EACvC,EAAQF,EAAAA,SAAS,gBAAgB,CAAQ,EAC/C,IAAK,IAAM,KAAQ,EAAO,EAAK,YAAY,CAAI,EAC/C,OAAO,CACR,CACA,MAAa,EAAW,EAEX,GACZ,EACA,EACA,EACA,EACA,EACA,IAEO,EAAI,EAAM,EAAO,CAAG"}
@@ -1,8 +1,9 @@
1
1
  import { Appendable, ChildList, Dodo, DodoUpdate, oo } from "../dodo.js";
2
2
  //#region src/util/jsx-runtime.d.ts
3
3
  type DodoJsxProps = DodoUpdate & { [K in keyof HTMLElementEventMap as `on:${K}`]?: (this: Dodo, ev: HTMLElementEventMap[K]) => any; };
4
- type DodoJsxSource = (DodoJsxProps & {
4
+ type DodoJsxSource = (Omit<DodoJsxProps, "class"> & {
5
5
  children?: Appendable | ChildList;
6
+ class?: string | string[];
6
7
  }) | null | undefined;
7
8
  declare global {
8
9
  namespace JSX {
@@ -10,9 +11,9 @@ declare global {
10
11
  type IntrinsicElements = { [K in keyof HTMLElementTagNameMap]: DodoJsxSource; };
11
12
  }
12
13
  }
13
- declare function dodoJsxApply(dodo: Dodo, update?: DodoJsxSource): void;
14
+ declare function dodoJsxApply(dodo: Dodo, update?: DodoJsxProps): void;
14
15
  declare class DodoJSX extends Dodo {
15
- static use: (update?: DodoJsxSource) => (dodo: Dodo) => void;
16
+ static use: (update?: DodoJsxProps) => (dodo: Dodo) => void;
16
17
  constructor(type: keyof HTMLElementTagNameMap, props: DodoJsxProps);
17
18
  }
18
19
  declare function jsx(type: any, props: DodoJsxSource, key: any): any;
@@ -1,2 +1,2 @@
1
- import{Dodo as e,DodoUtil as t,oo as n}from"../dodo.mjs";function r(e,t){if(t!=null){e.update(t);for(let n in t){let r=t[n];if(n.startsWith(`on:`)&&typeof r==`function`){let t=n.slice(3).toLowerCase();e.events.on(t,r)}}}}var i=class t extends e{static{this.use=e=>t=>r(t,e)}constructor(e,n){super(e),this.use([t.use(n)])}};function a(e,r,a){return r?.children!=null&&(r.children=Array.isArray(r.children)?t.flattenElements(r.children??[]):t.flattenElements([r.children])),typeof e==`function`?new e(r):n(e).use([i.use(r)]).append(...r?.children??[])}const o=a;function s(...e){let n=document.createDocumentFragment(),r=t.flattenElements(e);for(let e of r)n.appendChild(e);return n}const c=s,l=(e,t,n,r,i,o)=>a(e,t,n);export{i as DodoJSX,c as Fragment,s as JsxFragment,r as dodoJsxApply,a as jsx,l as jsxDEV,o as jsxs};
1
+ import{Dodo as e,DodoUtil as t,oo as n}from"../dodo.mjs";import{formatClasses as r}from"@orago/kiwi/utilities";function i(e,t){if(t!=null){e.update(t);for(let n in t){let r=t[n];if(n.startsWith(`on:`)&&typeof r==`function`){let t=n.slice(3).toLowerCase();e.events.on(t,r)}}}}var a=class t extends e{static{this.use=e=>t=>i(t,e)}constructor(e,n){super(e),this.use([t.use(n)])}};function o(e,i,o){return i?.children!=null&&(i.children=Array.isArray(i.children)?t.flattenElements(i.children??[]):t.flattenElements([i.children])),typeof i?.class==`string`&&(i.class=r([i.class])),typeof e==`function`?new e(i):n(e).use([a.use(i)]).append(...i?.children??[])}const s=o;function c(...e){let n=document.createDocumentFragment(),r=t.flattenElements(e);for(let e of r)n.appendChild(e);return n}const l=c,u=(e,t,n,r,i,a)=>o(e,t,n);export{a as DodoJSX,l as Fragment,c as JsxFragment,i as dodoJsxApply,o as jsx,u as jsxDEV,s as jsxs};
2
2
  //# sourceMappingURL=jsx-runtime.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-runtime.mjs","names":[],"sources":["../../src/util/jsx-runtime.ts"],"sourcesContent":["// polyfill for jsx\r\nimport {\r\n\tAppendable,\r\n\tChildList,\r\n\tDodo,\r\n\tDodoUpdate,\r\n\tDodoUtil,\r\n\too,\r\n} from \"../dodo.js\";\r\n\r\nexport type DodoJsxProps = DodoUpdate & {\r\n\t[K in keyof HTMLElementEventMap as `on:${K}`]?: (\r\n\t\tthis: Dodo,\r\n\t\tev: HTMLElementEventMap[K],\r\n\t) => any;\r\n};\r\n\r\nexport type DodoJsxSource =\r\n\t| (DodoJsxProps & { children?: Appendable | ChildList })\r\n\t| null\r\n\t| undefined;\r\n\r\ndeclare global {\r\n\tnamespace JSX {\r\n\t\texport type Element = ReturnType<typeof oo>;\r\n\t\texport type IntrinsicElements = {\r\n\t\t\t[K in keyof HTMLElementTagNameMap]: DodoJsxSource;\r\n\t\t};\r\n\t}\r\n}\r\n\r\nexport function dodoJsxApply(dodo: Dodo, update?: DodoJsxSource) {\r\n\tif (update == undefined) return;\r\n\tdodo.update(update);\r\n\r\n\tconst on_pre: string = \"on:\";\r\n\tfor (const key in update) {\r\n\t\tconst p = update[key as keyof typeof update];\r\n\t\tif (key.startsWith(on_pre) && typeof p === \"function\") {\r\n\t\t\tconst event = key.slice(on_pre.length).toLowerCase();\r\n\t\t\tdodo.events.on(event, p as EventListener);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport class DodoJSX extends Dodo {\r\n\tstatic use = (update?: DodoJsxSource) => (dodo: Dodo) =>\r\n\t\tdodoJsxApply(dodo, update);\r\n\r\n\tconstructor(type: keyof HTMLElementTagNameMap, props: DodoJsxProps) {\r\n\t\tsuper(type);\r\n\t\tthis.use([DodoJSX.use(props)]);\r\n\t}\r\n}\r\n\r\nexport function jsx(type: any, props: DodoJsxSource, key: any) {\r\n\tif (props?.children != undefined) {\r\n\t\tif (Array.isArray(props.children)) {\r\n\t\t\tprops.children = DodoUtil.flattenElements(props.children ?? []);\r\n\t\t} else {\r\n\t\t\tprops.children = DodoUtil.flattenElements([props.children]);\r\n\t\t}\r\n\t}\r\n\r\n\tif (typeof type === \"function\") {\r\n\t\treturn new type(props);\r\n\t}\r\n\r\n\treturn oo(type)\r\n\t\t.use([DodoJSX.use(props)])\r\n\t\t.append(...(props?.children ?? []));\r\n}\r\n\r\nexport const jsxs = jsx;\r\n\r\nexport function JsxFragment(...children: ChildList): DocumentFragment {\r\n\tconst frag = document.createDocumentFragment();\r\n\tconst items = DodoUtil.flattenElements(children);\r\n\tfor (const item of items) frag.appendChild(item);\r\n\treturn frag;\r\n}\r\nexport const Fragment = JsxFragment;\r\n\r\nexport const jsxDEV = (\r\n\ttype: any,\r\n\tprops: DodoJsxProps,\r\n\tkey: any,\r\n\tisStatic: any,\r\n\tsource: any,\r\n\tself: any,\r\n) => {\r\n\treturn jsx(type, props, key);\r\n};\r\n"],"mappings":"yDA+BA,SAAgB,EAAa,EAAY,EAAwB,CAC5D,MAAU,KACd,GAAK,OAAO,CAAM,EAGlB,IAAK,IAAM,KAAO,EAAQ,CACzB,IAAM,EAAI,EAAO,GACjB,GAAI,EAAI,WAAW,KAAM,GAAK,OAAO,GAAM,WAAY,CACtD,IAAM,EAAQ,EAAI,MAAM,CAAa,CAAC,CAAC,YAAY,EACnD,EAAK,OAAO,GAAG,EAAO,CAAkB,CACzC,CACD,CATkB,CAUnB,CAEA,IAAa,EAAb,MAAa,UAAgB,CAAK,QACnB,KAAA,IAAA,GAA4B,GACzC,EAAa,EAAM,CAAM,EAE1B,YAAY,EAAmC,EAAqB,CACnE,MAAM,CAAI,EACV,KAAK,IAAI,CAAC,EAAQ,IAAI,CAAK,CAAC,CAAC,CAC9B,CACD,EAEA,SAAgB,EAAI,EAAW,EAAsB,EAAU,CAa9D,OAZI,GAAO,UAAY,OACtB,AAGC,EAAM,SAHH,MAAM,QAAQ,EAAM,QAAQ,EACd,EAAS,gBAAgB,EAAM,UAAY,CAAC,CAAC,EAE7C,EAAS,gBAAgB,CAAC,EAAM,QAAQ,CAAC,GAIxD,OAAO,GAAS,WACZ,IAAI,EAAK,CAAK,EAGf,EAAG,CAAI,CAAC,CACb,IAAI,CAAC,EAAQ,IAAI,CAAK,CAAC,CAAC,CAAC,CACzB,OAAO,GAAI,GAAO,UAAY,CAAC,CAAE,CACpC,CAEA,MAAa,EAAO,EAEpB,SAAgB,EAAY,GAAG,EAAuC,CACrE,IAAM,EAAO,SAAS,uBAAuB,EACvC,EAAQ,EAAS,gBAAgB,CAAQ,EAC/C,IAAK,IAAM,KAAQ,EAAO,EAAK,YAAY,CAAI,EAC/C,OAAO,CACR,CACA,MAAa,EAAW,EAEX,GACZ,EACA,EACA,EACA,EACA,EACA,IAEO,EAAI,EAAM,EAAO,CAAG"}
1
+ {"version":3,"file":"jsx-runtime.mjs","names":[],"sources":["../../src/util/jsx-runtime.ts"],"sourcesContent":["// polyfill for jsx\r\nimport { formatClasses } from \"@orago/kiwi/utilities\";\r\nimport {\r\n\tAppendable,\r\n\tChildList,\r\n\tDodo,\r\n\tDodoUpdate,\r\n\tDodoUtil,\r\n\too,\r\n} from \"../dodo.js\";\r\n\r\nexport type DodoJsxProps = DodoUpdate & {\r\n\t[K in keyof HTMLElementEventMap as `on:${K}`]?: (\r\n\t\tthis: Dodo,\r\n\t\tev: HTMLElementEventMap[K],\r\n\t) => any;\r\n};\r\n\r\nexport type DodoJsxSource =\r\n\t| (Omit<DodoJsxProps, \"class\"> & {\r\n\t\t\tchildren?: Appendable | ChildList;\r\n\t\t\tclass?: string | string[];\r\n\t })\r\n\t| null\r\n\t| undefined;\r\n\r\ndeclare global {\r\n\tnamespace JSX {\r\n\t\texport type Element = ReturnType<typeof oo>;\r\n\t\texport type IntrinsicElements = {\r\n\t\t\t[K in keyof HTMLElementTagNameMap]: DodoJsxSource;\r\n\t\t};\r\n\t}\r\n}\r\n\r\nexport function dodoJsxApply(dodo: Dodo, update?: DodoJsxProps) {\r\n\tif (update == undefined) return;\r\n\r\n\tdodo.update(update);\r\n\r\n\tconst on_pre: string = \"on:\";\r\n\tfor (const key in update) {\r\n\t\tconst p = update[key as keyof typeof update];\r\n\t\tif (key.startsWith(on_pre) && typeof p === \"function\") {\r\n\t\t\tconst event = key.slice(on_pre.length).toLowerCase();\r\n\t\t\tdodo.events.on(event, p as EventListener);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport class DodoJSX extends Dodo {\r\n\tstatic use = (update?: DodoJsxProps) => (dodo: Dodo) =>\r\n\t\tdodoJsxApply(dodo, update);\r\n\r\n\tconstructor(type: keyof HTMLElementTagNameMap, props: DodoJsxProps) {\r\n\t\tsuper(type);\r\n\t\tthis.use([DodoJSX.use(props)]);\r\n\t}\r\n}\r\n\r\nexport function jsx(type: any, props: DodoJsxSource, key: any) {\r\n\tif (props?.children != undefined) {\r\n\t\tif (Array.isArray(props.children)) {\r\n\t\t\tprops.children = DodoUtil.flattenElements(props.children ?? []);\r\n\t\t} else {\r\n\t\t\tprops.children = DodoUtil.flattenElements([props.children]);\r\n\t\t}\r\n\t}\r\n\r\n\tif (typeof props?.class == \"string\") {\r\n\t\tprops.class = formatClasses([props.class]);\r\n\t}\r\n\r\n\tif (typeof type === \"function\") {\r\n\t\treturn new type(props);\r\n\t}\r\n\r\n\treturn oo(type)\r\n\t\t.use([DodoJSX.use(props as DodoJsxProps)])\r\n\t\t.append(...(props?.children ?? []));\r\n}\r\n\r\nexport const jsxs = jsx;\r\n\r\nexport function JsxFragment(...children: ChildList): DocumentFragment {\r\n\tconst frag = document.createDocumentFragment();\r\n\tconst items = DodoUtil.flattenElements(children);\r\n\tfor (const item of items) frag.appendChild(item);\r\n\treturn frag;\r\n}\r\nexport const Fragment = JsxFragment;\r\n\r\nexport const jsxDEV = (\r\n\ttype: any,\r\n\tprops: DodoJsxProps,\r\n\tkey: any,\r\n\tisStatic: any,\r\n\tsource: any,\r\n\tself: any,\r\n) => {\r\n\treturn jsx(type, props, key);\r\n};\r\n"],"mappings":"+GAmCA,SAAgB,EAAa,EAAY,EAAuB,CAC3D,MAAU,KAEd,GAAK,OAAO,CAAM,EAGlB,IAAK,IAAM,KAAO,EAAQ,CACzB,IAAM,EAAI,EAAO,GACjB,GAAI,EAAI,WAAW,KAAM,GAAK,OAAO,GAAM,WAAY,CACtD,IAAM,EAAQ,EAAI,MAAM,CAAa,CAAC,CAAC,YAAY,EACnD,EAAK,OAAO,GAAG,EAAO,CAAkB,CACzC,CACD,CATkB,CAUnB,CAEA,IAAa,EAAb,MAAa,UAAgB,CAAK,QACnB,KAAA,IAAA,GAA2B,GACxC,EAAa,EAAM,CAAM,EAE1B,YAAY,EAAmC,EAAqB,CACnE,MAAM,CAAI,EACV,KAAK,IAAI,CAAC,EAAQ,IAAI,CAAK,CAAC,CAAC,CAC9B,CACD,EAEA,SAAgB,EAAI,EAAW,EAAsB,EAAU,CAiB9D,OAhBI,GAAO,UAAY,OACtB,AAGC,EAAM,SAHH,MAAM,QAAQ,EAAM,QAAQ,EACd,EAAS,gBAAgB,EAAM,UAAY,CAAC,CAAC,EAE7C,EAAS,gBAAgB,CAAC,EAAM,QAAQ,CAAC,GAIxD,OAAO,GAAO,OAAS,WAC1B,EAAM,MAAQ,EAAc,CAAC,EAAM,KAAK,CAAC,GAGtC,OAAO,GAAS,WACZ,IAAI,EAAK,CAAK,EAGf,EAAG,CAAI,CAAC,CACb,IAAI,CAAC,EAAQ,IAAI,CAAqB,CAAC,CAAC,CAAC,CACzC,OAAO,GAAI,GAAO,UAAY,CAAC,CAAE,CACpC,CAEA,MAAa,EAAO,EAEpB,SAAgB,EAAY,GAAG,EAAuC,CACrE,IAAM,EAAO,SAAS,uBAAuB,EACvC,EAAQ,EAAS,gBAAgB,CAAQ,EAC/C,IAAK,IAAM,KAAQ,EAAO,EAAK,YAAY,CAAI,EAC/C,OAAO,CACR,CACA,MAAa,EAAW,EAEX,GACZ,EACA,EACA,EACA,EACA,EACA,IAEO,EAAI,EAAM,EAAO,CAAG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orago/dodo",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "Dear Orago's Dom Objects",
5
5
  "main": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -49,7 +49,7 @@
49
49
  "author": "Orago",
50
50
  "license": "ISC",
51
51
  "dependencies": {
52
- "@orago/kiwi": "^0.0.11",
52
+ "@orago/kiwi": "^0.0.12",
53
53
  "@orago/lib": "^0.0.47"
54
54
  },
55
55
  "devDependencies": {
@@ -1,4 +1,4 @@
1
1
  allowBuilds:
2
2
  esbuild: set this to true or false
3
3
  minimumReleaseAgeExclude:
4
- - '@orago/kiwi@0.0.1 || 0.0.4 || 0.0.5 || 0.0.6 || 0.0.7 || 0.0.8 || 0.0.9 || 0.0.10 || 0.0.11'
4
+ - '@orago/kiwi@0.0.1 || 0.0.4 || 0.0.5 || 0.0.6 || 0.0.7 || 0.0.8 || 0.0.9 || 0.0.10 || 0.0.11 || 0.0.12'
@@ -1,4 +1,5 @@
1
1
  // polyfill for jsx
2
+ import { formatClasses } from "@orago/kiwi/utilities";
2
3
  import {
3
4
  Appendable,
4
5
  ChildList,
@@ -16,7 +17,10 @@ export type DodoJsxProps = DodoUpdate & {
16
17
  };
17
18
 
18
19
  export type DodoJsxSource =
19
- | (DodoJsxProps & { children?: Appendable | ChildList })
20
+ | (Omit<DodoJsxProps, "class"> & {
21
+ children?: Appendable | ChildList;
22
+ class?: string | string[];
23
+ })
20
24
  | null
21
25
  | undefined;
22
26
 
@@ -29,8 +33,9 @@ declare global {
29
33
  }
30
34
  }
31
35
 
32
- export function dodoJsxApply(dodo: Dodo, update?: DodoJsxSource) {
36
+ export function dodoJsxApply(dodo: Dodo, update?: DodoJsxProps) {
33
37
  if (update == undefined) return;
38
+
34
39
  dodo.update(update);
35
40
 
36
41
  const on_pre: string = "on:";
@@ -44,7 +49,7 @@ export function dodoJsxApply(dodo: Dodo, update?: DodoJsxSource) {
44
49
  }
45
50
 
46
51
  export class DodoJSX extends Dodo {
47
- static use = (update?: DodoJsxSource) => (dodo: Dodo) =>
52
+ static use = (update?: DodoJsxProps) => (dodo: Dodo) =>
48
53
  dodoJsxApply(dodo, update);
49
54
 
50
55
  constructor(type: keyof HTMLElementTagNameMap, props: DodoJsxProps) {
@@ -62,12 +67,16 @@ export function jsx(type: any, props: DodoJsxSource, key: any) {
62
67
  }
63
68
  }
64
69
 
70
+ if (typeof props?.class == "string") {
71
+ props.class = formatClasses([props.class]);
72
+ }
73
+
65
74
  if (typeof type === "function") {
66
75
  return new type(props);
67
76
  }
68
77
 
69
78
  return oo(type)
70
- .use([DodoJSX.use(props)])
79
+ .use([DodoJSX.use(props as DodoJsxProps)])
71
80
  .append(...(props?.children ?? []));
72
81
  }
73
82