Skip to content

Commit

Permalink
Try updating typing w/ bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
ClassicOldSong committed Apr 4, 2020
1 parent d49d9e6 commit e9896af
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 20 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ Data on ef.js components are not always that easy to access, so since v0.10.4, a

ef.js can handle custom components in templates since v0.10.4. [Demo on writing logic within ef template using custom component](https://codepen.io/ClassicOldSong/pen/zYGXLyy)

### Scoping
### Scope

Scoping is not done in templates. You can write your template as normal, using whatever tag name you desire for your custom component, like:

Expand All @@ -242,7 +242,7 @@ const scope = {MyComponent, MyOtherComponent}
const app = new App(null, scope)
```

If `scope` is not given at initializing the component, ef will treat these custom tags as normal HTML tags.
If `scope` is not given when initializing the component, ef will treat these custom tags as normal HTML tags.

Note that if you reference a custom component, you'll get the component instance instead of the component's DOM object:

Expand Down Expand Up @@ -297,7 +297,7 @@ Note that modifier keys are no longer able to present on custom emitted events,

### Automatic Two Way Binding

Just like what ef requires HTML elements to do to get custom two way binding, a `value` or `checked` property should present on a custom component, together with an `input` or `keyup` or `change` event been emitted when value has been changed. When binding `checked`, only `change` event shoule be emitted.
Just like what ef requires HTML elements to do to get custom two way binding, a `value` or `checked` property should present on a custom component, together with an `input` or `keyup` or `change` event been emitted when value has been changed. When binding `checked`, only `change` event should be emitted.

```efml
App.eft
Expand Down Expand Up @@ -400,7 +400,9 @@ var output = buble.transform( input, {
## Typing Support
ef.js now has partial typing support using [JSDoc](https://jsdoc.app/), which probably compatibles with TypeScript.
**`HELP WANTED`**
ef.js now has partial experimental typing support using TypeScript flavored [JSDoc](https://jsdoc.app/), which should be compatible with TypeScript. See [ef-core](https://github.com/TheNeuronProject/ef-core/blob/master/src/ef-core.js) and [ef.js](https://github.com/TheNeuronProject/ef.js/blob/master/src/ef.js).
## Run a test
``` bash
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src/ef.js'
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "ef.js",
"version": "0.10.5",
"version": "0.10.6",
"description": "(maybe) An elegant HTML template engine & basic framework",
"main": "dist/ef.min.js",
"module": "src/ef.js",
"type": "./index.d.ts",
"scripts": {
"dev": "rollup -c ./config/rollup.dev.js -w",
"build": "rollup -c ./config/rollup.prod.js",
Expand Down Expand Up @@ -45,7 +46,7 @@
"rollup-plugin-uglify": "^6.0.4"
},
"dependencies": {
"ef-core": "^0.10.5",
"eft-parser": "^0.10.1"
"ef-core": "^0.10.6",
"eft-parser": "^0.10.6"
}
}
19 changes: 15 additions & 4 deletions src/ef.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,25 @@ import {
let parser = parseEft

/**
* @typedef {import('ef-core/src/lib/renderer.js').EFAST} EFAST
* @typedef {import('ef-core/src/ef-core.js').EFComponent} EFComponent
* @typedef {import('ef-core/src/ef-core.js').EFMountOption} EFMountOption
* @typedef {import('ef-core/src/ef-core.js').EFMountConfig} EFMountConfig
* @typedef {import('ef-core/src/ef-core.js').EFAST} EFAST
* @typedef {import('ef-core/src/ef-core.js').EFBaseClass} EFBaseClass
* @typedef {import('ef-core/src/ef-core.js').EFEventHandlerArg} EFEventHandlerArg
* @typedef {import('ef-core/src/ef-core.js').EFEventHandlerMethod} EFEventHandlerMethod
* @typedef {import('ef-core/src/ef-core.js').EFSubscriberHandlerArg} EFSubscriberHandlerArg
* @typedef {import('ef-core/src/ef-core.js').EFSubscriberHandlerMethod} EFSubscriberHandlerMethod
* @typedef {import('ef-core/src/ef-core.js').EFTemplateScope} EFTemplateScope
* @typedef {import('ef-core/src/ef-core.js').Fragment} Fragment
* @typedef {import('ef-core/src/ef-core.js').EFNodeWrapper} EFNodeWrapper
* @typedef {import('ef-core/src/ef-core.js').EFTextFragment} EFTextFragment
* @typedef {import('ef-core/src/ef-core.js').EFEventOptions} EFEventOptions
*/

// eslint-disable-next-line valid-jsdoc
/**
* Return a brand new class for the new component
* @param {string|EFAST} value - Template or AST for the component
* @returns {EFComponent} - Created component class from AST
*/
const create = (value) => {
const valType = typeOf(value)
Expand All @@ -51,10 +62,10 @@ const setParser = (newParser) => {
parser = newParser
}

// eslint-disable-next-line valid-jsdoc
/**
* Tagged template to quickly create an inline ef component class
* @param {...*} args - String literal
* @returns {EFComponent} - Created ef component class
*/
const t = (...args) => create(mixStr(...args))

Expand Down
4 changes: 2 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var template = '\n' +
' >input\n' +
' #type = radio\n' +
' #name = testradio\n' +
' %checked = {{testRadio1}}\n' +
' %checked = {{testRadio1 = true}}\n' +
' .checked: {{testRadio1}}\n' +
' >input\n' +
' #type = radio\n' +
Expand All @@ -54,7 +54,7 @@ var template = '\n' +
' >input\n' +
' #type = checkbox\n' +
' %checked = {{testCheck}}\n' +
' .checked: {{testCheck}}\n' +
' .checked: {{testCheck = true}}\n' +
' >br\n' +
' .Input style here: \n' +
' >br\n' +
Expand Down

0 comments on commit e9896af

Please sign in to comment.