-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
76 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const { _jsx } = require('./jsx') | ||
|
||
/** | ||
* Returns the transpiled JSX code into `h` pragma calls. | ||
* @param {string} string The code to transform. | ||
* @param {!_alaJsx.Config} [config] Options for the program. | ||
* @param {(boolean|string)} [config.quoteProps=false] Whether to surround property names with quotes. When the `dom` string is passed, it will only quote props for invoking html components, i.e. those that start with a lowercase letter (this is required for _Closure Compiler_ when not providing externs to elements). Default `false`. | ||
* @param {boolean} [config.prop2class=false] If a property name starts with a capital letter, the `className` of the _VNode_ will be updated. Default `false`. | ||
* @param {!Array<string>|!Object} [config.classNames] The list of properties to put into the `className` property. | ||
* @param {!Object<string, string>} [config.renameMap] How to rename classes (only applies to `prop2class` and `classNames`). | ||
* @param {!Object<string, string>} [config.styles] Rename these properties into styles, e.g., `<el border-top="1px">` will become `<el style="border-top:1px">`. The keys must be property names, and the values are either booleans, or a string that should be used for renaming of the CSS property, such as `{ borderTop: 'border-top' }`. Check out [`@a-la/styles`](https://github.com/a-la/styles) that provides such a map. | ||
* @param {(warning: string) => ?} [config.warn] The function to receive warnings, e.g., when destructuring of properties is used on dom elements (for Closure Compiler). | ||
* @return {string} | ||
*/ | ||
function jsx(string, config) { | ||
return _jsx(string, config) | ||
} | ||
|
||
module.exports = jsx | ||
|
||
/* typal types/index.xml namespace */ | ||
/** | ||
* @typedef {_alaJsx.Config} Config Options for the program. | ||
* @typedef {Object} _alaJsx.Config Options for the program. | ||
* @prop {(boolean|string)} [quoteProps=false] Whether to surround property names with quotes. When the `dom` string is passed, it will only quote props for invoking html components, i.e. those that start with a lowercase letter (this is required for _Closure Compiler_ when not providing externs to elements). Default `false`. | ||
* @prop {boolean} [prop2class=false] If a property name starts with a capital letter, the `className` of the _VNode_ will be updated. Default `false`. | ||
* @prop {!Array<string>|!Object} [classNames] The list of properties to put into the `className` property. | ||
* @prop {!Object<string, string>} [renameMap] How to rename classes (only applies to `prop2class` and `classNames`). | ||
* @prop {!Object<string, string>} [styles] Rename these properties into styles, e.g., `<el border-top="1px">` will become `<el style="border-top:1px">`. The keys must be property names, and the values are either booleans, or a string that should be used for renaming of the CSS property, such as `{ borderTop: 'border-top' }`. Check out [`@a-la/styles`](https://github.com/a-la/styles) that provides such a map. | ||
* @prop {(warning: string) => ?} [warn] The function to receive warnings, e.g., when destructuring of properties is used on dom elements (for Closure Compiler). | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const { _jsx } = require('./jsx') | ||
|
||
/** | ||
* @methodType {_alaJsx.jsx} | ||
*/ | ||
function jsx(string, config) { | ||
return _jsx(string, config) | ||
} | ||
|
||
module.exports = jsx | ||
|
||
/* typal types/index.xml namespace */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<types ns="_alaJsx"> | ||
<method name="jsx" return="string"> | ||
<arg string name="string">The code to transform.</arg> | ||
<arg type="_alaJsx.Config" name="config">Configuration object.</arg> | ||
<arg opt type="!_alaJsx.Config" name="config">Configuration object.</arg> | ||
Returns the transpiled JSX code into `h` pragma calls. | ||
</method> | ||
</types> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
/** | ||
* @fileoverview | ||
* @externs | ||
*/ | ||
|
||
/* typal types/index.xml */ | ||
/** @const */ | ||
var _alaJsx = {} | ||
/** | ||
* Options for the program. | ||
* @typedef {{ quoteProps: (((boolean|string))|undefined), warn: ((function(...string))|undefined), prop2class: (boolean|undefined), classNames: ((!Array<string>|!Object)|undefined), renameMap: ((!Object<string, string>)|undefined) }} | ||
* @typedef {{ quoteProps: (((boolean|string))|undefined), prop2class: (boolean|undefined), classNames: ((!Array<string>|!Object)|undefined), renameMap: ((!Object<string, string>)|undefined), styles: ((!Object<string, string>)|undefined), warn: ((function(string))|undefined) }} | ||
*/ | ||
_alaJsx.Config | ||
|
||
/* typal types/api.xml */ | ||
/** | ||
* Returns the transpiled JSX code into `h` pragma calls. | ||
* @typedef {function(string,!_alaJsx.Config=): string} | ||
*/ | ||
_alaJsx.jsx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters