How to use @material/list - 10 common examples

To help you get started, we’ve selected a few @material/list examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SpringflowNL / aurelia-mdc-elements / node_modules / @material / drawer / component.js View on Github external
focusActiveNavigationItem: function () {
                var activeNavItemEl = _this.root_.querySelector("." + MDCListFoundation.cssClasses.LIST_ITEM_ACTIVATED_CLASS);
                if (activeNavItemEl) {
                    activeNavItemEl.focus();
                }
            },
            notifyClose: function () { return _this.emit(strings.CLOSE_EVENT, {}, true /* shouldBubble */); },
github material-components / material-components-web / packages / mdc-menu / foundation.js View on Github external
getListItem_(target) {
    let isListItem = this.adapter_.elementContainsClass(target, MDCListFoundation.cssClasses.LIST_ITEM_CLASS);

    while (!isListItem) {
      target = this.adapter_.getParentElement(target);
      if (target) {
        isListItem = this.adapter_.elementContainsClass(target, MDCListFoundation.cssClasses.LIST_ITEM_CLASS);
      } else { // target has no parent element.
        return null;
      }
    }

    return target;
  }
github material-components / material-components-web / packages / mdc-menu / foundation.js View on Github external
getSelectionGroup_(listItem) {
    let parent = this.adapter_.getParentElement(listItem);
    let isGroup = this.adapter_.elementContainsClass(parent, cssClasses.MENU_SELECTION_GROUP);

    // Iterate through ancestors until we find the group or get to the list.
    while (!isGroup && !this.adapter_.elementContainsClass(parent, MDCListFoundation.cssClasses.ROOT)) {
      parent = this.adapter_.getParentElement(listItem);
      isGroup = this.adapter_.elementContainsClass(parent, cssClasses.MENU_SELECTION_GROUP);
    }

    if (isGroup) {
      return parent;
    } else {
      return null;
    }
  }
github material-components / material-components-web / packages / mdc-menu / foundation.js View on Github external
getListItem_(target) {
    let isListItem = this.adapter_.elementContainsClass(target, MDCListFoundation.cssClasses.LIST_ITEM_CLASS);

    while (!isListItem) {
      target = this.adapter_.getParentElement(target);
      if (target) {
        isListItem = this.adapter_.elementContainsClass(target, MDCListFoundation.cssClasses.LIST_ITEM_CLASS);
      } else { // target has no parent element.
        return null;
      }
    }

    return target;
  }
github Tencent / omi / packages / omim / src / list / index.tsx View on Github external
lists.forEach((list, index) => {
        const listControl = new MDCList(list)
        listControl.listElements.map((listItemEl) => new MDCRipple(listItemEl))
        listControl.singleSelection = this.props.singleSelection
        listControl.listen('MDCList:action', (evt: any) => {
          this.fire('itemclick', { item: this.props.items[evt.detail.index], index: evt.detail.index })
          // if(this.listAll[index][evt.detail.index]) {
          //   this.fire('change', this.listAll[index][evt.detail.index])
          // } else {
          //   this.fire('change', this.listAll[index+1][evt.detail.index])
          // }
        })
      })
    })
github jamesmfriedman / rmwc / src / list / list.tsx View on Github external
getListItemIndex(
    evt: React.FocusEvent | React.KeyboardEvent | React.MouseEvent
  ) {
    let eventTarget = evt.target as HTMLElement | null;
    let index = -1;

    // Find the first ancestor that is a list item or the list.
    while (
      eventTarget &&
      !eventTarget.classList.contains(
        MDCListFoundation.cssClasses.LIST_ITEM_CLASS
      ) &&
      !eventTarget.classList.contains(MDCListFoundation.cssClasses.ROOT)
    ) {
      eventTarget = eventTarget.parentElement as HTMLLIElement;
    }

    // Get the index of the element if it is a list item.
    if (
      eventTarget &&
      eventTarget.classList.contains(
        MDCListFoundation.cssClasses.LIST_ITEM_CLASS
      )
    ) {
      index = this.listElements.indexOf(eventTarget as HTMLLIElement);
    }
github jamesmfriedman / rmwc / src / list / list.tsx View on Github external
// Find the first ancestor that is a list item or the list.
    while (
      eventTarget &&
      !eventTarget.classList.contains(
        MDCListFoundation.cssClasses.LIST_ITEM_CLASS
      ) &&
      !eventTarget.classList.contains(MDCListFoundation.cssClasses.ROOT)
    ) {
      eventTarget = eventTarget.parentElement as HTMLLIElement;
    }

    // Get the index of the element if it is a list item.
    if (
      eventTarget &&
      eventTarget.classList.contains(
        MDCListFoundation.cssClasses.LIST_ITEM_CLASS
      )
    ) {
      index = this.listElements.indexOf(eventTarget as HTMLLIElement);
    }

    return index;
  }
github jamesmfriedman / rmwc / src / list / foundation.tsx View on Github external
(evt: React.MouseEvent) => {
      props.onClick?.(evt);

      const index = getListItemIndex(evt);

      // Toggle the checkbox only if it's not the target of the event, or the checkbox will have 2 change events.
      const toggleCheckbox = !matches(
        evt.target as HTMLElement,
        MDCListFoundation.strings.CHECKBOX_RADIO_SELECTOR
      );

      foundation.handleClick(index, toggleCheckbox);
    },
    [getListItemIndex, foundation, props.onClick]
github jamesmfriedman / rmwc / src / list / list.tsx View on Github external
handleClick(evt: React.MouseEvent) {
    this.props.onClick && this.props.onClick(evt);

    const index = this.getListItemIndex(evt);

    // Toggle the checkbox only if it's not the target of the event, or the checkbox will have 2 change events.
    const toggleCheckbox = !matches(
      evt.target as HTMLElement,
      MDCListFoundation.strings.CHECKBOX_RADIO_SELECTOR
    );

    this.foundation.handleClick(index, toggleCheckbox);
  }
github jamesmfriedman / rmwc / src / list / list.tsx View on Github external
getDefaultFoundation() {
    return new MDCListFoundation(
      /** @type {!MDCListAdapter} */ (Object.assign({
        getListItemCount: () => this.listElements.length,
        getFocusedElementIndex: () =>
          this.listElements.indexOf(document.activeElement as HTMLLIElement),
        setAttributeForElementIndex: (
          index: number,
          attr: string,
          value: string | number
        ) => {
          // This value is getting set and never getting set back
          // This is causing list items to be un-tabbable
          if (attr === 'tabindex' && value === -1) {
            return;
          }

          const element = this.listElements[index];