@davidsouther/jiffies 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/README.md +60 -0
  2. package/build/assert.d.ts +23 -0
  3. package/build/assert.js +33 -0
  4. package/build/case.d.ts +1 -0
  5. package/build/case.js +5 -0
  6. package/build/components/button_bar.d.ts +8 -0
  7. package/build/components/button_bar.js +16 -0
  8. package/build/components/index.d.ts +1 -0
  9. package/build/components/index.js +1 -0
  10. package/build/components/inline_edit.d.ts +12 -0
  11. package/build/components/inline_edit.js +48 -0
  12. package/build/components/logger.d.ts +7 -0
  13. package/build/components/logger.js +22 -0
  14. package/build/components/select.d.ts +13 -0
  15. package/build/components/select.js +3 -0
  16. package/build/components/test.d.ts +1 -0
  17. package/build/components/test.js +2 -0
  18. package/build/components/virtual_scroll.d.ts +41 -0
  19. package/build/components/virtual_scroll.js +94 -0
  20. package/build/components/virtual_scroll.test.d.ts +1 -0
  21. package/build/components/virtual_scroll.test.js +21 -0
  22. package/build/context.d.ts +15 -0
  23. package/build/context.js +43 -0
  24. package/build/context.test.d.ts +1 -0
  25. package/build/context.test.js +46 -0
  26. package/build/debounce.d.ts +1 -0
  27. package/build/debounce.js +7 -0
  28. package/build/display.d.ts +5 -0
  29. package/build/display.js +3 -0
  30. package/build/dom/css/border.d.ts +11 -0
  31. package/build/dom/css/border.js +27 -0
  32. package/build/dom/css/constants.d.ts +31 -0
  33. package/build/dom/css/constants.js +28 -0
  34. package/build/dom/css/core.d.ts +5 -0
  35. package/build/dom/css/core.js +24 -0
  36. package/build/dom/css/fstyle.d.ts +5 -0
  37. package/build/dom/css/fstyle.js +32 -0
  38. package/build/dom/css/sizing.d.ts +5 -0
  39. package/build/dom/css/sizing.js +10 -0
  40. package/build/dom/dom.d.ts +27 -0
  41. package/build/dom/dom.js +94 -0
  42. package/build/dom/fc.d.ts +14 -0
  43. package/build/dom/fc.js +35 -0
  44. package/build/dom/fc.test.d.ts +1 -0
  45. package/build/dom/fc.test.js +21 -0
  46. package/build/dom/form/form.app.d.ts +1 -0
  47. package/build/dom/form/form.app.js +23 -0
  48. package/build/dom/form/form.d.ts +25 -0
  49. package/build/dom/form/form.js +25 -0
  50. package/build/dom/form/form.test.d.ts +0 -0
  51. package/build/dom/form/form.test.js +1 -0
  52. package/build/dom/html.d.ts +117 -0
  53. package/build/dom/html.js +114 -0
  54. package/build/dom/html.test.d.ts +1 -0
  55. package/build/dom/html.test.js +58 -0
  56. package/build/dom/router/link.d.ts +6 -0
  57. package/build/dom/router/link.js +3 -0
  58. package/build/dom/router/router.d.ts +12 -0
  59. package/build/dom/router/router.js +49 -0
  60. package/build/dom/svg.d.ts +64 -0
  61. package/build/dom/svg.js +65 -0
  62. package/build/dom/test.d.ts +1 -0
  63. package/build/dom/test.js +2 -0
  64. package/build/dom/types/css.d.ts +6612 -0
  65. package/build/dom/types/css.js +23 -0
  66. package/build/dom/types/dom.d.ts +0 -0
  67. package/build/dom/types/dom.js +1 -0
  68. package/build/dom/types/html.d.ts +616 -0
  69. package/build/dom/types/html.js +1 -0
  70. package/build/dom/xml.d.ts +1 -0
  71. package/build/dom/xml.js +5 -0
  72. package/build/equal.d.ts +4 -0
  73. package/build/equal.js +22 -0
  74. package/build/equal.test.d.ts +1 -0
  75. package/build/equal.test.js +20 -0
  76. package/build/flags.d.ts +7 -0
  77. package/build/flags.js +48 -0
  78. package/build/flags.test.d.ts +1 -0
  79. package/build/flags.test.js +35 -0
  80. package/build/generator.d.ts +1 -0
  81. package/build/generator.js +10 -0
  82. package/build/generator.test.d.ts +1 -0
  83. package/build/generator.test.js +24 -0
  84. package/build/index.d.ts +13 -0
  85. package/build/index.js +13 -0
  86. package/build/is_browser.d.ts +1 -0
  87. package/build/is_browser.js +1 -0
  88. package/build/loader.d.mts +22 -0
  89. package/build/loader.mjs +35 -0
  90. package/build/lock.d.ts +1 -0
  91. package/build/lock.js +23 -0
  92. package/build/lock.test.d.ts +1 -0
  93. package/build/lock.test.js +16 -0
  94. package/build/log.d.ts +26 -0
  95. package/build/log.js +34 -0
  96. package/build/parcel_resolver.d.ts +3 -0
  97. package/build/parcel_resolver.js +19 -0
  98. package/build/range.d.ts +1 -0
  99. package/build/range.js +7 -0
  100. package/build/result.d.ts +31 -0
  101. package/build/result.js +65 -0
  102. package/build/result.test.d.ts +1 -0
  103. package/build/result.test.js +71 -0
  104. package/build/safe.d.ts +1 -0
  105. package/build/safe.js +10 -0
  106. package/build/scope/describe.d.ts +14 -0
  107. package/build/scope/describe.js +52 -0
  108. package/build/scope/display/console.d.ts +2 -0
  109. package/build/scope/display/console.js +21 -0
  110. package/build/scope/display/dom.d.ts +3 -0
  111. package/build/scope/display/dom.js +26 -0
  112. package/build/scope/display/junit.d.ts +2 -0
  113. package/build/scope/display/junit.js +17 -0
  114. package/build/scope/execute.d.ts +12 -0
  115. package/build/scope/execute.js +85 -0
  116. package/build/scope/expect.d.ts +23 -0
  117. package/build/scope/expect.js +107 -0
  118. package/build/scope/fix.d.ts +4 -0
  119. package/build/scope/fix.js +22 -0
  120. package/build/scope/index.d.ts +3 -0
  121. package/build/scope/index.js +3 -0
  122. package/build/scope/scope.d.ts +17 -0
  123. package/build/scope/scope.js +1 -0
  124. package/build/server/http/apps.d.ts +5 -0
  125. package/build/server/http/apps.js +23 -0
  126. package/build/server/http/index.d.ts +21 -0
  127. package/build/server/http/index.js +71 -0
  128. package/build/server/http/response.d.ts +4 -0
  129. package/build/server/http/response.js +37 -0
  130. package/build/server/http/sitemap.d.ts +2 -0
  131. package/build/server/http/sitemap.js +42 -0
  132. package/build/server/http/static.d.ts +2 -0
  133. package/build/server/http/static.js +21 -0
  134. package/build/server/http/typescript.d.ts +5 -0
  135. package/build/server/http/typescript.js +40 -0
  136. package/build/server/main.d.ts +2 -0
  137. package/build/server/main.js +9 -0
  138. package/build/test.d.mts +2 -0
  139. package/build/test.mjs +23 -0
  140. package/build/test_all.d.ts +1 -0
  141. package/build/test_all.js +19 -0
  142. package/build/transpile.d.mts +3 -0
  143. package/build/transpile.mjs +18 -0
  144. package/package.json +36 -0
  145. package/src/404.html +14 -0
  146. package/src/assert.ts +50 -0
  147. package/src/case.ts +5 -0
  148. package/src/components/_notes +33 -0
  149. package/src/components/button_bar.ts +38 -0
  150. package/src/components/inline_edit.ts +77 -0
  151. package/src/components/logger.ts +36 -0
  152. package/src/components/select.ts +22 -0
  153. package/src/components/test.js +2 -0
  154. package/src/components/virtual_scroll.test.ts +27 -0
  155. package/src/components/virtual_scroll.ts +194 -0
  156. package/src/context.test.ts +58 -0
  157. package/src/context.ts +62 -0
  158. package/src/debounce.ts +7 -0
  159. package/src/display.ts +12 -0
  160. package/src/dom/README.md +102 -0
  161. package/src/dom/css/border.ts +47 -0
  162. package/src/dom/css/constants.ts +34 -0
  163. package/src/dom/css/core.ts +28 -0
  164. package/src/dom/css/fstyle.ts +42 -0
  165. package/src/dom/css/sizing.ts +11 -0
  166. package/src/dom/dom.ts +153 -0
  167. package/src/dom/fc.test.ts +43 -0
  168. package/src/dom/fc.ts +79 -0
  169. package/src/dom/form/form.app.ts +50 -0
  170. package/src/dom/form/form.test.ts +0 -0
  171. package/src/dom/form/form.ts +53 -0
  172. package/src/dom/form/index.html +14 -0
  173. package/src/dom/html.test.ts +72 -0
  174. package/src/dom/html.ts +129 -0
  175. package/src/dom/router/link.ts +14 -0
  176. package/src/dom/router/router.ts +69 -0
  177. package/src/dom/svg.ts +77 -0
  178. package/src/dom/test.ts +2 -0
  179. package/src/dom/types/css.ts +10106 -0
  180. package/src/dom/types/dom.ts +0 -0
  181. package/src/dom/types/html.ts +631 -0
  182. package/src/dom/xml.ts +12 -0
  183. package/src/equal.test.ts +23 -0
  184. package/src/equal.ts +32 -0
  185. package/src/favicon.ico +0 -0
  186. package/src/flags.test.ts +43 -0
  187. package/src/flags.ts +53 -0
  188. package/src/generator.test.ts +26 -0
  189. package/src/generator.ts +12 -0
  190. package/src/hooks/_notes +3 -0
  191. package/src/index.html +79 -0
  192. package/src/is_browser.js +1 -0
  193. package/src/loader.mjs +45 -0
  194. package/src/lock.test.ts +17 -0
  195. package/src/lock.ts +22 -0
  196. package/src/log.ts +61 -0
  197. package/src/observable/_notes +13 -0
  198. package/src/observable/observable._js +175 -0
  199. package/src/range.ts +7 -0
  200. package/src/result.test.ts +98 -0
  201. package/src/result.ts +107 -0
  202. package/src/safe.ts +12 -0
  203. package/src/scope/describe.ts +70 -0
  204. package/src/scope/display/console.ts +26 -0
  205. package/src/scope/display/dom.ts +36 -0
  206. package/src/scope/display/junit.ts +67 -0
  207. package/src/scope/execute.ts +108 -0
  208. package/src/scope/expect.ts +170 -0
  209. package/src/scope/fix.ts +29 -0
  210. package/src/scope/index.ts +11 -0
  211. package/src/scope/scope.ts +21 -0
  212. package/src/server/http/apps.ts +26 -0
  213. package/src/server/http/index.ts +119 -0
  214. package/src/server/http/response.ts +47 -0
  215. package/src/server/http/sitemap.ts +48 -0
  216. package/src/server/http/static.ts +27 -0
  217. package/src/server/http/typescript.ts +46 -0
  218. package/src/server/main.ts +13 -0
  219. package/src/test.mjs +29 -0
  220. package/src/test_all.ts +22 -0
  221. package/src/transpile.mjs +29 -0
