1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | import { __assign, __extends } from "tslib";
|
17 |
|
18 |
|
19 | import * as React from "react";
|
20 | import { DISPLAYNAME_PREFIX, removeNonHTMLProps } from "../../common/props";
|
21 | import { refHandler, setRef } from "../../common/refs";
|
22 | import { AbstractButton } from "./abstractButton";
|
23 | var Button = (function (_super) {
|
24 | __extends(Button, _super);
|
25 | function Button() {
|
26 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
27 |
|
28 | _this.buttonRef = null;
|
29 | _this.handleRef = refHandler(_this, "buttonRef", _this.props.elementRef);
|
30 | return _this;
|
31 | }
|
32 | Button.prototype.render = function () {
|
33 | return (React.createElement("button", __assign({ type: "button", ref: this.handleRef }, removeNonHTMLProps(this.props), this.getCommonButtonProps()), this.renderChildren()));
|
34 | };
|
35 | Button.prototype.componentDidUpdate = function (prevProps) {
|
36 | if (prevProps.elementRef !== this.props.elementRef) {
|
37 | setRef(prevProps.elementRef, null);
|
38 | this.handleRef = refHandler(this, "buttonRef", this.props.elementRef);
|
39 | setRef(this.props.elementRef, this.buttonRef);
|
40 | }
|
41 | };
|
42 | Button.displayName = DISPLAYNAME_PREFIX + ".Button";
|
43 | return Button;
|
44 | }(AbstractButton));
|
45 | export { Button };
|
46 | var AnchorButton = (function (_super) {
|
47 | __extends(AnchorButton, _super);
|
48 | function AnchorButton() {
|
49 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
50 |
|
51 | _this.buttonRef = null;
|
52 | _this.handleRef = refHandler(_this, "buttonRef", _this.props.elementRef);
|
53 | return _this;
|
54 | }
|
55 | AnchorButton.prototype.render = function () {
|
56 | var _a = this.props, href = _a.href, _b = _a.tabIndex, tabIndex = _b === void 0 ? 0 : _b;
|
57 | var commonProps = this.getCommonButtonProps();
|
58 | return (React.createElement("a", __assign({ role: "button", ref: this.handleRef }, removeNonHTMLProps(this.props), commonProps, { href: commonProps.disabled ? undefined : href, tabIndex: commonProps.disabled ? -1 : tabIndex }), this.renderChildren()));
|
59 | };
|
60 | AnchorButton.prototype.componentDidUpdate = function (prevProps) {
|
61 | if (prevProps.elementRef !== this.props.elementRef) {
|
62 | setRef(prevProps.elementRef, null);
|
63 | this.handleRef = refHandler(this, "buttonRef", this.props.elementRef);
|
64 | setRef(this.props.elementRef, this.buttonRef);
|
65 | }
|
66 | };
|
67 | AnchorButton.displayName = DISPLAYNAME_PREFIX + ".AnchorButton";
|
68 | return AnchorButton;
|
69 | }(AbstractButton));
|
70 | export { AnchorButton };
|
71 |
|
\ | No newline at end of file |