@rmwc/checkbox
Advanced tools
Comparing version 5.0.2-alpha.0 to 5.0.3-alpha.0
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
@@ -41,120 +42,122 @@ var extendStatics = function (d, b) { | ||
}; | ||
define(["require", "exports", "react", "@material/checkbox", "@rmwc/base", "@rmwc/ripple", "@rmwc/toggleable"], function (require, exports, React, checkbox_1, base_1, ripple_1, toggleable_1) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
React = __importStar(React); | ||
/** | ||
* This is an awful freaking bugfix | ||
* Basically, MDC decided that patching the native getter and setter | ||
* on a checkbox would be fun which consequently kills Reacts ability | ||
* to do the same. | ||
*/ | ||
checkbox_1.MDCCheckboxFoundation.prototype.installPropertyChangeHooks_ = function () { }; | ||
var CheckboxRoot = ripple_1.withRipple({ | ||
surface: false, | ||
unbounded: true | ||
})(base_1.componentFactory({ | ||
displayName: 'CheckboxRoot', | ||
classNames: function (props) { return [ | ||
'mdc-checkbox', | ||
{ | ||
'mdc-checkbox--disabled': props.disabled | ||
} | ||
]; }, | ||
consumeProps: ['disabled'] | ||
})); | ||
var CheckboxNativeControl = base_1.componentFactory({ | ||
displayName: 'CheckboxNativeControl', | ||
defaultProps: { | ||
type: 'checkbox' | ||
}, | ||
tag: 'input', | ||
classNames: ['mdc-checkbox__native-control'] | ||
}); | ||
var CheckboxBackground = /** @class */ (function (_super) { | ||
__extends(CheckboxBackground, _super); | ||
function CheckboxBackground() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var React = __importStar(require("react")); | ||
// @ts-ignore | ||
var checkbox_1 = require("@material/checkbox"); | ||
var base_1 = require("@rmwc/base"); | ||
var ripple_1 = require("@rmwc/ripple"); | ||
var toggleable_1 = require("@rmwc/toggleable"); | ||
/** | ||
* This is an awful freaking bugfix | ||
* Basically, MDC decided that patching the native getter and setter | ||
* on a checkbox would be fun which consequently kills Reacts ability | ||
* to do the same. | ||
*/ | ||
checkbox_1.MDCCheckboxFoundation.prototype.installPropertyChangeHooks_ = function () { }; | ||
var CheckboxRoot = ripple_1.withRipple({ | ||
surface: false, | ||
unbounded: true | ||
})(base_1.componentFactory({ | ||
displayName: 'CheckboxRoot', | ||
classNames: function (props) { return [ | ||
'mdc-checkbox', | ||
{ | ||
'mdc-checkbox--disabled': props.disabled | ||
} | ||
CheckboxBackground.prototype.shouldComponentUpdate = function () { | ||
return false; | ||
}; | ||
CheckboxBackground.prototype.render = function () { | ||
return (React.createElement("div", { className: "mdc-checkbox__background" }, | ||
React.createElement("svg", { className: "mdc-checkbox__checkmark", viewBox: "0 0 24 24" }, | ||
React.createElement("path", { className: "mdc-checkbox__checkmark-path", fill: "none", stroke: "white", d: "M1.73,12.91 8.1,19.28 22.79,4.59" })), | ||
React.createElement("div", { className: "mdc-checkbox__mixedmark" }))); | ||
}; | ||
CheckboxBackground.displayName = 'CheckboxBackground'; | ||
return CheckboxBackground; | ||
}(React.Component)); | ||
/** | ||
* A Checkbox component | ||
*/ | ||
var Checkbox = /** @class */ (function (_super) { | ||
__extends(Checkbox, _super); | ||
function Checkbox(props) { | ||
var _this = _super.call(this, props) || this; | ||
_this.nativeCb = _this.createElement('nativeCb'); | ||
_this.root = _this.createElement('root'); | ||
_this.handleAnimationEnd = _this.handleAnimationEnd.bind(_this); | ||
_this.handleOnChange = _this.handleOnChange.bind(_this); | ||
return _this; | ||
]; }, | ||
consumeProps: ['disabled'] | ||
})); | ||
var CheckboxNativeControl = base_1.componentFactory({ | ||
displayName: 'CheckboxNativeControl', | ||
defaultProps: { | ||
type: 'checkbox' | ||
}, | ||
tag: 'input', | ||
classNames: ['mdc-checkbox__native-control'] | ||
}); | ||
var CheckboxBackground = /** @class */ (function (_super) { | ||
__extends(CheckboxBackground, _super); | ||
function CheckboxBackground() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
CheckboxBackground.prototype.shouldComponentUpdate = function () { | ||
return false; | ||
}; | ||
CheckboxBackground.prototype.render = function () { | ||
return (React.createElement("div", { className: "mdc-checkbox__background" }, | ||
React.createElement("svg", { className: "mdc-checkbox__checkmark", viewBox: "0 0 24 24" }, | ||
React.createElement("path", { className: "mdc-checkbox__checkmark-path", fill: "none", stroke: "white", d: "M1.73,12.91 8.1,19.28 22.79,4.59" })), | ||
React.createElement("div", { className: "mdc-checkbox__mixedmark" }))); | ||
}; | ||
CheckboxBackground.displayName = 'CheckboxBackground'; | ||
return CheckboxBackground; | ||
}(React.Component)); | ||
/** | ||
* A Checkbox component | ||
*/ | ||
var Checkbox = /** @class */ (function (_super) { | ||
__extends(Checkbox, _super); | ||
function Checkbox(props) { | ||
var _this = _super.call(this, props) || this; | ||
_this.nativeCb = _this.createElement('nativeCb'); | ||
_this.root = _this.createElement('root'); | ||
_this.handleAnimationEnd = _this.handleAnimationEnd.bind(_this); | ||
_this.handleOnChange = _this.handleOnChange.bind(_this); | ||
return _this; | ||
} | ||
Checkbox.prototype.sync = function (nextProps) { | ||
this.foundation.handleChange(); | ||
if (this.nativeCb.ref && | ||
nextProps.indeterminate !== this.nativeCb.ref.indeterminate) { | ||
this.nativeCb.ref.indeterminate = !!nextProps.indeterminate; | ||
} | ||
Checkbox.prototype.sync = function (nextProps) { | ||
this.foundation.handleChange(); | ||
if (this.nativeCb.ref && | ||
nextProps.indeterminate !== this.nativeCb.ref.indeterminate) { | ||
this.nativeCb.ref.indeterminate = !!nextProps.indeterminate; | ||
} | ||
}; | ||
Checkbox.prototype.getDefaultFoundation = function () { | ||
var _this = this; | ||
return new checkbox_1.MDCCheckboxFoundation({ | ||
addClass: function (className) { return _this.root.addClass(className); }, | ||
removeClass: function (className) { return _this.root.removeClass(className); }, | ||
setNativeControlAttr: function (attr, value) { | ||
return _this.nativeCb.setProp(attr, value); | ||
}, | ||
removeNativeControlAttr: function (attr) { | ||
return _this.nativeCb.removeProp(attr); | ||
}, | ||
getNativeControl: function () { return _this.nativeCb.ref; }, | ||
isIndeterminate: function () { return _this.props.indeterminate; }, | ||
isChecked: function () { | ||
return _this.props.checked !== undefined | ||
? _this.props.checked | ||
: _this.nativeCb.ref && _this.nativeCb.ref.checked; | ||
}, | ||
hasNativeControl: function () { return !!_this.nativeCb.ref; }, | ||
setNativeControlDisabled: function (disabled) { | ||
return _this.nativeCb.setProp('disabled', disabled); | ||
}, | ||
forceLayout: function () { return _this.root.ref && _this.root.ref.offsetWidth; }, | ||
isAttachedToDOM: function () { return true; } | ||
}); | ||
}; | ||
Checkbox.prototype.handleAnimationEnd = function (evt) { | ||
this.props.onAnimationEnd && this.props.onAnimationEnd(evt); | ||
this.foundation && this.foundation.handleAnimationEnd(); | ||
}; | ||
Checkbox.prototype.handleOnChange = function (evt) { | ||
this.props.onChange && this.props.onChange(evt); | ||
this.sync(this.props); | ||
}; | ||
Checkbox.prototype.render = function () { | ||
var _this = this; | ||
var _a = this.props, children = _a.children, className = _a.className, label = _a.label, style = _a.style, indeterminate = _a.indeterminate, inputRef = _a.inputRef, rest = __rest(_a, ["children", "className", "label", "style", "indeterminate", "inputRef"]); | ||
var checkbox = (React.createElement(CheckboxRoot, __assign({}, this.toggleRootProps, { ref: this.root.setRef, onAnimationEnd: this.handleAnimationEnd }), | ||
React.createElement(CheckboxNativeControl, __assign({}, this.nativeCb.props(rest), { ref: function (el) { | ||
_this.nativeCb.setRef(el); | ||
inputRef && inputRef(el); | ||
}, id: this.id, onChange: this.handleOnChange })), | ||
React.createElement(CheckboxBackground, null))); | ||
return this.renderToggle(checkbox); | ||
}; | ||
Checkbox.displayName = 'Checkbox'; | ||
return Checkbox; | ||
}(toggleable_1.ToggleableFoundationComponent)); | ||
exports.Checkbox = Checkbox; | ||
}); | ||
}; | ||
Checkbox.prototype.getDefaultFoundation = function () { | ||
var _this = this; | ||
return new checkbox_1.MDCCheckboxFoundation({ | ||
addClass: function (className) { return _this.root.addClass(className); }, | ||
removeClass: function (className) { return _this.root.removeClass(className); }, | ||
setNativeControlAttr: function (attr, value) { | ||
return _this.nativeCb.setProp(attr, value); | ||
}, | ||
removeNativeControlAttr: function (attr) { | ||
return _this.nativeCb.removeProp(attr); | ||
}, | ||
getNativeControl: function () { return _this.nativeCb.ref; }, | ||
isIndeterminate: function () { return _this.props.indeterminate; }, | ||
isChecked: function () { | ||
return _this.props.checked !== undefined | ||
? _this.props.checked | ||
: _this.nativeCb.ref && _this.nativeCb.ref.checked; | ||
}, | ||
hasNativeControl: function () { return !!_this.nativeCb.ref; }, | ||
setNativeControlDisabled: function (disabled) { | ||
return _this.nativeCb.setProp('disabled', disabled); | ||
}, | ||
forceLayout: function () { return _this.root.ref && _this.root.ref.offsetWidth; }, | ||
isAttachedToDOM: function () { return true; } | ||
}); | ||
}; | ||
Checkbox.prototype.handleAnimationEnd = function (evt) { | ||
this.props.onAnimationEnd && this.props.onAnimationEnd(evt); | ||
this.foundation && this.foundation.handleAnimationEnd(); | ||
}; | ||
Checkbox.prototype.handleOnChange = function (evt) { | ||
this.props.onChange && this.props.onChange(evt); | ||
this.sync(this.props); | ||
}; | ||
Checkbox.prototype.render = function () { | ||
var _this = this; | ||
var _a = this.props, children = _a.children, className = _a.className, label = _a.label, style = _a.style, indeterminate = _a.indeterminate, inputRef = _a.inputRef, rest = __rest(_a, ["children", "className", "label", "style", "indeterminate", "inputRef"]); | ||
var checkbox = (React.createElement(CheckboxRoot, __assign({}, this.toggleRootProps, { ref: this.root.setRef, onAnimationEnd: this.handleAnimationEnd }), | ||
React.createElement(CheckboxNativeControl, __assign({}, this.nativeCb.props(rest), { ref: function (el) { | ||
_this.nativeCb.setRef(el); | ||
inputRef && inputRef(el); | ||
}, id: this.id, onChange: this.handleOnChange })), | ||
React.createElement(CheckboxBackground, null))); | ||
return this.renderToggle(checkbox); | ||
}; | ||
Checkbox.displayName = 'Checkbox'; | ||
return Checkbox; | ||
}(toggleable_1.ToggleableFoundationComponent)); | ||
exports.Checkbox = Checkbox; |
{ | ||
"name": "@rmwc/checkbox", | ||
"version": "5.0.2-alpha.0", | ||
"version": "5.0.3-alpha.0", | ||
"description": "RMWC Checkbox component", | ||
@@ -35,8 +35,8 @@ "main": "dist/index.js", | ||
"@material/checkbox": "^0.43.0", | ||
"@rmwc/base": "^5.0.2-alpha.0", | ||
"@rmwc/formfield": "^5.0.2-alpha.0", | ||
"@rmwc/ripple": "^5.0.2-alpha.0", | ||
"@rmwc/toggleable": "^5.0.2-alpha.0" | ||
"@rmwc/base": "^5.0.3-alpha.0", | ||
"@rmwc/formfield": "^5.0.3-alpha.0", | ||
"@rmwc/ripple": "^5.0.3-alpha.0", | ||
"@rmwc/toggleable": "^5.0.3-alpha.0" | ||
}, | ||
"gitHead": "69fbf9ddbdad8cf2b014443c386e1c125a9cee79" | ||
"gitHead": "32b316530fb6c1c78e2335bc56d9be85e3cb3752" | ||
} |
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
13
5153
141562