无法动态导出, 恢复默认

This commit is contained in:
2024-05-15 20:56:42 +08:00
parent 3fb9f57e28
commit d575735bb4
3 changed files with 89 additions and 237 deletions

View File

@ -1,12 +1,21 @@
import { div, pre } from './main.js' import { Button, Main } from "./main.js";
const demo = div.w(128).h(64) //.onclick.stop('click') document.body.appendChild(Main({
demo.textContent = 'Hello world' children: [Button({
textContent: 'Hello world',
onclick: event => console.log('Hello world')
})]
}));
console.log('demo', demo) //import { div, pre } from './main.js'
document.body.appendChild(demo) //
document.body.appendChild(div.w(128).h(64).text('Hello world')) //const demo = div.w(128).h(64) //.onclick.stop('click')
//demo.textContent = 'Hello world'
fetch('./index.js').then(res => res.text()).then(text => { //
document.body.appendChild(pre.text(text)) //console.log('demo', demo)
}) //document.body.appendChild(demo)
//document.body.appendChild(div.w(128).h(64).text('Hello world'))
//
//fetch('./index.js').then(res => res.text()).then(text => {
// document.body.appendChild(pre.text(text))
//})

295
main.js
View File

@ -16,228 +16,70 @@ export function createElement({ innerText, innerHTML, textContent, readOnly, chi
} }
/* HTML5 语义标签 */ /* HTML5 语义标签 */
export function Header(options) { export const List = (options) => createElement(options, 'ul')
return createElement(options, 'header') export const ListItem = (options) => createElement(options, 'li')
} export const Div = (options) => createElement(options, 'div')
export const Span = (options) => createElement(options, 'span')
export function Nav(options) { export const Button = (options) => createElement({ ...options, style: { cursor: 'pointer', ...options.style } }, 'button')
return createElement(options, 'nav') export const Form = (options) => createElement(options, 'form')
} export const Header = (options) => createElement(options, 'header')
export const Nav = (options) => createElement(options, 'nav')
export function Main(options) { export const Main = (options) => createElement(options, 'main')
return createElement(options, 'main') export const Article = (options) => createElement(options, 'article')
} export const Section = (options) => createElement(options, 'section')
export const Aside = (options) => createElement(options, 'aside')
export function Article(options) { export const Footer = (options) => createElement(options, 'footer')
return createElement(options, 'article') export const H1 = (options) => createElement(options, 'h1')
} export const H2 = (options) => createElement(options, 'h2')
export const H3 = (options) => createElement(options, 'h3')
export function Section(options) { export const H4 = (options) => createElement(options, 'h4')
return createElement(options, 'section') export const H5 = (options) => createElement(options, 'h5')
} export const H6 = (options) => createElement(options, 'h6')
export const P = (options) => createElement(options, 'p')
export function Aside(options) { export const A = (options) => createElement(options, 'a')
return createElement(options, 'aside') export const Strong = (options) => createElement(options, 'strong')
} export const Em = (options) => createElement(options, 'em')
export const Small = (options) => createElement(options, 'small')
export function Footer(options) { export const Mark = (options) => createElement(options, 'mark')
return createElement(options, 'footer') export const Del = (options) => createElement(options, 'del')
} export const Ins = (options) => createElement(options, 'ins')
export const Pre = (options) => createElement(options, 'pre')
export function H1(options) { export const Code = (options) => createElement(options, 'code')
return createElement(options, 'h1') export const Blockquote = (options) => createElement(options, 'blockquote')
} export const Q = (options) => createElement(options, 'q')
export const Cite = (options) => createElement(options, 'cite')
export function H2(options) { export const Hr = (options) => createElement(options, 'hr')
return createElement(options, 'h2') export const Br = (options) => createElement(options, 'br')
} export const Ol = (options) => createElement(options, 'ol')
export const Ul = (options) => createElement(options, 'ul')
export function H3(options) { export const Li = (options) => createElement(options, 'li')
return createElement(options, 'h3') export const Dl = (options) => createElement(options, 'dl')
} export const Dt = (options) => createElement(options, 'dt')
export const Dd = (options) => createElement(options, 'dd')
export function H4(options) { export const Figure = (options) => createElement(options, 'figure')
return createElement(options, 'h4') export const Figcaption = (options) => createElement(options, 'figcaption')
} export const Img = (options) => createElement(options, 'img')
export const Video = (options) => createElement(options, 'video')
export function H5(options) { export const Audio = (options) => createElement(options, 'audio')
return createElement(options, 'h5') export const Canvas = (options) => createElement(options, 'canvas')
} export const Svg = (options) => createElement(options, 'svg')
export const Math = (options) => createElement(options, 'math')
export function H6(options) { export const Table = (options) => createElement(options, 'table')
return createElement(options, 'h6') export const Caption = (options) => createElement(options, 'caption')
} export const Thead = (options) => createElement(options, 'thead')
export const Tfoot = (options) => createElement(options, 'tfoot')
export function P(options) { export const Tbody = (options) => createElement(options, 'tbody')
return createElement(options, 'p') export const Tr = (options) => createElement(options, 'tr')
} export const Th = (options) => createElement(options, 'th')
export const Td = (options) => createElement(options, 'td')
export function A(options) { export const Col = (options) => createElement(options, 'col')
return createElement(options, 'a') export const Colgroup = (options) => createElement(options, 'colgroup')
} export const Fieldset = (options) => createElement(options, 'fieldset')
export const Legend = (options) => createElement(options, 'legend')
export function Strong(options) { export const Label = (options) => createElement(options, 'label')
return createElement(options, 'strong') export const Input = (options) => createElement(options, 'input')
} export const Select = (options) => createElement(options, 'select')
export const TextArea = (options) => createElement(options, 'textarea')
export function Em(options) {
return createElement(options, 'em')
}
export function Small(options) {
return createElement(options, 'small')
}
export function Mark(options) {
return createElement(options, 'mark')
}
export function Del(options) {
return createElement(options, 'del')
}
export function Ins(options) {
return createElement(options, 'ins')
}
export function Pre(options) {
return createElement(options, 'pre')
}
export function Code(options) {
return createElement(options, 'code')
}
export function Blockquote(options) {
return createElement(options, 'blockquote')
}
export function Q(options) {
return createElement(options, 'q')
}
export function Cite(options) {
return createElement(options, 'cite')
}
export function Br(options) {
return createElement(options, 'br')
}
export function Hr(options) {
return createElement(options, 'hr')
}
export function Ol(options) {
return createElement(options, 'ol')
}
export function Ul(options) {
return createElement(options, 'ul')
}
export function Li(options) {
return createElement(options, 'li')
}
export function Dl(options) {
return createElement(options, 'dl')
}
export function Dt(options) {
return createElement(options, 'dt')
}
export function Dd(options) {
return createElement(options, 'dd')
}
export function Figure(options) {
return createElement(options, 'figure')
}
export function Figcaption(options) {
return createElement(options, 'figcaption')
}
export function Div(options) {
return createElement(options, 'div')
}
export function Table(options) {
return createElement(options, 'table')
}
export function Caption(options) {
return createElement(options, 'caption')
}
export function Thead(options) {
return createElement(options, 'thead')
}
export function Tfoot(options) {
return createElement(options, 'tfoot')
}
export function Tbody(options) {
return createElement(options, 'tbody')
}
export function Tr(options) {
return createElement(options, 'tr')
}
export function Th(options) {
return createElement(options, 'th')
}
export function Td(options) {
return createElement(options, 'td')
}
export function Col(options) {
return createElement(options, 'col')
}
export function Colgroup(options) {
return createElement(options, 'colgroup')
}
/* 扩展标签 */
export function List(options) {
return createElement(options, 'ul')
}
export function ListItem(options) {
return createElement(options, 'li')
}
export function Span(options) {
return createElement(options, 'span')
}
export function Button(options) {
return createElement({
...options,
style: {
cursor: 'pointer',
...options.style
}
}, 'button')
}
export function Img(options) {
return createElement(options, 'img')
}
export function Input(options) {
return createElement(options, 'input')
}
export function TextArea(options) {
return createElement(options, 'textarea')
}
export function Avatar(options) { export function Avatar(options) {
const element = createElement(options, 'img') const element = createElement(options, 'img')
@ -303,8 +145,9 @@ export function Dialog(options) {
export default { export default {
createElement, List, ListItem, Span, Button, Img, Input, TextArea, Avatar, Dialog, createElement, List, ListItem, Span, Button, Img, Input, TextArea, Avatar, Dialog,
Header, Nav, Main, Article, Section, Aside, Footer, Div, Form, Header, Nav, Main, Article, Section, Aside, Footer,
H1, H2, H3, H4, H5, H6, P, A, Strong, Em, Small, Mark, Del, Ins, Pre, Code, Blockquote, Q, Cite, Br, Hr, H1, H2, H3, H4, H5, H6, P, A, Strong, Em, Small, Mark, Del, Ins, Pre, Code,
Ol, Ul, Li, Dl, Dt, Dd, Figure, Figcaption, Div, Blockquote, Q, Cite, Hr, Br, Ol, Ul, Li, Dl, Dt, Dd, Figure, Figcaption,
Table, Caption, Thead, Tfoot, Tbody, Tr, Th, Td, Col, Colgroup Video, Audio, Canvas, Svg, Math, Table, Caption, Thead, Tfoot, Tbody, Tr, Th, Td,
Col, Colgroup, Fieldset, Legend, Label, Select, TextArea
} }

View File

@ -1,7 +1,7 @@
{ {
"name": "@laniakeasupercluster/widgets", "name": "@laniakeasupercluster/widgets",
"description": "A simple widgets tracker", "description": "A simple widgets tracker",
"version": "1.0.3", "version": "1.0.4",
"type": "module", "type": "module",
"main": "main.js", "main": "main.js",
"author": "Laniakea Supercluster <huan0016@gmail.com>", "author": "Laniakea Supercluster <huan0016@gmail.com>",