Skip to content

Commit

Permalink
feat(menu,base): annotate mdc-menu for closure compiler (material-com…
Browse files Browse the repository at this point in the history
…ponents#339)

Added new annotations to mdc-menu. Corrected a couple of annotations in base.
  • Loading branch information
bogusred committed Jun 16, 2017
1 parent 7c6da3a commit 98a82e7
Show file tree
Hide file tree
Showing 7 changed files with 323 additions and 62 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
},
"closureWhitelist": [
"mdc-animation",
"mdc-base"
"mdc-base",
"mdc-menu"
]
}
4 changes: 2 additions & 2 deletions packages/mdc-base/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class MDCComponent {
* @param {...?} args
*/
constructor(root, foundation = undefined, ...args) {
/** @private {!Element} */
/** @protected {!Element} */
this.root_ = root;
this.initialize(...args);
// Note that we initialize foundation here and not within the constructor's default param so that
Expand Down Expand Up @@ -104,7 +104,7 @@ export default class MDCComponent {
* with the given data.
* @param {string} evtType
* @param {!Object} evtData
* @param {boolean} shouldBubble
* @param {boolean=} shouldBubble
*/
emit(evtType, evtData, shouldBubble = false) {
let evt;
Expand Down
127 changes: 127 additions & 0 deletions packages/mdc-menu/simple/adapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/**
* Provides type information for the adapter to the Closure compiler.
* @record
*/
export default class MDCSimpleMenuAdapter {
/** @param {string} className */
addClass(className) {}

/** @param {string} className */
removeClass(className) {}

/**
* @param {string} className
* @return {boolean}
*/
hasClass(className) {}

/** @return {boolean} */
hasNecessaryDom() {}

/**
* @param {EventTarget} target
* @param {string} attributeName
* @return {string}
*/
getAttributeForEventTarget(target, attributeName) {}

/** @return {{ width: number, height: number }} */
getInnerDimensions() {}

/** @return {boolean} */
hasAnchor() {}

/** @return {{width: number, height: number, top: number, right: number, bottom: number, left: number}} */
getAnchorDimensions() {}

/** @return {{ width: number, height: number }} */
getWindowDimensions() {}

/**
* @param {number} x
* @param {number} y
*/
setScale(x, y) {}

/**
* @param {number} x
* @param {number} y
*/
setInnerScale(x, y) {}

/** @return {number} */
getNumberOfItems() {}

/**
* @param {string} type
* @param {function(!Event)} handler
*/
registerInteractionHandler(type, handler) {}

/**
* @param {string} type
* @param {function(!Event)} handler
*/
deregisterInteractionHandler(type, handler) {}

/** @param {function(!Event)} handler */
registerBodyClickHandler(handler) {}

/** @param {function(!Event)} handler */
deregisterBodyClickHandler(handler) {}

/**
* @param {number} index
* @return {{top: number, height: number}}
*/
getYParamsForItemAtIndex(index) {}

/**
* @param {number} index
* @param {string|null} value
*/
setTransitionDelayForItemAtIndex(index, value) {}

/**
* @param {EventTarget} target
* @return {number}
*/
getIndexForEventTarget(target) {}

/** @param {{index: number}} evtData */
notifySelected(evtData) {}

notifyCancel() {}

saveFocus() {}

restoreFocus() {}

/** @return {boolean} */
isFocused() {}

focus() {}

/** @return {number} */
getFocusedItemIndex() /* number */ {}

/** @param {number} index */
focusItemAtIndex(index) {}

/** @return {boolean} */
isRtl() {}

/** @param {string} origin */
setTransformOrigin(origin) {}

/** @param {{
* top: (string|undefined),
* right: (string|undefined),
* bottom: (string|undefined),
* left: (string|undefined)
* }} position */
setPosition(position) {}

/** @return {number} */
getAccurateTime() {}
}
4 changes: 4 additions & 0 deletions packages/mdc-menu/simple/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/** @enum {string} */
export const cssClasses = {
ROOT: 'mdc-simple-menu',
OPEN: 'mdc-simple-menu--open',
Expand All @@ -22,13 +24,15 @@ export const cssClasses = {
BOTTOM_RIGHT: 'mdc-simple-menu--open-from-bottom-right',
};

/** @enum {string} */
export const strings = {
ITEMS_SELECTOR: '.mdc-simple-menu__items',
SELECTED_EVENT: 'MDCSimpleMenu:selected',
CANCEL_EVENT: 'MDCSimpleMenu:cancel',
ARIA_DISABLED_ATTR: 'aria-disabled',
};

/** @enum {number} */
export const numbers = {
// Amount of time to wait before triggering a selected event on the menu. Note that this time
// will most likely be bumped up once interactive lists are supported to allow for the ripple to
Expand Down
Loading

0 comments on commit 98a82e7

Please sign in to comment.