| @@ -1,35 +1,35 | |||||
| 1 | { | 
             | 
        1 | { | |
| 2 | "name": "@implab/djx", | 
             | 
        2 | "name": "@implab/djx", | |
| 3 | "version": "0.0.1-dev", | 
             | 
        3 | "version": "0.0.1-dev", | |
| 4 | "description": "Supports using dojo version 1 with typescript and .tsx files", | 
             | 
        4 | "description": "Supports using dojo version 1 with typescript and .tsx files", | |
| 5 | "keywords": [ | 
             | 
        5 | "keywords": [ | |
| 6 | "dojo", | 
             | 
        6 | "dojo", | |
| 7 | "tsx", | 
             | 
        7 | "tsx", | |
| 8 | "typescript", | 
             | 
        8 | "typescript", | |
| 9 | "widgets" | 
             | 
        9 | "widgets" | |
| 10 | ], | 
             | 
        10 | ], | |
| 11 | "author": "Implab team", | 
             | 
        11 | "author": "Implab team", | |
| 12 | "license": "BSD-2-Clause", | 
             | 
        12 | "license": "BSD-2-Clause", | |
| 13 | "repository": "https://code.implab.org/implab/implabjs-djx", | 
             | 
        13 | "repository": "https://code.implab.org/implab/implabjs-djx", | |
| 14 | "publishConfig": { | 
             | 
        14 | "publishConfig": { | |
| 15 | "access": "public" | 
             | 
        15 | "access": "public" | |
| 16 | }, | 
             | 
        16 | }, | |
| 17 | "peerDependencies": { | 
             | 
        17 | "peerDependencies": { | |
| 18 | "@implab/core-amd": "^1.4.0", | 
             | 
        18 | "@implab/core-amd": "^1.4.0", | |
| 19 | "dojo": "^1.10.0" | 
             | 
        19 | "dojo": "^1.10.0" | |
| 20 | }, | 
             | 
        20 | }, | |
| 21 | "devDependencies": { | 
             | 
        21 | "devDependencies": { | |
| 22 | "@implab/core-amd": "^1.4.0", | 
             | 
        22 | "@implab/core-amd": "^1.4.0", | |
| 23 | "@types/chai": "4.1.3", | 
             | 
        23 | "@types/chai": "4.1.3", | |
| 24 | "@types/requirejs": "2.1.31", | 
             | 
        24 | "@types/requirejs": "2.1.31", | |
| 25 | "@types/yaml": "1.2.0", | 
             | 
        25 | "@types/yaml": "1.2.0", | |
| 26 | "chai": "4.2.0", | 
             | 
        26 | "chai": "4.2.0", | |
| 27 | "dojo": "1.16.0", | 
             | 
        27 | "dojo": "1.16.0", | |
| 28 | "dojo-typings": "~1.11.9", | 
             | 
        28 | "dojo-typings": "~1.11.9", | |
| 29 | "eslint": "6.8.0", | 
             | 
        29 | "eslint": "6.8.0", | |
| 30 | "requirejs": "2.3.6", | 
             | 
        30 | "requirejs": "2.3.6", | |
| 31 | "tslint": "^6.1.3", | 
             | 
        31 | "tslint": "^6.1.3", | |
| 32 | 
            
                    "typescript": "4. | 
        
             | 
        32 | "typescript": "4.2.4", | |
| 33 | "yaml": "~1.7.2" | 
             | 
        33 | "yaml": "~1.7.2" | |
| 34 | } | 
             | 
        34 | } | |
| 35 | } | 
             | 
        35 | } | |
| @@ -1,29 +1,32 | |||||
| 1 | import { argumentNotNull } from "@implab/core-amd/safe"; | 
             | 
        1 | import { argumentNotNull } from "@implab/core-amd/safe"; | |
| 2 | import { RenditionBase } from "./RenditionBase"; | 
             | 
        2 | import { RenditionBase } from "./RenditionBase"; | |
| 3 | 
             | 
        3 | |||
| 4 | export class FunctionRendition extends RenditionBase<Node> { | 
             | 
        4 | export class FunctionRendition extends RenditionBase<Node> { | |
| 5 | 
            
                private _component: ( | 
        
             | 
        5 | private _component: (...args: any[]) => any; | |
| 6 | 
             | 
        6 | |||
| 7 | private _node: Node | undefined; | 
             | 
        7 | private _node: Node | undefined; | |
| 8 | 
             | 
        8 | |||
| 9 | 
            
                constructor(component: ( | 
        
             | 
        9 | constructor(component: (...args: any[]) => any) { | |
| 10 | super(); | 
             | 
        10 | super(); | |
| 11 | argumentNotNull(component, "component"); | 
             | 
        11 | argumentNotNull(component, "component"); | |
| 12 | 
             | 
        12 | |||
| 13 | this._component = component; | 
             | 
        13 | this._component = component; | |
| 14 | } | 
             | 
        14 | } | |
| 15 | 
             | 
        15 | |||
| 16 | _create(attrs: object, children: any[]) { | 
             | 
        16 | protected _create(attrs: object, children: any[]) { | |
| 17 | const _attrs: any = attrs || {}; | 
             | 
        17 | const _attrs: any = attrs || {}; | |
| 18 | 
            
                     | 
        
             | 
        18 | const _children = children.map(x => this.getItemDom(x)); | |
| 19 | 
             | 
        19 | this._node = this.getItemDom( | ||
| 20 | this._node = this.getItemDom(this._component.call(null, _attrs)); | 
             | 
        20 | this._component.length === 2 ? | |
| 
             | 
        21 | this._component.call(null, { ..._attrs }, _children) : | |||
| 
             | 
        22 | this._component.call(null, { ..._attrs, children: _children }) | |||
| 
             | 
        23 | ); | |||
| 21 | } | 
             | 
        24 | } | |
| 22 | 
             | 
        25 | |||
| 23 | _getDomNode() { | 
             | 
        26 | protected _getDomNode() { | |
| 24 | if (!this._node) | 
             | 
        27 | if (!this._node) | |
| 25 | throw new Error("The instance of the widget isn't created"); | 
             | 
        28 | throw new Error("The instance of the widget isn't created"); | |
| 26 | return this._node; | 
             | 
        29 | return this._node; | |
| 27 | } | 
             | 
        30 | } | |
| 28 | 
             | 
        31 | |||
| 29 | } | 
             | 
        32 | } | |
        
        General Comments 0
    
    
  
  
                      You need to be logged in to leave comments.
                      Login now
                    
                