@rmwc/base
Advanced tools
Comparing version 1.10.1-alpha.0 to 2.0.0-alpha.0
{ | ||
"name": "@rmwc/base", | ||
"version": "1.10.1-alpha.0", | ||
"version": "2.0.0-alpha.0", | ||
"description": "RMWC base module", | ||
@@ -23,3 +23,3 @@ "main": "index.js", | ||
}, | ||
"homepage": "https://github.com/jamesmfriedman/rmwc/tree/master/src/Base#readme", | ||
"homepage": "https://github.com/jamesmfriedman/rmwc/tree/master/src/base#readme", | ||
"peerDependencies": { | ||
@@ -26,0 +26,0 @@ "react": "^15.x.x || ^16.x.x", |
@@ -8,3 +8,3 @@ 'use strict'; | ||
exports.default = function () { | ||
if (global.window) { | ||
if (global['window']) { | ||
var _require = require('hyperform'), | ||
@@ -21,6 +21,6 @@ ValidityState = _require.ValidityState; | ||
Object.defineProperty(global.HTMLInputElement.prototype, 'validity', defineValidity); | ||
Object.defineProperty(global.HTMLTextAreaElement.prototype, 'validity', defineValidity); | ||
Object.defineProperty(global['HTMLInputElement'].prototype, 'validity', defineValidity); | ||
Object.defineProperty(global['HTMLTextAreaElement'].prototype, 'validity', defineValidity); | ||
Object.defineProperty(window.HTMLElement.prototype, 'dataset', { | ||
Object.defineProperty(window['HTMLElement'].prototype, 'dataset', { | ||
writable: true, | ||
@@ -30,3 +30,3 @@ value: {} | ||
Object.defineProperty(window.HTMLCanvasElement.prototype, 'getContext', { | ||
Object.defineProperty(window['HTMLCanvasElement'].prototype, 'getContext', { | ||
writable: true, | ||
@@ -43,4 +43,4 @@ value: function value() { | ||
window.MutationObserver = window.MutationObserver || require('mutation-observer'); | ||
window['MutationObserver'] = window['MutationObserver'] || require('mutation-observer'); | ||
} | ||
}; |
@@ -1,8 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var deprecationWarning = exports.deprecationWarning = function deprecationWarning(message) { | ||
return console.warn("RMWC Deprecation Warning: " + message); | ||
}; | ||
// @flow | ||
export const deprecationWarning = (message: string) => | ||
console.warn(`RMWC Deprecation Warning: ${message}`); |
@@ -1,180 +0,103 @@ | ||
'use strict'; | ||
import * as React from 'react'; | ||
export class DocumentComponent extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.DocumentComponent = undefined; | ||
this.flatDocs = Object.values(props.docs).reduce((acc, val) => { | ||
return acc.concat(val); | ||
}, []); | ||
} | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
findDocDef(name) { | ||
return this.flatDocs.find(v => v.displayName === name); | ||
} | ||
var _react = require('react'); | ||
renderRaw(raw: string) { | ||
return raw.split('\n').map((s, i) => ( | ||
<React.Fragment key={i}> | ||
{i !== 0 && <br />} | ||
{s.split(' ').map((v, i) => ( | ||
<React.Fragment key={i}> | ||
{i !== 0 && <React.Fragment> </React.Fragment>} | ||
{v} | ||
</React.Fragment> | ||
))} | ||
</React.Fragment> | ||
)); | ||
} | ||
var React = _interopRequireWildcard(_react); | ||
/** | ||
* Merges together docs from a handful of components | ||
* This is a workaround for showing extension because the AST cant pick up definitions across files | ||
*/ | ||
getComposedDefs(names) { | ||
return names | ||
.map(name => this.findDocDef(name)) | ||
.filter(Boolean) | ||
.reduce((acc, def) => { | ||
return { | ||
...def, | ||
...acc, | ||
props: | ||
def.props || acc.props | ||
? { | ||
...(def.props || {}), | ||
...(acc.props || {}) | ||
} | ||
: null | ||
}; | ||
}, {}); | ||
} | ||
var _docgen = require('./docgen'); | ||
var _docgen2 = _interopRequireDefault(_docgen); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
var flatDocs = Object.values(_docgen2.default).reduce(function (acc, val) { | ||
return acc.concat(val); | ||
}, []); | ||
var findDocDef = function findDocDef(name) { | ||
return flatDocs.find(function (v) { | ||
return v.displayName === name; | ||
}); | ||
}; | ||
/** | ||
* Merges together docs from a handful of components | ||
* This is a workaround for showing extension because the AST cant pick up definitions across files | ||
*/ | ||
var getComposedDefs = function getComposedDefs(names) { | ||
return names.map(findDocDef).filter(Boolean).reduce(function (acc, def) { | ||
return Object.assign({}, def, acc, { | ||
props: def.props || acc.props ? Object.assign({}, def.props || {}, acc.props || {}) : null | ||
}); | ||
}, {}); | ||
}; | ||
var renderRaw = function renderRaw(raw) { | ||
return raw.split('\n').map(function (s, i) { | ||
return React.createElement( | ||
React.Fragment, | ||
{ key: i }, | ||
i !== 0 && React.createElement('br', null), | ||
s.split(' ').map(function (v, i) { | ||
return React.createElement( | ||
React.Fragment, | ||
{ key: i }, | ||
i !== 0 && React.createElement( | ||
React.Fragment, | ||
null, | ||
'\xA0\xA0' | ||
), | ||
v | ||
); | ||
}) | ||
render() { | ||
const { displayName, composes = [] } = this.props; | ||
const docs = this.getComposedDefs([displayName, ...composes]); | ||
return ( | ||
<div className="document-component"> | ||
<h2>{displayName}</h2> | ||
{docs && !!docs.description && <p>{docs.description}</p>} | ||
{docs && | ||
docs.props && ( | ||
<div> | ||
<h3>Props</h3> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Type</th> | ||
<th>Default</th> | ||
<th>Description</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{Object.entries(docs.props).map(([propName, prop], i) => ( | ||
<tr key={i}> | ||
<td className={prop.required ? 'required' : ''}> | ||
<code>{propName}</code> | ||
</td> | ||
<td> | ||
<code> | ||
{prop.flowType && | ||
this.renderRaw( | ||
prop.flowType.raw || prop.flowType.name || '' | ||
)} | ||
</code> | ||
</td> | ||
<td> | ||
{prop.defaultValue ? ( | ||
<code>{prop.defaultValue.value}</code> | ||
) : ( | ||
<code>undefined</code> | ||
)} | ||
</td> | ||
<td>{prop.description || ''}</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}); | ||
}; | ||
var DocumentComponent = exports.DocumentComponent = function DocumentComponent(_ref) { | ||
var displayName = _ref.displayName, | ||
_ref$composes = _ref.composes, | ||
composes = _ref$composes === undefined ? [] : _ref$composes; | ||
var docs = getComposedDefs([displayName].concat(_toConsumableArray(composes))); | ||
return React.createElement( | ||
'div', | ||
{ className: 'document-component' }, | ||
React.createElement( | ||
'h2', | ||
null, | ||
displayName | ||
), | ||
docs && !!docs.description && React.createElement( | ||
'p', | ||
null, | ||
docs.description | ||
), | ||
docs && docs.props && React.createElement( | ||
'div', | ||
null, | ||
React.createElement( | ||
'h3', | ||
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, | ||
'Default' | ||
), | ||
React.createElement( | ||
'th', | ||
null, | ||
'Description' | ||
) | ||
) | ||
), | ||
React.createElement( | ||
'tbody', | ||
null, | ||
Object.entries(docs.props).map(function (_ref2, i) { | ||
var _ref3 = _slicedToArray(_ref2, 2), | ||
propName = _ref3[0], | ||
prop = _ref3[1]; | ||
return React.createElement( | ||
'tr', | ||
{ key: i }, | ||
React.createElement( | ||
'td', | ||
{ className: prop.required ? 'required' : '' }, | ||
React.createElement( | ||
'code', | ||
null, | ||
propName | ||
) | ||
), | ||
React.createElement( | ||
'td', | ||
null, | ||
React.createElement( | ||
'code', | ||
null, | ||
prop.flowType && renderRaw(prop.flowType.raw || prop.flowType.name || '') | ||
) | ||
), | ||
React.createElement( | ||
'td', | ||
null, | ||
prop.defaultValue ? React.createElement( | ||
'code', | ||
null, | ||
prop.defaultValue.value | ||
) : React.createElement( | ||
'code', | ||
null, | ||
'undefined' | ||
) | ||
), | ||
React.createElement( | ||
'td', | ||
null, | ||
prop.description || '' | ||
) | ||
); | ||
}) | ||
) | ||
) | ||
) | ||
); | ||
}; | ||
} | ||
} |
@@ -1,7 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var noop = exports.noop = function noop() {}; | ||
exports.default = noop; | ||
export const noop = () => {}; | ||
export default noop; |
@@ -1,8 +0,3 @@ | ||
'use strict'; | ||
// @flow | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
/** | ||
@@ -12,5 +7,8 @@ * Generates a pseudo random string for DOM ids | ||
* */ | ||
var randomId = exports.randomId = function randomId(prefix) { | ||
var id = process.env.NODE_ENV === 'test' ? 'test' : (Math.random() + Math.random() + 1).toString(36).substring(2); | ||
return prefix + '-' + id; | ||
export const randomId = (prefix: string): string => { | ||
const id = | ||
process.env.NODE_ENV === 'test' | ||
? 'test' | ||
: (Math.random() + Math.random() + 1).toString(36).substring(2); | ||
return `${prefix}-${id}`; | ||
}; |
@@ -1,57 +0,25 @@ | ||
'use strict'; | ||
import * as React from 'react'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.storyWithState = undefined; | ||
export const storyWithState = (getState, Component) => | ||
class extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = getState({}); | ||
} | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
componentWillUpdate(nextProps, nextState) { | ||
const knobState = getState(nextState); | ||
const stateToUpdate = Object.keys(knobState).reduce((acc, key) => { | ||
if (nextState[key] !== knobState[key]) { | ||
acc[key] = knobState[key]; | ||
} | ||
return acc; | ||
}, {}); | ||
var _react = require('react'); | ||
Object.keys(stateToUpdate).length && this.setState(stateToUpdate); | ||
} | ||
var React = _interopRequireWildcard(_react); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var storyWithState = exports.storyWithState = function storyWithState(getState, Component) { | ||
return function (_React$Component) { | ||
_inherits(_class, _React$Component); | ||
function _class(props) { | ||
_classCallCheck(this, _class); | ||
var _this = _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).call(this, props)); | ||
_this.state = getState({}); | ||
return _this; | ||
render() { | ||
return Component.call(this); | ||
} | ||
_createClass(_class, [{ | ||
key: 'componentWillUpdate', | ||
value: function componentWillUpdate(nextProps, nextState) { | ||
var knobState = getState(nextState); | ||
var stateToUpdate = Object.keys(knobState).reduce(function (acc, key) { | ||
if (nextState[key] !== knobState[key]) { | ||
acc[key] = knobState[key]; | ||
} | ||
return acc; | ||
}, {}); | ||
Object.keys(stateToUpdate).length && this.setState(stateToUpdate); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return Component.call(this); | ||
} | ||
}]); | ||
return _class; | ||
}(React.Component); | ||
}; | ||
}; |
@@ -1,10 +0,5 @@ | ||
'use strict'; | ||
// @flow | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var toDashCase = exports.toDashCase = function toDashCase(str) { | ||
return str.replace(/([A-Z])/g, function ($1) { | ||
return '-' + $1.toLowerCase(); | ||
}); | ||
export const toDashCase = (str: string) => { | ||
return str.replace(/([A-Z])/g, $1 => '-' + $1.toLowerCase()); | ||
}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
346124
24
9557