Socket
Socket
Sign inDemoInstall

@rmwc/base

Package Overview
Dependencies
Maintainers
1
Versions
168
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rmwc/base - npm Package Compare versions

Comparing version 2.0.0-alpha.2 to 2.0.0-alpha.3

utils/deprecationWarning.d.ts

2

package.json
{
"name": "@rmwc/base",
"version": "2.0.0-alpha.2",
"version": "2.0.0-alpha.3",
"description": "RMWC base module",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,3 +0,8 @@

// @flow
export const deprecationWarning = (message: string) =>
console.warn(`RMWC Deprecation Warning: ${message}`);
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var deprecationWarning = exports.deprecationWarning = function deprecationWarning(message) {
return console.warn("RMWC Deprecation Warning: " + message);
};

@@ -1,103 +0,209 @@

import * as React from 'react';
export class DocumentComponent extends React.Component {
constructor(props) {
super(props);
'use strict';
this.flatDocs = Object.values(props.docs).reduce((acc, val) => {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DocumentComponent = undefined;
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"); } }; }();
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; }; }();
var _react = require('react');
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 _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); } }
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 DocumentComponent = exports.DocumentComponent = function (_React$Component) {
_inherits(DocumentComponent, _React$Component);
function DocumentComponent(props) {
_classCallCheck(this, DocumentComponent);
var _this = _possibleConstructorReturn(this, (DocumentComponent.__proto__ || Object.getPrototypeOf(DocumentComponent)).call(this, props));
_this.flatDocs = Object.values(props.docs).reduce(function (acc, val) {
return acc.concat(val);
}, []);
return _this;
}
findDocDef(name) {
return this.flatDocs.find(v => v.displayName === name);
}
_createClass(DocumentComponent, [{
key: 'findDocDef',
value: function findDocDef(name) {
return this.flatDocs.find(function (v) {
return v.displayName === name;
});
}
}, {
key: 'renderRaw',
value: 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
);
})
);
});
}
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>&nbsp;&nbsp;</React.Fragment>}
{v}
</React.Fragment>
))}
</React.Fragment>
));
}
/**
* Merges together docs from a handful of components
* This is a workaround for showing extension because the AST cant pick up definitions across files
*/
/**
* 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
};
}, {
key: 'getComposedDefs',
value: function getComposedDefs(names) {
var _this2 = this;
return names.map(function (name) {
return _this2.findDocDef(name);
}).filter(Boolean).reduce(function (acc, def) {
return Object.assign({}, def, acc, {
props: def.props || acc.props ? Object.assign({}, def.props || {}, acc.props || {}) : null
});
}, {});
}
}
}, {
key: 'render',
value: function render() {
var _this3 = this;
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 _props = this.props,
displayName = _props.displayName,
_props$composes = _props.composes,
composes = _props$composes === undefined ? [] : _props$composes;
var docs = this.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 (_ref, i) {
var _ref2 = _slicedToArray(_ref, 2),
propName = _ref2[0],
prop = _ref2[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 && _this3.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 || ''
)
);
})
)
)
)
);
}
}]);
return DocumentComponent;
}(React.Component);

@@ -1,2 +0,7 @@

export const noop = () => {};
export default noop;
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var noop = exports.noop = function noop() {};
exports.default = noop;

@@ -1,3 +0,8 @@

// @flow
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
/**

@@ -7,8 +12,5 @@ * Generates a pseudo random string for DOM ids

* */
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}`;
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;
};

@@ -1,25 +0,57 @@

import * as React from 'react';
'use strict';
export const storyWithState = (getState, Component) =>
class extends React.Component {
constructor(props) {
super(props);
this.state = getState({});
}
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.storyWithState = undefined;
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 _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; }; }();
Object.keys(stateToUpdate).length && this.setState(stateToUpdate);
var _react = require('react');
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,5 +0,10 @@

// @flow
'use strict';
export const toDashCase = (str: string) => {
return str.replace(/([A-Z])/g, $1 => '-' + $1.toLowerCase());
Object.defineProperty(exports, "__esModule", {
value: true
});
var toDashCase = exports.toDashCase = function toDashCase(str) {
return str.replace(/([A-Z])/g, function ($1) {
return '-' + $1.toLowerCase();
});
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc