jsx-dom-runtime
Advanced tools
Comparing version 0.25.0 to 0.26.0
@@ -116,8 +116,7 @@ import { declarePreset } from '@babel/helper-plugin-utils'; | ||
attrs.push( | ||
attrs.splice(index, 0, | ||
t.jSXAttribute( | ||
t.jSXIdentifier('href'), | ||
t.stringLiteral(attr.value.value), | ||
), | ||
); | ||
)); | ||
} | ||
@@ -124,0 +123,0 @@ |
@@ -44,3 +44,3 @@ /// <reference lib="dom" /> | ||
export interface FunctionComponent<P = {}, T extends JSX.Element = JSX.Element> { | ||
(props: PropsWithChildren<P>): T | null | string | ||
(props: PropsWithChildren<P>): T | null | ||
} | ||
@@ -464,3 +464,2 @@ export { FunctionComponent as FC }; | ||
| 'treeitem' | ||
| (string & {}); | ||
@@ -592,2 +591,26 @@ export interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> { | ||
type HTMLInputTypeAttribute = | ||
| 'button' | ||
| 'checkbox' | ||
| 'color' | ||
| 'date' | ||
| 'datetime-local' | ||
| 'email' | ||
| 'file' | ||
| 'hidden' | ||
| 'image' | ||
| 'month' | ||
| 'number' | ||
| 'password' | ||
| 'radio' | ||
| 'range' | ||
| 'reset' | ||
| 'search' | ||
| 'submit' | ||
| 'tel' | ||
| 'text' | ||
| 'time' | ||
| 'url' | ||
| 'week' | ||
export interface AnchorHTMLAttributes extends HTMLAttributes<HTMLAnchorElement> { | ||
@@ -794,3 +817,3 @@ download?: any | ||
step?: number | string | ||
type?: string | ||
type?: HTMLInputTypeAttribute | ||
value?: string | readonly string[] | number | ||
@@ -1077,3 +1100,3 @@ width?: number | string | ||
namespace JSX { | ||
type Element = HTMLElement | ||
type Element = HTMLElement | DocumentFragment | Text | Node | SVGElement | ||
type ElementType<P = any> = | ||
@@ -1080,0 +1103,0 @@ | { |
{ | ||
"name": "jsx-dom-runtime", | ||
"version": "0.25.0", | ||
"version": "0.26.0", | ||
"description": "A tiny in 500 bytes library to JSX syntax templates for DOM", | ||
@@ -11,2 +11,3 @@ "type": "module", | ||
".": { | ||
"types": "./index.d.ts", | ||
"require": "./jsx-runtime/index.cjs", | ||
@@ -17,2 +18,3 @@ "import": "./jsx-runtime/index.js", | ||
"./jsx-runtime": { | ||
"types": "./index.d.ts", | ||
"require": "./jsx-runtime/index.cjs", | ||
@@ -23,2 +25,3 @@ "import": "./jsx-runtime/index.js", | ||
"./jsx-dev-runtime": { | ||
"types": "./index.d.ts", | ||
"require": "./jsx-runtime/index.cjs", | ||
@@ -56,3 +59,3 @@ "import": "./jsx-runtime/index.js", | ||
"@size-limit/preset-small-lib": "^8.2.4", | ||
"@testing-library/dom": "^8.20.0", | ||
"@testing-library/dom": "^9.0.0", | ||
"@testing-library/jest-dom": "^5.16.5", | ||
@@ -59,0 +62,0 @@ "@types/testing-library__jest-dom": "^5.14.5", |
@@ -18,2 +18,4 @@ # jsx-dom-runtime | ||
Add preset to your [`.babelrc`](https://babeljs.io/docs/en/config-files) file. | ||
**.babelrc** | ||
@@ -176,4 +178,6 @@ | ||
Add support of the properties to DOM Element object. | ||
### properties | ||
Add support of the DOM Element object properties. By default supported [`innerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML), [`muted`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/muted), `value`. | ||
```js | ||
@@ -198,4 +202,44 @@ import { properties } from 'jsx-dom-runtime'; | ||
## TypeScript Support | ||
Add compile options to your [`tsconfig.json`](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) file. | ||
**tsconfig.json** | ||
```json | ||
{ | ||
"compilerOptions": { | ||
"jsx": "react-jsx", | ||
"jsxImportSource": "jsx-dom-runtime", | ||
"moduleResolution": "nodenext", | ||
"lib": [ | ||
"DOM" | ||
] | ||
} | ||
} | ||
``` | ||
Example: | ||
```ts | ||
import type { FC } from 'jsx-dom-runtime'; | ||
interface Props { | ||
text: string; | ||
} | ||
const App: FC<Props> = ({ text }) => { | ||
return ( | ||
<div class="card"> | ||
<div class="text">{text}</div> | ||
</div> | ||
); | ||
}; | ||
document.body.append(<App text="Hello!" />); | ||
``` | ||
Read more: [TypeScript JSX](https://www.typescriptlang.org/docs/handbook/jsx.html) | ||
## License | ||
[MIT](./LICENSE) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62117
1724
243