@@ -12945,14 +12945,16 @@ return /******/ (function(modules) { // webpackBootstrap
1294512945 dismissible: _react2["default"].PropTypes.bool,
1294612946 duration: _react2["default"].PropTypes.number,
1294712947 icon: _react2["default"].PropTypes.string,
12948+ isOpen: _react2["default"].PropTypes.bool,
1294812949 onDismiss: _react2["default"].PropTypes.func,
1294912950 texture: _react2["default"].PropTypes.bool,
1295012951 theme: _react2["default"].PropTypes.oneOf(["success", "warning", "error", "offline"]),
1295112952 variant: _react2["default"].PropTypes.oneOf(["alert", "toast"])
1295212953 };
1295312954
1295412955 var defaultProps = {
12955- dismissible: true
12956+ dismissible: true,
12957+ isOpen: false
1295612958 };
1295712959
1295812960 var SLDSNotification = (function (_React$Component) {
@@ -12962,21 +12964,41 @@ return /******/ (function(modules) { // webpackBootstrap
1296212964 _classCallCheck(this, SLDSNotification);
1296312965
1296412966 _get(Object.getPrototypeOf(SLDSNotification.prototype), "constructor", this).call(this, props);
12965- this.state = { isOpen: true };
12967+ this.state = {
12968+ interval: null,
12969+ revealForScreenreader: false
12970+ };
1296612971 }
1296712972
1296812973 _createClass(SLDSNotification, [{
1296912974 key: "componentDidMount",
1297012975 value: function componentDidMount() {
12976+ if (this.props.duration) {
12977+ var that = this;
12978+ setTimeout(function () {
12979+ this.onDismiss();
12980+ }, that.props.duration);
12981+ }
12982+ }
12983+ }, {
12984+ key: "componentWillUnmount",
12985+ value: function componentWillUnmount() {
12986+ this.setState({
12987+ interval: null
12988+ });
12989+ }
12990+ }, {
12991+ key: "componentWillReceiveProps",
12992+ value: function componentWillReceiveProps(nextProps) {
1297112993 var _this = this;
1297212994
12973- if (this.props.duration ) {
12974- (function ( ) {
12975- var that = _this;
12976- setTimeout(function () {
12977- that.setState({ isOpen: false });
12978- }, that.props.duration);
12979- })( );
12995+ if (this.props.isOpen !== nextProps.isOpen ) {
12996+ if (nextProps.isOpen && !this.state.interval ) {
12997+ this.setState({ interval: setTimeout(function () {
12998+ _this.setState({ revealForScreenreader: true });
12999+ }, 500) });
13000+ }
13001+ console.log('revealForScreen', this.state.revealForScreenreader );
1298013002 }
1298113003 }
1298213004 }, {
@@ -13017,7 +13039,10 @@ return /******/ (function(modules) { // webpackBootstrap
1301713039 key: "onDismiss",
1301813040 value: function onDismiss() {
1301913041 if (this.props.onDismiss) this.props.onDismiss();
13020- this.setState({ isOpen: false });
13042+ this.setState({
13043+ revealForScreenreader: false,
13044+ interval: null
13045+ });
1302113046 }
1302213047 }, {
1302313048 key: "renderAlertContent",
@@ -13038,13 +13063,22 @@ return /******/ (function(modules) { // webpackBootstrap
1303813063 value: function getClassName() {
1303913064 var _classNames;
1304013065
13041- return classNames(this.props.className, "slds-notify", (_classNames = {}, _defineProperty(_classNames, "slds-notify--" + this.props.variant, this.props.variant), _defineProperty(_classNames, "slds-theme--" + this.props.theme, this.props.theme), _defineProperty(_classNames, "slds-theme--alert-texture-animated", this.props.texture), _classNames));
13066+ return classNames(this.props.className, "slds-notify", (_classNames = {}, _defineProperty(_classNames, "slds-transition-hide", !this.state.revealForScreenreader), _defineProperty(_classNames, "slds-notify--" + this.props.variant, this.props.variant), _defineProperty(_classNames, "slds-theme--" + this.props.theme, this.props.theme), _defineProperty(_classNames, "slds-theme--alert-texture-animated", this.props.texture), _classNames));
13067+ }
13068+ }, {
13069+ key: "renderContent",
13070+ value: function renderContent() {
13071+ if (this.state.revealForScreenreader) {
13072+ return _react2["default"].createElement("div", null, _react2["default"].createElement("p", { ref: "test", className: "slds-assistive-text" }, this.props.theme), this.renderClose(), this.renderAlertContent(), this.renderToastContent());
13073+ } else {
13074+ return _react2["default"].createElement("div", { className: "slds-hidden" }, "Notification loading");
13075+ }
1304213076 }
1304313077 }, {
1304413078 key: "render",
1304513079 value: function render() {
13046- if (this.state .isOpen) {
13047- return _react2["default"].createElement("div", { className: "slds-notify-container" }, _react2["default"].createElement("div", { className: this.getClassName(), role: "alert" }, _react2["default"].createElement("span", { className: "slds-assistive-text" }, this.props.theme), this.renderClose(), this.renderAlertContent(), this.renderToastContent ()));
13080+ if (this.props .isOpen) {
13081+ return _react2["default"].createElement("div", { className: "slds-notify-container" }, _react2["default"].createElement("div", { ref: "alertContent", className: this.getClassName(), role: "alert" }, this.renderContent ()));
1304813082 } else {
1304913083 return null;
1305013084 }
0 commit comments