scb-wc 0.1.109 → 0.1.111
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/fonts/material-symbols-outlined/files/material-symbols-outlined-subset.woff2 +0 -0
- package/mvc/components/scb-dialog/scb-dialog.js +3 -3
- package/mvc/components/scb-textfield/scb-textfield.js +38 -36
- package/mvc/fonts/material-symbols-outlined/files/material-symbols-outlined-subset.woff2 +0 -0
- package/package.json +2 -2
- package/scb-components/scb-dialog/scb-dialog.d.ts +2 -0
- package/scb-components/scb-textfield/scb-textfield.d.ts +2 -0
- package/scb-datepicker/scb-datepicker.js +6 -3
- package/scb-dialog/scb-dialog.js +25 -2
- package/scb-textfield/scb-textfield.js +10 -4
- package/scb-wc.bundle.js +12 -10
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as p,h as f,m as b,p as s,v as r,y as v}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import{t as n}from"../../vendor/decorate.js";import"../scb-button/scb-button.js";import"../scb-icon-button/scb-icon-button.js";import"../scb-textfield/scb-textfield.js";import"../scb-checkbox/scb-checkbox.js";import"../scb-radio-button/scb-radio-button.js";import"../scb-switch/scb-switch.js";import"../scb-chip/scb-chip.js";(function(){try{var d=typeof globalThis<"u"?globalThis:window;if(!d.__scb_ce_guard_installed__){d.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,i,o){try{customElements.get(t)||e(t,i,o)}catch(c){var l=String(c||"");if(l.indexOf("already been used")===-1&&l.indexOf("NotSupportedError")===-1)throw c}}}}catch{}})();var h,g={fromAttribute(d){if(d===null)return!1;const e=d.trim().toLowerCase();return e!=="false"&&e!=="0"&&e!=="no"}},a=(h=class extends f{constructor(...e){super(...e),this.open=!1,this.inSb=!1,this.scrimClose=!0,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.variant="basic",this.label="",this.icon="",this.supportingText="",this.okButton="OK",this.cancelButton="Avbryt",this.deleteButton="Delete",this.confirmButton="Ta bort",this.denyButton="Avbryt",this.resetButton="Återställ",this.submitButton="Spara",this.formId="",this.formAction="",this.formMethod="",this.__lastTriggerEl=null,this.__scrollLocked=!1,this.__onDocumentClick=t=>{this.__getActionFromEvent(t)==="toggle"&&(this.__setOpen(!this.open),t.stopPropagation())},this.__onDocumentKeydown=t=>{this.open&&t.key==="Escape"&&(this.__fire("esc"),this.__setOpen(!1))},this.__onScrimClick=()=>{this.scrimClose&&(this.__fire("scrim"),this.__setOpen(!1))},this.__onOk=()=>{this.__fire("ok"),this.__setOpen(!1)},this.__onCancel=()=>{this.__fire("cancel"),this.__setOpen(!1)},this.__onConfirm=()=>{this.__fire("confirm"),this.__setOpen(!1)},this.__onDeny=()=>{this.__fire("deny"),this.__setOpen(!1)},this.__onReset=()=>{const t=this.shadowRoot?.querySelector("form");t instanceof HTMLFormElement&&(this.__clearGeneratedFormValues(t),t.reset()),(this.shadowRoot?.querySelector("slot")?.assignedElements({flatten:!0})??[]).forEach(i=>{const o=i.tagName;o==="SCB-TEXTFIELD"&&(i.value=""),o==="SCB-CHECKBOX"&&(i.checked=!1),o==="SCB-RADIO-BUTTON"&&(i.checked=!1),o==="SCB-SWITCH"&&(i.selected=!1),o==="SCB-CHIP"&&(i.selected=!1)}),this.__fire("reset")},this.__onSubmit=()=>{const t=this.shadowRoot?.querySelector("form");if(t instanceof HTMLFormElement){if(this.__syncSlottedFormValues(t),!this.__validateFormAndSlottedFields(t))return;t.requestSubmit()}this.__fire("submit"),this.__setOpen(!1)},this.__onKeydownTrap=t=>{if(!this.open||t.key!=="Tab")return;const i=Array.from(this.shadowRoot.querySelectorAll('button,[href],input,select,textarea,[tabindex]:not([tabindex="-1"])')).filter(c=>!c.hasAttribute("disabled"));if(!i.length)return;const o=i[0],l=i[i.length-1];t.shiftKey&&document.activeElement===o?(l.focus(),t.preventDefault()):!t.shiftKey&&document.activeElement===l&&(o.focus(),t.preventDefault())}}__getActionFromEvent(e){if(!this.id)return null;for(const t of e.composedPath())if(t instanceof Element){if(t.getAttribute("data-dialog-toggle")===this.id)return this.__lastTriggerEl=t,"toggle";if(t.getAttribute("aria-controls")===this.id)return this.__lastTriggerEl=t,"toggle"}return null}connectedCallback(){super.connectedCallback(),this.__applyZIndex(),this.__applyMaxSize(),document.addEventListener("click",this.__onDocumentClick,!1),document.addEventListener("keydown",this.__onDocumentKeydown,!0),this.addEventListener("keydown",this.__onKeydownTrap)}disconnectedCallback(){document.removeEventListener("click",this.__onDocumentClick,!1),document.removeEventListener("keydown",this.__onDocumentKeydown,!0),this.removeEventListener("keydown",this.__onKeydownTrap),this.__toggleScrollLock(!1),super.disconnectedCallback()}__applyZIndex(){const e=typeof this.zIndex=="number"&&Number.isFinite(this.zIndex)?this.zIndex:void 0;if(e===void 0){this.style.removeProperty("--z-dialog-scrim"),this.style.removeProperty("--z-dialog");return}this.style.setProperty("--z-dialog-scrim",String(e)),this.style.setProperty("--z-dialog",String(e+1))}__applyMaxSize(){const e=(this.maxW??"").trim(),t=(this.maxH??"").trim();e?(this.style.setProperty("--scb-dialog-max-w",e),this.style.setProperty("--scb-dialog-width",`min(${e}, 90vw)`)):(this.style.removeProperty("--scb-dialog-max-w"),this.style.removeProperty("--scb-dialog-width")),t?this.style.setProperty("--scb-dialog-max-h",t):this.style.removeProperty("--scb-dialog-max-h")}updated(e){if(e.has("zIndex")&&this.__applyZIndex(),(e.has("maxW")||e.has("maxH"))&&this.__applyMaxSize(),e.has("open")){const t=e.get("open");this.__updateTriggersExpanded(),this.open&&!t?!this.inSb&&!this.__usesInPlaceLayout()&&this.updateComplete.then(()=>{const i=this.shadowRoot?.querySelector('button,[href],input,select,textarea,[tabindex]:not([tabindex="-1"])');i?i.focus():this.shadowRoot?.querySelector(".container")?.focus()}):!this.open&&t&&this.__lastTriggerEl?.focus?.(),this.__toggleScrollLock(this.open)}(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom")||e.has("spacingLeft")||e.has("spacingRight"))&&this.__applySpacing()}__updateTriggersExpanded(){this.id&&document.querySelectorAll(`[aria-controls="${this.id}"], [data-dialog-toggle="${this.id}"]`).forEach(e=>{e.hasAttribute("aria-controls")&&e.setAttribute("aria-expanded",String(this.open))})}__usesInPlaceLayout(){const e=getComputedStyle(this);return e.getPropertyValue("--scb-dialog-scrim-position").trim()==="relative"||e.getPropertyValue("--scb-dialog-container-position").trim()==="absolute"}__toggleScrollLock(e){const t=document.documentElement,i=document.body;if(e){if(this.__scrollLocked||this.inSb||this.__usesInPlaceLayout())return;const o=window.innerWidth-t.clientWidth;t.style.overflow="hidden",i.style.paddingRight=o>0?`${o}px`:"",this.__scrollLocked=!0;return}this.__scrollLocked&&(t.style.overflow="",i.style.paddingRight="",this.__scrollLocked=!1)}mapSpacingToken(e){if(!e)return;const t=String(e).trim();if(t)return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}__applySpacing(){const e=this.mapSpacingToken(this.spacing),t=this.mapSpacingToken(this.spacingTop)??e,i=this.mapSpacingToken(this.spacingBottom)??e,o=this.mapSpacingToken(this.spacingLeft),l=this.mapSpacingToken(this.spacingRight);t?this.style.setProperty("--scb-dialog-spacing-block-start",t):this.style.removeProperty("--scb-dialog-spacing-block-start"),i?this.style.setProperty("--scb-dialog-spacing-block-end",i):this.style.removeProperty("--scb-dialog-spacing-block-end"),o?this.style.setProperty("--scb-dialog-spacing-inline-start",o):this.style.removeProperty("--scb-dialog-spacing-inline-start"),l?this.style.setProperty("--scb-dialog-spacing-inline-end",l):this.style.removeProperty("--scb-dialog-spacing-inline-end")}__setOpen(e){this.open=e,this.__fire(e?"open":"close")}__fire(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}__getSlottedElements(){const e=this.shadowRoot?.querySelector("slot");if(!(e instanceof HTMLSlotElement))return[];const t=e.assignedElements({flatten:!0}),i=[];for(const o of t)i.push(o,...Array.from(o.querySelectorAll("*")));return i}__appendHiddenFormValue(e,t,i){const o=document.createElement("input");o.type="hidden",o.name=t,o.value=i,o.setAttribute("data-scb-dialog-generated","true"),e.append(o)}__clearGeneratedFormValues(e){e.querySelectorAll('input[data-scb-dialog-generated="true"]').forEach(t=>t.remove())}__syncSlottedFormValues(e){this.__clearGeneratedFormValues(e),this.__getSlottedElements().forEach(t=>{if(!(t instanceof HTMLElement))return;const i=(t.getAttribute("name")??"").trim();if(i&&!(t.disabled===!0||t.hasAttribute("disabled"))){if(t instanceof HTMLInputElement){if(t.form===e)return;const o=(t.type||"").toLowerCase();if(o==="checkbox"||o==="radio"){t.checked&&this.__appendHiddenFormValue(e,i,t.value||"on");return}this.__appendHiddenFormValue(e,i,t.value??"");return}if(t instanceof HTMLTextAreaElement){if(t.form===e)return;this.__appendHiddenFormValue(e,i,t.value??"");return}if(t instanceof HTMLSelectElement){if(t.form===e)return;if(t.multiple){Array.from(t.selectedOptions).forEach(o=>{this.__appendHiddenFormValue(e,i,o.value)});return}this.__appendHiddenFormValue(e,i,t.value??"");return}switch(t.tagName){case"SCB-TEXTFIELD":this.__appendHiddenFormValue(e,i,String(t.value??""));return;case"SCB-CHECKBOX":t.checked&&this.__appendHiddenFormValue(e,i,String(t.value??t.getAttribute("value")??"on"));return;case"SCB-RADIO-BUTTON":t.checked&&this.__appendHiddenFormValue(e,i,String(t.value??t.getAttribute("value")??"on"));return;case"SCB-SWITCH":(t.selected||t.checked)&&this.__appendHiddenFormValue(e,i,String(t.value??t.getAttribute("value")??"on"));return;case"SCB-CHIP":t.selected&&this.__appendHiddenFormValue(e,i,String(t.value??t.getAttribute("value")??"on"));return;default:"value"in t&&this.__appendHiddenFormValue(e,i,String(t.value??""))}}})}__validateFormAndSlottedFields(e){const t=c=>c.disabled===!0||c.hasAttribute("disabled");let i=e.reportValidity(),o=null;const l=new Set;return this.__getSlottedElements().forEach(c=>{if(!(c instanceof HTMLElement)||l.has(c)||t(c))return;l.add(c);const u=c;if(c.tagName==="SCB-TEXTFIELD"&&u.error===!0){o||(o=c),i=!1;return}if(typeof u.reportValidity=="function"){const m=!!u.reportValidity();!m&&!o&&(o=c),i=i&&m}}),!i&&o&&o.focus(),i}__slotIsEmpty(){const e=this.shadowRoot?.querySelector("slot");return e?e.assignedElements({flatten:!0}).length===0:!0}renderHeader(e){const t=this.variant==="form"||this.variant==="floating"||this.variant==="iframe";return r`
|
|
1
|
+
import{g as p,h as f,m as b,p as s,v as r,y as v}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import{t as a}from"../../vendor/decorate.js";import"../scb-button/scb-button.js";import"../scb-icon-button/scb-icon-button.js";import"../scb-textfield/scb-textfield.js";import"../scb-checkbox/scb-checkbox.js";import"../scb-radio-button/scb-radio-button.js";import"../scb-switch/scb-switch.js";import"../scb-chip/scb-chip.js";(function(){try{var d=typeof globalThis<"u"?globalThis:window;if(!d.__scb_ce_guard_installed__){d.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,i,o){try{customElements.get(t)||e(t,i,o)}catch(c){var l=String(c||"");if(l.indexOf("already been used")===-1&&l.indexOf("NotSupportedError")===-1)throw c}}}}catch{}})();var h,g={fromAttribute(d){if(d===null)return!1;const e=d.trim().toLowerCase();return e!=="false"&&e!=="0"&&e!=="no"}},n=(h=class extends f{constructor(...e){super(...e),this.open=!1,this.inSb=!1,this.scrimClose=!0,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.variant="basic",this.label="",this.icon="",this.supportingText="",this.okButton="OK",this.cancelButton="Avbryt",this.deleteButton="Delete",this.confirmButton="Ta bort",this.denyButton="Avbryt",this.resetButton="Återställ",this.submitButton="Spara",this.formId="",this.formAction="",this.formMethod="",this.__lastTriggerEl=null,this.__scrollLocked=!1,this.__onDocumentClick=t=>{this.__getActionFromEvent(t)==="toggle"&&(this.__setOpen(!this.open),t.stopPropagation())},this.__onDocumentKeydown=t=>{this.open&&t.key==="Escape"&&(this.__fire("esc"),this.__setOpen(!1))},this.__onScrimClick=()=>{this.scrimClose&&(this.__fire("scrim"),this.__setOpen(!1))},this.__onOk=()=>{this.__fire("ok"),this.__setOpen(!1)},this.__onCancel=()=>{this.__fire("cancel"),this.__setOpen(!1)},this.__onConfirm=()=>{this.__fire("confirm"),this.__setOpen(!1)},this.__onDeny=()=>{this.__fire("deny"),this.__setOpen(!1)},this.__onReset=()=>{const t=this.shadowRoot?.querySelector("form");t instanceof HTMLFormElement&&(this.__clearGeneratedFormValues(t),t.reset()),(this.shadowRoot?.querySelector("slot")?.assignedElements({flatten:!0})??[]).forEach(i=>{const o=i.tagName;o==="SCB-TEXTFIELD"&&(i.value=""),o==="SCB-CHECKBOX"&&(i.checked=!1),o==="SCB-RADIO-BUTTON"&&(i.checked=!1),o==="SCB-SWITCH"&&(i.selected=!1),o==="SCB-CHIP"&&(i.selected=!1)}),this.__fire("reset")},this.__onSubmit=()=>{const t=this.shadowRoot?.querySelector("form");if(t instanceof HTMLFormElement){if(this.__syncSlottedFormValues(t),!this.__validateFormAndSlottedFields(t))return;t.requestSubmit()}},this.__onFormSubmit=t=>{const i=t.currentTarget;if(!(i instanceof HTMLFormElement))return;if(this.__syncSlottedFormValues(i),!this.__validateFormAndSlottedFields(i)){t.preventDefault();return}const o=new FormData(i);if(!this.__fireCancelable("submit",{form:i,formData:o})){t.preventDefault();return}this.__setOpen(!1)},this.__onKeydownTrap=t=>{if(!this.open||t.key!=="Tab")return;const i=Array.from(this.shadowRoot.querySelectorAll('button,[href],input,select,textarea,[tabindex]:not([tabindex="-1"])')).filter(c=>!c.hasAttribute("disabled"));if(!i.length)return;const o=i[0],l=i[i.length-1];t.shiftKey&&document.activeElement===o?(l.focus(),t.preventDefault()):!t.shiftKey&&document.activeElement===l&&(o.focus(),t.preventDefault())}}__getActionFromEvent(e){if(!this.id)return null;for(const t of e.composedPath())if(t instanceof Element){if(t.getAttribute("data-dialog-toggle")===this.id)return this.__lastTriggerEl=t,"toggle";if(t.getAttribute("aria-controls")===this.id)return this.__lastTriggerEl=t,"toggle"}return null}connectedCallback(){super.connectedCallback(),this.__applyZIndex(),this.__applyMaxSize(),document.addEventListener("click",this.__onDocumentClick,!1),document.addEventListener("keydown",this.__onDocumentKeydown,!0),this.addEventListener("keydown",this.__onKeydownTrap)}disconnectedCallback(){document.removeEventListener("click",this.__onDocumentClick,!1),document.removeEventListener("keydown",this.__onDocumentKeydown,!0),this.removeEventListener("keydown",this.__onKeydownTrap),this.__toggleScrollLock(!1),super.disconnectedCallback()}__applyZIndex(){const e=typeof this.zIndex=="number"&&Number.isFinite(this.zIndex)?this.zIndex:void 0;if(e===void 0){this.style.removeProperty("--z-dialog-scrim"),this.style.removeProperty("--z-dialog");return}this.style.setProperty("--z-dialog-scrim",String(e)),this.style.setProperty("--z-dialog",String(e+1))}__applyMaxSize(){const e=(this.maxW??"").trim(),t=(this.maxH??"").trim();e?(this.style.setProperty("--scb-dialog-max-w",e),this.style.setProperty("--scb-dialog-width",`min(${e}, 90vw)`)):(this.style.removeProperty("--scb-dialog-max-w"),this.style.removeProperty("--scb-dialog-width")),t?this.style.setProperty("--scb-dialog-max-h",t):this.style.removeProperty("--scb-dialog-max-h")}updated(e){if(e.has("zIndex")&&this.__applyZIndex(),(e.has("maxW")||e.has("maxH"))&&this.__applyMaxSize(),e.has("open")){const t=e.get("open");this.__updateTriggersExpanded(),this.open&&!t?!this.inSb&&!this.__usesInPlaceLayout()&&this.updateComplete.then(()=>{const i=this.shadowRoot?.querySelector('button,[href],input,select,textarea,[tabindex]:not([tabindex="-1"])');i?i.focus():this.shadowRoot?.querySelector(".container")?.focus()}):!this.open&&t&&this.__lastTriggerEl?.focus?.(),this.__toggleScrollLock(this.open)}(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom")||e.has("spacingLeft")||e.has("spacingRight"))&&this.__applySpacing()}__updateTriggersExpanded(){this.id&&document.querySelectorAll(`[aria-controls="${this.id}"], [data-dialog-toggle="${this.id}"]`).forEach(e=>{e.hasAttribute("aria-controls")&&e.setAttribute("aria-expanded",String(this.open))})}__usesInPlaceLayout(){const e=getComputedStyle(this);return e.getPropertyValue("--scb-dialog-scrim-position").trim()==="relative"||e.getPropertyValue("--scb-dialog-container-position").trim()==="absolute"}__toggleScrollLock(e){const t=document.documentElement,i=document.body;if(e){if(this.__scrollLocked||this.inSb||this.__usesInPlaceLayout())return;const o=window.innerWidth-t.clientWidth;t.style.overflow="hidden",i.style.paddingRight=o>0?`${o}px`:"",this.__scrollLocked=!0;return}this.__scrollLocked&&(t.style.overflow="",i.style.paddingRight="",this.__scrollLocked=!1)}mapSpacingToken(e){if(!e)return;const t=String(e).trim();if(t)return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}__applySpacing(){const e=this.mapSpacingToken(this.spacing),t=this.mapSpacingToken(this.spacingTop)??e,i=this.mapSpacingToken(this.spacingBottom)??e,o=this.mapSpacingToken(this.spacingLeft),l=this.mapSpacingToken(this.spacingRight);t?this.style.setProperty("--scb-dialog-spacing-block-start",t):this.style.removeProperty("--scb-dialog-spacing-block-start"),i?this.style.setProperty("--scb-dialog-spacing-block-end",i):this.style.removeProperty("--scb-dialog-spacing-block-end"),o?this.style.setProperty("--scb-dialog-spacing-inline-start",o):this.style.removeProperty("--scb-dialog-spacing-inline-start"),l?this.style.setProperty("--scb-dialog-spacing-inline-end",l):this.style.removeProperty("--scb-dialog-spacing-inline-end")}__setOpen(e){this.open=e,this.__fire(e?"open":"close")}__fire(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}__fireCancelable(e,t){return this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0,cancelable:!0}))}__getSlottedElements(){const e=this.shadowRoot?.querySelector("slot");if(!(e instanceof HTMLSlotElement))return[];const t=e.assignedElements({flatten:!0}),i=[];for(const o of t)i.push(o,...Array.from(o.querySelectorAll("*")));return i}__appendHiddenFormValue(e,t,i){const o=document.createElement("input");o.type="hidden",o.name=t,o.value=i,o.setAttribute("data-scb-dialog-generated","true"),e.append(o)}__clearGeneratedFormValues(e){e.querySelectorAll('input[data-scb-dialog-generated="true"]').forEach(t=>t.remove())}__syncSlottedFormValues(e){this.__clearGeneratedFormValues(e),this.__getSlottedElements().forEach(t=>{if(!(t instanceof HTMLElement))return;const i=(t.getAttribute("name")??"").trim();if(i&&!(t.disabled===!0||t.hasAttribute("disabled"))){if(t instanceof HTMLInputElement){if(t.form===e)return;const o=(t.type||"").toLowerCase();if(o==="checkbox"||o==="radio"){t.checked&&this.__appendHiddenFormValue(e,i,t.value||"on");return}this.__appendHiddenFormValue(e,i,t.value??"");return}if(t instanceof HTMLTextAreaElement){if(t.form===e)return;this.__appendHiddenFormValue(e,i,t.value??"");return}if(t instanceof HTMLSelectElement){if(t.form===e)return;if(t.multiple){Array.from(t.selectedOptions).forEach(o=>{this.__appendHiddenFormValue(e,i,o.value)});return}this.__appendHiddenFormValue(e,i,t.value??"");return}switch(t.tagName){case"SCB-TEXTFIELD":this.__appendHiddenFormValue(e,i,String(t.value??""));return;case"SCB-CHECKBOX":t.checked&&this.__appendHiddenFormValue(e,i,String(t.value??t.getAttribute("value")??"on"));return;case"SCB-RADIO-BUTTON":t.checked&&this.__appendHiddenFormValue(e,i,String(t.value??t.getAttribute("value")??"on"));return;case"SCB-SWITCH":(t.selected||t.checked)&&this.__appendHiddenFormValue(e,i,String(t.value??t.getAttribute("value")??"on"));return;case"SCB-CHIP":t.selected&&this.__appendHiddenFormValue(e,i,String(t.value??t.getAttribute("value")??"on"));return;default:"value"in t&&this.__appendHiddenFormValue(e,i,String(t.value??""))}}})}__validateFormAndSlottedFields(e){const t=c=>c.disabled===!0||c.hasAttribute("disabled");let i=e.reportValidity(),o=null;const l=new Set;return this.__getSlottedElements().forEach(c=>{if(!(c instanceof HTMLElement)||l.has(c)||t(c))return;l.add(c);const u=c;if(c.tagName==="SCB-TEXTFIELD"&&u.error===!0){o||(o=c),i=!1;return}if(typeof u.reportValidity=="function"){const m=!!u.reportValidity();!m&&!o&&(o=c),i=i&&m}}),!i&&o&&o.focus(),i}__slotIsEmpty(){const e=this.shadowRoot?.querySelector("slot");return e?e.assignedElements({flatten:!0}).length===0:!0}renderHeader(e){const t=this.variant==="form"||this.variant==="floating"||this.variant==="iframe";return r`
|
|
2
2
|
<div class="header">
|
|
3
3
|
<div class="title">
|
|
4
4
|
${this.icon?r`<md-icon class="dialog-icon">${this.icon}</md-icon>`:p}
|
|
@@ -34,7 +34,7 @@ import{g as p,h as f,m as b,p as s,v as r,y as v}from"../../vendor/vendor.js";im
|
|
|
34
34
|
</div>`}}renderBody(e,t){return this.variant==="form"?r`
|
|
35
35
|
${this.renderHeader(e)}
|
|
36
36
|
<div class="content" id=${t}>
|
|
37
|
-
<form id=${this.formId} action=${this.formAction} method=${this.formMethod||p}>
|
|
37
|
+
<form id=${this.formId} action=${this.formAction} method=${this.formMethod||p} @submit=${this.__onFormSubmit}>
|
|
38
38
|
<slot></slot>
|
|
39
39
|
</form>
|
|
40
40
|
</div>
|
|
@@ -51,4 +51,4 @@ import{g as p,h as f,m as b,p as s,v as r,y as v}from"../../vendor/vendor.js";im
|
|
|
51
51
|
>
|
|
52
52
|
${this.renderBody(e,t)}
|
|
53
53
|
</div>
|
|
54
|
-
`}},h.styles=v`@keyframes scb-kf-fade-in{0%{opacity:0}to{opacity:1}}@keyframes scb-kf-fade-out{0%{opacity:1}to{opacity:0}}:host{display:block;position:relative;font-family:var(--brand-font, Inter, Arial, sans-serif);margin-block-start:var(--scb-dialog-spacing-block-start, 0);margin-block-end:var(--scb-dialog-spacing-block-end, 0);margin-inline-start:var(--scb-dialog-spacing-inline-start, 0);margin-inline-end:var(--scb-dialog-spacing-inline-end, 0)}.scrim{position:var(--scb-dialog-scrim-position, fixed);inset:0;background:color-mix(in srgb,var(--md-sys-color-scrim) 32%,transparent);z-index:var(--z-dialog-scrim, 1000);opacity:1;transition:opacity var(--motion-duration-short, 0.25s);transition-timing-function:var(--motion-easing-standard, cubic-bezier(0.2, 0, 0, 1));height:var(--scb-dialog-scrim-height, auto)}.container{outline:0;position:var(--scb-dialog-container-position, fixed);inset:50%auto auto 50%;transform:translate(-50%,-50%) scale(1);background:var(--md-sys-color-surface);color:var(--md-sys-color-on-surface);border-radius:var(--scb-dialog-radius, var(--spacing-5, 16px));box-shadow:0 var(--spacing-1, 2px) var(--spacing-5, 16px) color-mix(in srgb,var(--md-sys-color-shadow) 20%,transparent);min-width:var(--scb-dialog-min-w, 340px);width:var(--scb-dialog-width, auto);max-width:var(--scb-dialog-max-w, 90vw);max-height:var(--scb-dialog-max-h, 90vh);display:flex;flex-direction:column;padding:var(--scb-dialog-padding, var(--spacing-7, 24px));z-index:var(--z-dialog, 1001);opacity:1;transition:opacity var(--motion-duration-medium, 0.3s),transform var(--motion-duration-medium, 0.3s);transition-timing-function:var(--motion-easing-emphasized-decelerate, cubic-bezier(0.05, 0.7, 0.1, 1))}:host(:not([open])) .container,:host(:not([open])) .scrim{opacity:0;pointer-events:none}:host([open]) .scrim{animation:var(--motion-keyframe-fade-in, scb-kf-fade-in) var(--motion-duration-short, 0.25s) var(--motion-easing-standard, cubic-bezier(0.2, 0, 0, 1)) both}:host([open]) .container{animation:var(--motion-keyframe-fade-in, scb-kf-fade-in) var(--motion-duration-medium, 0.3s) var(--motion-easing-emphasized-decelerate, cubic-bezier(0.05, 0.7, 0.1, 1)) both}.header{display:flex;align-items:flex-start;gap:var(--spacing-4, 12px);margin-bottom:var(--spacing-5, 16px)}.header .title{display:flex;flex-direction:column;gap:var(--spacing-3, 8px)}.header .label{font-weight:var(--md-sys-typescale-headline-small-weight, 700);font-size:var(--md-sys-typescale-headline-small-size, 1.5rem);line-height:var(--md-sys-typescale-headline-small-line-height, 2rem)}.header .close{margin-left:auto}.dialog-icon{inline-size:var(--scb-dialog-icon-size, var(--spacing-7, 24px));block-size:var(--scb-dialog-icon-size, var(--spacing-7, 24px))}.content{flex:1 1 auto;overflow:auto;margin-bottom:var(--spacing-5, 16px);color:var(--md-sys-color-on-surface-variant)}.content-surface{border-radius:calc(var(--scb-dialog-radius, var(--spacing-5, 16px)) - var(--spacing-2, 4px));overflow:hidden;background:var(--md-sys-color-surface-container-lowest, var(--md-sys-color-surface))}:host([variant="iframe"]) .container{--scb-dialog-min-w:var(--scb-dialog-min-w-iframe, var(--scb-dialog-min-w-floating, 360px));--scb-dialog-padding:var(--scb-dialog-padding-iframe, var(--spacing-3, 8px) var(--spacing-3, 8px) var(--spacing-3, 8px))}:host([variant="iframe"]) .header{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;gap:var(--spacing-2, 4px);margin-bottom:var(--spacing-3, 8px);padding-block:var(--scb-dialog-header-padding-block-iframe, var(--spacing-3, 8px));padding-inline-start:var(--scb-dialog-header-padding-inline-start-iframe, var(--spacing-3, 8px));padding-inline-end:var(--scb-dialog-header-padding-inline-end-iframe, var(--spacing-3, 8px))}:host([variant="iframe"]) .header .title{min-width:0}:host([variant="iframe"]) .header .label{padding-inline-start:var(--scb-dialog-header-label-padding-inline-start-iframe, 0)}:host([variant="iframe"]) .header .close{margin-left:0;align-self:start;justify-self:end;margin-top:var(--spacing-negative-2, -4px);margin-right:var(--spacing-negative-4, -12px)}:host([variant="iframe"]) .content{margin-bottom:0;color:inherit}:host([variant="iframe"]) .content-surface{block-size:100%}:host([variant="iframe"]) ::slotted(iframe){display:block;inline-size:100%;block-size:var(--scb-dialog-iframe-height, min(70vh, 720px));border:0;background:var(--md-sys-color-surface-container-lowest, var(--md-sys-color-surface))}.actions{display:flex;align-items:center;gap:var(--spacing-3, 8px);justify-content:flex-end}.actions .start{margin-right:auto}:host([variant="choose"]) .container{--scb-dialog-min-w:var(--scb-dialog-min-w-choose, 280px)}:host([variant="alert"]) .container{--scb-dialog-min-w:var(--scb-dialog-min-w-alert, 320px)}:host([variant="confirm"]) .container{--scb-dialog-min-w:var(--scb-dialog-min-w-confirm, 360px)}:host([variant="form"]) form{display:grid;grid-template-columns:1fr;gap:var(--scb-form-gap, var(--spacing-6, 20px))}:host([variant="form"]) .content{overflow:visible}:host([variant="floating"]) .container{--scb-dialog-min-w:var(--scb-dialog-min-w-floating, 360px)}:host([variant="choose"]) ::slotted(scb-radio-button){display:block;margin-block:var(--scb-choice-gap, 6px)}`,h);
|
|
54
|
+
`}},h.styles=v`@keyframes scb-kf-fade-in{0%{opacity:0}to{opacity:1}}@keyframes scb-kf-fade-out{0%{opacity:1}to{opacity:0}}:host{display:block;position:relative;font-family:var(--brand-font, Inter, Arial, sans-serif);margin-block-start:var(--scb-dialog-spacing-block-start, 0);margin-block-end:var(--scb-dialog-spacing-block-end, 0);margin-inline-start:var(--scb-dialog-spacing-inline-start, 0);margin-inline-end:var(--scb-dialog-spacing-inline-end, 0)}.scrim{position:var(--scb-dialog-scrim-position, fixed);inset:0;background:color-mix(in srgb,var(--md-sys-color-scrim) 32%,transparent);z-index:var(--z-dialog-scrim, 1000);opacity:1;transition:opacity var(--motion-duration-short, 0.25s);transition-timing-function:var(--motion-easing-standard, cubic-bezier(0.2, 0, 0, 1));height:var(--scb-dialog-scrim-height, auto)}.container{outline:0;position:var(--scb-dialog-container-position, fixed);inset:50%auto auto 50%;transform:translate(-50%,-50%) scale(1);background:var(--md-sys-color-surface);color:var(--md-sys-color-on-surface);border-radius:var(--scb-dialog-radius, var(--spacing-5, 16px));box-shadow:0 var(--spacing-1, 2px) var(--spacing-5, 16px) color-mix(in srgb,var(--md-sys-color-shadow) 20%,transparent);min-width:var(--scb-dialog-min-w, 340px);width:var(--scb-dialog-width, auto);max-width:var(--scb-dialog-max-w, 90vw);max-height:var(--scb-dialog-max-h, 90vh);display:flex;flex-direction:column;padding:var(--scb-dialog-padding, var(--spacing-7, 24px));z-index:var(--z-dialog, 1001);opacity:1;transition:opacity var(--motion-duration-medium, 0.3s),transform var(--motion-duration-medium, 0.3s);transition-timing-function:var(--motion-easing-emphasized-decelerate, cubic-bezier(0.05, 0.7, 0.1, 1))}:host(:not([open])) .container,:host(:not([open])) .scrim{opacity:0;pointer-events:none}:host([open]) .scrim{animation:var(--motion-keyframe-fade-in, scb-kf-fade-in) var(--motion-duration-short, 0.25s) var(--motion-easing-standard, cubic-bezier(0.2, 0, 0, 1)) both}:host([open]) .container{animation:var(--motion-keyframe-fade-in, scb-kf-fade-in) var(--motion-duration-medium, 0.3s) var(--motion-easing-emphasized-decelerate, cubic-bezier(0.05, 0.7, 0.1, 1)) both}.header{display:flex;align-items:flex-start;gap:var(--spacing-4, 12px);margin-bottom:var(--spacing-5, 16px)}.header .title{display:flex;flex-direction:column;gap:var(--spacing-3, 8px)}.header .label{font-weight:var(--md-sys-typescale-headline-small-weight, 700);font-size:var(--md-sys-typescale-headline-small-size, 1.5rem);line-height:var(--md-sys-typescale-headline-small-line-height, 2rem)}.header .close{margin-left:auto}.dialog-icon{inline-size:var(--scb-dialog-icon-size, var(--spacing-7, 24px));block-size:var(--scb-dialog-icon-size, var(--spacing-7, 24px))}.content{flex:1 1 auto;overflow:auto;margin-bottom:var(--spacing-5, 16px);color:var(--md-sys-color-on-surface-variant)}.content-surface{border-radius:calc(var(--scb-dialog-radius, var(--spacing-5, 16px)) - var(--spacing-2, 4px));overflow:hidden;background:var(--md-sys-color-surface-container-lowest, var(--md-sys-color-surface))}:host([variant="iframe"]) .container{--scb-dialog-min-w:var(--scb-dialog-min-w-iframe, var(--scb-dialog-min-w-floating, 360px));--scb-dialog-padding:var(--scb-dialog-padding-iframe, var(--spacing-3, 8px) var(--spacing-3, 8px) var(--spacing-3, 8px))}:host([variant="iframe"]) .header{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;gap:var(--spacing-2, 4px);margin-bottom:var(--spacing-3, 8px);padding-block:var(--scb-dialog-header-padding-block-iframe, var(--spacing-3, 8px));padding-inline-start:var(--scb-dialog-header-padding-inline-start-iframe, var(--spacing-3, 8px));padding-inline-end:var(--scb-dialog-header-padding-inline-end-iframe, var(--spacing-3, 8px))}:host([variant="iframe"]) .header .title{min-width:0}:host([variant="iframe"]) .header .label{padding-inline-start:var(--scb-dialog-header-label-padding-inline-start-iframe, 0)}:host([variant="iframe"]) .header .close{margin-left:0;align-self:start;justify-self:end;margin-top:var(--spacing-negative-2, -4px);margin-right:var(--spacing-negative-4, -12px)}:host([variant="iframe"]) .content{margin-bottom:0;color:inherit}:host([variant="iframe"]) .content-surface{block-size:100%}:host([variant="iframe"]) ::slotted(iframe){display:block;inline-size:100%;block-size:var(--scb-dialog-iframe-height, min(70vh, 720px));border:0;background:var(--md-sys-color-surface-container-lowest, var(--md-sys-color-surface))}.actions{display:flex;align-items:center;gap:var(--spacing-3, 8px);justify-content:flex-end}.actions .start{margin-right:auto}:host([variant="choose"]) .container{--scb-dialog-min-w:var(--scb-dialog-min-w-choose, 280px)}:host([variant="alert"]) .container{--scb-dialog-min-w:var(--scb-dialog-min-w-alert, 320px)}:host([variant="confirm"]) .container{--scb-dialog-min-w:var(--scb-dialog-min-w-confirm, 360px)}:host([variant="form"]) form{display:grid;grid-template-columns:1fr;gap:var(--scb-form-gap, var(--spacing-6, 20px))}:host([variant="form"]) .content{overflow:visible}:host([variant="floating"]) .container{--scb-dialog-min-w:var(--scb-dialog-min-w-floating, 360px)}:host([variant="choose"]) ::slotted(scb-radio-button){display:block;margin-block:var(--scb-choice-gap, 6px)}`,h);a([s({type:Boolean,reflect:!0,converter:g})],n.prototype,"open",void 0);a([s({type:String,attribute:"max-w",reflect:!0})],n.prototype,"maxW",void 0);a([s({type:String,attribute:"max-h",reflect:!0})],n.prototype,"maxH",void 0);a([s({type:Number,attribute:"z-index",reflect:!0})],n.prototype,"zIndex",void 0);a([s({type:Boolean,attribute:!1})],n.prototype,"inSb",void 0);a([s({type:Boolean,attribute:"scrim-close",converter:g})],n.prototype,"scrimClose",void 0);a([s({type:String,reflect:!0})],n.prototype,"spacing",void 0);a([s({type:String,attribute:"spacing-top",reflect:!0})],n.prototype,"spacingTop",void 0);a([s({type:String,attribute:"spacing-bottom",reflect:!0})],n.prototype,"spacingBottom",void 0);a([s({type:String,attribute:"spacing-left",reflect:!0})],n.prototype,"spacingLeft",void 0);a([s({type:String,attribute:"spacing-right",reflect:!0})],n.prototype,"spacingRight",void 0);a([s({type:String,reflect:!0})],n.prototype,"variant",void 0);a([s({type:String})],n.prototype,"label",void 0);a([s({type:String})],n.prototype,"icon",void 0);a([s({type:String,attribute:"supporting-text"})],n.prototype,"supportingText",void 0);a([s({type:String,attribute:"ok-button"})],n.prototype,"okButton",void 0);a([s({type:String,attribute:"cancel-button"})],n.prototype,"cancelButton",void 0);a([s({type:String,attribute:"delete-button"})],n.prototype,"deleteButton",void 0);a([s({type:String,attribute:"confirm-button"})],n.prototype,"confirmButton",void 0);a([s({type:String,attribute:"deny-button"})],n.prototype,"denyButton",void 0);a([s({type:String,attribute:"reset-button"})],n.prototype,"resetButton",void 0);a([s({type:String,attribute:"submit-button"})],n.prototype,"submitButton",void 0);a([s({type:String,attribute:"form-id"})],n.prototype,"formId",void 0);a([s({type:String,attribute:"form-action"})],n.prototype,"formAction",void 0);a([s({type:String,attribute:"form-method"})],n.prototype,"formMethod",void 0);n=a([b("scb-dialog")],n);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as m,h as
|
|
1
|
+
import{f as m,h as T,m as F,p as c,v as a,y as C}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import"../../vendor/ripple.js";import{r as P,t as I}from"../../vendor/lazy-focus-ring.js";import{t as r}from"../../vendor/decorate.js";import{n as O,t as f}from"../../vendor/assertClassBrand.js";import"../scb-button/scb-button.js";import"../scb-icon-button/scb-icon-button.js";import"../scb-divider/scb-divider.js";import"../scb-tooltip/scb-tooltip.js";(function(){try{var s=typeof globalThis<"u"?globalThis:window;if(!s.__scb_ce_guard_installed__){s.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,i,o){try{customElements.get(t)||e(t,i,o)}catch(h){var l=String(h||"");if(l.indexOf("already been used")===-1&&l.indexOf("NotSupportedError")===-1)throw h}}}}catch{}})();var $,g=($=class extends T{constructor(...e){super(...e),this._currentDate=new Date,this._selectedDate=null,this._showMonthDropdown=!1,this._showYearDropdown=!1,this.variant="date",this.lang="sv",this.selectedValue="",this.open=!0,this._selectedHour=0,this._selectedMinute=0,this._viewportMargin=8,this._popupOffset=4,this._onWindowReposition=()=>{this._positionPopupWithinViewport()},this._monthNames=[this.lang=="sv"?"Januari":"January",this.lang=="sv"?"Februari":"February",this.lang=="sv"?"Mars":"March",(this.lang=="sv","April"),this.lang=="sv"?"Maj":"May",this.lang=="sv"?"Juni":"June",this.lang=="sv"?"Juli":"July",this.lang=="sv"?"Augusti":"August",(this.lang=="sv","September"),this.lang=="sv"?"Oktober":"October",(this.lang=="sv","November"),(this.lang=="sv","December")],this._outsideClickHandler=t=>{this.open&&(t.composedPath().includes(this)||this._close())},this._prevMonth=()=>{const t=this._currentDate.getFullYear(),i=this._currentDate.getMonth();i===0?this._currentDate=new Date(t-1,11,1):this._currentDate=new Date(t,i-1,1)},this._prevYear=()=>{const t=this._currentDate.getFullYear(),i=this._currentDate.getMonth();this._currentDate=new Date(t-1,i,1)},this._nextMonth=()=>{const t=this._currentDate.getFullYear(),i=this._currentDate.getMonth();i===11?this._currentDate=new Date(t+1,0,1):this._currentDate=new Date(t,i+1,1)},this._nextYear=()=>{const t=this._currentDate.getFullYear(),i=this._currentDate.getMonth();this._currentDate=new Date(t+1,i,1)},this._onTimeChange=t=>{const[i,o]=t.target.value.split(":"),l=parseInt(i,10),h=parseInt(o,10);this._selectedHour=isNaN(l)?0:Math.max(0,Math.min(23,l)),this._selectedMinute=isNaN(h)?0:Math.max(0,Math.min(59,h)),this._fireDateTimeChange()},this._close=()=>{this.open=!1,this.dispatchEvent(new CustomEvent("datepicker-closed",{bubbles:!0,composed:!0}))}}_isRenderedInsideDialog(){const e=this.getRootNode(),t=e instanceof ShadowRoot?e.host:null;return t instanceof HTMLElement&&t.closest("scb-dialog")?!0:!!this.closest("scb-dialog")}connectedCallback(){super.connectedCallback(),this._removeLazyFocusRingListeners=I(this,this.renderRoot)}_positionPopupWithinViewport(){if(!this.open)return;const e=this.renderRoot.querySelector(".datepicker-popup");if(!e)return;const t=this.parentElement?.getBoundingClientRect();if(!t)return;const i=window.innerWidth,o=window.innerHeight,l=Math.max(220,i-this._viewportMargin*2);if(this._isRenderedInsideDialog()){const D=Math.min(e.offsetWidth||380,l),M=e.offsetHeight||420,R=Math.min(Math.max(t.left,this._viewportMargin),i-this._viewportMargin-D),k=o-t.bottom-this._viewportMargin,z=t.top-this._viewportMargin,H=k<M+this._popupOffset&&z>k;if(this.style.setProperty("--scb-datepicker-position","absolute"),this.style.setProperty("--scb-datepicker-computed-width",`${D}px`),this.style.setProperty("--scb-datepicker-left",`${R-t.left}px`),this.style.setProperty("--scb-datepicker-transform","none"),this.style.setProperty("--scb-datepicker-bottom","auto"),H){const Y=Math.max(this._viewportMargin,t.top-M-this._popupOffset)-t.top;this.style.setProperty("--scb-datepicker-top",`${Y}px`),this.style.setProperty("--scb-datepicker-max-height",`${Math.max(0,z-this._popupOffset)}px`)}else this.style.setProperty("--scb-datepicker-top",`${t.height+this._popupOffset}px`),this.style.setProperty("--scb-datepicker-max-height",`${Math.max(0,k-this._popupOffset)}px`);return}const h=Math.min(e.offsetWidth||380,l),n=e.offsetHeight||420,d=Math.min(Math.max(t.left,this._viewportMargin),i-this._viewportMargin-h),b=o-t.bottom-this._viewportMargin,x=t.top-this._viewportMargin,V=b<n+this._popupOffset&&x>b;this.style.setProperty("--scb-datepicker-position","fixed"),this.style.setProperty("--scb-datepicker-computed-width",`${h}px`),this.style.setProperty("--scb-datepicker-left",`${d}px`),this.style.setProperty("--scb-datepicker-transform","none"),V?(this.style.setProperty("--scb-datepicker-top",`${Math.max(this._viewportMargin,t.top-n-this._popupOffset)}px`),this.style.setProperty("--scb-datepicker-bottom","auto"),this.style.setProperty("--scb-datepicker-max-height",`${Math.max(0,x-this._popupOffset)}px`)):(this.style.setProperty("--scb-datepicker-top",`${t.bottom+this._popupOffset}px`),this.style.setProperty("--scb-datepicker-bottom","auto"),this.style.setProperty("--scb-datepicker-max-height",`${Math.max(0,b-this._popupOffset)}px`))}updated(e){if(super.updated(e),this.open?(window.addEventListener("mousedown",this._outsideClickHandler),window.addEventListener("resize",this._onWindowReposition,{passive:!0}),window.addEventListener("scroll",this._onWindowReposition,{passive:!0,capture:!0}),requestAnimationFrame(()=>this._positionPopupWithinViewport())):(window.removeEventListener("mousedown",this._outsideClickHandler),window.removeEventListener("resize",this._onWindowReposition),window.removeEventListener("scroll",this._onWindowReposition,!0)),e.has("selectedValue")&&this.selectedValue){const t=new Date(this.selectedValue);isNaN(t.getTime())||(this._selectedDate=t,this._currentDate=new Date(t.getFullYear(),t.getMonth(),1),this.variant==="datetime-local"&&(this._selectedHour=t.getHours(),this._selectedMinute=t.getMinutes()))}this.open&&requestAnimationFrame(()=>this._positionPopupWithinViewport())}disconnectedCallback(){this._removeLazyFocusRingListeners?.(),this._removeLazyFocusRingListeners=void 0,window.removeEventListener("mousedown",this._outsideClickHandler),window.removeEventListener("resize",this._onWindowReposition),window.removeEventListener("scroll",this._onWindowReposition,!0),super.disconnectedCallback()}render(){if(!this.open)return a``;const e=this._currentDate.getFullYear(),t=this._currentDate.getMonth(),i=new Date,o=this._getMonthDays(e,t),l=Array.from({length:101},(n,d)=>i.getFullYear()-50+d),h=this.variant==="datetime-local"&&!this._showMonthDropdown&&!this._showYearDropdown;return a`
|
|
2
2
|
<div class="datepicker-popup popup">
|
|
3
3
|
<div class="header">
|
|
4
4
|
<div class="month-selector ${this._showMonthDropdown?"open":""} ${this._showYearDropdown?"disable":""}">
|
|
@@ -36,11 +36,11 @@ import{f as m,h as M,m as S,p as c,v as o,y as E}from"../../vendor/vendor.js";im
|
|
|
36
36
|
<scb-icon-button icon="chevron_right" @click=${this._nextYear} aria-label=${this.lang=="sv"?"Nästa år":"Next year"}></scb-icon-button>
|
|
37
37
|
</div>
|
|
38
38
|
</div>
|
|
39
|
-
${this._showMonthDropdown||this._showYearDropdown?
|
|
39
|
+
${this._showMonthDropdown||this._showYearDropdown?a`<scb-divider></scb-divider>`:""}
|
|
40
40
|
<div class="datepicker-content" style="position:relative;">
|
|
41
|
-
${this._showMonthDropdown?
|
|
41
|
+
${this._showMonthDropdown?a`
|
|
42
42
|
<div class="dropdown-list">
|
|
43
|
-
${this._monthNames.map((n,d)=>
|
|
43
|
+
${this._monthNames.map((n,d)=>a`
|
|
44
44
|
<div
|
|
45
45
|
@keydown=${b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),this._onMonthChangeCustom(d))}}
|
|
46
46
|
tabindex="0"
|
|
@@ -48,16 +48,16 @@ import{f as m,h as M,m as S,p as c,v as o,y as E}from"../../vendor/vendor.js";im
|
|
|
48
48
|
@click=${()=>this._onMonthChangeCustom(d)}
|
|
49
49
|
id=${d===t?"selected-month":""}
|
|
50
50
|
>
|
|
51
|
-
${d===t?
|
|
51
|
+
${d===t?a`<md-icon>check</md-icon>`:""}
|
|
52
52
|
${n}
|
|
53
53
|
<md-ripple></md-ripple><md-focus-ring inward></md-focus-ring>
|
|
54
54
|
</div>
|
|
55
55
|
`)}
|
|
56
56
|
</div>
|
|
57
57
|
`:""}
|
|
58
|
-
${this._showYearDropdown?
|
|
58
|
+
${this._showYearDropdown?a`
|
|
59
59
|
<div class="dropdown-list">
|
|
60
|
-
${l.map(n=>
|
|
60
|
+
${l.map(n=>a`
|
|
61
61
|
<div
|
|
62
62
|
@keydown=${d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),this._onYearChangeCustom(n))}}
|
|
63
63
|
tabindex="0"
|
|
@@ -65,14 +65,14 @@ import{f as m,h as M,m as S,p as c,v as o,y as E}from"../../vendor/vendor.js";im
|
|
|
65
65
|
@click=${()=>this._onYearChangeCustom(n)}
|
|
66
66
|
id=${n===e?"selected-year":""}
|
|
67
67
|
>
|
|
68
|
-
${n===e?
|
|
68
|
+
${n===e?a`<md-icon>check</md-icon>`:""}
|
|
69
69
|
${n}
|
|
70
70
|
<md-ripple></md-ripple><md-focus-ring inward></md-focus-ring>
|
|
71
71
|
</div>
|
|
72
72
|
`)}
|
|
73
73
|
</div>
|
|
74
74
|
`:""}
|
|
75
|
-
${!this._showMonthDropdown&&!this._showYearDropdown?
|
|
75
|
+
${!this._showMonthDropdown&&!this._showYearDropdown?a`
|
|
76
76
|
<div class="datepicker-calendar">
|
|
77
77
|
<table>
|
|
78
78
|
<thead>
|
|
@@ -81,9 +81,9 @@ import{f as m,h as M,m as S,p as c,v as o,y as E}from"../../vendor/vendor.js";im
|
|
|
81
81
|
</tr>
|
|
82
82
|
</thead>
|
|
83
83
|
<tbody>
|
|
84
|
-
${
|
|
84
|
+
${o.map(n=>a`
|
|
85
85
|
<tr>
|
|
86
|
-
${n.map(d=>d?
|
|
86
|
+
${n.map(d=>d?a`
|
|
87
87
|
<td>
|
|
88
88
|
<div
|
|
89
89
|
@keydown=${b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),this._selectDate(d))}}
|
|
@@ -93,7 +93,7 @@ import{f as m,h as M,m as S,p as c,v as o,y as E}from"../../vendor/vendor.js";im
|
|
|
93
93
|
@click=${()=>this._selectDate(d)}
|
|
94
94
|
>${d.getDate()}<md-ripple></md-ripple><md-focus-ring></md-focus-ring></div>
|
|
95
95
|
</td>
|
|
96
|
-
`:
|
|
96
|
+
`:a`<td></td>`)}
|
|
97
97
|
</tr>
|
|
98
98
|
`)}
|
|
99
99
|
</tbody>
|
|
@@ -101,7 +101,7 @@ import{f as m,h as M,m as S,p as c,v as o,y as E}from"../../vendor/vendor.js";im
|
|
|
101
101
|
</div>
|
|
102
102
|
`:""}
|
|
103
103
|
</div>
|
|
104
|
-
${h?
|
|
104
|
+
${h?a`
|
|
105
105
|
<div style="padding: 0 24px;">
|
|
106
106
|
<label style="display:flex;align-items:center;gap:8px;">
|
|
107
107
|
<span>${this.lang=="sv"?"Tid:":"Time:"}</span>
|
|
@@ -110,19 +110,19 @@ import{f as m,h as M,m as S,p as c,v as o,y as E}from"../../vendor/vendor.js";im
|
|
|
110
110
|
</div>
|
|
111
111
|
`:""}
|
|
112
112
|
<div class="datepicker-footer">
|
|
113
|
-
${!this._showMonthDropdown&&!this._showYearDropdown?
|
|
113
|
+
${!this._showMonthDropdown&&!this._showYearDropdown?a`
|
|
114
114
|
<scb-button variant="text" label=${this.lang=="sv"?"Stäng":"Close"} @click=${this._close}></scb-button>
|
|
115
115
|
`:""}
|
|
116
116
|
</div>
|
|
117
117
|
</div>
|
|
118
|
-
`}_getMonthDays(e,t){const i=new Date(Date.UTC(e,t,1)),
|
|
118
|
+
`}_getMonthDays(e,t){const i=new Date(Date.UTC(e,t,1)),o=new Date(Date.UTC(e,t+1,0)),l=[];let h=[],n=i.getUTCDay(),d=n===0?6:n-1;for(let b=0;b<d;b++)h.push(null);for(let b=1;b<=o.getUTCDate();b++){const x=new Date(Date.UTC(e,t,b));h.push(x),h.length===7&&(l.push(h),h=[])}if(h.length){for(;h.length<7;)h.push(null);l.push(h)}return l}_toggleMonthDropdown(){this._showMonthDropdown=!this._showMonthDropdown,this._showMonthDropdown&&(this._showYearDropdown=!1,setTimeout(()=>{const e=this.renderRoot.querySelector("#selected-month");e&&e.scrollIntoView({block:"center"})},0))}_toggleYearDropdown(){this._showYearDropdown=!this._showYearDropdown,this._showYearDropdown&&(this._showMonthDropdown=!1,setTimeout(()=>{const e=this.renderRoot.querySelector("#selected-year");e&&e.scrollIntoView({block:"center"})},0))}_onMonthChangeCustom(e){const t=this._currentDate.getFullYear();this._currentDate=new Date(t,e,1),this._showMonthDropdown=!1}_onYearChangeCustom(e){const t=this._currentDate.getMonth();this._currentDate=new Date(e,t,1),this._showYearDropdown=!1}_isToday(e,t){return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}_isSelected(e){return this._selectedDate&&e.getDate()===this._selectedDate.getDate()&&e.getMonth()===this._selectedDate.getMonth()&&e.getFullYear()===this._selectedDate.getFullYear()}_selectDate(e){if(this._selectedDate=e,this.variant==="datetime-local"){const t=new Date(e);t.setHours(this._selectedHour??0,this._selectedMinute??0,0,0),this._selectedHour=t.getHours(),this._selectedMinute=t.getMinutes();const i=l=>l.toString().padStart(2,"0"),o=`${t.getFullYear()}-${i(t.getMonth()+1)}-${i(t.getDate())} ${i(t.getHours())}:${i(t.getMinutes())}`;this.dispatchEvent(new CustomEvent("date-selected",{detail:{value:o},bubbles:!0,composed:!0}))}else{const t=e.toISOString().slice(0,10);this.dispatchEvent(new CustomEvent("date-selected",{detail:{value:t},bubbles:!0,composed:!0}))}}_fireDateTimeChange(){if(this.variant==="datetime-local"&&this._selectedDate){const e=new Date(this._selectedDate);e.setHours(this._selectedHour??0,this._selectedMinute??0,0,0);const t=o=>o.toString().padStart(2,"0"),i=`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())} ${t(e.getHours())}:${t(e.getMinutes())}`;this.dispatchEvent(new CustomEvent("date-selected",{detail:{value:i},bubbles:!0,composed:!0}))}}},$.styles=[C`:host{--scb-datepicker-width:380px;--scb-datepicker-z-index:1100;--scb-datepicker-viewport-margin:8px;--scb-datepicker-offset:var(--spacing-2, 4px);max-width:var(--scb-datepicker-computed-width, min(var(--scb-datepicker-width), calc(100vw - (var(--scb-datepicker-viewport-margin) * 2))));font-family:var(--brand-font);color:var(--md-sys-color-on-surface);display:block;position:var(--scb-datepicker-position, fixed);top:var(--scb-datepicker-top, calc(100% + var(--scb-datepicker-offset)));bottom:var(--scb-datepicker-bottom, auto);left:var(--scb-datepicker-left, 0);width:var(--scb-datepicker-computed-width, min(var(--scb-datepicker-width), calc(100vw - (var(--scb-datepicker-viewport-margin) * 2))));transform:var(--scb-datepicker-transform, translateX(0px));z-index:var(--scb-datepicker-z-index)}.dropdown-selected,.month-selector,.year-selector{display:flex;align-items:center}.dropdown-selected{position:relative;border-radius:8px;font-size:16px;cursor:pointer;text-align:left;gap:8px;padding:4px 8px}.dropdown-selected:focus{outline:0}.dropdown-selected md-focus-ring{border-radius:8px}.dropdown-list{position:relative;background:var(--md-sys-color-surface);padding:4px 0}.dropdown-item{display:flex;position:relative;cursor:pointer;padding:var(--spacing-3) 56px;min-height:40px;align-items:center}.dropdown-item:focus-within{outline:0}.datepicker-popup,.dropdown-item md-focus-ring{border-radius:var(--md-sys-shape-corner-small)}.dropdown-item.selected{background:var(--md-sys-color-secondary-container, #e3f2fd);font-weight:500;padding-left:16px;gap:16px}.datepicker-popup{background:var(--md-sys-color-surface);box-shadow:0 1px 2px 0 rgba(0,0,0,.3),0 2px 6px 2px rgba(0,0,0,.15);max-width:100%;width:100%;max-height:var(--scb-datepicker-max-height, 80vh);overflow:auto;font-family:var(--brand-font)}.datepicker-content{overflow-y:auto;max-height:290px}.datepicker-content::-webkit-scrollbar{width:12px;background:var(--md-sys-color-surface);border-radius:var(--md-sys-shape-corner-small)}.datepicker-content::-webkit-scrollbar-thumb{background:var(--md-sys-color-outline);border-radius:var(--md-sys-shape-corner-small);border:4px solid var(--md-sys-color-surface)}.datepicker-content::-webkit-scrollbar-track{background:var(--md-sys-color-surface);border-radius:var(--md-sys-shape-corner-small)}.popup{position:absolute;top:0;left:0;z-index:1}.header{display:flex;align-items:center;justify-content:space-between;margin-bottom:30px;padding:20px 16px 0;flex-wrap:wrap}.datepicker-footer{padding:8px 16px 24px}.month-label{font-size:18px;font-weight:500}.datepicker-calendar{padding:0 16px}table{width:100%;border-collapse:collapse;margin-bottom:8px}th{color:var(--md-sys-color-on-surface-variant, #757575);font-size:16px;font-weight:600;padding-bottom:20px}td{text-align:center}.day:focus-within{outline:0}.close-datepicker,.day{background:0 0;font-size:16px;cursor:pointer}.day{position:relative;width:40px;height:40px;border-radius:50%;border:0;font-family:var(--brand-font, Inter, Arial, sans-serif);align-content:center}.day.selected{background:var(--md-sys-color-secondary-container)}.close-datepicker{margin-top:8px;border-color:none;color:var(--md-sys-color-primary, #0057b8);padding:4px 12px;border-radius:8px}.close-datepicker:hover{background:var(--md-sys-color-primary-container, #e3f2fd)}`],$);r([m()],g.prototype,"_currentDate",void 0);r([m()],g.prototype,"_selectedDate",void 0);r([m()],g.prototype,"_showMonthDropdown",void 0);r([m()],g.prototype,"_showYearDropdown",void 0);r([c({type:String})],g.prototype,"variant",void 0);r([c({type:String})],g.prototype,"lang",void 0);r([c({type:String})],g.prototype,"selectedValue",void 0);r([c({type:Boolean})],g.prototype,"open",void 0);r([m()],g.prototype,"_selectedHour",void 0);r([m()],g.prototype,"_selectedMinute",void 0);g=r([F("scb-datepicker")],g);var u,y,p=(u=new WeakSet,y=class extends T{constructor(){super(),O(this,u),this._internals=null,this._inputFocused=!1,this._kbShouldShowRing=!1,this._onGlobalKeydown=e=>{e.key==="Tab"&&(P(),this._kbShouldShowRing=!0,this._inputFocused&&f(u,this,_).call(this))},this._onGlobalPointerDown=()=>{this._kbShouldShowRing=!1,this._inputFocused&&f(u,this,_).call(this)},this._hasRenderedOnce=!1,this._boundField=null,this._onFieldInput=()=>{const e=this._boundField;if(!e)return;const t=e;if(this.value=t.value,this._internals){const i=this.disabled?null:this.value;this._internals.setFormValue(i)}f(u,this,w).call(this),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("onValueChanged",{detail:{value:this.value},bubbles:!0,composed:!0}))},this._onFieldChange=()=>{this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))},this._onFieldSelect=()=>{this.dispatchEvent(new Event("select",{bubbles:!0,composed:!0}))},this._onFieldFocus=()=>{this._inputFocused=!0,f(u,this,_).call(this)},this._onFieldBlur=()=>{this._inputFocused=!1,f(u,this,_).call(this)},this.type="text",this.label="",this.supportingText="",this.helpText="",this.helpLabel="Visa hjälptext",this.errorText="",this.leadingIcon="",this.name="",this.pattern="",this.value="",this.underLabel="",this.error=!1,this.disabled=!1,this.required=!1,this.size="large",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this._form=null,this._formSubmitHandler=null,this._formResetHandler=null,this._initialValue="",this._inputId="",this._showDatepicker=!1,this._toggleDatepicker=()=>{this._showDatepicker=!this._showDatepicker},this._openDatepicker=()=>{this._showDatepicker=!0},this._onDatepickerClosed=()=>{this._showDatepicker=!1},this._onDateSelected=e=>{if(this.value=e.detail.value,this._showDatepicker=!1,this._internals){const t=this.disabled?null:this.value;this._internals.setFormValue(t)}f(u,this,w).call(this),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("onValueChanged",{detail:{value:this.value},bubbles:!0,composed:!0}))},"attachInternals"in this&&(this._internals=this.attachInternals())}_syncDensityForSize(){this.size==="extra-small"?this.setAttribute("data-density","-5"):this.size==="small"?this.setAttribute("data-density","-4"):this.size==="medium"?this.setAttribute("data-density","-2"):this.removeAttribute("data-density")}_renderLabel(){const e=!!this.underLabel,t=a`
|
|
119
119
|
<label
|
|
120
120
|
class="scb-textfield-label ${!e&&!this.helpText?"scb-textfield-label--without-supporting":""}"
|
|
121
121
|
for="${this._inputId}"
|
|
122
122
|
>
|
|
123
123
|
${this.label}
|
|
124
124
|
</label>
|
|
125
|
-
`;return this.helpText?
|
|
125
|
+
`;return this.helpText?a`
|
|
126
126
|
<div class="scb-textfield-label-row ${e?"":"scb-textfield-label-row--without-supporting"}">
|
|
127
127
|
${t}
|
|
128
128
|
<scb-tooltip
|
|
@@ -140,11 +140,11 @@ import{f as m,h as M,m as S,p as c,v as o,y as E}from"../../vendor/vendor.js";im
|
|
|
140
140
|
></scb-icon-button>
|
|
141
141
|
</scb-tooltip>
|
|
142
142
|
</div>
|
|
143
|
-
`:t}_renderSupportingText(){return this.underLabel?
|
|
143
|
+
`:t}_renderSupportingText(){return this.underLabel?a`
|
|
144
144
|
<span class="scb-textfield-supporting-text" id="${this._inputId}-supporting-text">
|
|
145
145
|
${this.underLabel}
|
|
146
146
|
</span>
|
|
147
|
-
`:null}render(){const e=this.leadingIcon?
|
|
147
|
+
`:null}render(){const e=this.leadingIcon?a`<md-icon class="scb-textfield-icon">${this.leadingIcon}</md-icon>`:null,t=this.error?a`<md-icon class="scb-textfield-error-icon" aria-hidden="true">error</md-icon>`:null;this.underLabel=this.error?this.errorText||"Ogiltig inmatning.":this.supportingText,this.value=this.value||"";const i=this.underLabel?`${this._inputId}-supporting-text`:void 0,o=this._renderLabel(),l=this._renderSupportingText(),h=this.type==="search"&&this.value?a`
|
|
148
148
|
<button
|
|
149
149
|
type="button"
|
|
150
150
|
class="scb-textfield-clear"
|
|
@@ -178,8 +178,8 @@ import{f as m,h as M,m as S,p as c,v as o,y as E}from"../../vendor/vendor.js";im
|
|
|
178
178
|
></line>
|
|
179
179
|
</svg>
|
|
180
180
|
</button>
|
|
181
|
-
`:null;return this.type==="textarea"?
|
|
182
|
-
${
|
|
181
|
+
`:null;return this.type==="textarea"?a`
|
|
182
|
+
${o}
|
|
183
183
|
${l}
|
|
184
184
|
<div class="scb-textfield-wrapper">
|
|
185
185
|
<div class="ripple-wrapper">
|
|
@@ -197,8 +197,8 @@ import{f as m,h as M,m as S,p as c,v as o,y as E}from"../../vendor/vendor.js";im
|
|
|
197
197
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
198
198
|
</div>
|
|
199
199
|
</div>
|
|
200
|
-
`:this.type==="date"?
|
|
201
|
-
${
|
|
200
|
+
`:this.type==="date"?a`
|
|
201
|
+
${o}
|
|
202
202
|
${l}
|
|
203
203
|
<div class="scb-textfield-wrapper">
|
|
204
204
|
${e}
|
|
@@ -214,13 +214,13 @@ import{f as m,h as M,m as S,p as c,v as o,y as E}from"../../vendor/vendor.js";im
|
|
|
214
214
|
aria-invalid=${this.error?"true":"false"}
|
|
215
215
|
aria-describedby=${i}
|
|
216
216
|
readonly
|
|
217
|
-
@focus=${this.
|
|
218
|
-
@click=${this.
|
|
217
|
+
@focus=${this._openDatepicker}
|
|
218
|
+
@click=${this._openDatepicker}
|
|
219
219
|
/>
|
|
220
220
|
<md-ripple></md-ripple>
|
|
221
221
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
222
222
|
</div>
|
|
223
|
-
${this.error?t:
|
|
223
|
+
${this.error?t:a`
|
|
224
224
|
<scb-icon-button
|
|
225
225
|
class="scb-textfield-datepicker-button"
|
|
226
226
|
icon="calendar_today"
|
|
@@ -233,10 +233,11 @@ import{f as m,h as M,m as S,p as c,v as o,y as E}from"../../vendor/vendor.js";im
|
|
|
233
233
|
.selectedValue=${this.value}
|
|
234
234
|
.open=${this._showDatepicker}
|
|
235
235
|
@date-selected=${this._onDateSelected}
|
|
236
|
+
@datepicker-closed=${this._onDatepickerClosed}
|
|
236
237
|
></scb-datepicker>
|
|
237
238
|
</div>
|
|
238
|
-
`:this.type==="datetime-local"?
|
|
239
|
-
${
|
|
239
|
+
`:this.type==="datetime-local"?a`
|
|
240
|
+
${o}
|
|
240
241
|
${l}
|
|
241
242
|
<div class="scb-textfield-wrapper" style="position:relative;">
|
|
242
243
|
${e}
|
|
@@ -252,15 +253,15 @@ import{f as m,h as M,m as S,p as c,v as o,y as E}from"../../vendor/vendor.js";im
|
|
|
252
253
|
aria-invalid=${this.error?"true":"false"}
|
|
253
254
|
aria-describedby=${i}
|
|
254
255
|
readonly
|
|
255
|
-
@focus=${this.
|
|
256
|
-
@click=${this.
|
|
256
|
+
@focus=${this._openDatepicker}
|
|
257
|
+
@click=${this._openDatepicker}
|
|
257
258
|
/>
|
|
258
259
|
|
|
259
260
|
<md-ripple></md-ripple>
|
|
260
261
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
261
262
|
</div>
|
|
262
263
|
|
|
263
|
-
${this.error?t:
|
|
264
|
+
${this.error?t:a`
|
|
264
265
|
<scb-icon-button
|
|
265
266
|
class="scb-textfield-datepicker-button"
|
|
266
267
|
icon="calendar_today"
|
|
@@ -274,10 +275,11 @@ import{f as m,h as M,m as S,p as c,v as o,y as E}from"../../vendor/vendor.js";im
|
|
|
274
275
|
.selectedValue=${this.value}
|
|
275
276
|
.open=${this._showDatepicker}
|
|
276
277
|
@date-selected=${this._onDateSelected}
|
|
278
|
+
@datepicker-closed=${this._onDatepickerClosed}
|
|
277
279
|
></scb-datepicker>
|
|
278
280
|
</div>
|
|
279
|
-
`:this.type==="time"?
|
|
280
|
-
${
|
|
281
|
+
`:this.type==="time"?a`
|
|
282
|
+
${o}
|
|
281
283
|
${l}
|
|
282
284
|
<div class="scb-textfield-wrapper">
|
|
283
285
|
${e}
|
|
@@ -299,8 +301,8 @@ import{f as m,h as M,m as S,p as c,v as o,y as E}from"../../vendor/vendor.js";im
|
|
|
299
301
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
300
302
|
</div>
|
|
301
303
|
</div>
|
|
302
|
-
`:
|
|
303
|
-
${
|
|
304
|
+
`:a`
|
|
305
|
+
${o}
|
|
304
306
|
${l}
|
|
305
307
|
<div class="scb-textfield-wrapper">
|
|
306
308
|
${e}
|
|
@@ -322,7 +324,7 @@ import{f as m,h as M,m as S,p as c,v as o,y as E}from"../../vendor/vendor.js";im
|
|
|
322
324
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
323
325
|
</div>
|
|
324
326
|
</div>
|
|
325
|
-
`}firstUpdated(e){super.firstUpdated(e),this._initialValue=this.value,this._internals&&this.value&&this._internals.setFormValue(this.value),f(u,this,
|
|
327
|
+
`}firstUpdated(e){super.firstUpdated(e),this._initialValue=this.value,this._internals&&this.value&&this._internals.setFormValue(this.value),f(u,this,E).call(this),f(u,this,S).call(this)}updated(e){if(super.updated(e),this.toggleAttribute("aria-disabled",this.disabled),e.has("size")&&this._syncDensityForSize(),this._internals&&(e.has("value")||e.has("disabled"))){const t=this.disabled?null:this.value;this._internals.setFormValue(t)}e.has("type")&&(f(u,this,E).call(this),this._hasRenderedOnce&&f(u,this,A).call(this)),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom")||e.has("spacingLeft")||e.has("spacingRight"))&&f(u,this,S).call(this),this._hasRenderedOnce=!0}formDisabledCallback(e){this.disabled=e}connectedCallback(){super.connectedCallback(),this._syncDensityForSize(),this._inputId=this.id||`scb-textfield-${Math.random().toString(36).substr(2,9)}`,this._formSubmitHandler=e=>{this.reportValidity()||(e.preventDefault(),e.stopPropagation())},this._form=this.closest("form"),this._form&&(this._form.addEventListener("submit",this._formSubmitHandler,!0),this._formResetHandler=()=>{this.value=this._initialValue;const e=this.shadowRoot?.querySelector(".scb-textfield");e&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&(e.value=this._initialValue),this.error=!1},this._form.addEventListener("reset",this._formResetHandler,!0)),window.addEventListener("keydown",this._onGlobalKeydown,!0),window.addEventListener("pointerdown",this._onGlobalPointerDown,!0)}disconnectedCallback(){super.disconnectedCallback(),this._form&&this._formSubmitHandler&&(this._form.removeEventListener("submit",this._formSubmitHandler,!0),this._formResetHandler&&this._form.removeEventListener("reset",this._formResetHandler,!0)),f(u,this,L).call(this),window.removeEventListener("keydown",this._onGlobalKeydown,!0),window.removeEventListener("pointerdown",this._onGlobalPointerDown,!0)}reportValidity(){return f(u,this,w).call(this,!0)}_onClearClick(){const e=this.shadowRoot?.querySelector(".scb-textfield");if(e&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)){if(e.value="",this.value="",this._internals){const t=this.disabled?null:this.value;this._internals.setFormValue(t),this._internals.setValidity({})}this.error=!1,e.setCustomValidity(""),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("onValueChanged",{detail:{value:this.value},bubbles:!0,composed:!0})),e.focus()}}},y.formAssociated=!0,y.styles=[C`:host{--scb-textfield-number-max-width:280px;--scb-textfield-text-max-width:400px;--scb-textfield-search-max-width:600px;--scb-textfield-email-max-width:400px;--scb-textfield-password-max-width:400px;--scb-textfield-tel-max-width:400px;--scb-textfield-url-max-width:400px;--scb-textfield-textarea-max-width:600px;font-family:var(--brand-font);color:var(--md-sys-color-on-surface);margin-block-start:var(--scb-textfield-spacing-block-start, 0);margin-block-end:var(--scb-textfield-spacing-block-end, 0);margin-inline-start:var(--scb-textfield-spacing-inline-start, 0);margin-inline-end:var(--scb-textfield-spacing-inline-end, 0);-webkit-tap-highlight-color:transparent;--scb-textfield-padding-x:var(--spacing-5);--scb-textfield-padding-y:var(--spacing-2);--scb-textfield-min-height:56px;--scb-textfield-font-size:var(--md-sys-typescale-body-large-size);--scb-textfield-line-height:var(--md-sys-typescale-body-large-line-height);--scb-textfield-label-font-size:var(--md-sys-typescale-label-medium-size);--scb-textfield-label-line-height:var(--md-sys-typescale-label-medium-line-height);--scb-textfield-label-letter-spacing:var(--md-sys-typescale-label-medium-tracking);--scb-textfield-supporting-font-size:var(--md-sys-typescale-body-medium-size);--scb-textfield-supporting-line-height:var(--md-sys-typescale-body-medium-line-height);--scb-textfield-supporting-letter-spacing:var(--md-sys-typescale-body-medium-tracking);--scb-textfield-label-gap:var(--spacing-3);--scb-textfield-leading-inset:var(--spacing-4);--scb-textfield-leading-icon-size:var(--icon-size-medium, 24px);--scb-textfield-leading-gap:var(--spacing-4);--scb-textfield-leading-padding:calc(
|
|
326
328
|
var(--scb-textfield-leading-inset) +
|
|
327
329
|
var(--scb-textfield-leading-icon-size) +
|
|
328
330
|
var(--scb-textfield-leading-gap)
|
|
@@ -330,4 +332,4 @@ import{f as m,h as M,m as S,p as c,v as o,y as E}from"../../vendor/vendor.js";im
|
|
|
330
332
|
var(--scb-textfield-trailing-inset) +
|
|
331
333
|
var(--scb-textfield-trailing-action-size) +
|
|
332
334
|
var(--spacing-2)
|
|
333
|
-
)}:host([size='extra-small']),:host([size='medium']),:host([size='small']){--scb-textfield-label-font-size:var(--md-sys-typescale-label-small-size);--scb-textfield-label-line-height:var(--md-sys-typescale-label-small-line-height);--scb-textfield-label-letter-spacing:var(--md-sys-typescale-label-small-tracking);--scb-textfield-supporting-font-size:var(--md-sys-typescale-body-small-size);--scb-textfield-supporting-line-height:var(--md-sys-typescale-body-small-line-height);--scb-textfield-supporting-letter-spacing:var(--md-sys-typescale-body-small-tracking);--scb-textfield-leading-inset:var(--spacing-3);--scb-textfield-trailing-inset:var(--spacing-3)}:host([size='medium']){--scb-textfield-padding-x:var(--spacing-4);--scb-textfield-padding-y:var(--spacing-3);--scb-textfield-min-height:48px;--scb-textfield-font-size:var(--md-sys-typescale-body-medium-size);--scb-textfield-line-height:var(--md-sys-typescale-body-medium-line-height);--scb-textfield-leading-icon-size:var(--icon-size-small, 20px);--scb-textfield-leading-gap:var(--spacing-5);--scb-textfield-trailing-icon-size:var(--icon-size-small, 20px);--scb-textfield-trailing-gap:var(--spacing-3);--scb-textfield-trailing-action-size:var(--scale-10, 40px)}:host([size='extra-small']),:host([size='small']){--scb-textfield-font-size:var(--md-sys-typescale-body-small-size);--scb-textfield-line-height:var(--md-sys-typescale-body-small-line-height)}:host([size='small']){--scb-textfield-padding-x:var(--spacing-4);--scb-textfield-padding-y:var(--spacing-3);--scb-textfield-min-height:40px;--scb-textfield-leading-icon-size:var(--icon-size-small, 20px);--scb-textfield-leading-gap:var(--spacing-5);--scb-textfield-trailing-icon-size:var(--icon-size-small, 20px);--scb-textfield-trailing-gap:var(--spacing-3);--scb-textfield-trailing-action-size:var(--scale-09, 36px)}:host([size='extra-small']){--scb-textfield-padding-x:var(--spacing-3);--scb-textfield-padding-y:var(--spacing-2);--scb-textfield-min-height:32px;--scb-textfield-leading-icon-size:var(--icon-size-extra-small, 16px);--scb-textfield-leading-gap:var(--spacing-4);--scb-textfield-trailing-icon-size:var(--icon-size-extra-small, 16px);--scb-textfield-trailing-gap:var(--spacing-2);--scb-textfield-trailing-action-size:var(--scale-08, 32px)}:host([type='number']){--scb-textfield-max-width:var(--scb-textfield-number-max-width)}:host([type='datetime-local']),:host([type='text']){--scb-textfield-max-width:var(--scb-textfield-text-max-width)}:host([type='search']){--scb-textfield-max-width:var(--scb-textfield-search-max-width)}:host([type='email']){--scb-textfield-max-width:var(--scb-textfield-email-max-width)}:host([type='password']){--scb-textfield-max-width:var(--scb-textfield-password-max-width)}:host([type='tel']){--scb-textfield-max-width:var(--scb-textfield-tel-max-width)}:host([type='url']){--scb-textfield-max-width:var(--scb-textfield-url-max-width)}:host([type='textarea']){--scb-textfield-max-width:var(--scb-textfield-textarea-max-width)}:host([type='date']),:host([type='time']){--scb-textfield-max-width:var(--scb-textfield-text-max-width)}input[type=time]::-webkit-calendar-picker-indicator{display:none;background:0 0}:host{display:flex;flex-direction:column;max-width:var(--scb-textfield-max-width)}:host([error]) .scb-textfield-supporting-text{color:var(--md-sys-color-error)}:host([error]) .scb-textfield{border-color:var(--md-sys-color-error)}:host([error]) .scb-textfield:focus-visible{border-color:var(--md-sys-color-error);box-shadow:inset 0 0 0 2px var(--md-sys-color-error)}:host([disabled]){opacity:.38;cursor:default}.scb-textfield-label{display:block;font-size:var(--scb-textfield-label-font-size);font-weight:var(--weight-semibold);line-height:var(--scb-textfield-label-line-height);letter-spacing:var(--scb-textfield-label-letter-spacing)}.scb-textfield-label-row{display:flex;align-items:center;gap:var(--spacing-1, 2px)}.scb-textfield-label-row--without-supporting{margin-bottom:var(--scb-textfield-label-gap)}.scb-textfield-help-tooltip{display:inline-flex;align-items:center;flex:0 0 auto;line-height:0}.scb-textfield-help-button{--scb-icon-button-container-size:var(--scale-06, 24px);--scb-icon-button-icon-size:var(--icon-size-extra-small, 16px)}.scb-textfield-label--without-supporting,.scb-textfield-supporting-text{margin-bottom:var(--scb-textfield-label-gap)}.scb-textfield-supporting-text{display:block;font-size:var(--scb-textfield-supporting-font-size);line-height:var(--scb-textfield-supporting-line-height);letter-spacing:var(--scb-textfield-supporting-letter-spacing);color:var(--md-sys-color-on-surface-variant)}.scb-textfield{padding:var(--scb-textfield-padding-y) var(--scb-textfield-padding-x);min-height:var(--scb-textfield-min-height);border:1px solid var(--md-sys-color-outline);border-radius:var(--md-sys-shape-corner-small);font-size:var(--scb-textfield-font-size);font-family:var(--brand-font);line-height:var(--scb-textfield-line-height);width:100%;box-sizing:border-box;background-color:transparent;color:var(--md-sys-color-on-surface);position:relative;z-index:1}:host([type='date']) .scb-textfield,:host([type='search']) .scb-textfield{padding-right:var(--scb-textfield-trailing-reserved)}md-icon+.ripple-wrapper>.scb-textfield{padding-left:var(--scb-textfield-leading-padding)}.scb-textfield-icon{position:absolute;left:var(--scb-textfield-leading-inset);top:50%;transform:translateY(-50%);pointer-events:none;font-size:var(--scb-textfield-leading-icon-size);z-index:2}.scb-textfield:focus-visible{outline:0;box-shadow:inset 0 0 0 2px var(--md-sys-color-primary);border:1px solid var(--md-sys-color-primary)}.ripple-wrapper,.scb-textfield-wrapper{position:relative;width:100%}md-focus-ring.input-ring,md-ripple{border-radius:var(--md-sys-shape-corner-small);position:absolute;inset:0;pointer-events:none}md-focus-ring.input-ring{display:none;z-index:3}.ripple-wrapper[data-kb-focus=true] md-focus-ring.input-ring{display:block}md-ripple{z-index:0;--md-ripple-hover-color:transparent;--md-ripple-hover-opacity:0}input[type=search]::-webkit-search-cancel-button{appearance:none;display:none}.scb-textfield-clear,.scb-textfield-error-icon{position:absolute;right:var(--scb-textfield-trailing-inset);top:50%;transform:translateY(-50%);z-index:2}.scb-textfield-error-icon{pointer-events:none;font-size:var(--scb-textfield-trailing-icon-size);color:var(--md-sys-color-error)}.scb-textfield.has-error-icon{padding-right:calc(var(--scb-textfield-trailing-inset) + var(--scb-textfield-trailing-icon-size) + var(--scb-textfield-trailing-gap))}.scb-textfield-clear{width:var(--scb-textfield-trailing-icon-size);height:var(--scb-textfield-trailing-icon-size);padding:0;margin:0;border:0;background:0 0;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;color:var(--md-sys-color-on-surface)}:host([error]) .scb-textfield-clear{right:calc(var(--scb-textfield-trailing-inset) + var(--scb-textfield-trailing-icon-size) + var(--spacing-2))}.scb-textfield-clear:focus-visible{outline:2px solid var(--md-sys-color-primary);outline-offset:2px}.scb-textfield-clear svg{width:100%;height:100%;display:block}.scb-textfield-datepicker-button{position:absolute;right:var(--scb-textfield-trailing-inset);top:50%;transform:translateY(-50%);z-index:4}`],y);function D(){const s=f(u,this,v).call(this,this.spacing),e=f(u,this,v).call(this,this.spacingTop)??s,t=f(u,this,v).call(this,this.spacingBottom)??s,i=f(u,this,v).call(this,this.spacingLeft),a=f(u,this,v).call(this,this.spacingRight);e?this.style.setProperty("--scb-textfield-spacing-block-start",e):this.style.removeProperty("--scb-textfield-spacing-block-start"),t?this.style.setProperty("--scb-textfield-spacing-block-end",t):this.style.removeProperty("--scb-textfield-spacing-block-end"),i?this.style.setProperty("--scb-textfield-spacing-inline-start",i):this.style.removeProperty("--scb-textfield-spacing-inline-start"),a?this.style.setProperty("--scb-textfield-spacing-inline-end",a):this.style.removeProperty("--scb-textfield-spacing-inline-end")}function v(s){if(!s)return;const e=String(s).trim();if(e)return/^\d+$/.test(e)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(e,10)))})`:e}function w(s=!1){const e=this.shadowRoot?.querySelector(".scb-textfield");if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))return!0;const t=this.errorText||"Ogiltig inmatning.";let i="";if(e.setCustomValidity(""),this.required&&!e.value)i=t,e.setCustomValidity(i);else if(this.pattern&&e.value)try{new RegExp(this.pattern).test(e.value)||(i=t,e.setCustomValidity(i))}catch{e.setCustomValidity("")}const a=s?e.reportValidity():e.checkValidity();if(this.error=!a,this._internals)if(a)this._internals.setValidity({});else{const l=i||e.validationMessage||t;this._internals.setValidity({customError:!0},l,e)}return a}function z(){const s=this.shadowRoot?.querySelector(".scb-textfield");s&&(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement)&&this._boundField!==s&&(f(u,this,T).call(this),this._boundField=s,this.type!=="time"&&s.addEventListener("input",this._onFieldInput),s.addEventListener("change",this._onFieldChange),s.addEventListener("select",this._onFieldSelect),s.addEventListener("focus",this._onFieldFocus),s.addEventListener("blur",this._onFieldBlur))}function T(){const s=this._boundField;s&&(s.removeEventListener("input",this._onFieldInput),s.removeEventListener("change",this._onFieldChange),s.removeEventListener("select",this._onFieldSelect),s.removeEventListener("focus",this._onFieldFocus),s.removeEventListener("blur",this._onFieldBlur),this._boundField=null)}function I(){this._showDatepicker=!1;const s=this.shadowRoot?.querySelector(".scb-textfield");if(s&&(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement)&&(s.value="",s.setCustomValidity("")),this.value="",this.error=!1,this._internals){const e=this.disabled?null:"";this._internals.setFormValue(e),this._internals.setValidity({})}}function _(){const s=this.renderRoot?.querySelector(".ripple-wrapper");s&&(this._inputFocused&&this._kbShouldShowRing?s.setAttribute("data-kb-focus","true"):s.removeAttribute("data-kb-focus"))}r([c({type:String,reflect:!0})],p.prototype,"type",void 0);r([c({type:String})],p.prototype,"label",void 0);r([c({type:String,attribute:"supporting-text"})],p.prototype,"supportingText",void 0);r([c({type:String,attribute:"help-text"})],p.prototype,"helpText",void 0);r([c({type:String,attribute:"help-label"})],p.prototype,"helpLabel",void 0);r([c({type:String,attribute:"error-text"})],p.prototype,"errorText",void 0);r([c({type:String,attribute:"leading-icon"})],p.prototype,"leadingIcon",void 0);r([c({type:String})],p.prototype,"name",void 0);r([c({type:String})],p.prototype,"pattern",void 0);r([c({type:String,attribute:"value"})],p.prototype,"value",void 0);r([c({type:String})],p.prototype,"underLabel",void 0);r([c({type:Boolean,reflect:!0})],p.prototype,"error",void 0);r([c({type:Boolean,reflect:!0})],p.prototype,"disabled",void 0);r([c({type:Boolean,reflect:!0})],p.prototype,"required",void 0);r([c({type:String,reflect:!0})],p.prototype,"size",void 0);r([c({type:String,reflect:!0})],p.prototype,"spacing",void 0);r([c({type:String,attribute:"spacing-top",reflect:!0})],p.prototype,"spacingTop",void 0);r([c({type:String,attribute:"spacing-bottom",reflect:!0})],p.prototype,"spacingBottom",void 0);r([c({type:String,attribute:"spacing-left",reflect:!0})],p.prototype,"spacingLeft",void 0);r([c({type:String,attribute:"spacing-right",reflect:!0})],p.prototype,"spacingRight",void 0);r([m()],p.prototype,"_showDatepicker",void 0);p=r([S("scb-textfield")],p);
|
|
335
|
+
)}:host([size='extra-small']),:host([size='medium']),:host([size='small']){--scb-textfield-label-font-size:var(--md-sys-typescale-label-small-size);--scb-textfield-label-line-height:var(--md-sys-typescale-label-small-line-height);--scb-textfield-label-letter-spacing:var(--md-sys-typescale-label-small-tracking);--scb-textfield-supporting-font-size:var(--md-sys-typescale-body-small-size);--scb-textfield-supporting-line-height:var(--md-sys-typescale-body-small-line-height);--scb-textfield-supporting-letter-spacing:var(--md-sys-typescale-body-small-tracking);--scb-textfield-leading-inset:var(--spacing-3);--scb-textfield-trailing-inset:var(--spacing-3)}:host([size='medium']){--scb-textfield-padding-x:var(--spacing-4);--scb-textfield-padding-y:var(--spacing-3);--scb-textfield-min-height:48px;--scb-textfield-font-size:var(--md-sys-typescale-body-medium-size);--scb-textfield-line-height:var(--md-sys-typescale-body-medium-line-height);--scb-textfield-leading-icon-size:var(--icon-size-small, 20px);--scb-textfield-leading-gap:var(--spacing-5);--scb-textfield-trailing-icon-size:var(--icon-size-small, 20px);--scb-textfield-trailing-gap:var(--spacing-3);--scb-textfield-trailing-action-size:var(--scale-10, 40px)}:host([size='extra-small']),:host([size='small']){--scb-textfield-font-size:var(--md-sys-typescale-body-small-size);--scb-textfield-line-height:var(--md-sys-typescale-body-small-line-height)}:host([size='small']){--scb-textfield-padding-x:var(--spacing-4);--scb-textfield-padding-y:var(--spacing-3);--scb-textfield-min-height:40px;--scb-textfield-leading-icon-size:var(--icon-size-small, 20px);--scb-textfield-leading-gap:var(--spacing-5);--scb-textfield-trailing-icon-size:var(--icon-size-small, 20px);--scb-textfield-trailing-gap:var(--spacing-3);--scb-textfield-trailing-action-size:var(--scale-09, 36px)}:host([size='extra-small']){--scb-textfield-padding-x:var(--spacing-3);--scb-textfield-padding-y:var(--spacing-2);--scb-textfield-min-height:32px;--scb-textfield-leading-icon-size:var(--icon-size-extra-small, 16px);--scb-textfield-leading-gap:var(--spacing-4);--scb-textfield-trailing-icon-size:var(--icon-size-extra-small, 16px);--scb-textfield-trailing-gap:var(--spacing-2);--scb-textfield-trailing-action-size:var(--scale-08, 32px)}:host([type='number']){--scb-textfield-max-width:var(--scb-textfield-number-max-width)}:host([type='datetime-local']),:host([type='text']){--scb-textfield-max-width:var(--scb-textfield-text-max-width)}:host([type='search']){--scb-textfield-max-width:var(--scb-textfield-search-max-width)}:host([type='email']){--scb-textfield-max-width:var(--scb-textfield-email-max-width)}:host([type='password']){--scb-textfield-max-width:var(--scb-textfield-password-max-width)}:host([type='tel']){--scb-textfield-max-width:var(--scb-textfield-tel-max-width)}:host([type='url']){--scb-textfield-max-width:var(--scb-textfield-url-max-width)}:host([type='textarea']){--scb-textfield-max-width:var(--scb-textfield-textarea-max-width)}:host([type='date']),:host([type='time']){--scb-textfield-max-width:var(--scb-textfield-text-max-width)}input[type=time]::-webkit-calendar-picker-indicator{display:none;background:0 0}:host{display:flex;flex-direction:column;max-width:var(--scb-textfield-max-width)}:host([error]) .scb-textfield-supporting-text{color:var(--md-sys-color-error)}:host([error]) .scb-textfield{border-color:var(--md-sys-color-error)}:host([error]) .scb-textfield:focus-visible{border-color:var(--md-sys-color-error);box-shadow:inset 0 0 0 2px var(--md-sys-color-error)}:host([disabled]){opacity:.38;cursor:default}.scb-textfield-label{display:block;font-size:var(--scb-textfield-label-font-size);font-weight:var(--weight-semibold);line-height:var(--scb-textfield-label-line-height);letter-spacing:var(--scb-textfield-label-letter-spacing)}.scb-textfield-label-row{display:flex;align-items:center;gap:var(--spacing-1, 2px)}.scb-textfield-label-row--without-supporting{margin-bottom:var(--scb-textfield-label-gap)}.scb-textfield-help-tooltip{display:inline-flex;align-items:center;flex:0 0 auto;line-height:0}.scb-textfield-help-button{--scb-icon-button-container-size:var(--scale-06, 24px);--scb-icon-button-icon-size:var(--icon-size-extra-small, 16px)}.scb-textfield-label--without-supporting,.scb-textfield-supporting-text{margin-bottom:var(--scb-textfield-label-gap)}.scb-textfield-supporting-text{display:block;font-size:var(--scb-textfield-supporting-font-size);line-height:var(--scb-textfield-supporting-line-height);letter-spacing:var(--scb-textfield-supporting-letter-spacing);color:var(--md-sys-color-on-surface-variant)}.scb-textfield{padding:var(--scb-textfield-padding-y) var(--scb-textfield-padding-x);min-height:var(--scb-textfield-min-height);border:1px solid var(--md-sys-color-outline);border-radius:var(--md-sys-shape-corner-small);font-size:var(--scb-textfield-font-size);font-family:var(--brand-font);line-height:var(--scb-textfield-line-height);width:100%;box-sizing:border-box;background-color:transparent;color:var(--md-sys-color-on-surface);position:relative;z-index:1}:host([type='date']) .scb-textfield,:host([type='search']) .scb-textfield{padding-right:var(--scb-textfield-trailing-reserved)}md-icon+.ripple-wrapper>.scb-textfield{padding-left:var(--scb-textfield-leading-padding)}.scb-textfield-icon{position:absolute;left:var(--scb-textfield-leading-inset);top:50%;transform:translateY(-50%);pointer-events:none;font-size:var(--scb-textfield-leading-icon-size);z-index:2}.scb-textfield:focus-visible{outline:0;box-shadow:inset 0 0 0 2px var(--md-sys-color-primary);border:1px solid var(--md-sys-color-primary)}.ripple-wrapper,.scb-textfield-wrapper{position:relative;width:100%}md-focus-ring.input-ring,md-ripple{border-radius:var(--md-sys-shape-corner-small);position:absolute;inset:0;pointer-events:none}md-focus-ring.input-ring{display:none;z-index:3}.ripple-wrapper[data-kb-focus=true] md-focus-ring.input-ring{display:block}md-ripple{z-index:0;--md-ripple-hover-color:transparent;--md-ripple-hover-opacity:0}input[type=search]::-webkit-search-cancel-button{appearance:none;display:none}.scb-textfield-clear,.scb-textfield-error-icon{position:absolute;right:var(--scb-textfield-trailing-inset);top:50%;transform:translateY(-50%);z-index:2}.scb-textfield-error-icon{pointer-events:none;font-size:var(--scb-textfield-trailing-icon-size);color:var(--md-sys-color-error)}.scb-textfield.has-error-icon{padding-right:calc(var(--scb-textfield-trailing-inset) + var(--scb-textfield-trailing-icon-size) + var(--scb-textfield-trailing-gap))}.scb-textfield-clear{width:var(--scb-textfield-trailing-icon-size);height:var(--scb-textfield-trailing-icon-size);padding:0;margin:0;border:0;background:0 0;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;color:var(--md-sys-color-on-surface)}:host([error]) .scb-textfield-clear{right:calc(var(--scb-textfield-trailing-inset) + var(--scb-textfield-trailing-icon-size) + var(--spacing-2))}.scb-textfield-clear:focus-visible{outline:2px solid var(--md-sys-color-primary);outline-offset:2px}.scb-textfield-clear svg{width:100%;height:100%;display:block}.scb-textfield-datepicker-button{position:absolute;right:var(--scb-textfield-trailing-inset);top:50%;transform:translateY(-50%);z-index:4}`],y);function S(){const s=f(u,this,v).call(this,this.spacing),e=f(u,this,v).call(this,this.spacingTop)??s,t=f(u,this,v).call(this,this.spacingBottom)??s,i=f(u,this,v).call(this,this.spacingLeft),o=f(u,this,v).call(this,this.spacingRight);e?this.style.setProperty("--scb-textfield-spacing-block-start",e):this.style.removeProperty("--scb-textfield-spacing-block-start"),t?this.style.setProperty("--scb-textfield-spacing-block-end",t):this.style.removeProperty("--scb-textfield-spacing-block-end"),i?this.style.setProperty("--scb-textfield-spacing-inline-start",i):this.style.removeProperty("--scb-textfield-spacing-inline-start"),o?this.style.setProperty("--scb-textfield-spacing-inline-end",o):this.style.removeProperty("--scb-textfield-spacing-inline-end")}function v(s){if(!s)return;const e=String(s).trim();if(e)return/^\d+$/.test(e)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(e,10)))})`:e}function w(s=!1){const e=this.shadowRoot?.querySelector(".scb-textfield");if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))return!0;const t=this.errorText||"Ogiltig inmatning.";let i="";if(e.setCustomValidity(""),this.required&&!e.value)i=t,e.setCustomValidity(i);else if(this.pattern&&e.value)try{new RegExp(this.pattern).test(e.value)||(i=t,e.setCustomValidity(i))}catch{e.setCustomValidity("")}const o=s?e.reportValidity():e.checkValidity();if(this.error=!o,this._internals)if(o)this._internals.setValidity({});else{const l=i||e.validationMessage||t;this._internals.setValidity({customError:!0},l,e)}return o}function E(){const s=this.shadowRoot?.querySelector(".scb-textfield");s&&(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement)&&this._boundField!==s&&(f(u,this,L).call(this),this._boundField=s,this.type!=="time"&&s.addEventListener("input",this._onFieldInput),s.addEventListener("change",this._onFieldChange),s.addEventListener("select",this._onFieldSelect),s.addEventListener("focus",this._onFieldFocus),s.addEventListener("blur",this._onFieldBlur))}function L(){const s=this._boundField;s&&(s.removeEventListener("input",this._onFieldInput),s.removeEventListener("change",this._onFieldChange),s.removeEventListener("select",this._onFieldSelect),s.removeEventListener("focus",this._onFieldFocus),s.removeEventListener("blur",this._onFieldBlur),this._boundField=null)}function A(){this._showDatepicker=!1;const s=this.shadowRoot?.querySelector(".scb-textfield");if(s&&(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement)&&(s.value="",s.setCustomValidity("")),this.value="",this.error=!1,this._internals){const e=this.disabled?null:"";this._internals.setFormValue(e),this._internals.setValidity({})}}function _(){const s=this.renderRoot?.querySelector(".ripple-wrapper");s&&(this._inputFocused&&this._kbShouldShowRing?s.setAttribute("data-kb-focus","true"):s.removeAttribute("data-kb-focus"))}r([c({type:String,reflect:!0})],p.prototype,"type",void 0);r([c({type:String})],p.prototype,"label",void 0);r([c({type:String,attribute:"supporting-text"})],p.prototype,"supportingText",void 0);r([c({type:String,attribute:"help-text"})],p.prototype,"helpText",void 0);r([c({type:String,attribute:"help-label"})],p.prototype,"helpLabel",void 0);r([c({type:String,attribute:"error-text"})],p.prototype,"errorText",void 0);r([c({type:String,attribute:"leading-icon"})],p.prototype,"leadingIcon",void 0);r([c({type:String})],p.prototype,"name",void 0);r([c({type:String})],p.prototype,"pattern",void 0);r([c({type:String,attribute:"value"})],p.prototype,"value",void 0);r([c({type:String})],p.prototype,"underLabel",void 0);r([c({type:Boolean,reflect:!0})],p.prototype,"error",void 0);r([c({type:Boolean,reflect:!0})],p.prototype,"disabled",void 0);r([c({type:Boolean,reflect:!0})],p.prototype,"required",void 0);r([c({type:String,reflect:!0})],p.prototype,"size",void 0);r([c({type:String,reflect:!0})],p.prototype,"spacing",void 0);r([c({type:String,attribute:"spacing-top",reflect:!0})],p.prototype,"spacingTop",void 0);r([c({type:String,attribute:"spacing-bottom",reflect:!0})],p.prototype,"spacingBottom",void 0);r([c({type:String,attribute:"spacing-left",reflect:!0})],p.prototype,"spacingLeft",void 0);r([c({type:String,attribute:"spacing-right",reflect:!0})],p.prototype,"spacingRight",void 0);r([m()],p.prototype,"_showDatepicker",void 0);p=r([F("scb-textfield")],p);
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scb-wc",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.111",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -462,5 +462,5 @@
|
|
|
462
462
|
},
|
|
463
463
|
"./mvc/*": "./mvc/*"
|
|
464
464
|
},
|
|
465
|
-
"buildHash": "
|
|
465
|
+
"buildHash": "2327A14E218136B40D0DC388D20EAF7DADBBFD7C50C56DA4E19F71EE94BDC617"
|
|
466
466
|
}
|
|
@@ -45,6 +45,7 @@ export declare class ScbDialog extends LitElement {
|
|
|
45
45
|
private __applySpacing;
|
|
46
46
|
private __setOpen;
|
|
47
47
|
private __fire;
|
|
48
|
+
private __fireCancelable;
|
|
48
49
|
private __getSlottedElements;
|
|
49
50
|
private __appendHiddenFormValue;
|
|
50
51
|
private __clearGeneratedFormValues;
|
|
@@ -57,6 +58,7 @@ export declare class ScbDialog extends LitElement {
|
|
|
57
58
|
private __onDeny;
|
|
58
59
|
private __onReset;
|
|
59
60
|
private __onSubmit;
|
|
61
|
+
private __onFormSubmit;
|
|
60
62
|
private __onKeydownTrap;
|
|
61
63
|
private __slotIsEmpty;
|
|
62
64
|
private renderHeader;
|
|
@@ -52,6 +52,8 @@ export declare class ScbTextField extends LitElement {
|
|
|
52
52
|
private _renderSupportingText;
|
|
53
53
|
render(): TemplateResult;
|
|
54
54
|
private _toggleDatepicker;
|
|
55
|
+
private _openDatepicker;
|
|
56
|
+
private _onDatepickerClosed;
|
|
55
57
|
private _onDateSelected;
|
|
56
58
|
/**
|
|
57
59
|
* Vi re-dispatchar inbyggda "input", "change" och "select"-events med { bubbles: true, composed: true }.
|
|
@@ -64,8 +64,11 @@ var c = class extends n {
|
|
|
64
64
|
if (!t) return;
|
|
65
65
|
let n = window.innerWidth, r = window.innerHeight, i = Math.max(220, n - this._viewportMargin * 2);
|
|
66
66
|
if (this._isRenderedInsideDialog()) {
|
|
67
|
-
let
|
|
68
|
-
this.style.setProperty("--scb-datepicker-position", "
|
|
67
|
+
let a = Math.min(e.offsetWidth || 380, i), o = e.offsetHeight || 420, s = Math.min(Math.max(t.left, this._viewportMargin), n - this._viewportMargin - a), c = r - t.bottom - this._viewportMargin, l = t.top - this._viewportMargin, u = c < o + this._popupOffset && l > c;
|
|
68
|
+
if (this.style.setProperty("--scb-datepicker-position", "absolute"), this.style.setProperty("--scb-datepicker-computed-width", `${a}px`), this.style.setProperty("--scb-datepicker-left", `${s - t.left}px`), this.style.setProperty("--scb-datepicker-transform", "none"), this.style.setProperty("--scb-datepicker-bottom", "auto"), u) {
|
|
69
|
+
let e = Math.max(this._viewportMargin, t.top - o - this._popupOffset) - t.top;
|
|
70
|
+
this.style.setProperty("--scb-datepicker-top", `${e}px`), this.style.setProperty("--scb-datepicker-max-height", `${Math.max(0, l - this._popupOffset)}px`);
|
|
71
|
+
} else this.style.setProperty("--scb-datepicker-top", `${t.height + this._popupOffset}px`), this.style.setProperty("--scb-datepicker-max-height", `${Math.max(0, c - this._popupOffset)}px`);
|
|
69
72
|
return;
|
|
70
73
|
}
|
|
71
74
|
let a = Math.min(e.offsetWidth || 380, i), o = e.offsetHeight || 420, s = Math.min(Math.max(t.left, this._viewportMargin), n - this._viewportMargin - a), c = r - t.bottom - this._viewportMargin, l = t.top - this._viewportMargin, u = c < o + this._popupOffset && l > c;
|
|
@@ -231,7 +234,7 @@ var c = class extends n {
|
|
|
231
234
|
background: none;
|
|
232
235
|
font-size: 16px;
|
|
233
236
|
cursor: pointer;
|
|
234
|
-
font-family:
|
|
237
|
+
font-family: var(--brand-font, Inter, Arial, sans-serif);
|
|
235
238
|
align-content: center;
|
|
236
239
|
}
|
|
237
240
|
.day.selected {
|
package/scb-dialog/scb-dialog.js
CHANGED
|
@@ -42,7 +42,22 @@ var s = { fromAttribute(e) {
|
|
|
42
42
|
if (this.__syncSlottedFormValues(e), !this.__validateFormAndSlottedFields(e)) return;
|
|
43
43
|
e.requestSubmit();
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
}, this.__onFormSubmit = (e) => {
|
|
46
|
+
let t = e.currentTarget;
|
|
47
|
+
if (!(t instanceof HTMLFormElement)) return;
|
|
48
|
+
if (this.__syncSlottedFormValues(t), !this.__validateFormAndSlottedFields(t)) {
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
let n = new FormData(t);
|
|
53
|
+
if (!this.__fireCancelable("submit", {
|
|
54
|
+
form: t,
|
|
55
|
+
formData: n
|
|
56
|
+
})) {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
this.__setOpen(!1);
|
|
46
61
|
}, this.__onKeydownTrap = (e) => {
|
|
47
62
|
if (!this.open || e.key !== "Tab") return;
|
|
48
63
|
let t = Array.from(this.shadowRoot.querySelectorAll("button,[href],input,select,textarea,[tabindex]:not([tabindex=\"-1\"])")).filter((e) => !e.hasAttribute("disabled"));
|
|
@@ -336,6 +351,14 @@ var s = { fromAttribute(e) {
|
|
|
336
351
|
composed: !0
|
|
337
352
|
}));
|
|
338
353
|
}
|
|
354
|
+
__fireCancelable(e, t) {
|
|
355
|
+
return this.dispatchEvent(new CustomEvent(e, {
|
|
356
|
+
detail: t,
|
|
357
|
+
bubbles: !0,
|
|
358
|
+
composed: !0,
|
|
359
|
+
cancelable: !0
|
|
360
|
+
}));
|
|
361
|
+
}
|
|
339
362
|
__getSlottedElements() {
|
|
340
363
|
let e = this.shadowRoot?.querySelector("slot");
|
|
341
364
|
if (!(e instanceof HTMLSlotElement)) return [];
|
|
@@ -480,7 +503,7 @@ var s = { fromAttribute(e) {
|
|
|
480
503
|
return this.variant === "form" ? r`
|
|
481
504
|
${this.renderHeader(e)}
|
|
482
505
|
<div class="content" id=${t}>
|
|
483
|
-
<form id=${this.formId} action=${this.formAction} method=${this.formMethod || i}>
|
|
506
|
+
<form id=${this.formId} action=${this.formAction} method=${this.formMethod || i} @submit=${this.__onFormSubmit}>
|
|
484
507
|
<slot></slot>
|
|
485
508
|
</form>
|
|
486
509
|
</div>
|
|
@@ -49,6 +49,10 @@ var c = class extends n {
|
|
|
49
49
|
this._inputFocused = !1, this.#o();
|
|
50
50
|
}, this.type = "text", this.label = "", this.supportingText = "", this.helpText = "", this.helpLabel = "Visa hjälptext", this.errorText = "", this.leadingIcon = "", this.name = "", this.pattern = "", this.value = "", this.underLabel = "", this.error = !1, this.disabled = !1, this.required = !1, this.size = "large", this.spacing = void 0, this.spacingTop = void 0, this.spacingBottom = void 0, this.spacingLeft = void 0, this.spacingRight = void 0, this._form = null, this._formSubmitHandler = null, this._formResetHandler = null, this._initialValue = "", this._inputId = "", this._showDatepicker = !1, this._toggleDatepicker = () => {
|
|
51
51
|
this._showDatepicker = !this._showDatepicker;
|
|
52
|
+
}, this._openDatepicker = () => {
|
|
53
|
+
this._showDatepicker = !0;
|
|
54
|
+
}, this._onDatepickerClosed = () => {
|
|
55
|
+
this._showDatepicker = !1;
|
|
52
56
|
}, this._onDateSelected = (e) => {
|
|
53
57
|
if (this.value = e.detail.value, this._showDatepicker = !1, this._internals) {
|
|
54
58
|
let e = this.disabled ? null : this.value;
|
|
@@ -573,8 +577,8 @@ var c = class extends n {
|
|
|
573
577
|
aria-invalid=${this.error ? "true" : "false"}
|
|
574
578
|
aria-describedby=${n}
|
|
575
579
|
readonly
|
|
576
|
-
@focus=${this.
|
|
577
|
-
@click=${this.
|
|
580
|
+
@focus=${this._openDatepicker}
|
|
581
|
+
@click=${this._openDatepicker}
|
|
578
582
|
/>
|
|
579
583
|
<md-ripple></md-ripple>
|
|
580
584
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
@@ -592,6 +596,7 @@ var c = class extends n {
|
|
|
592
596
|
.selectedValue=${this.value}
|
|
593
597
|
.open=${this._showDatepicker}
|
|
594
598
|
@date-selected=${this._onDateSelected}
|
|
599
|
+
@datepicker-closed=${this._onDatepickerClosed}
|
|
595
600
|
></scb-datepicker>
|
|
596
601
|
</div>
|
|
597
602
|
` : this.type === "datetime-local" ? i`
|
|
@@ -611,8 +616,8 @@ var c = class extends n {
|
|
|
611
616
|
aria-invalid=${this.error ? "true" : "false"}
|
|
612
617
|
aria-describedby=${n}
|
|
613
618
|
readonly
|
|
614
|
-
@focus=${this.
|
|
615
|
-
@click=${this.
|
|
619
|
+
@focus=${this._openDatepicker}
|
|
620
|
+
@click=${this._openDatepicker}
|
|
616
621
|
/>
|
|
617
622
|
|
|
618
623
|
<md-ripple></md-ripple>
|
|
@@ -633,6 +638,7 @@ var c = class extends n {
|
|
|
633
638
|
.selectedValue=${this.value}
|
|
634
639
|
.open=${this._showDatepicker}
|
|
635
640
|
@date-selected=${this._onDateSelected}
|
|
641
|
+
@datepicker-closed=${this._onDatepickerClosed}
|
|
636
642
|
></scb-datepicker>
|
|
637
643
|
</div>
|
|
638
644
|
` : this.type === "time" ? i`
|
package/scb-wc.bundle.js
CHANGED
|
@@ -4340,7 +4340,7 @@ var ScbWc=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module
|
|
|
4340
4340
|
:host([overlay][direction='vertical'][anchor='start']) {
|
|
4341
4341
|
left: calc(var(--scb-divider-gap) / -2);
|
|
4342
4342
|
}
|
|
4343
|
-
`}firstUpdated(){this.#e()}updated(e){e.has(`spacing`)&&this.#e()}mapSpacingToken(e){if(!e)return;let t=String(e).trim();if(t)return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}#e(){let e=this.mapSpacingToken(this.spacing);e?this.style.setProperty(`--scb-divider-spacing-orth`,e):this.style.removeProperty(`--scb-divider-spacing-orth`)}render(){return b``}},N([g({type:String,reflect:!0})],mu.prototype,`variant`,void 0),N([g({type:String,reflect:!0})],mu.prototype,`direction`,void 0),N([g({type:String,reflect:!0})],mu.prototype,`inset`,void 0),N([g({type:Boolean,reflect:!0})],mu.prototype,`overlay`,void 0),N([g({type:String,reflect:!0})],mu.prototype,`anchor`,void 0),N([g({type:String,reflect:!0})],mu.prototype,`spacing`,void 0),mu=N([o(`scb-divider`)],mu)}));C(),y(),Zc(),Sc(),O(),T(),hu(),M(),P();var gu=class extends S{constructor(...e){super(...e),this._currentDate=new Date,this._selectedDate=null,this._showMonthDropdown=!1,this._showYearDropdown=!1,this.variant=`date`,this.lang=`sv`,this.selectedValue=``,this.open=!0,this._selectedHour=0,this._selectedMinute=0,this._viewportMargin=8,this._popupOffset=4,this._onWindowReposition=()=>{this._positionPopupWithinViewport()},this._monthNames=[this.lang==`sv`?`Januari`:`January`,this.lang==`sv`?`Februari`:`February`,this.lang==`sv`?`Mars`:`March`,(this.lang,`April`),this.lang==`sv`?`Maj`:`May`,this.lang==`sv`?`Juni`:`June`,this.lang==`sv`?`Juli`:`July`,this.lang==`sv`?`Augusti`:`August`,(this.lang,`September`),this.lang==`sv`?`Oktober`:`October`,(this.lang,`November`),(this.lang,`December`)],this._outsideClickHandler=e=>{this.open&&(e.composedPath().includes(this)||this._close())},this._prevMonth=()=>{let e=this._currentDate.getFullYear(),t=this._currentDate.getMonth();t===0?this._currentDate=new Date(e-1,11,1):this._currentDate=new Date(e,t-1,1)},this._prevYear=()=>{let e=this._currentDate.getFullYear(),t=this._currentDate.getMonth();this._currentDate=new Date(e-1,t,1)},this._nextMonth=()=>{let e=this._currentDate.getFullYear(),t=this._currentDate.getMonth();t===11?this._currentDate=new Date(e+1,0,1):this._currentDate=new Date(e,t+1,1)},this._nextYear=()=>{let e=this._currentDate.getFullYear(),t=this._currentDate.getMonth();this._currentDate=new Date(e+1,t,1)},this._onTimeChange=e=>{let[t,n]=e.target.value.split(`:`),r=parseInt(t,10),i=parseInt(n,10);this._selectedHour=isNaN(r)?0:Math.max(0,Math.min(23,r)),this._selectedMinute=isNaN(i)?0:Math.max(0,Math.min(59,i)),this._fireDateTimeChange()},this._close=()=>{this.open=!1,this.dispatchEvent(new CustomEvent(`datepicker-closed`,{bubbles:!0,composed:!0}))}}_isRenderedInsideDialog(){let e=this.getRootNode(),t=e instanceof ShadowRoot?e.host:null;return t instanceof HTMLElement&&t.closest(`scb-dialog`)?!0:!!this.closest(`scb-dialog`)}connectedCallback(){super.connectedCallback(),this._removeLazyFocusRingListeners=sc(this,this.renderRoot)}_positionPopupWithinViewport(){if(!this.open)return;let e=this.renderRoot.querySelector(`.datepicker-popup`);if(!e)return;let t=this.parentElement?.getBoundingClientRect();if(!t)return;let n=window.innerWidth,r=window.innerHeight,i=Math.max(220,n-this._viewportMargin*2);if(this._isRenderedInsideDialog()){let
|
|
4343
|
+
`}firstUpdated(){this.#e()}updated(e){e.has(`spacing`)&&this.#e()}mapSpacingToken(e){if(!e)return;let t=String(e).trim();if(t)return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}#e(){let e=this.mapSpacingToken(this.spacing);e?this.style.setProperty(`--scb-divider-spacing-orth`,e):this.style.removeProperty(`--scb-divider-spacing-orth`)}render(){return b``}},N([g({type:String,reflect:!0})],mu.prototype,`variant`,void 0),N([g({type:String,reflect:!0})],mu.prototype,`direction`,void 0),N([g({type:String,reflect:!0})],mu.prototype,`inset`,void 0),N([g({type:Boolean,reflect:!0})],mu.prototype,`overlay`,void 0),N([g({type:String,reflect:!0})],mu.prototype,`anchor`,void 0),N([g({type:String,reflect:!0})],mu.prototype,`spacing`,void 0),mu=N([o(`scb-divider`)],mu)}));C(),y(),Zc(),Sc(),O(),T(),hu(),M(),P();var gu=class extends S{constructor(...e){super(...e),this._currentDate=new Date,this._selectedDate=null,this._showMonthDropdown=!1,this._showYearDropdown=!1,this.variant=`date`,this.lang=`sv`,this.selectedValue=``,this.open=!0,this._selectedHour=0,this._selectedMinute=0,this._viewportMargin=8,this._popupOffset=4,this._onWindowReposition=()=>{this._positionPopupWithinViewport()},this._monthNames=[this.lang==`sv`?`Januari`:`January`,this.lang==`sv`?`Februari`:`February`,this.lang==`sv`?`Mars`:`March`,(this.lang,`April`),this.lang==`sv`?`Maj`:`May`,this.lang==`sv`?`Juni`:`June`,this.lang==`sv`?`Juli`:`July`,this.lang==`sv`?`Augusti`:`August`,(this.lang,`September`),this.lang==`sv`?`Oktober`:`October`,(this.lang,`November`),(this.lang,`December`)],this._outsideClickHandler=e=>{this.open&&(e.composedPath().includes(this)||this._close())},this._prevMonth=()=>{let e=this._currentDate.getFullYear(),t=this._currentDate.getMonth();t===0?this._currentDate=new Date(e-1,11,1):this._currentDate=new Date(e,t-1,1)},this._prevYear=()=>{let e=this._currentDate.getFullYear(),t=this._currentDate.getMonth();this._currentDate=new Date(e-1,t,1)},this._nextMonth=()=>{let e=this._currentDate.getFullYear(),t=this._currentDate.getMonth();t===11?this._currentDate=new Date(e+1,0,1):this._currentDate=new Date(e,t+1,1)},this._nextYear=()=>{let e=this._currentDate.getFullYear(),t=this._currentDate.getMonth();this._currentDate=new Date(e+1,t,1)},this._onTimeChange=e=>{let[t,n]=e.target.value.split(`:`),r=parseInt(t,10),i=parseInt(n,10);this._selectedHour=isNaN(r)?0:Math.max(0,Math.min(23,r)),this._selectedMinute=isNaN(i)?0:Math.max(0,Math.min(59,i)),this._fireDateTimeChange()},this._close=()=>{this.open=!1,this.dispatchEvent(new CustomEvent(`datepicker-closed`,{bubbles:!0,composed:!0}))}}_isRenderedInsideDialog(){let e=this.getRootNode(),t=e instanceof ShadowRoot?e.host:null;return t instanceof HTMLElement&&t.closest(`scb-dialog`)?!0:!!this.closest(`scb-dialog`)}connectedCallback(){super.connectedCallback(),this._removeLazyFocusRingListeners=sc(this,this.renderRoot)}_positionPopupWithinViewport(){if(!this.open)return;let e=this.renderRoot.querySelector(`.datepicker-popup`);if(!e)return;let t=this.parentElement?.getBoundingClientRect();if(!t)return;let n=window.innerWidth,r=window.innerHeight,i=Math.max(220,n-this._viewportMargin*2);if(this._isRenderedInsideDialog()){let a=Math.min(e.offsetWidth||380,i),o=e.offsetHeight||420,s=Math.min(Math.max(t.left,this._viewportMargin),n-this._viewportMargin-a),c=r-t.bottom-this._viewportMargin,l=t.top-this._viewportMargin,u=c<o+this._popupOffset&&l>c;if(this.style.setProperty(`--scb-datepicker-position`,`absolute`),this.style.setProperty(`--scb-datepicker-computed-width`,`${a}px`),this.style.setProperty(`--scb-datepicker-left`,`${s-t.left}px`),this.style.setProperty(`--scb-datepicker-transform`,`none`),this.style.setProperty(`--scb-datepicker-bottom`,`auto`),u){let e=Math.max(this._viewportMargin,t.top-o-this._popupOffset)-t.top;this.style.setProperty(`--scb-datepicker-top`,`${e}px`),this.style.setProperty(`--scb-datepicker-max-height`,`${Math.max(0,l-this._popupOffset)}px`)}else this.style.setProperty(`--scb-datepicker-top`,`${t.height+this._popupOffset}px`),this.style.setProperty(`--scb-datepicker-max-height`,`${Math.max(0,c-this._popupOffset)}px`);return}let a=Math.min(e.offsetWidth||380,i),o=e.offsetHeight||420,s=Math.min(Math.max(t.left,this._viewportMargin),n-this._viewportMargin-a),c=r-t.bottom-this._viewportMargin,l=t.top-this._viewportMargin,u=c<o+this._popupOffset&&l>c;this.style.setProperty(`--scb-datepicker-position`,`fixed`),this.style.setProperty(`--scb-datepicker-computed-width`,`${a}px`),this.style.setProperty(`--scb-datepicker-left`,`${s}px`),this.style.setProperty(`--scb-datepicker-transform`,`none`),u?(this.style.setProperty(`--scb-datepicker-top`,`${Math.max(this._viewportMargin,t.top-o-this._popupOffset)}px`),this.style.setProperty(`--scb-datepicker-bottom`,`auto`),this.style.setProperty(`--scb-datepicker-max-height`,`${Math.max(0,l-this._popupOffset)}px`)):(this.style.setProperty(`--scb-datepicker-top`,`${t.bottom+this._popupOffset}px`),this.style.setProperty(`--scb-datepicker-bottom`,`auto`),this.style.setProperty(`--scb-datepicker-max-height`,`${Math.max(0,c-this._popupOffset)}px`))}static{this.styles=[m`
|
|
4344
4344
|
:host {
|
|
4345
4345
|
--scb-datepicker-width: 380px;
|
|
4346
4346
|
--scb-datepicker-z-index: 1100;
|
|
@@ -4499,7 +4499,7 @@ var ScbWc=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module
|
|
|
4499
4499
|
background: none;
|
|
4500
4500
|
font-size: 16px;
|
|
4501
4501
|
cursor: pointer;
|
|
4502
|
-
font-family:
|
|
4502
|
+
font-family: var(--brand-font, Inter, Arial, sans-serif);
|
|
4503
4503
|
align-content: center;
|
|
4504
4504
|
}
|
|
4505
4505
|
.day.selected {
|
|
@@ -4635,7 +4635,7 @@ var ScbWc=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module
|
|
|
4635
4635
|
`:``}
|
|
4636
4636
|
</div>
|
|
4637
4637
|
</div>
|
|
4638
|
-
`}_getMonthDays(e,t){let n=new Date(Date.UTC(e,t,1)),r=new Date(Date.UTC(e,t+1,0)),i=[],a=[],o=n.getUTCDay(),s=o===0?6:o-1;for(let e=0;e<s;e++)a.push(null);for(let n=1;n<=r.getUTCDate();n++){let r=new Date(Date.UTC(e,t,n));a.push(r),a.length===7&&(i.push(a),a=[])}if(a.length){for(;a.length<7;)a.push(null);i.push(a)}return i}_toggleMonthDropdown(){this._showMonthDropdown=!this._showMonthDropdown,this._showMonthDropdown&&(this._showYearDropdown=!1,setTimeout(()=>{let e=this.renderRoot.querySelector(`#selected-month`);e&&e.scrollIntoView({block:`center`})},0))}_toggleYearDropdown(){this._showYearDropdown=!this._showYearDropdown,this._showYearDropdown&&(this._showMonthDropdown=!1,setTimeout(()=>{let e=this.renderRoot.querySelector(`#selected-year`);e&&e.scrollIntoView({block:`center`})},0))}_onMonthChangeCustom(e){let t=this._currentDate.getFullYear();this._currentDate=new Date(t,e,1),this._showMonthDropdown=!1}_onYearChangeCustom(e){let t=this._currentDate.getMonth();this._currentDate=new Date(e,t,1),this._showYearDropdown=!1}_isToday(e,t){return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}_isSelected(e){return this._selectedDate&&e.getDate()===this._selectedDate.getDate()&&e.getMonth()===this._selectedDate.getMonth()&&e.getFullYear()===this._selectedDate.getFullYear()}_selectDate(e){if(this._selectedDate=e,this.variant===`datetime-local`){let t=new Date(e);t.setHours(this._selectedHour??0,this._selectedMinute??0,0,0),this._selectedHour=t.getHours(),this._selectedMinute=t.getMinutes();let n=e=>e.toString().padStart(2,`0`),r=`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`;this.dispatchEvent(new CustomEvent(`date-selected`,{detail:{value:r},bubbles:!0,composed:!0}))}else{let t=e.toISOString().slice(0,10);this.dispatchEvent(new CustomEvent(`date-selected`,{detail:{value:t},bubbles:!0,composed:!0}))}}_fireDateTimeChange(){if(this.variant===`datetime-local`&&this._selectedDate){let e=new Date(this._selectedDate);e.setHours(this._selectedHour??0,this._selectedMinute??0,0,0);let t=e=>e.toString().padStart(2,`0`),n=`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())} ${t(e.getHours())}:${t(e.getMinutes())}`;this.dispatchEvent(new CustomEvent(`date-selected`,{detail:{value:n},bubbles:!0,composed:!0}))}}};N([_()],gu.prototype,`_currentDate`,void 0),N([_()],gu.prototype,`_selectedDate`,void 0),N([_()],gu.prototype,`_showMonthDropdown`,void 0),N([_()],gu.prototype,`_showYearDropdown`,void 0),N([g({type:String})],gu.prototype,`variant`,void 0),N([g({type:String})],gu.prototype,`lang`,void 0),N([g({type:String})],gu.prototype,`selectedValue`,void 0),N([g({type:Boolean})],gu.prototype,`open`,void 0),N([_()],gu.prototype,`_selectedHour`,void 0),N([_()],gu.prototype,`_selectedMinute`,void 0),gu=N([o(`scb-datepicker`)],gu),C(),y(),O(),T(),M(),Zc(),vl(),P();var V=class extends S{static{this.formAssociated=!0}constructor(){super(),this._internals=null,this._inputFocused=!1,this._kbShouldShowRing=!1,this._onGlobalKeydown=e=>{e.key===`Tab`&&(ic(),this._kbShouldShowRing=!0,this._inputFocused&&this.#o())},this._onGlobalPointerDown=()=>{this._kbShouldShowRing=!1,this._inputFocused&&this.#o()},this._hasRenderedOnce=!1,this._boundField=null,this._onFieldInput=()=>{let e=this._boundField;if(!e)return;let t=e;if(this.value=t.value,this._internals){let e=this.disabled?null:this.value;this._internals.setFormValue(e)}this.#n(),this.dispatchEvent(new Event(`input`,{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`onValueChanged`,{detail:{value:this.value},bubbles:!0,composed:!0}))},this._onFieldChange=()=>{this.dispatchEvent(new Event(`change`,{bubbles:!0,composed:!0}))},this._onFieldSelect=()=>{this.dispatchEvent(new Event(`select`,{bubbles:!0,composed:!0}))},this._onFieldFocus=()=>{this._inputFocused=!0,this.#o()},this._onFieldBlur=()=>{this._inputFocused=!1,this.#o()},this.type=`text`,this.label=``,this.supportingText=``,this.helpText=``,this.helpLabel=`Visa hjälptext`,this.errorText=``,this.leadingIcon=``,this.name=``,this.pattern=``,this.value=``,this.underLabel=``,this.error=!1,this.disabled=!1,this.required=!1,this.size=`large`,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this._form=null,this._formSubmitHandler=null,this._formResetHandler=null,this._initialValue=``,this._inputId=``,this._showDatepicker=!1,this._toggleDatepicker=()=>{this._showDatepicker=!this._showDatepicker},this._onDateSelected=e=>{if(this.value=e.detail.value,this._showDatepicker=!1,this._internals){let e=this.disabled?null:this.value;this._internals.setFormValue(e)}this.#n(),this.dispatchEvent(new Event(`input`,{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`onValueChanged`,{detail:{value:this.value},bubbles:!0,composed:!0}))},`attachInternals`in this&&(this._internals=this.attachInternals())}static{this.styles=[m`
|
|
4638
|
+
`}_getMonthDays(e,t){let n=new Date(Date.UTC(e,t,1)),r=new Date(Date.UTC(e,t+1,0)),i=[],a=[],o=n.getUTCDay(),s=o===0?6:o-1;for(let e=0;e<s;e++)a.push(null);for(let n=1;n<=r.getUTCDate();n++){let r=new Date(Date.UTC(e,t,n));a.push(r),a.length===7&&(i.push(a),a=[])}if(a.length){for(;a.length<7;)a.push(null);i.push(a)}return i}_toggleMonthDropdown(){this._showMonthDropdown=!this._showMonthDropdown,this._showMonthDropdown&&(this._showYearDropdown=!1,setTimeout(()=>{let e=this.renderRoot.querySelector(`#selected-month`);e&&e.scrollIntoView({block:`center`})},0))}_toggleYearDropdown(){this._showYearDropdown=!this._showYearDropdown,this._showYearDropdown&&(this._showMonthDropdown=!1,setTimeout(()=>{let e=this.renderRoot.querySelector(`#selected-year`);e&&e.scrollIntoView({block:`center`})},0))}_onMonthChangeCustom(e){let t=this._currentDate.getFullYear();this._currentDate=new Date(t,e,1),this._showMonthDropdown=!1}_onYearChangeCustom(e){let t=this._currentDate.getMonth();this._currentDate=new Date(e,t,1),this._showYearDropdown=!1}_isToday(e,t){return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}_isSelected(e){return this._selectedDate&&e.getDate()===this._selectedDate.getDate()&&e.getMonth()===this._selectedDate.getMonth()&&e.getFullYear()===this._selectedDate.getFullYear()}_selectDate(e){if(this._selectedDate=e,this.variant===`datetime-local`){let t=new Date(e);t.setHours(this._selectedHour??0,this._selectedMinute??0,0,0),this._selectedHour=t.getHours(),this._selectedMinute=t.getMinutes();let n=e=>e.toString().padStart(2,`0`),r=`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`;this.dispatchEvent(new CustomEvent(`date-selected`,{detail:{value:r},bubbles:!0,composed:!0}))}else{let t=e.toISOString().slice(0,10);this.dispatchEvent(new CustomEvent(`date-selected`,{detail:{value:t},bubbles:!0,composed:!0}))}}_fireDateTimeChange(){if(this.variant===`datetime-local`&&this._selectedDate){let e=new Date(this._selectedDate);e.setHours(this._selectedHour??0,this._selectedMinute??0,0,0);let t=e=>e.toString().padStart(2,`0`),n=`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())} ${t(e.getHours())}:${t(e.getMinutes())}`;this.dispatchEvent(new CustomEvent(`date-selected`,{detail:{value:n},bubbles:!0,composed:!0}))}}};N([_()],gu.prototype,`_currentDate`,void 0),N([_()],gu.prototype,`_selectedDate`,void 0),N([_()],gu.prototype,`_showMonthDropdown`,void 0),N([_()],gu.prototype,`_showYearDropdown`,void 0),N([g({type:String})],gu.prototype,`variant`,void 0),N([g({type:String})],gu.prototype,`lang`,void 0),N([g({type:String})],gu.prototype,`selectedValue`,void 0),N([g({type:Boolean})],gu.prototype,`open`,void 0),N([_()],gu.prototype,`_selectedHour`,void 0),N([_()],gu.prototype,`_selectedMinute`,void 0),gu=N([o(`scb-datepicker`)],gu),C(),y(),O(),T(),M(),Zc(),vl(),P();var V=class extends S{static{this.formAssociated=!0}constructor(){super(),this._internals=null,this._inputFocused=!1,this._kbShouldShowRing=!1,this._onGlobalKeydown=e=>{e.key===`Tab`&&(ic(),this._kbShouldShowRing=!0,this._inputFocused&&this.#o())},this._onGlobalPointerDown=()=>{this._kbShouldShowRing=!1,this._inputFocused&&this.#o()},this._hasRenderedOnce=!1,this._boundField=null,this._onFieldInput=()=>{let e=this._boundField;if(!e)return;let t=e;if(this.value=t.value,this._internals){let e=this.disabled?null:this.value;this._internals.setFormValue(e)}this.#n(),this.dispatchEvent(new Event(`input`,{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`onValueChanged`,{detail:{value:this.value},bubbles:!0,composed:!0}))},this._onFieldChange=()=>{this.dispatchEvent(new Event(`change`,{bubbles:!0,composed:!0}))},this._onFieldSelect=()=>{this.dispatchEvent(new Event(`select`,{bubbles:!0,composed:!0}))},this._onFieldFocus=()=>{this._inputFocused=!0,this.#o()},this._onFieldBlur=()=>{this._inputFocused=!1,this.#o()},this.type=`text`,this.label=``,this.supportingText=``,this.helpText=``,this.helpLabel=`Visa hjälptext`,this.errorText=``,this.leadingIcon=``,this.name=``,this.pattern=``,this.value=``,this.underLabel=``,this.error=!1,this.disabled=!1,this.required=!1,this.size=`large`,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this._form=null,this._formSubmitHandler=null,this._formResetHandler=null,this._initialValue=``,this._inputId=``,this._showDatepicker=!1,this._toggleDatepicker=()=>{this._showDatepicker=!this._showDatepicker},this._openDatepicker=()=>{this._showDatepicker=!0},this._onDatepickerClosed=()=>{this._showDatepicker=!1},this._onDateSelected=e=>{if(this.value=e.detail.value,this._showDatepicker=!1,this._internals){let e=this.disabled?null:this.value;this._internals.setFormValue(e)}this.#n(),this.dispatchEvent(new Event(`input`,{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`onValueChanged`,{detail:{value:this.value},bubbles:!0,composed:!0}))},`attachInternals`in this&&(this._internals=this.attachInternals())}static{this.styles=[m`
|
|
4639
4639
|
:host {
|
|
4640
4640
|
--scb-textfield-number-max-width: 280px;
|
|
4641
4641
|
--scb-textfield-text-max-width: 400px;
|
|
@@ -5127,8 +5127,8 @@ var ScbWc=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module
|
|
|
5127
5127
|
aria-invalid=${this.error?`true`:`false`}
|
|
5128
5128
|
aria-describedby=${n}
|
|
5129
5129
|
readonly
|
|
5130
|
-
@focus=${this.
|
|
5131
|
-
@click=${this.
|
|
5130
|
+
@focus=${this._openDatepicker}
|
|
5131
|
+
@click=${this._openDatepicker}
|
|
5132
5132
|
/>
|
|
5133
5133
|
<md-ripple></md-ripple>
|
|
5134
5134
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
@@ -5146,6 +5146,7 @@ var ScbWc=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module
|
|
|
5146
5146
|
.selectedValue=${this.value}
|
|
5147
5147
|
.open=${this._showDatepicker}
|
|
5148
5148
|
@date-selected=${this._onDateSelected}
|
|
5149
|
+
@datepicker-closed=${this._onDatepickerClosed}
|
|
5149
5150
|
></scb-datepicker>
|
|
5150
5151
|
</div>
|
|
5151
5152
|
`:this.type===`datetime-local`?b`
|
|
@@ -5165,8 +5166,8 @@ var ScbWc=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module
|
|
|
5165
5166
|
aria-invalid=${this.error?`true`:`false`}
|
|
5166
5167
|
aria-describedby=${n}
|
|
5167
5168
|
readonly
|
|
5168
|
-
@focus=${this.
|
|
5169
|
-
@click=${this.
|
|
5169
|
+
@focus=${this._openDatepicker}
|
|
5170
|
+
@click=${this._openDatepicker}
|
|
5170
5171
|
/>
|
|
5171
5172
|
|
|
5172
5173
|
<md-ripple></md-ripple>
|
|
@@ -5187,6 +5188,7 @@ var ScbWc=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module
|
|
|
5187
5188
|
.selectedValue=${this.value}
|
|
5188
5189
|
.open=${this._showDatepicker}
|
|
5189
5190
|
@date-selected=${this._onDateSelected}
|
|
5191
|
+
@datepicker-closed=${this._onDatepickerClosed}
|
|
5190
5192
|
></scb-datepicker>
|
|
5191
5193
|
</div>
|
|
5192
5194
|
`:this.type===`time`?b`
|
|
@@ -5409,7 +5411,7 @@ var ScbWc=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module
|
|
|
5409
5411
|
</div>`:x}
|
|
5410
5412
|
</label>
|
|
5411
5413
|
<slot></slot>
|
|
5412
|
-
`}};N([g({type:Boolean,reflect:!0})],wu.prototype,`disabled`,void 0),N([g({type:Boolean,reflect:!0})],wu.prototype,`checked`,void 0),N([g({type:String,reflect:!0})],wu.prototype,`name`,void 0),N([g({type:String,reflect:!0})],wu.prototype,`value`,void 0),N([g({type:String,reflect:!0})],wu.prototype,`size`,void 0),N([g({type:Boolean,reflect:!0})],wu.prototype,`deselectable`,void 0),N([g({type:String})],wu.prototype,`label`,void 0),N([g({type:String,attribute:`supporting-text`})],wu.prototype,`supportingText`,void 0),N([g({type:String,attribute:`aria-label`})],wu.prototype,`ariaLabel`,void 0),wu=N([o(`scb-radio-button`)],wu),C(),y(),Sc(),Zc(),Lc(),sl(),O(),P();var Tu={fromAttribute(e){if(e===null)return!1;let t=e.trim().toLowerCase();return t!==`false`&&t!==`0`&&t!==`no`}},H=class extends S{constructor(...e){super(...e),this.open=!1,this.inSb=!1,this.scrimClose=!0,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.variant=`basic`,this.label=``,this.icon=``,this.supportingText=``,this.okButton=`OK`,this.cancelButton=`Avbryt`,this.deleteButton=`Delete`,this.confirmButton=`Ta bort`,this.denyButton=`Avbryt`,this.resetButton=`Återställ`,this.submitButton=`Spara`,this.formId=``,this.formAction=``,this.formMethod=``,this.__lastTriggerEl=null,this.__scrollLocked=!1,this.__onDocumentClick=e=>{this.__getActionFromEvent(e)===`toggle`&&(this.__setOpen(!this.open),e.stopPropagation())},this.__onDocumentKeydown=e=>{this.open&&e.key===`Escape`&&(this.__fire(`esc`),this.__setOpen(!1))},this.__onScrimClick=()=>{this.scrimClose&&(this.__fire(`scrim`),this.__setOpen(!1))},this.__onOk=()=>{this.__fire(`ok`),this.__setOpen(!1)},this.__onCancel=()=>{this.__fire(`cancel`),this.__setOpen(!1)},this.__onConfirm=()=>{this.__fire(`confirm`),this.__setOpen(!1)},this.__onDeny=()=>{this.__fire(`deny`),this.__setOpen(!1)},this.__onReset=()=>{let e=this.shadowRoot?.querySelector(`form`);e instanceof HTMLFormElement&&(this.__clearGeneratedFormValues(e),e.reset()),(this.shadowRoot?.querySelector(`slot`)?.assignedElements({flatten:!0})??[]).forEach(e=>{let t=e.tagName;t===`SCB-TEXTFIELD`&&(e.value=``),t===`SCB-CHECKBOX`&&(e.checked=!1),t===`SCB-RADIO-BUTTON`&&(e.checked=!1),t===`SCB-SWITCH`&&(e.selected=!1),t===`SCB-CHIP`&&(e.selected=!1)}),this.__fire(`reset`)},this.__onSubmit=()=>{let e=this.shadowRoot?.querySelector(`form`);if(e instanceof HTMLFormElement){if(this.__syncSlottedFormValues(e),!this.__validateFormAndSlottedFields(e))return;e.requestSubmit()}this.
|
|
5414
|
+
`}};N([g({type:Boolean,reflect:!0})],wu.prototype,`disabled`,void 0),N([g({type:Boolean,reflect:!0})],wu.prototype,`checked`,void 0),N([g({type:String,reflect:!0})],wu.prototype,`name`,void 0),N([g({type:String,reflect:!0})],wu.prototype,`value`,void 0),N([g({type:String,reflect:!0})],wu.prototype,`size`,void 0),N([g({type:Boolean,reflect:!0})],wu.prototype,`deselectable`,void 0),N([g({type:String})],wu.prototype,`label`,void 0),N([g({type:String,attribute:`supporting-text`})],wu.prototype,`supportingText`,void 0),N([g({type:String,attribute:`aria-label`})],wu.prototype,`ariaLabel`,void 0),wu=N([o(`scb-radio-button`)],wu),C(),y(),Sc(),Zc(),Lc(),sl(),O(),P();var Tu={fromAttribute(e){if(e===null)return!1;let t=e.trim().toLowerCase();return t!==`false`&&t!==`0`&&t!==`no`}},H=class extends S{constructor(...e){super(...e),this.open=!1,this.inSb=!1,this.scrimClose=!0,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.variant=`basic`,this.label=``,this.icon=``,this.supportingText=``,this.okButton=`OK`,this.cancelButton=`Avbryt`,this.deleteButton=`Delete`,this.confirmButton=`Ta bort`,this.denyButton=`Avbryt`,this.resetButton=`Återställ`,this.submitButton=`Spara`,this.formId=``,this.formAction=``,this.formMethod=``,this.__lastTriggerEl=null,this.__scrollLocked=!1,this.__onDocumentClick=e=>{this.__getActionFromEvent(e)===`toggle`&&(this.__setOpen(!this.open),e.stopPropagation())},this.__onDocumentKeydown=e=>{this.open&&e.key===`Escape`&&(this.__fire(`esc`),this.__setOpen(!1))},this.__onScrimClick=()=>{this.scrimClose&&(this.__fire(`scrim`),this.__setOpen(!1))},this.__onOk=()=>{this.__fire(`ok`),this.__setOpen(!1)},this.__onCancel=()=>{this.__fire(`cancel`),this.__setOpen(!1)},this.__onConfirm=()=>{this.__fire(`confirm`),this.__setOpen(!1)},this.__onDeny=()=>{this.__fire(`deny`),this.__setOpen(!1)},this.__onReset=()=>{let e=this.shadowRoot?.querySelector(`form`);e instanceof HTMLFormElement&&(this.__clearGeneratedFormValues(e),e.reset()),(this.shadowRoot?.querySelector(`slot`)?.assignedElements({flatten:!0})??[]).forEach(e=>{let t=e.tagName;t===`SCB-TEXTFIELD`&&(e.value=``),t===`SCB-CHECKBOX`&&(e.checked=!1),t===`SCB-RADIO-BUTTON`&&(e.checked=!1),t===`SCB-SWITCH`&&(e.selected=!1),t===`SCB-CHIP`&&(e.selected=!1)}),this.__fire(`reset`)},this.__onSubmit=()=>{let e=this.shadowRoot?.querySelector(`form`);if(e instanceof HTMLFormElement){if(this.__syncSlottedFormValues(e),!this.__validateFormAndSlottedFields(e))return;e.requestSubmit()}},this.__onFormSubmit=e=>{let t=e.currentTarget;if(!(t instanceof HTMLFormElement))return;if(this.__syncSlottedFormValues(t),!this.__validateFormAndSlottedFields(t)){e.preventDefault();return}let n=new FormData(t);if(!this.__fireCancelable(`submit`,{form:t,formData:n})){e.preventDefault();return}this.__setOpen(!1)},this.__onKeydownTrap=e=>{if(!this.open||e.key!==`Tab`)return;let t=Array.from(this.shadowRoot.querySelectorAll(`button,[href],input,select,textarea,[tabindex]:not([tabindex="-1"])`)).filter(e=>!e.hasAttribute(`disabled`));if(!t.length)return;let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(r.focus(),e.preventDefault()):!e.shiftKey&&document.activeElement===r&&(n.focus(),e.preventDefault())}}static{this.styles=m`
|
|
5413
5415
|
:host {
|
|
5414
5416
|
display:block;
|
|
5415
5417
|
position:relative;
|
|
@@ -5620,7 +5622,7 @@ var ScbWc=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module
|
|
|
5620
5622
|
to { opacity: 0; }
|
|
5621
5623
|
}
|
|
5622
5624
|
|
|
5623
|
-
`}__getActionFromEvent(e){if(!this.id)return null;for(let t of e.composedPath())if(t instanceof Element&&(t.getAttribute(`data-dialog-toggle`)===this.id||t.getAttribute(`aria-controls`)===this.id))return this.__lastTriggerEl=t,`toggle`;return null}connectedCallback(){super.connectedCallback(),this.__applyZIndex(),this.__applyMaxSize(),document.addEventListener(`click`,this.__onDocumentClick,!1),document.addEventListener(`keydown`,this.__onDocumentKeydown,!0),this.addEventListener(`keydown`,this.__onKeydownTrap)}disconnectedCallback(){document.removeEventListener(`click`,this.__onDocumentClick,!1),document.removeEventListener(`keydown`,this.__onDocumentKeydown,!0),this.removeEventListener(`keydown`,this.__onKeydownTrap),this.__toggleScrollLock(!1),super.disconnectedCallback()}__applyZIndex(){let e=typeof this.zIndex==`number`&&Number.isFinite(this.zIndex)?this.zIndex:void 0;if(e===void 0){this.style.removeProperty(`--z-dialog-scrim`),this.style.removeProperty(`--z-dialog`);return}this.style.setProperty(`--z-dialog-scrim`,String(e)),this.style.setProperty(`--z-dialog`,String(e+1))}__applyMaxSize(){let e=(this.maxW??``).trim(),t=(this.maxH??``).trim();e?(this.style.setProperty(`--scb-dialog-max-w`,e),this.style.setProperty(`--scb-dialog-width`,`min(${e}, 90vw)`)):(this.style.removeProperty(`--scb-dialog-max-w`),this.style.removeProperty(`--scb-dialog-width`)),t?this.style.setProperty(`--scb-dialog-max-h`,t):this.style.removeProperty(`--scb-dialog-max-h`)}updated(e){if(e.has(`zIndex`)&&this.__applyZIndex(),(e.has(`maxW`)||e.has(`maxH`))&&this.__applyMaxSize(),e.has(`open`)){let t=e.get(`open`);this.__updateTriggersExpanded(),this.open&&!t?!this.inSb&&!this.__usesInPlaceLayout()&&this.updateComplete.then(()=>{let e=this.shadowRoot?.querySelector(`button,[href],input,select,textarea,[tabindex]:not([tabindex="-1"])`);e?e.focus():this.shadowRoot?.querySelector(`.container`)?.focus()}):!this.open&&t&&this.__lastTriggerEl?.focus?.(),this.__toggleScrollLock(this.open)}(e.has(`spacing`)||e.has(`spacingTop`)||e.has(`spacingBottom`)||e.has(`spacingLeft`)||e.has(`spacingRight`))&&this.__applySpacing()}__updateTriggersExpanded(){this.id&&document.querySelectorAll(`[aria-controls="${this.id}"], [data-dialog-toggle="${this.id}"]`).forEach(e=>{e.hasAttribute(`aria-controls`)&&e.setAttribute(`aria-expanded`,String(this.open))})}__usesInPlaceLayout(){let e=getComputedStyle(this);return e.getPropertyValue(`--scb-dialog-scrim-position`).trim()===`relative`||e.getPropertyValue(`--scb-dialog-container-position`).trim()===`absolute`}__toggleScrollLock(e){let t=document.documentElement,n=document.body;if(e){if(this.__scrollLocked||this.inSb||this.__usesInPlaceLayout())return;let e=window.innerWidth-t.clientWidth;t.style.overflow=`hidden`,n.style.paddingRight=e>0?`${e}px`:``,this.__scrollLocked=!0;return}this.__scrollLocked&&=(t.style.overflow=``,n.style.paddingRight=``,!1)}mapSpacingToken(e){if(!e)return;let t=String(e).trim();if(t)return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}__applySpacing(){let e=this.mapSpacingToken(this.spacing),t=this.mapSpacingToken(this.spacingTop)??e,n=this.mapSpacingToken(this.spacingBottom)??e,r=this.mapSpacingToken(this.spacingLeft),i=this.mapSpacingToken(this.spacingRight);t?this.style.setProperty(`--scb-dialog-spacing-block-start`,t):this.style.removeProperty(`--scb-dialog-spacing-block-start`),n?this.style.setProperty(`--scb-dialog-spacing-block-end`,n):this.style.removeProperty(`--scb-dialog-spacing-block-end`),r?this.style.setProperty(`--scb-dialog-spacing-inline-start`,r):this.style.removeProperty(`--scb-dialog-spacing-inline-start`),i?this.style.setProperty(`--scb-dialog-spacing-inline-end`,i):this.style.removeProperty(`--scb-dialog-spacing-inline-end`)}__setOpen(e){this.open=e,this.__fire(e?`open`:`close`)}__fire(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}__getSlottedElements(){let e=this.shadowRoot?.querySelector(`slot`);if(!(e instanceof HTMLSlotElement))return[];let t=e.assignedElements({flatten:!0}),n=[];for(let e of t)n.push(e,...Array.from(e.querySelectorAll(`*`)));return n}__appendHiddenFormValue(e,t,n){let r=document.createElement(`input`);r.type=`hidden`,r.name=t,r.value=n,r.setAttribute(`data-scb-dialog-generated`,`true`),e.append(r)}__clearGeneratedFormValues(e){e.querySelectorAll(`input[data-scb-dialog-generated="true"]`).forEach(e=>e.remove())}__syncSlottedFormValues(e){this.__clearGeneratedFormValues(e),this.__getSlottedElements().forEach(t=>{if(!(t instanceof HTMLElement))return;let n=(t.getAttribute(`name`)??``).trim();if(n&&!(t.disabled===!0||t.hasAttribute(`disabled`))){if(t instanceof HTMLInputElement){if(t.form===e)return;let r=(t.type||``).toLowerCase();if(r===`checkbox`||r===`radio`){t.checked&&this.__appendHiddenFormValue(e,n,t.value||`on`);return}this.__appendHiddenFormValue(e,n,t.value??``);return}if(t instanceof HTMLTextAreaElement){if(t.form===e)return;this.__appendHiddenFormValue(e,n,t.value??``);return}if(t instanceof HTMLSelectElement){if(t.form===e)return;if(t.multiple){Array.from(t.selectedOptions).forEach(t=>{this.__appendHiddenFormValue(e,n,t.value)});return}this.__appendHiddenFormValue(e,n,t.value??``);return}switch(t.tagName){case`SCB-TEXTFIELD`:this.__appendHiddenFormValue(e,n,String(t.value??``));return;case`SCB-CHECKBOX`:t.checked&&this.__appendHiddenFormValue(e,n,String(t.value??t.getAttribute(`value`)??`on`));return;case`SCB-RADIO-BUTTON`:t.checked&&this.__appendHiddenFormValue(e,n,String(t.value??t.getAttribute(`value`)??`on`));return;case`SCB-SWITCH`:(t.selected||t.checked)&&this.__appendHiddenFormValue(e,n,String(t.value??t.getAttribute(`value`)??`on`));return;case`SCB-CHIP`:t.selected&&this.__appendHiddenFormValue(e,n,String(t.value??t.getAttribute(`value`)??`on`));return;default:`value`in t&&this.__appendHiddenFormValue(e,n,String(t.value??``))}}})}__validateFormAndSlottedFields(e){let t=e=>e.disabled===!0||e.hasAttribute(`disabled`),n=e.reportValidity(),r=null,i=new Set;return this.__getSlottedElements().forEach(e=>{if(!(e instanceof HTMLElement)||i.has(e)||t(e))return;i.add(e);let a=e;if(e.tagName===`SCB-TEXTFIELD`&&a.error===!0){r||=e,n=!1;return}if(typeof a.reportValidity==`function`){let t=!!a.reportValidity();!t&&!r&&(r=e),n&&=t}}),!n&&r&&r.focus(),n}__slotIsEmpty(){let e=this.shadowRoot?.querySelector(`slot`);return e?e.assignedElements({flatten:!0}).length===0:!0}renderHeader(e){let t=this.variant===`form`||this.variant===`floating`||this.variant===`iframe`;return b`
|
|
5625
|
+
`}__getActionFromEvent(e){if(!this.id)return null;for(let t of e.composedPath())if(t instanceof Element&&(t.getAttribute(`data-dialog-toggle`)===this.id||t.getAttribute(`aria-controls`)===this.id))return this.__lastTriggerEl=t,`toggle`;return null}connectedCallback(){super.connectedCallback(),this.__applyZIndex(),this.__applyMaxSize(),document.addEventListener(`click`,this.__onDocumentClick,!1),document.addEventListener(`keydown`,this.__onDocumentKeydown,!0),this.addEventListener(`keydown`,this.__onKeydownTrap)}disconnectedCallback(){document.removeEventListener(`click`,this.__onDocumentClick,!1),document.removeEventListener(`keydown`,this.__onDocumentKeydown,!0),this.removeEventListener(`keydown`,this.__onKeydownTrap),this.__toggleScrollLock(!1),super.disconnectedCallback()}__applyZIndex(){let e=typeof this.zIndex==`number`&&Number.isFinite(this.zIndex)?this.zIndex:void 0;if(e===void 0){this.style.removeProperty(`--z-dialog-scrim`),this.style.removeProperty(`--z-dialog`);return}this.style.setProperty(`--z-dialog-scrim`,String(e)),this.style.setProperty(`--z-dialog`,String(e+1))}__applyMaxSize(){let e=(this.maxW??``).trim(),t=(this.maxH??``).trim();e?(this.style.setProperty(`--scb-dialog-max-w`,e),this.style.setProperty(`--scb-dialog-width`,`min(${e}, 90vw)`)):(this.style.removeProperty(`--scb-dialog-max-w`),this.style.removeProperty(`--scb-dialog-width`)),t?this.style.setProperty(`--scb-dialog-max-h`,t):this.style.removeProperty(`--scb-dialog-max-h`)}updated(e){if(e.has(`zIndex`)&&this.__applyZIndex(),(e.has(`maxW`)||e.has(`maxH`))&&this.__applyMaxSize(),e.has(`open`)){let t=e.get(`open`);this.__updateTriggersExpanded(),this.open&&!t?!this.inSb&&!this.__usesInPlaceLayout()&&this.updateComplete.then(()=>{let e=this.shadowRoot?.querySelector(`button,[href],input,select,textarea,[tabindex]:not([tabindex="-1"])`);e?e.focus():this.shadowRoot?.querySelector(`.container`)?.focus()}):!this.open&&t&&this.__lastTriggerEl?.focus?.(),this.__toggleScrollLock(this.open)}(e.has(`spacing`)||e.has(`spacingTop`)||e.has(`spacingBottom`)||e.has(`spacingLeft`)||e.has(`spacingRight`))&&this.__applySpacing()}__updateTriggersExpanded(){this.id&&document.querySelectorAll(`[aria-controls="${this.id}"], [data-dialog-toggle="${this.id}"]`).forEach(e=>{e.hasAttribute(`aria-controls`)&&e.setAttribute(`aria-expanded`,String(this.open))})}__usesInPlaceLayout(){let e=getComputedStyle(this);return e.getPropertyValue(`--scb-dialog-scrim-position`).trim()===`relative`||e.getPropertyValue(`--scb-dialog-container-position`).trim()===`absolute`}__toggleScrollLock(e){let t=document.documentElement,n=document.body;if(e){if(this.__scrollLocked||this.inSb||this.__usesInPlaceLayout())return;let e=window.innerWidth-t.clientWidth;t.style.overflow=`hidden`,n.style.paddingRight=e>0?`${e}px`:``,this.__scrollLocked=!0;return}this.__scrollLocked&&=(t.style.overflow=``,n.style.paddingRight=``,!1)}mapSpacingToken(e){if(!e)return;let t=String(e).trim();if(t)return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}__applySpacing(){let e=this.mapSpacingToken(this.spacing),t=this.mapSpacingToken(this.spacingTop)??e,n=this.mapSpacingToken(this.spacingBottom)??e,r=this.mapSpacingToken(this.spacingLeft),i=this.mapSpacingToken(this.spacingRight);t?this.style.setProperty(`--scb-dialog-spacing-block-start`,t):this.style.removeProperty(`--scb-dialog-spacing-block-start`),n?this.style.setProperty(`--scb-dialog-spacing-block-end`,n):this.style.removeProperty(`--scb-dialog-spacing-block-end`),r?this.style.setProperty(`--scb-dialog-spacing-inline-start`,r):this.style.removeProperty(`--scb-dialog-spacing-inline-start`),i?this.style.setProperty(`--scb-dialog-spacing-inline-end`,i):this.style.removeProperty(`--scb-dialog-spacing-inline-end`)}__setOpen(e){this.open=e,this.__fire(e?`open`:`close`)}__fire(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}__fireCancelable(e,t){return this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0,cancelable:!0}))}__getSlottedElements(){let e=this.shadowRoot?.querySelector(`slot`);if(!(e instanceof HTMLSlotElement))return[];let t=e.assignedElements({flatten:!0}),n=[];for(let e of t)n.push(e,...Array.from(e.querySelectorAll(`*`)));return n}__appendHiddenFormValue(e,t,n){let r=document.createElement(`input`);r.type=`hidden`,r.name=t,r.value=n,r.setAttribute(`data-scb-dialog-generated`,`true`),e.append(r)}__clearGeneratedFormValues(e){e.querySelectorAll(`input[data-scb-dialog-generated="true"]`).forEach(e=>e.remove())}__syncSlottedFormValues(e){this.__clearGeneratedFormValues(e),this.__getSlottedElements().forEach(t=>{if(!(t instanceof HTMLElement))return;let n=(t.getAttribute(`name`)??``).trim();if(n&&!(t.disabled===!0||t.hasAttribute(`disabled`))){if(t instanceof HTMLInputElement){if(t.form===e)return;let r=(t.type||``).toLowerCase();if(r===`checkbox`||r===`radio`){t.checked&&this.__appendHiddenFormValue(e,n,t.value||`on`);return}this.__appendHiddenFormValue(e,n,t.value??``);return}if(t instanceof HTMLTextAreaElement){if(t.form===e)return;this.__appendHiddenFormValue(e,n,t.value??``);return}if(t instanceof HTMLSelectElement){if(t.form===e)return;if(t.multiple){Array.from(t.selectedOptions).forEach(t=>{this.__appendHiddenFormValue(e,n,t.value)});return}this.__appendHiddenFormValue(e,n,t.value??``);return}switch(t.tagName){case`SCB-TEXTFIELD`:this.__appendHiddenFormValue(e,n,String(t.value??``));return;case`SCB-CHECKBOX`:t.checked&&this.__appendHiddenFormValue(e,n,String(t.value??t.getAttribute(`value`)??`on`));return;case`SCB-RADIO-BUTTON`:t.checked&&this.__appendHiddenFormValue(e,n,String(t.value??t.getAttribute(`value`)??`on`));return;case`SCB-SWITCH`:(t.selected||t.checked)&&this.__appendHiddenFormValue(e,n,String(t.value??t.getAttribute(`value`)??`on`));return;case`SCB-CHIP`:t.selected&&this.__appendHiddenFormValue(e,n,String(t.value??t.getAttribute(`value`)??`on`));return;default:`value`in t&&this.__appendHiddenFormValue(e,n,String(t.value??``))}}})}__validateFormAndSlottedFields(e){let t=e=>e.disabled===!0||e.hasAttribute(`disabled`),n=e.reportValidity(),r=null,i=new Set;return this.__getSlottedElements().forEach(e=>{if(!(e instanceof HTMLElement)||i.has(e)||t(e))return;i.add(e);let a=e;if(e.tagName===`SCB-TEXTFIELD`&&a.error===!0){r||=e,n=!1;return}if(typeof a.reportValidity==`function`){let t=!!a.reportValidity();!t&&!r&&(r=e),n&&=t}}),!n&&r&&r.focus(),n}__slotIsEmpty(){let e=this.shadowRoot?.querySelector(`slot`);return e?e.assignedElements({flatten:!0}).length===0:!0}renderHeader(e){let t=this.variant===`form`||this.variant===`floating`||this.variant===`iframe`;return b`
|
|
5624
5626
|
<div class="header">
|
|
5625
5627
|
<div class="title">
|
|
5626
5628
|
${this.icon?b`<md-icon class="dialog-icon">${this.icon}</md-icon>`:x}
|
|
@@ -5656,7 +5658,7 @@ var ScbWc=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module
|
|
|
5656
5658
|
</div>`}}renderBody(e,t){return this.variant===`form`?b`
|
|
5657
5659
|
${this.renderHeader(e)}
|
|
5658
5660
|
<div class="content" id=${t}>
|
|
5659
|
-
<form id=${this.formId} action=${this.formAction} method=${this.formMethod||x}>
|
|
5661
|
+
<form id=${this.formId} action=${this.formAction} method=${this.formMethod||x} @submit=${this.__onFormSubmit}>
|
|
5660
5662
|
<slot></slot>
|
|
5661
5663
|
</form>
|
|
5662
5664
|
</div>
|