scb-wc-test 0.1.297 → 0.1.299
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/mvc/components/scb-checkbox/scb-checkbox.js +8 -7
- package/mvc/components/scb-pagination/scb-pagination.js +107 -71
- package/mvc/components/scb-radio-button/scb-radio-button.js +7 -7
- package/mvc/components/scb-radio-button/scb-radio-group.js +6 -4
- package/mvc/components/scb-search/scb-search.js +6 -6
- package/mvc/components/scb-segmented-button/scb-segmented-button.js +2 -2
- package/mvc/components/scb-select/scb-select.js +5 -3
- package/mvc/components/scb-switch/scb-switch.js +5 -4
- package/mvc/components/scb-viz/scb-viz.js +6 -17
- package/package.json +2 -2
- package/scb-checkbox/scb-checkbox.d.ts +10 -0
- package/scb-checkbox/scb-checkbox.js +130 -97
- package/scb-pagination/scb-pagination.d.ts +2 -0
- package/scb-pagination/scb-pagination.js +189 -140
- package/scb-radio-button/scb-radio-button.d.ts +2 -1
- package/scb-radio-button/scb-radio-button.js +70 -66
- package/scb-radio-button/scb-radio-group.d.ts +11 -0
- package/scb-radio-button/scb-radio-group.js +124 -71
- package/scb-search/scb-search.d.ts +11 -0
- package/scb-search/scb-search.js +107 -70
- package/scb-segmented-button/scb-segmented-button.d.ts +10 -0
- package/scb-segmented-button/scb-segmented-button.js +79 -47
- package/scb-select/scb-select.d.ts +16 -0
- package/scb-select/scb-select.js +145 -83
- package/scb-switch/scb-switch.d.ts +10 -0
- package/scb-switch/scb-switch.js +51 -18
- package/scb-viz/scb-viz.js +205 -216
- package/scb-wc-test.bundle.js +822 -791
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as C,n as l,i as M,E as m,x as y,t as R}from"../../vendor/vendor.js";import"../../vendor/vendor-material.js";import"./scb-checkbox-group.js";(function(){try{var e=typeof globalThis<"u"?globalThis:window;if(!e.__scb_ce_guard_installed__){e.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(s,r,i){try{customElements.get(s)||t(s,r,i)}catch(d){var o=String(d||"");if(o.indexOf("already been used")===-1&&o.indexOf("NotSupportedError")===-1)throw d}}}}catch{}})();var I=Object.defineProperty,A=Object.getOwnPropertyDescriptor,E=e=>{throw TypeError(e)},c=(e,t,s,r)=>{for(var i=r>1?void 0:r?A(t,s):t,o=e.length-1,d;o>=0;o--)(d=e[o])&&(i=(r?d(t,s,i):d(i))||i);return r&&i&&I(t,s,i),i},S=(e,t,s)=>t.has(e)||E("Cannot "+s),b=(e,t,s)=>(S(e,t,"read from private field"),s?s.call(e):t.get(e)),v=(e,t,s)=>t.has(e)?E("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),h=(e,t,s)=>(S(e,t,"access private method"),s),n,u,w,x,k,_,L,p;let V=!1,f=0;const $=e=>{e.metaKey||e.altKey||e.ctrlKey||(V=!0)},g=()=>{V=!1},z=()=>{f===0&&(window.addEventListener("keydown",$,!0),window.addEventListener("pointerdown",g,!0),window.addEventListener("mousedown",g,!0),window.addEventListener("touchstart",g,!0)),f+=1},F=()=>{f=Math.max(0,f-1),f===0&&(window.removeEventListener("keydown",$,!0),window.removeEventListener("pointerdown",g,!0),window.removeEventListener("mousedown",g,!0),window.removeEventListener("touchstart",g,!0))};let a=class extends M{constructor(){super(),v(this,n),this._internals=null,this.disabled=!1,this.indeterminate=!1,this.checked=!1,this.required=!1,this.size="medium",this.label="",this.supportingText="",this.ariaLabel="",this.name="",this.value="on",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this._form=null,this._formResetHandler=null,this._initialChecked=!1,this._customValidationMessage="",this._checkboxId="",this._showOuterFocusRing=!1,v(this,x,()=>{this.disabled||!this.label?.trim()||V&&h(this,n,u).call(this,!0)}),v(this,k,()=>{h(this,n,u).call(this,!1)}),v(this,_,()=>{h(this,n,u).call(this,!1)}),"attachInternals"in this&&(this._internals=this.attachInternals())}connectedCallback(){super.connectedCallback(),z(),this._checkboxId=this.id||`scb-checkbox-${Math.random().toString(36).slice(2,11)}`,this._initialChecked=this.checked,h(this,n,w).call(this),this.addEventListener("focusin",b(this,x)),this.addEventListener("focusout",b(this,k)),this.addEventListener("pointerdown",b(this,_),!0),this._form=this.closest("form"),this._form&&(this._formResetHandler=()=>{this.checked=this._initialChecked,this.indeterminate=!1,this.__syncFormValue()},this._form.addEventListener("reset",this._formResetHandler,!0)),this.__syncFormValue()}disconnectedCallback(){super.disconnectedCallback(),F(),this.removeEventListener("focusin",b(this,x)),this.removeEventListener("focusout",b(this,k)),this.removeEventListener("pointerdown",b(this,_),!0),this._form&&this._formResetHandler&&this._form.removeEventListener("reset",this._formResetHandler,!0)}firstUpdated(){const e=this.shadowRoot?.querySelector("md-checkbox");e&&e.addEventListener("change",()=>{const s=e,r=!!s.checked,i=!!s.indeterminate;this.checked=r,this.indeterminate=i,this.dispatchEvent(new CustomEvent("change",{detail:{checked:r,indeterminate:i},bubbles:!0,composed:!0}))}),this.shadowRoot?.querySelector("label.wrap")?.addEventListener("click",s=>{if(this.disabled)return;if(!s.composedPath().some(o=>{const d=o;return d?.tagName?.toLowerCase?.()==="md-checkbox"||d?.classList?.contains("box-wrap")})){s.preventDefault();const o=this.shadowRoot.querySelector("md-checkbox");o&&(o.checked=!o.checked,o.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}}),this.__syncInnerAria(),this.__syncValidity(),h(this,n,L).call(this)}updated(e){super.updated(e),e.has("disabled")&&(this.toggleAttribute("aria-disabled",this.disabled),this.disabled&&h(this,n,u).call(this,!1)),(e.has("label")||e.has("supportingText")||e.has("ariaLabel"))&&this.__syncInnerAria(),e.has("label")&&h(this,n,w).call(this),(e.has("checked")||e.has("disabled")||e.has("value"))&&this.__syncFormValue(),(e.has("checked")||e.has("disabled")||e.has("required"))&&this.__syncValidity(),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom")||e.has("spacingLeft")||e.has("spacingRight"))&&h(this,n,L).call(this)}formDisabledCallback(e){this.disabled=e}__syncInnerAria(){const t=this.shadowRoot?.querySelector("md-checkbox")?.shadowRoot;if(!t)return;const s=t.querySelector('[role="checkbox"]')||t.querySelector('input[type="checkbox"]');if(!s)return;const r=!!this.label?.trim(),i=r?`${this._checkboxId}-label`:"",o=this.supportingText?`${this._checkboxId}-supporting-text`:"";r&&i?(s.setAttribute("aria-labelledby",i),s.removeAttribute("aria-label")):(s.removeAttribute("aria-labelledby"),this.ariaLabel?.trim()?s.setAttribute("aria-label",this.ariaLabel.trim()):s.removeAttribute("aria-label")),o?s.setAttribute("aria-describedby",o):s.removeAttribute("aria-describedby")}__getValidationMessage(){return this._customValidationMessage?this._customValidationMessage:this.required&&!this.checked?"Markera det här fältet.":""}__syncValidity(){const e=this.shadowRoot?.querySelector("md-checkbox"),t=this.disabled?"":this.__getValidationMessage();this._internals&&(t?this._internals.setValidity({valueMissing:!0},t,e??void 0):this._internals.setValidity({})),this.toggleAttribute("aria-invalid",!!t)}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}__syncFormValue(){if(!this._internals)return;const e=this.disabled||!this.checked?null:this.value;this._internals.setFormValue(e)}render(){const e=this.supportingText?`${this._checkboxId}-supporting-text`:void 0,t=!!this.label?.trim(),s=t?m:this.ariaLabel||m;return y`
|
|
2
2
|
<label class="wrap">
|
|
3
|
-
${
|
|
3
|
+
${t?y`<md-focus-ring class="outer-focus-ring" ?visible=${this._showOuterFocusRing}></md-focus-ring>`:m}
|
|
4
4
|
<div class="box-wrap">
|
|
5
5
|
<md-checkbox
|
|
6
6
|
id="${this._checkboxId}"
|
|
7
7
|
?disabled=${this.disabled}
|
|
8
8
|
?indeterminate=${this.indeterminate}
|
|
9
9
|
?checked=${this.checked}
|
|
10
|
-
|
|
10
|
+
?required=${this.required}
|
|
11
|
+
aria-label=${s}
|
|
11
12
|
></md-checkbox>
|
|
12
13
|
</div>
|
|
13
|
-
${
|
|
14
|
+
${t?y`<span class="lbl" id="${this._checkboxId}-label">${this.label}</span>`:m}
|
|
14
15
|
</label>
|
|
15
16
|
|
|
16
|
-
${this.supportingText?
|
|
17
|
+
${this.supportingText?y`<div id="${e}" class="supporting-text">
|
|
17
18
|
${this.supportingText}
|
|
18
19
|
</div>`:m}
|
|
19
20
|
<slot></slot>
|
|
20
|
-
`}};
|
|
21
|
+
`}};n=new WeakSet;u=function(e){this._showOuterFocusRing!==e&&(this._showOuterFocusRing=e,this.requestUpdate())};w=function(){const e=!!this.label?.trim();this.toggleAttribute("data-has-label",e),e||h(this,n,u).call(this,!1)};x=new WeakMap;k=new WeakMap;_=new WeakMap;L=function(){const e=h(this,n,p).call(this,this.spacing),t=h(this,n,p).call(this,this.spacingTop)??e,s=h(this,n,p).call(this,this.spacingBottom)??e,r=h(this,n,p).call(this,this.spacingLeft),i=h(this,n,p).call(this,this.spacingRight);t?this.style.setProperty("--scb-checkbox-spacing-block-start",t):this.style.removeProperty("--scb-checkbox-spacing-block-start"),s?this.style.setProperty("--scb-checkbox-spacing-block-end",s):this.style.removeProperty("--scb-checkbox-spacing-block-end"),r?this.style.setProperty("--scb-checkbox-spacing-inline-start",r):this.style.removeProperty("--scb-checkbox-spacing-inline-start"),i?this.style.setProperty("--scb-checkbox-spacing-inline-end",i):this.style.removeProperty("--scb-checkbox-spacing-inline-end")};p=function(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};a.formAssociated=!0;a.styles=C`
|
|
21
22
|
:host {
|
|
22
23
|
display: inline-grid;
|
|
23
24
|
grid-template-columns: auto;
|
|
@@ -136,4 +137,4 @@ import{a as R,n as h,i as I,E as m,x as v,t as A}from"../../vendor/vendor.js";im
|
|
|
136
137
|
color: var(--md-sys-color-on-surface-variant);
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
|
-
`;
|
|
140
|
+
`;c([l({type:Boolean,reflect:!0})],a.prototype,"disabled",2);c([l({type:Boolean,reflect:!0})],a.prototype,"indeterminate",2);c([l({type:Boolean,reflect:!0})],a.prototype,"checked",2);c([l({type:Boolean,reflect:!0})],a.prototype,"required",2);c([l({type:String,reflect:!0})],a.prototype,"size",2);c([l({type:String})],a.prototype,"label",2);c([l({type:String,attribute:"supporting-text"})],a.prototype,"supportingText",2);c([l({type:String,reflect:!0,attribute:"aria-label"})],a.prototype,"ariaLabel",2);c([l({type:String})],a.prototype,"name",2);c([l({type:String})],a.prototype,"value",2);c([l({type:String,reflect:!0})],a.prototype,"spacing",2);c([l({type:String,attribute:"spacing-top",reflect:!0})],a.prototype,"spacingTop",2);c([l({type:String,attribute:"spacing-bottom",reflect:!0})],a.prototype,"spacingBottom",2);c([l({type:String,attribute:"spacing-left",reflect:!0})],a.prototype,"spacingLeft",2);c([l({type:String,attribute:"spacing-right",reflect:!0})],a.prototype,"spacingRight",2);a=c([R("scb-checkbox")],a);export{a as ScbCheckbox};
|
|
@@ -1,105 +1,133 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as m,n as p,i as v,x as r,t as y}from"../../vendor/vendor.js";import"../scb-link/scb-link.js";import"../scb-button/scb-button.js";import"../scb-icon-button/scb-icon-button.js";import"../../vendor/vendor-material.js";import"../../vendor/preload-helper.js";(function(){try{var i=typeof globalThis<"u"?globalThis:window;if(!i.__scb_ce_guard_installed__){i.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(n,a,s){try{customElements.get(n)||t(n,a,s)}catch(d){var c=String(d||"");if(c.indexOf("already been used")===-1&&c.indexOf("NotSupportedError")===-1)throw d}}}}catch{}})();var x=Object.defineProperty,_=Object.getOwnPropertyDescriptor,l=(i,t,n,a)=>{for(var s=a>1?void 0:a?_(t,n):t,c=i.length-1,d;c>=0;c--)(d=i[c])&&(s=(a?d(t,n,s):d(s))||s);return a&&s&&x(t,n,s),s};let o=class extends v{constructor(){super(...arguments),this.variant="icon-text",this.page=1,this.totalPages=0,this.pagingHref="",this.paginationAriaLabel="Paginering",this.currentAriaLabel="Nuvarande sida, ",this.pagingNumberAriaLabel="Gå till sida ",this.isNarrow=window.innerWidth<=768,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this._onResize=()=>{this.isNarrow=window.innerWidth<=768}}_emitPageChange(i){const t={page:i};this.dispatchEvent(new CustomEvent("page-change",{detail:t,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("pagechange",{detail:t,bubbles:!0,composed:!0}))}_getPagingHref(i){if(this.pagingHref)return`${this.pagingHref}${i}`}_handlePageSelection(i,t){!this.pagingHref&&t&&t.preventDefault(),this.page=i,this._emitPageChange(i)}_prevPage(i){if(this.page<=1){!this.pagingHref&&i&&i.preventDefault();return}this._handlePageSelection(this.page-1,i)}_nextPage(i){if(this.page>=this.totalPages){!this.pagingHref&&i&&i.preventDefault();return}this._handlePageSelection(this.page+1,i)}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this._onResize),this._onResize()}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this._onResize)}mapSpacingToken(i){if(i==null)return;const t=String(i).trim();if(t)return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}__applySpacing(){const i=this.mapSpacingToken(this.spacing),t=this.mapSpacingToken(this.spacingTop)??i,n=this.mapSpacingToken(this.spacingBottom)??i,a=this.mapSpacingToken(this.spacingLeft),s=this.mapSpacingToken(this.spacingRight);t?this.style.setProperty("--scb-pagination-spacing-block-start",t):this.style.removeProperty("--scb-pagination-spacing-block-start"),n?this.style.setProperty("--scb-pagination-spacing-block-end",n):this.style.removeProperty("--scb-pagination-spacing-block-end"),a?this.style.setProperty("--scb-pagination-spacing-inline-start",a):this.style.removeProperty("--scb-pagination-spacing-inline-start"),s?this.style.setProperty("--scb-pagination-spacing-inline-end",s):this.style.removeProperty("--scb-pagination-spacing-inline-end")}firstUpdated(){this.__applySpacing()}updated(i){super.updated(i),(i.has("spacing")||i.has("spacingTop")||i.has("spacingBottom")||i.has("spacingLeft")||i.has("spacingRight"))&&this.__applySpacing()}render(){if(this.totalPages===0)return null;const i=this.variant?`${this.variant.toLowerCase()}`:"",t=[],{page:n,totalPages:a}=this,s=window.innerWidth<=768,c=s?1:2,d=this._getPagingHref(Math.max(1,this.page-1)),h=this._getPagingHref(Math.min(this.totalPages,this.page+1)),b=this.pagingHref?this.variant==="icon"?r`<a
|
|
2
|
+
class="paging-action-link"
|
|
3
|
+
href=${d}
|
|
4
|
+
@click=${this._prevPage}
|
|
5
|
+
aria-label="Föregående sida"
|
|
6
|
+
aria-disabled=${this.page===1?"true":"false"}
|
|
7
|
+
>
|
|
8
|
+
<scb-icon-button
|
|
9
|
+
icon="chevron_left"
|
|
10
|
+
?disabled=${this.page===1}
|
|
11
|
+
aria-label="Föregående sida"
|
|
12
|
+
></scb-icon-button>
|
|
13
|
+
</a>`:r`<a
|
|
14
|
+
class="paging-action-link"
|
|
15
|
+
href=${d}
|
|
16
|
+
@click=${this._prevPage}
|
|
17
|
+
aria-label="Föregående sida"
|
|
18
|
+
aria-disabled=${this.page===1?"true":"false"}
|
|
19
|
+
>
|
|
20
|
+
<scb-button
|
|
21
|
+
variant="text"
|
|
22
|
+
label="Föregående"
|
|
23
|
+
icon="chevron_left"
|
|
24
|
+
?disabled=${this.page===1}
|
|
25
|
+
aria-label="Föregående sida"
|
|
26
|
+
></scb-button>
|
|
27
|
+
</a>`:this.variant==="icon"?r`<scb-icon-button
|
|
28
|
+
icon="chevron_left"
|
|
29
|
+
@click=${this._prevPage}
|
|
30
|
+
?disabled=${this.page===1}
|
|
31
|
+
aria-label="Föregående sida"
|
|
32
|
+
></scb-icon-button>`:r`<scb-button
|
|
33
|
+
variant="text"
|
|
34
|
+
label="Föregående"
|
|
35
|
+
icon="chevron_left"
|
|
36
|
+
@click=${this._prevPage}
|
|
37
|
+
?disabled=${this.page===1}
|
|
38
|
+
aria-label="Föregående sida"
|
|
39
|
+
></scb-button>`,u=this.pagingHref?this.variant==="icon"?r`<a
|
|
40
|
+
class="paging-action-link"
|
|
41
|
+
href=${h}
|
|
42
|
+
@click=${this._nextPage}
|
|
43
|
+
aria-label="Nästa sida"
|
|
44
|
+
aria-disabled=${this.page===this.totalPages?"true":"false"}
|
|
45
|
+
>
|
|
46
|
+
<scb-icon-button
|
|
47
|
+
icon="chevron_right"
|
|
48
|
+
?disabled=${this.page===this.totalPages}
|
|
49
|
+
aria-label="Nästa sida"
|
|
50
|
+
></scb-icon-button>
|
|
51
|
+
</a>`:r`<a
|
|
52
|
+
class="paging-action-link"
|
|
53
|
+
href=${h}
|
|
54
|
+
@click=${this._nextPage}
|
|
55
|
+
aria-label="Nästa sida"
|
|
56
|
+
aria-disabled=${this.page===this.totalPages?"true":"false"}
|
|
57
|
+
>
|
|
58
|
+
<scb-button
|
|
59
|
+
variant="text"
|
|
60
|
+
label="Nästa"
|
|
61
|
+
icon="chevron_right"
|
|
62
|
+
iconPosition="right"
|
|
63
|
+
?disabled=${this.page===this.totalPages}
|
|
64
|
+
aria-label="Nästa sida"
|
|
65
|
+
trailing-icon
|
|
66
|
+
></scb-button>
|
|
67
|
+
</a>`:this.variant==="icon"?r`<scb-icon-button
|
|
68
|
+
icon="chevron_right"
|
|
69
|
+
@click=${this._nextPage}
|
|
70
|
+
?disabled=${this.page===this.totalPages}
|
|
71
|
+
aria-label="Nästa sida"
|
|
72
|
+
></scb-icon-button>`:r`<scb-button
|
|
73
|
+
variant="text"
|
|
74
|
+
label="Nästa"
|
|
75
|
+
icon="chevron_right"
|
|
76
|
+
iconPosition="right"
|
|
77
|
+
@click=${this._nextPage}
|
|
78
|
+
?disabled=${this.page===this.totalPages}
|
|
79
|
+
aria-label="Nästa sida"
|
|
80
|
+
trailing-icon
|
|
81
|
+
></scb-button>`,g=e=>e===n?r`
|
|
2
82
|
<li>
|
|
3
83
|
<span
|
|
4
84
|
class="page-number active"
|
|
5
85
|
aria-current="page"
|
|
6
|
-
aria-label="${this.currentAriaLabel} ${
|
|
7
|
-
>${
|
|
86
|
+
aria-label="${this.currentAriaLabel} ${e}"
|
|
87
|
+
>${e}</span
|
|
8
88
|
>
|
|
9
89
|
</li>
|
|
10
90
|
`:r`
|
|
11
91
|
<li>
|
|
12
92
|
<scb-link
|
|
13
|
-
class="page-number${
|
|
14
|
-
@click=${
|
|
15
|
-
aria-current=${
|
|
16
|
-
aria-label="${this.pagingNumberAriaLabel} ${
|
|
17
|
-
href=${this.
|
|
18
|
-
?disabled=${
|
|
19
|
-
>${
|
|
93
|
+
class="page-number${e===n?" active":""}"
|
|
94
|
+
@click=${f=>this._handlePageSelection(e,f)}
|
|
95
|
+
aria-current=${e===n?"page":void 0}
|
|
96
|
+
aria-label="${this.pagingNumberAriaLabel} ${e}"
|
|
97
|
+
href=${this._getPagingHref(e)}
|
|
98
|
+
?disabled=${e===n}
|
|
99
|
+
>${e}</scb-link
|
|
20
100
|
>
|
|
21
101
|
</li>
|
|
22
|
-
`;if(
|
|
23
|
-
<nav aria-label="${this.paginationAriaLabel}" class="pagination ${
|
|
102
|
+
`;if(a<=8)for(let e=1;e<=a;e++)t.push(g(e));else if(t.push(g(1)),n<=4&&!s){for(let e=2;e<=5;e++)t.push(g(e));a>6?(t.push(r`<li><span class="ellipsis" aria-hidden="true">…</span></li>`),t.push(g(a))):a===6&&t.push(g(a))}else if(n<=3&&s){for(let e=2;e<=3;e++)t.push(g(e));a>4?(t.push(r`<li><span class="ellipsis" aria-hidden="true">…</span></li>`),t.push(g(a))):a===4&&t.push(g(a))}else if(n>=a-(c+1)){t.push(r`<li><span class="ellipsis" aria-hidden="true">…</span></li>`);for(let e=a-c*2;e<=a;e++)e>1&&t.push(g(e))}else{t.push(r`<li><span class="ellipsis" aria-hidden="true">…</span></li>`);for(let e=n-c;e<=n+c;e++)e>1&&e<a&&t.push(g(e));t.push(r`<li><span class="ellipsis" aria-hidden="true">…</span></li>`),t.push(g(a))}return s?r`
|
|
103
|
+
<nav aria-label="${this.paginationAriaLabel}" class="pagination ${i}">
|
|
24
104
|
<div class="pagination-row">
|
|
25
105
|
<div class="prev">
|
|
26
|
-
${
|
|
27
|
-
icon="chevron_left"
|
|
28
|
-
@click=${this._prevPage}
|
|
29
|
-
?disabled=${this.page===1}
|
|
30
|
-
aria-label="Föregående sida"
|
|
31
|
-
></scb-icon-button>`:r`<scb-button
|
|
32
|
-
variant="text"
|
|
33
|
-
label="Föregående"
|
|
34
|
-
icon="chevron_left"
|
|
35
|
-
@click=${this._prevPage}
|
|
36
|
-
?disabled=${this.page===1}
|
|
37
|
-
aria-label="Föregående sida"
|
|
38
|
-
></scb-button>`}
|
|
106
|
+
${b}
|
|
39
107
|
</div>
|
|
40
108
|
<ol>
|
|
41
109
|
${t}
|
|
42
110
|
</ol>
|
|
43
111
|
</div>
|
|
44
112
|
<div class="next">
|
|
45
|
-
${
|
|
46
|
-
icon="chevron_right"
|
|
47
|
-
@click=${this._nextPage}
|
|
48
|
-
?disabled=${this.page===this.totalPages}
|
|
49
|
-
aria-label="Nästa sida"
|
|
50
|
-
></scb-icon-button>`:r`<scb-button
|
|
51
|
-
variant="text"
|
|
52
|
-
label="Nästa"
|
|
53
|
-
icon="chevron_right"
|
|
54
|
-
iconPosition="right"
|
|
55
|
-
@click=${this._nextPage}
|
|
56
|
-
?disabled=${this.page===this.totalPages}
|
|
57
|
-
aria-label="Nästa sida"
|
|
58
|
-
trailing-icon
|
|
59
|
-
></scb-button>`}
|
|
113
|
+
${u}
|
|
60
114
|
</div>
|
|
61
115
|
</nav>
|
|
62
116
|
`:r`
|
|
63
|
-
<nav aria-label="${this.paginationAriaLabel}" class="pagination ${
|
|
117
|
+
<nav aria-label="${this.paginationAriaLabel}" class="pagination ${i}">
|
|
64
118
|
<div class="pagination-row">
|
|
65
119
|
<div class="prev">
|
|
66
|
-
${
|
|
67
|
-
icon="chevron_left"
|
|
68
|
-
@click=${this._prevPage}
|
|
69
|
-
?disabled=${this.page===1}
|
|
70
|
-
aria-label="Föregående sida"
|
|
71
|
-
></scb-icon-button>`:r`<scb-button
|
|
72
|
-
variant="text"
|
|
73
|
-
label="Föregående"
|
|
74
|
-
icon="chevron_left"
|
|
75
|
-
@click=${this._prevPage}
|
|
76
|
-
?disabled=${this.page===1}
|
|
77
|
-
aria-label="Föregående sida"
|
|
78
|
-
></scb-button>`}
|
|
120
|
+
${b}
|
|
79
121
|
</div>
|
|
80
122
|
<ol>
|
|
81
123
|
${t}
|
|
82
124
|
</ol>
|
|
83
125
|
<div class="next">
|
|
84
|
-
${
|
|
85
|
-
icon="chevron_right"
|
|
86
|
-
@click=${this._nextPage}
|
|
87
|
-
?disabled=${this.page===this.totalPages}
|
|
88
|
-
aria-label="Nästa sida"
|
|
89
|
-
></scb-icon-button>`:r`<scb-button
|
|
90
|
-
variant="text"
|
|
91
|
-
label="Nästa"
|
|
92
|
-
icon="chevron_right"
|
|
93
|
-
iconPosition="right"
|
|
94
|
-
@click=${this._nextPage}
|
|
95
|
-
?disabled=${this.page===this.totalPages}
|
|
96
|
-
aria-label="Nästa sida"
|
|
97
|
-
trailing-icon
|
|
98
|
-
></scb-button>`}
|
|
126
|
+
${u}
|
|
99
127
|
</div>
|
|
100
128
|
</div>
|
|
101
129
|
</nav>
|
|
102
|
-
`}};
|
|
130
|
+
`}};o.styles=[m`
|
|
103
131
|
:host {
|
|
104
132
|
display: block;
|
|
105
133
|
width: 100%;
|
|
@@ -204,6 +232,14 @@ import{a as h,n as c,i as b,x as r,t as u}from"../../vendor/vendor.js";import"..
|
|
|
204
232
|
opacity: 0.5;
|
|
205
233
|
pointer-events: none;
|
|
206
234
|
}
|
|
235
|
+
.paging-action-link {
|
|
236
|
+
display: inline-flex;
|
|
237
|
+
text-decoration: none;
|
|
238
|
+
}
|
|
239
|
+
.paging-action-link[aria-disabled='true'] {
|
|
240
|
+
opacity: 0.5;
|
|
241
|
+
pointer-events: none;
|
|
242
|
+
}
|
|
207
243
|
|
|
208
244
|
@media (max-width: 768px) {
|
|
209
245
|
.pagination .prev {
|
|
@@ -235,4 +271,4 @@ import{a as h,n as c,i as b,x as r,t as u}from"../../vendor/vendor.js";import"..
|
|
|
235
271
|
margin-top: 8px;
|
|
236
272
|
}
|
|
237
273
|
}
|
|
238
|
-
`];
|
|
274
|
+
`];l([p({type:String})],o.prototype,"variant",2);l([p({type:Number})],o.prototype,"page",2);l([p({type:Number,attribute:"total-pages"})],o.prototype,"totalPages",2);l([p({type:String,attribute:"paging-href"})],o.prototype,"pagingHref",2);l([p({type:String,attribute:"pagination-aria-label"})],o.prototype,"paginationAriaLabel",2);l([p({type:String,attribute:"current-aria-label"})],o.prototype,"currentAriaLabel",2);l([p({type:String,attribute:"paging-number-aria-label"})],o.prototype,"pagingNumberAriaLabel",2);l([p({type:Boolean})],o.prototype,"isNarrow",2);l([p({type:String})],o.prototype,"spacing",2);l([p({type:String,attribute:"spacing-top"})],o.prototype,"spacingTop",2);l([p({type:String,attribute:"spacing-bottom"})],o.prototype,"spacingBottom",2);l([p({type:String,attribute:"spacing-left"})],o.prototype,"spacingLeft",2);l([p({type:String,attribute:"spacing-right"})],o.prototype,"spacingRight",2);o=l([y("scb-pagination")],o);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as C,n as c,i as A,E as p,x as g,t as I}from"../../vendor/vendor.js";import"../../vendor/vendor-material.js";import"./scb-radio-group.js";(function(){try{var e=typeof globalThis<"u"?globalThis:window;if(!e.__scb_ce_guard_installed__){e.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(i,l,s){try{customElements.get(i)||t(i,l,s)}catch(h){var d=String(h||"");if(d.indexOf("already been used")===-1&&d.indexOf("NotSupportedError")===-1)throw h}}}}catch{}})();var z=Object.defineProperty,R=Object.getOwnPropertyDescriptor,L=e=>{throw TypeError(e)},n=(e,t,i,l)=>{for(var s=l>1?void 0:l?R(t,i):t,d=e.length-1,h;d>=0;d--)(h=e[d])&&(s=(l?h(t,i,s):h(s))||s);return l&&s&&z(t,i,s),s},$=(e,t,i)=>t.has(e)||L("Cannot "+i),u=(e,t,i)=>($(e,t,"read from private field"),i?i.call(e):t.get(e)),f=(e,t,i)=>t.has(e)?L("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),o=(e,t,i)=>($(e,t,"access private method"),i),a,b,k,y,w,x,_;let E=!1,m=0;const S=e=>{e.metaKey||e.altKey||e.ctrlKey||(E=!0)},v=()=>{E=!1},O=()=>{m===0&&(window.addEventListener("keydown",S,!0),window.addEventListener("pointerdown",v,!0),window.addEventListener("mousedown",v,!0),window.addEventListener("touchstart",v,!0)),m+=1},F=()=>{m=Math.max(0,m-1),m===0&&(window.removeEventListener("keydown",S,!0),window.removeEventListener("pointerdown",v,!0),window.removeEventListener("mousedown",v,!0),window.removeEventListener("touchstart",v,!0))};let r=class extends A{constructor(){super(...arguments),f(this,a),this.disabled=!1,this.checked=!1,this.name="",this.value="",this.size="medium",this.deselectable=!1,this.label="",this.supportingText="",this.ariaLabel="",this._radioId="",this._showOuterFocusRing=!1,f(this,y,()=>{this.disabled||!this.label?.trim()||E&&o(this,a,b).call(this,!0)}),f(this,w,()=>{o(this,a,b).call(this,!1)}),f(this,x,()=>{o(this,a,b).call(this,!1)}),this._onClick=e=>{if(this.disabled)return;e.preventDefault(),e.stopPropagation();const t=this.deselectable?!this.checked:!0;t!==this.checked&&(this.checked=t,o(this,a,_).call(this),this.checked&&this.dispatchEvent(new CustomEvent("scb-radio-change",{detail:{name:this.name,source:this},bubbles:!0,composed:!0})),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{checked:this.checked,value:this.checked?this.value:""},bubbles:!0,composed:!0})))},this._onRadioChange=e=>{e.detail.name===this.name&&e.detail.source!==this&&(this.checked=!1)}}connectedCallback(){super.connectedCallback(),O(),this._radioId=this.id||`scb-radio-${Math.random().toString(36).substr(2,9)}`,o(this,a,k).call(this),this.addEventListener("focusin",u(this,y)),this.addEventListener("focusout",u(this,w)),this.addEventListener("pointerdown",u(this,x),!0),document.addEventListener("scb-radio-change",this._onRadioChange)}disconnectedCallback(){super.disconnectedCallback(),F(),this.removeEventListener("focusin",u(this,y)),this.removeEventListener("focusout",u(this,w)),this.removeEventListener("pointerdown",u(this,x),!0),document.removeEventListener("scb-radio-change",this._onRadioChange)}firstUpdated(){this.__syncInnerAria(),o(this,a,_).call(this)}updated(e){super.updated(e),e.has("disabled")&&(this.toggleAttribute("aria-disabled",this.disabled),this.disabled&&o(this,a,b).call(this,!1)),(e.has("label")||e.has("supportingText")||e.has("ariaLabel"))&&this.__syncInnerAria(),e.has("label")&&o(this,a,k).call(this),e.has("checked")&&o(this,a,_).call(this)}__syncInnerAria(){const t=this.shadowRoot?.querySelector("md-radio")?.shadowRoot;if(!t)return;const i=t.querySelector('[role="radio"]')||t.querySelector('input[type="radio"]');if(!i)return;const l=!!this.label?.trim(),s=l?`${this._radioId}-label`:"",d=this.supportingText?`${this._radioId}-supporting-text`:"";l&&s?(i.setAttribute("aria-labelledby",s),i.removeAttribute("aria-label")):(i.removeAttribute("aria-labelledby"),this.ariaLabel?.trim()?i.setAttribute("aria-label",this.ariaLabel.trim()):i.removeAttribute("aria-label")),d?i.setAttribute("aria-describedby",d):i.removeAttribute("aria-describedby")}render(){const e=this.supportingText?`${this._radioId}-supporting-text`:void 0,t=!!this.label?.trim(),i=t?p:this.ariaLabel||p;return g`
|
|
2
2
|
<label class="wrap">
|
|
3
|
-
${t?
|
|
3
|
+
${t?g`<md-focus-ring class="outer-focus-ring" ?visible=${this._showOuterFocusRing}></md-focus-ring>`:p}
|
|
4
4
|
<div class="radio-wrap">
|
|
5
5
|
<md-radio
|
|
6
6
|
id="${this._radioId}"
|
|
@@ -10,17 +10,17 @@ import{a as S,n as d,i as z,E as p,x as m,t as C}from"../../vendor/vendor.js";im
|
|
|
10
10
|
value="${this.value}"
|
|
11
11
|
aria-label=${i}
|
|
12
12
|
aria-describedby=${e??p}
|
|
13
|
-
@
|
|
13
|
+
@click=${this._onClick}
|
|
14
14
|
></md-radio>
|
|
15
15
|
</div>
|
|
16
|
-
${t?
|
|
16
|
+
${t?g`<span class="lbl" id="${this._radioId}-label">${this.label}</span>`:p}
|
|
17
17
|
</label>
|
|
18
18
|
|
|
19
|
-
${this.supportingText?
|
|
19
|
+
${this.supportingText?g`<div id="${e}" class="supporting-text">
|
|
20
20
|
${this.supportingText}
|
|
21
21
|
</div>`:p}
|
|
22
22
|
<slot></slot>
|
|
23
|
-
`}};
|
|
23
|
+
`}};a=new WeakSet;b=function(e){this._showOuterFocusRing!==e&&(this._showOuterFocusRing=e,this.requestUpdate())};k=function(){const e=!!this.label?.trim();this.toggleAttribute("data-has-label",e),e||o(this,a,b).call(this,!1)};y=new WeakMap;w=new WeakMap;x=new WeakMap;_=function(){const e=this.shadowRoot?.querySelector("md-radio");e&&(e.checked=this.checked,this.checked?e.setAttribute("checked",""):e.removeAttribute("checked"))};r.styles=C`
|
|
24
24
|
/* layout med inline-grid */
|
|
25
25
|
:host {
|
|
26
26
|
display: inline-grid;
|
|
@@ -129,4 +129,4 @@ import{a as S,n as d,i as z,E as p,x as m,t as C}from"../../vendor/vendor.js";im
|
|
|
129
129
|
.lbl { color: var(--md-sys-color-on-surface); }
|
|
130
130
|
.supporting-text { color: var(--md-sys-color-on-surface-variant); }
|
|
131
131
|
}
|
|
132
|
-
`;
|
|
132
|
+
`;n([c({type:Boolean,reflect:!0})],r.prototype,"disabled",2);n([c({type:Boolean,reflect:!0})],r.prototype,"checked",2);n([c({type:String,reflect:!0})],r.prototype,"name",2);n([c({type:String,reflect:!0})],r.prototype,"value",2);n([c({type:String,reflect:!0})],r.prototype,"size",2);n([c({type:Boolean,reflect:!0})],r.prototype,"deselectable",2);n([c({type:String})],r.prototype,"label",2);n([c({type:String,attribute:"supporting-text"})],r.prototype,"supportingText",2);n([c({type:String,attribute:"aria-label"})],r.prototype,"ariaLabel",2);r=n([I("scb-radio-button")],r);
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import{a as E,n as
|
|
1
|
+
import{a as E,n as h,i as C,x as A,t as L}from"../../vendor/vendor.js";(function(){try{var t=typeof globalThis<"u"?globalThis:window;if(!t.__scb_ce_guard_installed__){t.__scb_ce_guard_installed__=!0;var i=customElements.define.bind(customElements);customElements.define=function(e,s,a){try{customElements.get(e)||i(e,s,a)}catch(u){var c=String(u||"");if(c.indexOf("already been used")===-1&&c.indexOf("NotSupportedError")===-1)throw u}}}}catch{}})();var M=Object.defineProperty,P=Object.getOwnPropertyDescriptor,V=t=>{throw TypeError(t)},l=(t,i,e,s)=>{for(var a=s>1?void 0:s?P(i,e):i,c=t.length-1,u;c>=0;c--)(u=t[c])&&(a=(s?u(i,e,a):u(a))||a);return s&&a&&M(i,e,a),a},w=(t,i,e)=>i.has(t)||V("Cannot "+e),d=(t,i,e)=>(w(t,i,"read from private field"),e?e.call(t):i.get(t)),b=(t,i,e)=>i.has(t)?V("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(t):i.set(t,e),o=(t,i,e)=>(w(t,i,"access private method"),e),y,p,m,v,r,_,g,k,f;let n=class extends C{constructor(){super(),b(this,r),this.name="",this.orientation="vertical",this.disabled=!1,this.required=!1,this.deselectable=!1,this.size="medium",this.ariaLabel=null,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.value="",this._internals=null,this._form=null,this._formResetHandler=null,this._initialValue="",this._customValidationMessage="",b(this,y,()=>{const t=this.shadowRoot?.querySelector("slot");return t?t.assignedElements({flatten:!0}).filter(i=>i.tagName.toLowerCase()==="scb-radio-button"):[]}),b(this,p,()=>{const t=d(this,y).call(this);if(!t.length)return;let i=null;for(const e of t){const s=e;this.name&&e.setAttribute("name",this.name),this.disabled?e.setAttribute("disabled",""):e.removeAttribute("disabled"),this.orientation==="horizontal"?e.setAttribute("orientation","horizontal"):e.removeAttribute("orientation");const a=e.hasAttribute("data-size-from-group");this.deselectable?e.setAttribute("deselectable",""):e.removeAttribute("deselectable"),this.size==="medium"?a&&(e.removeAttribute("size"),e.removeAttribute("data-size-from-group")):(!e.hasAttribute("size")||a)&&(e.setAttribute("size",this.size),e.setAttribute("data-size-from-group",""));const c=s.value??e.getAttribute("value")??"",u=typeof s.checked=="boolean"?s.checked:e.hasAttribute("checked");if(this.value){const S=String(c)===this.value;S&&!u?s.checked=!0:!S&&u&&(s.checked=!1)}else u&&i===null&&(i=String(c))}!this.value&&i!==null&&(this.value=i)}),b(this,m,t=>{t.target===this||!t.composedPath().find(e=>e?.tagName?.toLowerCase()==="scb-radio-button")||(t.stopImmediatePropagation(),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})))}),b(this,v,t=>{if(t.target===this)return;const i=t.composedPath().find(c=>c?.tagName?.toLowerCase()==="scb-radio-button");if(!i)return;t.stopImmediatePropagation();const e=i?.checked===!0,s=e?i?.value??i?.getAttribute?.("value")??t.target?.value??"":"";this.value=String(s??"");const a={value:String(s??""),checked:e,originalIsTrusted:t?.isTrusted===!0};this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("scb-change",{detail:a,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("scbchange",{detail:a,bubbles:!0,composed:!0}))}),"attachInternals"in this&&(this._internals=this.attachInternals())}render(){const t=this.orientation==="horizontal"?"row":"column";return A`
|
|
2
2
|
<div
|
|
3
3
|
class="g"
|
|
4
4
|
role="radiogroup"
|
|
5
5
|
aria-disabled=${String(this.disabled)}
|
|
6
|
+
aria-required=${String(this.required)}
|
|
7
|
+
aria-invalid=${o(this,r,_).call(this)?"true":"false"}
|
|
6
8
|
aria-label=${this.ariaLabel??""}
|
|
7
9
|
style=${`--_dir:${t}`}
|
|
8
10
|
>
|
|
9
|
-
<slot @slotchange=${
|
|
11
|
+
<slot @slotchange=${d(this,p)}></slot>
|
|
10
12
|
</div>
|
|
11
|
-
`}firstUpdated(){
|
|
13
|
+
`}firstUpdated(){o(this,r,k).call(this),d(this,p).call(this),this.addEventListener("input",d(this,m)),this.addEventListener("change",d(this,v)),this._initialValue=this.value,this._form=this.closest("form"),this._form&&(this._formResetHandler=()=>{this.value=this._initialValue,this.requestUpdate(),d(this,p).call(this),this.__syncFormValue(),o(this,r,g).call(this)},this._form.addEventListener("reset",this._formResetHandler,!0)),this.__syncFormValue(),o(this,r,g).call(this)}disconnectedCallback(){this.removeEventListener("input",d(this,m)),this.removeEventListener("change",d(this,v)),this._form&&this._formResetHandler&&this._form.removeEventListener("reset",this._formResetHandler,!0),super.disconnectedCallback()}updated(t){(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom")||t.has("spacingLeft")||t.has("spacingRight"))&&o(this,r,k).call(this),(t.has("name")||t.has("disabled")||t.has("orientation")||t.has("size")||t.has("deselectable")||t.has("required")||t.has("value"))&&d(this,p).call(this),(t.has("value")||t.has("disabled")||t.has("name"))&&this.__syncFormValue(),(t.has("value")||t.has("disabled")||t.has("required"))&&o(this,r,g).call(this)}get form(){return this._internals?.form??this._form}get validity(){return this._internals?.validity}get validationMessage(){return this._internals?.validationMessage??""}get willValidate(){return this._internals?.willValidate??!this.disabled}get labels(){return this._internals?.labels}checkValidity(){return this._internals?.checkValidity()??!o(this,r,_).call(this)}reportValidity(){return this._internals?.reportValidity()??!o(this,r,_).call(this)}setCustomValidity(t){this._customValidationMessage=String(t??""),o(this,r,g).call(this)}formDisabledCallback(t){this.disabled=t,o(this,r,g).call(this)}__syncFormValue(){if(!this._internals)return;const t=typeof this.name=="string"&&this.name.trim()!=="",i=typeof this.value=="string"&&this.value.trim()!=="",e=this.disabled||!t||!i?null:this.value;this._internals.setFormValue(e)}};y=new WeakMap;p=new WeakMap;m=new WeakMap;v=new WeakMap;r=new WeakSet;_=function(){return this.disabled?!1:this._customValidationMessage?!0:this.required&&!this.value.trim()};g=function(){if(!this._internals)return;const t=!this.disabled&&this.required&&!this.value.trim(),i=this._customValidationMessage||(t?"Välj ett alternativ.":"");this._internals.setValidity(t?{valueMissing:!0}:{},i,this.shadowRoot?.querySelector(".g")??void 0)};k=function(){const t=o(this,r,f).call(this,this.spacing),i=o(this,r,f).call(this,this.spacingTop)??t,e=o(this,r,f).call(this,this.spacingBottom)??t,s=o(this,r,f).call(this,this.spacingLeft),a=o(this,r,f).call(this,this.spacingRight);i?this.style.setProperty("--scb-radio-group-spacing-block-start",i):this.style.removeProperty("--scb-radio-group-spacing-block-start"),e?this.style.setProperty("--scb-radio-group-spacing-block-end",e):this.style.removeProperty("--scb-radio-group-spacing-block-end"),s?this.style.setProperty("--scb-radio-group-spacing-inline-start",s):this.style.removeProperty("--scb-radio-group-spacing-inline-start"),a?this.style.setProperty("--scb-radio-group-spacing-inline-end",a):this.style.removeProperty("--scb-radio-group-spacing-inline-end")};f=function(t){if(!t)return;const i=String(t).trim();if(i)return/^\d+$/.test(i)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(i,10)))})`:i};n.formAssociated=!0;n.styles=E`
|
|
12
14
|
:host {
|
|
13
15
|
display: block;
|
|
14
16
|
|
|
@@ -38,4 +40,4 @@ import{a as E,n as o,i as w,x as C,t as A}from"../../vendor/vendor.js";(function
|
|
|
38
40
|
::slotted(scb-radio-button) {
|
|
39
41
|
--scb-radio-gap: 0;
|
|
40
42
|
}
|
|
41
|
-
`;
|
|
43
|
+
`;l([h({type:String})],n.prototype,"name",2);l([h({type:String,reflect:!0})],n.prototype,"orientation",2);l([h({type:Boolean,reflect:!0})],n.prototype,"disabled",2);l([h({type:Boolean,reflect:!0})],n.prototype,"required",2);l([h({type:Boolean,reflect:!0})],n.prototype,"deselectable",2);l([h({type:String,reflect:!0})],n.prototype,"size",2);l([h({type:String,attribute:"aria-label"})],n.prototype,"ariaLabel",2);l([h({type:String,reflect:!0})],n.prototype,"spacing",2);l([h({type:String,attribute:"spacing-top",reflect:!0})],n.prototype,"spacingTop",2);l([h({type:String,attribute:"spacing-bottom",reflect:!0})],n.prototype,"spacingBottom",2);l([h({type:String,attribute:"spacing-left",reflect:!0})],n.prototype,"spacingLeft",2);l([h({type:String,attribute:"spacing-right",reflect:!0})],n.prototype,"spacingRight",2);l([h({type:String,reflect:!0})],n.prototype,"value",2);n=l([L("scb-radio-group")],n);
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import{a as y,n as c,i as x,E as
|
|
1
|
+
import{a as y,n as c,i as x,E as g,x as p,t as w}from"../../vendor/vendor.js";import"../scb-list/scb-list.js";import"../../vendor/vendor-material.js";import"../../vendor/preload-helper.js";import"../scb-list/scb-list-item.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,r,s){try{customElements.get(i)||e(i,r,s)}catch(o){var n=String(o||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw o}}}}catch{}})();var S=Object.defineProperty,A=Object.getOwnPropertyDescriptor,l=(t,e,i,r)=>{for(var s=r>1?void 0:r?A(e,i):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(r?o(e,i,s):o(s))||s);return r&&s&&S(e,i,s),s};let k=0,a=class extends x{constructor(){super(),this._internals=null,this.supportingText="",this.value="",this.name="",this.disabled=!1,this.required=!1,this.autocomplete=!1,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.size="large",this.fullScreen=!1,this._inputFocused=!1,this._visibleSuggestions=0,this._activeIndex=-1,this._listboxId=`scb-search-listbox-${++k}`,this._kbMode=!1,this._valueOnFocus="",this._lastChangeValue="",this._kbShouldShowRing=!1,this._onGlobalKeydown=t=>{t.key==="Tab"&&(this._kbShouldShowRing=!0,this._inputFocused&&this._updateInputRingVisibility())},this._onGlobalPointerDown=()=>{this._kbShouldShowRing=!1,this._inputFocused&&this._updateInputRingVisibility()},this._form=null,this._formResetHandler=null,this._formSubmitHandler=null,this._initialValue="",this._customValidationMessage="",this._listScrollHandler=()=>{const t=this._getActiveItem();this._kbMode&&t&&this._positionOptionRing(t)},"attachInternals"in this&&(this._internals=this.attachInternals())}_syncDensityForSize(){this.size==="small"?this.setAttribute("data-density","-4"):this.size==="medium"?this.setAttribute("data-density","-2"):this.removeAttribute("data-density")}connectedCallback(){super.connectedCallback(),this._syncDensityForSize(),this._onWindowResize=this._onWindowResize.bind(this),window.addEventListener("resize",this._onWindowResize,{passive:!0}),window.addEventListener("keydown",this._onGlobalKeydown,!0),window.addEventListener("pointerdown",this._onGlobalPointerDown,!0),this._initialValue=this.value??"",this._lastChangeValue=this.value??"",this._form=this.closest("form"),this._form&&(this._formSubmitHandler=t=>{this.reportValidity()||(t.preventDefault(),t.stopPropagation())},this._form.addEventListener("submit",this._formSubmitHandler,!0),this._formResetHandler=()=>{this.value=this._initialValue;const t=this._inputEl();t&&(t.value=this._initialValue),this._lastChangeValue=this._initialValue,this._syncFormValue(),this._filterSuggestions(this.value),this._activeIndex=-1,this._kbMode=!1,this._updateComboboxA11y()},this._form.addEventListener("reset",this._formResetHandler,!0)),this._syncFormValue(),this._syncValidity()}disconnectedCallback(){const t=this._inputEl();t&&this._boundNativeKeydown&&t.removeEventListener("keydown",this._boundNativeKeydown,!0),this._detachListScrollListener(),window.removeEventListener("resize",this._onWindowResize),window.removeEventListener("keydown",this._onGlobalKeydown,!0),window.removeEventListener("pointerdown",this._onGlobalPointerDown,!0),this._form&&this._formResetHandler&&this._form.removeEventListener("reset",this._formResetHandler,!0),this._form&&this._formSubmitHandler&&this._form.removeEventListener("submit",this._formSubmitHandler,!0),super.disconnectedCallback()}firstUpdated(){this._ensureListboxA11y(),this._updateComboboxA11y();const t=this._inputEl();t&&(this._boundNativeKeydown=e=>this._handleKey(e),t.addEventListener("keydown",this._boundNativeKeydown,!0),t.disabled=this.disabled),this.applySpacing()}updated(t){if(super.updated(t),t.has("size")&&this._syncDensityForSize(),this._ensureListboxA11y(),this._updateComboboxA11y(),this._attachListScrollListener(),(t.has("value")||t.has("disabled"))&&this._syncFormValue(),(t.has("value")||t.has("disabled")||t.has("required"))&&this._syncValidity(),t.has("disabled")){this.toggleAttribute("aria-disabled",this.disabled);const e=this._inputEl();e&&(e.disabled=this.disabled)}(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom")||t.has("spacingLeft")||t.has("spacingRight"))&&this.applySpacing()}render(){const t=(this.value??"").trim().length>0,e=this._inputFocused&&t&&this._hasSuggestions;return p`
|
|
2
2
|
<div class="ripple-wrapper">
|
|
3
3
|
<md-icon class="leading">${t?"arrow_back":"search"}</md-icon>
|
|
4
4
|
|
|
5
5
|
<input
|
|
6
6
|
id="searchInput"
|
|
7
7
|
type="search"
|
|
8
|
-
name=${this.name||"textfield"}
|
|
9
8
|
class=${e?"with-list":""}
|
|
10
9
|
.value=${this.value}
|
|
11
10
|
placeholder=${this.supportingText}
|
|
12
11
|
autocomplete=${this.autocomplete?"on":"off"}
|
|
13
12
|
?disabled=${this.disabled}
|
|
13
|
+
?required=${this.required}
|
|
14
14
|
@input=${this._onInput}
|
|
15
15
|
@change=${this._onNativeChange}
|
|
16
16
|
@focus=${this._onFocus}
|
|
@@ -27,7 +27,7 @@ import{a as y,n as c,i as x,E as b,x as p,t as w}from"../../vendor/vendor.js";im
|
|
|
27
27
|
aria-label="Rensa sökfält"
|
|
28
28
|
>
|
|
29
29
|
<md-icon>close</md-icon>
|
|
30
|
-
</button>`:this.trailingIcon?p`<span class="trailing"><md-icon>${this.trailingIcon}</md-icon></span>`:
|
|
30
|
+
</button>`:this.trailingIcon?p`<span class="trailing"><md-icon>${this.trailingIcon}</md-icon></span>`:g}
|
|
31
31
|
|
|
32
32
|
<md-ripple></md-ripple>
|
|
33
33
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
@@ -40,8 +40,8 @@ import{a as y,n as c,i as x,E as b,x as p,t as w}from"../../vendor/vendor.js";im
|
|
|
40
40
|
<slot @slotchange=${this._onSlotChange}></slot>
|
|
41
41
|
</scb-list>
|
|
42
42
|
<md-focus-ring id="optionRing" class="option-ring"></md-focus-ring>
|
|
43
|
-
`:
|
|
44
|
-
`}formDisabledCallback(t){this.disabled=t}submit(){const t=this._getActiveItem(),e={value:this.value};t&&(e.active=this._itemPayload(t)),this._dispatchSubmit(e)}get _hasSuggestions(){return this._visibleSuggestions>=0?this._visibleSuggestions>0:Array.from(this.getElementsByTagName("scb-list-item")).some(e=>!e.hasAttribute("hidden")&&e.style.display!=="none")}_onSlotChange(){this._filterSuggestions(this.value)}_onInput(t){t.stopPropagation();const e=t.target;this.value=e.value,this._syncFormValue(),this._filterSuggestions(this.value),this._activeIndex=-1,this._kbMode=!1,this._updateComboboxA11y();const i={value:this.value};this.dispatchEvent(new CustomEvent("scb-search-input",{detail:i,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("scbsearchinput",{detail:i,bubbles:!0,composed:!0})),this._dispatchStandardInput()}_onNativeChange(t){t.stopPropagation()}_onFocus(){this.disabled||(this._valueOnFocus=this.value??"",this._inputFocused=!0,this._updateInputRingVisibility(),this._filterSuggestions(this.value),this._updateComboboxA11y(),this.requestUpdate())}_onBlur(){setTimeout(()=>{this._inputFocused=!1,this._activeIndex=-1,this._kbMode=!1,this._updateInputRingVisibility(),this._updateComboboxA11y(),this._hideOptionRing(),this._valueOnFocus!==(this.value??"")&&this._dispatchStandardChangeIfNeeded(),this.requestUpdate()},100)}_updateInputRingVisibility(){const t=this.renderRoot?.querySelector(".ripple-wrapper");t&&(this._inputFocused&&this._kbShouldShowRing?t.setAttribute("data-kb-focus","true"):t.removeAttribute("data-kb-focus"))}_handleKey(t){if(this.disabled||!this._inputEl())return;const i=this._getVisibleItems(),
|
|
43
|
+
`:g}
|
|
44
|
+
`}formDisabledCallback(t){this.disabled=t}_getValidationMessage(){return this._customValidationMessage?this._customValidationMessage:this.required&&!(this.value??"").trim()?"Fyll i det här fältet.":""}_syncValidity(){const t=this._inputEl(),e=this.disabled?"":this._getValidationMessage();t&&(t.setCustomValidity(e),t.setAttribute("aria-invalid",e?"true":"false")),this._internals&&(e?this._internals.setValidity({valueMissing:!0},e,t??void 0):this._internals.setValidity({})),this.toggleAttribute("aria-invalid",!!e)}checkValidity(){return!this._getValidationMessage()}reportValidity(){this._syncValidity();const t=this._inputEl();return t?t.reportValidity():this._internals?this._internals.reportValidity():this.checkValidity()}setCustomValidity(t){this._customValidationMessage=t,this._syncValidity()}get validity(){return this._internals?.validity}get validationMessage(){return this._internals?.validationMessage??this._getValidationMessage()}get willValidate(){return this._internals?.willValidate??!0}submit(){const t=this._getActiveItem(),e={value:this.value};t&&(e.active=this._itemPayload(t)),this._dispatchSubmit(e)}get _hasSuggestions(){return this._visibleSuggestions>=0?this._visibleSuggestions>0:Array.from(this.getElementsByTagName("scb-list-item")).some(e=>!e.hasAttribute("hidden")&&e.style.display!=="none")}_onSlotChange(){this._filterSuggestions(this.value)}_onInput(t){t.stopPropagation();const e=t.target;this.value=e.value,this._syncFormValue(),this._filterSuggestions(this.value),this._activeIndex=-1,this._kbMode=!1,this._updateComboboxA11y();const i={value:this.value};this.dispatchEvent(new CustomEvent("scb-search-input",{detail:i,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("scbsearchinput",{detail:i,bubbles:!0,composed:!0})),this._dispatchStandardInput()}_onNativeChange(t){t.stopPropagation()}_onFocus(){this.disabled||(this._valueOnFocus=this.value??"",this._inputFocused=!0,this._updateInputRingVisibility(),this._filterSuggestions(this.value),this._updateComboboxA11y(),this.requestUpdate())}_onBlur(){setTimeout(()=>{this._inputFocused=!1,this._activeIndex=-1,this._kbMode=!1,this._updateInputRingVisibility(),this._updateComboboxA11y(),this._hideOptionRing(),this._valueOnFocus!==(this.value??"")&&this._dispatchStandardChangeIfNeeded(),this.requestUpdate()},100)}_updateInputRingVisibility(){const t=this.renderRoot?.querySelector(".ripple-wrapper");t&&(this._inputFocused&&this._kbShouldShowRing?t.setAttribute("data-kb-focus","true"):t.removeAttribute("data-kb-focus"))}_handleKey(t){if(this.disabled||!this._inputEl())return;const i=this._getVisibleItems(),r=(this.value??"").trim().length>0,s=this._inputFocused&&r&&i.length>0,n=t.key,o=t.keyCode,h=n==="ArrowDown"||n==="Down"||o===40,d=n==="ArrowUp"||n==="Up"||o===38,v=n==="Home"||o===36,_=n==="End"||o===35,m=n==="Enter"||o===13,f=n==="Escape"||n==="Esc"||o===27;if(h){if(!s)return;t.preventDefault(),this._kbMode=!0,this._moveActive(i,1);return}if(d){if(!s)return;t.preventDefault(),this._kbMode=!0,this._moveActive(i,-1);return}if(v){if(!s)return;t.preventDefault(),this._kbMode=!0,this._activeIndex=i.length?0:-1,this._updateComboboxA11y(),this._scrollActiveIntoView();return}if(_){if(!s)return;t.preventDefault(),this._kbMode=!0,this._activeIndex=i.length?i.length-1:-1,this._updateComboboxA11y(),this._scrollActiveIntoView();return}if(m){if(!s){const u=this._internals?.form??this._form??this.closest("form");u?(t.preventDefault(),this.reportValidity()&&u.requestSubmit()):this.submit();return}t.preventDefault();const b=this._getActiveItem();if(b){const u=b.getAttribute("label")||"";this.value=u,this._syncFormValue(),this._dispatchStandardInput(),this._dispatchSubmit({value:this.value,active:this._itemPayload(b)}),this._visibleSuggestions=0,this._activeIndex=-1,this._kbMode=!1,this._hideOptionRing(),this.requestUpdate()}else this.submit();return}if(f){t.preventDefault(),this._clearInput();return}}_clearInput(){if(this.disabled)return;this.value="",this._activeIndex=-1,this._kbMode=!1;const t=this._inputEl();t&&(t.value="",t.focus()),this._filterSuggestions(""),this._updateComboboxA11y(),this._hideOptionRing(),this._syncFormValue(),this._dispatchStandardInput(),this.dispatchEvent(new CustomEvent("scb-search-clear",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("scbsearchclear",{bubbles:!0,composed:!0})),this._dispatchStandardChangeIfNeeded()}_filterSuggestions(t){const e=(t??"").trim().toLowerCase(),i=Array.from(this.querySelectorAll("scb-list-item"));let r=0;for(const s of i){const n=(s.getAttribute("label")||"").toLowerCase(),o=(s.getAttribute("supporting-text")||"").toLowerCase(),h=`${n} ${o}`.trim();e!==""&&h.includes(e)?(s.removeAttribute("hidden"),r++):s.setAttribute("hidden",""),this._ensureOptionA11y(s)}this._visibleSuggestions=r,this._activeIndex>=r&&(this._activeIndex=-1),this._updateComboboxA11y(),this.requestUpdate()}_inputEl(){return this.renderRoot?.querySelector("#searchInput")??null}_listEl(){return this.renderRoot?.querySelector("scb-list.suggestion-list")??null}_ringEl(){return this.renderRoot?.querySelector("#optionRing")??null}_getVisibleItems(){return Array.from(this.querySelectorAll("scb-list-item")).filter(e=>!e.hasAttribute("hidden")&&e.style.display!=="none")}_getActiveItem(){const t=this._getVisibleItems();return this._activeIndex<0||this._activeIndex>=t.length?null:t[this._activeIndex]??null}_moveActive(t,e){if(!t.length){this._activeIndex=-1,this._updateComboboxA11y(),this._hideOptionRing();return}let i=this._activeIndex+e;this._activeIndex===-1?i=e>0?0:t.length-1:(i<0&&(i=0),i>=t.length&&(i=t.length-1)),this._activeIndex=i,this._updateComboboxA11y(),this._scrollActiveIntoView()}_scrollActiveIntoView(){const t=this._getActiveItem();t&&t.scrollIntoView({block:"nearest"})}_itemPayload(t){return{label:t.getAttribute("label")||"",supportingText:t.getAttribute("supporting-text")||"",href:t.getAttribute("href")||"",type:t.getAttribute("type")||"",id:t.id||""}}_ensureListboxA11y(){const t=this._listEl();t&&(t.id||(t.id=this._listboxId),t.setAttribute("role","listbox"),t.setAttribute("aria-label","Sökförslag")),Array.from(this.querySelectorAll("scb-list-item")).forEach(i=>this._ensureOptionA11y(i))}_ensureOptionA11y(t){t.id||(t.id=`${this._listboxId}-opt-${Math.random().toString(36).slice(2,8)}`),t.setAttribute("role","option"),t.setAttribute("tabindex","-1")}_updateComboboxA11y(){const t=this._inputEl();if(!t)return;const e=this._getVisibleItems(),i=(this.value??"").trim().length>0,r=this._inputFocused&&i&&e.length>0;t.setAttribute("role","combobox"),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-controls",this._listboxId),t.setAttribute("aria-expanded",String(r));const s=r?this._getActiveItem():null;s?.id?t.setAttribute("aria-activedescendant",s.id):t.removeAttribute("aria-activedescendant"),this._kbMode&&s&&r?this._positionOptionRing(s):this._hideOptionRing()}_positionOptionRing(t){const e=this._ringEl(),i=this._listEl();if(!e||!i)return;const r=this.getBoundingClientRect(),s=t.getBoundingClientRect(),n=s.top-r.top,o=s.left-r.left,h=s.width,d=s.height;e.style.top=`${n}px`,e.style.left=`${o}px`,e.style.width=`${h}px`,e.style.height=`${d}px`,e.setAttribute("data-show","true")}_hideOptionRing(){const t=this._ringEl();t&&t.removeAttribute("data-show")}_onWindowResize(){const t=this._getActiveItem();this._kbMode&&t&&this._positionOptionRing(t)}_attachListScrollListener(){const t=this._listEl();!t||this._listWithHandler===t||(this._detachListScrollListener(),t.addEventListener("scroll",this._listScrollHandler,{passive:!0}),this._listWithHandler=t)}_detachListScrollListener(){this._listWithHandler&&(this._listWithHandler.removeEventListener("scroll",this._listScrollHandler),this._listWithHandler=void 0)}_dispatchStandardInput(){this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0}))}_dispatchStandardChangeIfNeeded(){const t=this.value??"";t!==this._lastChangeValue&&(this._lastChangeValue=t,this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}_dispatchSubmit(t){this.dispatchEvent(new CustomEvent("scb-search-submit",{detail:t,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("scbsearchsubmit",{detail:t,bubbles:!0,composed:!0})),this._dispatchStandardChangeIfNeeded()}mapSpacingToken(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}applySpacing(){const t=this.mapSpacingToken(this.spacing),e=this.mapSpacingToken(this.spacingTop)??t,i=this.mapSpacingToken(this.spacingBottom)??t,r=this.mapSpacingToken(this.spacingLeft),s=this.mapSpacingToken(this.spacingRight);e?this.style.setProperty("--scb-search-spacing-block-start",e):this.style.removeProperty("--scb-search-spacing-block-start"),i?this.style.setProperty("--scb-search-spacing-block-end",i):this.style.removeProperty("--scb-search-spacing-block-end"),r?this.style.setProperty("--scb-search-spacing-inline-start",r):this.style.removeProperty("--scb-search-spacing-inline-start"),s?this.style.setProperty("--scb-search-spacing-inline-end",s):this.style.removeProperty("--scb-search-spacing-inline-end")}_syncFormValue(){if(!this._internals)return;const t=this.disabled?null:this.value;this._internals.setFormValue(t)}};a.formAssociated=!0;a.styles=y`
|
|
45
45
|
:host {
|
|
46
46
|
display: flex;
|
|
47
47
|
flex-direction: column;
|
|
@@ -289,4 +289,4 @@ import{a as y,n as c,i as x,E as b,x as p,t as w}from"../../vendor/vendor.js";im
|
|
|
289
289
|
color: var(--md-sys-color-on-surface);
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
|
-
`;l([c({type:String,attribute:"trailing-icon"})],
|
|
292
|
+
`;l([c({type:String,attribute:"trailing-icon"})],a.prototype,"trailingIcon",2);l([c({type:String,attribute:"supporting-text"})],a.prototype,"supportingText",2);l([c({type:String})],a.prototype,"value",2);l([c({type:String,reflect:!0})],a.prototype,"name",2);l([c({type:Boolean,reflect:!0})],a.prototype,"disabled",2);l([c({type:Boolean,reflect:!0})],a.prototype,"required",2);l([c({type:Boolean,reflect:!0})],a.prototype,"autocomplete",2);l([c({type:String,reflect:!0})],a.prototype,"spacing",2);l([c({type:String,attribute:"spacing-top",reflect:!0})],a.prototype,"spacingTop",2);l([c({type:String,attribute:"spacing-bottom",reflect:!0})],a.prototype,"spacingBottom",2);l([c({type:String,attribute:"spacing-left",reflect:!0})],a.prototype,"spacingLeft",2);l([c({type:String,attribute:"spacing-right",reflect:!0})],a.prototype,"spacingRight",2);l([c({type:String,reflect:!0})],a.prototype,"size",2);l([c({type:Boolean,attribute:"full-screen",reflect:!0})],a.prototype,"fullScreen",2);a=l([w("scb-search")],a);
|