armstrong-react
Advanced tools
Comparing version
@@ -1,62 +0,73 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var React = require("react"); | ||
var _ = require("underscore"); | ||
var JSXToString = require("react-element-to-jsx-string"); | ||
var ReactServerDOM = require("react-dom/server"); | ||
var Sample = /** @class */ (function (_super) { | ||
tslib_1.__extends(Sample, _super); | ||
function Sample() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
Sample.prototype.getProps = function () { | ||
return this.getPropInfo(this.props.component.props); | ||
}; | ||
Sample.prototype.getPropInfo = function (props) { | ||
var ps = []; | ||
Object.keys(props).forEach(function (k) { | ||
var p = props[k]; | ||
var t = '(' + typeof (p) + ')'; | ||
if (t === "(object)") { | ||
t = String(p.$$typeof).replace('Symbol', ''); | ||
} | ||
if (_.isArray(p)) { | ||
if (p[0].$$typeof !== undefined) { | ||
t = String(p[0].$$typeof).replace('Symbol', '') + '[]'; | ||
} | ||
else { | ||
t = "(object[])"; | ||
} | ||
} | ||
ps.push({ name: k, type: t, value: p.toString() }); | ||
}); | ||
return ps; | ||
}; | ||
Sample.prototype.render = function () { | ||
return (React.createElement("div", { className: "element-sample" }, | ||
React.createElement("h1", null, this.props.title), | ||
React.createElement("p", null, this.props.description), | ||
React.createElement("h2", null, "RESULT"), | ||
this.props.component, | ||
React.createElement("h2", null, "PROPS"), | ||
React.createElement("table", null, | ||
React.createElement("thead", null, | ||
React.createElement("tr", null, | ||
React.createElement("th", null, "Name"), | ||
React.createElement("th", null, "Type"), | ||
React.createElement("th", null, "Value (Example)"))), | ||
React.createElement("tbody", null, this.getProps().map(function (m, i) { | ||
return React.createElement("tr", { key: "p_" + i + "_" + m.name }, | ||
React.createElement("td", null, m.name), | ||
React.createElement("td", null, m.type), | ||
React.createElement("td", null, m.value)); | ||
}))), | ||
React.createElement("h2", null, "JSX"), | ||
React.createElement("pre", null, JSXToString(this.props.component)), | ||
this.props.showHtml && React.createElement("h2", null, "HTML"), | ||
this.props.showHtml && React.createElement("pre", null, ReactServerDOM.renderToStaticMarkup(this.props.component).replace(/</g, '\r\n<').trim()))); | ||
}; | ||
return Sample; | ||
}(React.Component)); | ||
exports.Sample = Sample; | ||
// import * as React from "react"; | ||
// import * as _ from "underscore"; | ||
// import * as JSXToString from "react-element-to-jsx-string"; | ||
// import * as ReactServerDOM from "react-dom/server"; | ||
// import { Grid, Row, Col } from './../../../source/components/layout/grid'; | ||
// export interface IPropInfo { | ||
// name: string; | ||
// type: string; | ||
// value: string; | ||
// } | ||
// export interface ISampleProps extends React.Props<Sample> { | ||
// component: JSX.Element; | ||
// title: string; | ||
// description?: string; | ||
// showHtml?: boolean; | ||
// } | ||
// export class Sample extends React.Component<ISampleProps, {}> { | ||
// getProps(): IPropInfo[] { | ||
// return this.getPropInfo(this.props.component.props); | ||
// } | ||
// getPropInfo(props: any): IPropInfo[] { | ||
// let ps = []; | ||
// Object.keys(props).forEach(k => { | ||
// let p = props[k]; | ||
// let t = '(' + typeof (p) + ')'; | ||
// if (t === "(object)") { | ||
// t = String(p.$$typeof).replace('Symbol', ''); | ||
// } | ||
// if (_.isArray(p)) { | ||
// if (p[0].$$typeof !== undefined) { | ||
// t = String(p[0].$$typeof).replace('Symbol', '') + '[]'; | ||
// } else { | ||
// t = "(object[])" | ||
// } | ||
// } | ||
// ps.push({ name: k, type: t, value: p.toString() }); | ||
// }) | ||
// return ps; | ||
// } | ||
// render() { | ||
// return ( | ||
// <div className="element-sample"> | ||
// <h1>{this.props.title}</h1> | ||
// <p>{this.props.description}</p> | ||
// <h2>RESULT</h2> | ||
// {this.props.component} | ||
// <h2>PROPS</h2> | ||
// <table> | ||
// <thead> | ||
// <tr> | ||
// <th>Name</th> | ||
// <th>Type</th> | ||
// <th>Value (Example)</th> | ||
// </tr> | ||
// </thead> | ||
// <tbody> | ||
// {this.getProps().map((m, i) => | ||
// <tr key={`p_${i}_${m.name}`}> | ||
// <td>{m.name}</td> | ||
// <td>{m.type}</td> | ||
// <td>{m.value}</td> | ||
// </tr> | ||
// )} | ||
// </tbody> | ||
// </table> | ||
// <h2>JSX</h2> | ||
// <pre>{JSXToString(this.props.component)}</pre> | ||
// {this.props.showHtml && <h2>HTML</h2>} | ||
// {this.props.showHtml && <pre>{ReactServerDOM.renderToStaticMarkup(this.props.component).replace(/</g, '\r\n<').trim()}</pre>} | ||
// </div> | ||
// ) | ||
// } | ||
// } |
@@ -28,3 +28,2 @@ export { IInputValueConverter, IValueConverter } from "./components/form/formValueConverters"; | ||
export { TabControl, TabItem, ITabItemProps, ITabControlProps, ITabControlState } from "./components/navigation/tabControl"; | ||
export { Sample, ISampleProps, IPropInfo } from "./components/utility/sample"; | ||
import * as ArmstrongConfig from "./config/config"; | ||
@@ -31,0 +30,0 @@ export { ClassHelpers } from "./utilities/classNames"; |
@@ -66,4 +66,3 @@ "use strict"; | ||
// Utility | ||
var sample_1 = require("./components/utility/sample"); | ||
exports.Sample = sample_1.Sample; | ||
// export { Sample, ISampleProps, IPropInfo } from "./components/utility/sample"; | ||
var ArmstrongConfig = require("./config/config"); | ||
@@ -70,0 +69,0 @@ exports.ArmstrongConfig = ArmstrongConfig; |
{ | ||
"name": "armstrong-react", | ||
"version": "2.4.6", | ||
"version": "2.4.7", | ||
"description": "Rocketmakers Armstrong library of React components", | ||
@@ -30,3 +30,2 @@ "main": "./dist/index.js", | ||
"prop-types": "^15.6.0", | ||
"react-element-to-jsx-string": "^13.1.0", | ||
"tslib": "^1.8.1", | ||
@@ -33,0 +32,0 @@ "underscore": "^1.8.3" |
@@ -1,6 +0,6 @@ | ||
declare module "react-element-to-jsx-string" { | ||
namespace JSXToString { } | ||
// declare module "react-element-to-jsx-string" { | ||
// namespace JSXToString { } | ||
function JSXToString(element: any): string; | ||
export = JSXToString; | ||
} | ||
// function JSXToString(element: any): string; | ||
// export = JSXToString; | ||
// } |
@@ -43,3 +43,3 @@ export { IInputValueConverter, IValueConverter } from "./components/form/formValueConverters"; | ||
// Utility | ||
export { Sample, ISampleProps, IPropInfo } from "./components/utility/sample"; | ||
// export { Sample, ISampleProps, IPropInfo } from "./components/utility/sample"; | ||
@@ -46,0 +46,0 @@ import * as ArmstrongConfig from "./config/config"; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
7
-12.5%724010
-0.32%14650
-0.06%- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed