{"version":3,"sources":["components/file-uploader/file-uploader-item.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAiC,UAAU,EAAE,MAAM,aAAa,CAAC;AAMxE,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAC;AAG3E,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,CAAC;AAI7D;;;;;;;;;GASG;AACH,cACM,kBAAmB,SAAQ,UAAU;IACzC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAYhC;;OAEG;IACH,OAAO,CAAC,cAAc;IAUtB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAKxB;;OAEG;IACH,OAAO,CAAC,eAAe;IAQvB;;OAEG;IACH,OAAO,CAAC,aAAa;IAcrB;;OAEG;IAEH,mBAAmB,SAAsB;IAEzC;;OAEG;IAEH,OAAO,UAAS;IAEhB;;OAEG;IAEH,IAAI,0BAAmC;IAEvC;;OAEG;IAEH,KAAK,2BAAsC;IAE3C;;OAEG;IAEH,sBAAsB,SAAe;IAErC;;OAEG;IAEH,qBAAqB,SAAc;IAEnC;;OAEG;IAEH,eAAe,SAAM;IAErB,MAAM;IAgBN;;;OAGG;IACH,MAAM,KAAK,iBAAiB,WAE3B;IAED;;OAEG;IACH,MAAM,KAAK,WAAW,WAErB;IAED,MAAM,CAAC,MAAM,MAAU;CACxB;AAED,eAAe,kBAAkB,CAAC","file":"file-uploader-item.d.ts","sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2020, 2022\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 CheckmarkFilled16 from '@carbon/icons/lib/checkmark--filled/16';\nimport Close16 from '@carbon/icons/lib/close/16';\nimport WarningFilled16 from '@carbon/icons/lib/warning--filled/16';\nimport settings from 'carbon-components/es/globals/js/settings';\nimport { LOADING_TYPE } from '../loading/loading';\nimport { FILE_UPLOADER_ITEM_SIZE, FILE_UPLOADER_ITEM_STATE } from './defs';\nimport styles from './file-uploader.scss';\n\nexport { FILE_UPLOADER_ITEM_SIZE, FILE_UPLOADER_ITEM_STATE };\n\nconst { prefix } = settings;\n\n/**\n * File uploader item.\n * @element bx-file-uploader-item\n * @slot validity-message The validity message.\n * @slot validity-message-supplement The supplemental validity message.\n * @fires bx-file-uploader-item-beingdeleted\n *   The custom event fired before this file uploader item is being deleted upon a user gesture.\n *   Cancellation of this event stops the user-initiated action of deleting this file uploader item.\n * @fires bx-file-uploader-item-deleted - The custom event fired after this file uploader item is deleted upon a user gesture.\n */\n@customElement(`${prefix}-file-uploader-item`)\nclass BXFileUploaderItem extends LitElement {\n  /**\n   * Handles `click` event on the delete button.\n   */\n  private _handleClickDeleteButton() {\n    const init = {\n      bubbles: true,\n      cancelable: true,\n      composed: true,\n    };\n    const { eventBeforeDelete, eventDelete } = this.constructor as typeof BXFileUploaderItem;\n    if (this.dispatchEvent(new CustomEvent(eventBeforeDelete, init))) {\n      this.dispatchEvent(new CustomEvent(eventDelete, init));\n    }\n  }\n\n  /**\n   * @returns The content showing the editing UI of this file uploader item.\n   */\n  private _renderEditing() {\n    const { deleteAssistiveText, invalid, _handleClickDeleteButton: handleClickDeleteButton } = this;\n    return html`\n      ${!invalid ? undefined : WarningFilled16({ class: `${prefix}--file-invalid` })}\n      <button type=\"button\" aria-label=\"${deleteAssistiveText}\" class=\"${prefix}--file-close\" @click=\"${handleClickDeleteButton}\">\n        ${Close16()}\n      </button>\n    `;\n  }\n\n  /**\n   * @returns The content showing this file uploader's file uploading status as in progress.\n   */\n  private _renderUploading() {\n    const { uploadingAssistiveText } = this;\n    return html` <bx-loading assistive-text=\"${uploadingAssistiveText}\" type=\"${LOADING_TYPE.SMALL}\"></bx-loading> `;\n  }\n\n  /**\n   * @returns The content showing this file uploader's file uploading status as complete.\n   */\n  private _renderUploaded() {\n    const { uploadedAssistiveText } = this;\n    return CheckmarkFilled16({\n      class: `${prefix}--file-complete`,\n      'aria-label': uploadedAssistiveText,\n    });\n  }\n\n  /**\n   * @returns The content showing this file uploader's status.\n   */\n  private _renderStatus() {\n    const { state } = this;\n    switch (state) {\n      case FILE_UPLOADER_ITEM_STATE.EDITING:\n        return this._renderEditing();\n      case FILE_UPLOADER_ITEM_STATE.UPLOADING:\n        return this._renderUploading();\n      case FILE_UPLOADER_ITEM_STATE.UPLOADED:\n        return this._renderUploaded();\n      default:\n        return undefined;\n    }\n  }\n\n  /**\n   * The `aria-label` attribute for the icon to delete this file uploader item.\n   */\n  @property({ attribute: 'delete-assistive-text' })\n  deleteAssistiveText = 'Delete this file';\n\n  /**\n   * Controls the invalid state and visibility of the `validityMessage`.\n   */\n  @property({ type: Boolean, reflect: true })\n  invalid = false;\n\n  /**\n   * The size of this file uploader item.\n   */\n  @property({ reflect: true })\n  size = FILE_UPLOADER_ITEM_SIZE.REGULAR;\n\n  /**\n   * The state of this file uploader item.\n   */\n  @property({ reflect: true })\n  state = FILE_UPLOADER_ITEM_STATE.UPLOADING;\n\n  /**\n   * The `aria-label` attribute for the icon to indicate file uploading is in progress.\n   */\n  @property({ attribute: 'uploading-assistive-text' })\n  uploadingAssistiveText = 'Uploading';\n\n  /**\n   * The `aria-label` attribute for the icon to indicate file uploading is complete.\n   */\n  @property({ attribute: 'uploaded-assistive-text' })\n  uploadedAssistiveText = 'Uploaded';\n\n  /**\n   * The validity message.\n   */\n  @property({ attribute: 'validity-message' })\n  validityMessage = '';\n\n  render() {\n    const { validityMessage } = this;\n    return html`\n      <p class=\"${prefix}--file-filename\"><slot></slot></p>\n      <span class=\"${prefix}--file__state-container\">${this._renderStatus()}</span>\n      <div class=\"${prefix}--form-requirement\">\n        <div class=\"${prefix}--form-requirement__title\">\n          <slot name=\"validity-message\">${validityMessage}</slot>\n        </div>\n        <p class=\"${prefix}--form-requirement__supplement\">\n          <slot name=\"validity-message-supplement\"></slot>\n        </p>\n      </div>\n    `;\n  }\n\n  /**\n   * The name of the custom event fired before this file uplodaer item is being deleted upon a user gesture.\n   * Cancellation of this event stops the user-initiated action of deleting this file uploader item.\n   */\n  static get eventBeforeDelete() {\n    return `${prefix}-file-uploader-item-beingdeleted`;\n  }\n\n  /**\n   * The name of the custom event fired after this file uplodaer item is deleted upon a user gesture.\n   */\n  static get eventDelete() {\n    return `${prefix}-file-uploader-item-deleted`;\n  }\n\n  static styles = styles;\n}\n\nexport default BXFileUploaderItem;\n"]}