/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-env browser */ "use strict";
// A list of menu items. // // This component provides keyboard navigation amongst any focusable // children.
class MenuList extends PureComponent { static get propTypes() { return { // ID to assign to the list container.
id: PropTypes.string,
// Children of the list.
children: PropTypes.any,
// Called whenever there is a change to the hovered or selected child. // The callback is passed the ID of the highlighted child or null if no // child is highlighted.
onHighlightedChildChange: PropTypes.func,
};
}
notifyHighlightedChildChange(id) { if (this.props.onHighlightedChildChange) { this.props.onHighlightedChildChange(id);
}
}
onKeyDown(e) { // Check if the focus is in the list. if (
!this.wrapperRef ||
!this.wrapperRef.contains(e.target.ownerDocument.activeElement)
) { return;
}
// Add padding for checkbox image if necessary.
let hasCheckbox = false;
Children.forEach(this.props.children, (child, i) => { if (child == null || typeof child == "undefined") {
console.warn("MenuList children at index", i, "is", child); return;
}
if (typeof child?.props?.checked !== "undefined") {
hasCheckbox = true;
}
}); if (hasCheckbox) {
attr.className = "checkbox-container menu-standard-padding";
}
return div(attr, this.props.children);
}
}
module.exports = MenuList;
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.11Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.