diff --git a/bs/build.js b/bs/build.js index 477a301..f45cdc8 100755 --- a/bs/build.js +++ b/bs/build.js @@ -5,18 +5,18 @@ const files= [ "index", "index-with-signals" ]; $.api("") .command("main", "Build main files", { default: true }) .option("--no-types", "Also generate d.ts files", false) -.action(async function main({ types }){ - const regular = await build({ +.action(function main({ types }){ + const regular = build({ files, filesOut, minify: "no", types, }); - const min = await build({ + const min = build({ files, filesOut(file, mark= "esm"){ const out= filesOut(file, mark); - const idx= out.lastIndexOf("."); + const idx= out.indexOf("."); return out.slice(0, idx)+".min"+out.slice(idx); }, minify: "full", @@ -25,8 +25,8 @@ $.api("") return $.exit(regular + min); }) .command("signals", "Build only signals (for example for analysis)") -.action(async function signals(){ - const regular = await build({ +.action(function signals(){ + const regular = build({ files: [ "signals" ], filesOut(file){ return "dist/."+file; }, minify: "no", diff --git a/dist/esm-with-signals.d.min.ts b/dist/esm-with-signals.d.min.ts deleted file mode 100644 index 49490b4..0000000 --- a/dist/esm-with-signals.d.min.ts +++ /dev/null @@ -1,641 +0,0 @@ -declare global{ /* ddeSignal */ } -type CustomElementTagNameMap= { '#text': Text, '#comment': Comment } -type SupportedElement= - HTMLElementTagNameMap[keyof HTMLElementTagNameMap] - | SVGElementTagNameMap[keyof SVGElementTagNameMap] - | MathMLElementTagNameMap[keyof MathMLElementTagNameMap] - | CustomElementTagNameMap[keyof CustomElementTagNameMap] -declare global { - type ddeComponentAttributes= Record | undefined; - type ddeElementAddon= (element: El)=> any; - type ddeString= string | ddeSignal - type ddeStringable= ddeString | number | ddeSignal -} -type PascalCase= -`${Capitalize}${string}`; -type AttrsModified= { - /** - * Use string like in HTML (internally uses `*.setAttribute("style", *)`), or object representation (like DOM API). - */ - style: Partial | ddeString - | Partial<{ [K in keyof CSSStyleDeclaration]: ddeSignal }> - /** - * Provide option to add/remove/toggle CSS clasess (index of object) using 1/0/-1. - * In fact `el.classList.toggle(class_name)` for `-1` and `el.classList.toggle(class_name, Boolean(...))` - * for others. - */ - classList: Record>, - /** - * Used by the dataset HTML attribute to represent data for custom attributes added to elements. - * Values are converted to string (see {@link DOMStringMap}). - * - * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMStringMap) - * */ - dataset: Record, - /** - * Sets `aria-*` simiraly to `dataset` - * */ - ariaset: Record, -} & Record<`=${string}` | `data${PascalCase}` | `aria${PascalCase}`, ddeString> - & Record<`.${string}`, any> -type _fromElsInterfaces= Omit; -type IsReadonly = - T extends { readonly [P in K]: T[K] } ? true : false; -/** - * Just element attributtes - * - * In most cases, you can use native propertie such as - * [MDN WEB/API/Element](https://developer.mozilla.org/en-US/docs/Web/API/Element) and so on - * (e.g. [`Text`](https://developer.mozilla.org/en-US/docs/Web/API/Text)). - * - * There is added support for `data[A-Z].*`/`aria[A-Z].*` to be converted to the kebab-case alternatives. - * @private - */ -type ElementAttributes= Partial<{ - [K in keyof _fromElsInterfaces]: - _fromElsInterfaces[K] extends ((...p: any[])=> any) - ? _fromElsInterfaces[K] | ((...p: Parameters<_fromElsInterfaces[K]>)=> - ddeSignal[K]>>) - : (IsReadonly<_fromElsInterfaces, K> extends false - ? _fromElsInterfaces[K] | ddeSignal<_fromElsInterfaces[K]> - : ddeStringable) -} & AttrsModified> & Record; -export function classListDeclarative( - element: El, - classList: AttrsModified["classList"] -): El -export function assign(element: El, ...attrs_array: ElementAttributes[]): El -export function assignAttribute>( - element: El, - attr: ATT, - value: ElementAttributes[ATT] -): ElementAttributes[ATT] - -type ExtendedHTMLElementTagNameMap= HTMLElementTagNameMap & CustomElementTagNameMap; -export namespace el { - /** - * Creates a marker comment for elements - * - * @param attrs - Marker attributes - * @param [is_open=false] - Whether the marker is open-ended - * @returns Comment node marker - */ - export function mark( - attrs: { type: "component"|"reactive"|"later", name?: string, host?: "this"|"parentElement" }, - is_open?: boolean - ): Comment; -} - -export function el< - A extends ddeComponentAttributes, - EL extends SupportedElement | ddeDocumentFragment ->( - component: (attr: A, ...rest: any[])=> EL, - attrs?: NoInfer, - ...addons: ddeElementAddon[] -): EL extends ddeHTMLElementTagNameMap[keyof ddeHTMLElementTagNameMap] - ? EL - : ( EL extends ddeDocumentFragment ? EL : ddeHTMLElement ) -export function el< - A extends { textContent: ddeStringable }, - EL extends SupportedElement | ddeDocumentFragment ->( - component: (attr: A, ...rest: any[])=> EL, - attrs?: NoInfer["textContent"], - ...addons: ddeElementAddon[] -): EL extends ddeHTMLElementTagNameMap[keyof ddeHTMLElementTagNameMap] - ? EL - : ( EL extends ddeDocumentFragment ? EL : ddeHTMLElement ) -export function el< - TAG extends keyof ExtendedHTMLElementTagNameMap, ->( - tag_name: TAG, - attrs?: ElementAttributes]> | ddeStringable, - ...addons: ddeElementAddon< - ExtendedHTMLElementTagNameMap[NoInfer] - >[], // TODO: for now addons must have the same element -): TAG extends keyof ddeHTMLElementTagNameMap ? ddeHTMLElementTagNameMap[TAG] : ddeHTMLElement -export function el( - tag_name?: "<>", -): ddeDocumentFragment -export function el( - tag_name: string, - attrs?: ElementAttributes | ddeStringable, - ...addons: ddeElementAddon[] -): ddeHTMLElement -export { el as createElement } - -export function elNS( - namespace: "http://www.w3.org/2000/svg" -): < - TAG extends keyof SVGElementTagNameMap & string, - EL extends ( TAG extends keyof SVGElementTagNameMap ? SVGElementTagNameMap[TAG] : SVGElement ), ->( - tag_name: TAG, - attrs?: ElementAttributes> | ddeStringable, - ...addons: ddeElementAddon>[] -)=> TAG extends keyof ddeSVGElementTagNameMap ? ddeSVGElementTagNameMap[TAG] : ddeSVGElement -export function elNS( - namespace: "http://www.w3.org/1998/Math/MathML" -): < - TAG extends keyof MathMLElementTagNameMap & string, - EL extends ( TAG extends keyof MathMLElementTagNameMap ? MathMLElementTagNameMap[TAG] : MathMLElement ), ->( - tag_name: TAG, - attrs?: ddeStringable | Partial<{ - [key in keyof EL]: EL[key] | ddeSignal | string | number | boolean - }>, - ...addons: ddeElementAddon>[] -)=> ddeMathMLElement -export function elNS( - namespace: string -): ( - tag_name: string, - attrs?: string | ddeStringable | Record, - ...addons: ddeElementAddon[] -)=> SupportedElement -export { elNS as createElementNS } - -export function chainableAppend(el: EL): EL; -/** Simulate slots for ddeComponents */ -export function simulateSlots( - root: EL, -): EL -/** - * Simulate slots in Custom Elements without using `shadowRoot`. - * @param el Custom Element root element - * @param body Body of the custom element - * */ -export function simulateSlots( - el: HTMLElement, - body: EL, -): EL - -export function dispatchEvent(name: keyof DocumentEventMap | string, element: SupportedElement): - (data?: any)=> void; -export function dispatchEvent(name: keyof DocumentEventMap | string, options?: EventInit): - (element: SupportedElement, data?: any)=> void; -export function dispatchEvent( - name: keyof DocumentEventMap | string, - options: EventInit | null, - element: SupportedElement | (()=> SupportedElement) -): (data?: any)=> void; -interface On{ - /** Listens to the DOM event. See {@link Document.addEventListener} */ - < - Event extends keyof DocumentEventMap, - EE extends ddeElementAddon= ddeElementAddon, - >( - type: Event, - listener: (this: EE extends ddeElementAddon ? El : never, ev: DocumentEventMap[Event]) => any, - options?: AddEventListenerOptions - ) : EE; - < - EE extends ddeElementAddon= ddeElementAddon, - >( - type: string, - listener: (this: EE extends ddeElementAddon ? El : never, ev: Event | CustomEvent ) => any, - options?: AddEventListenerOptions - ) : EE; - /** Listens to the element is connected to the live DOM. In case of custom elements uses [`connectedCallback`](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#custom_element_lifecycle_callbacks), or {@link MutationObserver} else where */// editorconfig-checker-disable-line - connected< - EE extends ddeElementAddon, - El extends ( EE extends ddeElementAddon ? El : never ) - >( - listener: (this: El, event: CustomEvent) => any, - options?: AddEventListenerOptions - ) : EE; - /** Listens to the element is disconnected from the live DOM. In case of custom elements uses [`disconnectedCallback`](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#custom_element_lifecycle_callbacks), or {@link MutationObserver} else where */// editorconfig-checker-disable-line - disconnected< - EE extends ddeElementAddon, - El extends ( EE extends ddeElementAddon ? El : never ) - >( - listener: (this: El, event: CustomEvent) => any, - options?: AddEventListenerOptions - ) : EE; - /** Listens to the element attribute changes. In case of custom elements uses [`attributeChangedCallback`](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#custom_element_lifecycle_callbacks), or {@link MutationObserver} else where */// editorconfig-checker-disable-line - attributeChanged< - EE extends ddeElementAddon, - El extends ( EE extends ddeElementAddon ? El : never ) - >( - listener: (this: El, event: CustomEvent<[ string, string ]>) => any, - options?: AddEventListenerOptions - ) : EE; -} -export const on: On; - -type Scope= { - scope: Node | Function | Object, - host: ddeElementAddon, - custom_element: false | HTMLElement, - prevent: boolean -}; -/** Current scope created last time the `el(Function)` was invoke. (Or {@link scope.push}) */ -export const scope: { - current: Scope, - /** Stops all automatizations. E. g. signals used as attributes in current scope - * registers removing these listeners (and clean signal if no other listeners are detected) - * on `disconnected` event. */ - preventDefault(prevent: T): T, - /** - * This represents reference to the current host element — `scope.host()`. - * It can be also used to register Addon(s) (functions to be called when component is initized) - * — `scope.host(on.connected(console.log))`. - * */ - host: (...addons: ddeElementAddon[])=> HTMLElement, - - state: Scope[], - /** Adds new child scope. All attributes are inherited by default. */ - push(scope?: Partial): ReturnType["push"]>, - /** Adds root scope as a child of the current scope. */ - pushRoot(): ReturnType["push"]>, - /** Removes last/current child scope. */ - pop(): ReturnType["pop"]>, -}; - -export function customElementRender< - EL extends HTMLElement, - P extends any = Record> ->( - target: ShadowRoot | EL, - render: (props: P)=> SupportedElement | DocumentFragment, - props?: P | ((el: EL)=> P) -): EL -export function customElementWithDDE HTMLElement)>(custom_element: EL): EL -export function lifecyclesToEvents HTMLElement)>(custom_element: EL): EL -export function observedAttributes(custom_element: HTMLElement): Record - -/** - * This is used primarly for server side rendering. To be sure that all async operations - * are finished before the page is sent to the client. - * ``` - * // on component - * function component(){ - * … - * queue(fetch(...).then(...)); - * } - * - * // building the page - * async function build(){ - * const { component }= await import("./component.js"); - * document.body.append(el(component)); - * await queue(); - * retutn document.body.innerHTML; - * } - * ``` - * */ -export function queue(promise?: Promise): Promise; - -/* TypeScript MEH */ -declare global{ - type ddeAppend= (...nodes: (Node | string)[])=> el; - - interface ddeDocumentFragment extends DocumentFragment{ append: ddeAppend; } - interface ddeHTMLElement extends HTMLElement{ append: ddeAppend; } - interface ddeSVGElement extends SVGElement{ append: ddeAppend; } - interface ddeMathMLElement extends MathMLElement{ append: ddeAppend; } - - interface ddeHTMLElementTagNameMap { - "a": ddeHTMLAnchorElement; - "area": ddeHTMLAreaElement; - "audio": ddeHTMLAudioElement; - "base": ddeHTMLBaseElement; - "blockquote": ddeHTMLQuoteElement; - "body": ddeHTMLBodyElement; - "br": ddeHTMLBRElement; - "button": ddeHTMLButtonElement; - "canvas": ddeHTMLCanvasElement; - "caption": ddeHTMLTableCaptionElement; - "col": ddeHTMLTableColElement; - "colgroup": ddeHTMLTableColElement; - "data": ddeHTMLDataElement; - "datalist": ddeHTMLDataListElement; - "del": ddeHTMLModElement; - "details": ddeHTMLDetailsElement; - "dialog": ddeHTMLDialogElement; - "div": ddeHTMLDivElement; - "dl": ddeHTMLDListElement; - "embed": ddeHTMLEmbedElement; - "fieldset": ddeHTMLFieldSetElement; - "form": ddeHTMLFormElement; - "h1": ddeHTMLHeadingElement; - "h2": ddeHTMLHeadingElement; - "h3": ddeHTMLHeadingElement; - "h4": ddeHTMLHeadingElement; - "h5": ddeHTMLHeadingElement; - "h6": ddeHTMLHeadingElement; - "head": ddeHTMLHeadElement; - "hr": ddeHTMLHRElement; - "html": ddeHTMLHtmlElement; - "iframe": ddeHTMLIFrameElement; - "img": ddeHTMLImageElement; - "input": ddeHTMLInputElement; - "ins": ddeHTMLModElement; - "label": ddeHTMLLabelElement; - "legend": ddeHTMLLegendElement; - "li": ddeHTMLLIElement; - "link": ddeHTMLLinkElement; - "map": ddeHTMLMapElement; - "menu": ddeHTMLMenuElement; - "meta": ddeHTMLMetaElement; - "meter": ddeHTMLMeterElement; - "object": ddeHTMLObjectElement; - "ol": ddeHTMLOListElement; - "optgroup": ddeHTMLOptGroupElement; - "option": ddeHTMLOptionElement; - "output": ddeHTMLOutputElement; - "p": ddeHTMLParagraphElement; - "picture": ddeHTMLPictureElement; - "pre": ddeHTMLPreElement; - "progress": ddeHTMLProgressElement; - "q": ddeHTMLQuoteElement; - "script": ddeHTMLScriptElement; - "select": ddeHTMLSelectElement; - "slot": ddeHTMLSlotElement; - "source": ddeHTMLSourceElement; - "span": ddeHTMLSpanElement; - "style": ddeHTMLStyleElement; - "table": ddeHTMLTableElement; - "tbody": ddeHTMLTableSectionElement; - "td": ddeHTMLTableCellElement; - "template": ddeHTMLTemplateElement; - "textarea": ddeHTMLTextAreaElement; - "tfoot": ddeHTMLTableSectionElement; - "th": ddeHTMLTableCellElement; - "thead": ddeHTMLTableSectionElement; - "time": ddeHTMLTimeElement; - "title": ddeHTMLTitleElement; - "tr": ddeHTMLTableRowElement; - "track": ddeHTMLTrackElement; - "ul": ddeHTMLUListElement; - "video": ddeHTMLVideoElement; - } - interface ddeSVGElementTagNameMap { - "a": ddeSVGAElement; - "animate": ddeSVGAnimateElement; - "animateMotion": ddeSVGAnimateMotionElement; - "animateTransform": ddeSVGAnimateTransformElement; - "circle": ddeSVGCircleElement; - "clipPath": ddeSVGClipPathElement; - "defs": ddeSVGDefsElement; - "desc": ddeSVGDescElement; - "ellipse": ddeSVGEllipseElement; - "feBlend": ddeSVGFEBlendElement; - "feColorMatrix": ddeSVGFEColorMatrixElement; - "feComponentTransfer": ddeSVGFEComponentTransferElement; - "feComposite": ddeSVGFECompositeElement; - "feConvolveMatrix": ddeSVGFEConvolveMatrixElement; - "feDiffuseLighting": ddeSVGFEDiffuseLightingElement; - "feDisplacementMap": ddeSVGFEDisplacementMapElement; - "feDistantLight": ddeSVGFEDistantLightElement; - "feDropShadow": ddeSVGFEDropShadowElement; - "feFlood": ddeSVGFEFloodElement; - "feFuncA": ddeSVGFEFuncAElement; - "feFuncB": ddeSVGFEFuncBElement; - "feFuncG": ddeSVGFEFuncGElement; - "feFuncR": ddeSVGFEFuncRElement; - "feGaussianBlur": ddeSVGFEGaussianBlurElement; - "feImage": ddeSVGFEImageElement; - "feMerge": ddeSVGFEMergeElement; - "feMergeNode": ddeSVGFEMergeNodeElement; - "feMorphology": ddeSVGFEMorphologyElement; - "feOffset": ddeSVGFEOffsetElement; - "fePointLight": ddeSVGFEPointLightElement; - "feSpecularLighting": ddeSVGFESpecularLightingElement; - "feSpotLight": ddeSVGFESpotLightElement; - "feTile": ddeSVGFETileElement; - "feTurbulence": ddeSVGFETurbulenceElement; - "filter": ddeSVGFilterElement; - "foreignObject": ddeSVGForeignObjectElement; - "g": ddeSVGGElement; - "image": ddeSVGImageElement; - "line": ddeSVGLineElement; - "linearGradient": ddeSVGLinearGradientElement; - "marker": ddeSVGMarkerElement; - "mask": ddeSVGMaskElement; - "metadata": ddeSVGMetadataElement; - "mpath": ddeSVGMPathElement; - "path": ddeSVGPathElement; - "pattern": ddeSVGPatternElement; - "polygon": ddeSVGPolygonElement; - "polyline": ddeSVGPolylineElement; - "radialGradient": ddeSVGRadialGradientElement; - "rect": ddeSVGRectElement; - "script": ddeSVGScriptElement; - "set": ddeSVGSetElement; - "stop": ddeSVGStopElement; - "style": ddeSVGStyleElement; - "svg": ddeSVGSVGElement; - "switch": ddeSVGSwitchElement; - "symbol": ddeSVGSymbolElement; - "text": ddeSVGTextElement; - "textPath": ddeSVGTextPathElement; - "title": ddeSVGTitleElement; - "tspan": ddeSVGTSpanElement; - "use": ddeSVGUseElement; - "view": ddeSVGViewElement; - } -} - -// editorconfig-checker-disable -interface ddeHTMLAnchorElement extends HTMLAnchorElement{ append: ddeAppend; } -interface ddeHTMLAreaElement extends HTMLAreaElement{ append: ddeAppend; } -interface ddeHTMLAudioElement extends HTMLAudioElement{ append: ddeAppend; } -interface ddeHTMLBaseElement extends HTMLBaseElement{ append: ddeAppend; } -interface ddeHTMLQuoteElement extends HTMLQuoteElement{ append: ddeAppend; } -interface ddeHTMLBodyElement extends HTMLBodyElement{ append: ddeAppend; } -interface ddeHTMLBRElement extends HTMLBRElement{ append: ddeAppend; } -interface ddeHTMLButtonElement extends HTMLButtonElement{ append: ddeAppend; } -interface ddeHTMLCanvasElement extends HTMLCanvasElement{ append: ddeAppend; } -interface ddeHTMLTableCaptionElement extends HTMLTableCaptionElement{ append: ddeAppend; } -interface ddeHTMLTableColElement extends HTMLTableColElement{ append: ddeAppend; } -interface ddeHTMLTableColElement extends HTMLTableColElement{ append: ddeAppend; } -interface ddeHTMLDataElement extends HTMLDataElement{ append: ddeAppend; } -interface ddeHTMLDataListElement extends HTMLDataListElement{ append: ddeAppend; } -interface ddeHTMLModElement extends HTMLModElement{ append: ddeAppend; } -interface ddeHTMLDetailsElement extends HTMLDetailsElement{ append: ddeAppend; } -interface ddeHTMLDialogElement extends HTMLDialogElement{ append: ddeAppend; } -interface ddeHTMLDivElement extends HTMLDivElement{ append: ddeAppend; } -interface ddeHTMLDListElement extends HTMLDListElement{ append: ddeAppend; } -interface ddeHTMLEmbedElement extends HTMLEmbedElement{ append: ddeAppend; } -interface ddeHTMLFieldSetElement extends HTMLFieldSetElement{ append: ddeAppend; } -interface ddeHTMLFormElement extends HTMLFormElement{ append: ddeAppend; } -interface ddeHTMLHeadingElement extends HTMLHeadingElement{ append: ddeAppend; } -interface ddeHTMLHeadElement extends HTMLHeadElement{ append: ddeAppend; } -interface ddeHTMLHRElement extends HTMLHRElement{ append: ddeAppend; } -interface ddeHTMLHtmlElement extends HTMLHtmlElement{ append: ddeAppend; } -interface ddeHTMLIFrameElement extends HTMLIFrameElement{ append: ddeAppend; } -interface ddeHTMLImageElement extends HTMLImageElement{ append: ddeAppend; } -interface ddeHTMLInputElement extends HTMLInputElement{ append: ddeAppend; } -interface ddeHTMLLabelElement extends HTMLLabelElement{ append: ddeAppend; } -interface ddeHTMLLegendElement extends HTMLLegendElement{ append: ddeAppend; } -interface ddeHTMLLIElement extends HTMLLIElement{ append: ddeAppend; } -interface ddeHTMLLinkElement extends HTMLLinkElement{ append: ddeAppend; } -interface ddeHTMLMapElement extends HTMLMapElement{ append: ddeAppend; } -interface ddeHTMLMenuElement extends HTMLMenuElement{ append: ddeAppend; } -interface ddeHTMLMetaElement extends HTMLMetaElement{ append: ddeAppend; } -interface ddeHTMLMeterElement extends HTMLMeterElement{ append: ddeAppend; } -interface ddeHTMLObjectElement extends HTMLObjectElement{ append: ddeAppend; } -interface ddeHTMLOListElement extends HTMLOListElement{ append: ddeAppend; } -interface ddeHTMLOptGroupElement extends HTMLOptGroupElement{ append: ddeAppend; } -interface ddeHTMLOptionElement extends HTMLOptionElement{ append: ddeAppend; } -interface ddeHTMLOutputElement extends HTMLOutputElement{ append: ddeAppend; } -interface ddeHTMLParagraphElement extends HTMLParagraphElement{ append: ddeAppend; } -interface ddeHTMLPictureElement extends HTMLPictureElement{ append: ddeAppend; } -interface ddeHTMLPreElement extends HTMLPreElement{ append: ddeAppend; } -interface ddeHTMLProgressElement extends HTMLProgressElement{ append: ddeAppend; } -interface ddeHTMLScriptElement extends HTMLScriptElement{ append: ddeAppend; } -interface ddeHTMLSelectElement extends HTMLSelectElement{ append: ddeAppend; } -interface ddeHTMLSlotElement extends HTMLSlotElement{ append: ddeAppend; } -interface ddeHTMLSourceElement extends HTMLSourceElement{ append: ddeAppend; } -interface ddeHTMLSpanElement extends HTMLSpanElement{ append: ddeAppend; } -interface ddeHTMLStyleElement extends HTMLStyleElement{ append: ddeAppend; } -interface ddeHTMLTableElement extends HTMLTableElement{ append: ddeAppend; } -interface ddeHTMLTableSectionElement extends HTMLTableSectionElement{ append: ddeAppend; } -interface ddeHTMLTableCellElement extends HTMLTableCellElement{ append: ddeAppend; } -interface ddeHTMLTemplateElement extends HTMLTemplateElement{ append: ddeAppend; } -interface ddeHTMLTextAreaElement extends HTMLTextAreaElement{ append: ddeAppend; } -interface ddeHTMLTableCellElement extends HTMLTableCellElement{ append: ddeAppend; } -interface ddeHTMLTimeElement extends HTMLTimeElement{ append: ddeAppend; } -interface ddeHTMLTitleElement extends HTMLTitleElement{ append: ddeAppend; } -interface ddeHTMLTableRowElement extends HTMLTableRowElement{ append: ddeAppend; } -interface ddeHTMLTrackElement extends HTMLTrackElement{ append: ddeAppend; } -interface ddeHTMLUListElement extends HTMLUListElement{ append: ddeAppend; } -interface ddeHTMLVideoElement extends HTMLVideoElement{ append: ddeAppend; } -interface ddeSVGAElement extends SVGAElement{ append: ddeAppend; } -interface ddeSVGAnimateElement extends SVGAnimateElement{ append: ddeAppend; } -interface ddeSVGAnimateMotionElement extends SVGAnimateMotionElement{ append: ddeAppend; } -interface ddeSVGAnimateTransformElement extends SVGAnimateTransformElement{ append: ddeAppend; } -interface ddeSVGCircleElement extends SVGCircleElement{ append: ddeAppend; } -interface ddeSVGClipPathElement extends SVGClipPathElement{ append: ddeAppend; } -interface ddeSVGDefsElement extends SVGDefsElement{ append: ddeAppend; } -interface ddeSVGDescElement extends SVGDescElement{ append: ddeAppend; } -interface ddeSVGEllipseElement extends SVGEllipseElement{ append: ddeAppend; } -interface ddeSVGFEBlendElement extends SVGFEBlendElement{ append: ddeAppend; } -interface ddeSVGFEColorMatrixElement extends SVGFEColorMatrixElement{ append: ddeAppend; } -interface ddeSVGFEComponentTransferElement extends SVGFEComponentTransferElement{ append: ddeAppend; } -interface ddeSVGFECompositeElement extends SVGFECompositeElement{ append: ddeAppend; } -interface ddeSVGFEConvolveMatrixElement extends SVGFEConvolveMatrixElement{ append: ddeAppend; } -interface ddeSVGFEDiffuseLightingElement extends SVGFEDiffuseLightingElement{ append: ddeAppend; } -interface ddeSVGFEDisplacementMapElement extends SVGFEDisplacementMapElement{ append: ddeAppend; } -interface ddeSVGFEDistantLightElement extends SVGFEDistantLightElement{ append: ddeAppend; } -interface ddeSVGFEDropShadowElement extends SVGFEDropShadowElement{ append: ddeAppend; } -interface ddeSVGFEFloodElement extends SVGFEFloodElement{ append: ddeAppend; } -interface ddeSVGFEFuncAElement extends SVGFEFuncAElement{ append: ddeAppend; } -interface ddeSVGFEFuncBElement extends SVGFEFuncBElement{ append: ddeAppend; } -interface ddeSVGFEFuncGElement extends SVGFEFuncGElement{ append: ddeAppend; } -interface ddeSVGFEFuncRElement extends SVGFEFuncRElement{ append: ddeAppend; } -interface ddeSVGFEGaussianBlurElement extends SVGFEGaussianBlurElement{ append: ddeAppend; } -interface ddeSVGFEImageElement extends SVGFEImageElement{ append: ddeAppend; } -interface ddeSVGFEMergeElement extends SVGFEMergeElement{ append: ddeAppend; } -interface ddeSVGFEMergeNodeElement extends SVGFEMergeNodeElement{ append: ddeAppend; } -interface ddeSVGFEMorphologyElement extends SVGFEMorphologyElement{ append: ddeAppend; } -interface ddeSVGFEOffsetElement extends SVGFEOffsetElement{ append: ddeAppend; } -interface ddeSVGFEPointLightElement extends SVGFEPointLightElement{ append: ddeAppend; } -interface ddeSVGFESpecularLightingElement extends SVGFESpecularLightingElement{ append: ddeAppend; } -interface ddeSVGFESpotLightElement extends SVGFESpotLightElement{ append: ddeAppend; } -interface ddeSVGFETileElement extends SVGFETileElement{ append: ddeAppend; } -interface ddeSVGFETurbulenceElement extends SVGFETurbulenceElement{ append: ddeAppend; } -interface ddeSVGFilterElement extends SVGFilterElement{ append: ddeAppend; } -interface ddeSVGForeignObjectElement extends SVGForeignObjectElement{ append: ddeAppend; } -interface ddeSVGGElement extends SVGGElement{ append: ddeAppend; } -interface ddeSVGImageElement extends SVGImageElement{ append: ddeAppend; } -interface ddeSVGLineElement extends SVGLineElement{ append: ddeAppend; } -interface ddeSVGLinearGradientElement extends SVGLinearGradientElement{ append: ddeAppend; } -interface ddeSVGMarkerElement extends SVGMarkerElement{ append: ddeAppend; } -interface ddeSVGMaskElement extends SVGMaskElement{ append: ddeAppend; } -interface ddeSVGMetadataElement extends SVGMetadataElement{ append: ddeAppend; } -interface ddeSVGMPathElement extends SVGMPathElement{ append: ddeAppend; } -interface ddeSVGPathElement extends SVGPathElement{ append: ddeAppend; } -interface ddeSVGPatternElement extends SVGPatternElement{ append: ddeAppend; } -interface ddeSVGPolygonElement extends SVGPolygonElement{ append: ddeAppend; } -interface ddeSVGPolylineElement extends SVGPolylineElement{ append: ddeAppend; } -interface ddeSVGRadialGradientElement extends SVGRadialGradientElement{ append: ddeAppend; } -interface ddeSVGRectElement extends SVGRectElement{ append: ddeAppend; } -interface ddeSVGScriptElement extends SVGScriptElement{ append: ddeAppend; } -interface ddeSVGSetElement extends SVGSetElement{ append: ddeAppend; } -interface ddeSVGStopElement extends SVGStopElement{ append: ddeAppend; } -interface ddeSVGStyleElement extends SVGStyleElement{ append: ddeAppend; } -interface ddeSVGSVGElement extends SVGSVGElement{ append: ddeAppend; } -interface ddeSVGSwitchElement extends SVGSwitchElement{ append: ddeAppend; } -interface ddeSVGSymbolElement extends SVGSymbolElement{ append: ddeAppend; } -interface ddeSVGTextElement extends SVGTextElement{ append: ddeAppend; } -interface ddeSVGTextPathElement extends SVGTextPathElement{ append: ddeAppend; } -interface ddeSVGTitleElement extends SVGTitleElement{ append: ddeAppend; } -interface ddeSVGTSpanElement extends SVGTSpanElement{ append: ddeAppend; } -interface ddeSVGUseElement extends SVGUseElement{ append: ddeAppend; } -interface ddeSVGViewElement extends SVGViewElement{ append: ddeAppend; } -// editorconfig-checker-enable -export interface Signal { - /** The current value of the signal */ - get(): V; - /** Set new value of the signal */ - set(value: V): V; - toJSON(): V; - valueOf(): V; -} -type Action= (this: { value: V, stopPropagation(): void }, ...a: any[])=> typeof signal._ | void; -//type SymbolSignal= Symbol; -type SymbolOnclear= symbol; -type Actions= Record>; -type OnListenerOptions= Pick & { first_time?: boolean }; -interface signal{ - _: Symbol - /** - * Computations signal. This creates a signal which is computed from other signals. - * */ - any>(computation: V): Signal, {}> - /** - * Simple example: - * ```js - * const hello= S("Hello Signal"); - * ``` - * …simple todo signal: - * ```js - * const todos= S([], { - * add(v){ this.value.push(S(v)); }, - * remove(i){ this.value.splice(i, 1); }, - * [S.symbols.onclear](){ S.clear(...this.value); }, - * }); - * ``` - * …computed signal: - * ```js - * const name= S("Jan"); - * const surname= S("Andrle"); - * const fullname= S(()=> name.get()+" "+surname.get()); - * ``` - * @param value Initial signal value. Or function computing value from other signals. - * @param actions Use to define actions on the signal. Such as add item to the array. - * There is also a reserved function `S.symbol.onclear` which is called when the signal is cleared - * by `S.clear`. - * */ - >(value: V, actions?: A): Signal; - action>, A extends (S extends Signal ? A : never), N extends keyof A>( - signal: S, - name: N, - ...params: A[N] extends (...args: infer P)=> any ? P : never - ): void; - clear(...signals: Signal[]): void; - on(signal: Signal, onchange: (a: T)=> void, options?: OnListenerOptions): void; - symbols: { - //signal: SymbolSignal; - onclear: SymbolOnclear; - } - /** - * Reactive element, which is rendered based on the given signal. - * ```js - * S.el(signal, value=> value ? el("b", "True") : el("i", "False")); - * S.el(listS, list=> list.map(li=> el("li", li))); - * ``` - * */ - el(signal: Signal, el: (v: S)=> Element | Element[] | DocumentFragment): DocumentFragment; - - observedAttributes(custom_element: HTMLElement): Record>; -} -export const signal: signal; -export const S: signal; -declare global { - type ddeSignal= Signal; - type ddeAction= Action - type ddeActions= Actions -} \ No newline at end of file diff --git a/dist/esm.d.min.ts b/dist/esm.d.min.ts deleted file mode 100644 index 9ac112a..0000000 --- a/dist/esm.d.min.ts +++ /dev/null @@ -1,568 +0,0 @@ -declare global{ /* ddeSignal */ } -type CustomElementTagNameMap= { '#text': Text, '#comment': Comment } -type SupportedElement= - HTMLElementTagNameMap[keyof HTMLElementTagNameMap] - | SVGElementTagNameMap[keyof SVGElementTagNameMap] - | MathMLElementTagNameMap[keyof MathMLElementTagNameMap] - | CustomElementTagNameMap[keyof CustomElementTagNameMap] -declare global { - type ddeComponentAttributes= Record | undefined; - type ddeElementAddon= (element: El)=> any; - type ddeString= string | ddeSignal - type ddeStringable= ddeString | number | ddeSignal -} -type PascalCase= -`${Capitalize}${string}`; -type AttrsModified= { - /** - * Use string like in HTML (internally uses `*.setAttribute("style", *)`), or object representation (like DOM API). - */ - style: Partial | ddeString - | Partial<{ [K in keyof CSSStyleDeclaration]: ddeSignal }> - /** - * Provide option to add/remove/toggle CSS clasess (index of object) using 1/0/-1. - * In fact `el.classList.toggle(class_name)` for `-1` and `el.classList.toggle(class_name, Boolean(...))` - * for others. - */ - classList: Record>, - /** - * Used by the dataset HTML attribute to represent data for custom attributes added to elements. - * Values are converted to string (see {@link DOMStringMap}). - * - * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMStringMap) - * */ - dataset: Record, - /** - * Sets `aria-*` simiraly to `dataset` - * */ - ariaset: Record, -} & Record<`=${string}` | `data${PascalCase}` | `aria${PascalCase}`, ddeString> - & Record<`.${string}`, any> -type _fromElsInterfaces= Omit; -type IsReadonly = - T extends { readonly [P in K]: T[K] } ? true : false; -/** - * Just element attributtes - * - * In most cases, you can use native propertie such as - * [MDN WEB/API/Element](https://developer.mozilla.org/en-US/docs/Web/API/Element) and so on - * (e.g. [`Text`](https://developer.mozilla.org/en-US/docs/Web/API/Text)). - * - * There is added support for `data[A-Z].*`/`aria[A-Z].*` to be converted to the kebab-case alternatives. - * @private - */ -type ElementAttributes= Partial<{ - [K in keyof _fromElsInterfaces]: - _fromElsInterfaces[K] extends ((...p: any[])=> any) - ? _fromElsInterfaces[K] | ((...p: Parameters<_fromElsInterfaces[K]>)=> - ddeSignal[K]>>) - : (IsReadonly<_fromElsInterfaces, K> extends false - ? _fromElsInterfaces[K] | ddeSignal<_fromElsInterfaces[K]> - : ddeStringable) -} & AttrsModified> & Record; -export function classListDeclarative( - element: El, - classList: AttrsModified["classList"] -): El -export function assign(element: El, ...attrs_array: ElementAttributes[]): El -export function assignAttribute>( - element: El, - attr: ATT, - value: ElementAttributes[ATT] -): ElementAttributes[ATT] - -type ExtendedHTMLElementTagNameMap= HTMLElementTagNameMap & CustomElementTagNameMap; -export namespace el { - /** - * Creates a marker comment for elements - * - * @param attrs - Marker attributes - * @param [is_open=false] - Whether the marker is open-ended - * @returns Comment node marker - */ - export function mark( - attrs: { type: "component"|"reactive"|"later", name?: string, host?: "this"|"parentElement" }, - is_open?: boolean - ): Comment; -} - -export function el< - A extends ddeComponentAttributes, - EL extends SupportedElement | ddeDocumentFragment ->( - component: (attr: A, ...rest: any[])=> EL, - attrs?: NoInfer, - ...addons: ddeElementAddon[] -): EL extends ddeHTMLElementTagNameMap[keyof ddeHTMLElementTagNameMap] - ? EL - : ( EL extends ddeDocumentFragment ? EL : ddeHTMLElement ) -export function el< - A extends { textContent: ddeStringable }, - EL extends SupportedElement | ddeDocumentFragment ->( - component: (attr: A, ...rest: any[])=> EL, - attrs?: NoInfer["textContent"], - ...addons: ddeElementAddon[] -): EL extends ddeHTMLElementTagNameMap[keyof ddeHTMLElementTagNameMap] - ? EL - : ( EL extends ddeDocumentFragment ? EL : ddeHTMLElement ) -export function el< - TAG extends keyof ExtendedHTMLElementTagNameMap, ->( - tag_name: TAG, - attrs?: ElementAttributes]> | ddeStringable, - ...addons: ddeElementAddon< - ExtendedHTMLElementTagNameMap[NoInfer] - >[], // TODO: for now addons must have the same element -): TAG extends keyof ddeHTMLElementTagNameMap ? ddeHTMLElementTagNameMap[TAG] : ddeHTMLElement -export function el( - tag_name?: "<>", -): ddeDocumentFragment -export function el( - tag_name: string, - attrs?: ElementAttributes | ddeStringable, - ...addons: ddeElementAddon[] -): ddeHTMLElement -export { el as createElement } - -export function elNS( - namespace: "http://www.w3.org/2000/svg" -): < - TAG extends keyof SVGElementTagNameMap & string, - EL extends ( TAG extends keyof SVGElementTagNameMap ? SVGElementTagNameMap[TAG] : SVGElement ), ->( - tag_name: TAG, - attrs?: ElementAttributes> | ddeStringable, - ...addons: ddeElementAddon>[] -)=> TAG extends keyof ddeSVGElementTagNameMap ? ddeSVGElementTagNameMap[TAG] : ddeSVGElement -export function elNS( - namespace: "http://www.w3.org/1998/Math/MathML" -): < - TAG extends keyof MathMLElementTagNameMap & string, - EL extends ( TAG extends keyof MathMLElementTagNameMap ? MathMLElementTagNameMap[TAG] : MathMLElement ), ->( - tag_name: TAG, - attrs?: ddeStringable | Partial<{ - [key in keyof EL]: EL[key] | ddeSignal | string | number | boolean - }>, - ...addons: ddeElementAddon>[] -)=> ddeMathMLElement -export function elNS( - namespace: string -): ( - tag_name: string, - attrs?: string | ddeStringable | Record, - ...addons: ddeElementAddon[] -)=> SupportedElement -export { elNS as createElementNS } - -export function chainableAppend(el: EL): EL; -/** Simulate slots for ddeComponents */ -export function simulateSlots( - root: EL, -): EL -/** - * Simulate slots in Custom Elements without using `shadowRoot`. - * @param el Custom Element root element - * @param body Body of the custom element - * */ -export function simulateSlots( - el: HTMLElement, - body: EL, -): EL - -export function dispatchEvent(name: keyof DocumentEventMap | string, element: SupportedElement): - (data?: any)=> void; -export function dispatchEvent(name: keyof DocumentEventMap | string, options?: EventInit): - (element: SupportedElement, data?: any)=> void; -export function dispatchEvent( - name: keyof DocumentEventMap | string, - options: EventInit | null, - element: SupportedElement | (()=> SupportedElement) -): (data?: any)=> void; -interface On{ - /** Listens to the DOM event. See {@link Document.addEventListener} */ - < - Event extends keyof DocumentEventMap, - EE extends ddeElementAddon= ddeElementAddon, - >( - type: Event, - listener: (this: EE extends ddeElementAddon ? El : never, ev: DocumentEventMap[Event]) => any, - options?: AddEventListenerOptions - ) : EE; - < - EE extends ddeElementAddon= ddeElementAddon, - >( - type: string, - listener: (this: EE extends ddeElementAddon ? El : never, ev: Event | CustomEvent ) => any, - options?: AddEventListenerOptions - ) : EE; - /** Listens to the element is connected to the live DOM. In case of custom elements uses [`connectedCallback`](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#custom_element_lifecycle_callbacks), or {@link MutationObserver} else where */// editorconfig-checker-disable-line - connected< - EE extends ddeElementAddon, - El extends ( EE extends ddeElementAddon ? El : never ) - >( - listener: (this: El, event: CustomEvent) => any, - options?: AddEventListenerOptions - ) : EE; - /** Listens to the element is disconnected from the live DOM. In case of custom elements uses [`disconnectedCallback`](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#custom_element_lifecycle_callbacks), or {@link MutationObserver} else where */// editorconfig-checker-disable-line - disconnected< - EE extends ddeElementAddon, - El extends ( EE extends ddeElementAddon ? El : never ) - >( - listener: (this: El, event: CustomEvent) => any, - options?: AddEventListenerOptions - ) : EE; - /** Listens to the element attribute changes. In case of custom elements uses [`attributeChangedCallback`](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#custom_element_lifecycle_callbacks), or {@link MutationObserver} else where */// editorconfig-checker-disable-line - attributeChanged< - EE extends ddeElementAddon, - El extends ( EE extends ddeElementAddon ? El : never ) - >( - listener: (this: El, event: CustomEvent<[ string, string ]>) => any, - options?: AddEventListenerOptions - ) : EE; -} -export const on: On; - -type Scope= { - scope: Node | Function | Object, - host: ddeElementAddon, - custom_element: false | HTMLElement, - prevent: boolean -}; -/** Current scope created last time the `el(Function)` was invoke. (Or {@link scope.push}) */ -export const scope: { - current: Scope, - /** Stops all automatizations. E. g. signals used as attributes in current scope - * registers removing these listeners (and clean signal if no other listeners are detected) - * on `disconnected` event. */ - preventDefault(prevent: T): T, - /** - * This represents reference to the current host element — `scope.host()`. - * It can be also used to register Addon(s) (functions to be called when component is initized) - * — `scope.host(on.connected(console.log))`. - * */ - host: (...addons: ddeElementAddon[])=> HTMLElement, - - state: Scope[], - /** Adds new child scope. All attributes are inherited by default. */ - push(scope?: Partial): ReturnType["push"]>, - /** Adds root scope as a child of the current scope. */ - pushRoot(): ReturnType["push"]>, - /** Removes last/current child scope. */ - pop(): ReturnType["pop"]>, -}; - -export function customElementRender< - EL extends HTMLElement, - P extends any = Record> ->( - target: ShadowRoot | EL, - render: (props: P)=> SupportedElement | DocumentFragment, - props?: P | ((el: EL)=> P) -): EL -export function customElementWithDDE HTMLElement)>(custom_element: EL): EL -export function lifecyclesToEvents HTMLElement)>(custom_element: EL): EL -export function observedAttributes(custom_element: HTMLElement): Record - -/** - * This is used primarly for server side rendering. To be sure that all async operations - * are finished before the page is sent to the client. - * ``` - * // on component - * function component(){ - * … - * queue(fetch(...).then(...)); - * } - * - * // building the page - * async function build(){ - * const { component }= await import("./component.js"); - * document.body.append(el(component)); - * await queue(); - * retutn document.body.innerHTML; - * } - * ``` - * */ -export function queue(promise?: Promise): Promise; - -/* TypeScript MEH */ -declare global{ - type ddeAppend= (...nodes: (Node | string)[])=> el; - - interface ddeDocumentFragment extends DocumentFragment{ append: ddeAppend; } - interface ddeHTMLElement extends HTMLElement{ append: ddeAppend; } - interface ddeSVGElement extends SVGElement{ append: ddeAppend; } - interface ddeMathMLElement extends MathMLElement{ append: ddeAppend; } - - interface ddeHTMLElementTagNameMap { - "a": ddeHTMLAnchorElement; - "area": ddeHTMLAreaElement; - "audio": ddeHTMLAudioElement; - "base": ddeHTMLBaseElement; - "blockquote": ddeHTMLQuoteElement; - "body": ddeHTMLBodyElement; - "br": ddeHTMLBRElement; - "button": ddeHTMLButtonElement; - "canvas": ddeHTMLCanvasElement; - "caption": ddeHTMLTableCaptionElement; - "col": ddeHTMLTableColElement; - "colgroup": ddeHTMLTableColElement; - "data": ddeHTMLDataElement; - "datalist": ddeHTMLDataListElement; - "del": ddeHTMLModElement; - "details": ddeHTMLDetailsElement; - "dialog": ddeHTMLDialogElement; - "div": ddeHTMLDivElement; - "dl": ddeHTMLDListElement; - "embed": ddeHTMLEmbedElement; - "fieldset": ddeHTMLFieldSetElement; - "form": ddeHTMLFormElement; - "h1": ddeHTMLHeadingElement; - "h2": ddeHTMLHeadingElement; - "h3": ddeHTMLHeadingElement; - "h4": ddeHTMLHeadingElement; - "h5": ddeHTMLHeadingElement; - "h6": ddeHTMLHeadingElement; - "head": ddeHTMLHeadElement; - "hr": ddeHTMLHRElement; - "html": ddeHTMLHtmlElement; - "iframe": ddeHTMLIFrameElement; - "img": ddeHTMLImageElement; - "input": ddeHTMLInputElement; - "ins": ddeHTMLModElement; - "label": ddeHTMLLabelElement; - "legend": ddeHTMLLegendElement; - "li": ddeHTMLLIElement; - "link": ddeHTMLLinkElement; - "map": ddeHTMLMapElement; - "menu": ddeHTMLMenuElement; - "meta": ddeHTMLMetaElement; - "meter": ddeHTMLMeterElement; - "object": ddeHTMLObjectElement; - "ol": ddeHTMLOListElement; - "optgroup": ddeHTMLOptGroupElement; - "option": ddeHTMLOptionElement; - "output": ddeHTMLOutputElement; - "p": ddeHTMLParagraphElement; - "picture": ddeHTMLPictureElement; - "pre": ddeHTMLPreElement; - "progress": ddeHTMLProgressElement; - "q": ddeHTMLQuoteElement; - "script": ddeHTMLScriptElement; - "select": ddeHTMLSelectElement; - "slot": ddeHTMLSlotElement; - "source": ddeHTMLSourceElement; - "span": ddeHTMLSpanElement; - "style": ddeHTMLStyleElement; - "table": ddeHTMLTableElement; - "tbody": ddeHTMLTableSectionElement; - "td": ddeHTMLTableCellElement; - "template": ddeHTMLTemplateElement; - "textarea": ddeHTMLTextAreaElement; - "tfoot": ddeHTMLTableSectionElement; - "th": ddeHTMLTableCellElement; - "thead": ddeHTMLTableSectionElement; - "time": ddeHTMLTimeElement; - "title": ddeHTMLTitleElement; - "tr": ddeHTMLTableRowElement; - "track": ddeHTMLTrackElement; - "ul": ddeHTMLUListElement; - "video": ddeHTMLVideoElement; - } - interface ddeSVGElementTagNameMap { - "a": ddeSVGAElement; - "animate": ddeSVGAnimateElement; - "animateMotion": ddeSVGAnimateMotionElement; - "animateTransform": ddeSVGAnimateTransformElement; - "circle": ddeSVGCircleElement; - "clipPath": ddeSVGClipPathElement; - "defs": ddeSVGDefsElement; - "desc": ddeSVGDescElement; - "ellipse": ddeSVGEllipseElement; - "feBlend": ddeSVGFEBlendElement; - "feColorMatrix": ddeSVGFEColorMatrixElement; - "feComponentTransfer": ddeSVGFEComponentTransferElement; - "feComposite": ddeSVGFECompositeElement; - "feConvolveMatrix": ddeSVGFEConvolveMatrixElement; - "feDiffuseLighting": ddeSVGFEDiffuseLightingElement; - "feDisplacementMap": ddeSVGFEDisplacementMapElement; - "feDistantLight": ddeSVGFEDistantLightElement; - "feDropShadow": ddeSVGFEDropShadowElement; - "feFlood": ddeSVGFEFloodElement; - "feFuncA": ddeSVGFEFuncAElement; - "feFuncB": ddeSVGFEFuncBElement; - "feFuncG": ddeSVGFEFuncGElement; - "feFuncR": ddeSVGFEFuncRElement; - "feGaussianBlur": ddeSVGFEGaussianBlurElement; - "feImage": ddeSVGFEImageElement; - "feMerge": ddeSVGFEMergeElement; - "feMergeNode": ddeSVGFEMergeNodeElement; - "feMorphology": ddeSVGFEMorphologyElement; - "feOffset": ddeSVGFEOffsetElement; - "fePointLight": ddeSVGFEPointLightElement; - "feSpecularLighting": ddeSVGFESpecularLightingElement; - "feSpotLight": ddeSVGFESpotLightElement; - "feTile": ddeSVGFETileElement; - "feTurbulence": ddeSVGFETurbulenceElement; - "filter": ddeSVGFilterElement; - "foreignObject": ddeSVGForeignObjectElement; - "g": ddeSVGGElement; - "image": ddeSVGImageElement; - "line": ddeSVGLineElement; - "linearGradient": ddeSVGLinearGradientElement; - "marker": ddeSVGMarkerElement; - "mask": ddeSVGMaskElement; - "metadata": ddeSVGMetadataElement; - "mpath": ddeSVGMPathElement; - "path": ddeSVGPathElement; - "pattern": ddeSVGPatternElement; - "polygon": ddeSVGPolygonElement; - "polyline": ddeSVGPolylineElement; - "radialGradient": ddeSVGRadialGradientElement; - "rect": ddeSVGRectElement; - "script": ddeSVGScriptElement; - "set": ddeSVGSetElement; - "stop": ddeSVGStopElement; - "style": ddeSVGStyleElement; - "svg": ddeSVGSVGElement; - "switch": ddeSVGSwitchElement; - "symbol": ddeSVGSymbolElement; - "text": ddeSVGTextElement; - "textPath": ddeSVGTextPathElement; - "title": ddeSVGTitleElement; - "tspan": ddeSVGTSpanElement; - "use": ddeSVGUseElement; - "view": ddeSVGViewElement; - } -} - -// editorconfig-checker-disable -interface ddeHTMLAnchorElement extends HTMLAnchorElement{ append: ddeAppend; } -interface ddeHTMLAreaElement extends HTMLAreaElement{ append: ddeAppend; } -interface ddeHTMLAudioElement extends HTMLAudioElement{ append: ddeAppend; } -interface ddeHTMLBaseElement extends HTMLBaseElement{ append: ddeAppend; } -interface ddeHTMLQuoteElement extends HTMLQuoteElement{ append: ddeAppend; } -interface ddeHTMLBodyElement extends HTMLBodyElement{ append: ddeAppend; } -interface ddeHTMLBRElement extends HTMLBRElement{ append: ddeAppend; } -interface ddeHTMLButtonElement extends HTMLButtonElement{ append: ddeAppend; } -interface ddeHTMLCanvasElement extends HTMLCanvasElement{ append: ddeAppend; } -interface ddeHTMLTableCaptionElement extends HTMLTableCaptionElement{ append: ddeAppend; } -interface ddeHTMLTableColElement extends HTMLTableColElement{ append: ddeAppend; } -interface ddeHTMLTableColElement extends HTMLTableColElement{ append: ddeAppend; } -interface ddeHTMLDataElement extends HTMLDataElement{ append: ddeAppend; } -interface ddeHTMLDataListElement extends HTMLDataListElement{ append: ddeAppend; } -interface ddeHTMLModElement extends HTMLModElement{ append: ddeAppend; } -interface ddeHTMLDetailsElement extends HTMLDetailsElement{ append: ddeAppend; } -interface ddeHTMLDialogElement extends HTMLDialogElement{ append: ddeAppend; } -interface ddeHTMLDivElement extends HTMLDivElement{ append: ddeAppend; } -interface ddeHTMLDListElement extends HTMLDListElement{ append: ddeAppend; } -interface ddeHTMLEmbedElement extends HTMLEmbedElement{ append: ddeAppend; } -interface ddeHTMLFieldSetElement extends HTMLFieldSetElement{ append: ddeAppend; } -interface ddeHTMLFormElement extends HTMLFormElement{ append: ddeAppend; } -interface ddeHTMLHeadingElement extends HTMLHeadingElement{ append: ddeAppend; } -interface ddeHTMLHeadElement extends HTMLHeadElement{ append: ddeAppend; } -interface ddeHTMLHRElement extends HTMLHRElement{ append: ddeAppend; } -interface ddeHTMLHtmlElement extends HTMLHtmlElement{ append: ddeAppend; } -interface ddeHTMLIFrameElement extends HTMLIFrameElement{ append: ddeAppend; } -interface ddeHTMLImageElement extends HTMLImageElement{ append: ddeAppend; } -interface ddeHTMLInputElement extends HTMLInputElement{ append: ddeAppend; } -interface ddeHTMLLabelElement extends HTMLLabelElement{ append: ddeAppend; } -interface ddeHTMLLegendElement extends HTMLLegendElement{ append: ddeAppend; } -interface ddeHTMLLIElement extends HTMLLIElement{ append: ddeAppend; } -interface ddeHTMLLinkElement extends HTMLLinkElement{ append: ddeAppend; } -interface ddeHTMLMapElement extends HTMLMapElement{ append: ddeAppend; } -interface ddeHTMLMenuElement extends HTMLMenuElement{ append: ddeAppend; } -interface ddeHTMLMetaElement extends HTMLMetaElement{ append: ddeAppend; } -interface ddeHTMLMeterElement extends HTMLMeterElement{ append: ddeAppend; } -interface ddeHTMLObjectElement extends HTMLObjectElement{ append: ddeAppend; } -interface ddeHTMLOListElement extends HTMLOListElement{ append: ddeAppend; } -interface ddeHTMLOptGroupElement extends HTMLOptGroupElement{ append: ddeAppend; } -interface ddeHTMLOptionElement extends HTMLOptionElement{ append: ddeAppend; } -interface ddeHTMLOutputElement extends HTMLOutputElement{ append: ddeAppend; } -interface ddeHTMLParagraphElement extends HTMLParagraphElement{ append: ddeAppend; } -interface ddeHTMLPictureElement extends HTMLPictureElement{ append: ddeAppend; } -interface ddeHTMLPreElement extends HTMLPreElement{ append: ddeAppend; } -interface ddeHTMLProgressElement extends HTMLProgressElement{ append: ddeAppend; } -interface ddeHTMLScriptElement extends HTMLScriptElement{ append: ddeAppend; } -interface ddeHTMLSelectElement extends HTMLSelectElement{ append: ddeAppend; } -interface ddeHTMLSlotElement extends HTMLSlotElement{ append: ddeAppend; } -interface ddeHTMLSourceElement extends HTMLSourceElement{ append: ddeAppend; } -interface ddeHTMLSpanElement extends HTMLSpanElement{ append: ddeAppend; } -interface ddeHTMLStyleElement extends HTMLStyleElement{ append: ddeAppend; } -interface ddeHTMLTableElement extends HTMLTableElement{ append: ddeAppend; } -interface ddeHTMLTableSectionElement extends HTMLTableSectionElement{ append: ddeAppend; } -interface ddeHTMLTableCellElement extends HTMLTableCellElement{ append: ddeAppend; } -interface ddeHTMLTemplateElement extends HTMLTemplateElement{ append: ddeAppend; } -interface ddeHTMLTextAreaElement extends HTMLTextAreaElement{ append: ddeAppend; } -interface ddeHTMLTableCellElement extends HTMLTableCellElement{ append: ddeAppend; } -interface ddeHTMLTimeElement extends HTMLTimeElement{ append: ddeAppend; } -interface ddeHTMLTitleElement extends HTMLTitleElement{ append: ddeAppend; } -interface ddeHTMLTableRowElement extends HTMLTableRowElement{ append: ddeAppend; } -interface ddeHTMLTrackElement extends HTMLTrackElement{ append: ddeAppend; } -interface ddeHTMLUListElement extends HTMLUListElement{ append: ddeAppend; } -interface ddeHTMLVideoElement extends HTMLVideoElement{ append: ddeAppend; } -interface ddeSVGAElement extends SVGAElement{ append: ddeAppend; } -interface ddeSVGAnimateElement extends SVGAnimateElement{ append: ddeAppend; } -interface ddeSVGAnimateMotionElement extends SVGAnimateMotionElement{ append: ddeAppend; } -interface ddeSVGAnimateTransformElement extends SVGAnimateTransformElement{ append: ddeAppend; } -interface ddeSVGCircleElement extends SVGCircleElement{ append: ddeAppend; } -interface ddeSVGClipPathElement extends SVGClipPathElement{ append: ddeAppend; } -interface ddeSVGDefsElement extends SVGDefsElement{ append: ddeAppend; } -interface ddeSVGDescElement extends SVGDescElement{ append: ddeAppend; } -interface ddeSVGEllipseElement extends SVGEllipseElement{ append: ddeAppend; } -interface ddeSVGFEBlendElement extends SVGFEBlendElement{ append: ddeAppend; } -interface ddeSVGFEColorMatrixElement extends SVGFEColorMatrixElement{ append: ddeAppend; } -interface ddeSVGFEComponentTransferElement extends SVGFEComponentTransferElement{ append: ddeAppend; } -interface ddeSVGFECompositeElement extends SVGFECompositeElement{ append: ddeAppend; } -interface ddeSVGFEConvolveMatrixElement extends SVGFEConvolveMatrixElement{ append: ddeAppend; } -interface ddeSVGFEDiffuseLightingElement extends SVGFEDiffuseLightingElement{ append: ddeAppend; } -interface ddeSVGFEDisplacementMapElement extends SVGFEDisplacementMapElement{ append: ddeAppend; } -interface ddeSVGFEDistantLightElement extends SVGFEDistantLightElement{ append: ddeAppend; } -interface ddeSVGFEDropShadowElement extends SVGFEDropShadowElement{ append: ddeAppend; } -interface ddeSVGFEFloodElement extends SVGFEFloodElement{ append: ddeAppend; } -interface ddeSVGFEFuncAElement extends SVGFEFuncAElement{ append: ddeAppend; } -interface ddeSVGFEFuncBElement extends SVGFEFuncBElement{ append: ddeAppend; } -interface ddeSVGFEFuncGElement extends SVGFEFuncGElement{ append: ddeAppend; } -interface ddeSVGFEFuncRElement extends SVGFEFuncRElement{ append: ddeAppend; } -interface ddeSVGFEGaussianBlurElement extends SVGFEGaussianBlurElement{ append: ddeAppend; } -interface ddeSVGFEImageElement extends SVGFEImageElement{ append: ddeAppend; } -interface ddeSVGFEMergeElement extends SVGFEMergeElement{ append: ddeAppend; } -interface ddeSVGFEMergeNodeElement extends SVGFEMergeNodeElement{ append: ddeAppend; } -interface ddeSVGFEMorphologyElement extends SVGFEMorphologyElement{ append: ddeAppend; } -interface ddeSVGFEOffsetElement extends SVGFEOffsetElement{ append: ddeAppend; } -interface ddeSVGFEPointLightElement extends SVGFEPointLightElement{ append: ddeAppend; } -interface ddeSVGFESpecularLightingElement extends SVGFESpecularLightingElement{ append: ddeAppend; } -interface ddeSVGFESpotLightElement extends SVGFESpotLightElement{ append: ddeAppend; } -interface ddeSVGFETileElement extends SVGFETileElement{ append: ddeAppend; } -interface ddeSVGFETurbulenceElement extends SVGFETurbulenceElement{ append: ddeAppend; } -interface ddeSVGFilterElement extends SVGFilterElement{ append: ddeAppend; } -interface ddeSVGForeignObjectElement extends SVGForeignObjectElement{ append: ddeAppend; } -interface ddeSVGGElement extends SVGGElement{ append: ddeAppend; } -interface ddeSVGImageElement extends SVGImageElement{ append: ddeAppend; } -interface ddeSVGLineElement extends SVGLineElement{ append: ddeAppend; } -interface ddeSVGLinearGradientElement extends SVGLinearGradientElement{ append: ddeAppend; } -interface ddeSVGMarkerElement extends SVGMarkerElement{ append: ddeAppend; } -interface ddeSVGMaskElement extends SVGMaskElement{ append: ddeAppend; } -interface ddeSVGMetadataElement extends SVGMetadataElement{ append: ddeAppend; } -interface ddeSVGMPathElement extends SVGMPathElement{ append: ddeAppend; } -interface ddeSVGPathElement extends SVGPathElement{ append: ddeAppend; } -interface ddeSVGPatternElement extends SVGPatternElement{ append: ddeAppend; } -interface ddeSVGPolygonElement extends SVGPolygonElement{ append: ddeAppend; } -interface ddeSVGPolylineElement extends SVGPolylineElement{ append: ddeAppend; } -interface ddeSVGRadialGradientElement extends SVGRadialGradientElement{ append: ddeAppend; } -interface ddeSVGRectElement extends SVGRectElement{ append: ddeAppend; } -interface ddeSVGScriptElement extends SVGScriptElement{ append: ddeAppend; } -interface ddeSVGSetElement extends SVGSetElement{ append: ddeAppend; } -interface ddeSVGStopElement extends SVGStopElement{ append: ddeAppend; } -interface ddeSVGStyleElement extends SVGStyleElement{ append: ddeAppend; } -interface ddeSVGSVGElement extends SVGSVGElement{ append: ddeAppend; } -interface ddeSVGSwitchElement extends SVGSwitchElement{ append: ddeAppend; } -interface ddeSVGSymbolElement extends SVGSymbolElement{ append: ddeAppend; } -interface ddeSVGTextElement extends SVGTextElement{ append: ddeAppend; } -interface ddeSVGTextPathElement extends SVGTextPathElement{ append: ddeAppend; } -interface ddeSVGTitleElement extends SVGTitleElement{ append: ddeAppend; } -interface ddeSVGTSpanElement extends SVGTSpanElement{ append: ddeAppend; } -interface ddeSVGUseElement extends SVGUseElement{ append: ddeAppend; } -interface ddeSVGViewElement extends SVGViewElement{ append: ddeAppend; } -// editorconfig-checker-enable \ No newline at end of file diff --git a/examples/components/3rd-party.js b/examples/components/3rd-party.js deleted file mode 100644 index 4b5d7b7..0000000 --- a/examples/components/3rd-party.js +++ /dev/null @@ -1,51 +0,0 @@ -import { style, el, S, isSignal } from '../exports.js'; -const className= style.host(thirdParty).css` - :host { - color: green; - } -`; - -const store_adapter= { - read(){ return (new URL(location)).searchParams; }, - write(data){ console.log(data); history.replaceState("", "", "?"+(new URLSearchParams(data)).toString()); } -}; -export function thirdParty(){ - const store= S({ - value: S("initial") - }, { - set(key, value){ - const p= this.value[key] || S(); - p.set(value); - this.value[key]= p; - } - }); - // Array.from((new URL(location)).searchParams.entries()) - // .forEach(([ key, value ])=> S.action(store, "set", key, value)); - // S.on(store, data=> history.replaceState("", "", - // "?"+(new URLSearchParams(JSON.parse(JSON.stringify(data)))).toString())); - useStore(store_adapter, { - onread(data){ - Array.from(data.entries()) - .forEach(([ key, value ])=> S.action(store, "set", key, value)); - return store; - } - })(); - return el("input", { - className, - value: store.get().value.get(), - type: "text", - onchange: ev=> S.action(store, "set", "value", ev.target.value) - }); -} - -function useStore(adapter_in, { onread, onbeforewrite }= {}){ - const adapter= typeof adapter_in === "function" ? { read: adapter_in } : adapter_in; - if(!onread) onread= S; - if(!onbeforewrite) onbeforewrite= data=> JSON.parse(JSON.stringify(data)); - return function useStoreInner(data_read){ - const signal= onread(adapter.read(data_read)); //TODO OK as synchronous - if(adapter.write && isSignal(signal)) - S.on(signal, data=> adapter.write(onbeforewrite(data))); - return signal; - }; -} diff --git a/examples/components/fullNameComponent.js b/examples/components/fullNameComponent.js deleted file mode 100644 index c0e2179..0000000 --- a/examples/components/fullNameComponent.js +++ /dev/null @@ -1,42 +0,0 @@ -import { style, el, elNS, on, S, scope } from '../exports.js'; -const className= style.host(fullNameComponent).css` - :host form{ - display: flex; - flex-flow: column nowrap; - } -`; -export function fullNameComponent(){ - const labels= [ "Name", "Surname" ]; - const name= labels.map(_=> S("")); - const full_name= S(()=> - name.map(l=> l.get()).filter(Boolean).join(" ") || "-"); - scope.host( - on.connected(()=> console.log(fullNameComponent)), - on.disconnected(()=> console.log(fullNameComponent)) - ); - - const count= S(0); - setInterval(()=> count.set(count.get()+1), 5000); - const style= { height: "80px", display: "block", fill: "currentColor" }; - const elSVG= elNS("http://www.w3.org/2000/svg"); - return el("div", { className }).append( - el("h2", "Simple form:"), - el("p", { textContent: S(()=> "Count: "+count.get()), - dataset: { count }, classList: { count: S(() => count.get()%2 === 0) } }), - el("form", { onsubmit: ev=> ev.preventDefault() }).append( - ...name.map((v, i)=> - el("label", labels[i]).append( - el("input", { type: "text", name: labels[i], value: v.get() }, on("change", ev=> v.set(ev.target.value))) - )) - ), - el("p").append( - el("strong", "Full name"), - ": ", - el("#text", full_name) - ), - elSVG("svg", { viewBox: "0 0 240 80", style }).append( - //elSVG("style", { }) - elSVG("text", { x: 20, y: 35, textContent: "Text" }), - ) - ); -} diff --git a/examples/components/todosComponent.js b/examples/components/todosComponent.js deleted file mode 100644 index 9f552ba..0000000 --- a/examples/components/todosComponent.js +++ /dev/null @@ -1,93 +0,0 @@ -import { style, el, dispatchEvent, on, S, scope } from '../exports.js'; -const className= style.host(todosComponent).css` - :host{ - display: flex; - flex-flow: column nowrap; - } - :host input{ - margin-inline-start: .5em; - } - :host button{ - margin-inline-start: 1em; - } - :host output{ - white-space: pre; - } -`; -/** @param {{ todos: string[] }} */ -export function todosComponent({ todos= [ "Task A" ] }= {}){ - let key= 0; - const todosO= S( /** @type {Map>} */ (new Map()), { - /** @param {string} v */ - add(v){ this.value.set(key++, S(v)); }, - /** @param {number} key */ - remove(key){ S.clear(this.value.get(key)); this.value.delete(key); } - }); - todos.forEach(text=> S.action(todosO, "add", text)); - - const name= "todoName"; - const onsubmitAdd= on("submit", event=> { - const el_form= /** @type {HTMLFormElement} */ (event.target); - const el= /** @type {HTMLInputElement} */ (el_form.elements[name]); - event.preventDefault(); - S.action(todosO, "add", el.value); - el.value= ""; - }); - const onremove= on("remove", /** @param {CustomEvent} event */ - event=> S.action(todosO, "remove", event.detail)); - - return el("div", { className }).append( - el("div").append( - el("h2", "Todos:"), - el("h3", "List of todos:"), - S.el(todosO, (ts, memo)=> !ts.size - ? el("p", "No todos yet") - : el("ul").append( - ...Array.from(ts).map(([ value, textContent ])=> - memo(value, ()=> el(todoComponent, { textContent, value, className }, onremove))) - ), - ), - el("p", "Click to the text to edit it.") - ), - el("form", null, onsubmitAdd).append( - el("h3", "Add a todo:"), - el("label", "New todo: ").append( - el("input", { name, type: "text", required: true }), - ), - el("button", "+"), - ), - el("div").append( - el("h3", "Output (JSON):"), - el("output", S(()=> JSON.stringify(Array.from(todosO.get()), null, "\t"))) - ) - ) -} -/** - * @param {{ textContent: ddeSignal, value: ddeSignal }} attrs - * @dispatchs {number} remove - * */ -function todoComponent({ textContent, value }){ - const { host }= scope; - const dispatchRemove= /** @type {(data: number) => void} */ - (dispatchEvent("remove", null, host)); - const onclick= on("click", event=> { - const el= /** @type {HTMLButtonElement} */ (event.target); - const value= Number(el.value); - event.preventDefault(); - event.stopPropagation(); - dispatchRemove(value); - }); - const is_editable= S(false); - const onedited= on("change", ev=> { - const el= /** @type {HTMLInputElement} */ (ev.target); - textContent.set(el.value); - is_editable.set(false); - }); - return el("li").append( - S.el(is_editable, is=> is - ? el("input", { value: textContent.get(), type: "text" }, onedited) - : el("span", { textContent, onclick: ()=> is_editable.set(true) }) - ), - el("button", { type: "button", value, textContent: "-" }, onclick) - ); -} diff --git a/examples/components/webComponent.js b/examples/components/webComponent.js deleted file mode 100644 index 1126cd9..0000000 --- a/examples/components/webComponent.js +++ /dev/null @@ -1,70 +0,0 @@ -import { el, on, customElementRender, customElementWithDDE, scope, simulateSlots } from "../../index.js"; -import { S } from "../../signals.js"; - -/** - * Compatible with `npx -y web-component-analyzer examples/components/webComponent.js` - * @element custom-test - * */ -export class CustomHTMLTestElement extends HTMLElement{ - static tagName= "custom-test"; - static get observedAttributes(){ - return [ "name", "pre-name" ]; - } - connectedCallback(){ - if(!this.hasAttribute("pre-name")) this.setAttribute("pre-name", "default"); - customElementRender(this.attachShadow({ mode: "open" }), this.render, this.attributes) - } - - attributes(element){ - const observed= S.observedAttributes(element); - return Object.assign({ test: element.test }, observed); - } - render({ name, preName, test }){ - console.log(scope.state); - scope.host( - on.connected(console.log), - on.attributeChanged(e=> console.log(e)), - on.disconnected(()=> console.log(CustomHTMLTestElement)) - ); - const text= text=> el().append( - el("#text", text), - " | " - ); - return el("p").append( - text(test), - text(name), - text(preName), - el("button", { type: "button", textContent: "pre-name", onclick: ()=> preName.set("Ahoj") }), - " | ", - el("slot", { className: "test", name: "test" }), - ); - } - test= "A"; - - get name(){ return this.getAttribute("name"); } - set name(value){ this.setAttribute("name", value); } - /** @attr pre-name */ - get preName(){ return this.getAttribute("pre-name"); } - set preName(value){ this.setAttribute("pre-name", value); } -} -customElementWithDDE(CustomHTMLTestElement); -customElements.define(CustomHTMLTestElement.tagName, CustomHTMLTestElement); - -export class CustomSlottingHTMLElement extends HTMLElement{ - static tagName= "custom-slotting"; - render(){ - return simulateSlots(this, el().append( - el("p").append( - "Ahoj ", el("slot", { name: "name", className: "name", textContent: "World" }) - ), - el("p").append( - "BTW ", el("slot") - ) - )); - } - connectedCallback(){ - customElementRender(this, this.render); - } -} -customElementWithDDE(CustomSlottingHTMLElement); -customElements.define(CustomSlottingHTMLElement.tagName, CustomSlottingHTMLElement); diff --git a/examples/exports.js b/examples/exports.js deleted file mode 100644 index 8c4928f..0000000 --- a/examples/exports.js +++ /dev/null @@ -1,30 +0,0 @@ -import * as dde_dom from "../index.js"; -export * from "../index.js"; -import * as dde_s from "../signals.js"; -export * from "../signals.js"; -Object.assign(globalThis, dde_dom, dde_s); -//import * as dde_dom from "../dist/esm-with-signals.js"; -//export * from "../dist/esm-with-signals.js"; -//Object.assign(globalThis, dde_dom); -export const style= createStyle(); - -function createStyle(){ - const element= dde_dom.el("style"); - const store= new WeakSet(); - let host; - return { - element, - host(k, h= k.name){ - if(store.has(k)) return { css: ()=> {} }; - store.add(k); - host= h; - return this; - }, - css(...args){ - const textContent= String.raw(...args).replaceAll(":host", "."+host); - const className= host; - element.appendChild(el("#text", { textContent })); - return className; - } - }; -} diff --git a/examples/index-nosignals.html b/examples/index-nosignals.html deleted file mode 100644 index 98be4f0..0000000 --- a/examples/index-nosignals.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - Small DOM element creation enhancements - - - - - - diff --git a/examples/index.html b/examples/index.html deleted file mode 100644 index d4b04f6..0000000 --- a/examples/index.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - Small DOM element creation enhancements - - - - - - diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6708196..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -import { style, el, S } from './exports.js'; -style.css` -:root{ - color-scheme: dark light; -} -`; -document.head.append(style.element); -import { fullNameComponent } from './components/fullNameComponent.js'; -import { todosComponent } from './components/todosComponent.js'; -import { CustomHTMLTestElement, CustomSlottingHTMLElement } from "./components/webComponent.js"; -import { thirdParty } from "./components/3rd-party.js"; - -const toggle= S(false); -document.body.append( - el("h1", "Experiments:"), - el(fullNameComponent), - el(todosComponent), - el(CustomHTMLTestElement.tagName, { name: "attr" }).append( - el("span", { textContent: "test", slot: "test" }), - el("span", { textContent: "test", slot: "test" }), - ), - el(thirdParty), - el(CustomSlottingHTMLElement.tagName, { onclick: ()=> toggle.set(!toggle.get()) }).append( - el("strong", { slot: "name", textContent: "Honzo" }), - S.el(toggle, is=> is - ? el("span", "…default slot") - : el("span", "…custom slot") - ) - ) -);