UNPKG

preact-material-components

Version:
240 lines (188 loc) 7 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = exports.ChipSet = exports.ChipText = exports.ChipCheckmark = exports.ChipIcon = exports.Chip = void 0; var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get")); var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); var _chips = require("@material/chips"); var _preact = require("preact"); var _MaterialComponent4 = _interopRequireDefault(require("../Base/MaterialComponent")); var _Icon3 = _interopRequireDefault(require("../Icon")); var __rest = void 0 && (void 0).__rest || function (s, e) { var t = {}; for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; } if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; var Chip = /*#__PURE__*/ function (_MaterialComponent) { (0, _inherits2.default)(Chip, _MaterialComponent); function Chip() { var _this; (0, _classCallCheck2.default)(this, Chip); _this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(Chip).apply(this, arguments)); _this.componentName = 'chip'; _this.mdcProps = ['selected']; return _this; } (0, _createClass2.default)(Chip, [{ key: "materialDom", value: function materialDom(allprops) { var children = allprops.children, props = __rest(allprops, ["children"]); return (0, _preact.h)("div", Object.assign({}, props, { ref: this.setControlRef }), children); } }]); return Chip; }(_MaterialComponent4.default); exports.Chip = Chip; var ChipIcon = /*#__PURE__*/ function (_Icon) { (0, _inherits2.default)(ChipIcon, _Icon); function ChipIcon() { var _this2; (0, _classCallCheck2.default)(this, ChipIcon); _this2 = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(ChipIcon).apply(this, arguments)); _this2.componentName = 'chip__icon'; _this2.mdcProps = ['leading', 'trailing']; return _this2; } (0, _createClass2.default)(ChipIcon, [{ key: "materialDom", value: function materialDom(allprops) { var children = allprops.children, props = __rest(allprops, ["children"]); var otherprops = {}; if (props.trailing) { otherprops.tabindex = 0; otherprops.role = 'button'; } return (0, _preact.h)(_Icon3.default, Object.assign({}, props, otherprops), children); } }]); return ChipIcon; }(_Icon3.default); exports.ChipIcon = ChipIcon; var ChipCheckmark = /*#__PURE__*/ function (_Icon2) { (0, _inherits2.default)(ChipCheckmark, _Icon2); function ChipCheckmark() { var _this3; (0, _classCallCheck2.default)(this, ChipCheckmark); _this3 = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(ChipCheckmark).apply(this, arguments)); _this3.componentName = 'chip__checkmark'; _this3.mdcProps = []; return _this3; } (0, _createClass2.default)(ChipCheckmark, [{ key: "materialDom", value: function materialDom(props) { return (0, _preact.h)("div", Object.assign({}, props), (0, _preact.h)("svg", { class: "mdc-chip__checkmark-svg", viewBox: "-2 -3 30 30" }, (0, _preact.h)("path", { class: "mdc-chip__checkmark-path", fill: "none", stroke: "black", d: "M1.73,12.91 8.1,19.28 22.79,4.59" }))); } }]); return ChipCheckmark; }(_Icon3.default); exports.ChipCheckmark = ChipCheckmark; var ChipText = /*#__PURE__*/ function (_MaterialComponent2) { (0, _inherits2.default)(ChipText, _MaterialComponent2); function ChipText() { var _this4; (0, _classCallCheck2.default)(this, ChipText); _this4 = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(ChipText).apply(this, arguments)); _this4.componentName = 'chip__text'; _this4.mdcProps = []; return _this4; } (0, _createClass2.default)(ChipText, [{ key: "materialDom", value: function materialDom(allprops) { var children = allprops.children, props = __rest(allprops, ["children"]); return (0, _preact.h)("div", Object.assign({}, props), children); } }]); return ChipText; }(_MaterialComponent4.default); exports.ChipText = ChipText; var ChipSet = /*#__PURE__*/ function (_MaterialComponent3) { (0, _inherits2.default)(ChipSet, _MaterialComponent3); function ChipSet() { var _this5; (0, _classCallCheck2.default)(this, ChipSet); _this5 = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(ChipSet).apply(this, arguments)); _this5.componentName = 'chip-set'; _this5.mdcProps = ['choice', 'filter', 'input']; return _this5; } (0, _createClass2.default)(ChipSet, [{ key: "componentDidMount", value: function componentDidMount() { (0, _get2.default)((0, _getPrototypeOf2.default)(ChipSet.prototype), "componentDidMount", this).call(this); if (this.control) { this.MDComponent = new _chips.MDCChipSet(this.control); } } }, { key: "componentWillUnmount", value: function componentWillUnmount() { (0, _get2.default)((0, _getPrototypeOf2.default)(ChipSet.prototype), "componentWillUnmount", this).call(this); if (this.MDComponent) { this.MDComponent.destroy(); } } }, { key: "materialDom", value: function materialDom(allprops) { var children = allprops.children, props = __rest(allprops, ["children"]); return (0, _preact.h)("div", Object.assign({}, props, { ref: this.setControlRef }), children); } }]); return ChipSet; }(_MaterialComponent4.default); exports.ChipSet = ChipSet; var default_1 = /*#__PURE__*/ function (_ChipSet) { (0, _inherits2.default)(default_1, _ChipSet); function default_1() { (0, _classCallCheck2.default)(this, default_1); return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(default_1).apply(this, arguments)); } return default_1; }(ChipSet); exports.default = default_1; default_1.Chip = Chip; default_1.Icon = ChipIcon; default_1.Text = ChipText; default_1.Checkmark = ChipCheckmark; //# sourceMappingURL=index.js.map