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.97 kB
Source Map (JSON)
{"version":3,"sources":["components/data-table/table-batch-actions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAiC,UAAU,EAAE,MAAM,aAAa,CAAC;AAMxE;;;;GAIG;AACH,cACM,mBAAoB,SAAQ,UAAU;IAC1C;;OAEG;IACH,OAAO,CAAC,aAAa;IAKrB;;OAEG;IAEH,MAAM,UAAS;IAEf;;OAEG;IAEH,wBAAwB;;iBAAmE;IAE3F;;;OAGG;IAEH,iBAAiB,SAAK;IAEtB,MAAM;IAiBN;;OAEG;IACH,MAAM,KAAK,gBAAgB,WAE1B;IAED,MAAM,CAAC,MAAM,MAAU;CACxB;AAED,eAAe,mBAAmB,CAAC","file":"table-batch-actions.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 { html, property, customElement, LitElement } from 'lit-element';\nimport settings from 'carbon-components/es/globals/js/settings';\nimport styles from './data-table.scss';\n\nconst { prefix } = settings;\n\n/**\n * Table batch actions.\n * @element bx-table-batch-actions\n * @fires bx-table-batch-actions-cancel-clicked - The custom event fired after the Cancel button is clicked.\n */\n@customElement(`${prefix}-table-batch-actions`)\nclass BXTableBatchActions extends LitElement {\n /**\n * Handles `click` event on the Cancel button.\n */\n private _handleCancel() {\n const { eventClickCancel } = this.constructor as typeof BXTableBatchActions;\n this.dispatchEvent(new CustomEvent(eventClickCancel, { bubbles: true, composed: true }));\n }\n\n /**\n * `true` if this batch actions bar should be active.\n */\n @property({ type: Boolean, reflect: true })\n active = false;\n\n /**\n * The formatter for selected items. Should be changed upon the locale the UI is rendered with.\n */\n @property({ attribute: false })\n formatSelectedItemsCount = ({ count }) => `${count} item${count <= 1 ? '' : 's'} selected`;\n\n /**\n * Numeric representation of the total number of items selected in a table.\n * This number is used to derive the selection message.\n */\n @property({ type: Number, attribute: 'selected-rows-count' })\n selectedRowsCount = 0;\n\n render() {\n const { formatSelectedItemsCount, selectedRowsCount, _handleCancel: handleCancel } = this;\n return html`\n <div class=\"${prefix}--action-list\">\n <slot></slot>\n <button class=\"${prefix}--btn ${prefix}--btn--primary ${prefix}--batch-summary__cancel\" @click=${handleCancel}>\n <slot name=\"cancel-button-content\">Cancel</slot>\n </button>\n </div>\n <div class=\"${prefix}--batch-summary\">\n <p class=\"${prefix}--batch-summary__para\">\n ${formatSelectedItemsCount({ count: selectedRowsCount })}\n </p>\n </div>\n `;\n }\n\n /**\n * The name of the custom event fired after the Cancel button is clicked.\n */\n static get eventClickCancel() {\n return `${prefix}-table-batch-actions-cancel-clicked`;\n }\n\n static styles = styles;\n}\n\nexport default BXTableBatchActions;\n"]}