@arcmantle/lit-jsx 1.0.0

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 (119) hide show
  1. package/README.md +768 -0
  2. package/dist/compiler/attribute-processor.d.ts +128 -0
  3. package/dist/compiler/attribute-processor.d.ts.map +1 -0
  4. package/dist/compiler/attribute-processor.js +380 -0
  5. package/dist/compiler/attribute-processor.js.map +1 -0
  6. package/dist/compiler/babel-preset.d.ts +6 -0
  7. package/dist/compiler/babel-preset.d.ts.map +1 -0
  8. package/dist/compiler/babel-preset.js +27 -0
  9. package/dist/compiler/babel-preset.js.map +1 -0
  10. package/dist/compiler/builder.d.ts +22 -0
  11. package/dist/compiler/builder.d.ts.map +1 -0
  12. package/dist/compiler/builder.js +62 -0
  13. package/dist/compiler/builder.js.map +1 -0
  14. package/dist/compiler/compiler-utils.d.ts +81 -0
  15. package/dist/compiler/compiler-utils.d.ts.map +1 -0
  16. package/dist/compiler/compiler-utils.js +410 -0
  17. package/dist/compiler/compiler-utils.js.map +1 -0
  18. package/dist/compiler/config.d.ts +77 -0
  19. package/dist/compiler/config.d.ts.map +1 -0
  20. package/dist/compiler/config.js +78 -0
  21. package/dist/compiler/config.js.map +1 -0
  22. package/dist/compiler/postprocess.d.ts +5 -0
  23. package/dist/compiler/postprocess.d.ts.map +1 -0
  24. package/dist/compiler/postprocess.js +3 -0
  25. package/dist/compiler/postprocess.js.map +1 -0
  26. package/dist/compiler/preprocess.d.ts +5 -0
  27. package/dist/compiler/preprocess.d.ts.map +1 -0
  28. package/dist/compiler/preprocess.js +28 -0
  29. package/dist/compiler/preprocess.js.map +1 -0
  30. package/dist/compiler/transform-jsx.d.ts +5 -0
  31. package/dist/compiler/transform-jsx.d.ts.map +1 -0
  32. package/dist/compiler/transform-jsx.js +25 -0
  33. package/dist/compiler/transform-jsx.js.map +1 -0
  34. package/dist/compiler/transpiler.d.ts +48 -0
  35. package/dist/compiler/transpiler.d.ts.map +1 -0
  36. package/dist/compiler/transpiler.js +463 -0
  37. package/dist/compiler/transpiler.js.map +1 -0
  38. package/dist/compiler/vite-plugin.d.ts +38 -0
  39. package/dist/compiler/vite-plugin.d.ts.map +1 -0
  40. package/dist/compiler/vite-plugin.js +96 -0
  41. package/dist/compiler/vite-plugin.js.map +1 -0
  42. package/dist/runtime/choose-component.d.ts +39 -0
  43. package/dist/runtime/choose-component.d.ts.map +1 -0
  44. package/dist/runtime/choose-component.js +40 -0
  45. package/dist/runtime/choose-component.js.map +1 -0
  46. package/dist/runtime/compiler-ctors.d.ts +21 -0
  47. package/dist/runtime/compiler-ctors.d.ts.map +1 -0
  48. package/dist/runtime/compiler-ctors.js +21 -0
  49. package/dist/runtime/compiler-ctors.js.map +1 -0
  50. package/dist/runtime/for-component.d.ts +25 -0
  51. package/dist/runtime/for-component.d.ts.map +1 -0
  52. package/dist/runtime/for-component.js +35 -0
  53. package/dist/runtime/for-component.js.map +1 -0
  54. package/dist/runtime/literal-map.d.ts +22 -0
  55. package/dist/runtime/literal-map.d.ts.map +1 -0
  56. package/dist/runtime/literal-map.js +29 -0
  57. package/dist/runtime/literal-map.js.map +1 -0
  58. package/dist/runtime/rest-directive.d.ts +28 -0
  59. package/dist/runtime/rest-directive.d.ts.map +1 -0
  60. package/dist/runtime/rest-directive.js +49 -0
  61. package/dist/runtime/rest-directive.js.map +1 -0
  62. package/dist/runtime/show-component.d.ts +33 -0
  63. package/dist/runtime/show-component.d.ts.map +1 -0
  64. package/dist/runtime/show-component.js +30 -0
  65. package/dist/runtime/show-component.js.map +1 -0
  66. package/dist/runtime/tagged-template.d.ts +12 -0
  67. package/dist/runtime/tagged-template.d.ts.map +1 -0
  68. package/dist/runtime/tagged-template.js +12 -0
  69. package/dist/runtime/tagged-template.js.map +1 -0
  70. package/dist/runtime/type-helpers.d.ts +80 -0
  71. package/dist/runtime/type-helpers.d.ts.map +1 -0
  72. package/dist/runtime/type-helpers.js +85 -0
  73. package/dist/runtime/type-helpers.js.map +1 -0
  74. package/dist/shared/jsx-types.d.ts +2139 -0
  75. package/dist/shared/jsx-types.d.ts.map +1 -0
  76. package/dist/shared/jsx-types.js +2 -0
  77. package/dist/shared/jsx-types.js.map +1 -0
  78. package/dist/shared/jsx-utils.d.ts +30 -0
  79. package/dist/shared/jsx-utils.d.ts.map +1 -0
  80. package/dist/shared/jsx-utils.js +58 -0
  81. package/dist/shared/jsx-utils.js.map +1 -0
  82. package/dist/shared/mathml-tags.d.ts +12 -0
  83. package/dist/shared/mathml-tags.d.ts.map +1 -0
  84. package/dist/shared/mathml-tags.js +215 -0
  85. package/dist/shared/mathml-tags.js.map +1 -0
  86. package/dist/shared/svg-tags.d.ts +13 -0
  87. package/dist/shared/svg-tags.d.ts.map +1 -0
  88. package/dist/shared/svg-tags.js +95 -0
  89. package/dist/shared/svg-tags.js.map +1 -0
  90. package/dist/utils.d.ts +30 -0
  91. package/dist/utils.d.ts.map +1 -0
  92. package/dist/utils.js +30 -0
  93. package/dist/utils.js.map +1 -0
  94. package/package.json +52 -0
  95. package/src/compiler/attribute-processor.ts +579 -0
  96. package/src/compiler/babel-preset.ts +34 -0
  97. package/src/compiler/builder.ts +86 -0
  98. package/src/compiler/compiler-utils.ts +789 -0
  99. package/src/compiler/config.ts +77 -0
  100. package/src/compiler/postprocess.ts +7 -0
  101. package/src/compiler/preprocess.ts +40 -0
  102. package/src/compiler/transform-jsx.ts +36 -0
  103. package/src/compiler/transpiler.ts +644 -0
  104. package/src/compiler/vite-plugin.ts +114 -0
  105. package/src/external.d.ts +9 -0
  106. package/src/runtime/choose-component.ts +53 -0
  107. package/src/runtime/compiler-ctors.ts +28 -0
  108. package/src/runtime/for-component.ts +54 -0
  109. package/src/runtime/literal-map.ts +37 -0
  110. package/src/runtime/rest-directive.ts +66 -0
  111. package/src/runtime/show-component.ts +48 -0
  112. package/src/runtime/tagged-template.ts +11 -0
  113. package/src/runtime/type-helpers.ts +91 -0
  114. package/src/shared/jsx-types.ts +2556 -0
  115. package/src/shared/jsx-utils.ts +85 -0
  116. package/src/shared/mathml-tags.ts +235 -0
  117. package/src/shared/svg-tags.ts +103 -0
  118. package/src/tsconfig.json +4 -0
  119. package/src/utils.ts +30 -0
