·
Jumper package ·Description
Last Version: 0.1.13
Modules:
- jumper_react (Base module)
- Console
- Memory (Browser Storage)
- Browser
- jumper_react/appState (Module for application state managment)
- jumper_react/appStateExtended (Module for application state managment - extended with developers tools only recommend during development)
- jumper_react/components (Components tools)
- parseHTMLComponent
- parseHTMLReactComponent
- HTMLReactParser (OOP of parseHTMLReactComponent, comming soon)
- Widget
- jumper_react/cryptography (Crypto algorythms module)
- basicHashString
- cyrb53
- md5
- jumper_react/dataProcessing (Data tools module)
- jumper_react/languageDescriptor (Language translation module)
- jumper_react/models (Models module)
- jumper_react/service (Services and network tools module) *
- jumper_react/performance (Performance tools module)
- jumper_react/strUtils (String utilities module)
- format
- jumper_react/langUtils (Javascript language utilities module)
- jumper_react/experimental (Experimental module)
Important classes
ActionsStack
- component : React.Component - target Component to initialize
- inArr : Array<ActionOperation | ...> - operations namespaces
- options={stackSize:20, debug:false, loadResumeable:true} : any - options to configure
in component file:
import React, { Component } from 'react';
import { ActionsStack } from 'jumper_react/appState';
export default class SampleComponent extends Component {
constructor(props) {
super(props);
let self = this;
this.state = {
currentMenu:""
}
this.actions = new ActionsStack(this, [
SampleAction1,
SampleAction2
], { loadResumeable:false });
let lastData = this.actions.restoreComponentProp("exampleData");
this.actions.addEventListener("beforeunload", function() {
this.saveComponentProp("exampleData");
});
}
componentDidMount() {
this.actions.restoreStacksSessions();
}
render() {
return (<>
<h1>Sample...</h1>
</>);
}
}
in operations/actions file:
import { ActionOperation, ActionResumeOperation, TemponaryActionOperation } from 'jumper_react/appState';
export class SampleTemponaryAction1 extends TemponaryActionOperation {
}
export class SampleAction1 extends ActionOperation {
onStore(component, inputData) {
component.currDocument.dimensionX += inputData.count;
return { };
}
}
export class SampleAction2 extends ActionOperation {
onStore(component, inputData) {
component.currDocument.dimensionY += inputData.count;
return { };
}
}
Important functions
parseHTMLReactComponent
- htmlStr: string - input with sample HTML code to parse
- allowedTags: Array = [] - Array of allowed or dissalowed tags (string tag name) to parse
- allowed: boolean - if true all tag names given in argument 2 will be parsed, otherwise ignored. https://codesandbox.io/s/jumper-module-react-simple-parser-3b8c9
import React from "react";
import "./styles.css";
import { parseHTMLReactComponent } from "jumper_react/components";
export default function App() {
return parseHTMLReactComponent(
'<h1><i>Hello world!</i></h1> Really? <span id="me" style="color:green; background-color:#eee; -webkit-transform:translate(-100px,200px)">Yolo</span> <div><h2>I love react!</h2></div> <input type="text"/>',
["h1"],
false
);
}
parseHTMLComponent
- htmlStr: string - input with sample HTML code to parse
- allowedTags: Array = [] - Array of allowed or dissalowed tags (string tag name) to parse
- allowed: boolean - if true all tag names given in argument 2 will be parsed, otherwise ignored.
import { parseHTMLComponent } from "jumper_react/components";
let container = document.createElement("div"), childs = parseHTMLComponent(
'<h1><i>Hello world!</i></h1> Really? <span id="me" style="color:green; background-color:#eee; -webkit-transform:translate(-100px,200px)">Yolo</span> <div><h2>I love react!</h2></div> <input type="text"/>',
["h1"],
false
);
for(let el of childs) container.appendChild(el);
console.log(container);
document.body.innerHTML = "";
document.body.appendChild(container);
format
- targetStr: string - input with sample text to parse
- initialObj: any - can be an Array or Object.prototype. Contains a elements to replace.
Types:
- %s - String
- %f - float
- %a - any
- %ad - auto detect
- %d - decimal
- %n - science notation
- %oct - octal number
- %hex - hex number
- %bin - binary number
- %f{number} - floating with rounding (experimental)
- %b - boolean
- %bt - boolean translated (experimental)
console.log(format("Hello %s exacly! Wow, we make it %d times!", ["World", 14]));
console.log(format("Thats really simple with %s[labelsWord], you can use it in any %s[situationWord]!", {labelsWord:"labels", situationWord:"situation"}));