@wsxjs/wsx-core 0.0.5 → 0.0.7

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 (41) hide show
  1. package/dist/{chunk-YNUVFDKT.mjs → chunk-VZQT7HU5.mjs} +4 -4
  2. package/dist/index.js +370 -24
  3. package/dist/index.mjs +370 -25
  4. package/dist/jsx-runtime.js +4 -3
  5. package/dist/jsx-runtime.mjs +1 -1
  6. package/dist/jsx.mjs +1 -1
  7. package/package.json +1 -1
  8. package/src/index.ts +2 -0
  9. package/src/jsx-factory.ts +5 -4
  10. package/src/light-component.ts +351 -0
  11. package/src/reactive-component.ts +135 -0
  12. package/types/index.d.ts +5 -0
  13. package/types/wsx-types.d.ts +4 -2
  14. package/dist/chunk-3CJEWYVF.mjs +0 -197
  15. package/dist/chunk-5JVEHB6H.mjs +0 -197
  16. package/dist/chunk-7E7KJQSW.mjs +0 -210
  17. package/dist/chunk-A5GYVTI3.mjs +0 -222
  18. package/dist/chunk-A5GYVTI3.mjs.map +0 -1
  19. package/dist/chunk-K6N3JDTI.mjs +0 -216
  20. package/dist/chunk-RVGKV4GP.mjs +0 -79
  21. package/dist/chunk-S3O776FY.mjs +0 -173
  22. package/dist/chunk-VNK4B3FW.mjs +0 -217
  23. package/dist/chunk-YNUVFDKT.mjs.map +0 -1
  24. package/dist/index.d.mts +0 -235
  25. package/dist/index.d.ts +0 -235
  26. package/dist/index.js.map +0 -1
  27. package/dist/index.mjs.map +0 -1
  28. package/dist/jsx-factory-pFUwL2Dz.d.mts +0 -26
  29. package/dist/jsx-factory-pFUwL2Dz.d.ts +0 -26
  30. package/dist/jsx-pFUwL2Dz.d.mts +0 -26
  31. package/dist/jsx-pFUwL2Dz.d.ts +0 -26
  32. package/dist/jsx-runtime-pFUwL2Dz.d.mts +0 -26
  33. package/dist/jsx-runtime-pFUwL2Dz.d.ts +0 -26
  34. package/dist/jsx-runtime.d.mts +0 -1
  35. package/dist/jsx-runtime.d.ts +0 -1
  36. package/dist/jsx-runtime.js.map +0 -1
  37. package/dist/jsx-runtime.mjs.map +0 -1
  38. package/dist/jsx.d.mts +0 -66
  39. package/dist/jsx.d.ts +0 -66
  40. package/dist/jsx.js.map +0 -1
  41. package/dist/jsx.mjs.map +0 -1
