Skip to content

Commit 2f4c857

Browse files
committed
feat: add build to typescript, fix data-* and x-* attribute handling
1 parent 3888c7e commit 2f4c857

584 files changed

Lines changed: 215589 additions & 3673 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dist/article.js

Lines changed: 465 additions & 0 deletions
Large diffs are not rendered by default.

dist/block/article/article.js

Lines changed: 465 additions & 0 deletions
Large diffs are not rendered by default.

dist/block/article/article.js.map

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/block/aside/aside.js

Lines changed: 476 additions & 0 deletions
Large diffs are not rendered by default.

dist/block/aside/aside.js.map

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/block/audio/audio.js

Lines changed: 454 additions & 0 deletions
Large diffs are not rendered by default.

dist/block/audio/audio.js.map

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/block/blockquote/blockquote.js

Lines changed: 476 additions & 0 deletions
Large diffs are not rendered by default.

dist/block/blockquote/blockquote.js.map

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/block/body/body.js

Lines changed: 378 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,378 @@
1+
// templates/typescript/block/body/body.ts
2+
var Body = class {
3+
constructor(props = {}) {
4+
this.element = document.createElement("body");
5+
this.applyProps(props);
6+
}
7+
applyProps(props) {
8+
if (props.children !== void 0) {
9+
this.setChildren(props.children);
10+
}
11+
if (props.accessKey !== void 0) {
12+
this.element.setAttribute("accessKey", String(props.accessKey));
13+
}
14+
if (props.accesskey !== void 0) {
15+
this.element.setAttribute("accesskey", String(props.accesskey));
16+
}
17+
if (props.className !== void 0) {
18+
this.element.setAttribute("className", String(props.className));
19+
}
20+
if (props["data-attributes"] !== void 0) {
21+
const __map = props["data-attributes"];
22+
if (__map !== null && __map !== void 0) {
23+
for (const __k in __map) {
24+
this.element.setAttribute(`data-${__k}`, String(__map[__k]));
25+
}
26+
}
27+
}
28+
if (props.dir !== void 0) {
29+
this.setDir(props.dir);
30+
}
31+
if (props.draggable !== void 0) {
32+
this.element.setAttribute("draggable", String(props.draggable));
33+
}
34+
if (props.hidden !== void 0) {
35+
this.element.setAttribute("hidden", String(props.hidden));
36+
}
37+
if (props.id !== void 0) {
38+
this.element.setAttribute("id", String(props.id));
39+
}
40+
if (props.lang !== void 0) {
41+
this.element.setAttribute("lang", String(props.lang));
42+
}
43+
if (props.onafterprint !== void 0) {
44+
this.element.setAttribute("onafterprint", String(props.onafterprint));
45+
}
46+
if (props.onbeforeprint !== void 0) {
47+
this.element.setAttribute("onbeforeprint", String(props.onbeforeprint));
48+
}
49+
if (props.onbeforeunload !== void 0) {
50+
this.element.setAttribute("onbeforeunload", String(props.onbeforeunload));
51+
}
52+
if (props.onhashchange !== void 0) {
53+
this.element.setAttribute("onhashchange", String(props.onhashchange));
54+
}
55+
if (props.onlanguagechange !== void 0) {
56+
this.element.setAttribute("onlanguagechange", String(props.onlanguagechange));
57+
}
58+
if (props.onmessage !== void 0) {
59+
this.element.setAttribute("onmessage", String(props.onmessage));
60+
}
61+
if (props.onmessageerror !== void 0) {
62+
this.element.setAttribute("onmessageerror", String(props.onmessageerror));
63+
}
64+
if (props.onoffline !== void 0) {
65+
this.element.setAttribute("onoffline", String(props.onoffline));
66+
}
67+
if (props.ononline !== void 0) {
68+
this.element.setAttribute("ononline", String(props.ononline));
69+
}
70+
if (props.onpagehide !== void 0) {
71+
this.element.setAttribute("onpagehide", String(props.onpagehide));
72+
}
73+
if (props.onpageshow !== void 0) {
74+
this.element.setAttribute("onpageshow", String(props.onpageshow));
75+
}
76+
if (props.onpopstate !== void 0) {
77+
this.element.setAttribute("onpopstate", String(props.onpopstate));
78+
}
79+
if (props.onrejectionhandled !== void 0) {
80+
this.element.setAttribute("onrejectionhandled", String(props.onrejectionhandled));
81+
}
82+
if (props.onstorage !== void 0) {
83+
this.element.setAttribute("onstorage", String(props.onstorage));
84+
}
85+
if (props.onunhandledrejection !== void 0) {
86+
this.element.setAttribute("onunhandledrejection", String(props.onunhandledrejection));
87+
}
88+
if (props.onunload !== void 0) {
89+
this.element.setAttribute("onunload", String(props.onunload));
90+
}
91+
if (props.style !== void 0) {
92+
this.element.setAttribute("style", String(props.style));
93+
}
94+
if (props.tabIndex !== void 0) {
95+
this.element.setAttribute("tabIndex", String(props.tabIndex));
96+
}
97+
if (props.tabindex !== void 0) {
98+
this.element.setAttribute("tabindex", String(props.tabindex));
99+
}
100+
if (props.title !== void 0) {
101+
this.element.setAttribute("title", String(props.title));
102+
}
103+
if (props.translate !== void 0) {
104+
this.setTranslate(props.translate);
105+
}
106+
}
107+
setAccessKey(value) {
108+
if (value === null || value === void 0) {
109+
this.element.removeAttribute("accessKey");
110+
} else {
111+
this.element.setAttribute("accessKey", String(value));
112+
}
113+
return this;
114+
}
115+
setAccesskey(value) {
116+
if (value === null || value === void 0) {
117+
this.element.removeAttribute("accesskey");
118+
} else {
119+
this.element.setAttribute("accesskey", String(value));
120+
}
121+
return this;
122+
}
123+
setClassName(value) {
124+
if (value === null || value === void 0) {
125+
this.element.removeAttribute("className");
126+
} else {
127+
this.element.setAttribute("className", String(value));
128+
}
129+
return this;
130+
}
131+
setDataAttributes(value) {
132+
if (value === null || value === void 0) {
133+
for (const __a of Array.from(this.element.attributes)) {
134+
if (__a.name.startsWith("data-")) {
135+
this.element.removeAttribute(__a.name);
136+
}
137+
}
138+
} else {
139+
for (const __k in value) {
140+
this.element.setAttribute(`data-${__k}`, String(value[__k]));
141+
}
142+
}
143+
return this;
144+
}
145+
setDir(value) {
146+
if (value === null || value === void 0) {
147+
this.element.removeAttribute("dir");
148+
} else {
149+
this.element.setAttribute("dir", String(value));
150+
}
151+
return this;
152+
}
153+
setDraggable(value) {
154+
if (value === true) {
155+
this.element.setAttribute("draggable", "");
156+
} else {
157+
this.element.removeAttribute("draggable");
158+
}
159+
return this;
160+
}
161+
setHidden(value) {
162+
if (value === true) {
163+
this.element.setAttribute("hidden", "");
164+
} else {
165+
this.element.removeAttribute("hidden");
166+
}
167+
return this;
168+
}
169+
setId(value) {
170+
if (value === null || value === void 0) {
171+
this.element.removeAttribute("id");
172+
} else {
173+
this.element.setAttribute("id", String(value));
174+
}
175+
return this;
176+
}
177+
setLang(value) {
178+
if (value === null || value === void 0) {
179+
this.element.removeAttribute("lang");
180+
} else {
181+
this.element.setAttribute("lang", String(value));
182+
}
183+
return this;
184+
}
185+
setOnafterprint(value) {
186+
if (value === null || value === void 0) {
187+
this.element.removeAttribute("onafterprint");
188+
} else {
189+
this.element.setAttribute("onafterprint", String(value));
190+
}
191+
return this;
192+
}
193+
setOnbeforeprint(value) {
194+
if (value === null || value === void 0) {
195+
this.element.removeAttribute("onbeforeprint");
196+
} else {
197+
this.element.setAttribute("onbeforeprint", String(value));
198+
}
199+
return this;
200+
}
201+
setOnbeforeunload(value) {
202+
if (value === null || value === void 0) {
203+
this.element.removeAttribute("onbeforeunload");
204+
} else {
205+
this.element.setAttribute("onbeforeunload", String(value));
206+
}
207+
return this;
208+
}
209+
setOnhashchange(value) {
210+
if (value === null || value === void 0) {
211+
this.element.removeAttribute("onhashchange");
212+
} else {
213+
this.element.setAttribute("onhashchange", String(value));
214+
}
215+
return this;
216+
}
217+
setOnlanguagechange(value) {
218+
if (value === null || value === void 0) {
219+
this.element.removeAttribute("onlanguagechange");
220+
} else {
221+
this.element.setAttribute("onlanguagechange", String(value));
222+
}
223+
return this;
224+
}
225+
setOnmessage(value) {
226+
if (value === null || value === void 0) {
227+
this.element.removeAttribute("onmessage");
228+
} else {
229+
this.element.setAttribute("onmessage", String(value));
230+
}
231+
return this;
232+
}
233+
setOnmessageerror(value) {
234+
if (value === null || value === void 0) {
235+
this.element.removeAttribute("onmessageerror");
236+
} else {
237+
this.element.setAttribute("onmessageerror", String(value));
238+
}
239+
return this;
240+
}
241+
setOnoffline(value) {
242+
if (value === null || value === void 0) {
243+
this.element.removeAttribute("onoffline");
244+
} else {
245+
this.element.setAttribute("onoffline", String(value));
246+
}
247+
return this;
248+
}
249+
setOnonline(value) {
250+
if (value === null || value === void 0) {
251+
this.element.removeAttribute("ononline");
252+
} else {
253+
this.element.setAttribute("ononline", String(value));
254+
}
255+
return this;
256+
}
257+
setOnpagehide(value) {
258+
if (value === null || value === void 0) {
259+
this.element.removeAttribute("onpagehide");
260+
} else {
261+
this.element.setAttribute("onpagehide", String(value));
262+
}
263+
return this;
264+
}
265+
setOnpageshow(value) {
266+
if (value === null || value === void 0) {
267+
this.element.removeAttribute("onpageshow");
268+
} else {
269+
this.element.setAttribute("onpageshow", String(value));
270+
}
271+
return this;
272+
}
273+
setOnpopstate(value) {
274+
if (value === null || value === void 0) {
275+
this.element.removeAttribute("onpopstate");
276+
} else {
277+
this.element.setAttribute("onpopstate", String(value));
278+
}
279+
return this;
280+
}
281+
setOnrejectionhandled(value) {
282+
if (value === null || value === void 0) {
283+
this.element.removeAttribute("onrejectionhandled");
284+
} else {
285+
this.element.setAttribute("onrejectionhandled", String(value));
286+
}
287+
return this;
288+
}
289+
setOnstorage(value) {
290+
if (value === null || value === void 0) {
291+
this.element.removeAttribute("onstorage");
292+
} else {
293+
this.element.setAttribute("onstorage", String(value));
294+
}
295+
return this;
296+
}
297+
setOnunhandledrejection(value) {
298+
if (value === null || value === void 0) {
299+
this.element.removeAttribute("onunhandledrejection");
300+
} else {
301+
this.element.setAttribute("onunhandledrejection", String(value));
302+
}
303+
return this;
304+
}
305+
setOnunload(value) {
306+
if (value === null || value === void 0) {
307+
this.element.removeAttribute("onunload");
308+
} else {
309+
this.element.setAttribute("onunload", String(value));
310+
}
311+
return this;
312+
}
313+
setStyle(value) {
314+
if (value === null || value === void 0) {
315+
this.element.removeAttribute("style");
316+
} else {
317+
this.element.setAttribute("style", String(value));
318+
}
319+
return this;
320+
}
321+
setTabIndex(value) {
322+
if (value === null || value === void 0) {
323+
this.element.removeAttribute("tabIndex");
324+
} else {
325+
this.element.setAttribute("tabIndex", String(value));
326+
}
327+
return this;
328+
}
329+
setTabindex(value) {
330+
if (value === null || value === void 0) {
331+
this.element.removeAttribute("tabindex");
332+
} else {
333+
this.element.setAttribute("tabindex", String(value));
334+
}
335+
return this;
336+
}
337+
setTitle(value) {
338+
if (value === null || value === void 0) {
339+
this.element.removeAttribute("title");
340+
} else {
341+
this.element.setAttribute("title", String(value));
342+
}
343+
return this;
344+
}
345+
setTranslate(value) {
346+
if (value === null || value === void 0) {
347+
this.element.removeAttribute("translate");
348+
} else {
349+
this.element.setAttribute("translate", String(value));
350+
}
351+
return this;
352+
}
353+
setChildren(children) {
354+
while (this.element.firstChild) {
355+
this.element.removeChild(this.element.firstChild);
356+
}
357+
if (typeof children === "string") {
358+
this.element.textContent = children;
359+
} else if (Array.isArray(children)) {
360+
children.forEach((child) => {
361+
if (typeof child === "string") {
362+
this.element.appendChild(document.createTextNode(child));
363+
} else {
364+
this.element.appendChild(child);
365+
}
366+
});
367+
} else {
368+
this.element.appendChild(children);
369+
}
370+
return this;
371+
}
372+
getElement() {
373+
return this.element;
374+
}
375+
};
376+
export {
377+
Body
378+
};

0 commit comments

Comments
 (0)