@department-of-veterans-affairs/component-library 51.3.0 → 51.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Modal.js +1 -1
- package/README.md +1 -1
- package/contacts.js +1 -1
- package/dist/12.app.bundle.js +1 -1
- package/dist/2205.app.bundle.js +1 -1
- package/dist/2236.app.bundle.js +1 -1
- package/dist/272.app.bundle.js +1 -1
- package/dist/2923.app.bundle.js +1 -1
- package/dist/3589.app.bundle.js +1 -1
- package/dist/4780.app.bundle.js +1 -1
- package/dist/5341.app.bundle.js +1 -1
- package/dist/5663.app.bundle.js +1 -1
- package/dist/606.app.bundle.js +1 -1
- package/dist/6555.app.bundle.js +1 -1
- package/dist/6650.app.bundle.js +1 -1
- package/dist/6696.app.bundle.js +1 -1
- package/dist/7166.app.bundle.js +1 -1
- package/dist/7372.app.bundle.js +1 -1
- package/dist/{7747.app.bundle.js → 7731.app.bundle.js} +1 -1
- package/dist/8255.app.bundle.js +1 -1
- package/dist/8913.app.bundle.js +1 -1
- package/dist/9496.app.bundle.js +1 -1
- package/dist/app.bundle.js +1 -1
- package/dist/components/i18n-setup.js +1 -1
- package/dist/components/i18next.js +1 -1
- package/dist/components/va-file-input-multiple.js +1 -1
- package/dist/components/va-file-input2.js +1 -1
- package/dist/components/va-on-this-page.js +1 -1
- package/dist/components/va-sidenav.js +1 -1
- package/format-date.js +1 -1
- package/package.json +2 -3
- package/test-helpers.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{proxyCustomElement,HTMLElement,createEvent,h,forceUpdate,Host,Fragment}from"@stencil/core/internal/client";import"./i18n-setup.js";import"./contacts.js";import{s as selectOrMatches,S as Sanitizer}from"./utils.js";import{d as defineCustomElement$7}from"./va-button2.js";import{d as defineCustomElement$6}from"./va-button-icon2.js";import{d as defineCustomElement$5}from"./va-card2.js";import{d as defineCustomElement$4}from"./va-icon2.js";import{d as defineCustomElement$3}from"./va-modal2.js";import{d as defineCustomElement$2}from"./va-progress-bar2.js";import{d as defineCustomElement$1}from"./va-text-input2.js";import{i as instance}from"./i18next.js";const PREFIX="usa",DROPZONE_CLASS="usa-file-input",DROPZONE=`.${DROPZONE_CLASS}`,INPUT_CLASS="usa-file-input__input",TARGET_CLASS="usa-file-input__target",INPUT=`.${INPUT_CLASS}`,BOX_CLASS="usa-file-input__box",INSTRUCTIONS_CLASS="usa-file-input__instructions",PREVIEW_CLASS="usa-file-input__preview",PREVIEW_HEADING_CLASS="usa-file-input__preview-heading",DISABLED_CLASS="usa-file-input--disabled",CHOOSE_CLASS="usa-file-input__choose",ACCEPTED_FILE_MESSAGE_CLASS="usa-file-input__accepted-files-message",DRAG_TEXT_CLASS="usa-file-input__drag-text",DRAG_CLASS="usa-file-input--drag",LOADING_CLASS="is-loading",INVALID_FILE_CLASS="has-invalid-file",GENERIC_PREVIEW_CLASS_NAME="usa-file-input__preview-image",GENERIC_PREVIEW_CLASS=`${GENERIC_PREVIEW_CLASS_NAME}--generic`,PDF_PREVIEW_CLASS=`${GENERIC_PREVIEW_CLASS_NAME}--pdf`,WORD_PREVIEW_CLASS=`${GENERIC_PREVIEW_CLASS_NAME}--word`,VIDEO_PREVIEW_CLASS=`${GENERIC_PREVIEW_CLASS_NAME}--video`,EXCEL_PREVIEW_CLASS=`${GENERIC_PREVIEW_CLASS_NAME}--excel`,SR_ONLY_CLASS="usa-sr-only",SPACER_GIF="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";let TYPE_IS_VALID=Boolean(!0),DEFAULT_ARIA_LABEL_TEXT="",DEFAULT_FILE_STATUS_TEXT="";const getFileInputContext=e=>{const t=e.closest(DROPZONE);if(!t)throw new Error(`Element is missing outer ${DROPZONE}`);const i=t.querySelector(INPUT);return{dropZoneEl:t,inputEl:i}},disable=e=>{const{dropZoneEl:t,inputEl:i}=getFileInputContext(e);i.disabled=!0,t.classList.add(DISABLED_CLASS)},ariaDisable=e=>{const{dropZoneEl:t}=getFileInputContext(e);t.classList.add(DISABLED_CLASS)},enable=e=>{const{dropZoneEl:t,inputEl:i}=getFileInputContext(e);i.disabled=!1,t.classList.remove(DISABLED_CLASS),t.removeAttribute("aria-disabled")},replaceName=e=>{const t=e.charCodeAt(0);return 32===t?"-":t>=65&&t<=90?`img_${e.toLowerCase()}`:`__000${t.toString(16).slice(-4)}`},makeSafeForID=e=>e.replace(/[^a-z0-9]/g,replaceName),createUniqueID=e=>`${e}-${Math.floor(Date.now()/1e3)}`,getItemsLabel=e=>e.hasAttribute("multiple")?"files":"file",createTargetArea=e=>{const t=document.createElement("div"),i=document.createElement("div"),a=document.createElement("div");return e.classList.remove(DROPZONE_CLASS),e.classList.add(INPUT_CLASS),t.classList.add(DROPZONE_CLASS),a.classList.add(BOX_CLASS),i.classList.add(TARGET_CLASS),i.prepend(a),e.parentNode.insertBefore(i,e),e.parentNode.insertBefore(t,i),i.appendChild(e),t.appendChild(i),i},createVisibleInstructions=e=>{const t=e.closest(DROPZONE),i=getItemsLabel(e),a=document.createElement("div"),s=`Drag ${i} here or`,r="choose from folder";return DEFAULT_ARIA_LABEL_TEXT=`${s} ${r}`,a.classList.add(INSTRUCTIONS_CLASS),a.setAttribute("aria-hidden","true"),e.setAttribute("aria-label",DEFAULT_ARIA_LABEL_TEXT),a.innerHTML=Sanitizer.escapeHTML(`<span class="${DRAG_TEXT_CLASS}">${s}</span> <span class="${CHOOSE_CLASS}">${r}</span>`),e.parentNode.insertBefore(a,e),(/rv:11.0/i.test(navigator.userAgent)||/Edge\/\d./i.test(navigator.userAgent))&&(t.querySelector(`.${DRAG_TEXT_CLASS}`).outerHTML=""),a},createSROnlyStatus=e=>{const t=document.createElement("div"),i=getItemsLabel(e),a=e.closest(DROPZONE),s=e.closest(`.${TARGET_CLASS}`);DEFAULT_FILE_STATUS_TEXT=`No ${i} selected.`,t.classList.add("usa-sr-only"),t.setAttribute("aria-live","polite"),t.textContent=DEFAULT_FILE_STATUS_TEXT,a.insertBefore(t,s)},enhanceFileInput=e=>{const t=e.hasAttribute("aria-disabled")||e.hasAttribute("disabled"),i=createTargetArea(e),a=createVisibleInstructions(e),{dropZoneEl:s}=getFileInputContext(e);return t?s.classList.add(DISABLED_CLASS):createSROnlyStatus(e),{instructions:a,dropTarget:i}},removeOldPreviews=(e,t)=>{const i=e.querySelectorAll(`.${PREVIEW_CLASS}`),a=e.querySelector(`.${PREVIEW_HEADING_CLASS}`),s=e.querySelector(`.${ACCEPTED_FILE_MESSAGE_CLASS}`);a&&(a.outerHTML=""),s&&(s.outerHTML="",e.classList.remove("has-invalid-file")),null!==i&&(t&&t.removeAttribute("hidden"),Array.prototype.forEach.call(i,(e=>{e.parentNode.removeChild(e)})))},updateStatusMessage=(e,t,i)=>{const a=e;let s=DEFAULT_FILE_STATUS_TEXT;1===t.length?s=`You have selected the file: ${i}`:t.length>1&&(s=`You have selected ${t.length} files: ${i.join(", ")}`),setTimeout((()=>{a.textContent=s}),1e3)},addPreviewHeading=(e,t)=>{const i=document.createElement("div"),a=e.closest(`.${TARGET_CLASS}`),s=a.querySelector(`.${INSTRUCTIONS_CLASS}`);let r="Change file",o="";1===t.length?o=Sanitizer.escapeHTML(`Selected file <span class="usa-file-input__choose">${r}</span>`):t.length>1&&(r="Change files",o=Sanitizer.escapeHTML(`${t.length} files selected <span class="usa-file-input__choose">${r}</span>`)),s.setAttribute("hidden","true"),i.classList.add(PREVIEW_HEADING_CLASS),i.innerHTML=o,a.insertBefore(i,s),e.setAttribute("aria-label",r)},handleChange=(e,t,i,a)=>{const s=t.getAttribute("multiple")?e.target.files:[e.target.files[0]],r=a.closest(`.${DROPZONE_CLASS}`).querySelector(".usa-sr-only"),o=[];removeOldPreviews(a,i);for(let e=0;e<s.length;e+=1){const t=new FileReader,r=s[e].name;let n;o.push(r),t.onloadstart=function(){n=createUniqueID(makeSafeForID(r)),i.insertAdjacentHTML("afterend",Sanitizer.escapeHTML(`<div class="${PREVIEW_CLASS}" aria-hidden="true">\n <img id="${n}" src="${SPACER_GIF}" alt="" class="${GENERIC_PREVIEW_CLASS_NAME} is-loading"/>${r}\n <div>`))},t.onloadend=function(){const e=a.querySelector(`#${n}`);r.indexOf(".pdf")>0?e.setAttribute("onerror",`this.onerror=null;this.src="${SPACER_GIF}"; this.classList.add("${PDF_PREVIEW_CLASS}")`):r.indexOf(".doc")>0||r.indexOf(".pages")>0?e.setAttribute("onerror",`this.onerror=null;this.src="${SPACER_GIF}"; this.classList.add("${WORD_PREVIEW_CLASS}")`):r.indexOf(".xls")>0||r.indexOf(".numbers")>0?e.setAttribute("onerror",`this.onerror=null;this.src="${SPACER_GIF}"; this.classList.add("${EXCEL_PREVIEW_CLASS}")`):r.indexOf(".mov")>0||r.indexOf(".mp4")>0?e.setAttribute("onerror",`this.onerror=null;this.src="${SPACER_GIF}"; this.classList.add("${VIDEO_PREVIEW_CLASS}")`):e.setAttribute("onerror",`this.onerror=null;this.src="${SPACER_GIF}"; this.classList.add("${GENERIC_PREVIEW_CLASS}")`),e.classList.remove("is-loading"),e.src=t.result},s[e]&&t.readAsDataURL(s[e])}0===s.length?t.setAttribute("aria-label",DEFAULT_ARIA_LABEL_TEXT):addPreviewHeading(t,s),updateStatusMessage(r,s,o)},preventInvalidFiles=(e,t,i,a)=>{const s=t.getAttribute("accept");a.classList.remove("has-invalid-file");const r=(e,t)=>{let i=!1;return e.indexOf(t)>=0&&(i=!0),i};if(s){const o=s.split(","),n=document.createElement("div");let l=!0;const d=e.target.files||e.dataTransfer.files;for(let e=0;e<d.length;e+=1){const t=d[e];if(!l)break;for(let e=0;e<o.length;e+=1){const i=o[e];if(l=t.name.indexOf(i)>0||r(t.type,i.replace(/\*/g,"")),l){TYPE_IS_VALID=!0;break}}}l||(removeOldPreviews(a,i),t.value="",a.insertBefore(n,t),n.textContent=t.dataset.errormessage||"This is not a valid file type.",n.classList.add(ACCEPTED_FILE_MESSAGE_CLASS),a.classList.add("has-invalid-file"),TYPE_IS_VALID=!1,e.preventDefault(),e.stopPropagation())}},handleUpload=(e,t,i,a)=>{preventInvalidFiles(e,t,i,a),!0===TYPE_IS_VALID&&handleChange(e,t,i,a)},fileInput={init(e){selectOrMatches(DROPZONE,e).forEach((e=>{const{instructions:t,dropTarget:i}=enhanceFileInput(e);i.addEventListener("dragover",(function(){this.classList.add(DRAG_CLASS)}),!1),i.addEventListener("dragleave",(function(){this.classList.remove(DRAG_CLASS)}),!1),i.addEventListener("drop",(function(a){a.preventDefault(),this.classList.remove(DRAG_CLASS);const s=a.dataTransfer;if(a.target.files=s.files,s.files.length>1)return;handleUpload(a,e,t,i);const r=new CustomEvent("change",{detail:{files:s.files}});e.dispatchEvent(r)}),!1),e.addEventListener("input",(a=>handleUpload(a,e,t,i)),!1)}))},teardown(e){selectOrMatches(INPUT,e).forEach((e=>{const t=e.parentElement.parentElement;t.parentElement.replaceChild(e,t),e.className=DROPZONE_CLASS}))},getFileInputContext:getFileInputContext,disable:disable,ariaDisable:ariaDisable,enable:enable},extensionToMimeType={".txt":"text/plain",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".odt":"application/vnd.oasis.opendocument.text",".rtf":"application/rtf",".csv":"text/csv",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".gif":"image/gif",".bmp":"image/bmp",".webp":"image/webp",".tif":"image/tiff",".tiff":"image/tiff",".svg":"image/svg+xml",".mp3":"audio/mpeg",".wav":"audio/wav",".ogg":"audio/ogg",".m4a":"audio/mp4",".aac":"audio/aac",".mp4":"video/mp4",".avi":"video/x-msvideo",".mov":"video/quicktime",".wmv":"video/x-ms-wmv",".flv":"video/x-flv",".mkv":"video/x-matroska",".webm":"video/webm",".zip":"application/zip",".rar":"application/x-rar-compressed",".7z":"application/x-7z-compressed",".tar":"application/x-tar",".gz":"application/gzip",".json":"application/json",".xml":"application/xml",".html":"text/html",".htm":"text/html",".css":"text/css",".js":"application/javascript"},vaFileInputCss='button:not([disabled]):focus,select:not([disabled]):focus,a:not([disabled]):focus,h1:focus,input:not([disabled]):focus,textarea:not([disabled]):focus,#form-question [role=\'option\']:focus,*[tabindex]:focus,a.va-sidenav-submenu__link:focus{outline:2px solid var(--vads-color-action-focus-on-light);outline-offset:2px;z-index:2}h1{margin-top:0}h1,h2,h3,h4,h5,h6{margin-bottom:0;margin-top:0;clear:both}*+h1,*+h2,*+h3,*+h4,*+h5,*+h6{margin-top:1.5em}h1+*,h2+*,h3+*,h4+*,h5+*,h6+*{margin-top:1em}h1{font-family:Merriweather Web, Georgia, Cambria, Times New Roman, Times, serif;font-size:2.44rem;line-height:1.2;font-weight:700}h2{font-family:Merriweather Web, Georgia, Cambria, Times New Roman, Times, serif;font-size:1.95rem;line-height:1.2;font-weight:700}h3{font-family:Merriweather Web, Georgia, Cambria, Times New Roman, Times, serif;font-size:1.34rem;line-height:1.2;font-weight:700}h4{font-family:Merriweather Web, Georgia, Cambria, Times New Roman, Times, serif;font-size:0.98rem;line-height:1.2;font-weight:700}h5{font-family:Merriweather Web, Georgia, Cambria, Times New Roman, Times, serif;font-size:0.91rem;line-height:1.2;font-weight:700}h6{font-family:Source Sans Pro Web, Helvetica Neue, Helvetica, Roboto, Arial, sans-serif;font-size:0.87rem;line-height:1.1;font-weight:normal;letter-spacing:0.025em;text-transform:uppercase}h1,h2,h3,h4,h5{font-family:Bitter, Georgia, Cambria, "Times New Roman", Times, serif;font-weight:700}h6{font-family:"Source Sans Pro Web", "Source Sans Pro", "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;font-weight:700}h1{margin-top:0;font-size:2.5rem}h2{font-size:1.875rem}h3{font-size:1.25rem}h4{font-size:1.0625rem}h5{font-size:0.9375rem}h6{font-size:0.9375rem}@media (max-width: 481px){h1{font-size:30px}h2{font-size:24px}}h6{margin:0.5em 0 0;text-transform:none;font-weight:700}@media (max-width: 481px){h1{font-size:30px}h2{font-size:24px}}h6{margin:0.5em 0 0;text-transform:none;font-weight:700}:host legend :is(h1,h2,h3,h4,h5,h6),:host label :is(h1,h2,h3,h4,h5,h6){display:inline;margin:0px}:host legend :is(h1,h2,h3,h4,h5),:host label :is(h1,h2,h3,h4,h5){font-family:var(--font-serif)}:host h1+*,:host h2+*,:host h3+*,:host h4+*,:host h5+*,:host h6+*{margin-top:unset}:host #form-question{margin-bottom:1rem}.usa-hint{font-family:Source Sans Pro Web, "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans;font-size:1.06rem;line-height:1.3}.usa-label{font-family:Source Sans Pro Web, "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans;font-size:1.06rem;line-height:1.3;display:block;font-weight:normal;margin-top:1.5rem;max-width:30rem}.usa-label--error{font-weight:700;margin-top:0}.usa-label--required{color:#b50909}.usa-hint{color:#71767a}.usa-hint--required{color:#b50909}.usa-sr-only{position:absolute;left:-999em;right:auto}.usa-error-message{padding-bottom:0.25rem;padding-top:0.25rem;color:#b50909;display:block;font-weight:700}.usa-error-message{font-size:1.06rem}:host([error]:not([error=""])){border-left:0.25rem solid #b50909;padding-left:1rem;position:relative}:host([error]:not([error=""])[use-forms-pattern=multiple]){border-left:none}:host([error]:not([error=""])[use-forms-pattern=multiple]) .input-wrap{border-left:0.25rem solid #b50909;padding-left:1rem;position:relative}@media screen and (min-width: 1008px){:host([error]:not([error=""])){margin-left:-0.9rem}:host([error]:not([error=""])[use-forms-pattern=multiple]) .input-wrap{margin-left:-0.9rem}}@media screen and (max-width: 1008px){:host([error]:not([error=""])[use-forms-pattern=multiple]){padding-left:0}}[hidden]{display:none}:host{display:block;font-family:var(--font-source-sans);font-size:16.96px;}:host .label-header{color:var(--vads-color-base);font-weight:var(--font-weight-normal)}:host .label-header-tag{margin:0;display:inline-block}:host .file-input-wrapper{display:block;max-width:30rem;width:100%;position:relative;margin:8px 0}:host .file-input{cursor:pointer;height:100%;width:100%;max-width:none;top:0;left:0;z-index:1;margin:0;position:absolute;text-indent:-999em;-webkit-box-sizing:border-box;box-sizing:border-box}:host .file-input-target{border:1px dashed var(--vads-color-action-border-base-active-on-dark);display:block;margin-top:0.3125rem;position:relative;text-align:center;width:100%;-webkit-box-sizing:border-box;box-sizing:border-box}:host .file-input-target.file-input-target-error{border:2px dashed var(--vads-color-secondary-dark)}:host .file-input-box{background:var(--vads-color-white);height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%;z-index:2}:host .file-input-instructions{font-size:1.06rem;padding:1.25rem 0.625rem;pointer-events:none;position:relative;z-index:3}:host .file-input-choose-text{color:var(--vads-color-link);text-decoration:underline;font-weight:var(--font-weight-normal)}:host .file-icon{color:var(--vads-color-primary-alt-darkest)}:host .selected-files-wrapper{background-color:var(--vads-color-primary-lighter);border:1px solid var(--vads-color-base-light)}:host .selected-files-label{color:var(--vads-color-base);font-weight:var(--font-weight-bold);font-size:1.06rem;border-bottom:1px solid var(--vads-color-white);margin-bottom:8px;padding:8px}:host .va-card{margin:8px}:host .file-label{color:var(--vads-color-base);font-weight:var(--font-weight-bold);font-size:1.06rem;padding:0 8px;display:block;width:100%;word-wrap:break-word;word-break:break-word;overflow:hidden}:host #input-error-message{padding:0 8px;width:100%}:host .file-size-label,:host .file-status-label{color:var(--vads-color-base-dark);font-weight:var(--font-weight-normal);font-size:1.06rem;padding:0 8px;display:block}:host .file-status-label{font-style:italic}:host .file-info-section{padding:0 8px 8px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}:host .file-button-section{margin-top:8px;display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-direction:row;flex-direction:row}:host .file-button-section>va-button-icon{font-size:1.06rem}@media screen and (max-width: 320px){:host .file-button-section{-ms-flex-direction:column;flex-direction:column;-ms-flex-align:start;align-items:flex-start}}:host .separator{border:0;border-top:1px solid var(--vads-color-base-lighter);margin:0}:host .vads-u-line-height--2{line-height:1.15}:host .thumbnail-container{height:40px;width:40px;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}:host .thumbnail-preview{max-width:40px;width:auto;max-height:40px;height:auto}:host .thumbnail-error{color:#b21d38}:host va-progress-bar{font-size:var(--vads-font-size-root);display:block;margin-left:16px}:host .uploading-status{font-style:var(--font-style-italic)}:host(.has-error){border-left:0.25rem solid #b50909;padding-left:1rem;position:relative}@media screen and (min-width: 1008px){:host(.has-error){margin-left:-0.9rem}}.required{color:var(--vads-color-secondary-dark);margin-left:0.25rem}h1 .required,h2 .required,h3 .required,h4 .required,h5 .required,h6 .required{font-family:var(--font-source-sans);font-size:initial;font-weight:initial}',VaFileInputStyle0=vaFileInputCss,VaFileInput=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.vaChange=createEvent(this,"vaChange",7),this.vaPasswordChange=createEvent(this,"vaPasswordChange",7),this.componentLibraryAnalytics=createEvent(this,"component-library-analytics",7),this.uploadStatus="idle",this.chooseFileString="choose from folder",this.dragFileString="Drag a file here or ",this.handleChange=e=>{this.resetVisualState=!1;const t=e.target;t.files&&t.files.length>0&&this.handleFile(t.files[0]),t.value=""},this.handleDrop=e=>{e.preventDefault(),e.stopPropagation();const t=e.dataTransfer.files;t.length>0&&this.handleFile(t[0])},this.handleFile=(e,t=!0)=>{if(this.accept){const t=this.normalizeAcceptProp(this.accept);if(!this.isAcceptedFileType(e.type,t))return this.removeFile(!1),void(this.internalError="This is not a valid file type.")}return 0===e.size?(this.internalError="The file you selected is empty. Files must be larger than 0B.",void this.resetState()):e.size>this.maxFileSize?(this.internalError=`\n We can't upload your file because it's too big. Files must be less than ${this.formatFileSize(this.maxFileSize)}.`,void this.resetState()):e.size<this.minFileSize?(this.internalError=`We can't upload your file because it's too small. Files must be at least ${this.formatFileSize(this.minFileSize)}.`,void this.resetState()):(this.uploadedFile=null,this.file=e,t&&this.vaChange.emit({files:[this.file]}),this.uploadStatus="success",this.internalError=null,this.generateFileContents(this.file),this.updateStatusMessage(`You have selected the file: ${this.file.name}`),this.el.focus(),void(this.enableAnalytics&&this.componentLibraryAnalytics.emit({componentName:"va-file-input",action:"change",details:{label:this.label}})))},this.removeFile=(e=!0)=>{this.closeModal(),this.uploadStatus="idle",this.internalError=null,e&&this.vaChange.emit({files:[]}),this.file=null,this.uploadedFile=null,this.updateStatusMessage("File removed. No file selected."),this.el.focus()},this.openModal=()=>{this.el.shadowRoot.querySelector("va-modal").setAttribute("status","warning"),this.showModal=!0},this.closeModal=()=>{this.showModal=!1,setTimeout((()=>{this.fileInputRef.focus()}),0)},this.changeFile=()=>{this.fileInputRef&&this.fileInputRef.click()},this.formatFileSize=e=>{const t=["B","KB","MB","GB","TB"];if(0===e)return"0 B";const i=Math.floor(Math.log(e)/Math.log(1024));return 0===i?`${e} ${t[i]}`:`${(e/Math.pow(1024,i)).toFixed(i<2?0:1)} ${t[i]}`},this.normalizeAcceptProp=e=>e.split(",").map((e=>(e=e.trim()).startsWith(".")?extensionToMimeType[e]:e)),this.isAcceptedFileType=(e,t)=>{for(const i of t){if(i===e)return!0;if(i.endsWith("/*")&&e.startsWith(i.slice(0,-1)))return!0}return!1},this.renderLabelOrHeader=(e,t,i)=>{const a=t?h("span",{class:"required"}," ",instance.t("required")):null;return h("div",{class:"label-header"},i&&i>=1&&i<=6?h(`h${i}`,{htmlFor:"fileInputField",part:"label",class:"label-header-tag"},e,a):h("label",{htmlFor:"fileInputField",part:"label",class:"usa-label"},e,a))},this.file=void 0,this.fileContents=void 0,this.internalError=void 0,this.showModal=!1,this.showSeparator=!0,this.label=void 0,this.name=void 0,this.buttonText=void 0,this.value=void 0,this.required=!1,this.accept=void 0,this.error=void 0,this.hint=void 0,this.statusText=void 0,this.uploadMessage=null,this.enableAnalytics=!1,this.headerSize=void 0,this.headless=!1,this.readOnly=!1,this.encrypted=!1,this.uploadedFile=void 0,this.maxFileSize=1/0,this.minFileSize=0,this.percentUploaded=null,this.passwordError=void 0,this.resetVisualState=!1}handleValueChange(e){setTimeout((()=>{this.updateStatusMessage(e)}))}percentHandler(e){e>=100&&this.resetState()}handleError(e){e&&this.resetState()}resetState(){this.fileContents=null,this.uploadStatus="idle",this.percentUploaded=null,forceUpdate(this.el)}updateStatusMessage(e){setTimeout((()=>{const t=this.el.shadowRoot.querySelector("#statusMessage");t&&(t.textContent=e)}),1e3)}generateFileContents(e){if(!e)return;const t=new FileReader;this.fileType=e.type,t.onloadend=()=>{this.fileContents=t.result},this.fileType&&("application/pdf"===this.fileType||this.fileType.startsWith("image/"))&&t.readAsDataURL(e)}componentWillRender(){const e=!!this.el.querySelector(":scope > *"),t=!(!this.value&&!this.file||this.readOnly);this.showSeparator=e||t}componentDidLoad(){fileInput.init(this.el)}connectedCallback(){this.el.addEventListener("change",this.handleChange)}disconnectedCallback(){this.el.removeEventListener("change",this.handleChange)}getDefaultUploadMessage(){return h("span",null,this.dragFileString,h("span",{class:"file-input-choose-text"},this.chooseFileString))}handlePasswordChange(e){this.vaPasswordChange.emit({password:e.target.value})}render(){const{label:e,name:t,required:i,accept:a,error:s,hint:r,file:o,uploadStatus:n,dragFileString:l,chooseFileString:d,uploadMessage:c,headerSize:f,fileContents:p,fileType:u,headless:m,value:b,readOnly:g,encrypted:v,statusText:S,uploadedFile:E,percentUploaded:A,passwordError:C,resetVisualState:_}=this;b&&!this.file&&this.handleFile(b,!1);const x=s||this.internalError,y=`${r?"input-hint-message":""} ${x?"input-error-message":""}`.trim()||null,L=("file-input-target "+(x?"file-input-target-error":"")).trim();let w=h("div",{key:"0ba4f1b07bf71702d3c009a564c31a0cbda42d00",class:"thumbnail-container"},h("svg",{key:"17f77585c4980081c3b50d20fa64ab3ec5d31d69",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"#07648d",width:"40px",height:"40px"},h("path",{key:"7d51920b90ca18ac6dcde81c854dd955e3436060",d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm160-14.1v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"})));s?w=h("div",{key:"2448d7fdce3bc76b49ceaa72a33fddf2322f5cab",class:"thumbnail-container"},h("va-icon",{key:"d07fc7841535c7e5859aec7974d5f9cdf7607825",icon:"error",size:3,class:"thumbnail-preview thumbnail-error"})):p&&(u.startsWith("image/")?w=h("div",{key:"8f490b7395bbf487269d055ff2bb9da70b8e426d",class:"thumbnail-container","aria-hidden":"true"},h("img",{key:"af93e9a4d390bc2fe7f8ee79e87b2ba12c233c8f",class:"thumbnail-preview",src:p,alt:"image"})):"application/pdf"===u&&(w=h("div",{key:"22014a42479666e381aa4f64e6d12567e7c19bd8",class:"thumbnail-container","aria-hidden":"true"},h("object",{key:"e462949648a918fe00762ad165acb888ffd2ece9",class:"thumbnail-preview",data:p,type:"application/pdf"}))));let T=m?"headless-selected-files-wrapper":"selected-files-wrapper";const I="usa-hint"+(m?" usa-sr-only":""),F=null!==A&&A<100;let R="file-status-label";return F&&(R=`${R} uploading-status`),h(Host,{key:"7d253c4ad42da6875edf8ef049645a1a3b49eebf",class:{"has-error":!!x}},!g&&h("span",{key:"7021e55cd2bbedf6af02d1f513f3c2701884e55c",class:{"usa-sr-only":!!m}},e&&this.renderLabelOrHeader(e,i,f)),r&&!g&&h("div",{key:"6622aac52e6b1be43030b4876cf49f2f066d4164",class:I,id:"input-hint-message"},r),h("div",{key:"bcf5e22ead3af8eb8f22447f1d3445595ee4e2e0",class:"file-input-wrapper",onDrop:this.handleDrop},h("input",{key:"83009dec11a4c8e473d2b640a8f656dae0c4ba67",id:"fileInputField",class:"file-input","aria-label":`${e}${i?" "+instance.t("required"):""}. ${l}${d}`,style:{visibility:"success"===this.uploadStatus||E?"hidden":"unset"},type:"file",ref:e=>this.fileInputRef=e,name:t,accept:a,"aria-describedby":y,onChange:this.handleChange}),"idle"===n&&(!E||_)&&h("div",{key:"a78108c5d97259840b1552a7398dd3e021604901"},h("span",{key:"575ef5a846fcf1e452172f34c1c2ece5ed627364",id:"file-input-error-alert",role:"alert"},x&&h(Fragment,{key:"789e7490933fe0ba0ca8176edeb0d149e4fd3935"},h("span",{key:"5509b84567e638a6db301371cc372e7c9907c714",class:"usa-sr-only"},instance.t("error")),h("span",{key:"084096c61f148d3e556c920c0c5a00db7531952f",class:"usa-error-message"},x))),h("div",{key:"1723caf5827884c35e654093a246ae75071ed17e",class:"usa-sr-only","aria-live":"polite",id:"statusMessage"}),h("div",{key:"a0be5187a9ecae0445449e60185d2f2c19d32526",class:L},h("div",{key:"d9eab9e1bb721a1f520ad473ed5c9b963fa597fe",class:"file-input-box"}),h("div",{key:"068b66442b3923be0733022f3b3d473041a5a15b",class:"file-input-instructions"},c||this.getDefaultUploadMessage()))),!_&&("idle"!==n||E)&&h("div",{key:"05017f4217ce8eb4429d88abd531dc07f6b361e4",class:T},!m&&h("div",{key:"e91ef46b351a709aaac7817980153bf6ad1814f9",class:"selected-files-label"},g?"Files you uploaded":"Selected files"),h("div",{key:"48fd42f25102184a12cfdfcaee500a3aade78528",class:"usa-sr-only","aria-live":"polite",id:"statusMessage"}),h("va-card",{key:"4bf0435ce687700831d1330db3b40e910b76a197",class:"va-card"},h("div",{key:"86a10d691a6bdfe591bc8f1674b5f4c32867b4c1",class:"file-info-section"},w,h("div",{key:"f494b9130126b0059fd53deb7dbb70ec8f1203d5",class:"file-info-group vads-u-line-height--2"},h("span",{key:"10fa6909381cc27da81bf1ae53b193ee19352b6e",class:"file-label"},o?o.name:E.name),x&&h("span",{key:"68e20992dc2c0531f7aec0bc380a27b871df11ac",id:"input-error-message",role:"alert"},h("span",{key:"bc8a416d10786b6c9ef0f8bc4dbc1f5262abe359",class:"usa-sr-only"},instance.t("error")),h("span",{key:"75bafd31d1187d576021e2bcf1d3b34748f15a8f","aria-live":"polite",class:"usa-error-message"},x)),!F&&h("span",{key:"2210e1e49afeabefe7a7e026a934a7774281def2",class:"file-size-label"},this.formatFileSize(o?o.size:E.size)),h("span",{key:"2ac795ef2250f06cf7f154fdcdcf873ec4c1678b",class:R,"aria-live":"polite"},F?"Uploading...":S))),(o||b||E)&&h("div",{key:"eb8e7d6ca1e7111239c4351219b2f608219bc866"},this.showSeparator&&h("hr",{key:"2577220314f9cbd9e80f1881175cd5d8ce417885",class:"separator"}),v&&h("va-text-input",{key:"eddfce5dac7dfd7ceb5f07af044f9d01464db246",onInput:e=>{this.handlePasswordChange(e)},label:"File password",required:!0,error:C}),h("div",{key:"62b0ba0d836c390c6100d0afbd13c0146bc4f65e",class:"additional-info-slot"},h("slot",{key:"89c2a3dcb4b37e292a72009d460bd605cb10f642"})),g?null:F?h(Fragment,null,h("va-progress-bar",{percent:A}),h("va-button-icon",{buttonType:"cancel",onClick:this.resetState.bind(this)})):h(Fragment,null,h("div",{class:"file-button-section"},h("va-button-icon",{buttonType:"change-file",onClick:this.changeFile,label:"Change file","aria-label":`change file ${o?o.name:E.name}`}),h("va-button-icon",{buttonType:"delete",onClick:this.openModal,"aria-label":`delete file ${o?o.name:E.name}`,label:"Delete"})),h("va-modal",{modalTitle:"Delete this file?",visible:this.showModal,primaryButtonText:"Yes, remove this",secondaryButtonText:"No, keep this",onCloseEvent:this.closeModal,onPrimaryButtonClick:()=>this.removeFile(!0),onSecondaryButtonClick:this.closeModal},"We'll delete the uploaded file"," ",h("span",{class:"file-label"},o?o.name:E.name))))))))}get el(){return this}static get watchers(){return{statusText:["handleValueChange"],percentUploaded:["percentHandler"],resetVisualState:["handleError"]}}static get style(){return VaFileInputStyle0}},[1,"va-file-input",{label:[1],name:[1],buttonText:[1,"button-text"],value:[16],required:[4],accept:[1],error:[1],hint:[1],statusText:[1,"status-text"],uploadMessage:[16],enableAnalytics:[4,"enable-analytics"],headerSize:[2,"header-size"],headless:[4],readOnly:[4,"read-only"],encrypted:[4],uploadedFile:[16],maxFileSize:[2,"max-file-size"],minFileSize:[2,"min-file-size"],percentUploaded:[1026,"percent-uploaded"],passwordError:[1,"password-error"],resetVisualState:[1028,"reset-visual-state"],file:[32],fileContents:[32],internalError:[32],showModal:[32],showSeparator:[32]},void 0,{statusText:["handleValueChange"],percentUploaded:["percentHandler"],resetVisualState:["handleError"]}]);function defineCustomElement(){"undefined"!=typeof customElements&&["va-file-input","va-button","va-button-icon","va-card","va-icon","va-modal","va-progress-bar","va-text-input"].forEach((e=>{switch(e){case"va-file-input":customElements.get(e)||customElements.define(e,VaFileInput);break;case"va-button":customElements.get(e)||defineCustomElement$7();break;case"va-button-icon":customElements.get(e)||defineCustomElement$6();break;case"va-card":customElements.get(e)||defineCustomElement$5();break;case"va-icon":customElements.get(e)||defineCustomElement$4();break;case"va-modal":customElements.get(e)||defineCustomElement$3();break;case"va-progress-bar":customElements.get(e)||defineCustomElement$2();break;case"va-text-input":customElements.get(e)||defineCustomElement$1()}}))}export{VaFileInput as V,defineCustomElement as d};
|
|
1
|
+
import{proxyCustomElement,HTMLElement,createEvent,h,forceUpdate,Host,Fragment}from"@stencil/core/internal/client";import"./i18n-setup.js";import"./contacts.js";import{s as selectOrMatches,S as Sanitizer}from"./utils.js";import{d as defineCustomElement$7}from"./va-button2.js";import{d as defineCustomElement$6}from"./va-button-icon2.js";import{d as defineCustomElement$5}from"./va-card2.js";import{d as defineCustomElement$4}from"./va-icon2.js";import{d as defineCustomElement$3}from"./va-modal2.js";import{d as defineCustomElement$2}from"./va-progress-bar2.js";import{d as defineCustomElement$1}from"./va-text-input2.js";import{i as instance}from"./i18next.js";const PREFIX="usa",DROPZONE_CLASS="usa-file-input",DROPZONE=`.${DROPZONE_CLASS}`,INPUT_CLASS="usa-file-input__input",TARGET_CLASS="usa-file-input__target",INPUT=`.${INPUT_CLASS}`,BOX_CLASS="usa-file-input__box",INSTRUCTIONS_CLASS="usa-file-input__instructions",PREVIEW_CLASS="usa-file-input__preview",PREVIEW_HEADING_CLASS="usa-file-input__preview-heading",DISABLED_CLASS="usa-file-input--disabled",CHOOSE_CLASS="usa-file-input__choose",ACCEPTED_FILE_MESSAGE_CLASS="usa-file-input__accepted-files-message",DRAG_TEXT_CLASS="usa-file-input__drag-text",DRAG_CLASS="usa-file-input--drag",LOADING_CLASS="is-loading",INVALID_FILE_CLASS="has-invalid-file",GENERIC_PREVIEW_CLASS_NAME="usa-file-input__preview-image",GENERIC_PREVIEW_CLASS=`${GENERIC_PREVIEW_CLASS_NAME}--generic`,PDF_PREVIEW_CLASS=`${GENERIC_PREVIEW_CLASS_NAME}--pdf`,WORD_PREVIEW_CLASS=`${GENERIC_PREVIEW_CLASS_NAME}--word`,VIDEO_PREVIEW_CLASS=`${GENERIC_PREVIEW_CLASS_NAME}--video`,EXCEL_PREVIEW_CLASS=`${GENERIC_PREVIEW_CLASS_NAME}--excel`,SR_ONLY_CLASS="usa-sr-only",SPACER_GIF="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";let TYPE_IS_VALID=Boolean(!0),DEFAULT_ARIA_LABEL_TEXT="",DEFAULT_FILE_STATUS_TEXT="";const getFileInputContext=e=>{const t=e.closest(DROPZONE);if(!t)throw new Error(`Element is missing outer ${DROPZONE}`);const i=t.querySelector(INPUT);return{dropZoneEl:t,inputEl:i}},disable=e=>{const{dropZoneEl:t,inputEl:i}=getFileInputContext(e);i.disabled=!0,t.classList.add(DISABLED_CLASS)},ariaDisable=e=>{const{dropZoneEl:t}=getFileInputContext(e);t.classList.add(DISABLED_CLASS)},enable=e=>{const{dropZoneEl:t,inputEl:i}=getFileInputContext(e);i.disabled=!1,t.classList.remove(DISABLED_CLASS),t.removeAttribute("aria-disabled")},replaceName=e=>{const t=e.charCodeAt(0);return 32===t?"-":t>=65&&t<=90?`img_${e.toLowerCase()}`:`__000${t.toString(16).slice(-4)}`},makeSafeForID=e=>e.replace(/[^a-z0-9]/g,replaceName),createUniqueID=e=>`${e}-${Math.floor(Date.now()/1e3)}`,getItemsLabel=e=>e.hasAttribute("multiple")?"files":"file",createTargetArea=e=>{const t=document.createElement("div"),i=document.createElement("div"),a=document.createElement("div");return e.classList.remove(DROPZONE_CLASS),e.classList.add(INPUT_CLASS),t.classList.add(DROPZONE_CLASS),a.classList.add(BOX_CLASS),i.classList.add(TARGET_CLASS),i.prepend(a),e.parentNode.insertBefore(i,e),e.parentNode.insertBefore(t,i),i.appendChild(e),t.appendChild(i),i},createVisibleInstructions=e=>{const t=e.closest(DROPZONE),i=getItemsLabel(e),a=document.createElement("div"),s=`Drag ${i} here or`,r="choose from folder";return DEFAULT_ARIA_LABEL_TEXT=`${s} ${r}`,a.classList.add(INSTRUCTIONS_CLASS),a.setAttribute("aria-hidden","true"),e.setAttribute("aria-label",DEFAULT_ARIA_LABEL_TEXT),a.innerHTML=Sanitizer.escapeHTML(`<span class="${DRAG_TEXT_CLASS}">${s}</span> <span class="${CHOOSE_CLASS}">${r}</span>`),e.parentNode.insertBefore(a,e),(/rv:11.0/i.test(navigator.userAgent)||/Edge\/\d./i.test(navigator.userAgent))&&(t.querySelector(`.${DRAG_TEXT_CLASS}`).outerHTML=""),a},createSROnlyStatus=e=>{const t=document.createElement("div"),i=getItemsLabel(e),a=e.closest(DROPZONE),s=e.closest(`.${TARGET_CLASS}`);DEFAULT_FILE_STATUS_TEXT=`No ${i} selected.`,t.classList.add("usa-sr-only"),t.setAttribute("aria-live","polite"),t.textContent=DEFAULT_FILE_STATUS_TEXT,a.insertBefore(t,s)},enhanceFileInput=e=>{const t=e.hasAttribute("aria-disabled")||e.hasAttribute("disabled"),i=createTargetArea(e),a=createVisibleInstructions(e),{dropZoneEl:s}=getFileInputContext(e);return t?s.classList.add(DISABLED_CLASS):createSROnlyStatus(e),{instructions:a,dropTarget:i}},removeOldPreviews=(e,t)=>{const i=e.querySelectorAll(`.${PREVIEW_CLASS}`),a=e.querySelector(`.${PREVIEW_HEADING_CLASS}`),s=e.querySelector(`.${ACCEPTED_FILE_MESSAGE_CLASS}`);a&&(a.outerHTML=""),s&&(s.outerHTML="",e.classList.remove("has-invalid-file")),null!==i&&(t&&t.removeAttribute("hidden"),Array.prototype.forEach.call(i,(e=>{e.parentNode.removeChild(e)})))},updateStatusMessage=(e,t,i)=>{const a=e;let s=DEFAULT_FILE_STATUS_TEXT;1===t.length?s=`You have selected the file: ${i}`:t.length>1&&(s=`You have selected ${t.length} files: ${i.join(", ")}`),setTimeout((()=>{a.textContent=s}),1e3)},addPreviewHeading=(e,t)=>{const i=document.createElement("div"),a=e.closest(`.${TARGET_CLASS}`),s=a.querySelector(`.${INSTRUCTIONS_CLASS}`);let r="Change file",o="";1===t.length?o=Sanitizer.escapeHTML(`Selected file <span class="usa-file-input__choose">${r}</span>`):t.length>1&&(r="Change files",o=Sanitizer.escapeHTML(`${t.length} files selected <span class="usa-file-input__choose">${r}</span>`)),s.setAttribute("hidden","true"),i.classList.add(PREVIEW_HEADING_CLASS),i.innerHTML=o,a.insertBefore(i,s),e.setAttribute("aria-label",r)},handleChange=(e,t,i,a)=>{const s=t.getAttribute("multiple")?e.target.files:[e.target.files[0]],r=a.closest(`.${DROPZONE_CLASS}`).querySelector(".usa-sr-only"),o=[];removeOldPreviews(a,i);for(let e=0;e<s.length;e+=1){const t=new FileReader,r=s[e].name;let n;o.push(r),t.onloadstart=function(){n=createUniqueID(makeSafeForID(r)),i.insertAdjacentHTML("afterend",Sanitizer.escapeHTML(`<div class="${PREVIEW_CLASS}" aria-hidden="true">\n <img id="${n}" src="${SPACER_GIF}" alt="" class="${GENERIC_PREVIEW_CLASS_NAME} is-loading"/>${r}\n <div>`))},t.onloadend=function(){const e=a.querySelector(`#${n}`);r.indexOf(".pdf")>0?e.setAttribute("onerror",`this.onerror=null;this.src="${SPACER_GIF}"; this.classList.add("${PDF_PREVIEW_CLASS}")`):r.indexOf(".doc")>0||r.indexOf(".pages")>0?e.setAttribute("onerror",`this.onerror=null;this.src="${SPACER_GIF}"; this.classList.add("${WORD_PREVIEW_CLASS}")`):r.indexOf(".xls")>0||r.indexOf(".numbers")>0?e.setAttribute("onerror",`this.onerror=null;this.src="${SPACER_GIF}"; this.classList.add("${EXCEL_PREVIEW_CLASS}")`):r.indexOf(".mov")>0||r.indexOf(".mp4")>0?e.setAttribute("onerror",`this.onerror=null;this.src="${SPACER_GIF}"; this.classList.add("${VIDEO_PREVIEW_CLASS}")`):e.setAttribute("onerror",`this.onerror=null;this.src="${SPACER_GIF}"; this.classList.add("${GENERIC_PREVIEW_CLASS}")`),e.classList.remove("is-loading"),e.src=t.result},s[e]&&t.readAsDataURL(s[e])}0===s.length?t.setAttribute("aria-label",DEFAULT_ARIA_LABEL_TEXT):addPreviewHeading(t,s),updateStatusMessage(r,s,o)},preventInvalidFiles=(e,t,i,a)=>{const s=t.getAttribute("accept");a.classList.remove("has-invalid-file");const r=(e,t)=>{let i=!1;return e.indexOf(t)>=0&&(i=!0),i};if(s){const o=s.split(","),n=document.createElement("div");let l=!0;const d=e.target.files||e.dataTransfer.files;for(let e=0;e<d.length;e+=1){const t=d[e];if(!l)break;for(let e=0;e<o.length;e+=1){const i=o[e];if(l=t.name.indexOf(i)>0||r(t.type,i.replace(/\*/g,"")),l){TYPE_IS_VALID=!0;break}}}l||(removeOldPreviews(a,i),t.value="",a.insertBefore(n,t),n.textContent=t.dataset.errormessage||"This is not a valid file type.",n.classList.add(ACCEPTED_FILE_MESSAGE_CLASS),a.classList.add("has-invalid-file"),TYPE_IS_VALID=!1,e.preventDefault(),e.stopPropagation())}},handleUpload=(e,t,i,a)=>{preventInvalidFiles(e,t,i,a),!0===TYPE_IS_VALID&&handleChange(e,t,i,a)},fileInput={init(e){selectOrMatches(DROPZONE,e).forEach((e=>{const{instructions:t,dropTarget:i}=enhanceFileInput(e);i.addEventListener("dragover",(function(){this.classList.add(DRAG_CLASS)}),!1),i.addEventListener("dragleave",(function(){this.classList.remove(DRAG_CLASS)}),!1),i.addEventListener("drop",(function(a){a.preventDefault(),this.classList.remove(DRAG_CLASS);const s=a.dataTransfer;if(a.target.files=s.files,s.files.length>1)return;handleUpload(a,e,t,i);const r=new CustomEvent("change",{detail:{files:s.files}});e.dispatchEvent(r)}),!1),e.addEventListener("input",(a=>handleUpload(a,e,t,i)),!1)}))},teardown(e){selectOrMatches(INPUT,e).forEach((e=>{const t=e.parentElement.parentElement;t.parentElement.replaceChild(e,t),e.className=DROPZONE_CLASS}))},getFileInputContext:getFileInputContext,disable:disable,ariaDisable:ariaDisable,enable:enable},extensionToMimeType={".txt":"text/plain",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".odt":"application/vnd.oasis.opendocument.text",".rtf":"application/rtf",".csv":"text/csv",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".gif":"image/gif",".bmp":"image/bmp",".webp":"image/webp",".tif":"image/tiff",".tiff":"image/tiff",".svg":"image/svg+xml",".mp3":"audio/mpeg",".wav":"audio/wav",".ogg":"audio/ogg",".m4a":"audio/mp4",".aac":"audio/aac",".mp4":"video/mp4",".avi":"video/x-msvideo",".mov":"video/quicktime",".wmv":"video/x-ms-wmv",".flv":"video/x-flv",".mkv":"video/x-matroska",".webm":"video/webm",".zip":"application/zip",".rar":"application/x-rar-compressed",".7z":"application/x-7z-compressed",".tar":"application/x-tar",".gz":"application/gzip",".json":"application/json",".xml":"application/xml",".html":"text/html",".htm":"text/html",".css":"text/css",".js":"application/javascript"},vaFileInputCss='button:not([disabled]):focus,select:not([disabled]):focus,a:not([disabled]):focus,h1:focus,input:not([disabled]):focus,textarea:not([disabled]):focus,#form-question [role=\'option\']:focus,*[tabindex]:focus,a.va-sidenav-submenu__link:focus{outline:2px solid var(--vads-color-action-focus-on-light);outline-offset:2px;z-index:2}h1{margin-top:0}h1,h2,h3,h4,h5,h6{margin-bottom:0;margin-top:0;clear:both}*+h1,*+h2,*+h3,*+h4,*+h5,*+h6{margin-top:1.5em}h1+*,h2+*,h3+*,h4+*,h5+*,h6+*{margin-top:1em}h1{font-family:Merriweather Web, Georgia, Cambria, Times New Roman, Times, serif;font-size:2.44rem;line-height:1.2;font-weight:700}h2{font-family:Merriweather Web, Georgia, Cambria, Times New Roman, Times, serif;font-size:1.95rem;line-height:1.2;font-weight:700}h3{font-family:Merriweather Web, Georgia, Cambria, Times New Roman, Times, serif;font-size:1.34rem;line-height:1.2;font-weight:700}h4{font-family:Merriweather Web, Georgia, Cambria, Times New Roman, Times, serif;font-size:0.98rem;line-height:1.2;font-weight:700}h5{font-family:Merriweather Web, Georgia, Cambria, Times New Roman, Times, serif;font-size:0.91rem;line-height:1.2;font-weight:700}h6{font-family:Source Sans Pro Web, Helvetica Neue, Helvetica, Roboto, Arial, sans-serif;font-size:0.87rem;line-height:1.1;font-weight:normal;letter-spacing:0.025em;text-transform:uppercase}h1,h2,h3,h4,h5{font-family:Bitter, Georgia, Cambria, "Times New Roman", Times, serif;font-weight:700}h6{font-family:"Source Sans Pro Web", "Source Sans Pro", "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;font-weight:700}h1{margin-top:0;font-size:2.5rem}h2{font-size:1.875rem}h3{font-size:1.25rem}h4{font-size:1.0625rem}h5{font-size:0.9375rem}h6{font-size:0.9375rem}@media (max-width: 481px){h1{font-size:30px}h2{font-size:24px}}h6{margin:0.5em 0 0;text-transform:none;font-weight:700}@media (max-width: 481px){h1{font-size:30px}h2{font-size:24px}}h6{margin:0.5em 0 0;text-transform:none;font-weight:700}:host legend :is(h1,h2,h3,h4,h5,h6),:host label :is(h1,h2,h3,h4,h5,h6){display:inline;margin:0px}:host legend :is(h1,h2,h3,h4,h5),:host label :is(h1,h2,h3,h4,h5){font-family:var(--font-serif)}:host h1+*,:host h2+*,:host h3+*,:host h4+*,:host h5+*,:host h6+*{margin-top:unset}:host #form-question{margin-bottom:1rem}.usa-hint{font-family:Source Sans Pro Web, "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans;font-size:1.06rem;line-height:1.3}.usa-label{font-family:Source Sans Pro Web, "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans;font-size:1.06rem;line-height:1.3;display:block;font-weight:normal;margin-top:1.5rem;max-width:30rem}.usa-label--error{font-weight:700;margin-top:0}.usa-label--required{color:#b50909}.usa-hint{color:#71767a}.usa-hint--required{color:#b50909}.usa-sr-only{position:absolute;left:-999em;right:auto}.usa-error-message{padding-bottom:0.25rem;padding-top:0.25rem;color:#b50909;display:block;font-weight:700}.usa-error-message{font-size:1.06rem}:host([error]:not([error=""])){border-left:0.25rem solid #b50909;padding-left:1rem;position:relative}:host([error]:not([error=""])[use-forms-pattern=multiple]){border-left:none}:host([error]:not([error=""])[use-forms-pattern=multiple]) .input-wrap{border-left:0.25rem solid #b50909;padding-left:1rem;position:relative}@media screen and (min-width: 1008px){:host([error]:not([error=""])){margin-left:-0.9rem}:host([error]:not([error=""])[use-forms-pattern=multiple]) .input-wrap{margin-left:-0.9rem}}@media screen and (max-width: 1008px){:host([error]:not([error=""])[use-forms-pattern=multiple]){padding-left:0}}[hidden]{display:none}:host{display:block;font-family:var(--font-source-sans);font-size:16.96px;}:host .label-header{color:var(--vads-color-base);font-weight:var(--font-weight-normal)}:host .label-header-tag{margin:0;display:inline-block}:host .file-input-wrapper{display:block;max-width:30rem;width:100%;position:relative;margin:8px 0}:host .file-input{cursor:pointer;height:100%;width:100%;max-width:none;top:0;left:0;z-index:1;margin:0;position:absolute;text-indent:-999em;-webkit-box-sizing:border-box;box-sizing:border-box}:host .file-input-target{border:1px dashed var(--vads-color-action-border-base-active-on-dark);display:block;margin-top:0.3125rem;position:relative;text-align:center;width:100%;-webkit-box-sizing:border-box;box-sizing:border-box}:host .file-input-target.file-input-target-error{border:2px dashed var(--vads-color-secondary-dark)}:host .file-input-box{background:var(--vads-color-white);height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%;z-index:2}:host .file-input-instructions{font-size:1.06rem;padding:1.25rem 0.625rem;pointer-events:none;position:relative;z-index:3}:host .file-input-choose-text{color:var(--vads-color-link);text-decoration:underline;font-weight:var(--font-weight-normal)}:host .file-icon{color:var(--vads-color-primary-alt-darkest)}:host .selected-files-wrapper{background-color:var(--vads-color-primary-lighter);border:1px solid var(--vads-color-base-light)}:host .selected-files-label{color:var(--vads-color-base);font-weight:var(--font-weight-bold);font-size:1.06rem;border-bottom:1px solid var(--vads-color-white);margin-bottom:8px;padding:8px}:host .va-card{margin:8px}:host .file-label{color:var(--vads-color-base);font-weight:var(--font-weight-bold);font-size:1.06rem;padding:0 8px;display:block;width:100%;word-wrap:break-word;word-break:break-word;overflow:hidden}:host #input-error-message{padding:0 8px;width:100%}:host .file-size-label,:host .file-status-label{color:var(--vads-color-base-dark);font-weight:var(--font-weight-normal);font-size:1.06rem;padding:0 8px;display:block}:host .file-status-label{font-style:italic}:host .file-info-section{padding:0 8px 8px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}:host .file-button-section{margin-top:8px;display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-direction:row;flex-direction:row}:host .file-button-section>va-button-icon{font-size:1.06rem}@media screen and (max-width: 320px){:host .file-button-section{-ms-flex-direction:column;flex-direction:column;-ms-flex-align:start;align-items:flex-start}}:host .separator{border:0;border-top:1px solid var(--vads-color-base-lighter);margin:0}:host .vads-u-line-height--2{line-height:1.15}:host .thumbnail-container{height:40px;width:40px;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}:host .thumbnail-preview{max-width:40px;width:auto;max-height:40px;height:auto}:host .thumbnail-error{color:#b21d38}:host va-progress-bar{font-size:var(--vads-font-size-root);display:block;margin-left:16px}:host .uploading-status{font-style:var(--font-style-italic)}:host(.has-error){border-left:0.25rem solid #b50909;padding-left:1rem;position:relative}@media screen and (min-width: 1008px){:host(.has-error){margin-left:-0.9rem}}.required{color:var(--vads-color-secondary-dark);margin-left:0.25rem}h1 .required,h2 .required,h3 .required,h4 .required,h5 .required,h6 .required{font-family:var(--font-source-sans);font-size:initial;font-weight:initial}',VaFileInputStyle0=vaFileInputCss,VaFileInput=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.vaChange=createEvent(this,"vaChange",7),this.vaPasswordChange=createEvent(this,"vaPasswordChange",7),this.componentLibraryAnalytics=createEvent(this,"component-library-analytics",7),this.uploadStatus="idle",this.chooseFileString="choose from folder",this.dragFileString="Drag a file here or ",this.FILE_PREVIEW_SIZE_LIMIT=5242880,this.handleChange=e=>{this.resetVisualState=!1;const t=e.target;t.files&&t.files.length>0&&this.handleFile(t.files[0]),t.value=""},this.handleDrop=e=>{e.preventDefault(),e.stopPropagation();const t=e.dataTransfer.files;t.length>0&&this.handleFile(t[0])},this.handleFile=(e,t=!0)=>{if(this.accept){const t=this.normalizeAcceptProp(this.accept);if(!this.isAcceptedFileType(e.type,t))return this.removeFile(!1),void(this.internalError="This is not a valid file type.")}return 0===e.size?(this.internalError="The file you selected is empty. Files must be larger than 0B.",void this.resetState()):e.size>this.maxFileSize?(this.internalError=`\n We can't upload your file because it's too big. Files must be less than ${this.formatFileSize(this.maxFileSize)}.`,void this.resetState()):e.size<this.minFileSize?(this.internalError=`We can't upload your file because it's too small. Files must be at least ${this.formatFileSize(this.minFileSize)}.`,void this.resetState()):(this.uploadedFile=null,this.file=e,t&&this.vaChange.emit({files:[this.file]}),this.uploadStatus="success",this.internalError=null,e.size<this.FILE_PREVIEW_SIZE_LIMIT&&this.generateFileContents(this.file),this.updateStatusMessage(`You have selected the file: ${this.file.name}`),this.el.focus(),void(this.enableAnalytics&&this.componentLibraryAnalytics.emit({componentName:"va-file-input",action:"change",details:{label:this.label}})))},this.removeFile=(e=!0)=>{this.closeModal(),this.uploadStatus="idle",this.internalError=null,e&&this.vaChange.emit({files:[]}),this.file=null,this.uploadedFile=null,this.updateStatusMessage("File removed. No file selected."),this.el.focus()},this.openModal=()=>{this.el.shadowRoot.querySelector("va-modal").setAttribute("status","warning"),this.showModal=!0},this.closeModal=()=>{this.showModal=!1,setTimeout((()=>{this.fileInputRef.focus()}),0)},this.changeFile=()=>{this.fileInputRef&&this.fileInputRef.click()},this.formatFileSize=e=>{const t=["B","KB","MB","GB","TB"];if(0===e)return"0 B";const i=Math.floor(Math.log(e)/Math.log(1024));return 0===i?`${e} ${t[i]}`:`${(e/Math.pow(1024,i)).toFixed(i<2?0:1)} ${t[i]}`},this.normalizeAcceptProp=e=>e.split(",").map((e=>(e=e.trim()).startsWith(".")?extensionToMimeType[e]:e)),this.isAcceptedFileType=(e,t)=>{for(const i of t){if(i===e)return!0;if(i.endsWith("/*")&&e.startsWith(i.slice(0,-1)))return!0}return!1},this.renderLabelOrHeader=(e,t,i)=>{const a=t?h("span",{class:"required"}," ",instance.t("required")):null;return h("div",{class:"label-header"},i&&i>=1&&i<=6?h(`h${i}`,{htmlFor:"fileInputField",part:"label",class:"label-header-tag"},e,a):h("label",{htmlFor:"fileInputField",part:"label",class:"usa-label"},e,a))},this.file=void 0,this.fileContents=void 0,this.internalError=void 0,this.showModal=!1,this.showSeparator=!0,this.label=void 0,this.name=void 0,this.buttonText=void 0,this.value=void 0,this.required=!1,this.accept=void 0,this.error=void 0,this.hint=void 0,this.statusText=void 0,this.uploadMessage=null,this.enableAnalytics=!1,this.headerSize=void 0,this.headless=!1,this.readOnly=!1,this.encrypted=!1,this.uploadedFile=void 0,this.maxFileSize=1/0,this.minFileSize=0,this.percentUploaded=null,this.passwordError=void 0,this.resetVisualState=!1}handleValueChange(e){setTimeout((()=>{this.updateStatusMessage(e)}))}percentHandler(e){e>=100&&this.resetState()}handleError(e){e&&this.resetState()}resetState(){this.fileContents=null,this.uploadStatus="idle",this.percentUploaded=null,forceUpdate(this.el)}updateStatusMessage(e){setTimeout((()=>{const t=this.el.shadowRoot.querySelector("#statusMessage");t&&(t.textContent=e)}),1e3)}generateFileContents(e){if(!e)return;const t=new FileReader;this.fileType=e.type,t.onloadend=()=>{this.fileContents=t.result},this.fileType&&("application/pdf"===this.fileType||this.fileType.startsWith("image/"))&&t.readAsDataURL(e)}componentWillRender(){const e=!!this.el.querySelector(":scope > *"),t=!(!this.value&&!this.file||this.readOnly);this.showSeparator=e||t}componentDidLoad(){fileInput.init(this.el)}connectedCallback(){this.el.addEventListener("change",this.handleChange)}disconnectedCallback(){this.el.removeEventListener("change",this.handleChange)}getDefaultUploadMessage(){return h("span",null,this.dragFileString,h("span",{class:"file-input-choose-text"},this.chooseFileString))}handlePasswordChange(e){this.vaPasswordChange.emit({password:e.target.value})}render(){const{label:e,name:t,required:i,accept:a,error:s,hint:r,file:o,uploadStatus:n,dragFileString:l,chooseFileString:d,uploadMessage:c,headerSize:f,fileContents:p,fileType:u,headless:m,value:b,readOnly:g,encrypted:v,statusText:S,uploadedFile:E,percentUploaded:A,passwordError:_,resetVisualState:C}=this;b&&!this.file&&this.handleFile(b,!1);const x=s||this.internalError,y=`${r?"input-hint-message":""} ${x?"input-error-message":""}`.trim()||null,L=("file-input-target "+(x?"file-input-target-error":"")).trim();let w=h("div",{key:"a8147f8da0cb8b080f33d487afba34d00a375ba5",class:"thumbnail-container"},h("svg",{key:"9adc7d012279d6d1c387473ec20bdd30398d594a",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"#07648d",width:"40px",height:"40px"},h("path",{key:"6122c0411f084eda2039356f9e8c2464ddf4782e",d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm160-14.1v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"})));s?w=h("div",{key:"f74993cb63fea2aaadb69feab51e3d6c5eec135a",class:"thumbnail-container"},h("va-icon",{key:"fd79026cb78d04036aa7abd4f11b72f3c5146972",icon:"error",size:3,class:"thumbnail-preview thumbnail-error"})):p&&(u.startsWith("image/")?w=h("div",{key:"bb009cbbb587c00d29dad4cc135b4c6effd81d4a",class:"thumbnail-container","aria-hidden":"true"},h("img",{key:"2a572be0dc1579962b4ccf96365de48cdcab697d",class:"thumbnail-preview",src:p,alt:"image"})):"application/pdf"===u&&(w=h("div",{key:"f0318c876c0c48cff42e5fdf5781388b37dd7c5e",class:"thumbnail-container","aria-hidden":"true"},h("object",{key:"fac0943836f9f502ca82b029260ee60a4be06dfc",class:"thumbnail-preview",data:p,type:"application/pdf"}))));let I=m?"headless-selected-files-wrapper":"selected-files-wrapper";const T="usa-hint"+(m?" usa-sr-only":""),F=null!==A&&A<100;let R="file-status-label";return F&&(R=`${R} uploading-status`),h(Host,{key:"37781c9877d7f5c181df4dbc42adaa501044da54",class:{"has-error":!!x}},!g&&h("span",{key:"4cafef4d3360af3e1e20b5abee7116427678d1d7",class:{"usa-sr-only":!!m}},e&&this.renderLabelOrHeader(e,i,f)),r&&!g&&h("div",{key:"c0d30f964f241573f83e3178049425e6fb74bc65",class:T,id:"input-hint-message"},r),h("div",{key:"d7c4321d873eef1f4cf50a82955674d2d62db8ac",class:"file-input-wrapper",onDrop:this.handleDrop},h("input",{key:"fcdfc42a3a71d2c5495a54e7c4b39dd491095ea5",id:"fileInputField",class:"file-input","aria-label":`${e}${i?" "+instance.t("required"):""}. ${l}${d}`,style:{visibility:"success"===this.uploadStatus||E?"hidden":"unset"},type:"file",ref:e=>this.fileInputRef=e,name:t,accept:a,"aria-describedby":y,onChange:this.handleChange}),"idle"===n&&(!E||C)&&h("div",{key:"758b3ade629346c31843f28b2d0a3f21d0987a3f"},h("span",{key:"130f00af6b61bbaeffe7f82ca11fec45365d5f04",id:"file-input-error-alert",role:"alert"},x&&h(Fragment,{key:"70681de5a0f6f56a447b75ca76fb39602ec43f09"},h("span",{key:"1f15abf78d104092a9c25c3a5b9ea2f6b8e28a92",class:"usa-sr-only"},instance.t("error")),h("span",{key:"f1d535d569c6c1e5e217e087032a209b5f7d3bce",class:"usa-error-message"},x))),h("div",{key:"c4003675c5243e6db58660159faa275a1c46ec5e",class:"usa-sr-only","aria-live":"polite",id:"statusMessage"}),h("div",{key:"d90c463c57946bb09419da3f39e364d10024fab8",class:L},h("div",{key:"efdc66ddc32316bf8223bd171761cac515837c6f",class:"file-input-box"}),h("div",{key:"56a57c1e586ddad014a52c54e79e722f48523f6a",class:"file-input-instructions"},c||this.getDefaultUploadMessage()))),!C&&("idle"!==n||E)&&h("div",{key:"e0dec646ae39cc6cbbe358f0ea376b032522ecb9",class:I},!m&&h("div",{key:"350a72c12e41fb2f3b6185f4e384bf18a62e1c1b",class:"selected-files-label"},g?"Files you uploaded":"Selected files"),h("div",{key:"6d99979169229ac6d3793bdcc287ffc52c2a5d77",class:"usa-sr-only","aria-live":"polite",id:"statusMessage"}),h("va-card",{key:"f8e12be2be5e1cdd9cb85ea879ba11c9ec794299",class:"va-card"},h("div",{key:"830095c8b6eed03024d24f8afc523b84b4ec2275",class:"file-info-section"},w,h("div",{key:"55c5c74f081461a461593ebda2d87c828e8a4ccb",class:"file-info-group vads-u-line-height--2"},h("span",{key:"ffaac7a0b5faae4cb7b80ead605f5a01f8b942b2",class:"file-label"},o?o.name:E.name),x&&h("span",{key:"08d6db853f80afef3771c1d95d39555f26c41dbc",id:"input-error-message",role:"alert"},h("span",{key:"022ac299251482dfb5573b893e8bc2e258777d95",class:"usa-sr-only"},instance.t("error")),h("span",{key:"76e7aaac76ce6fb4546547461380c4563cec6e13","aria-live":"polite",class:"usa-error-message"},x)),!F&&h("span",{key:"5a0d65be1cd32bf27a29ea54acf8b11286ccd9b6",class:"file-size-label"},this.formatFileSize(o?o.size:E.size)),h("span",{key:"5c449f21a0bf5f2370901414da78d996fdbad733",class:R,"aria-live":"polite"},F?"Uploading...":S))),(o||b||E)&&h("div",{key:"0019699b466d8378d34de9501fb54e509db14e6e"},this.showSeparator&&h("hr",{key:"cfdd71b6c6f6cf29199d31eb4ec59833d3e3835d",class:"separator"}),v&&h("va-text-input",{key:"1db7bf8bfd8039c9dd042029887a87b27f4ce7e0",onInput:e=>{this.handlePasswordChange(e)},label:"File password",required:!0,error:_}),h("div",{key:"c996bde181bd3301abacb7595708872293cd1565",class:"additional-info-slot"},h("slot",{key:"b79a5b765a7d004ee98c399a93b2ce405ee9a051"})),g?null:F?h(Fragment,null,h("va-progress-bar",{percent:A}),h("va-button-icon",{buttonType:"cancel",onClick:this.resetState.bind(this)})):h(Fragment,null,h("div",{class:"file-button-section"},h("va-button-icon",{buttonType:"change-file",onClick:this.changeFile,label:"Change file","aria-label":`change file ${o?o.name:E.name}`}),h("va-button-icon",{buttonType:"delete",onClick:this.openModal,"aria-label":`delete file ${o?o.name:E.name}`,label:"Delete"})),h("va-modal",{modalTitle:"Delete this file?",visible:this.showModal,primaryButtonText:"Yes, remove this",secondaryButtonText:"No, keep this",onCloseEvent:this.closeModal,onPrimaryButtonClick:()=>this.removeFile(!0),onSecondaryButtonClick:this.closeModal},"We'll delete the uploaded file"," ",h("span",{class:"file-label"},o?o.name:E.name))))))))}get el(){return this}static get watchers(){return{statusText:["handleValueChange"],percentUploaded:["percentHandler"],resetVisualState:["handleError"]}}static get style(){return VaFileInputStyle0}},[1,"va-file-input",{label:[1],name:[1],buttonText:[1,"button-text"],value:[16],required:[4],accept:[1],error:[1],hint:[1],statusText:[1,"status-text"],uploadMessage:[16],enableAnalytics:[4,"enable-analytics"],headerSize:[2,"header-size"],headless:[4],readOnly:[4,"read-only"],encrypted:[4],uploadedFile:[16],maxFileSize:[2,"max-file-size"],minFileSize:[2,"min-file-size"],percentUploaded:[1026,"percent-uploaded"],passwordError:[1,"password-error"],resetVisualState:[1028,"reset-visual-state"],file:[32],fileContents:[32],internalError:[32],showModal:[32],showSeparator:[32]},void 0,{statusText:["handleValueChange"],percentUploaded:["percentHandler"],resetVisualState:["handleError"]}]);function defineCustomElement(){"undefined"!=typeof customElements&&["va-file-input","va-button","va-button-icon","va-card","va-icon","va-modal","va-progress-bar","va-text-input"].forEach((e=>{switch(e){case"va-file-input":customElements.get(e)||customElements.define(e,VaFileInput);break;case"va-button":customElements.get(e)||defineCustomElement$7();break;case"va-button-icon":customElements.get(e)||defineCustomElement$6();break;case"va-card":customElements.get(e)||defineCustomElement$5();break;case"va-icon":customElements.get(e)||defineCustomElement$4();break;case"va-modal":customElements.get(e)||defineCustomElement$3();break;case"va-progress-bar":customElements.get(e)||defineCustomElement$2();break;case"va-text-input":customElements.get(e)||defineCustomElement$1()}}))}export{VaFileInput as V,defineCustomElement as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Build,proxyCustomElement,HTMLElement,createEvent,forceUpdate,h}from"@stencil/core/internal/client";import"./i18n-setup.js";import"./contacts.js";import{c as consoleDevError}from"./utils.js";import{d as defineCustomElement$2}from"./va-icon2.js";import{i as instance}from"./i18next.js";const vaOnThisPageCss='p,a,ol,ul,li,dl,dt,dd,form,label,button{font-family:Source Sans Pro Web, "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans;font-size:1.06rem;line-height:1.5}button:not([disabled]):focus,select:not([disabled]):focus,a:not([disabled]):focus,h1:focus,input:not([disabled]):focus,textarea:not([disabled]):focus,#form-question [role=\'option\']:focus,*[tabindex]:focus,a.va-sidenav-submenu__link:focus{outline:2px solid var(--vads-color-action-focus-on-light);outline-offset:2px;z-index:2}a{text-decoration:none;color:var(--vads-color-link);-webkit-transition-duration:0.3s;transition-duration:0.3s;-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-property:color, background-color, border-color;transition-property:color, background-color, border-color}a:hover{background-color:rgba(0, 0, 0, 0.05);color:inherit}a:visited{color:var(--vads-color-link-visited)}:host{display:block;border:1px solid var(--vads-color-base-light);border-radius:4px;padding:1em}@media (min-width: 768px){:host{border:none;padding:1em 1em 1em 0}}#on-this-page{font-family:var(--font-serif);font-size:1.25rem;margin:0.4em 0em}ul{margin-top:0;margin-bottom:0;margin-left:0;list-style-type:none;padding-left:0}li{padding:0.5em;max-width:var(--vads-size-line-length-4)}li a{line-height:1.5em;display:-ms-flexbox;display:flex}li:hover{background-color:rgba(0, 0, 0, 0.05)}li a:hover{background-color:transparent}va-icon{margin-right:4px;padding-top:4px;line-height:1}',VaOnThisPageStyle0=vaOnThisPageCss;Build.isTesting&&instance.init({lng:"cimode"});const VaOnThisPage$1=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.componentLibraryAnalytics=createEvent(this,"component-library-analytics",7),this.handleOnClick=e=>{var t,n,i,o;this.disableAnalytics||this.componentLibraryAnalytics.emit({componentName:"va-on-this-page",action:"click",details:{"click-text":(null===(n=null===(t=e.composedPath())||void 0===t?void 0:t[0])||void 0===n?void 0:n.textContent)||(null===(o=null===(i=e.path)||void 0===i?void 0:i[0])||void 0===o?void 0:o.textContent)}})},this.disableAnalytics=!1}connectedCallback(){instance.on("languageChanged",(()=>{forceUpdate(this.el)}))}disconnectedCallback(){instance.off("languageChanged")}render(){const{handleOnClick:e}=this,t=Array.from(document.querySelectorAll("article h2")).filter((e=>(e.id||consoleDevError(`${e.textContent} is missing an id`),e.id)));return h("nav",{"aria-labelledby":"on-this-page"},h("ul",null,h("li",{id:"on-this-page"},instance.t("on-this-page")),t.map((t=>h("li",null,h("a",{href:`#${t.id}`,onClick:e},h("va-icon",{icon:"arrow_downward"}),h("span",null,t.innerText)))))))}get el(){return this}static get style(){return VaOnThisPageStyle0}},[1,"va-on-this-page",{disableAnalytics:[4,"disable-analytics"]}]);function defineCustomElement$1(){"undefined"!=typeof customElements&&["va-on-this-page","va-icon"].forEach((e=>{switch(e){case"va-on-this-page":customElements.get(e)||customElements.define(e,VaOnThisPage$1);break;case"va-icon":customElements.get(e)||defineCustomElement$2()}}))}const VaOnThisPage=VaOnThisPage$1,defineCustomElement=defineCustomElement$1;export{VaOnThisPage,defineCustomElement};
|
|
1
|
+
import{Build,proxyCustomElement,HTMLElement,createEvent,forceUpdate,h}from"@stencil/core/internal/client";import"./i18n-setup.js";import"./contacts.js";import{c as consoleDevError}from"./utils.js";import{d as defineCustomElement$2}from"./va-icon2.js";import{i as instance}from"./i18next.js";const vaOnThisPageCss='p,a,ol,ul,li,dl,dt,dd,form,label,button{font-family:Source Sans Pro Web, "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans;font-size:1.06rem;line-height:1.5}button:not([disabled]):focus,select:not([disabled]):focus,a:not([disabled]):focus,h1:focus,input:not([disabled]):focus,textarea:not([disabled]):focus,#form-question [role=\'option\']:focus,*[tabindex]:focus,a.va-sidenav-submenu__link:focus{outline:2px solid var(--vads-color-action-focus-on-light);outline-offset:2px;z-index:2}a{text-decoration:none;color:var(--vads-color-link);-webkit-transition-duration:0.3s;transition-duration:0.3s;-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-property:color, background-color, border-color;transition-property:color, background-color, border-color}a:hover{background-color:rgba(0, 0, 0, 0.05);color:inherit}a:visited{color:var(--vads-color-link-visited)}:host{display:block;border:1px solid var(--vads-color-base-light);border-radius:4px;padding:1em}@media (min-width: 768px){:host{border:none;padding:1em 1em 1em 0}}#on-this-page{font-family:var(--font-serif);font-size:1.25rem;margin:0.4em 0em}ul{margin-top:0;margin-bottom:0;margin-left:0;list-style-type:none;padding-left:0}li{padding:0.5em;max-width:var(--vads-size-line-length-4)}li a{line-height:1.5em;display:-ms-flexbox;display:flex}li:hover{background-color:rgba(0, 0, 0, 0.05)}li a:hover{background-color:transparent}va-icon{margin-right:4px;padding-top:4px;line-height:1}',VaOnThisPageStyle0=vaOnThisPageCss;Build.isTesting&&instance.init({lng:"cimode"});const VaOnThisPage$1=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.componentLibraryAnalytics=createEvent(this,"component-library-analytics",7),this.handleHeadingBlur=e=>{const t=e.target;t.removeAttribute("tabindex"),t.removeAttribute("role")},this.moveFocusToHeading=e=>{const t=e.currentTarget,n=document.getElementById(t.hash.slice(1));n&&(n.setAttribute("tabindex","-1"),n.setAttribute("role","text"),n.focus(),n.addEventListener("blur",this.handleHeadingBlur,{once:!0}))},this.handleOnClick=e=>{var t,n,i,o;this.moveFocusToHeading(e),this.disableAnalytics||this.componentLibraryAnalytics.emit({componentName:"va-on-this-page",action:"click",details:{"click-text":(null===(n=null===(t=e.composedPath())||void 0===t?void 0:t[0])||void 0===n?void 0:n.textContent)||(null===(o=null===(i=e.path)||void 0===i?void 0:i[0])||void 0===o?void 0:o.textContent)}})},this.disableAnalytics=!1}connectedCallback(){instance.on("languageChanged",(()=>{forceUpdate(this.el)}))}disconnectedCallback(){instance.off("languageChanged")}render(){const{handleOnClick:e}=this,t=Array.from(document.querySelectorAll("article h2")).filter((e=>(e.id||consoleDevError(`${e.textContent} is missing an id`),e.id)));return h("nav",{"aria-labelledby":"on-this-page"},h("ul",null,h("li",{id:"on-this-page"},instance.t("on-this-page")),t.map((t=>h("li",null,h("a",{href:`#${t.id}`,onClick:e},h("va-icon",{icon:"arrow_downward"}),h("span",null,t.innerText)))))))}get el(){return this}static get style(){return VaOnThisPageStyle0}},[1,"va-on-this-page",{disableAnalytics:[4,"disable-analytics"]}]);function defineCustomElement$1(){"undefined"!=typeof customElements&&["va-on-this-page","va-icon"].forEach((e=>{switch(e){case"va-on-this-page":customElements.get(e)||customElements.define(e,VaOnThisPage$1);break;case"va-icon":customElements.get(e)||defineCustomElement$2()}}))}const VaOnThisPage=VaOnThisPage$1,defineCustomElement=defineCustomElement$1;export{VaOnThisPage,defineCustomElement};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{proxyCustomElement,HTMLElement,forceUpdate,h,Host}from"@stencil/core/internal/client";import{d as defineCustomElement$4}from"./va-accordion2.js";import{d as defineCustomElement$3}from"./va-accordion-item2.js";import{d as defineCustomElement$2}from"./va-icon2.js";const vaSidenavCss=":host{display:block}.va-sidenav__list{margin-bottom:0;margin-top:0;list-style-type:none;padding-left:0;font-size:var(--vads-font-size-source-sans-normalized);line-height:var(--vads-font-line-height-2);border-top:1px solid var(--vads-color-base-lighter)}.va-sidenav__header{-ms-flex-align:center;align-items:center;color:var(--vads-color-base);display:-ms-flexbox;display:flex;font-family:var(--font-serif);font-size:var(--font-size-h4);font-weight:var(--font-weight-bold);margin-bottom:12px;margin-top:0}.va-sidenav__header .va-sidenav__icon-background{font-size:24px}.va-sidenav__icon-background{color:var(--vads-color-white);border-radius:50%;width:40px;height:40px;margin-right:8px;position:relative}.va-sidenav__icon-background va-icon{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%)}va-accordion-item::part(accordion-header){padding-left:1.4rem}",VaSidenavStyle0=vaSidenavCss,TABLET_BREAKPOINT=640,VaSidenav$1=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.isDesktop=window.innerWidth>640,this.iconBackgroundColorStyle=()=>({backgroundColor:`var(--${this.iconBackgroundColor})`}),this.ariaLabel="Related pages menu",this.header=void 0,this.iconName=void 0,this.iconBackgroundColor="vads-color-primary"}handleResize(){this.isDesktop=window.innerWidth>640,forceUpdate(this)}setOnlyOneCurrentPage(){this.el.querySelectorAll("va-sidenav-item[current-page], va-sidenav-submenu[current-page]").forEach(((e,t)=>{t>0&&e.setAttribute("current-page","false")}))}setupCurrentPageObserver(){this.mutationObserver=new MutationObserver((e=>{const t=e.filter((e=>"attributes"===e.type&&"current-page"===e.attributeName));if(t.length>0){const e=t[0].target;"true"===e.getAttribute("current-page")&&this.el.querySelectorAll("va-sidenav-item[current-page], va-sidenav-submenu[current-page]").forEach((t=>{t!==e&&t.removeAttribute("current-page")}))}})),this.mutationObserver.observe(this.el,{attributes:!0,attributeFilter:["current-page"],subtree:!0})}componentWillLoad(){this.setOnlyOneCurrentPage()}componentDidLoad(){this.setupCurrentPageObserver()}disconnectedCallback(){this.mutationObserver&&this.mutationObserver.disconnect()}render(){return this.isDesktop?h(Host,null,h("nav",{"aria-label":this.ariaLabel},this.header&&h("
|
|
1
|
+
import{proxyCustomElement,HTMLElement,forceUpdate,h,Host}from"@stencil/core/internal/client";import{d as defineCustomElement$4}from"./va-accordion2.js";import{d as defineCustomElement$3}from"./va-accordion-item2.js";import{d as defineCustomElement$2}from"./va-icon2.js";const vaSidenavCss=":host{display:block}.va-sidenav__list{margin-bottom:0;margin-top:0;list-style-type:none;padding-left:0;font-size:var(--vads-font-size-source-sans-normalized);line-height:var(--vads-font-line-height-2);border-top:1px solid var(--vads-color-base-lighter)}.va-sidenav__header{-ms-flex-align:center;align-items:center;color:var(--vads-color-base);display:-ms-flexbox;display:flex;font-family:var(--font-serif);font-size:var(--font-size-h4);font-weight:var(--font-weight-bold);margin-bottom:12px;margin-top:0}.va-sidenav__header .va-sidenav__icon-background{font-size:24px}.va-sidenav__icon-background{color:var(--vads-color-white);border-radius:50%;width:40px;height:40px;margin-right:8px;position:relative}.va-sidenav__icon-background va-icon{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%)}va-accordion-item::part(accordion-header){padding-left:1.4rem}",VaSidenavStyle0=vaSidenavCss,TABLET_BREAKPOINT=640,VaSidenav$1=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.isDesktop=window.innerWidth>640,this.iconBackgroundColorStyle=()=>({backgroundColor:`var(--${this.iconBackgroundColor})`}),this.ariaLabel="Related pages menu",this.header=void 0,this.iconName=void 0,this.iconBackgroundColor="vads-color-primary"}handleResize(){this.isDesktop=window.innerWidth>640,forceUpdate(this)}setOnlyOneCurrentPage(){this.el.querySelectorAll("va-sidenav-item[current-page], va-sidenav-submenu[current-page]").forEach(((e,t)=>{t>0&&e.setAttribute("current-page","false")}))}setupCurrentPageObserver(){this.mutationObserver=new MutationObserver((e=>{const t=e.filter((e=>"attributes"===e.type&&"current-page"===e.attributeName));if(t.length>0){const e=t[0].target;"true"===e.getAttribute("current-page")&&this.el.querySelectorAll("va-sidenav-item[current-page], va-sidenav-submenu[current-page]").forEach((t=>{t!==e&&t.removeAttribute("current-page")}))}})),this.mutationObserver.observe(this.el,{attributes:!0,attributeFilter:["current-page"],subtree:!0})}componentWillLoad(){this.setOnlyOneCurrentPage()}componentDidLoad(){this.setupCurrentPageObserver()}disconnectedCallback(){this.mutationObserver&&this.mutationObserver.disconnect()}render(){return this.isDesktop?h(Host,null,h("nav",{"aria-label":this.ariaLabel},this.header&&h("span",{class:"va-sidenav__header"},this.iconName?h("span",{class:"va-sidenav__icon-background",style:this.iconBackgroundColorStyle()},h("va-icon",{icon:this.iconName})):null,this.header),h("div",{role:"list",class:"va-sidenav__list"},h("slot",null)))):h(Host,null,h("va-accordion",{"open-single":!0},h("va-accordion-item",{bordered:!0,header:this.ariaLabel},h("nav",{"aria-label":this.ariaLabel},h("div",{role:"list",class:"va-sidenav__list"},h("slot",null))))))}get el(){return this}static get style(){return VaSidenavStyle0}},[1,"va-sidenav",{header:[1],iconName:[1,"icon-name"],iconBackgroundColor:[1,"icon-background-color"]},[[9,"resize","handleResize"]]]);function defineCustomElement$1(){"undefined"!=typeof customElements&&["va-sidenav","va-accordion","va-accordion-item","va-icon"].forEach((e=>{switch(e){case"va-sidenav":customElements.get(e)||customElements.define(e,VaSidenav$1);break;case"va-accordion":customElements.get(e)||defineCustomElement$4();break;case"va-accordion-item":customElements.get(e)||defineCustomElement$3();break;case"va-icon":customElements.get(e)||defineCustomElement$2()}}))}const VaSidenav=VaSidenav$1,defineCustomElement=defineCustomElement$1;export{VaSidenav,defineCustomElement};
|
package/format-date.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return
|
|
1
|
+
"use strict";function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==_typeof(t)?t:t+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.isDateSameDay=exports.isDateBefore=exports.isDateAfter=exports.formatTime=exports.formatDateShort=exports.formatDate=void 0;var formatDate=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{dateStyle:"full",timeStyle:"short"},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"America/New_York";if(e&&e instanceof Date)return e.toLocaleString("en-US",_objectSpread(_objectSpread({},t),{},{timeZone:r}))};exports.formatDate=formatDate;var formatDateShort=function(e,t){return formatDate(e,{dateStyle:"full"},t)};exports.formatDateShort=formatDateShort;var formatTime=function(e,t){return formatDate(e,{timeStyle:"short"},t)};exports.formatTime=formatTime;var isDateAfter=function(e,t){if(e&&e instanceof Date&&t&&t instanceof Date)return e.getTime()>t.getTime()};exports.isDateAfter=isDateAfter;var isDateBefore=function(e,t){if(e&&e instanceof Date&&t&&t instanceof Date)return e.getTime()<t.getTime()};exports.isDateBefore=isDateBefore;var isDateSameDay=function(e,t){if(e&&e instanceof Date&&t&&t instanceof Date)return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDay()===t.getDay()};exports.isDateSameDay=isDateSameDay;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@department-of-veterans-affairs/component-library",
|
|
3
3
|
"description": "VA.gov component library. Includes React and web components.",
|
|
4
|
-
"version": "51.
|
|
4
|
+
"version": "51.4.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "webpack"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"module": "src/main.js",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@department-of-veterans-affairs/react-components": "28.1.0",
|
|
19
|
-
"@department-of-veterans-affairs/web-components": "19.
|
|
19
|
+
"@department-of-veterans-affairs/web-components": "19.4.0",
|
|
20
20
|
"i18next": "^21.6.14",
|
|
21
21
|
"i18next-browser-languagedetector": "^6.1.4",
|
|
22
22
|
"react-focus-on": "^3.5.1",
|
|
@@ -32,7 +32,6 @@
|
|
|
32
32
|
"webpack-cli": "^4.8.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@department-of-veterans-affairs/formation": "*",
|
|
36
35
|
"react": "^18",
|
|
37
36
|
"react-dom": "*"
|
|
38
37
|
}
|
package/test-helpers.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.axeCheck=axeCheck,exports.mountToDiv=mountToDiv,exports.testAnalytics=testAnalytics;var _enzyme=require("enzyme"),_sinon=_interopRequireDefault(require("sinon"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.axeCheck=axeCheck,exports.mountToDiv=mountToDiv,exports.testAnalytics=testAnalytics;var _enzyme=require("enzyme"),_sinon=_interopRequireDefault(require("sinon"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function mountToDiv(e,t){var r=document.getElementById(t);return r||((r=document.createElement("div")).setAttribute("id",t),document.body.appendChild(r)),r.innerHTML="",(0,_enzyme.mount)(e,{attachTo:r})}function axeCheck(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=document.getElementById("axeContainer");n||((n=document.createElement("div")).setAttribute("id","axeContainer"),document.body.appendChild(n)),n.setAttribute("role","region"),n.setAttribute("aria-label","Component ".concat(Math.floor(Math.random()*Math.floor(100)))),n.innerHTML="";var o=(0,_enzyme.mount)(e,{attachTo:n});return r&&o.setState(r),new Promise((function(e,r){axe.run(document.body,(function(n,a){n&&(console.error(n),r(n));var i=a.violations.filter((function(e){return!t.includes(e.id)}));i.length&&r(new Error(i.map((function(e){var t=e.nodes.reduce((function(e,t){var r=t.html,n=t.target;return[e,r].concat(_toConsumableArray(n)).join("\n")}),"");return"[".concat(e.impact,"] ").concat(e.help,"\nId: ").concat(e.id,"\nSee ").concat(e.helpUrl,"\n").concat(t)})).join("\n"))),o.unmount(),e()}))}))}function testAnalytics(e,t){var r=_sinon.default.spy();return global.document.body.addEventListener("component-library-analytics",r),t(e),global.document.body.removeEventListener("component-library-analytics",r),r}
|