scb-wc-test 0.1.324 → 0.1.325
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.
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import{a as m,n as s,i as g,E as
|
|
1
|
+
import{a as m,n as s,i as g,E as u,x as l,t as f}from"../../vendor/vendor.js";import"../scb-button/scb-button.js";import"../scb-icon-button/scb-icon-button.js";import"../scb-textfield/scb-textfield.js";import"../scb-checkbox/scb-checkbox.js";import"../scb-radio-button/scb-radio-button.js";import"../scb-switch/scb-switch.js";import"../scb-chip/scb-chip.js";import"../../vendor/vendor-material.js";import"../../vendor/preload-helper.js";import"../scb-datepicker/scb-datepicker.js";import"../scb-divider/scb-divider.js";import"../scb-checkbox/scb-checkbox-group.js";import"../scb-radio-button/scb-radio-group.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,a,r){try{customElements.get(e)||i(e,a,r)}catch(c){var d=String(c||"");if(d.indexOf("already been used")===-1&&d.indexOf("NotSupportedError")===-1)throw c}}}}catch{}})();var b=Object.defineProperty,v=Object.getOwnPropertyDescriptor,o=(t,i,e,a)=>{for(var r=a>1?void 0:a?v(i,e):i,d=t.length-1,c;d>=0;d--)(c=t[d])&&(r=(a?c(i,e,r):c(r))||r);return a&&r&&b(i,e,r),r};let n=class extends g{constructor(){super(...arguments),this.open=!1,this.inSb=!1,this.scrimClose=!0,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.variant="basic",this.label="",this.icon="",this.supportingText="",this.okButton="OK",this.cancelButton="Avbryt",this.deleteButton="Delete",this.confirmButton="Ta bort",this.denyButton="Avbryt",this.resetButton="Återställ",this.submitButton="Spara",this.formId="",this.formAction="",this.formMethod="",this.__lastTriggerEl=null,this.__onDocumentClick=t=>{this.__getActionFromEvent(t)==="toggle"&&(this.__setOpen(!this.open),t.stopPropagation())},this.__onDocumentKeydown=t=>{this.open&&t.key==="Escape"&&(this.__fire("esc"),this.__setOpen(!1))},this.__onScrimClick=()=>{this.scrimClose&&(this.__fire("scrim"),this.__setOpen(!1))},this.__onOk=()=>{this.__fire("ok"),this.__setOpen(!1)},this.__onCancel=()=>{this.__fire("cancel"),this.__setOpen(!1)},this.__onConfirm=()=>{this.__fire("confirm"),this.__setOpen(!1)},this.__onDeny=()=>{this.__fire("deny"),this.__setOpen(!1)},this.__onReset=()=>{const t=this.shadowRoot?.querySelector("form");t instanceof HTMLFormElement&&(this.__clearGeneratedFormValues(t),t.reset()),(this.shadowRoot?.querySelector("slot")?.assignedElements({flatten:!0})??[]).forEach(e=>{const a=e.tagName;a==="SCB-TEXTFIELD"&&(e.value=""),a==="SCB-CHECKBOX"&&(e.checked=!1),a==="SCB-RADIO-BUTTON"&&(e.checked=!1),a==="SCB-SWITCH"&&(e.selected=!1),a==="SCB-CHIP"&&(e.selected=!1)}),this.__fire("reset")},this.__onSubmit=()=>{const t=this.shadowRoot?.querySelector("form");if(t instanceof HTMLFormElement){if(this.__syncSlottedFormValues(t),!this.__validateFormAndSlottedFields(t))return;t.requestSubmit()}this.__fire("submit"),this.__setOpen(!1)},this.__onKeydownTrap=t=>{if(!this.open||t.key!=="Tab")return;const i=Array.from(this.shadowRoot.querySelectorAll('button,[href],input,select,textarea,[tabindex]:not([tabindex="-1"])')).filter(r=>!r.hasAttribute("disabled"));if(!i.length)return;const e=i[0],a=i[i.length-1];t.shiftKey&&document.activeElement===e?(a.focus(),t.preventDefault()):!t.shiftKey&&document.activeElement===a&&(e.focus(),t.preventDefault())}}__getActionFromEvent(t){if(!this.id)return null;for(const i of t.composedPath())if(i instanceof Element){if(i.getAttribute("data-dialog-toggle")===this.id)return this.__lastTriggerEl=i,"toggle";if(i.getAttribute("aria-controls")===this.id)return this.__lastTriggerEl=i,"toggle"}return null}connectedCallback(){super.connectedCallback(),this.__applyZIndex(),this.__applyMaxSize(),document.addEventListener("click",this.__onDocumentClick,!1),document.addEventListener("keydown",this.__onDocumentKeydown,!0),this.addEventListener("keydown",this.__onKeydownTrap)}disconnectedCallback(){document.removeEventListener("click",this.__onDocumentClick,!1),document.removeEventListener("keydown",this.__onDocumentKeydown,!0),this.removeEventListener("keydown",this.__onKeydownTrap),super.disconnectedCallback()}__applyZIndex(){const t=typeof this.zIndex=="number"&&Number.isFinite(this.zIndex)?this.zIndex:void 0;if(t===void 0){this.style.removeProperty("--z-dialog-scrim"),this.style.removeProperty("--z-dialog");return}this.style.setProperty("--z-dialog-scrim",String(t)),this.style.setProperty("--z-dialog",String(t+1))}__applyMaxSize(){const t=(this.maxW??"").trim(),i=(this.maxH??"").trim();t?(this.style.setProperty("--scb-dialog-max-w",t),this.style.setProperty("--scb-dialog-width",`min(${t}, 90vw)`)):(this.style.removeProperty("--scb-dialog-max-w"),this.style.removeProperty("--scb-dialog-width")),i?this.style.setProperty("--scb-dialog-max-h",i):this.style.removeProperty("--scb-dialog-max-h")}updated(t){if(t.has("zIndex")&&this.__applyZIndex(),(t.has("maxW")||t.has("maxH"))&&this.__applyMaxSize(),t.has("open")){const i=t.get("open");this.__updateTriggersExpanded(),this.open&&!i?this.updateComplete.then(()=>{const e=this.shadowRoot?.querySelector('button,[href],input,select,textarea,[tabindex]:not([tabindex="-1"])');e?e.focus():this.shadowRoot?.querySelector(".container")?.focus()}):!this.open&&i&&this.__lastTriggerEl?.focus?.(),this.__toggleScrollLock(this.open)}(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom")||t.has("spacingLeft")||t.has("spacingRight"))&&this.__applySpacing()}__updateTriggersExpanded(){this.id&&document.querySelectorAll(`[aria-controls="${this.id}"], [data-dialog-toggle="${this.id}"]`).forEach(t=>{t.hasAttribute("aria-controls")&&t.setAttribute("aria-expanded",String(this.open))})}__toggleScrollLock(t){if(this.inSb)return;const i=document.documentElement,e=document.body;if(t){const a=window.innerWidth-i.clientWidth;i.style.overflow="hidden",e.style.paddingRight=a>0?`${a}px`:"";return}i.style.overflow="",e.style.paddingRight=""}mapSpacingToken(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}__applySpacing(){const t=this.mapSpacingToken(this.spacing),i=this.mapSpacingToken(this.spacingTop)??t,e=this.mapSpacingToken(this.spacingBottom)??t,a=this.mapSpacingToken(this.spacingLeft),r=this.mapSpacingToken(this.spacingRight);i?this.style.setProperty("--scb-dialog-spacing-block-start",i):this.style.removeProperty("--scb-dialog-spacing-block-start"),e?this.style.setProperty("--scb-dialog-spacing-block-end",e):this.style.removeProperty("--scb-dialog-spacing-block-end"),a?this.style.setProperty("--scb-dialog-spacing-inline-start",a):this.style.removeProperty("--scb-dialog-spacing-inline-start"),r?this.style.setProperty("--scb-dialog-spacing-inline-end",r):this.style.removeProperty("--scb-dialog-spacing-inline-end")}__setOpen(t){this.open=t,this.__fire(t?"open":"close")}__fire(t,i){this.dispatchEvent(new CustomEvent(t,{detail:i,bubbles:!0,composed:!0}))}__getSlottedElements(){const t=this.shadowRoot?.querySelector("slot");if(!(t instanceof HTMLSlotElement))return[];const i=t.assignedElements({flatten:!0}),e=[];for(const a of i)e.push(a,...Array.from(a.querySelectorAll("*")));return e}__appendHiddenFormValue(t,i,e){const a=document.createElement("input");a.type="hidden",a.name=i,a.value=e,a.setAttribute("data-scb-dialog-generated","true"),t.append(a)}__clearGeneratedFormValues(t){t.querySelectorAll('input[data-scb-dialog-generated="true"]').forEach(i=>i.remove())}__syncSlottedFormValues(t){this.__clearGeneratedFormValues(t),this.__getSlottedElements().forEach(e=>{if(!(e instanceof HTMLElement))return;const a=(e.getAttribute("name")??"").trim();if(!(!a||e.disabled===!0||e.hasAttribute("disabled"))){if(e instanceof HTMLInputElement){if(e.form===t)return;const d=(e.type||"").toLowerCase();if(d==="checkbox"||d==="radio"){e.checked&&this.__appendHiddenFormValue(t,a,e.value||"on");return}this.__appendHiddenFormValue(t,a,e.value??"");return}if(e instanceof HTMLTextAreaElement){if(e.form===t)return;this.__appendHiddenFormValue(t,a,e.value??"");return}if(e instanceof HTMLSelectElement){if(e.form===t)return;if(e.multiple){Array.from(e.selectedOptions).forEach(d=>{this.__appendHiddenFormValue(t,a,d.value)});return}this.__appendHiddenFormValue(t,a,e.value??"");return}switch(e.tagName){case"SCB-TEXTFIELD":this.__appendHiddenFormValue(t,a,String(e.value??""));return;case"SCB-CHECKBOX":e.checked&&this.__appendHiddenFormValue(t,a,String(e.value??e.getAttribute("value")??"on"));return;case"SCB-RADIO-BUTTON":e.checked&&this.__appendHiddenFormValue(t,a,String(e.value??e.getAttribute("value")??"on"));return;case"SCB-SWITCH":(e.selected||e.checked)&&this.__appendHiddenFormValue(t,a,String(e.value??e.getAttribute("value")??"on"));return;case"SCB-CHIP":e.selected&&this.__appendHiddenFormValue(t,a,String(e.value??e.getAttribute("value")??"on"));return;default:"value"in e&&this.__appendHiddenFormValue(t,a,String(e.value??""))}}})}__validateFormAndSlottedFields(t){const i=c=>c.disabled===!0||c.hasAttribute("disabled");let e=t.reportValidity(),a=null;const r=new Set;return this.__getSlottedElements().forEach(c=>{if(!(c instanceof HTMLElement)||r.has(c)||i(c))return;r.add(c);const p=c;if(c.tagName==="SCB-TEXTFIELD"&&p.error===!0){a||(a=c),e=!1;return}if(typeof p.reportValidity=="function"){const h=!!p.reportValidity();!h&&!a&&(a=c),e=e&&h}}),!e&&a&&a.focus(),e}__slotIsEmpty(){const t=this.shadowRoot?.querySelector("slot");return t?t.assignedElements({flatten:!0}).length===0:!0}renderHeader(t){const i=this.variant==="form"||this.variant==="floating"||this.variant==="iframe";return l`
|
|
2
2
|
<div class="header">
|
|
3
3
|
<div class="title">
|
|
4
|
-
${this.icon?
|
|
4
|
+
${this.icon?l`<md-icon class="dialog-icon">${this.icon}</md-icon>`:u}
|
|
5
5
|
<div class="label" id=${t}>${this.label}</div>
|
|
6
6
|
</div>
|
|
7
|
-
${i?
|
|
7
|
+
${i?l`<scb-icon-button class="close" icon="close" @click=${this.__onCancel}></scb-icon-button>`:u}
|
|
8
8
|
</div>
|
|
9
|
-
`}renderContentDefault(t){const i=this.__slotIsEmpty();return
|
|
9
|
+
`}renderContentDefault(t){const i=this.__slotIsEmpty();return l`
|
|
10
10
|
<div class="content" id=${t}>
|
|
11
|
-
${i&&this.supportingText?
|
|
11
|
+
${i&&this.supportingText?l`${this.supportingText}`:l`<slot></slot>`}
|
|
12
12
|
</div>
|
|
13
|
-
`}renderContentIframe(t){const i=this.__slotIsEmpty();return
|
|
13
|
+
`}renderContentIframe(t){const i=this.__slotIsEmpty();return l`
|
|
14
14
|
<div class="content" id=${t}>
|
|
15
15
|
<div class="content-surface">
|
|
16
|
-
${i&&this.supportingText?
|
|
16
|
+
${i&&this.supportingText?l`${this.supportingText}`:l`<slot></slot>`}
|
|
17
17
|
</div>
|
|
18
18
|
</div>
|
|
19
|
-
`}renderActions(){switch(this.variant){case"alert":return
|
|
19
|
+
`}renderActions(){switch(this.variant){case"alert":return l`<div class="actions">
|
|
20
20
|
<scb-button variant="text" label=${this.okButton} @click=${this.__onOk}></scb-button>
|
|
21
|
-
</div>`;case"confirm":return
|
|
21
|
+
</div>`;case"confirm":return l`<div class="actions">
|
|
22
22
|
<scb-button variant="text" label=${this.confirmButton} @click=${this.__onConfirm}></scb-button>
|
|
23
23
|
<scb-button variant="text" label=${this.denyButton} @click=${this.__onDeny}></scb-button>
|
|
24
|
-
</div>`;case"choose":return
|
|
24
|
+
</div>`;case"choose":return l`<div class="actions">
|
|
25
25
|
<scb-button variant="text" label=${this.cancelButton} @click=${this.__onCancel}></scb-button>
|
|
26
26
|
<scb-button variant="text" label=${this.okButton} @click=${this.__onOk}></scb-button>
|
|
27
|
-
</div>`;case"form":return
|
|
27
|
+
</div>`;case"form":return l`<div class="actions">
|
|
28
28
|
<scb-button class="start" variant="text" label=${this.resetButton} @click=${this.__onReset}></scb-button>
|
|
29
29
|
<scb-button variant="text" label=${this.cancelButton} @click=${this.__onCancel}></scb-button>
|
|
30
30
|
<scb-button variant="text" type="submit" label=${this.submitButton} @click=${this.__onSubmit}></scb-button>
|
|
31
|
-
</div>`;case"floating":case"iframe":return
|
|
31
|
+
</div>`;case"floating":case"iframe":return u;default:return l`<div class="actions">
|
|
32
32
|
<scb-button variant="text" label=${this.cancelButton} @click=${this.__onCancel}></scb-button>
|
|
33
33
|
<scb-button variant="text" label=${this.okButton} @click=${this.__onOk}></scb-button>
|
|
34
|
-
</div>`}}renderBody(t,i){return this.variant==="form"?
|
|
34
|
+
</div>`}}renderBody(t,i){return this.variant==="form"?l`
|
|
35
35
|
${this.renderHeader(t)}
|
|
36
36
|
<div class="content" id=${i}>
|
|
37
|
-
<form id=${this.formId} action=${this.formAction} method=${this.formMethod||
|
|
37
|
+
<form id=${this.formId} action=${this.formAction} method=${this.formMethod||u}>
|
|
38
38
|
<slot></slot>
|
|
39
39
|
</form>
|
|
40
40
|
</div>
|
|
41
41
|
${this.renderActions()}
|
|
42
|
-
`:this.variant==="iframe"?
|
|
42
|
+
`:this.variant==="iframe"?l`${this.renderHeader(t)} ${this.renderContentIframe(i)} ${this.renderActions()}`:l`${this.renderHeader(t)} ${this.renderContentDefault(i)} ${this.renderActions()}`}render(){const t="dlg-title",i="dlg-desc";return l`
|
|
43
43
|
<div class="scrim" @click=${this.__onScrimClick} aria-hidden="true"></div>
|
|
44
44
|
<div
|
|
45
45
|
class="container"
|
|
@@ -51,7 +51,7 @@ import{a as m,n as s,i as g,E as p,x as c,t as f}from"../../vendor/vendor.js";im
|
|
|
51
51
|
>
|
|
52
52
|
${this.renderBody(t,i)}
|
|
53
53
|
</div>
|
|
54
|
-
`}};
|
|
54
|
+
`}};n.styles=m`
|
|
55
55
|
:host {
|
|
56
56
|
display:block;
|
|
57
57
|
position:relative;
|
|
@@ -262,4 +262,4 @@ import{a as m,n as s,i as g,E as p,x as c,t as f}from"../../vendor/vendor.js";im
|
|
|
262
262
|
to { opacity: 0; }
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
-
`;o([s({type:Boolean,reflect:!0})],
|
|
265
|
+
`;o([s({type:Boolean,reflect:!0})],n.prototype,"open",2);o([s({type:String,attribute:"max-w",reflect:!0})],n.prototype,"maxW",2);o([s({type:String,attribute:"max-h",reflect:!0})],n.prototype,"maxH",2);o([s({type:Number,attribute:"z-index",reflect:!0})],n.prototype,"zIndex",2);o([s({type:Boolean,attribute:!1})],n.prototype,"inSb",2);o([s({type:Boolean,attribute:"scrim-close"})],n.prototype,"scrimClose",2);o([s({type:String,reflect:!0})],n.prototype,"spacing",2);o([s({type:String,attribute:"spacing-top",reflect:!0})],n.prototype,"spacingTop",2);o([s({type:String,attribute:"spacing-bottom",reflect:!0})],n.prototype,"spacingBottom",2);o([s({type:String,attribute:"spacing-left",reflect:!0})],n.prototype,"spacingLeft",2);o([s({type:String,attribute:"spacing-right",reflect:!0})],n.prototype,"spacingRight",2);o([s({type:String})],n.prototype,"variant",2);o([s({type:String})],n.prototype,"label",2);o([s({type:String})],n.prototype,"icon",2);o([s({type:String,attribute:"supporting-text"})],n.prototype,"supportingText",2);o([s({type:String,attribute:"ok-button"})],n.prototype,"okButton",2);o([s({type:String,attribute:"cancel-button"})],n.prototype,"cancelButton",2);o([s({type:String,attribute:"delete-button"})],n.prototype,"deleteButton",2);o([s({type:String,attribute:"confirm-button"})],n.prototype,"confirmButton",2);o([s({type:String,attribute:"deny-button"})],n.prototype,"denyButton",2);o([s({type:String,attribute:"reset-button"})],n.prototype,"resetButton",2);o([s({type:String,attribute:"submit-button"})],n.prototype,"submitButton",2);o([s({type:String,attribute:"form-id"})],n.prototype,"formId",2);o([s({type:String,attribute:"form-action"})],n.prototype,"formAction",2);o([s({type:String,attribute:"form-method"})],n.prototype,"formMethod",2);n=o([f("scb-dialog")],n);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as _,n,r as w,i as $,x as
|
|
1
|
+
import{a as _,n as d,r as w,i as $,x as c,t as z}from"../../vendor/vendor.js";import"../../vendor/vendor-material.js";import"../scb-datepicker/scb-datepicker.js";import"../scb-icon-button/scb-icon-button.js";import"../scb-button/scb-button.js";import"../scb-divider/scb-divider.js";import"../../vendor/preload-helper.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,o,n){try{customElements.get(i)||t(i,o,n)}catch(h){var p=String(h||"");if(p.indexOf("already been used")===-1&&p.indexOf("NotSupportedError")===-1)throw h}}}}catch{}})();var k=Object.defineProperty,E=Object.getOwnPropertyDescriptor,v=e=>{throw TypeError(e)},r=(e,t,i,o)=>{for(var n=o>1?void 0:o?E(t,i):t,p=e.length-1,h;p>=0;p--)(h=e[p])&&(n=(o?h(t,i,n):h(n))||n);return o&&n&&k(t,i,n),n},S=(e,t,i)=>t.has(e)||v("Cannot "+i),L=(e,t,i)=>t.has(e)?v("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),a=(e,t,i)=>(S(e,t,"access private method"),i),l,g,b,u,x,m,y,f;let s=class extends ${constructor(){super(),L(this,l),this._internals=null,this._inputFocused=!1,this._kbShouldShowRing=!1,this._onGlobalKeydown=e=>{e.key==="Tab"&&(this._kbShouldShowRing=!0,this._inputFocused&&a(this,l,f).call(this))},this._onGlobalPointerDown=()=>{this._kbShouldShowRing=!1,this._inputFocused&&a(this,l,f).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)}a(this,l,u).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(this,l,f).call(this)},this._onFieldBlur=()=>{this._inputFocused=!1,a(this,l,f).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)}a(this,l,u).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?c`<md-icon class="scb-textfield-icon">${this.leadingIcon}</md-icon>`:null,t=this.error?c`<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?c`
|
|
2
2
|
<button
|
|
3
3
|
type="button"
|
|
4
4
|
class="scb-textfield-clear"
|
|
@@ -32,14 +32,14 @@ import{a as _,n,r as w,i as $,x as d,t as z}from"../../vendor/vendor.js";import"
|
|
|
32
32
|
></line>
|
|
33
33
|
</svg>
|
|
34
34
|
</button>
|
|
35
|
-
`:null;return this.type==="textarea"?
|
|
35
|
+
`:null;return this.type==="textarea"?c`
|
|
36
36
|
<label
|
|
37
37
|
class="scb-textfield-label ${this.underLabel?"":"scb-textfield-label--without-supporting"}"
|
|
38
38
|
for="${this._inputId}"
|
|
39
39
|
>
|
|
40
40
|
${this.label}
|
|
41
41
|
</label>
|
|
42
|
-
${this.underLabel?
|
|
42
|
+
${this.underLabel?c`
|
|
43
43
|
<span class="scb-textfield-supporting-text" id="${this._inputId}-supporting-text">
|
|
44
44
|
${this.underLabel}
|
|
45
45
|
</span>
|
|
@@ -60,14 +60,14 @@ import{a as _,n,r as w,i as $,x as d,t as z}from"../../vendor/vendor.js";import"
|
|
|
60
60
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
61
61
|
</div>
|
|
62
62
|
</div>
|
|
63
|
-
`:this.type==="date"?
|
|
63
|
+
`:this.type==="date"?c`
|
|
64
64
|
<label
|
|
65
65
|
class="scb-textfield-label ${this.underLabel?"":"scb-textfield-label--without-supporting"}"
|
|
66
66
|
for="${this._inputId}"
|
|
67
67
|
>
|
|
68
68
|
${this.label}
|
|
69
69
|
</label>
|
|
70
|
-
${this.underLabel?
|
|
70
|
+
${this.underLabel?c`
|
|
71
71
|
<span class="scb-textfield-supporting-text" id="${this._inputId}-supporting-text">
|
|
72
72
|
${this.underLabel}
|
|
73
73
|
</span>
|
|
@@ -92,7 +92,7 @@ import{a as _,n,r as w,i as $,x as d,t as z}from"../../vendor/vendor.js";import"
|
|
|
92
92
|
<md-ripple></md-ripple>
|
|
93
93
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
94
94
|
</div>
|
|
95
|
-
${this.error?t:
|
|
95
|
+
${this.error?t:c`
|
|
96
96
|
<scb-icon-button
|
|
97
97
|
class="scb-textfield-datepicker-button"
|
|
98
98
|
icon="calendar_today"
|
|
@@ -107,14 +107,14 @@ import{a as _,n,r as w,i as $,x as d,t as z}from"../../vendor/vendor.js";import"
|
|
|
107
107
|
@date-selected=${this._onDateSelected}
|
|
108
108
|
></scb-datepicker>
|
|
109
109
|
</div>
|
|
110
|
-
`:this.type==="datetime-local"?
|
|
110
|
+
`:this.type==="datetime-local"?c`
|
|
111
111
|
<label
|
|
112
112
|
class="scb-textfield-label ${this.underLabel?"":"scb-textfield-label--without-supporting"}"
|
|
113
113
|
for="${this._inputId}"
|
|
114
114
|
>
|
|
115
115
|
${this.label}
|
|
116
116
|
</label>
|
|
117
|
-
${this.underLabel?
|
|
117
|
+
${this.underLabel?c`
|
|
118
118
|
<span class="scb-textfield-supporting-text" id="${this._inputId}-supporting-text">
|
|
119
119
|
${this.underLabel}
|
|
120
120
|
</span>
|
|
@@ -141,7 +141,7 @@ import{a as _,n,r as w,i as $,x as d,t as z}from"../../vendor/vendor.js";import"
|
|
|
141
141
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
142
142
|
</div>
|
|
143
143
|
|
|
144
|
-
${this.error?t:
|
|
144
|
+
${this.error?t:c`
|
|
145
145
|
<scb-icon-button
|
|
146
146
|
class="scb-textfield-datepicker-button"
|
|
147
147
|
icon="calendar_today"
|
|
@@ -157,14 +157,14 @@ import{a as _,n,r as w,i as $,x as d,t as z}from"../../vendor/vendor.js";import"
|
|
|
157
157
|
@date-selected=${this._onDateSelected}
|
|
158
158
|
></scb-datepicker>
|
|
159
159
|
</div>
|
|
160
|
-
`:this.type==="time"?
|
|
160
|
+
`:this.type==="time"?c`
|
|
161
161
|
<label
|
|
162
162
|
class="scb-textfield-label ${this.underLabel?"":"scb-textfield-label--without-supporting"}"
|
|
163
163
|
for="${this._inputId}"
|
|
164
164
|
>
|
|
165
165
|
${this.label}
|
|
166
166
|
</label>
|
|
167
|
-
${this.underLabel?
|
|
167
|
+
${this.underLabel?c`
|
|
168
168
|
<span class="scb-textfield-supporting-text" id="${this._inputId}-supporting-text">
|
|
169
169
|
${this.underLabel}
|
|
170
170
|
</span>
|
|
@@ -182,21 +182,21 @@ import{a as _,n,r as w,i as $,x as d,t as z}from"../../vendor/vendor.js";import"
|
|
|
182
182
|
?required=${this.required}
|
|
183
183
|
aria-invalid=${this.error?"true":"false"}
|
|
184
184
|
aria-describedby=${i}
|
|
185
|
-
@input=${
|
|
185
|
+
@input=${n=>{const p=n.target;if(this.value=p.value,this._internals){const h=this.disabled?null:this.value;this._internals.setFormValue(h)}a(this,l,u).call(this),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("onValueChanged",{detail:{value:this.value},bubbles:!0,composed:!0}))}}
|
|
186
186
|
/>
|
|
187
187
|
${t}
|
|
188
188
|
<md-ripple></md-ripple>
|
|
189
189
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
190
190
|
</div>
|
|
191
191
|
</div>
|
|
192
|
-
`:
|
|
192
|
+
`:c`
|
|
193
193
|
<label
|
|
194
194
|
class="scb-textfield-label ${this.underLabel?"":"scb-textfield-label--without-supporting"}"
|
|
195
195
|
for="${this._inputId}"
|
|
196
196
|
>
|
|
197
197
|
${this.label}
|
|
198
198
|
</label>
|
|
199
|
-
${this.underLabel?
|
|
199
|
+
${this.underLabel?c`
|
|
200
200
|
<span class="scb-textfield-supporting-text" id="${this._inputId}-supporting-text">
|
|
201
201
|
${this.underLabel}
|
|
202
202
|
</span>
|
|
@@ -221,7 +221,7 @@ import{a as _,n,r as w,i as $,x as d,t as z}from"../../vendor/vendor.js";import"
|
|
|
221
221
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
222
222
|
</div>
|
|
223
223
|
</div>
|
|
224
|
-
`}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(this,l,x).call(this),a(this,l,g).call(this)}updated(e){if(super.updated(e),this.toggleAttribute("aria-disabled",this.disabled),e.has("size")&&this._syncDensityForSize(),this._internals&&(e.has("value")||e.has("disabled"))){const t=this.disabled?null:this.value;this._internals.setFormValue(t)}e.has("type")&&(a(this,l,x).call(this),this._hasRenderedOnce&&a(this,l,y).call(this)),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom")||e.has("spacingLeft")||e.has("spacingRight"))&&a(this,l,g).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(this,l,m).call(this),window.removeEventListener("keydown",this._onGlobalKeydown,!0),window.removeEventListener("pointerdown",this._onGlobalPointerDown,!0)}reportValidity(){return a(this,l,u).call(this,!0)}_onClearClick(){const e=this.shadowRoot?.querySelector(".scb-textfield");if(e&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)){if(e.value="",this.value="",this._internals){const t=this.disabled?null:this.value;this._internals.setFormValue(t),this._internals.setValidity({})}this.error=!1,e.setCustomValidity(""),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("onValueChanged",{detail:{value:this.value},bubbles:!0,composed:!0})),e.focus()}}};l=new WeakSet;g=function(){const e=a(this,l,b).call(this,this.spacing),t=a(this,l,b).call(this,this.spacingTop)??e,i=a(this,l,b).call(this,this.spacingBottom)??e,o=a(this,l,b).call(this,this.spacingLeft),n=a(this,l,b).call(this,this.spacingRight);t?this.style.setProperty("--scb-textfield-spacing-block-start",t):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"),o?this.style.setProperty("--scb-textfield-spacing-inline-start",o):this.style.removeProperty("--scb-textfield-spacing-inline-start"),n?this.style.setProperty("--scb-textfield-spacing-inline-end",n):this.style.removeProperty("--scb-textfield-spacing-inline-end")};b=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};u=function(e=!1){const t=this.shadowRoot?.querySelector(".scb-textfield");if(!(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement))return!0;const i=this.errorText||"Ogiltig inmatning.";let o="";if(t.setCustomValidity(""),this.required&&!t.value)o=i,t.setCustomValidity(o);else if(this.pattern&&t.value)try{new RegExp(this.pattern).test(t.value)||(o=i,t.setCustomValidity(o))}catch{t.setCustomValidity("")}const n=e?t.reportValidity():t.checkValidity();if(this.error=!n,this._internals)if(n)this._internals.setValidity({});else{const p=o||t.validationMessage||i;this._internals.setValidity({customError:!0},p,t)}return n};x=function(){const e=this.shadowRoot?.querySelector(".scb-textfield");e&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&this._boundField!==e&&(a(this,l,m).call(this),this._boundField=e,this.type!=="time"&&e.addEventListener("input",this._onFieldInput),e.addEventListener("change",this._onFieldChange),e.addEventListener("select",this._onFieldSelect),e.addEventListener("focus",this._onFieldFocus),e.addEventListener("blur",this._onFieldBlur))};m=function(){const e=this._boundField;e&&(e.removeEventListener("input",this._onFieldInput),e.removeEventListener("change",this._onFieldChange),e.removeEventListener("select",this._onFieldSelect),e.removeEventListener("focus",this._onFieldFocus),e.removeEventListener("blur",this._onFieldBlur),this._boundField=null)};y=function(){this._showDatepicker=!1;const e=this.shadowRoot?.querySelector(".scb-textfield");if(e&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&(e.value="",e.setCustomValidity("")),this.value="",this.error=!1,this._internals){const t=this.disabled?null:"";this._internals.setFormValue(t),this._internals.setValidity({})}};f=function(){const e=this.renderRoot?.querySelector(".ripple-wrapper");e&&(this._inputFocused&&this._kbShouldShowRing?e.setAttribute("data-kb-focus","true"):e.removeAttribute("data-kb-focus"))};s.formAssociated=!0;s.styles=[_`
|
|
225
225
|
:host {
|
|
226
226
|
--scb-textfield-number-max-width: 280px;
|
|
227
227
|
--scb-textfield-text-max-width: 400px;
|
|
@@ -592,4 +592,4 @@ import{a as _,n,r as w,i as $,x as d,t as z}from"../../vendor/vendor.js";import"
|
|
|
592
592
|
transform: translateY(-50%);
|
|
593
593
|
z-index: 4;
|
|
594
594
|
}
|
|
595
|
-
`];
|
|
595
|
+
`];r([d({type:String,reflect:!0})],s.prototype,"type",2);r([d({type:String})],s.prototype,"label",2);r([d({type:String,attribute:"supporting-text"})],s.prototype,"supportingText",2);r([d({type:String,attribute:"error-text"})],s.prototype,"errorText",2);r([d({type:String,attribute:"leading-icon"})],s.prototype,"leadingIcon",2);r([d({type:String})],s.prototype,"name",2);r([d({type:String})],s.prototype,"pattern",2);r([d({type:String,attribute:"value"})],s.prototype,"value",2);r([d({type:String})],s.prototype,"underLabel",2);r([d({type:Boolean,reflect:!0})],s.prototype,"error",2);r([d({type:Boolean,reflect:!0})],s.prototype,"disabled",2);r([d({type:Boolean,reflect:!0})],s.prototype,"required",2);r([d({type:String,reflect:!0})],s.prototype,"size",2);r([d({type:String,reflect:!0})],s.prototype,"spacing",2);r([d({type:String,attribute:"spacing-top",reflect:!0})],s.prototype,"spacingTop",2);r([d({type:String,attribute:"spacing-bottom",reflect:!0})],s.prototype,"spacingBottom",2);r([d({type:String,attribute:"spacing-left",reflect:!0})],s.prototype,"spacingLeft",2);r([d({type:String,attribute:"spacing-right",reflect:!0})],s.prototype,"spacingRight",2);r([w()],s.prototype,"_showDatepicker",2);s=r([z("scb-textfield")],s);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scb-wc-test",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.325",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -390,5 +390,5 @@
|
|
|
390
390
|
},
|
|
391
391
|
"./mvc/*": "./mvc/*"
|
|
392
392
|
},
|
|
393
|
-
"buildHash": "
|
|
393
|
+
"buildHash": "03102A9A2D83C198F8369ABAB00F3223998C1A1165B3BC8EEA8477AE8A90671F"
|
|
394
394
|
}
|
package/scb-dialog/scb-dialog.js
CHANGED
|
@@ -223,6 +223,10 @@ let n = class extends g {
|
|
|
223
223
|
if (!(c instanceof HTMLElement) || s.has(c) || e(c)) return;
|
|
224
224
|
s.add(c);
|
|
225
225
|
const p = c;
|
|
226
|
+
if (c.tagName === "SCB-TEXTFIELD" && p.error === !0) {
|
|
227
|
+
a || (a = c), i = !1;
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
226
230
|
if (typeof p.reportValidity == "function") {
|
|
227
231
|
const h = !!p.reportValidity();
|
|
228
232
|
!h && !a && (a = c), i = i && h;
|