@@ -0,0 +1,39 @@
1
+ type ChooseValue<T> = T extends undefined ? never : T;
2
+ type ChooseChild<T> = [
3
+ condition: (value: ChooseValue<T>) => boolean,
4
+ output: (value: ChooseValue<T>) => JSX.JSXElement
5
+ ];
6
+ /**
7
+ * Conditionally renders content based on evaluating multiple condition-output pairs against a value.
8
+ * Similar to lit-html's choose directive, evaluates each condition in order and renders the first match.
9
+ *
10
+ * @template T - The type of the value to evaluate against (defaults to undefined for no value)
11
+ * @param props.value - The value to pass to each condition and output function
12
+ * @param props.children - Single [condition, output] tuple or multiple tuple children to evaluate
13
+ * @returns The rendered JSX element from the first matching condition, or nothing if no match
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * // Multiple condition-output tuples as separate children
18
+ * <Choose value={status}>
19
+ * {[
20
+ * (status) => status === 'loading',
21
+ * () => <div>Loading...</div>
22
+ * ]}
23
+ * {[
24
+ * (status) => status === 'error',
25
+ * (status) => <div>Error: {status}</div>
26
+ * ]}
27
+ * {[
28
+ * () => true, // default case
29
+ * (status) => <div>Status: {status}</div>
30
+ * ]}
31
+ * </Choose>
32
+ * ```
33
+ */
34
+ export declare function Choose<T = undefined>(props: {
35
+ value?: T;
36
+ children: ChooseChild<T> | ChooseChild<T>[];
37
+ }): JSX.JSXElement;
38
+ export {};
39
+ //# sourceMappingURL=choose-component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choose-component.d.ts","sourceRoot":"","sources":["../../src/runtime/choose-component.ts"],"names":[],"mappings":"AAGA,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AACtD,KAAK,WAAW,CAAC,CAAC,IAAI;IACrB,SAAS,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,OAAO;IAC7C,MAAM,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,UAAU;CACjD,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,MAAM,CAAC,CAAC,GAAG,SAAS,EAAE,KAAK,EAAE;IAC5C,KAAK,CAAC,EAAI,CAAC,CAAC;IACZ,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;CAC5C,GAAG,GAAG,CAAC,UAAU,CAWjB"}
@@ -0,0 +1,40 @@
1
+ import { nothing } from 'lit-html';
2
+ /**
3
+ * Conditionally renders content based on evaluating multiple condition-output pairs against a value.
4
+ * Similar to lit-html's choose directive, evaluates each condition in order and renders the first match.
5
+ *
6
+ * @template T - The type of the value to evaluate against (defaults to undefined for no value)
7
+ * @param props.value - The value to pass to each condition and output function
8
+ * @param props.children - Single [condition, output] tuple or multiple tuple children to evaluate
9
+ * @returns The rendered JSX element from the first matching condition, or nothing if no match
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * // Multiple condition-output tuples as separate children
14
+ * <Choose value={status}>
15
+ * {[
16
+ * (status) => status === 'loading',
17
+ * () => <div>Loading...</div>
18
+ * ]}
19
+ * {[
20
+ * (status) => status === 'error',
21
+ * (status) => <div>Error: {status}</div>
22
+ * ]}
23
+ * {[
24
+ * () => true, // default case
25
+ * (status) => <div>Status: {status}</div>
26
+ * ]}
27
+ * </Choose>
28
+ * ```
29
+ */
30
+ export function Choose(props) {
31
+ const children = Array.isArray(props.children.at(-1))
32
+ ? props.children
33
+ : [props.children];
34
+ for (const [condition, output] of children) {
35
+ if (condition(props.value))
36
+ return output(props.value);
37
+ }
38
+ return nothing;
39
+ }
40
+ //# sourceMappingURL=choose-component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choose-component.js","sourceRoot":"","sources":["../../src/runtime/choose-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAUnC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,MAAM,CAAgB,KAGrC;IACA,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,CAAC,CAAC,KAAK,CAAC,QAA4B;QACpC,CAAC,CAAC,CAAE,KAAK,CAAC,QAA0B,CAAE,CAAC;IAExC,KAAK,MAAM,CAAE,SAAS,EAAE,MAAM,CAAE,IAAI,QAAQ,EAAE,CAAC;QAC9C,IAAI,SAAS,CAAC,KAAK,CAAC,KAAuB,CAAC;YAC3C,OAAO,MAAM,CAAC,KAAK,CAAC,KAAuB,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @fileoverview Internal lit-html part constructors for jsx-lit compiler.
3
+ *
4
+ * This module exports the internal part constructors from lit-html that are used
5
+ * by the lit-jsx compiler to create optimized template parts. These are low-level
6
+ * utilities used internally by the compilation process.
7
+ */
8
+ import * as internals from 'lit-html/private-ssr-support.js';
9
+ /** Boolean attribute part constructor from lit-html internals */
10
+ export declare const BooleanPart: typeof internals._$LH.BooleanAttributePart;
11
+ /** Attribute part constructor from lit-html internals */
12
+ export declare const AttributePart: typeof internals._$LH.AttributePart;
13
+ /** Property part constructor from lit-html internals */
14
+ export declare const PropertyPart: typeof internals._$LH.PropertyPart;
15
+ /** Element part constructor from lit-html internals */
16
+ export declare const ElementPart: typeof internals._$LH.ElementPart;
17
+ /** Event part constructor from lit-html internals */
18
+ export declare const EventPart: typeof internals._$LH.EventPart;
19
+ /** Child part constructor from lit-html internals */
20
+ export declare const ChildPart: typeof internals._$LH.ChildPart;
21
+ //# sourceMappingURL=compiler-ctors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler-ctors.d.ts","sourceRoot":"","sources":["../../src/runtime/compiler-ctors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,SAAS,MAAM,iCAAiC,CAAC;AAG7D,iEAAiE;AACjE,eAAO,MAAM,WAAW,EAAI,OAAO,SAAS,CAAC,IAAI,CAAC,oBAA0D,CAAC;AAE7G,yDAAyD;AACzD,eAAO,MAAM,aAAa,EAAE,OAAO,SAAS,CAAC,IAAI,CAAC,aAA4C,CAAC;AAE/F,wDAAwD;AACxD,eAAO,MAAM,YAAY,EAAG,OAAO,SAAS,CAAC,IAAI,CAAC,YAA2C,CAAC;AAE9F,uDAAuD;AACvD,eAAO,MAAM,WAAW,EAAI,OAAO,SAAS,CAAC,IAAI,CAAC,WAA0C,CAAC;AAE7F,qDAAqD;AACrD,eAAO,MAAM,SAAS,EAAM,OAAO,SAAS,CAAC,IAAI,CAAC,SAAwC,CAAC;AAE3F,qDAAqD;AACrD,eAAO,MAAM,SAAS,EAAM,OAAO,SAAS,CAAC,IAAI,CAAC,SAAwC,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @fileoverview Internal lit-html part constructors for jsx-lit compiler.
3
+ *
4
+ * This module exports the internal part constructors from lit-html that are used
5
+ * by the lit-jsx compiler to create optimized template parts. These are low-level
6
+ * utilities used internally by the compilation process.
7
+ */
8
+ import * as internals from 'lit-html/private-ssr-support.js';
9
+ /** Boolean attribute part constructor from lit-html internals */
10
+ export const BooleanPart = internals._$LH.BooleanAttributePart;
11
+ /** Attribute part constructor from lit-html internals */
12
+ export const AttributePart = internals._$LH.AttributePart;
13
+ /** Property part constructor from lit-html internals */
14
+ export const PropertyPart = internals._$LH.PropertyPart;
15
+ /** Element part constructor from lit-html internals */
16
+ export const ElementPart = internals._$LH.ElementPart;
17
+ /** Event part constructor from lit-html internals */
18
+ export const EventPart = internals._$LH.EventPart;
19
+ /** Child part constructor from lit-html internals */
20
+ export const ChildPart = internals._$LH.ChildPart;
21
+ //# sourceMappingURL=compiler-ctors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler-ctors.js","sourceRoot":"","sources":["../../src/runtime/compiler-ctors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,SAAS,MAAM,iCAAiC,CAAC;AAG7D,iEAAiE;AACjE,MAAM,CAAC,MAAM,WAAW,GAAiD,SAAS,CAAC,IAAI,CAAC,oBAAoB,CAAC;AAE7G,yDAAyD;AACzD,MAAM,CAAC,MAAM,aAAa,GAAwC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC;AAE/F,wDAAwD;AACxD,MAAM,CAAC,MAAM,YAAY,GAAyC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC;AAE9F,uDAAuD;AACvD,MAAM,CAAC,MAAM,WAAW,GAA0C,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC;AAE7F,qDAAqD;AACrD,MAAM,CAAC,MAAM,SAAS,GAA4C,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;AAE3F,qDAAqD;AACrD,MAAM,CAAC,MAAM,SAAS,GAA4C,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Renders a list of items with optional keys and separators.
3
+ *
4
+ * @template T - The type of items in the array
5
+ * @template U - The JSX element type returned by the render function
6
+ * @param props.each - Array of items to render
7
+ * @param props.key - Optional key function for efficient updates (uses lit-html's repeat directive)
8
+ * @param props.separator - Optional JSX element to insert between items
9
+ * @param props.children - Render function that receives each item and its index
10
+ * @returns An iterator from either the map or repeat directive, depending on whether a key function is provided.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * <For each={users} key={(user) => user.id}>
15
+ * {(user, index) => <div key={user.id}>{user.name}</div>}
16
+ * </For>
17
+ * ```
18
+ */
19
+ export declare function For<T, U extends JSX.JSXElement>(props: {
20
+ each: readonly T[];
21
+ key?: (item: T, index: number) => any;
22
+ separator?: JSX.JSXElement;
23
+ children: (item: T, index: number) => U;
24
+ }): JSX.JSXElement;
25
+ //# sourceMappingURL=for-component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"for-component.d.ts","sourceRoot":"","sources":["../../src/runtime/for-component.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE;IACvD,IAAI,EAAQ,SAAS,CAAC,EAAE,CAAC;IACzB,GAAG,CAAC,EAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG,CAAC;IAC5C,SAAS,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC;IAC3B,QAAQ,EAAI,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC;CAC1C,GAAG,GAAG,CAAC,UAAU,CAyBjB"}
@@ -0,0 +1,35 @@
1
+ import { join } from 'lit-html/directives/join.js';
2
+ import { map } from 'lit-html/directives/map.js';
3
+ import { repeat } from 'lit-html/directives/repeat.js';
4
+ /**
5
+ * Renders a list of items with optional keys and separators.
6
+ *
7
+ * @template T - The type of items in the array
8
+ * @template U - The JSX element type returned by the render function
9
+ * @param props.each - Array of items to render
10
+ * @param props.key - Optional key function for efficient updates (uses lit-html's repeat directive)
11
+ * @param props.separator - Optional JSX element to insert between items
12
+ * @param props.children - Render function that receives each item and its index
13
+ * @returns An iterator from either the map or repeat directive, depending on whether a key function is provided.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * <For each={users} key={(user) => user.id}>
18
+ * {(user, index) => <div key={user.id}>{user.name}</div>}
19
+ * </For>
20
+ * ```
21
+ */
22
+ export function For(props) {
23
+ if (props.key) {
24
+ return repeat(props.each, (item, index) => props.key(item, index), (item, index) => {
25
+ if (props.separator && index > 0)
26
+ return [props.separator, props.children(item, index)];
27
+ return props.children(item, index);
28
+ });
29
+ }
30
+ if (props.separator) {
31
+ return join(map(props.each, (item, index) => props.children(item, index)), props.separator);
32
+ }
33
+ return map(props.each, (item, index) => props.children(item, index));
34
+ }
35
+ //# sourceMappingURL=for-component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"for-component.js","sourceRoot":"","sources":["../../src/runtime/for-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAGvD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,GAAG,CAA8B,KAKhD;IACA,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;QACf,OAAO,MAAM,CACZ,KAAK,CAAC,IAAI,EACV,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAI,CAAC,IAAI,EAAE,KAAK,CAAC,EACxC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YACf,IAAI,KAAK,CAAC,SAAS,IAAI,KAAK,GAAG,CAAC;gBAC/B,OAAO,CAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAE,CAAC;YAEzD,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACpC,CAAC,CACD,CAAC;IACH,CAAC;IAED,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC,GAAG,CACd,KAAK,CAAC,IAAI,EACV,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAC5C,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IACrB,CAAC;IAED,OAAO,GAAG,CACT,KAAK,CAAC,IAAI,EACV,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAC5C,CAAC;AACH,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { StaticValue } from 'lit-html/static.js';
2
+ /**
3
+ * Cache for static literal values used in lit-html templates.
4
+ * Extends Map to automatically create and cache StaticValue instances for string keys.
5
+ */
6
+ declare class LiteralMap extends Map<string, StaticValue> {
7
+ /**
8
+ * Gets a cached StaticValue for the given key, creating one if it doesn't exist.
9
+ *
10
+ * @param key - The string key to get or create a StaticValue for
11
+ * @returns The cached or newly created StaticValue
12
+ */
13
+ get(key: string): StaticValue;
14
+ }
15
+ /**
16
+ * Global cache instance for static literal values used throughout jsx-lit templates.
17
+ * This is used internally by the jsx-lit compiler to cache StaticValue instances
18
+ * for efficient template reuse.
19
+ */
20
+ export declare const __$literalMap: LiteralMap;
21
+ export {};
22
+ //# sourceMappingURL=literal-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"literal-map.d.ts","sourceRoot":"","sources":["../../src/runtime/literal-map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAItD;;;GAGG;AACH,cAAM,UAAW,SAAQ,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC;IAEhD;;;;;OAKG;IACM,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW;CAYtC;AAGD;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,UAA6B,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { unsafeStatic } from 'lit-html/static.js';
2
+ /**
3
+ * Cache for static literal values used in lit-html templates.
4
+ * Extends Map to automatically create and cache StaticValue instances for string keys.
5
+ */
6
+ class LiteralMap extends Map {
7
+ /**
8
+ * Gets a cached StaticValue for the given key, creating one if it doesn't exist.
9
+ *
10
+ * @param key - The string key to get or create a StaticValue for
11
+ * @returns The cached or newly created StaticValue
12
+ */
13
+ get(key) {
14
+ const value = super.get(key);
15
+ if (value === undefined) {
16
+ const literal = unsafeStatic(key);
17
+ this.set(key, literal);
18
+ return literal;
19
+ }
20
+ return value;
21
+ }
22
+ }
23
+ /**
24
+ * Global cache instance for static literal values used throughout jsx-lit templates.
25
+ * This is used internally by the jsx-lit compiler to cache StaticValue instances
26
+ * for efficient template reuse.
27
+ */
28
+ export const __$literalMap = new LiteralMap();
29
+ //# sourceMappingURL=literal-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"literal-map.js","sourceRoot":"","sources":["../../src/runtime/literal-map.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD;;;GAGG;AACH,MAAM,UAAW,SAAQ,GAAwB;IAEhD;;;;;OAKG;IACM,GAAG,CAAC,GAAW;QACvB,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;YAClC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAEvB,OAAO,OAAO,CAAC;QAChB,CAAC;QAED,OAAO,KAAK,CAAC;IACd,CAAC;CAED;AAGD;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAe,IAAI,UAAU,EAAE,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { ElementPart } from 'lit-html';
2
+ import type { DirectiveParameters, DirectiveResult, PartInfo } from 'lit-html/directive.js';
3
+ import { Directive } from 'lit-html/directive.js';
4
+ /**
5
+ * Lit directive for applying rest/spread props to an element.
6
+ * Efficiently sets properties and attributes from an object of key-value pairs.
7
+ */
8
+ declare class RestDirective extends Directive {
9
+ constructor(part: PartInfo);
10
+ update(part: ElementPart, [rest]: DirectiveParameters<this>): unknown;
11
+ render(rest: Record<keyof any, any>): unknown;
12
+ }
13
+ /**
14
+ * Lit directive for applying rest/spread props to DOM elements.
15
+ *
16
+ * This directive efficiently applies an object of properties and attributes
17
+ * to a DOM element, handling the differences between properties and attributes
18
+ * automatically.
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * const props = { className: 'my-class', disabled: true };
23
+ * <div {...__$rest(props)}>Content</div>
24
+ * ```
25
+ */
26
+ export declare const __$rest: DirectiveResult<typeof RestDirective>;
27
+ export {};
28
+ //# sourceMappingURL=rest-directive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rest-directive.d.ts","sourceRoot":"","sources":["../../src/runtime/rest-directive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAuB,MAAM,uBAAuB,CAAC;AAGvE;;;GAGG;AACH,cAAM,aAAc,SAAQ,SAAS;gBAExB,IAAI,EAAE,QAAQ;IAOjB,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,CAAE,IAAI,CAAE,EAAE,mBAAmB,CAAC,IAAI,CAAC,GAAG,OAAO;IAuBvE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,GAAG,EAAE,GAAG,CAAC,GAAG,OAAO;CAMtD;AAGD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,OAAO,EAAE,eAAe,CAAC,OAAO,aAAa,CACjC,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { noChange } from 'lit-html';
2
+ import { Directive, directive, PartType } from 'lit-html/directive.js';
3
+ /**
4
+ * Lit directive for applying rest/spread props to an element.
5
+ * Efficiently sets properties and attributes from an object of key-value pairs.
6
+ */
7
+ class RestDirective extends Directive {
8
+ constructor(part) {
9
+ super(part);
10
+ if (part.type !== PartType.ELEMENT)
11
+ throw new Error('RestDirective can only be used on ElementParts');
12
+ }
13
+ update(part, [rest]) {
14
+ const element = part.element;
15
+ for (const key in rest) {
16
+ if (!Object.prototype.hasOwnProperty.call(rest, key))
17
+ continue;
18
+ const value = rest[key];
19
+ if (element[key] === value)
20
+ continue;
21
+ if (typeof value === 'object')
22
+ element[key] = value;
23
+ else if (value === null || value === undefined)
24
+ element.removeAttribute(key);
25
+ else
26
+ element.setAttribute(key, String(value));
27
+ }
28
+ return noChange;
29
+ }
30
+ render(rest) {
31
+ console.log('rest parameter stuff', rest);
32
+ return noChange;
33
+ }
34
+ }
35
+ /**
36
+ * Lit directive for applying rest/spread props to DOM elements.
37
+ *
38
+ * This directive efficiently applies an object of properties and attributes
39
+ * to a DOM element, handling the differences between properties and attributes
40
+ * automatically.
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * const props = { className: 'my-class', disabled: true };
45
+ * <div {...__$rest(props)}>Content</div>
46
+ * ```
47
+ */
48
+ export const __$rest = directive(RestDirective);
49
+ //# sourceMappingURL=rest-directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rest-directive.js","sourceRoot":"","sources":["../../src/runtime/rest-directive.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGvE;;;GAGG;AACH,MAAM,aAAc,SAAQ,SAAS;IAEpC,YAAY,IAAc;QACzB,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,OAAO;YACjC,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IAEQ,MAAM,CAAC,IAAiB,EAAE,CAAE,IAAI,CAA6B;QACrE,MAAM,OAAO,GAAG,IAAI,CAAC,OAA4C,CAAC;QAElE,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACxB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC;gBACnD,SAAS;YAEV,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAE,CAAC;YAEzB,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK;gBACzB,SAAS;YAEV,IAAI,OAAO,KAAK,KAAK,QAAQ;gBAC5B,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;iBACjB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;gBAC7C,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;;gBAE7B,OAAO,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3C,CAAC;QAED,OAAO,QAAQ,CAAC;IACjB,CAAC;IAEQ,MAAM,CAAC,IAA4B;QAC3C,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,IAAI,CAAC,CAAC;QAE1C,OAAO,QAAQ,CAAC;IACjB,CAAC;CAED;AAGD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,OAAO,GACnB,SAAS,CAAC,aAAa,CAAC,CAAC"}
@@ -0,0 +1,33 @@
1
+ type Falsy = null | undefined | false | 0 | -0 | 0n | '';
2
+ export declare const when: <C, T, F>(condition: C, trueCase: (c: NoInfer<Exclude<C, Falsy>>) => T, falseCase?: (c: NoInfer<Exclude<C, Falsy>>) => F) => C extends Falsy ? F : T;
3
+ type ShowTrueCase<C, T> = (value: NoInfer<Exclude<C, Falsy>>) => T;
4
+ type ShowFalseCase<C, F> = (value: NoInfer<Exclude<C, Falsy>>) => F;
5
+ type ShowChildren<C, T, F> = ShowTrueCase<C, T> | [true: ShowTrueCase<C, T>, false: ShowFalseCase<C, F>];
6
+ /**
7
+ * Conditionally renders content based on a truthy value.
8
+ *
9
+ * @template T - The type of the condition value
10
+ * @template U - The JSX element type returned by the render functions
11
+ * @param props.when - The condition value to evaluate for truthiness
12
+ * @param props.children - A single render or tuple containing render functions for true and optionally false cases
13
+ * @returns The rendered JSX element based on the condition's truthiness
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * <Show when={user}>
18
+ * {(user) => <div>Welcome, {user.name}!</div>}
19
+ * {() => <div>Please log in</div>}
20
+ * </Show>
21
+ *
22
+ * // Or without fallback
23
+ * <Show when={isVisible}>
24
+ * {() => <div>This content is visible</div>}
25
+ * </Show>
26
+ * ```
27
+ */
28
+ export declare function Show<C, T, F>(props: {
29
+ when: C;
30
+ children: ShowChildren<C, T, F>;
31
+ }): C extends Falsy ? F : T;
32
+ export {};
33
+ //# sourceMappingURL=show-component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"show-component.d.ts","sourceRoot":"","sources":["../../src/runtime/show-component.ts"],"names":[],"mappings":"AAGA,KAAK,KAAK,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC;AACzD,eAAO,MAAM,IAAI,EAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EACtC,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,EAC9C,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,KAC5C,CAAC,SAAS,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC;AAE7B,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;AACnE,KAAK,aAAa,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;AACpE,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IACtB,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAClB,CAAE,IAAI,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAE,CAAC;AAG5D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE;IACpC,IAAI,EAAM,CAAC,CAAC;IACZ,QAAQ,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;CAChC,GAAG,CAAC,SAAS,KAAK,GAAG,CAAC,GAAG,CAAC,CAK1B"}
@@ -0,0 +1,30 @@
1
+ import { when as litWhen } from 'lit-html/directives/when.js';
2
+ export const when = litWhen;
3
+ /**
4
+ * Conditionally renders content based on a truthy value.
5
+ *
6
+ * @template T - The type of the condition value
7
+ * @template U - The JSX element type returned by the render functions
8
+ * @param props.when - The condition value to evaluate for truthiness
9
+ * @param props.children - A single render or tuple containing render functions for true and optionally false cases
10
+ * @returns The rendered JSX element based on the condition's truthiness
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * <Show when={user}>
15
+ * {(user) => <div>Welcome, {user.name}!</div>}
16
+ * {() => <div>Please log in</div>}
17
+ * </Show>
18
+ *
19
+ * // Or without fallback
20
+ * <Show when={isVisible}>
21
+ * {() => <div>This content is visible</div>}
22
+ * </Show>
23
+ * ```
24
+ */
25
+ export function Show(props) {
26
+ if (Array.isArray(props.children))
27
+ return when(props.when, props.children[0], props.children[1]);
28
+ return when(props.when, props.children);
29
+ }
30
+ //# sourceMappingURL=show-component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"show-component.js","sourceRoot":"","sources":["../../src/runtime/show-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAI9D,MAAM,CAAC,MAAM,IAAI,GAAG,OAIQ,CAAC;AAS7B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,IAAI,CAAU,KAG7B;IACA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC;QAChC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAE/D,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Identity function for template string arrays used by jsx-lit compiler.
3
+ *
4
+ * This function is used as a marker by the jsx-lit compiler to identify
5
+ * template literals that should be processed for JSX compilation. It simply
6
+ * returns the input unchanged but signals to the compiler where JSX templates are located.
7
+ *
8
+ * @param strings - The template strings array from a template literal
9
+ * @returns The same template strings array unchanged
10
+ */
11
+ export declare const __$t: (strings: TemplateStringsArray) => TemplateStringsArray;
12
+ //# sourceMappingURL=tagged-template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tagged-template.d.ts","sourceRoot":"","sources":["../../src/runtime/tagged-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,IAAI,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,oBAA6B,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Identity function for template string arrays used by jsx-lit compiler.
3
+ *
4
+ * This function is used as a marker by the jsx-lit compiler to identify
5
+ * template literals that should be processed for JSX compilation. It simply
6
+ * returns the input unchanged but signals to the compiler where JSX templates are located.
7
+ *
8
+ * @param strings - The template strings array from a template literal
9
+ * @returns The same template strings array unchanged
10
+ */
11
+ export const __$t = s => s;
12
+ //# sourceMappingURL=tagged-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tagged-template.js","sourceRoot":"","sources":["../../src/runtime/tagged-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,IAAI,GAA4D,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Creates a variable which can be used using the Component syntax in JSX.
3
+ * Also registers the custom element if it hasn't been registered yet.
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * import { toJSX } from 'jsx-lit';
8
+ *
9
+ * export class MyButton extends LitElement {
10
+ * static tagName = 'my-button';
11
+ * static tag = toJSX(MyButton);
12
+ *
13
+ * render() {
14
+ * return html`<button><slot></slot></button>`;
15
+ * }
16
+ * }
17
+ *
18
+ * // Usage in JSX
19
+ * const jsx = (
20
+ * <MyButton.tag
21
+ * class="my-button"
22
+ * on-click={() => { console.log('Clicked!'); }}
23
+ * />
24
+ * );
25
+ * ```
26
+ */
27
+ export declare const toJSX: <T extends {
28
+ new (...args: any): any;
29
+ tagName: string;
30
+ }>(element: T) => (props: JSX.JSXProps<InstanceType<T>>) => string;
31
+ /**
32
+ * Creates a dynamic tag name object that can be used with jsx-lit's Component syntax.
33
+ * This function is required for dynamic tag names to compile to static literals.
34
+ *
35
+ * **IMPORTANT**: Dynamic tag names must use the `.tag` property pattern to be properly
36
+ * compiled to lit-html static templates. Without this pattern, jsx-lit cannot detect
37
+ * and transform the dynamic tag name into efficient static template literals.
38
+ *
39
+ * @example
40
+ * ```tsx
41
+ * import { toTag } from 'jsx-lit';
42
+ *
43
+ * // ✅ Correct usage - creates { tag: 'div' } object
44
+ * const DynamicDiv = toTag('div');
45
+ * const DynamicCustomElement = toTag('my-custom-element');
46
+ *
47
+ * // Usage in JSX with .tag property (required for compilation)
48
+ * function renderConditional({ useDiv }) {
49
+ * const Tag = toTag(useDiv ? 'div' : 'span');
50
+ * return <Tag.tag class="dynamic">Content</Tag.tag>;
51
+ * }
52
+ *
53
+ * // Compiles to efficient static templates:
54
+ * // const Tag = toTag(useDiv ? 'div' : 'span');
55
+ * // const __$Tag = __$literalMap.get(Tag.tag);
56
+ * // htmlStatic`<${__$Tag} class="dynamic">Content</${__$Tag}>`
57
+ * ```
58
+ *
59
+ * @example
60
+ * ```tsx
61
+ * // ❌ Incorrect usage - won't compile to static templates
62
+ * const badTag = 'div';
63
+ * return <badTag>Content</badTag>; // This won't work with jsx-lit
64
+ *
65
+ * // ❌ Incorrect usage - missing .tag property
66
+ * const BadTag = toTag('div');
67
+ * return <BadTag>Content</BadTag>; // Won't compile correctly
68
+ *
69
+ * // ✅ Correct usage - with .tag property
70
+ * const GoodTag = toTag('div');
71
+ * return <GoodTag.tag>Content</GoodTag.tag>; // Compiles to static templates
72
+ * ```
73
+ *
74
+ * @param tag - The HTML tag name (standard HTML elements or custom element names)
75
+ * @returns An object with a `tag` property containing the tag name, designed for use with jsx-lit's Component syntax
76
+ */
77
+ export declare const toTag: <T extends keyof HTMLElementTagNameMap | (string & {})>(tag: T) => {
78
+ tag: T;
79
+ };
80
+ //# sourceMappingURL=type-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-helpers.d.ts","sourceRoot":"","sources":["../../src/runtime/type-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS;IAAE,KAAI,GAAG,IAAI,EAAE,GAAG,GAAG,GAAG,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;CAAE,EAC3E,SAAS,CAAC,KACR,CAAC,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,MAS5C,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,MAAM,qBAAqB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,EAC1E,KAAK,CAAC,KACJ;IAAE,GAAG,EAAE,CAAC,CAAC;CAEX,CAAC"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Creates a variable which can be used using the Component syntax in JSX.
3
+ * Also registers the custom element if it hasn't been registered yet.
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * import { toJSX } from 'jsx-lit';
8
+ *
9
+ * export class MyButton extends LitElement {
10
+ * static tagName = 'my-button';
11
+ * static tag = toJSX(MyButton);
12
+ *
13
+ * render() {
14
+ * return html`<button><slot></slot></button>`;
15
+ * }
16
+ * }
17
+ *
18
+ * // Usage in JSX
19
+ * const jsx = (
20
+ * <MyButton.tag
21
+ * class="my-button"
22
+ * on-click={() => { console.log('Clicked!'); }}
23
+ * />
24
+ * );
25
+ * ```
26
+ */
27
+ export const toJSX = (element) => {
28
+ queueMicrotask(() => {
29
+ if ('register' in element && typeof element.register === 'function')
30
+ element.register();
31
+ else if (!customElements.get(element.tagName))
32
+ customElements.define(element.tagName, element);
33
+ });
34
+ return element.tagName;
35
+ };
36
+ /**
37
+ * Creates a dynamic tag name object that can be used with jsx-lit's Component syntax.
38
+ * This function is required for dynamic tag names to compile to static literals.
39
+ *
40
+ * **IMPORTANT**: Dynamic tag names must use the `.tag` property pattern to be properly
41
+ * compiled to lit-html static templates. Without this pattern, jsx-lit cannot detect
42
+ * and transform the dynamic tag name into efficient static template literals.
43
+ *
44
+ * @example
45
+ * ```tsx
46
+ * import { toTag } from 'jsx-lit';
47
+ *
48
+ * // ✅ Correct usage - creates { tag: 'div' } object
49
+ * const DynamicDiv = toTag('div');
50
+ * const DynamicCustomElement = toTag('my-custom-element');
51
+ *
52
+ * // Usage in JSX with .tag property (required for compilation)
53
+ * function renderConditional({ useDiv }) {
54
+ * const Tag = toTag(useDiv ? 'div' : 'span');
55
+ * return <Tag.tag class="dynamic">Content</Tag.tag>;
56
+ * }
57
+ *
58
+ * // Compiles to efficient static templates:
59
+ * // const Tag = toTag(useDiv ? 'div' : 'span');
60
+ * // const __$Tag = __$literalMap.get(Tag.tag);
61
+ * // htmlStatic`<${__$Tag} class="dynamic">Content</${__$Tag}>`
62
+ * ```
63
+ *
64
+ * @example
65
+ * ```tsx
66
+ * // ❌ Incorrect usage - won't compile to static templates
67
+ * const badTag = 'div';
68
+ * return <badTag>Content</badTag>; // This won't work with jsx-lit
69
+ *
70
+ * // ❌ Incorrect usage - missing .tag property
71
+ * const BadTag = toTag('div');
72
+ * return <BadTag>Content</BadTag>; // Won't compile correctly
73
+ *
74
+ * // ✅ Correct usage - with .tag property
75
+ * const GoodTag = toTag('div');
76
+ * return <GoodTag.tag>Content</GoodTag.tag>; // Compiles to static templates
77
+ * ```
78
+ *
79
+ * @param tag - The HTML tag name (standard HTML elements or custom element names)
80
+ * @returns An object with a `tag` property containing the tag name, designed for use with jsx-lit's Component syntax
81
+ */
82
+ export const toTag = (tag) => {
83
+ return { tag };
84
+ };
85
+ //# sourceMappingURL=type-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-helpers.js","sourceRoot":"","sources":["../../src/runtime/type-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CACpB,OAAU,EACyC,EAAE;IACrD,cAAc,CAAC,GAAG,EAAE;QACnB,IAAI,UAAU,IAAI,OAAO,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,UAAU;YAClE,OAAO,CAAC,QAAQ,EAAE,CAAC;aACf,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC;YAC5C,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,OAAc,CAAC;AAC/B,CAAC,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CACpB,GAAM,EACQ,EAAE;IAChB,OAAO,EAAE,GAAG,EAAS,CAAC;AACvB,CAAC,CAAC"}