@rmwc/ripple
Advanced tools
Comparing version 2.0.0-alpha.3 to 2.0.0-alpha.4
import * as React from 'react'; | ||
export { withRipple } from './withRipple'; | ||
export { WithRipplePropsT } from './withRipple'; | ||
export declare type RipplePropsT = { | ||
@@ -89,2 +87,46 @@ /** Makes the ripple unbounded */ | ||
} | ||
export declare type WithRipplePropsT = { | ||
ripple?: boolean; | ||
surface?: boolean; | ||
cssOnly?: boolean; | ||
unbounded?: boolean; | ||
}; | ||
/** | ||
* HOC that adds ripples to any component | ||
*/ | ||
export declare const withRipple: ({ unbounded: defaultUnbounded, surface: defaultSurface }?: { | ||
unbounded?: boolean | undefined; | ||
surface?: boolean | undefined; | ||
}) => (Component: React.ComponentType<any>) => { | ||
new (props: Readonly<any>): { | ||
render(): JSX.Element; | ||
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<any>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void; | ||
forceUpdate(callBack?: (() => void) | undefined): void; | ||
readonly props: Readonly<{ | ||
children?: React.ReactNode; | ||
}> & Readonly<any>; | ||
state: Readonly<{}>; | ||
context: any; | ||
refs: { | ||
[key: string]: React.ReactInstance; | ||
}; | ||
}; | ||
new (props: any, context?: any): { | ||
render(): JSX.Element; | ||
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<any>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void; | ||
forceUpdate(callBack?: (() => void) | undefined): void; | ||
readonly props: Readonly<{ | ||
children?: React.ReactNode; | ||
}> & Readonly<any>; | ||
state: Readonly<{}>; | ||
context: any; | ||
refs: { | ||
[key: string]: React.ReactInstance; | ||
}; | ||
}; | ||
displayName: string; | ||
defaultProps: { | ||
ripple: boolean; | ||
}; | ||
}; | ||
export default Ripple; |
72
index.js
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.Ripple = exports.withRipple = undefined; | ||
exports.withRipple = exports.Ripple = undefined; | ||
@@ -13,11 +13,2 @@ 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 _withRipple = require('./withRipple'); | ||
Object.defineProperty(exports, 'withRipple', { | ||
enumerable: true, | ||
get: function get() { | ||
return _withRipple.withRipple; | ||
} | ||
}); | ||
var _react = require('react'); | ||
@@ -124,2 +115,63 @@ | ||
}); | ||
/** | ||
* HOC that adds ripples to any component | ||
*/ | ||
var withRipple = function withRipple() { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
defaultUnbounded = _ref.unbounded, | ||
_ref$surface = _ref.surface, | ||
defaultSurface = _ref$surface === undefined ? true : _ref$surface; | ||
return function (Component) { | ||
var _class, _temp; | ||
return _temp = _class = function (_React$Component) { | ||
_inherits(_class, _React$Component); | ||
function _class() { | ||
_classCallCheck(this, _class); | ||
return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments)); | ||
} | ||
_createClass(_class, [{ | ||
key: 'render', | ||
value: function render() { | ||
var _props2 = this.props, | ||
ripple = _props2.ripple, | ||
rest = _objectWithoutProperties(_props2, ['ripple']); | ||
if (ripple && !rest.cssOnly) { | ||
return React.createElement( | ||
Ripple, | ||
Object.assign({}, rest, { | ||
unbounded: rest.unbounded || defaultUnbounded, | ||
surface: rest.surface || defaultSurface | ||
}), | ||
React.createElement(Component, rest) | ||
); | ||
} | ||
return React.createElement(Component, rest); | ||
} | ||
}]); | ||
return _class; | ||
}(React.Component), Object.defineProperty(_class, 'displayName', { | ||
enumerable: true, | ||
writable: true, | ||
value: 'withRipple(' + (Component.displayName || 'Unknown') + ')' | ||
}), Object.defineProperty(_class, 'defaultProps', { | ||
enumerable: true, | ||
writable: true, | ||
value: { | ||
ripple: true | ||
} | ||
}), _temp; | ||
}; | ||
}; | ||
exports.withRipple = withRipple; | ||
exports.default = Ripple; |
{ | ||
"name": "@rmwc/ripple", | ||
"version": "2.0.0-alpha.3", | ||
"version": "2.0.0-alpha.4", | ||
"description": "RMWC Ripple component", | ||
@@ -30,5 +30,5 @@ "main": "index.js", | ||
"@material/ripple": "~0.39.0", | ||
"@rmwc/base": "^2.0.0-alpha.3", | ||
"@rmwc/base": "^2.0.0-alpha.4", | ||
"classnames": "^2.2.5" | ||
} | ||
} |
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
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
19794
6
361
Updated@rmwc/base@^2.0.0-alpha.4