scb-wc 0.1.76 → 0.1.77
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/README.md +22 -41
- package/all.js +2 -0
- package/icons.json +178 -178
- package/index.js +90 -88
- package/mvc/components/all.js +2 -0
- package/mvc/components/scb-accordion/scb-accordion-item.js +1 -1
- package/mvc/{vendor → components/scb-chevron}/scb-chevron.js +1 -1
- package/mvc/components/scb-datepicker/scb-datepicker.js +296 -0
- package/mvc/components/scb-dropdown/scb-dropdown.js +1 -1
- package/mvc/components/scb-header/scb-header.js +1 -1
- package/mvc/components/scb-menu/scb-menu-item.js +1 -1
- package/mvc/components/scb-select/scb-select.js +1 -1
- package/mvc/components/scb-textfield/scb-textfield.js +24 -319
- package/mvc/components/scb-toc/scb-toc-item.js +1 -1
- package/mvc/scb-logo.svg +20 -20
- package/mvc/scb.svg +13 -13
- package/package.json +2 -2
- package/scb-chevron/scb-chevron.js +1 -0
- package/scb-components/index.d.ts +99 -0
- package/scb-components/scb-chevron/scb-chevron.d.ts +11 -0
- package/scb-components/scb-datepicker/scb-datepicker.d.ts +39 -0
- package/scb-datepicker/scb-datepicker.js +1 -0
- package/scb-wc.bundle.js +216 -216
- package/scb-wc.d.ts +198 -194
- package/scb-wc-public-entry/index.d.ts +0 -97
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../../vendor/ripple.js","../../vendor/rolldown-runtime.js","../../vendor/vendor.js","../../vendor/attachable-controller.js","../../vendor/vendor-lit.js","../../vendor/md-focus-ring.js","../../vendor/icon.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as g,b as _,g as f,h as r,m as v,v as u,y as l}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as s}from"../../vendor/decorate.js";import"
|
|
2
|
+
import{_ as g,b as _,g as f,h as r,m as v,v as u,y as l}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as s}from"../../vendor/decorate.js";import"../scb-chevron/scb-chevron.js";import{t as h}from"../../vendor/preload-helper.js";(function(){try{var a=typeof globalThis<"u"?globalThis:window;if(!a.__scb_ce_guard_installed__){a.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,n,d){try{customElements.get(t)||e(t,n,d)}catch(p){var m=String(p||"");if(m.indexOf("already been used")===-1&&m.indexOf("NotSupportedError")===-1)throw p}}}}catch{}})();var c,o,b={fromAttribute:a=>a==null?!1:!/^(false|0|off|no)$/i.test(a),toAttribute:a=>a?"":null},i=(c=class extends g{constructor(...e){super(...e),this.label="",this.selected=!1,this.noHighlightSelected=!1,this.leadingIcon="",this.itemHref="",this.hasChildren=!1,this.loading=!1,this.hasSlotContent=!1,this.expanded=!1,this.__submenuId=`sub-${Math.random().toString(36).slice(2)}`,this.__focusId=`f-${Math.random().toString(36).slice(2)}`,this._toggleExpand=t=>{t&&t.stopPropagation(),this.__isExpandable&&this.__setExpanded(!this.expanded)},this._onButtonClick=t=>{t.stopPropagation(),this._dispatchSelect(),this._toggleExpand()},this._onLinkClick=()=>{this._dispatchSelect()},this._onKeyDown=t=>{const n=Array.from(this.closest("scb-sub-menu, scb-menu")?.querySelectorAll("scb-menu-item")||[]),d=n.indexOf(this);switch(t.key){case"ArrowDown":t.preventDefault(),(n[d+1]||n[0]).shadowRoot?.querySelector(".scb-menu-label-text")?.focus();break;case"ArrowUp":t.preventDefault(),(n[d-1]||n[n.length-1]).shadowRoot?.querySelector(".scb-menu-label-text")?.focus();break;case"Home":t.preventDefault(),n[0].shadowRoot?.querySelector(".scb-menu-label-text")?.focus();break;case"End":t.preventDefault(),n[n.length-1].shadowRoot?.querySelector(".scb-menu-label-text")?.focus();break}}}get __submenuEl(){return this.renderRoot.querySelector(`#${this.__submenuId}`)}get __isExpandable(){return this.hasSlotContent||this.hasChildren}async __ensureDepsLoaded(){o.__rippleLoaded||(await h(()=>import("../../vendor/ripple.js").then(e=>e.t),__vite__mapDeps([0,1,2,3,4]),import.meta.url),o.__rippleLoaded=!0),o.__focusRingLoaded||(await h(()=>import("../../vendor/md-focus-ring.js").then(e=>e.t),__vite__mapDeps([5,1,2,3,4]),import.meta.url),o.__focusRingLoaded=!0),this.leadingIcon&&!o.__iconLoaded&&(await h(()=>import("../../vendor/icon.js").then(e=>e.t),__vite__mapDeps([6,1,2,4]),import.meta.url),o.__iconLoaded=!0)}__syncHasSlotContentFromLightDom(){const e=Array.from(this.children);this.hasSlotContent=e.some(t=>t.tagName==="SCB-SUB-MENU")}connectedCallback(){super.connectedCallback(),this.__syncHasSlotContentFromLightDom()}_onSlotChange(e){const t=e.target.assignedElements({flatten:!0});this.hasSlotContent=t.some(n=>n.tagName==="SCB-SUB-MENU")}__setExpanded(e){if(!this.__isExpandable)return;this.expanded=e;const t={item:this,expanded:e,hasChildren:this.hasChildren,hasSlotContent:this.hasSlotContent,loading:this.loading,lazy:this.hasChildren&&!this.hasSlotContent};this.dispatchEvent(new CustomEvent("scb-menu-expand",{bubbles:!0,composed:!0,detail:t})),this.dispatchEvent(new CustomEvent("scbmenuexpand",{bubbles:!0,composed:!0,detail:t}))}_dispatchSelect(){this.dispatchEvent(new CustomEvent("scb-menu-select",{bubbles:!0,composed:!0,detail:{item:this}})),this.dispatchEvent(new CustomEvent("scbmenuselect",{bubbles:!0,composed:!0,detail:{item:this}}))}async firstUpdated(){await this.__ensureDepsLoaded(),this.__applyInert()}updated(e){e.has("leadingIcon")&&this.leadingIcon&&this.__ensureDepsLoaded(),(e.has("hasSlotContent")&&this.hasSlotContent||e.has("hasChildren")&&this.hasChildren||e.has("loading")&&this.loading)&&this.__ensureDepsLoaded(),(e.has("expanded")||e.has("hasChildren")||e.has("loading"))&&this.__applyInert()}__applyInert(){const e=this.__submenuEl;e&&(this.loading?e.setAttribute("aria-busy","true"):e.removeAttribute("aria-busy"),this.expanded?(e.removeAttribute("inert"),e.setAttribute("aria-hidden","false")):(e.setAttribute("inert",""),e.setAttribute("aria-hidden","true")))}render(){const e=!!this.leadingIcon,t=!!this.itemHref,n=this.__isExpandable;return l`
|
|
3
3
|
<div class="scb-menu-item">
|
|
4
4
|
<div class="scb-menu-item-label" ?selected=${this.selected} ?no-highlight-selected=${this.noHighlightSelected}>
|
|
5
5
|
${t?l`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as h,b as u,g as b,h as a,s as g,y as d}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/md-focus-ring.js";import{t as l}from"../../vendor/decorate.js";import"
|
|
1
|
+
import{_ as h,b as u,g as b,h as a,s as g,y as d}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/md-focus-ring.js";import{t as l}from"../../vendor/decorate.js";import"../scb-chevron/scb-chevron.js";import"./scb-select-option.js";(function(){try{var p=typeof globalThis<"u"?globalThis:window;if(!p.__scb_ce_guard_installed__){p.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,s,r){try{customElements.get(t)||e(t,s,r)}catch(o){var n=String(o||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw o}}}}catch{}})();var c,i=(c=class extends h{constructor(){super(),this._optionsObserver=null,this._internals=null,this.focusedIndex=-1,this.variant="single-select",this.value="",this.values=[],this.disabled=!1,this.required=!1,this.open=!1,this.label="",this.name="",this.placeholder="",this.supportingText="",this.withRadiobuttons=!1,this.noHighlightSelected=!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.zIndex=void 0,this._form=null,this._formResetHandler=null,this._formSubmitHandler=null,this._initialValue="",this._initialValues=[],this._customValidationMessage="",this._onDocumentClick=e=>{this.open&&(e.composedPath().includes(this)||this._setOpen(!1))},this._onSlotClick=e=>{const t=this.shadowRoot?.querySelector("slot");if(!t)return;const s=t.assignedElements({flatten:!0}).filter(o=>o.tagName.toLowerCase()==="scb-select-option"),r=e.composedPath(),n=s.find(o=>r.includes(o));n&&(this._selectOption(n),e.stopPropagation())},this._onKeyDown=e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this._toggleOpen())},this._onOptionKeyDown=e=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();const t=this.shadowRoot?.querySelector("slot");if(!t)return;const s=t.assignedElements({flatten:!0}).filter(o=>o.tagName.toLowerCase()==="scb-select-option"),r=e.composedPath(),n=s.find(o=>r.includes(o));n&&this._selectOption(n)}},"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")}connectedCallback(){super.connectedCallback(),document.addEventListener("mousedown",this._onDocumentClick),this._optionsObserver=new MutationObserver(()=>{this.requestUpdate()}),this._optionsObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["label","value","disabled"]}),this._syncDensityForSize(),this._initialValue=this.value,this._initialValues=Array.isArray(this.values)?[...this.values]:[],this._form=this.closest("form"),this._form&&(this._formResetHandler=()=>{this.value=this._initialValue,this.values=Array.isArray(this._initialValues)?[...this._initialValues]:[],this._syncFormValue(),this._syncValidity(),this.requestUpdate()},this._formSubmitHandler=e=>{this.reportValidity()||(e.preventDefault(),e.stopPropagation())},this._form.addEventListener("reset",this._formResetHandler,!0),this._form.addEventListener("submit",this._formSubmitHandler,!0))}disconnectedCallback(){document.removeEventListener("mousedown",this._onDocumentClick),this._form&&this._formResetHandler&&this._form.removeEventListener("reset",this._formResetHandler,!0),this._form&&this._formSubmitHandler&&this._form.removeEventListener("submit",this._formSubmitHandler,!0),this._optionsObserver?.disconnect(),this._optionsObserver=null,super.disconnectedCallback()}_getMultiValues(){return Array.isArray(this.values)&&this.values.length>0?this.values:this.value?this.value.split(",").map(e=>e.trim()).filter(Boolean):[]}_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,s=this._mapSpacingToken(this.spacingBottom)??e,r=this._mapSpacingToken(this.spacingLeft),n=this._mapSpacingToken(this.spacingRight);t?this.style.setProperty("--scb-select-spacing-block-start",t):this.style.removeProperty("--scb-select-spacing-block-start"),s?this.style.setProperty("--scb-select-spacing-block-end",s):this.style.removeProperty("--scb-select-spacing-block-end"),r?this.style.setProperty("--scb-select-spacing-inline-start",r):this.style.removeProperty("--scb-select-spacing-inline-start"),n?this.style.setProperty("--scb-select-spacing-inline-end",n):this.style.removeProperty("--scb-select-spacing-inline-end")}_setOpen(e){this.open!==e&&(this.open=e,e?(this.focusedIndex=0,this.requestUpdate()):this.focusedIndex=-1)}_toggleOpen(){this.disabled||this._setOpen(!this.open)}_hasMoreThanFourOptions(){const e=this.shadowRoot?.querySelector("slot");if(!e)return!1;const t=e.assignedElements({flatten:!0}).filter(s=>s.tagName.toLowerCase()==="scb-select-option");return["extra-small","small","medium"].includes(this.size)?t.length>5:t.length>4}_selectOption(e){if(!e.disabled){if(this.variant==="multi-select"){const t=this._getMultiValues();t.indexOf(e.value)>-1?this.values=t.filter(s=>s!==e.value):this.values=[...t,e.value],this.value=this.values.join(","),this.dispatchEvent(new CustomEvent("change",{detail:{values:this.values},bubbles:!0,composed:!0}))}else this.variant==="single-select"&&this.withRadiobuttons?(this.value=e.value,this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0}))):(this.value=e.value,this._setOpen(!1),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0})));this._updateOptionsChecked(),this.requestUpdate()}}_getOptionLabel(e){return e.label||e.textContent?.trim()||""}_getSelectedLabel(){const e=this.shadowRoot?.querySelector("slot");if(!e)return"";const t=e.assignedElements({flatten:!0}).filter(s=>s.tagName.toLowerCase()==="scb-select-option");if(this.variant==="multi-select"){const s=this._getMultiValues(),r=t.filter(n=>s.includes(n.value));return r&&r.length>0?r.map(n=>this._getOptionLabel(n)).join(", "):""}else{const s=t.find(r=>r.value===this.value);return s?this._getOptionLabel(s):""}}firstUpdated(){this._updateOptionsChecked(),this._syncFormValue(),this._syncValidity(),this._applySpacing()}updated(e){this._updateOptionsChecked(),this._syncFormValue(),this._syncValidity(),e.has("size")&&this._syncDensityForSize(),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom")||e.has("spacingLeft")||e.has("spacingRight"))&&this._applySpacing()}_syncFormValue(){if(this._internals){if(this.disabled||!this.name){this._internals.setFormValue(null);return}if(this.variant==="multi-select"){const e=this._getMultiValues();if(e.length===0){this._internals.setFormValue(null);return}const t=new FormData;e.forEach(s=>t.append(this.name,s)),this._internals.setFormValue(t);return}this._internals.setFormValue(this.value||null)}}_getValidationMessage(){return this._customValidationMessage?this._customValidationMessage:this.required&&!(this.variant==="multi-select"?this._getMultiValues().length>0:this.value)?"Välj ett alternativ.":""}_syncValidity(){if(!this._internals)return;const e=this.disabled?"":this._getValidationMessage(),t=this.shadowRoot?.querySelector(".selected-value");if(!e){this._internals.setValidity({}),this.removeAttribute("aria-invalid"),t&&t.setCustomValidity("");return}t&&t.setCustomValidity(e),this._internals.setValidity({valueMissing:!0},e,t??void 0),this.setAttribute("aria-invalid","true")}checkValidity(){return!this._getValidationMessage()}reportValidity(){return this._syncValidity(),this._internals?this._internals.reportValidity():this.checkValidity()}setCustomValidity(e){this._customValidationMessage=e,this._syncValidity()}get validity(){return this._internals?.validity}get validationMessage(){return this._internals?.validationMessage??this._getValidationMessage()}get willValidate(){return this._internals?.willValidate??!0}_updateOptionsChecked(){const e=this.shadowRoot?.querySelector("slot");e&&e.assignedElements({flatten:!0}).filter(t=>t.tagName.toLowerCase()==="scb-select-option").forEach(t=>{if(this.noHighlightSelected?t.setAttribute("no-highlight-selected",""):t.removeAttribute("no-highlight-selected"),this.variant==="multi-select"){const s=this._getMultiValues();t.showCheckbox=!0,t.checked=s.includes(t.value),t.showRadio=!1}else t.showCheckbox=!1,t.checked=this.value===t.value,this.withRadiobuttons&&(t.showRadio=!0)})}render(){return d`
|
|
2
2
|
${this.label?d`
|
|
3
3
|
<label
|
|
4
4
|
class="select-label ${this.supportingText?"":"select-label--without-supporting"}"
|
|
@@ -1,299 +1,4 @@
|
|
|
1
|
-
import{_
|
|
2
|
-
<div class="datepicker-popup popup">
|
|
3
|
-
<div class="header">
|
|
4
|
-
<div class="month-selector ${this._showMonthDropdown?"open":""} ${this._showYearDropdown?"disable":""}">
|
|
5
|
-
<scb-icon-button icon="chevron_left" @click=${this._prevMonth} aria-label=${this.lang=="sv"?"Föregående månad":"Previous month"}></scb-icon-button>
|
|
6
|
-
<div class="custom-dropdown month-dropdown">
|
|
7
|
-
<div
|
|
8
|
-
tabindex=${this._showYearDropdown?-1:0}
|
|
9
|
-
class="dropdown-selected"
|
|
10
|
-
@click=${()=>this._toggleMonthDropdown()}
|
|
11
|
-
@keydown=${n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),this._toggleMonthDropdown())}}
|
|
12
|
-
>
|
|
13
|
-
${this._monthNames[t].slice(0,3)}
|
|
14
|
-
<md-icon>arrow_drop_down</md-icon>
|
|
15
|
-
<md-focus-ring></md-focus-ring>
|
|
16
|
-
<md-ripple></md-ripple>
|
|
17
|
-
</div>
|
|
18
|
-
</div>
|
|
19
|
-
<scb-icon-button icon="chevron_right" @click=${this._nextMonth} aria-label=${this.lang=="sv"?"Nästa månad":"Next month"}></scb-icon-button>
|
|
20
|
-
</div>
|
|
21
|
-
<div class="year-selector ${this._showMonthDropdown?"disable":""} ${this._showYearDropdown?"open":""}">
|
|
22
|
-
<scb-icon-button icon="chevron_left" @click=${this._prevYear} aria-label=${this.lang=="sv"?"Föregående år":"Previous year"}></scb-icon-button>
|
|
23
|
-
<div class="custom-dropdown year-dropdown">
|
|
24
|
-
<div
|
|
25
|
-
tabindex=${this._showMonthDropdown?-1:0}
|
|
26
|
-
class="dropdown-selected"
|
|
27
|
-
@click=${()=>this._toggleYearDropdown()}
|
|
28
|
-
@keydown=${n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),this._toggleYearDropdown())}}
|
|
29
|
-
>
|
|
30
|
-
${e}
|
|
31
|
-
<md-icon>arrow_drop_down</md-icon>
|
|
32
|
-
<md-focus-ring></md-focus-ring>
|
|
33
|
-
<md-ripple></md-ripple>
|
|
34
|
-
</div>
|
|
35
|
-
</div>
|
|
36
|
-
<scb-icon-button icon="chevron_right" @click=${this._nextYear} aria-label=${this.lang=="sv"?"Nästa år":"Next year"}></scb-icon-button>
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
${this._showMonthDropdown||this._showYearDropdown?a`<scb-divider></scb-divider>`:""}
|
|
40
|
-
<div class="datepicker-content" style="position:relative;">
|
|
41
|
-
${this._showMonthDropdown?a`
|
|
42
|
-
<div class="dropdown-list">
|
|
43
|
-
${this._monthNames.map((n,d)=>a`
|
|
44
|
-
<div
|
|
45
|
-
@keydown=${f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),this._onMonthChangeCustom(d))}}
|
|
46
|
-
tabindex="0"
|
|
47
|
-
class="dropdown-item${d===t?" selected":""}"
|
|
48
|
-
@click=${()=>this._onMonthChangeCustom(d)}
|
|
49
|
-
id=${d===t?"selected-month":""}
|
|
50
|
-
>
|
|
51
|
-
${d===t?a`<md-icon>check</md-icon>`:""}
|
|
52
|
-
${n}
|
|
53
|
-
<md-ripple></md-ripple><md-focus-ring inward></md-focus-ring>
|
|
54
|
-
</div>
|
|
55
|
-
`)}
|
|
56
|
-
</div>
|
|
57
|
-
`:""}
|
|
58
|
-
${this._showYearDropdown?a`
|
|
59
|
-
<div class="dropdown-list">
|
|
60
|
-
${u.map(n=>a`
|
|
61
|
-
<div
|
|
62
|
-
@keydown=${d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),this._onYearChangeCustom(n))}}
|
|
63
|
-
tabindex="0"
|
|
64
|
-
class="dropdown-item${n===e?" selected":""}"
|
|
65
|
-
@click=${()=>this._onYearChangeCustom(n)}
|
|
66
|
-
id=${n===e?"selected-year":""}
|
|
67
|
-
>
|
|
68
|
-
${n===e?a`<md-icon>check</md-icon>`:""}
|
|
69
|
-
${n}
|
|
70
|
-
<md-ripple></md-ripple><md-focus-ring inward></md-focus-ring>
|
|
71
|
-
</div>
|
|
72
|
-
`)}
|
|
73
|
-
</div>
|
|
74
|
-
`:""}
|
|
75
|
-
${!this._showMonthDropdown&&!this._showYearDropdown?a`
|
|
76
|
-
<div class="datepicker-calendar">
|
|
77
|
-
<table>
|
|
78
|
-
<thead>
|
|
79
|
-
<tr>
|
|
80
|
-
<th>${this.lang=="sv"?"Må":"Mo"}</th><th>${this.lang=="sv"?"Ti":"Tu"}</th><th>${this.lang=="sv"?"On":"We"}</th><th>${this.lang=="sv"?"To":"Th"}</th><th>${this.lang=="sv","Fr"}</th><th>${this.lang=="sv"?"Lö":"Sa"}</th><th>${this.lang=="sv"?"Sö":"Su"}</th>
|
|
81
|
-
</tr>
|
|
82
|
-
</thead>
|
|
83
|
-
<tbody>
|
|
84
|
-
${o.map(n=>a`
|
|
85
|
-
<tr>
|
|
86
|
-
${n.map(d=>d?a`
|
|
87
|
-
<td>
|
|
88
|
-
<div
|
|
89
|
-
@keydown=${f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),this._selectDate(d))}}
|
|
90
|
-
role="button"
|
|
91
|
-
tabindex="0"
|
|
92
|
-
class="day${this._isToday(d,i)?" today":""}${this._isSelected(d)?" selected":""}"
|
|
93
|
-
@click=${()=>this._selectDate(d)}
|
|
94
|
-
>${d.getDate()}<md-ripple></md-ripple><md-focus-ring></md-focus-ring></div>
|
|
95
|
-
</td>
|
|
96
|
-
`:a`<td></td>`)}
|
|
97
|
-
</tr>
|
|
98
|
-
`)}
|
|
99
|
-
</tbody>
|
|
100
|
-
</table>
|
|
101
|
-
</div>
|
|
102
|
-
`:""}
|
|
103
|
-
</div>
|
|
104
|
-
${l?a`
|
|
105
|
-
<div style="padding: 0 24px;">
|
|
106
|
-
<label style="display:flex;align-items:center;gap:8px;">
|
|
107
|
-
<span>${this.lang=="sv"?"Tid:":"Time:"}</span>
|
|
108
|
-
<scb-textfield type="time" .value=${`${String(this._selectedHour).padStart(2,"0")}:${String(this._selectedMinute).padStart(2,"0")}`} @blur=${this._onTimeChange} aria-label="${this.lang=="sv"?"Tid":"Time"}"></scb-textfield>
|
|
109
|
-
</label>
|
|
110
|
-
</div>
|
|
111
|
-
`:""}
|
|
112
|
-
<div class="datepicker-footer">
|
|
113
|
-
${!this._showMonthDropdown&&!this._showYearDropdown?a`
|
|
114
|
-
<scb-button variant="text" label=${this.lang=="sv"?"Stäng":"Close"} @click=${this._close}></scb-button>
|
|
115
|
-
`:""}
|
|
116
|
-
</div>
|
|
117
|
-
</div>
|
|
118
|
-
`}_getMonthDays(e,t){const i=new Date(Date.UTC(e,t,1)),o=new Date(Date.UTC(e,t+1,0)),u=[];let l=[],n=i.getUTCDay(),d=n===0?6:n-1;for(let f=0;f<d;f++)l.push(null);for(let f=1;f<=o.getUTCDate();f++){const x=new Date(Date.UTC(e,t,f));l.push(x),l.length===7&&(u.push(l),l=[])}if(l.length){for(;l.length<7;)l.push(null);u.push(l)}return u}_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=u=>u.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}))}}},k.styles=[S`
|
|
119
|
-
:host {
|
|
120
|
-
--scb-datepicker-width: 380px;
|
|
121
|
-
--scb-datepicker-z-index: 1100;
|
|
122
|
-
--scb-datepicker-viewport-margin: 8px;
|
|
123
|
-
--scb-datepicker-offset: var(--spacing-2, 4px);
|
|
124
|
-
max-width: var(--scb-datepicker-computed-width, min(var(--scb-datepicker-width), calc(100vw - (var(--scb-datepicker-viewport-margin) * 2))));
|
|
125
|
-
font-family: var(--brand-font);
|
|
126
|
-
color: var(--md-sys-color-on-surface);
|
|
127
|
-
display: block;
|
|
128
|
-
position: var(--scb-datepicker-position, absolute);
|
|
129
|
-
top: var(--scb-datepicker-top, calc(100% + var(--scb-datepicker-offset)));
|
|
130
|
-
bottom: var(--scb-datepicker-bottom, auto);
|
|
131
|
-
left: var(--scb-datepicker-left, 0);
|
|
132
|
-
width: var(--scb-datepicker-computed-width, min(var(--scb-datepicker-width), calc(100vw - (var(--scb-datepicker-viewport-margin) * 2))));
|
|
133
|
-
transform: var(--scb-datepicker-transform, translateX(0px));
|
|
134
|
-
z-index: var(--scb-datepicker-z-index);
|
|
135
|
-
}
|
|
136
|
-
.month-selector, .year-selector {
|
|
137
|
-
display: flex;
|
|
138
|
-
align-items: center;
|
|
139
|
-
&.disable{
|
|
140
|
-
pointer-events: none;
|
|
141
|
-
opacity: 0.3;
|
|
142
|
-
scb-icon-button{
|
|
143
|
-
visibility: hidden;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
&.open{
|
|
147
|
-
scb-icon-button{
|
|
148
|
-
visibility: hidden;
|
|
149
|
-
}
|
|
150
|
-
.dropdown-selected{
|
|
151
|
-
background: var(--md-sys-color-secondary-container);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
.dropdown-selected {
|
|
156
|
-
position: relative;
|
|
157
|
-
border-radius: 8px;
|
|
158
|
-
font-size: 16px;
|
|
159
|
-
cursor: pointer;
|
|
160
|
-
text-align: left;
|
|
161
|
-
display: flex;
|
|
162
|
-
gap: 8px;
|
|
163
|
-
align-items: center;
|
|
164
|
-
padding: 4px 8px;
|
|
165
|
-
}
|
|
166
|
-
.dropdown-selected:focus {
|
|
167
|
-
outline: none;
|
|
168
|
-
}
|
|
169
|
-
.dropdown-selected md-focus-ring {
|
|
170
|
-
border-radius: 8px;
|
|
171
|
-
}
|
|
172
|
-
.dropdown-list {
|
|
173
|
-
position: relative;
|
|
174
|
-
background: var(--md-sys-color-surface);
|
|
175
|
-
padding: 4px 0;
|
|
176
|
-
}
|
|
177
|
-
.dropdown-item {
|
|
178
|
-
display: flex;
|
|
179
|
-
position: relative;
|
|
180
|
-
cursor: pointer;
|
|
181
|
-
padding: var(--spacing-3) 56px;
|
|
182
|
-
min-height: 40px;
|
|
183
|
-
align-items: center;
|
|
184
|
-
}
|
|
185
|
-
.dropdown-item:focus-within {
|
|
186
|
-
outline: none;
|
|
187
|
-
}
|
|
188
|
-
.dropdown-item md-focus-ring {
|
|
189
|
-
border-radius: var(--md-sys-shape-corner-small);
|
|
190
|
-
}
|
|
191
|
-
.dropdown-item.selected {
|
|
192
|
-
background: var(--md-sys-color-secondary-container, #e3f2fd);
|
|
193
|
-
font-weight: 500;
|
|
194
|
-
padding-left: 16px;
|
|
195
|
-
gap: 16px;
|
|
196
|
-
}
|
|
197
|
-
.datepicker-popup {
|
|
198
|
-
background: var(--md-sys-color-surface);
|
|
199
|
-
border-radius: var(--md-sys-shape-corner-small);
|
|
200
|
-
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.30), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
|
|
201
|
-
max-width: 100%;
|
|
202
|
-
width: 100%;
|
|
203
|
-
max-height: var(--scb-datepicker-max-height, 80vh);
|
|
204
|
-
overflow: auto;
|
|
205
|
-
font-family: var(--brand-font);
|
|
206
|
-
}
|
|
207
|
-
.datepicker-content{
|
|
208
|
-
overflow-y: auto;
|
|
209
|
-
max-height: 290px;
|
|
210
|
-
}
|
|
211
|
-
.datepicker-content::-webkit-scrollbar {
|
|
212
|
-
width: 12px;
|
|
213
|
-
background: var(--md-sys-color-surface);
|
|
214
|
-
border-radius: var(--md-sys-shape-corner-small);
|
|
215
|
-
}
|
|
216
|
-
.datepicker-content::-webkit-scrollbar-thumb {
|
|
217
|
-
background: var(--md-sys-color-outline);
|
|
218
|
-
border-radius: var(--md-sys-shape-corner-small);
|
|
219
|
-
border: 4px solid var(--md-sys-color-surface);
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
.datepicker-content::-webkit-scrollbar-track {
|
|
223
|
-
background: var(--md-sys-color-surface);
|
|
224
|
-
border-radius: var(--md-sys-shape-corner-small);
|
|
225
|
-
}
|
|
226
|
-
.popup {
|
|
227
|
-
position:absolute;
|
|
228
|
-
top:0;
|
|
229
|
-
left:0;
|
|
230
|
-
z-index:1;
|
|
231
|
-
}
|
|
232
|
-
.header {
|
|
233
|
-
display: flex;
|
|
234
|
-
align-items: center;
|
|
235
|
-
justify-content: space-between;
|
|
236
|
-
margin-bottom: 30px;
|
|
237
|
-
padding: 20px 16px 0px 16px;
|
|
238
|
-
flex-wrap: wrap;
|
|
239
|
-
}
|
|
240
|
-
.datepicker-footer{
|
|
241
|
-
padding: 8px 16px 24px 16px;
|
|
242
|
-
}
|
|
243
|
-
.month-label {
|
|
244
|
-
font-size: 18px;
|
|
245
|
-
font-weight: 500;
|
|
246
|
-
}
|
|
247
|
-
.datepicker-calendar{
|
|
248
|
-
padding: 0 16px;
|
|
249
|
-
}
|
|
250
|
-
table {
|
|
251
|
-
width: 100%;
|
|
252
|
-
border-collapse: collapse;
|
|
253
|
-
margin-bottom: 8px;
|
|
254
|
-
}
|
|
255
|
-
th {
|
|
256
|
-
color: var(--md-sys-color-on-surface-variant, #757575);
|
|
257
|
-
font-size: 16px;
|
|
258
|
-
font-weight: 600;
|
|
259
|
-
padding-bottom: 20px;
|
|
260
|
-
}
|
|
261
|
-
td {
|
|
262
|
-
text-align: center;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
.day:focus-within{
|
|
266
|
-
outline: none;
|
|
267
|
-
}
|
|
268
|
-
.day {
|
|
269
|
-
position: relative;
|
|
270
|
-
width: 40px;
|
|
271
|
-
height: 40px;
|
|
272
|
-
border-radius: 50%;
|
|
273
|
-
border: none;
|
|
274
|
-
background: none;
|
|
275
|
-
font-size: 16px;
|
|
276
|
-
cursor: pointer;
|
|
277
|
-
font-family: 'Inter';
|
|
278
|
-
align-content: center;
|
|
279
|
-
}
|
|
280
|
-
.day.selected {
|
|
281
|
-
background: var(--md-sys-color-secondary-container);
|
|
282
|
-
}
|
|
283
|
-
.close-datepicker {
|
|
284
|
-
margin-top: 8px;
|
|
285
|
-
background: none;
|
|
286
|
-
border-color: none;
|
|
287
|
-
color: var(--md-sys-color-primary, #0057b8);
|
|
288
|
-
font-size: 16px;
|
|
289
|
-
cursor: pointer;
|
|
290
|
-
padding: 4px 12px;
|
|
291
|
-
border-radius: 8px;
|
|
292
|
-
}
|
|
293
|
-
.close-datepicker:hover {
|
|
294
|
-
background: var(--md-sys-color-primary-container, #e3f2fd);
|
|
295
|
-
}
|
|
296
|
-
`],k);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([p({type:String})],g.prototype,"variant",void 0);r([p({type:String})],g.prototype,"lang",void 0);r([p({type:String})],g.prototype,"selectedValue",void 0);r([p({type:Boolean})],g.prototype,"open",void 0);r([m()],g.prototype,"_selectedHour",void 0);r([m()],g.prototype,"_selectedMinute",void 0);g=r([E("scb-datepicker")],g);var c,y,h=(c=new WeakSet,y=class extends M{constructor(){super(),Y(this,c),this._internals=null,this._inputFocused=!1,this._kbShouldShowRing=!1,this._onGlobalKeydown=e=>{e.key==="Tab"&&(this._kbShouldShowRing=!0,this._inputFocused&&b(c,this,_).call(this))},this._onGlobalPointerDown=()=>{this._kbShouldShowRing=!1,this._inputFocused&&b(c,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)}b(c,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,b(c,this,_).call(this)},this._onFieldBlur=()=>{this._inputFocused=!1,b(c,this,_).call(this)},this.type="text",this.label="",this.supportingText="",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){const t=this.disabled?null:this.value;this._internals.setFormValue(t)}b(c,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")}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.type==="search"&&this.value?a`
|
|
1
|
+
import{_,b as w,g as $,h as d,m as k,y as o}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/md-focus-ring.js";import"../../vendor/icon.js";import"../../vendor/ripple.js";import{t as r}from"../../vendor/decorate.js";import{n as z,t as a}from"../../vendor/assertClassBrand.js";import"../scb-icon-button/scb-icon-button.js";import"../scb-datepicker/scb-datepicker.js";(function(){try{var t=typeof globalThis<"u"?globalThis:window;if(!t.__scb_ce_guard_installed__){t.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(i,n,c){try{customElements.get(i)||e(i,n,c)}catch(b){var p=String(b||"");if(p.indexOf("already been used")===-1&&p.indexOf("NotSupportedError")===-1)throw b}}}}catch{}})();var s,u,l=(s=new WeakSet,u=class extends _{constructor(){super(),z(this,s),this._internals=null,this._inputFocused=!1,this._kbShouldShowRing=!1,this._onGlobalKeydown=e=>{e.key==="Tab"&&(this._kbShouldShowRing=!0,this._inputFocused&&a(s,this,g).call(this))},this._onGlobalPointerDown=()=>{this._kbShouldShowRing=!1,this._inputFocused&&a(s,this,g).call(this)},this._hasRenderedOnce=!1,this._boundField=null,this._onFieldInput=()=>{const e=this._boundField;if(!e)return;const i=e;if(this.value=i.value,this._internals){const n=this.disabled?null:this.value;this._internals.setFormValue(n)}a(s,this,f).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,a(s,this,g).call(this)},this._onFieldBlur=()=>{this._inputFocused=!1,a(s,this,g).call(this)},this.type="text",this.label="",this.supportingText="",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){const i=this.disabled?null:this.value;this._internals.setFormValue(i)}a(s,this,f).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")}render(){const e=this.leadingIcon?o`<md-icon class="scb-textfield-icon">${this.leadingIcon}</md-icon>`:null,i=this.error?o`<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 n=this.underLabel?`${this._inputId}-supporting-text`:void 0,c=this.type==="search"&&this.value?o`
|
|
297
2
|
<button
|
|
298
3
|
type="button"
|
|
299
4
|
class="scb-textfield-clear"
|
|
@@ -327,14 +32,14 @@ import{_ as M,b as S,g as E,h as p,m,y as a}from"../../vendor/vendor.js";import"
|
|
|
327
32
|
></line>
|
|
328
33
|
</svg>
|
|
329
34
|
</button>
|
|
330
|
-
`:null;return this.type==="textarea"?
|
|
35
|
+
`:null;return this.type==="textarea"?o`
|
|
331
36
|
<label
|
|
332
37
|
class="scb-textfield-label ${this.underLabel?"":"scb-textfield-label--without-supporting"}"
|
|
333
38
|
for="${this._inputId}"
|
|
334
39
|
>
|
|
335
40
|
${this.label}
|
|
336
41
|
</label>
|
|
337
|
-
${this.underLabel?
|
|
42
|
+
${this.underLabel?o`
|
|
338
43
|
<span class="scb-textfield-supporting-text" id="${this._inputId}-supporting-text">
|
|
339
44
|
${this.underLabel}
|
|
340
45
|
</span>
|
|
@@ -349,20 +54,20 @@ import{_ as M,b as S,g as E,h as p,m,y as a}from"../../vendor/vendor.js";import"
|
|
|
349
54
|
id="${this._inputId}"
|
|
350
55
|
?required=${this.required}
|
|
351
56
|
aria-invalid=${this.error?"true":"false"}
|
|
352
|
-
aria-describedby=${
|
|
57
|
+
aria-describedby=${n}
|
|
353
58
|
></textarea>
|
|
354
59
|
<md-ripple></md-ripple>
|
|
355
60
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
356
61
|
</div>
|
|
357
62
|
</div>
|
|
358
|
-
`:this.type==="date"?
|
|
63
|
+
`:this.type==="date"?o`
|
|
359
64
|
<label
|
|
360
65
|
class="scb-textfield-label ${this.underLabel?"":"scb-textfield-label--without-supporting"}"
|
|
361
66
|
for="${this._inputId}"
|
|
362
67
|
>
|
|
363
68
|
${this.label}
|
|
364
69
|
</label>
|
|
365
|
-
${this.underLabel?
|
|
70
|
+
${this.underLabel?o`
|
|
366
71
|
<span class="scb-textfield-supporting-text" id="${this._inputId}-supporting-text">
|
|
367
72
|
${this.underLabel}
|
|
368
73
|
</span>
|
|
@@ -379,7 +84,7 @@ import{_ as M,b as S,g as E,h as p,m,y as a}from"../../vendor/vendor.js";import"
|
|
|
379
84
|
?disabled=${this.disabled}
|
|
380
85
|
?required=${this.required}
|
|
381
86
|
aria-invalid=${this.error?"true":"false"}
|
|
382
|
-
aria-describedby=${
|
|
87
|
+
aria-describedby=${n}
|
|
383
88
|
readonly
|
|
384
89
|
@focus=${this._toggleDatepicker}
|
|
385
90
|
@click=${this._toggleDatepicker}
|
|
@@ -387,7 +92,7 @@ import{_ as M,b as S,g as E,h as p,m,y as a}from"../../vendor/vendor.js";import"
|
|
|
387
92
|
<md-ripple></md-ripple>
|
|
388
93
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
389
94
|
</div>
|
|
390
|
-
${this.error?
|
|
95
|
+
${this.error?i:o`
|
|
391
96
|
<scb-icon-button
|
|
392
97
|
class="scb-textfield-datepicker-button"
|
|
393
98
|
icon="calendar_today"
|
|
@@ -402,14 +107,14 @@ import{_ as M,b as S,g as E,h as p,m,y as a}from"../../vendor/vendor.js";import"
|
|
|
402
107
|
@date-selected=${this._onDateSelected}
|
|
403
108
|
></scb-datepicker>
|
|
404
109
|
</div>
|
|
405
|
-
`:this.type==="datetime-local"?
|
|
110
|
+
`:this.type==="datetime-local"?o`
|
|
406
111
|
<label
|
|
407
112
|
class="scb-textfield-label ${this.underLabel?"":"scb-textfield-label--without-supporting"}"
|
|
408
113
|
for="${this._inputId}"
|
|
409
114
|
>
|
|
410
115
|
${this.label}
|
|
411
116
|
</label>
|
|
412
|
-
${this.underLabel?
|
|
117
|
+
${this.underLabel?o`
|
|
413
118
|
<span class="scb-textfield-supporting-text" id="${this._inputId}-supporting-text">
|
|
414
119
|
${this.underLabel}
|
|
415
120
|
</span>
|
|
@@ -426,7 +131,7 @@ import{_ as M,b as S,g as E,h as p,m,y as a}from"../../vendor/vendor.js";import"
|
|
|
426
131
|
?disabled=${this.disabled}
|
|
427
132
|
?required=${this.required}
|
|
428
133
|
aria-invalid=${this.error?"true":"false"}
|
|
429
|
-
aria-describedby=${
|
|
134
|
+
aria-describedby=${n}
|
|
430
135
|
readonly
|
|
431
136
|
@focus=${this._toggleDatepicker}
|
|
432
137
|
@click=${this._toggleDatepicker}
|
|
@@ -436,7 +141,7 @@ import{_ as M,b as S,g as E,h as p,m,y as a}from"../../vendor/vendor.js";import"
|
|
|
436
141
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
437
142
|
</div>
|
|
438
143
|
|
|
439
|
-
${this.error?
|
|
144
|
+
${this.error?i:o`
|
|
440
145
|
<scb-icon-button
|
|
441
146
|
class="scb-textfield-datepicker-button"
|
|
442
147
|
icon="calendar_today"
|
|
@@ -452,14 +157,14 @@ import{_ as M,b as S,g as E,h as p,m,y as a}from"../../vendor/vendor.js";import"
|
|
|
452
157
|
@date-selected=${this._onDateSelected}
|
|
453
158
|
></scb-datepicker>
|
|
454
159
|
</div>
|
|
455
|
-
`:this.type==="time"?
|
|
160
|
+
`:this.type==="time"?o`
|
|
456
161
|
<label
|
|
457
162
|
class="scb-textfield-label ${this.underLabel?"":"scb-textfield-label--without-supporting"}"
|
|
458
163
|
for="${this._inputId}"
|
|
459
164
|
>
|
|
460
165
|
${this.label}
|
|
461
166
|
</label>
|
|
462
|
-
${this.underLabel?
|
|
167
|
+
${this.underLabel?o`
|
|
463
168
|
<span class="scb-textfield-supporting-text" id="${this._inputId}-supporting-text">
|
|
464
169
|
${this.underLabel}
|
|
465
170
|
</span>
|
|
@@ -476,22 +181,22 @@ import{_ as M,b as S,g as E,h as p,m,y as a}from"../../vendor/vendor.js";import"
|
|
|
476
181
|
?disabled=${this.disabled}
|
|
477
182
|
?required=${this.required}
|
|
478
183
|
aria-invalid=${this.error?"true":"false"}
|
|
479
|
-
aria-describedby=${
|
|
480
|
-
@input=${
|
|
184
|
+
aria-describedby=${n}
|
|
185
|
+
@input=${p=>{const b=p.target;if(this.value=b.value,this._internals){const y=this.disabled?null:this.value;this._internals.setFormValue(y)}a(s,this,f).call(this),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("onValueChanged",{detail:{value:this.value},bubbles:!0,composed:!0}))}}
|
|
481
186
|
/>
|
|
482
|
-
${
|
|
187
|
+
${i}
|
|
483
188
|
<md-ripple></md-ripple>
|
|
484
189
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
485
190
|
</div>
|
|
486
191
|
</div>
|
|
487
|
-
`:
|
|
192
|
+
`:o`
|
|
488
193
|
<label
|
|
489
194
|
class="scb-textfield-label ${this.underLabel?"":"scb-textfield-label--without-supporting"}"
|
|
490
195
|
for="${this._inputId}"
|
|
491
196
|
>
|
|
492
197
|
${this.label}
|
|
493
198
|
</label>
|
|
494
|
-
${this.underLabel?
|
|
199
|
+
${this.underLabel?o`
|
|
495
200
|
<span class="scb-textfield-supporting-text" id="${this._inputId}-supporting-text">
|
|
496
201
|
${this.underLabel}
|
|
497
202
|
</span>
|
|
@@ -508,15 +213,15 @@ import{_ as M,b as S,g as E,h as p,m,y as a}from"../../vendor/vendor.js";import"
|
|
|
508
213
|
?disabled=${this.disabled}
|
|
509
214
|
?required=${this.required}
|
|
510
215
|
aria-invalid=${this.error?"true":"false"}
|
|
511
|
-
aria-describedby=${
|
|
216
|
+
aria-describedby=${n}
|
|
512
217
|
/>
|
|
513
|
-
${
|
|
514
|
-
${
|
|
218
|
+
${c}
|
|
219
|
+
${i}
|
|
515
220
|
<md-ripple></md-ripple>
|
|
516
221
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
517
222
|
</div>
|
|
518
223
|
</div>
|
|
519
|
-
`}firstUpdated(e){super.firstUpdated(e),this._initialValue=this.value,this._internals&&this.value&&this._internals.setFormValue(this.value),
|
|
224
|
+
`}firstUpdated(e){super.firstUpdated(e),this._initialValue=this.value,this._internals&&this.value&&this._internals.setFormValue(this.value),a(s,this,x).call(this),a(s,this,m).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 i=this.disabled?null:this.value;this._internals.setFormValue(i)}e.has("type")&&(a(s,this,x).call(this),this._hasRenderedOnce&&a(s,this,S).call(this)),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom")||e.has("spacingLeft")||e.has("spacingRight"))&&a(s,this,m).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)),a(s,this,v).call(this),window.removeEventListener("keydown",this._onGlobalKeydown,!0),window.removeEventListener("pointerdown",this._onGlobalPointerDown,!0)}reportValidity(){return a(s,this,f).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 i=this.disabled?null:this.value;this._internals.setFormValue(i),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()}}},u.formAssociated=!0,u.styles=[w`
|
|
520
225
|
:host {
|
|
521
226
|
--scb-textfield-number-max-width: 280px;
|
|
522
227
|
--scb-textfield-text-max-width: 400px;
|
|
@@ -887,4 +592,4 @@ import{_ as M,b as S,g as E,h as p,m,y as a}from"../../vendor/vendor.js";import"
|
|
|
887
592
|
transform: translateY(-50%);
|
|
888
593
|
z-index: 4;
|
|
889
594
|
}
|
|
890
|
-
`],
|
|
595
|
+
`],u);function m(){const t=a(s,this,h).call(this,this.spacing),e=a(s,this,h).call(this,this.spacingTop)??t,i=a(s,this,h).call(this,this.spacingBottom)??t,n=a(s,this,h).call(this,this.spacingLeft),c=a(s,this,h).call(this,this.spacingRight);e?this.style.setProperty("--scb-textfield-spacing-block-start",e):this.style.removeProperty("--scb-textfield-spacing-block-start"),i?this.style.setProperty("--scb-textfield-spacing-block-end",i):this.style.removeProperty("--scb-textfield-spacing-block-end"),n?this.style.setProperty("--scb-textfield-spacing-inline-start",n):this.style.removeProperty("--scb-textfield-spacing-inline-start"),c?this.style.setProperty("--scb-textfield-spacing-inline-end",c):this.style.removeProperty("--scb-textfield-spacing-inline-end")}function h(t){if(!t)return;const e=String(t).trim();if(e)return/^\d+$/.test(e)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(e,10)))})`:e}function f(t=!1){const e=this.shadowRoot?.querySelector(".scb-textfield");if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))return!0;const i=this.errorText||"Ogiltig inmatning.";let n="";if(e.setCustomValidity(""),this.required&&!e.value)n=i,e.setCustomValidity(n);else if(this.pattern&&e.value)try{new RegExp(this.pattern).test(e.value)||(n=i,e.setCustomValidity(n))}catch{e.setCustomValidity("")}const c=t?e.reportValidity():e.checkValidity();if(this.error=!c,this._internals)if(c)this._internals.setValidity({});else{const p=n||e.validationMessage||i;this._internals.setValidity({customError:!0},p,e)}return c}function x(){const t=this.shadowRoot?.querySelector(".scb-textfield");t&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&this._boundField!==t&&(a(s,this,v).call(this),this._boundField=t,this.type!=="time"&&t.addEventListener("input",this._onFieldInput),t.addEventListener("change",this._onFieldChange),t.addEventListener("select",this._onFieldSelect),t.addEventListener("focus",this._onFieldFocus),t.addEventListener("blur",this._onFieldBlur))}function v(){const t=this._boundField;t&&(t.removeEventListener("input",this._onFieldInput),t.removeEventListener("change",this._onFieldChange),t.removeEventListener("select",this._onFieldSelect),t.removeEventListener("focus",this._onFieldFocus),t.removeEventListener("blur",this._onFieldBlur),this._boundField=null)}function S(){this._showDatepicker=!1;const t=this.shadowRoot?.querySelector(".scb-textfield");if(t&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.value="",t.setCustomValidity("")),this.value="",this.error=!1,this._internals){const e=this.disabled?null:"";this._internals.setFormValue(e),this._internals.setValidity({})}}function g(){const t=this.renderRoot?.querySelector(".ripple-wrapper");t&&(this._inputFocused&&this._kbShouldShowRing?t.setAttribute("data-kb-focus","true"):t.removeAttribute("data-kb-focus"))}r([d({type:String,reflect:!0})],l.prototype,"type",void 0);r([d({type:String})],l.prototype,"label",void 0);r([d({type:String,attribute:"supporting-text"})],l.prototype,"supportingText",void 0);r([d({type:String,attribute:"error-text"})],l.prototype,"errorText",void 0);r([d({type:String,attribute:"leading-icon"})],l.prototype,"leadingIcon",void 0);r([d({type:String})],l.prototype,"name",void 0);r([d({type:String})],l.prototype,"pattern",void 0);r([d({type:String,attribute:"value"})],l.prototype,"value",void 0);r([d({type:String})],l.prototype,"underLabel",void 0);r([d({type:Boolean,reflect:!0})],l.prototype,"error",void 0);r([d({type:Boolean,reflect:!0})],l.prototype,"disabled",void 0);r([d({type:Boolean,reflect:!0})],l.prototype,"required",void 0);r([d({type:String,reflect:!0})],l.prototype,"size",void 0);r([d({type:String,reflect:!0})],l.prototype,"spacing",void 0);r([d({type:String,attribute:"spacing-top",reflect:!0})],l.prototype,"spacingTop",void 0);r([d({type:String,attribute:"spacing-bottom",reflect:!0})],l.prototype,"spacingBottom",void 0);r([d({type:String,attribute:"spacing-left",reflect:!0})],l.prototype,"spacingLeft",void 0);r([d({type:String,attribute:"spacing-right",reflect:!0})],l.prototype,"spacingRight",void 0);r([k()],l.prototype,"_showDatepicker",void 0);l=r([$("scb-textfield")],l);
|