DOCUMENTATION
Quick-React Library Classes
- QuickReactElement
Quick-React elements are an object type where each element has an assigned type, name, and a set of unique key/value attributes stored as a JavaScript Map data structure.
- QuickReact
The QuickReact class methods perform all the processing of parsing Quick-React markup into an n-ary tree, which can then be output as React folder and file components for quick React project setup
Functions
- output_index(useBootstrap, quickReact, NaryTree, QuickReactElement, NaryNode) ⇒
string Output the index.js file as index_qr.js for this React project
- output_app(useBootstrap, quickReact, NaryTree, QuickReactElement, NaryNode) ⇒
string Output the App.js file as App_qr.js for this React project
- output_component(useBootstrap, quickReact, NaryTree, QuickReactElement, NaryNode) ⇒
string Output individual component files for the React project
QuickReactElement
Quick-React elements are an object type where each element has an assigned type, name, and a
set of unique key/value attributes stored as a JavaScript Map data structure.
Kind: global class
- QuickReactElement
- new QuickReactElement(name, type, attributes)
- .type() ⇒
string - .type(typeValue)
- .subtype() ⇒
string - .subtype(subtypeValue)
- .name() ⇒
string - .name(nameValue)
- .hasAttribute(key) ⇒
boolean - .safeHasAttribute(obj) ⇒
boolean - .getAttributeSize() ⇒
number - .getAttribute(key) ⇒
string - .deleteAttribute(key) ⇒
boolean - .setAttribute({key:value}) ⇒
Object - .getAllAttributes() ⇒
Array.<array> - .toString() ⇒
string
new QuickReactElement(name, type, attributes)
The QuickReactElement class object constructor method
| Param | Type | Description |
|---|---|---|
| name | string | a name for this element |
| type | string | a type to categorize this element |
| attributes | Object | object - a shallow object containing [key, value] pairs |
quickReactElement.type() ⇒ string
Get this element's designated type.
Kind: instance method of QuickReactElement
Returns: - this element's designated type
quickReactElement.type(typeValue)
Set this element's type value
Kind: instance method of QuickReactElement
| Param | Type | Description |
|---|---|---|
| typeValue | string | string - the element's type value |
quickReactElement.subtype() ⇒ string
Get this element's subtype value
Kind: instance method of QuickReactElement
Returns: string - this element's designated subtype
quickReactElement.subtype(subtypeValue)
Set this element's subtype value
Kind: instance method of QuickReactElement
| Param | Type | Description |
|---|---|---|
| subtypeValue | string | string - the element's subtype value |
quickReactElement.name() ⇒ string
Get the element's name.
Kind: instance method of QuickReactElement
Returns: string - this element's name
quickReactElement.name(nameValue)
Set this element's name.
Kind: instance method of QuickReactElement
| Param | Type | Description |
|---|---|---|
| nameValue | string | string - the element's name |
quickReactElement.hasAttribute(key) ⇒ boolean
Check to see if the Quick-React element has a specific attribute set
Kind: instance method of QuickReactElement
Returns: boolean - does this Quick-React element have this attribute?
| Param | Type | Description |
|---|---|---|
| key | string | string - check to see whether this element has an attribute with the specified property key |
quickReactElement.safeHasAttribute(obj) ⇒ boolean
Safely Check to see if the Quick-React element has a specific attribute key set to a specific value
This method does not return undefined for undefined properties, it always returns a boolean true or false value
Kind: instance method of QuickReactElement
Returns: boolean - does this Quick-React element have this attribute key and value?
| Param | Type | Description |
|---|---|---|
| obj | obj | object - check to see whether this element has an attribute with the specified property key and value, submitted as a shallow object |
quickReactElement.getAttributeSize() ⇒ number
Returns the number of attributes this element has
Kind: instance method of QuickReactElement
Returns: number - the number of attributes this element has
quickReactElement.getAttribute(key) ⇒ string
Get an attribute's value specified by the key parameter
Kind: instance method of QuickReactElement
Returns: string - value string - the value associated with the specified key
| Param | Type | Description |
|---|---|---|
| key | string | string - the string representing the attribute property to search for |
quickReactElement.deleteAttribute(key) ⇒ boolean
Delete an attribute specified by the key parameter
Kind: instance method of QuickReactElement
Returns: boolean - true or false return value depending on whether the delete request was successfully processed
| Param | Type | Description |
|---|---|---|
| key | string | string - the string representing the attribute property to delete |
quickReactElement.setAttribute({key:value}) ⇒ Object
Set a key value pair as an attribute of this element
Kind: instance method of QuickReactElement
Returns: Object - map object - attribute map object is returned
| Param | Type | Description |
|---|---|---|
| {key:value} | Object | object to be set as a new attribute of this element or to replace an existing attribute with the same key |
quickReactElement.getAllAttributes() ⇒ Array.<array>
Returns all key/value pairs as an array using the spread operator
Kind: instance method of QuickReactElement
Returns: Array.<array> - returns all key/value pairs as an array using the spread operator
quickReactElement.toString() ⇒ string
Returns the name of this element
Kind: instance method of QuickReactElement
Returns: string - returns the name of this element
QuickReact
The QuickReact class methods perform all the processing of parsing Quick-React markup into an
n-ary tree, which can then be output as React folder and file components for quick React project setup
Kind: global class
new QuickReact()
Instantiates a QuickReact object and an empty n-ary tree as a JavaScript object
quickReact.tree ⇒ Object
Retrieve a reference to this NaryTree
Kind: instance property of QuickReact
Returns: Object - NaryTree object associated with this QuickReact object
quickReact.parseMarkup(code) ⇒ Object
The parseMarkup method takes submitted Quick-React JSX markup code and produces an n-Ary tree structure representing the components, their nested
structure, and each element's attributes.
Kind: instance method of QuickReact
Returns: Object - returns a populated NaryTree object representing the lexed and parsed output of the supplied Quick-React markup code
| Param | Type | Description |
|---|---|---|
| code | string | string - Quick-Start markup code in text JSX format |
quickReact._printRef(code, index, length) ⇒ string
This function prints a strings from the current code index to a specified length to provide the developer/user
with a reference as to where their code may have a syntax error.
Kind: instance method of QuickReact
Returns: string - message - a message regarding the error or problem found in the supplied code
| Param | Type | Description |
|---|---|---|
| code | string | the Quick-React markup code |
| index | number | the character position in the code where an error was found |
| length | number | the length is characters of surrounding context text to display in the response message |
quickReact._multiplier(attribute) ⇒ number
The _multiplier function checks the passed attribute and determines whether a multiplier
expression is used in the attribute, denoted by an '*', to request a repeat of the item a specified number of times.
Multiplier values can be a single integer digit or two integer digits long.
Kind: instance method of QuickReact
Returns: number - returns the multiplier value found in the attribute or 1 as a default
| Param | Type | Description |
|---|---|---|
| attribute | string | string - the attribute key to search for |
quickReact._findMultiplier(quickReactElement, searchAttribute, specifiedNameArray, defaultName, matchIndex) ⇒ number
This is the same as the _multiplier function except that it looks through all of the component's attributes for
the first matching attribute, compared via key name, and then checks to see if a multiplier expression is used.
Kind: instance method of QuickReact
Returns: number - returns the multiplier value found or zero if the attribute wasn't found, or one if the attribute was found but no multiplier was specified
| Param | Type | Description |
|---|---|---|
| quickReactElement | Object | component - a Quick-React object element to search |
| searchAttribute | string | the attribute to search for in the element |
| specifiedNameArray | Array.<array> | an array used to hold values of requested field/variable names in the markup |
| defaultName | string | a default name to use for a field/variable if specified names are used in the markup |
| matchIndex | number | add support for use of an attribute more than one time in a single component |
quickReact.generateProjectFiles(userID, projectID, NaryTree) ⇒ undefined
A function to generate React directories and files based on the n-Ary tree representation of the Quick-React markup
Kind: instance method of QuickReact
Returns: undefined - Stores the directories and files for the project and generates a zip file with all of the content archived into a single downloadable document.
| Param | Type | Description |
|---|---|---|
| userID | string | The registered Quick-React user's unique id, as assigned by MongoDB. |
| projectID | string | The registered Quick-React user's unique project ID, as assigned by MongoDB |
| NaryTree | Object | tree - The tree of parsed values representing the structure of this Quick-React project |
output_index(useBootstrap, quickReact, NaryTree, QuickReactElement, NaryNode) ⇒ string
Output the index.js file as index_qr.js for this React project
Kind: global function
Returns: string - Outputs the code for the content of the index.js file as index_qr.js for this React project
| Param | Type | Description |
|---|---|---|
| useBootstrap | boolean | boolean - boolean flag indicating whether react-bootstrap should be used |
| quickReact | Object | object - the instance of the Quick-React project object |
| NaryTree | Object | tree object - the parse tree of object and values for this project |
| QuickReactElement | Object | object - a specific quickReactElement |
| NaryNode | Object | node object - a specific node in the project tree |
output_app(useBootstrap, quickReact, NaryTree, QuickReactElement, NaryNode) ⇒ string
Output the App.js file as App_qr.js for this React project
Kind: global function
Returns: string - - Outputs the contents of the App.js file as App_qr.js for this React project
| Param | Type | Description |
|---|---|---|
| useBootstrap | boolean | boolean - boolean flag indicating whether react-bootstrap should be used |
| quickReact | Object | object - the instance of the Quick-React project object |
| NaryTree | Object | tree object - the parse tree of object and values for this project |
| QuickReactElement | Object | object - a specific quickReactElement |
| NaryNode | Object | node object - a specific node in the project tree |
output_component(useBootstrap, quickReact, NaryTree, QuickReactElement, NaryNode) ⇒ string
Output individual component files for the React project
Kind: global function
Returns: strings - Outputs the content of a specific component file for this React project
| Param | Type | Description |
|---|---|---|
| useBootstrap | boolean | boolean - boolean flag indicating whether react-bootstrap should be used |
| quickReact | Object | object - the instance of the Quick-React project object |
| NaryTree | Object | tree object - the parse tree of object and values for this project |
| QuickReactElement | Object | object - a specific quickReactElement |
| NaryNode | Object | node object - a specific node in the project tree |

