Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-twemoji

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-twemoji - npm Package Compare versions

Comparing version 0.0.8 to 0.1.0

lib/Twemoji/__tests__/index-test.js

5

karma.conf.js

@@ -20,6 +20,5 @@ var webpack = require('webpack');

webpack: {
devtool: 'inline-source-map',
module: {
loaders: [
{ test: /\.js$/, loader: 'babel-loader' }
rules: [
{ test: /\.jsx?$/, loader: 'babel-loader' }
]

@@ -26,0 +25,0 @@ }

123

lib/Twemoji/index.js

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

'use strict';
"use strict";

@@ -6,54 +6,82 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
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 _isEqual = _interopRequireDefault(require("lodash/isEqual"));
var _isEqual = require('lodash/isEqual');
var _react = _interopRequireDefault(require("react"));
var _isEqual2 = _interopRequireDefault(_isEqual);
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = require('react');
var _twemoji = _interopRequireDefault(require("twemoji"));
var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _propTypes = require('prop-types');
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var _propTypes2 = _interopRequireDefault(_propTypes);
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var _reactDom = require('react-dom');
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
var _reactDom2 = _interopRequireDefault(_reactDom);
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
var _twemoji = require('twemoji');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _twemoji2 = _interopRequireDefault(_twemoji);
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); } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
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 _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
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; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
var Twemoji = function (_React$Component) {
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var Twemoji =
/*#__PURE__*/
function (_React$Component) {
_inherits(Twemoji, _React$Component);
function Twemoji() {
function Twemoji(props) {
var _this;
_classCallCheck(this, Twemoji);
return _possibleConstructorReturn(this, Object.getPrototypeOf(Twemoji).apply(this, arguments));
_this = _possibleConstructorReturn(this, _getPrototypeOf(Twemoji).call(this, props));
if (props.noWrapper) {
_this.childrenRefs = {};
} else {
_this.rootRef = _react.default.createRef();
}
return _this;
}
_createClass(Twemoji, [{
key: '_parseTwemoji',
key: "_parseTwemoji",
value: function _parseTwemoji() {
var node = _reactDom2.default.findDOMNode(this);
_twemoji2.default.parse(node, this.props.options);
var noWrapper = this.props.noWrapper;
if (noWrapper) {
for (var i in this.childrenRefs) {
var node = this.childrenRefs[i].current;
_twemoji.default.parse(node, this.props.options);
}
} else {
var _node = this.rootRef.current;
_twemoji.default.parse(_node, this.props.options);
}
}
}, {
key: 'componentDidUpdate',
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) {
if (!(0, _isEqual2.default)(this.props, prevProps)) {
if (!(0, _isEqual.default)(this.props, prevProps)) {
this._parseTwemoji();

@@ -63,3 +91,3 @@ }

}, {
key: 'componentDidMount',
key: "componentDidMount",
value: function componentDidMount() {

@@ -69,15 +97,24 @@ this._parseTwemoji();

}, {
key: 'render',
key: "render",
value: function render() {
var _props = this.props;
var children = _props.children;
var _this2 = this;
var other = _objectWithoutProperties(_props, ['children']);
var _this$props = this.props,
children = _this$props.children,
noWrapper = _this$props.noWrapper,
other = _objectWithoutProperties(_this$props, ["children", "noWrapper"]);
delete other.options;
return _react2.default.createElement(
'div',
other,
children
);
if (noWrapper) {
return _react.default.createElement(_react.default.Fragment, null, _react.default.Children.map(children, function (c, i) {
_this2.childrenRefs[i] = _this2.childrenRefs[i] || _react.default.createRef();
return _react.default.cloneElement(c, {
ref: _this2.childrenRefs[i]
});
}));
} else {
delete other.options;
return _react.default.createElement("div", _extends({
ref: this.rootRef
}, other), children);
}
}

@@ -87,8 +124,10 @@ }]);

return Twemoji;
}(_react2.default.Component);
}(_react.default.Component);
Twemoji.propTypes = {
children: _propTypes2.default.node,
options: _propTypes2.default.object
};
exports.default = Twemoji;
exports.default = Twemoji;
_defineProperty(Twemoji, "propTypes", {
children: _propTypes.default.node,
noWrapper: _propTypes.default.bool,
options: _propTypes.default.object
});
{
"name": "react-twemoji",
"version": "0.0.8",
"version": "0.1.0",
"description": "A React wrapper for Twemoji",

@@ -12,4 +12,3 @@ "keyword": [

"engines": {
"node": ">=5.0",
"npm": ">=3.3"
"node": ">=5.0"
},

@@ -22,3 +21,3 @@ "repository": {

"scripts": {
"build": "npm run lint && babel src -d lib --ignore='*-test.js'",
"build": "yarn run lint && babel src -d lib --ignore='*-test.js'",
"example": "node example/server.js",

@@ -30,20 +29,24 @@ "lint": "eslint --ext .js ./",

"presets": [
"es2015",
"react",
"stage-1"
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": []
"plugins": [
"@babel/plugin-proposal-class-properties"
]
},
"devDependencies": {
"babel-cli": "^6.7.5",
"babel-eslint": "^6.0.2",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-1": "^6.5.0",
"@babel/cli": "^7.0.0-beta.56",
"@babel/core": "^7.0.0-beta.56",
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.56",
"@babel/preset-env": "^7.0.0-beta.56",
"@babel/preset-react": "^7.0.0-beta.56",
"babel-eslint": "^9.0.0-beta.3",
"babel-loader": "^8.0.0-beta",
"chai": "^3.5.0",
"eslint": "^2.7.0",
"eslint-config-airbnb": "^7.0.0",
"eslint-plugin-babel": "^3.2.0",
"eslint-plugin-react": "^4.3.0",
"eslint": "^5.3.0",
"eslint-config-airbnb": "^17.0.0",
"eslint-plugin-babel": "^5.1.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-react": "^7.10.0",
"express": "^4.13.4",

@@ -53,19 +56,20 @@ "karma": "^0.13.22",

"karma-mocha": "^0.2.2",
"karma-webpack": "^1.7.0",
"karma-webpack": "^3.0.0",
"mocha": "^2.4.5",
"pretty-error": "^2.0.0",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"webpack": "^1.12.15",
"webpack-dev-middleware": "^1.6.1"
"react": "^16.4.2",
"react-dom": "^16.4.2",
"webpack": "^4.16.4",
"webpack-cli": "^3.1.0",
"webpack-dev-middleware": "^3.1.3"
},
"dependencies": {
"lodash": "^4.16.2",
"prop-types": "^15.5.8",
"twemoji": "^2.0.5"
"prop-types": "^15.6.2",
"twemoji": "^11.0.1"
},
"peerDependencies": {
"react": "^15.3.0",
"react-dom": "^15.3.0"
"react": "^16.4.2",
"react-dom": "^16.4.2"
}
}

@@ -8,3 +8,3 @@ # react-twemoji

```shell
npm install react-twemoji
yarn install react-twemoji
```

@@ -37,6 +37,13 @@

## Props
| Name | Type | Default | Description|
|:---- |:---- |:---- |:----|
| `options` | `Object` | `{}` | `twemoji.parse` options |
| `noWrapper` | `Boolean` | `false` | When set to `true`, Twemoji will not render a wrapping `div` to contain children |
### Run example
```sh
npm run example
yarn run example
```

@@ -49,3 +56,3 @@ then open http://localhost:8080/

```sh
npm run lint
yarn run lint
```

@@ -56,3 +63,3 @@

```sh
npm run test
yarn run test
```

@@ -63,3 +70,3 @@

```sh
npm run build
yarn run build
```
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