@@ -1,222 +0,0 @@
1
- // src/utils/svg-utils.ts
2
- var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
3
- var SVG_ONLY_ELEMENTS = /* @__PURE__ */ new Set([
4
- // 结构元素 (Structural elements)
5
- "svg",
6
- "defs",
7
- "g",
8
- "symbol",
9
- "use",
10
- // 图形元素 (Graphics elements)
11
- "circle",
12
- "ellipse",
13
- "line",
14
- "path",
15
- "polygon",
16
- "polyline",
17
- "rect",
18
- // 文本元素 (Text elements)
19
- "textPath",
20
- "tspan",
21
- // 渐变和模式 (Gradients and patterns)
22
- "linearGradient",
23
- "radialGradient",
24
- "stop",
25
- "pattern",
26
- // 滤镜 (Filter elements)
27
- "filter",
28
- "feBlend",
29
- "feColorMatrix",
30
- "feComponentTransfer",
31
- "feComposite",
32
- "feConvolveMatrix",
33
- "feDiffuseLighting",
34
- "feDisplacementMap",
35
- "feDistantLight",
36
- "feDropShadow",
37
- "feFlood",
38
- "feFuncA",
39
- "feFuncB",
40
- "feFuncG",
41
- "feFuncR",
42
- "feGaussianBlur",
43
- "feImage",
44
- "feMerge",
45
- "feMergeNode",
46
- "feMorphology",
47
- "feOffset",
48
- "fePointLight",
49
- "feSpecularLighting",
50
- "feSpotLight",
51
- "feTile",
52
- "feTurbulence",
53
- // 动画元素 (Animation elements)
54
- "animate",
55
- "animateMotion",
56
- "animateTransform",
57
- "set",
58
- // 其他元素 (Other elements)
59
- "clipPath",
60
- "foreignObject",
61
- "marker",
62
- "mask",
63
- "metadata",
64
- "switch",
65
- "desc"
66
- ]);
67
- var DUAL_ELEMENTS = /* @__PURE__ */ new Set(["image", "style", "title", "text"]);
68
- var FORCE_HTML_ELEMENTS = /* @__PURE__ */ new Set(["a"]);
69
- var SVG_ELEMENTS = /* @__PURE__ */ new Set([
70
- ...SVG_ONLY_ELEMENTS,
71
- ...DUAL_ELEMENTS,
72
- ...FORCE_HTML_ELEMENTS
73
- ]);
74
- var svgContext = false;
75
- function isSVGOnlyElement(tagName) {
76
- return SVG_ONLY_ELEMENTS.has(tagName);
77
- }
78
- function isDualElement(tagName) {
79
- return DUAL_ELEMENTS.has(tagName);
80
- }
81
- function isForceHTMLElement(tagName) {
82
- return FORCE_HTML_ELEMENTS.has(tagName);
83
- }
84
- function setSVGContext(inSVG) {
85
- svgContext = inSVG;
86
- }
87
- function createElement(tagName) {
88
- if (isForceHTMLElement(tagName)) {
89
- return document.createElement(tagName);
90
- }
91
- if (isSVGOnlyElement(tagName)) {
92
- setSVGContext(true);
93
- return document.createElementNS(SVG_NAMESPACE, tagName);
94
- }
95
- if (isDualElement(tagName)) {
96
- if (svgContext) {
97
- return document.createElementNS(SVG_NAMESPACE, tagName);
98
- }
99
- }
100
- return document.createElement(tagName);
101
- }
102
- function shouldUseSVGNamespace(tagName) {
103
- return isSVGOnlyElement(tagName) || isDualElement(tagName) && svgContext;
104
- }
105
- var SVG_ATTRIBUTE_MAP = /* @__PURE__ */ new Map([
106
- ["className", "class"],
107
- ["htmlFor", "for"]
108
- ]);
109
- function getSVGAttributeName(attributeName) {
110
- return SVG_ATTRIBUTE_MAP.get(attributeName) || attributeName;
111
- }
112
-
113
- // src/jsx-factory.ts
114
- function h(tag, props = {}, ...children) {
115
- if (typeof tag === "function") {
116
- return tag(props, children);
117
- }
118
- const element = createElement(tag);
119
- if (props) {
120
- const isSVG = shouldUseSVGNamespace(tag);
121
- Object.entries(props).forEach(([key, value]) => {
122
- if (value === null || value === void 0 || value === false) {
123
- return;
124
- }
125
- if (key === "ref" && typeof value === "function") {
126
- value(element);
127
- } else if (key === "className" || key === "class") {
128
- if (isSVG) {
129
- element.setAttribute("class", value);
130
- } else {
131
- element.className = value;
132
- }
133
- } else if (key === "style" && typeof value === "string") {
134
- element.setAttribute("style", value);
135
- } else if (key.startsWith("on") && typeof value === "function") {
136
- const eventName = key.slice(2).toLowerCase();
137
- element.addEventListener(eventName, value);
138
- } else if (typeof value === "boolean") {
139
- if (value) {
140
- element.setAttribute(key, "");
141
- }
142
- } else {
143
- const attributeName = isSVG ? getSVGAttributeName(key) : key;
144
- element.setAttribute(attributeName, String(value));
145
- }
146
- });
147
- }
148
- const flatChildren = flattenChildren(children);
149
- flatChildren.forEach((child) => {
150
- if (child === null || child === void 0 || child === false) {
151
- return;
152
- }
153
- if (typeof child === "string" || typeof child === "number") {
154
- element.appendChild(document.createTextNode(String(child)));
155
- } else if (child instanceof HTMLElement || child instanceof SVGElement) {
156
- element.appendChild(child);
157
- } else if (child instanceof DocumentFragment) {
158
- element.appendChild(child);
159
- }
160
- });
161
- return element;
162
- }
163
- function flattenChildren(children) {
164
- const result = [];
165
- for (const child of children) {
166
- if (child === null || child === void 0 || child === false) {
167
- continue;
168
- } else if (Array.isArray(child)) {
169
- result.push(...flattenChildren(child));
170
- } else {
171
- result.push(child);
172
- }
173
- }
174
- return result;
175
- }
176
- function Fragment(_props, children) {
177
- const fragment = document.createDocumentFragment();
178
- const flatChildren = flattenChildren(children);
179
- flatChildren.forEach((child) => {
180
- if (child === null || child === void 0 || child === false) {
181
- return;
182
- }
183
- if (typeof child === "string" || typeof child === "number") {
184
- fragment.appendChild(document.createTextNode(String(child)));
185
- } else if (child instanceof HTMLElement || child instanceof SVGElement) {
186
- fragment.appendChild(child);
187
- } else if (child instanceof DocumentFragment) {
188
- fragment.appendChild(child);
189
- }
190
- });
191
- return fragment;
192
- }
193
- function jsx(tag, props) {
194
- if (!props) {
195
- return h(tag, null);
196
- }
197
- const { children, ...restProps } = props;
198
- if (children !== void 0 && children !== null && typeof children !== "object" || Array.isArray(children) || typeof children === "string" || typeof children === "number" || typeof children === "boolean" || children instanceof HTMLElement || children instanceof SVGElement || children instanceof DocumentFragment) {
199
- return h(tag, restProps, children);
200
- }
201
- return h(tag, restProps);
202
- }
203
- function jsxs(tag, props) {
204
- if (!props) {
205
- return h(tag, null);
206
- }
207
- const { children, ...restProps } = props;
208
- if (Array.isArray(children)) {
209
- return h(tag, restProps, ...children);
210
- } else if (children !== void 0 && children !== null && (typeof children !== "object" || children instanceof HTMLElement || children instanceof SVGElement || children instanceof DocumentFragment)) {
211
- return h(tag, restProps, children);
212
- }
213
- return h(tag, restProps);
214
- }
215
-
216
- export {
217
- h,
218
- Fragment,
219
- jsx,
220
- jsxs
221
- };
222
- //# sourceMappingURL=chunk-A5GYVTI3.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/svg-utils.ts","../src/jsx-factory.ts"],"sourcesContent":["/**\n * SVG utilities for namespace-aware element creation\n */\n\n// SVG namespace URI\nexport const SVG_NAMESPACE = \"http://www.w3.org/2000/svg\";\n\n// SVG专用元素 - 只存在于SVG中的元素\nexport const SVG_ONLY_ELEMENTS = new Set([\n // 结构元素 (Structural elements)\n \"svg\",\n \"defs\",\n \"g\",\n \"symbol\",\n \"use\",\n\n // 图形元素 (Graphics elements)\n \"circle\",\n \"ellipse\",\n \"line\",\n \"path\",\n \"polygon\",\n \"polyline\",\n \"rect\",\n\n // 文本元素 (Text elements)\n \"textPath\",\n \"tspan\",\n\n // 渐变和模式 (Gradients and patterns)\n \"linearGradient\",\n \"radialGradient\",\n \"stop\",\n \"pattern\",\n\n // 滤镜 (Filter elements)\n \"filter\",\n \"feBlend\",\n \"feColorMatrix\",\n \"feComponentTransfer\",\n \"feComposite\",\n \"feConvolveMatrix\",\n \"feDiffuseLighting\",\n \"feDisplacementMap\",\n \"feDistantLight\",\n \"feDropShadow\",\n \"feFlood\",\n \"feFuncA\",\n \"feFuncB\",\n \"feFuncG\",\n \"feFuncR\",\n \"feGaussianBlur\",\n \"feImage\",\n \"feMerge\",\n \"feMergeNode\",\n \"feMorphology\",\n \"feOffset\",\n \"fePointLight\",\n \"feSpecularLighting\",\n \"feSpotLight\",\n \"feTile\",\n \"feTurbulence\",\n\n // 动画元素 (Animation elements)\n \"animate\",\n \"animateMotion\",\n \"animateTransform\",\n \"set\",\n\n // 其他元素 (Other elements)\n \"clipPath\",\n \"foreignObject\",\n \"marker\",\n \"mask\",\n \"metadata\",\n \"switch\",\n \"desc\",\n]);\n\n// 既存在于HTML又存在于SVG的元素 - 默认使用HTML版本\nexport const DUAL_ELEMENTS = new Set([\"image\", \"style\", \"title\", \"text\"]);\n\n// 强制使用HTML版本的元素(即使在SVG上下文中)\nexport const FORCE_HTML_ELEMENTS = new Set([\"a\"]);\n\n// 所有SVG元素的集合\nexport const SVG_ELEMENTS = new Set([\n ...SVG_ONLY_ELEMENTS,\n ...DUAL_ELEMENTS,\n ...FORCE_HTML_ELEMENTS,\n]);\n\n// SVG上下文追踪\nlet svgContext = false;\n\n/**\n * 检查标签名是否为SVG专用元素\n */\nexport function isSVGOnlyElement(tagName: string): boolean {\n return SVG_ONLY_ELEMENTS.has(tagName);\n}\n\n/**\n * 检查标签名是否为双重元素(HTML和SVG都有)\n */\nexport function isDualElement(tagName: string): boolean {\n return DUAL_ELEMENTS.has(tagName);\n}\n\n/**\n * 检查标签名是否为强制HTML元素\n */\nexport function isForceHTMLElement(tagName: string): boolean {\n return FORCE_HTML_ELEMENTS.has(tagName);\n}\n\n/**\n * 检查标签名是否为SVG元素(保持向后兼容)\n */\nexport function isSVGElement(tagName: string): boolean {\n return SVG_ELEMENTS.has(tagName);\n}\n\n/**\n * 设置SVG上下文状态\n */\nexport function setSVGContext(inSVG: boolean): void {\n svgContext = inSVG;\n}\n\n/**\n * 获取当前SVG上下文状态\n */\nexport function getSVGContext(): boolean {\n return svgContext;\n}\n\n/**\n * 创建元素 - 基于上下文和元素类型智能选择命名空间\n */\nexport function createElement(tagName: string): HTMLElement | SVGElement {\n // 强制HTML元素始终使用HTML版本\n if (isForceHTMLElement(tagName)) {\n return document.createElement(tagName) as HTMLElement;\n }\n\n // SVG专用元素始终使用SVG命名空间\n if (isSVGOnlyElement(tagName)) {\n setSVGContext(true); // 进入SVG上下文\n return document.createElementNS(SVG_NAMESPACE, tagName) as SVGElement;\n }\n\n // 双重元素根据上下文决定\n if (isDualElement(tagName)) {\n if (svgContext) {\n return document.createElementNS(SVG_NAMESPACE, tagName) as SVGElement;\n }\n }\n\n // 默认创建HTML元素\n return document.createElement(tagName) as HTMLElement;\n}\n\n/**\n * 检测元素是否需要在SVG上下文中处理\n */\nexport function shouldUseSVGNamespace(tagName: string): boolean {\n return isSVGOnlyElement(tagName) || (isDualElement(tagName) && svgContext);\n}\n\n/**\n * SVG特殊属性映射 - 处理SVG和HTML属性差异\n */\nexport const SVG_ATTRIBUTE_MAP = new Map([\n [\"className\", \"class\"],\n [\"htmlFor\", \"for\"],\n]);\n\n/**\n * 获取SVG元素的正确属性名\n */\nexport function getSVGAttributeName(attributeName: string): string {\n return SVG_ATTRIBUTE_MAP.get(attributeName) || attributeName;\n}\n","/**\n * 纯原生JSX工厂 - 零依赖的EditorJS Web Component支持\n *\n * 特点:\n * - 完全独立,不依赖React或任何框架\n * - 支持标准JSX语法\n * - 原生DOM操作,性能优异\n * - 完全通用,适用于任何Web Components\n * - TypeScript类型安全\n */\n\n// JSX 类型声明已移至 types/wsx-types.d.ts\n\nimport { createElement, shouldUseSVGNamespace, getSVGAttributeName } from \"./utils/svg-utils\";\n\n// JSX子元素类型\nexport type JSXChildren =\n | string\n | number\n | HTMLElement\n | SVGElement\n | DocumentFragment\n | JSXChildren[]\n | null\n | undefined\n | boolean;\n\n/**\n * 纯原生JSX工厂函数\n *\n * @param tag - HTML标签名或组件函数\n * @param props - 属性对象\n * @param children - 子元素\n * @returns DOM元素\n */\nexport function h(\n tag:\n | string\n | ((\n props: Record<string, unknown> | null,\n children: JSXChildren[]\n ) => HTMLElement | SVGElement),\n props: Record<string, unknown> | null = {},\n ...children: JSXChildren[]\n): HTMLElement | SVGElement {\n // 处理组件函数\n if (typeof tag === \"function\") {\n return tag(props, children);\n }\n\n // 创建DOM元素 - 自动检测SVG命名空间\n const element = createElement(tag);\n\n // 处理属性\n if (props) {\n const isSVG = shouldUseSVGNamespace(tag);\n\n Object.entries(props).forEach(([key, value]) => {\n if (value === null || value === undefined || value === false) {\n return;\n }\n\n // 处理ref回调\n if (key === \"ref\" && typeof value === \"function\") {\n value(element);\n }\n // 处理className和class\n else if (key === \"className\" || key === \"class\") {\n if (isSVG) {\n // SVG元素使用class属性\n element.setAttribute(\"class\", value as string);\n } else {\n // HTML元素可以使用className\n (element as HTMLElement).className = value as string;\n }\n }\n // 处理style\n else if (key === \"style\" && typeof value === \"string\") {\n element.setAttribute(\"style\", value);\n }\n // 处理事件监听器\n else if (key.startsWith(\"on\") && typeof value === \"function\") {\n const eventName = key.slice(2).toLowerCase();\n element.addEventListener(eventName, value as EventListener);\n }\n // 处理布尔属性\n else if (typeof value === \"boolean\") {\n if (value) {\n element.setAttribute(key, \"\");\n }\n }\n // 处理其他属性\n else {\n // 对SVG元素使用正确的属性名\n const attributeName = isSVG ? getSVGAttributeName(key) : key;\n element.setAttribute(attributeName, String(value));\n }\n });\n }\n\n // 处理子元素\n const flatChildren = flattenChildren(children);\n flatChildren.forEach((child) => {\n if (child === null || child === undefined || child === false) {\n return;\n }\n\n if (typeof child === \"string\" || typeof child === \"number\") {\n element.appendChild(document.createTextNode(String(child)));\n } else if (child instanceof HTMLElement || child instanceof SVGElement) {\n element.appendChild(child);\n } else if (child instanceof DocumentFragment) {\n element.appendChild(child);\n }\n });\n\n return element;\n}\n\n/**\n * 扁平化子元素数组\n */\nfunction flattenChildren(\n children: JSXChildren[]\n): (string | number | HTMLElement | SVGElement | DocumentFragment | boolean | null | undefined)[] {\n const result: (\n | string\n | number\n | HTMLElement\n | SVGElement\n | DocumentFragment\n | boolean\n | null\n | undefined\n )[] = [];\n\n for (const child of children) {\n if (child === null || child === undefined || child === false) {\n continue;\n } else if (Array.isArray(child)) {\n result.push(...flattenChildren(child));\n } else {\n result.push(child);\n }\n }\n\n return result;\n}\n\n/**\n * JSX Fragment支持 - 用于包装多个子元素\n */\nexport function Fragment(_props: unknown, children: JSXChildren[]): DocumentFragment {\n const fragment = document.createDocumentFragment();\n const flatChildren = flattenChildren(children);\n\n flatChildren.forEach((child) => {\n if (child === null || child === undefined || child === false) {\n return;\n }\n\n if (typeof child === \"string\" || typeof child === \"number\") {\n fragment.appendChild(document.createTextNode(String(child)));\n } else if (child instanceof HTMLElement || child instanceof SVGElement) {\n fragment.appendChild(child);\n } else if (child instanceof DocumentFragment) {\n fragment.appendChild(child);\n }\n });\n\n return fragment;\n}\n\n/**\n * JSX function for React's new JSX transform\n * Handles the new format: jsx(tag, { children: child, ...props })\n */\nexport function jsx(\n tag:\n | string\n | ((\n props: Record<string, unknown> | null,\n children: JSXChildren[]\n ) => HTMLElement | SVGElement),\n props: Record<string, unknown> | null\n): HTMLElement | SVGElement {\n if (!props) {\n return h(tag, null);\n }\n\n const { children, ...restProps } = props;\n if (\n (children !== undefined && children !== null && typeof children !== \"object\") ||\n Array.isArray(children) ||\n typeof children === \"string\" ||\n typeof children === \"number\" ||\n typeof children === \"boolean\" ||\n children instanceof HTMLElement ||\n children instanceof SVGElement ||\n children instanceof DocumentFragment\n ) {\n return h(tag, restProps, children as JSXChildren);\n }\n return h(tag, restProps);\n}\n\n/**\n * JSX function for multiple children in React's new JSX transform\n * Handles the new format: jsxs(tag, { children: [child1, child2], ...props })\n */\nexport function jsxs(\n tag:\n | string\n | ((\n props: Record<string, unknown> | null,\n children: JSXChildren[]\n ) => HTMLElement | SVGElement),\n props: Record<string, unknown> | null\n): HTMLElement | SVGElement {\n if (!props) {\n return h(tag, null);\n }\n\n const { children, ...restProps } = props;\n if (Array.isArray(children)) {\n return h(tag, restProps, ...children);\n } else if (\n children !== undefined &&\n children !== null &&\n (typeof children !== \"object\" ||\n children instanceof HTMLElement ||\n children instanceof SVGElement ||\n children instanceof DocumentFragment)\n ) {\n return h(tag, restProps, children as JSXChildren);\n }\n return h(tag, restProps);\n}\n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NAMESPACE = "http://www.w3.org/2000/svg";
3
- var SVG_ONLY_ELEMENTS = /* @__PURE__ */ new Set([
4
- // 结构元素 (Structural elements)
5
- "svg",
6
- "defs",
7
- "g",
8
- "symbol",
9
- "use",
10
- // 图形元素 (Graphics elements)
11
- "circle",
12
- "ellipse",
13
- "line",
14
- "path",
15
- "polygon",
16
- "polyline",
17
- "rect",
18
- // 文本元素 (Text elements)
19
- "textPath",
20
- "tspan",
21
- // 渐变和模式 (Gradients and patterns)
22
- "linearGradient",
23
- "radialGradient",
24
- "stop",
25
- "pattern",
26
- // 滤镜 (Filter elements)
27
- "filter",
28
- "feBlend",
29
- "feColorMatrix",
30
- "feComponentTransfer",
31
- "feComposite",
32
- "feConvolveMatrix",
33
- "feDiffuseLighting",
34
- "feDisplacementMap",
35
- "feDistantLight",
36
- "feDropShadow",
37
- "feFlood",
38
- "feFuncA",
39
- "feFuncB",
40
- "feFuncG",
41
- "feFuncR",
42
- "feGaussianBlur",
43
- "feImage",
44
- "feMerge",
45
- "feMergeNode",
46
- "feMorphology",
47
- "feOffset",
48
- "fePointLight",
49
- "feSpecularLighting",
50
- "feSpotLight",
51
- "feTile",
52
- "feTurbulence",
53
- // 动画元素 (Animation elements)
54
- "animate",
55
- "animateMotion",
56
- "animateTransform",
57
- "set",
58
- // 其他元素 (Other elements)
59
- "clipPath",
60
- "foreignObject",
61
- "marker",
62
- "mask",
63
- "metadata",
64
- "switch",
65
- "desc"
66
- ]);
67
- var DUAL_ELEMENTS = /* @__PURE__ */ new Set([
68
- "a",
69
- "image",
70
- "style",
71
- "title",
72
- "text"
73
- ]);
74
- var SVG_ELEMENTS = /* @__PURE__ */ new Set([...SVG_ONLY_ELEMENTS, ...DUAL_ELEMENTS]);
75
- var svgContext = false;
76
- function isSVGOnlyElement(tagName) {
77
- return SVG_ONLY_ELEMENTS.has(tagName);
78
- }
79
- function isDualElement(tagName) {
80
- return DUAL_ELEMENTS.has(tagName);
81
- }
82
- function setSVGContext(inSVG) {
83
- svgContext = inSVG;
84
- }
85
- function createElement(tagName) {
86
- if (isSVGOnlyElement(tagName)) {
87
- setSVGContext(true);
88
- return document.createElementNS(SVG_NAMESPACE, tagName);
89
- }
90
- if (isDualElement(tagName)) {
91
- if (svgContext) {
92
- return document.createElementNS(SVG_NAMESPACE, tagName);
93
- }
94
- }
95
- return document.createElement(tagName);
96
- }
97
- function shouldUseSVGNamespace(tagName) {
98
- return isSVGOnlyElement(tagName) || isDualElement(tagName) && svgContext;
99
- }
100
- var SVG_ATTRIBUTE_MAP = /* @__PURE__ */ new Map([
101
- ["className", "class"],
102
- ["htmlFor", "for"]
103
- ]);
104
- function getSVGAttributeName(attributeName) {
105
- return SVG_ATTRIBUTE_MAP.get(attributeName) || attributeName;
106
- }
107
-
108
- // src/jsx-factory.ts
109
- function h(tag, props = {}, ...children) {
110
- if (typeof tag === "function") {
111
- return tag(props, children);
112
- }
113
- const element = createElement(tag);
114
- if (props) {
115
- const isSVG = shouldUseSVGNamespace(tag);
116
- Object.entries(props).forEach(([key, value]) => {
117
- if (value === null || value === void 0 || value === false) {
118
- return;
119
- }
120
- if (key === "ref" && typeof value === "function") {
121
- value(element);
122
- } else if (key === "className" || key === "class") {
123
- if (isSVG) {
124
- element.setAttribute("class", value);
125
- } else {
126
- element.className = value;
127
- }
128
- } else if (key === "style" && typeof value === "string") {
129
- element.setAttribute("style", value);
130
- } else if (key.startsWith("on") && typeof value === "function") {
131
- const eventName = key.slice(2).toLowerCase();
132
- element.addEventListener(eventName, value);
133
- } else if (typeof value === "boolean") {
134
- if (value) {
135
- element.setAttribute(key, "");
136
- }
137
- } else {
138
- const attributeName = isSVG ? getSVGAttributeName(key) : key;
139
- element.setAttribute(attributeName, String(value));
140
- }
141
- });
142
- }
143
- const flatChildren = flattenChildren(children);
144
- flatChildren.forEach((child) => {
145
- if (child === null || child === void 0 || child === false) {
146
- return;
147
- }
148
- if (typeof child === "string" || typeof child === "number") {
149
- element.appendChild(document.createTextNode(String(child)));
150
- } else if (child instanceof HTMLElement || child instanceof SVGElement) {
151
- element.appendChild(child);
152
- } else if (child instanceof DocumentFragment) {
153
- element.appendChild(child);
154
- }
155
- });
156
- return element;
157
- }
158
- function flattenChildren(children) {
159
- const result = [];
160
- for (const child of children) {
161
- if (child === null || child === void 0 || child === false) {
162
- continue;
163
- } else if (Array.isArray(child)) {
164
- result.push(...flattenChildren(child));
165
- } else {
166
- result.push(child);
167
- }
168
- }
169
- return result;
170
- }
171
- function Fragment(_props, children) {
172
- const fragment = document.createDocumentFragment();
173
- const flatChildren = flattenChildren(children);
174
- flatChildren.forEach((child) => {
175
- if (child === null || child === void 0 || child === false) {
176
- return;
177
- }
178
- if (typeof child === "string" || typeof child === "number") {
179
- fragment.appendChild(document.createTextNode(String(child)));
180
- } else if (child instanceof HTMLElement || child instanceof SVGElement) {
181
- fragment.appendChild(child);
182
- } else if (child instanceof DocumentFragment) {
183
- fragment.appendChild(child);
184
- }
185
- });
186
- return fragment;
187
- }
188
- function jsx(tag, props) {
189
- if (!props) {
190
- return h(tag, null);
191
- }
192
- const { children, ...restProps } = props;
193
- if (children !== void 0) {
194
- return h(tag, restProps, children);
195
- }
196
- return h(tag, restProps);
197
- }
198
- function jsxs(tag, props) {
199
- if (!props) {
200
- return h(tag, null);
201
- }
202
- const { children, ...restProps } = props;
203
- if (Array.isArray(children)) {
204
- return h(tag, restProps, ...children);
205
- } else if (children !== void 0) {
206
- return h(tag, restProps, children);
207
- }
208
- return h(tag, restProps);
209
- }
210
-
211
- export {
212
- h,
213
- Fragment,
214
- jsx,
215
- jsxs
216
- };
@@ -1,79 +0,0 @@
1
- // src/jsx-factory.ts
2
- function h(tag, props = {}, ...children) {
3
- if (typeof tag === "function") {
4
- return tag(props, children);
5
- }
6
- const element = document.createElement(tag);
7
- if (props) {
8
- Object.entries(props).forEach(([key, value]) => {
9
- if (value === null || value === void 0 || value === false) {
10
- return;
11
- }
12
- if (key === "ref" && typeof value === "function") {
13
- value(element);
14
- } else if (key === "className" || key === "class") {
15
- element.className = value;
16
- } else if (key === "style" && typeof value === "string") {
17
- element.setAttribute("style", value);
18
- } else if (key.startsWith("on") && typeof value === "function") {
19
- const eventName = key.slice(2).toLowerCase();
20
- element.addEventListener(eventName, value);
21
- } else if (typeof value === "boolean") {
22
- if (value) {
23
- element.setAttribute(key, "");
24
- }
25
- } else {
26
- element.setAttribute(key, String(value));
27
- }
28
- });
29
- }
30
- const flatChildren = flattenChildren(children);
31
- flatChildren.forEach((child) => {
32
- if (child === null || child === void 0 || child === false) {
33
- return;
34
- }
35
- if (typeof child === "string" || typeof child === "number") {
36
- element.appendChild(document.createTextNode(String(child)));
37
- } else if (child instanceof HTMLElement) {
38
- element.appendChild(child);
39
- } else if (child instanceof DocumentFragment) {
40
- element.appendChild(child);
41
- }
42
- });
43
- return element;
44
- }
45
- function flattenChildren(children) {
46
- const result = [];
47
- for (const child of children) {
48
- if (child === null || child === void 0 || child === false) {
49
- continue;
50
- } else if (Array.isArray(child)) {
51
- result.push(...flattenChildren(child));
52
- } else {
53
- result.push(child);
54
- }
55
- }
56
- return result;
57
- }
58
- function Fragment(_props, children) {
59
- const fragment = document.createDocumentFragment();
60
- const flatChildren = flattenChildren(children);
61
- flatChildren.forEach((child) => {
62
- if (child === null || child === void 0 || child === false) {
63
- return;
64
- }
65
- if (typeof child === "string" || typeof child === "number") {
66
- fragment.appendChild(document.createTextNode(String(child)));
67
- } else if (child instanceof HTMLElement) {
68
- fragment.appendChild(child);
69
- } else if (child instanceof DocumentFragment) {
70
- fragment.appendChild(child);
71
- }
72
- });
73
- return fragment;
74
- }
75
-
76
- export {
77
- h,
78
- Fragment
79
- };