This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {ElementType, TagsByType} from '../types' | |
const ns = { | |
html: 'http://www.w3.org/1999/xhtml', | |
svg: 'http://www.w3.org/2000/svg', | |
mathMl: 'http://www.w3.org/1998/Math/MathML', | |
} | |
export function createElement< | |
Type extends ElementType, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type HTMLs = HTMLElementTagNameMap | |
export type SVGs = SVGElementTagNameMap | |
export type MathMLs = MathMLElementTagNameMap | |
export type Tags = keyof (HTMLs | SVGs | MathMLs) | |
export type HTMLByTag<K extends keyof HTMLs> = HTMLs[K] | |
export type SVGByTag<K extends keyof SVGs> = SVGs[K] | |
export type MathMLByTag<K extends keyof MathMLs> = MathMLs[K] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<file-tree class="not-content"> | |
<ul> | |
<li class="directory" data-filetype="dir"> | |
<details> | |
<summary> | |
<span class="tree-entry"> | |
<span class=""> | |
<span> | |
<span class="sr-only">Directory</span> | |
<svg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface CustomConstructor<K extends keyof HTMLElementTagNameMap> | |
extends CustomElementConstructor { | |
new (...params: any[]): HTMLElementTagNameMap[K] | |
prototype: HTMLElementTagNameMap[K] | |
} | |
export const extend = <K extends keyof HTMLElementTagNameMap>(inherite: K) => { | |
return <T extends CustomConstructor<K>>(target: T) => { | |
customElements.define(`txs-${inherite}`, target, {extends: inherite}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const deepPick = <T extends object>(value: T) => { | |
return <K extends keyof T & string>(path: K) => { | |
return path.split('.').reduce<T[K]>((prev, curr) => { | |
return typeof prev[curr] === 'object' ? prev[curr] : prev; | |
}, value as T[K]); | |
}; | |
}; | |
export function deep<T extends object>(value: T) { | |
// prettier-ignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="pt-br"> | |
<head> | |
<meta charset="UTF-8" /> | |
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Vite + TS</title> | |
</head> | |
<body> | |
<figure id="figure"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const slugify = (...args: (string | number)[]): string => { | |
const value = args.join(' '); | |
return value | |
.normalize('NFD') | |
.replace(/[\u0300-\u036f]/g, '') | |
.toLowerCase() | |
.trim() | |
.replace(/[^a-z0-9 ]/g, '') | |
.replace(/\s+/g, '-'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type DetectTypedForm<T> = | |
T extends Array<infer U> | |
? FormArray<DetectTypedForm<U>> | |
: T extends Date | |
? FormControl<Date> | |
: T extends object | |
? FormGroup<TypedForm<T>> | |
: T extends true | false | |
? FormControl<boolean> | |
: T extends PropertyKey |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type {TypedForm} from './typed-form' | |
type TypedFormModel<T> = { | |
// Verifique cada tipo do model | |
[K in keyof T]: TypedForm<T[K]> | |
} | |
export type {TypedFormModel} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type DOMEventMapDefinitions = [ | |
[HTMLElement, HTMLElementEventMap], | |
[Document, DocumentEventMap], | |
[Window, WindowEventMap], | |
[FileReader, FileReaderEventMap], | |
[Element, ElementEventMap], | |
[Animation, AnimationEventMap], | |
[EventSource, EventSourceEventMap], | |
[AbortSignal, AbortSignalEventMap], | |
[AbstractWorker, AbstractWorkerEventMap], |