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 • 2.03 kB
Source Map (JSON)
{"version":3,"sources":["components/loading/loading.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAiC,UAAU,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,YAAY,MAAM,SAAS,CAAC;AAMnC;;;GAGG;AACH,cACM,SAAU,SAAQ,UAAU;IAChC;;OAEG;IAEH,aAAa,SAAa;IAE1B;;OAEG;IAEH,IAAI,eAAwB;IAE5B;;OAEG;IAEH,QAAQ,UAAS;IAEjB,MAAM;IAcN,MAAM,CAAC,MAAM,MAAU;CACxB;AAED,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,eAAe,SAAS,CAAC","file":"loading.d.ts","sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2019, 2020\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 settings from 'carbon-components/es/globals/js/settings';\nimport { classMap } from 'lit-html/directives/class-map';\nimport { html, property, customElement, LitElement } from 'lit-element';\nimport LOADING_TYPE from './types';\nimport getLoadingIcon from './loading-icon';\nimport styles from './loading.scss';\n\nconst { prefix } = settings;\n\n/**\n * Spinner indicating loading state.\n * @element bx-loading\n */\n@customElement(`${prefix}-loading`)\nclass BXLoading extends LitElement {\n /**\n * The assistive text for the spinner icon.\n */\n @property({ attribute: 'assistive-text' })\n assistiveText = 'Loading';\n\n /**\n * Spinner type.\n */\n @property()\n type = LOADING_TYPE.REGULAR;\n\n /**\n * `true` if spinner should stop.\n */\n @property({ type: Boolean, reflect: true })\n inactive = false;\n\n render() {\n const { inactive, assistiveText, type } = this;\n const innerClasses = classMap({\n [`${prefix}--loading`]: true,\n [`${prefix}--loading--stop`]: inactive,\n });\n const icon = getLoadingIcon({ assistiveText, type });\n return type !== LOADING_TYPE.OVERLAY\n ? icon\n : html`\n <div class=\"${innerClasses}\">${icon}</div>\n `;\n }\n\n static styles = styles; // `styles` here is a `CSSResult` generated by custom WebPack loader\n}\n\nexport { LOADING_TYPE };\n\nexport default BXLoading;\n"]}