UNPKG

carbon-custom-elements

Version:

A Carbon Design System variant that's as easy to use as native HTML elements, with no framework tax, no framework silo.

1 lines 1.69 kB
{"version":3,"sources":["components/list/unordered-list.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAuB,UAAU,EAAE,MAAM,aAAa,CAAC;AAM9D;;GAEG;AACH,cACM,eAAgB,SAAQ,UAAU;IACtC,iBAAiB;IAUjB,MAAM;IAYN;;OAEG;IACH,MAAM,KAAK,gBAAgB,WAE1B;IAED,MAAM,CAAC,MAAM,MAAU;CACxB;AAED,eAAe,eAAe,CAAC","file":"unordered-list.d.ts","sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2019\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { classMap } from 'lit-html/directives/class-map';\nimport { html, customElement, LitElement } from 'lit-element';\nimport settings from 'carbon-components/es/globals/js/settings';\nimport styles from './list.scss';\n\nconst { prefix } = settings;\n\n/**\n * Ordered list.\n */\n@customElement(`${prefix}-unordered-list`)\nclass BXUnorderedList extends LitElement {\n connectedCallback() {\n // Uses attribute for lookup from child\n if (this.closest((this.constructor as typeof BXUnorderedList).selectorListItem)) {\n this.setAttribute('slot', 'nested');\n } else {\n this.removeAttribute('slot');\n }\n super.connectedCallback();\n }\n\n render() {\n const classes = classMap({\n [`${prefix}--list--unordered`]: true,\n [`${prefix}--list--nested`]: this.getAttribute('slot') === 'nested',\n });\n return html`\n <ul class=\"${classes}\">\n <slot></slot>\n </ul>\n `;\n }\n\n /**\n * A selector that will return list item.\n */\n static get selectorListItem() {\n return `${prefix}-list-item`;\n }\n\n static styles = styles;\n}\n\nexport default BXUnorderedList;\n"]}