@@ -0,0 +1,53 @@
1
+ import { Attrs, DenormChildren } from "../dom.js";
2
+ import { form, input, label, option, select } from "../html.js";
3
+ import {
4
+ FormAttributes,
5
+ InputAttributes,
6
+ OptionAttributes,
7
+ SelectAttributes,
8
+ } from "../types/html.js";
9
+
10
+ export const Form = (attrs: FormAttributes, ...children: DenormChildren[]) => {
11
+ if (attrs.events?.submit) {
12
+ const submit = attrs.events.submit;
13
+ attrs.events.submit = (event) => {
14
+ event.preventDefault();
15
+ submit(event);
16
+ };
17
+ }
18
+ return form(attrs as Attrs<HTMLFormElement>, ...children);
19
+ };
20
+ export const Input = (attrs: InputAttributes, ...children: DenormChildren[]) =>
21
+ label(input(attrs as Attrs<HTMLInputElement>), ...children);
22
+ export const Select = ({ options }: { options: string[] | {} }) =>
23
+ label(select(...prepareOptions(options).map(Option)));
24
+ export const Button = () => {};
25
+
26
+ const prepareOptions = (
27
+ attrs:
28
+ | string[]
29
+ | Record<
30
+ string,
31
+ string | { label: string; disabled?: boolean; selected?: boolean }
32
+ >
33
+ ): Parameters<typeof Option>[0][] =>
34
+ Array.isArray(attrs)
35
+ ? attrs.map((value) => ({ value, label: value }))
36
+ : Object.entries(attrs).map(([value, label]) =>
37
+ typeof label === "string" ? { value, label } : { value, ...label }
38
+ );
39
+ export const Option = (attrs: OptionAttributes) =>
40
+ option(attrs as Attrs<HTMLOptionElement>);
41
+
42
+ export const Dropdown = (
43
+ attrs: SelectAttributes | { options: Parameters<typeof prepareOptions>[0] }
44
+ ) => {};
45
+ export const Radios = () => {};
46
+ export const Checks = () => {};
47
+ export const Switches = () => {};
48
+
49
+ export const Radio = (attrs: Omit<InputAttributes, "type">) =>
50
+ Input({ type: "radio" });
51
+ export const Checkbox = (attrs: Omit<InputAttributes, "type">) =>
52
+ Input({ type: "checkbox" });
53
+ export const Switch = () => Checkbox({ role: "switch" });
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Jiffies Form</title>
5
+ <base href="/dom/form/" />
6
+ <link rel="stylesheet" href="https://unpkg.com/@picocss/pico@latest/css/pico.min.css">
7
+ </head>
8
+ <body>
9
+ <script type="module">
10
+ import {App} from './form.app.js';
11
+ document.body.appendChild(App());
12
+ </script>
13
+ </body>
14
+ </html>
@@ -0,0 +1,72 @@
1
+ import { describe, it } from "../scope/describe.js";
2
+ import { expect } from "../scope/expect.js";
3
+ import { table, tbody, td, th, thead, tr, button } from "./html.js";
4
+
5
+ describe("html", () => {
6
+ it("creates HTML Elements", () => {
7
+ let tableBody;
8
+ const myTable = table(
9
+ thead(tr(th("Col A"), th("Col B"))),
10
+ (tableBody = tbody())
11
+ );
12
+ for (let x = 1; x <= 3; x++) {
13
+ tableBody.appendChild(tr(td(`${x}`), td(`${x * 2}`)));
14
+ }
15
+ expect(myTable.textContent).toEqual("Col ACol B122436");
16
+ });
17
+
18
+ it("attaches event handlers", () => {
19
+ let clicked = false;
20
+ const btn = button({
21
+ events: {
22
+ click: () => {
23
+ clicked = true;
24
+ },
25
+ },
26
+ });
27
+ btn.dispatchEvent(new Event("click"));
28
+ expect(clicked).toBe(true);
29
+ });
30
+
31
+ it("removes event handlers", () => {
32
+ let clicked = 0;
33
+ const btn = button({
34
+ events: {
35
+ click: () => {
36
+ clicked += 1;
37
+ },
38
+ },
39
+ });
40
+ btn.dispatchEvent(new Event("click"));
41
+
42
+ expect(clicked).toBe(1);
43
+
44
+ btn.update({ events: { click: undefined } });
45
+ btn.dispatchEvent(new Event("click"));
46
+ expect(clicked).toBe(1);
47
+ });
48
+
49
+ it("sets style properties", () => {
50
+ const btn = button({
51
+ style: { flexDirection: "column" },
52
+ }) as unknown as HTMLButtonElement;
53
+
54
+ expect(btn.style.flexDirection).toBe("column");
55
+ });
56
+
57
+ it("sets style, attributes, and events together", () => {
58
+ let clicked = false;
59
+ const btn = button({
60
+ class: "test-class",
61
+ style: { flexDirection: "column" },
62
+ events: { click: () => (clicked = true) },
63
+ });
64
+ btn.dispatchEvent(new Event("click"));
65
+
66
+ expect(btn.classList.contains("test-class")).toBe(true);
67
+ expect((btn as unknown as HTMLButtonElement).style.flexDirection).toBe(
68
+ "column"
69
+ );
70
+ expect(clicked).toBe(true);
71
+ });
72
+ });
@@ -0,0 +1,129 @@
1
+ import { DenormAttrs, DenormChildren, up, Updatable } from "./dom.js";
2
+ import { Properties } from "./types/css.js";
3
+
4
+ export type UHTMLElement<E extends HTMLElement = HTMLElement> = Updatable<
5
+ Omit<E, "style">
6
+ > & { style: Properties };
7
+
8
+ const makeHTMLElement =
9
+ <K extends keyof HTMLElementTagNameMap>(name: K) =>
10
+ (
11
+ attrs?: DenormAttrs<Omit<HTMLElementTagNameMap[K], "style">>,
12
+ ...children: DenormChildren[]
13
+ ) =>
14
+ up(document.createElement(name), attrs, ...children) as UHTMLElement<
15
+ HTMLElementTagNameMap[K]
16
+ >;
17
+
18
+ export const a = makeHTMLElement("a");
19
+ export const abbr = makeHTMLElement("abbr");
20
+ export const address = makeHTMLElement("address");
21
+ export const area = makeHTMLElement("area");
22
+ export const article = makeHTMLElement("article");
23
+ export const aside = makeHTMLElement("aside");
24
+ export const audio = makeHTMLElement("audio");
25
+ export const b = makeHTMLElement("b");
26
+ export const base = makeHTMLElement("base");
27
+ export const bdi = makeHTMLElement("bdi");
28
+ export const bdo = makeHTMLElement("bdo");
29
+ export const blockquote = makeHTMLElement("blockquote");
30
+ export const body = makeHTMLElement("body");
31
+ export const br = makeHTMLElement("br");
32
+ export const button = makeHTMLElement("button");
33
+ export const canvas = makeHTMLElement("canvas");
34
+ export const caption = makeHTMLElement("caption");
35
+ export const cite = makeHTMLElement("cite");
36
+ export const code = makeHTMLElement("code");
37
+ export const col = makeHTMLElement("col");
38
+ export const colgroup = makeHTMLElement("colgroup");
39
+ export const data = makeHTMLElement("data");
40
+ export const datalist = makeHTMLElement("datalist");
41
+ export const dd = makeHTMLElement("dd");
42
+ export const del = makeHTMLElement("del");
43
+ export const details = makeHTMLElement("details");
44
+ export const dfn = makeHTMLElement("dfn");
45
+ export const dialog = makeHTMLElement("dialog");
46
+ export const div = makeHTMLElement("div");
47
+ export const dl = makeHTMLElement("dl");
48
+ export const dt = makeHTMLElement("dt");
49
+ export const em = makeHTMLElement("em");
50
+ export const embed = makeHTMLElement("embed");
51
+ export const fieldset = makeHTMLElement("fieldset");
52
+ export const figcaption = makeHTMLElement("figcaption");
53
+ export const figure = makeHTMLElement("figure");
54
+ export const footer = makeHTMLElement("footer");
55
+ export const form = makeHTMLElement("form");
56
+ export const h1 = makeHTMLElement("h1");
57
+ export const h2 = makeHTMLElement("h2");
58
+ export const h3 = makeHTMLElement("h3");
59
+ export const h4 = makeHTMLElement("h4");
60
+ export const h5 = makeHTMLElement("h5");
61
+ export const h6 = makeHTMLElement("h6");
62
+ export const head = makeHTMLElement("head");
63
+ export const header = makeHTMLElement("header");
64
+ export const hgroup = makeHTMLElement("hgroup");
65
+ export const hr = makeHTMLElement("hr");
66
+ export const html = makeHTMLElement("html");
67
+ export const i = makeHTMLElement("i");
68
+ export const iframe = makeHTMLElement("iframe");
69
+ export const img = makeHTMLElement("img");
70
+ export const input = makeHTMLElement("input");
71
+ export const ins = makeHTMLElement("ins");
72
+ export const kbd = makeHTMLElement("kbd");
73
+ export const label = makeHTMLElement("label");
74
+ export const legend = makeHTMLElement("legend");
75
+ export const li = makeHTMLElement("li");
76
+ export const link = makeHTMLElement("link");
77
+ export const main = makeHTMLElement("main");
78
+ export const map = makeHTMLElement("map");
79
+ export const mark = makeHTMLElement("mark");
80
+ export const menu = makeHTMLElement("menu");
81
+ export const meta = makeHTMLElement("meta");
82
+ export const meter = makeHTMLElement("meter");
83
+ export const nav = makeHTMLElement("nav");
84
+ export const noscript = makeHTMLElement("noscript");
85
+ export const object = makeHTMLElement("object");
86
+ export const ol = makeHTMLElement("ol");
87
+ export const optgroup = makeHTMLElement("optgroup");
88
+ export const option = makeHTMLElement("option");
89
+ export const output = makeHTMLElement("output");
90
+ export const p = makeHTMLElement("p");
91
+ export const param = makeHTMLElement("param");
92
+ export const picture = makeHTMLElement("picture");
93
+ export const pre = makeHTMLElement("pre");
94
+ export const progress = makeHTMLElement("progress");
95
+ export const q = makeHTMLElement("q");
96
+ export const rp = makeHTMLElement("rp");
97
+ export const rt = makeHTMLElement("rt");
98
+ export const ruby = makeHTMLElement("ruby");
99
+ export const s = makeHTMLElement("s");
100
+ export const samp = makeHTMLElement("samp");
101
+ export const script = makeHTMLElement("script");
102
+ export const section = makeHTMLElement("section");
103
+ export const select = makeHTMLElement("select");
104
+ export const slot = makeHTMLElement("slot");
105
+ export const small = makeHTMLElement("small");
106
+ export const source = makeHTMLElement("source");
107
+ export const span = makeHTMLElement("span");
108
+ export const strong = makeHTMLElement("strong");
109
+ export const style = makeHTMLElement("style");
110
+ export const sub = makeHTMLElement("sub");
111
+ export const summary = makeHTMLElement("summary");
112
+ export const sup = makeHTMLElement("sup");
113
+ export const table = makeHTMLElement("table");
114
+ export const tbody = makeHTMLElement("tbody");
115
+ export const td = makeHTMLElement("td");
116
+ export const template = makeHTMLElement("template");
117
+ export const textarea = makeHTMLElement("textarea");
118
+ export const tfoot = makeHTMLElement("tfoot");
119
+ export const th = makeHTMLElement("th");
120
+ export const thead = makeHTMLElement("thead");
121
+ export const time = makeHTMLElement("time");
122
+ export const title = makeHTMLElement("title");
123
+ export const tr = makeHTMLElement("tr");
124
+ export const track = makeHTMLElement("track");
125
+ export const u = makeHTMLElement("u");
126
+ export const ul = makeHTMLElement("ul");
127
+ export const htmlvar = makeHTMLElement("var"); // var is reserved, export as variable
128
+ export const video = makeHTMLElement("video");
129
+ export const wbr = makeHTMLElement("wbr");
@@ -0,0 +1,14 @@
1
+ import { a } from "../html.js";
2
+ import { Router } from "./router.js";
3
+
4
+ export interface Link {
5
+ href: string;
6
+ link: string;
7
+ target: () => Node;
8
+ }
9
+
10
+ export const link = ({ href, link }: Link) =>
11
+ a(
12
+ { href: Router.href(href), events: { click: Router.navigate(href) } },
13
+ link
14
+ );
@@ -0,0 +1,69 @@
1
+ import { DOMElement, Updatable } from "../dom";
2
+ import { Link } from "./link";
3
+
4
+ export interface Router {
5
+ current?: string;
6
+ navigate: (url: string) => (event: Event) => void;
7
+ (target: Updatable<DOMElement>): Updatable<DOMElement>;
8
+ }
9
+
10
+ let baseURI = `${document.baseURI}`;
11
+ const normalizeHref = () => {
12
+ return location.href + "/" === baseURI ? baseURI : location.href;
13
+ };
14
+
15
+ let globalRouter: Router;
16
+ export const Router = {
17
+ for(links: Link[], index: string, setGlobalRouter = true): Router {
18
+ let target: Updatable<Element>;
19
+ const partialRouter: Partial<Router> = (t: Updatable<Element>) => {
20
+ target = t;
21
+ const href = normalizeHref();
22
+ const route = href === baseURI ? baseURI + index : href;
23
+ doNavigate(route);
24
+ window.addEventListener("popstate", () => {
25
+ doNavigate(location.href);
26
+ });
27
+ return target;
28
+ };
29
+
30
+ const doNavigate = (link: string) => {
31
+ link = link.replace(baseURI, "") || index;
32
+ if (link === partialRouter.current) {
33
+ return false;
34
+ }
35
+ partialRouter.current = link;
36
+ target.update(
37
+ (
38
+ links.find(({ href }) => link.endsWith(href))?.target ??
39
+ (() => undefined)
40
+ )()
41
+ );
42
+ return true;
43
+ };
44
+
45
+ const navigate = (url: string) => {
46
+ return (event: Event) => {
47
+ event.preventDefault();
48
+ if (doNavigate(url || index)) {
49
+ history.pushState(null, "", url);
50
+ }
51
+ };
52
+ };
53
+
54
+ partialRouter.navigate = navigate;
55
+
56
+ if (setGlobalRouter) {
57
+ globalRouter = partialRouter as Router;
58
+ }
59
+ return partialRouter as Router;
60
+ },
61
+
62
+ href(link: string) {
63
+ return `${baseURI}${link.replace(/^\//, "")}`;
64
+ },
65
+
66
+ navigate(href: string) {
67
+ return globalRouter?.navigate(href);
68
+ },
69
+ };
package/src/dom/svg.ts ADDED
@@ -0,0 +1,77 @@
1
+ import { DenormAttrs, DenormChildren, up } from "./dom.js";
2
+
3
+ const makeSVGElement =
4
+ <K extends keyof SVGElementTagNameMap>(name: K) =>
5
+ (
6
+ attrs?: DenormAttrs<SVGElementTagNameMap[K]>,
7
+ ...children: DenormChildren[]
8
+ ) =>
9
+ up(
10
+ document.createElementNS("http://www.w3.org/2000/svg", name),
11
+ attrs,
12
+ ...children
13
+ );
14
+
15
+ export const a = makeSVGElement("a");
16
+ export const animate = makeSVGElement("animate");
17
+ export const animateMotion = makeSVGElement("animateMotion");
18
+ export const animateTransform = makeSVGElement("animateTransform");
19
+ export const circle = makeSVGElement("circle");
20
+ export const clipPath = makeSVGElement("clipPath");
21
+ export const defs = makeSVGElement("defs");
22
+ export const desc = makeSVGElement("desc");
23
+ export const ellipse = makeSVGElement("ellipse");
24
+ export const feBlend = makeSVGElement("feBlend");
25
+ export const feColorMatrix = makeSVGElement("feColorMatrix");
26
+ export const feComponentTransfer = makeSVGElement("feComponentTransfer");
27
+ export const feComposite = makeSVGElement("feComposite");
28
+ export const feConvolveMatrix = makeSVGElement("feConvolveMatrix");
29
+ export const feDiffuseLighting = makeSVGElement("feDiffuseLighting");
30
+ export const feDisplacementMap = makeSVGElement("feDisplacementMap");
31
+ export const feDistantLight = makeSVGElement("feDistantLight");
32
+ export const feDropShadow = makeSVGElement("feDropShadow");
33
+ export const feFlood = makeSVGElement("feFlood");
34
+ export const feFuncA = makeSVGElement("feFuncA");
35
+ export const feFuncB = makeSVGElement("feFuncB");
36
+ export const feFuncG = makeSVGElement("feFuncG");
37
+ export const feFuncR = makeSVGElement("feFuncR");
38
+ export const feGaussianBlur = makeSVGElement("feGaussianBlur");
39
+ export const feImage = makeSVGElement("feImage");
40
+ export const feMerge = makeSVGElement("feMerge");
41
+ export const feMergeNode = makeSVGElement("feMergeNode");
42
+ export const feMorphology = makeSVGElement("feMorphology");
43
+ export const feOffset = makeSVGElement("feOffset");
44
+ export const fePointLight = makeSVGElement("fePointLight");
45
+ export const feSpecularLighting = makeSVGElement("feSpecularLighting");
46
+ export const feSpotLight = makeSVGElement("feSpotLight");
47
+ export const feTile = makeSVGElement("feTile");
48
+ export const feTurbulence = makeSVGElement("feTurbulence");
49
+ export const filter = makeSVGElement("filter");
50
+ export const foreignObject = makeSVGElement("foreignObject");
51
+ export const g = makeSVGElement("g");
52
+ export const image = makeSVGElement("image");
53
+ export const line = makeSVGElement("line");
54
+ export const linearGradient = makeSVGElement("linearGradient");
55
+ export const marker = makeSVGElement("marker");
56
+ export const mask = makeSVGElement("mask");
57
+ export const metadata = makeSVGElement("metadata");
58
+ export const mpath = makeSVGElement("mpath");
59
+ export const path = makeSVGElement("path");
60
+ export const pattern = makeSVGElement("pattern");
61
+ export const polygon = makeSVGElement("polygon");
62
+ export const polyline = makeSVGElement("polyline");
63
+ export const radialGradient = makeSVGElement("radialGradient");
64
+ export const rect = makeSVGElement("rect");
65
+ export const script = makeSVGElement("script");
66
+ export const set = makeSVGElement("set");
67
+ export const stop = makeSVGElement("stop");
68
+ export const style = makeSVGElement("style");
69
+ export const svg = makeSVGElement("svg");
70
+ export const svgswitch = makeSVGElement("switch");
71
+ export const symbol = makeSVGElement("symbol");
72
+ export const text = makeSVGElement("text");
73
+ export const textPath = makeSVGElement("textPath");
74
+ export const title = makeSVGElement("title");
75
+ export const tspan = makeSVGElement("tspan");
76
+ export const use = makeSVGElement("use");
77
+ export const view = makeSVGElement("view");
@@ -0,0 +1,2 @@
1
+ export {};
2
+ await Promise.all([import("./html.test.js"), import("./fc.test.js")]);