scb-wc-test 0.1.115 → 0.1.116

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,5 +1,5 @@
1
- import{a as g,r as h,n as p,i as w,x as i,t as m}from"../../vendor/vendor.js";import"../scb-icon-button/scb-icon-button.js";import"../scb-button/scb-button.js";import"../../vendor/vendor-material.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(a,c,r){try{customElements.get(a)||t(a,c,r)}catch(s){var o=String(s||"");if(o.indexOf("already been used")===-1&&o.indexOf("NotSupportedError")===-1)throw s}}}}catch{}})();var v=Object.defineProperty,_=Object.getOwnPropertyDescriptor,l=(e,t,a,c)=>{for(var r=c>1?void 0:c?_(t,a):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(r=(c?s(t,a,r):s(r))||r);return c&&r&&v(t,a,r),r};let d=class extends w{constructor(){super(...arguments),this._currentDate=new Date,this._selectedDate=null,this._showMonthDropdown=!1,this._showYearDropdown=!1,this.variant="static",this.lang="sv",this.selectedValue="",this.open=!0,this._outsideClickHandler=e=>{this.variant!=="static"&&this.open&&(e.composedPath().includes(this)||this._close())},this._monthNames=[this.lang=="sv"?"Januari":"January",this.lang=="sv"?"Februari":"February",this.lang=="sv"?"Mars":"March",(this.lang=="sv","April"),this.lang=="sv"?"Maj":"May",this.lang=="sv"?"Juni":"June",this.lang=="sv"?"Juli":"July",this.lang=="sv"?"Augusti":"August",(this.lang=="sv","September"),this.lang=="sv"?"Oktober":"October",(this.lang=="sv","November"),(this.lang=="sv","December")],this._prevYear=()=>{const e=this._currentDate.getFullYear(),t=this._currentDate.getMonth();this._currentDate=new Date(e-1,t,1)},this._nextYear=()=>{const e=this._currentDate.getFullYear(),t=this._currentDate.getMonth();this._currentDate=new Date(e+1,t,1)},this._prevMonth=()=>{const e=this._currentDate.getFullYear(),t=this._currentDate.getMonth();this._currentDate=new Date(e,t-1,1)},this._nextMonth=()=>{const e=this._currentDate.getFullYear(),t=this._currentDate.getMonth();this._currentDate=new Date(e,t+1,1)},this._close=()=>{this.open=!1,this.dispatchEvent(new CustomEvent("datepicker-closed",{bubbles:!0,composed:!0})),window.removeEventListener("mousedown",this._outsideClickHandler)}}updated(e){if(super.updated(e),this.variant!=="static"&&this.open?window.addEventListener("mousedown",this._outsideClickHandler):window.removeEventListener("mousedown",this._outsideClickHandler),e.has("selectedValue")&&this.selectedValue){const t=new Date(this.selectedValue);isNaN(t.getTime())||(this._selectedDate=t,this._currentDate=new Date(t.getFullYear(),t.getMonth(),1))}}_getMonthDays(e,t){const a=new Date(e,t,1),c=new Date(e,t+1,0),r=[];let o=[],s=(a.getDay()+6)%7;for(let n=0;n<s;n++)o.push(null);for(let n=1;n<=c.getDate();n++){const u=new Date(e,t,n);o.push(u),o.length===7&&(r.push(o),o=[])}if(o.length){for(;o.length<7;)o.push(null);r.push(o)}return r}render(){if(!this.open)return i``;const e=this._currentDate.getFullYear(),t=this._currentDate.getMonth(),a=new Date,c=this._getMonthDays(e,t),r=Array.from({length:101},(o,s)=>a.getFullYear()-50+s);return i`
2
- <div class="datepicker-popup ${this.variant==="popup"?"popup":"static"}">
1
+ import{a as m,r as p,n as u,i as w,x as d,t as _}from"../../vendor/vendor.js";import"../scb-icon-button/scb-icon-button.js";import"../scb-button/scb-button.js";import"../../vendor/vendor-material.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(s,a,n){try{customElements.get(s)||t(s,a,n)}catch(o){var r=String(o||"");if(r.indexOf("already been used")===-1&&r.indexOf("NotSupportedError")===-1)throw o}}}}catch{}})();var v=Object.defineProperty,b=Object.getOwnPropertyDescriptor,h=(e,t,s,a)=>{for(var n=a>1?void 0:a?b(t,s):t,r=e.length-1,o;r>=0;r--)(o=e[r])&&(n=(a?o(t,s,n):o(n))||n);return a&&n&&v(t,s,n),n};let c=class extends w{constructor(){super(...arguments),this._currentDate=new Date,this._selectedDate=null,this._showMonthDropdown=!1,this._showYearDropdown=!1,this.variant="date",this.lang="sv",this.selectedValue="",this.open=!0,this._selectedHour=0,this._selectedMinute=0,this._monthNames=[this.lang=="sv"?"Januari":"January",this.lang=="sv"?"Februari":"February",this.lang=="sv"?"Mars":"March",(this.lang=="sv","April"),this.lang=="sv"?"Maj":"May",this.lang=="sv"?"Juni":"June",this.lang=="sv"?"Juli":"July",this.lang=="sv"?"Augusti":"August",(this.lang=="sv","September"),this.lang=="sv"?"Oktober":"October",(this.lang=="sv","November"),(this.lang=="sv","December")],this._outsideClickHandler=e=>{this.open&&(e.composedPath().includes(this)||this._close())},this._prevMonth=()=>{const e=this._currentDate.getFullYear(),t=this._currentDate.getMonth();t===0?this._currentDate=new Date(e-1,11,1):this._currentDate=new Date(e,t-1,1)},this._prevYear=()=>{const e=this._currentDate.getFullYear(),t=this._currentDate.getMonth();this._currentDate=new Date(e-1,t,1)},this._nextMonth=()=>{const e=this._currentDate.getFullYear(),t=this._currentDate.getMonth();t===11?this._currentDate=new Date(e+1,0,1):this._currentDate=new Date(e,t+1,1)},this._nextYear=()=>{const e=this._currentDate.getFullYear(),t=this._currentDate.getMonth();this._currentDate=new Date(e+1,t,1)},this._onTimeChange=e=>{const t=e.target.value,[s,a]=t.split(":"),n=parseInt(s,10),r=parseInt(a,10);this._selectedHour=isNaN(n)?0:Math.max(0,Math.min(23,n)),this._selectedMinute=isNaN(r)?0:Math.max(0,Math.min(59,r)),this._fireDateTimeChange()},this._close=()=>{this.open=!1,this.dispatchEvent(new CustomEvent("datepicker-closed",{bubbles:!0,composed:!0}))}}updated(e){if(super.updated(e),this.open?window.addEventListener("mousedown",this._outsideClickHandler):window.removeEventListener("mousedown",this._outsideClickHandler),e.has("selectedValue")&&this.selectedValue){const t=new Date(this.selectedValue);isNaN(t.getTime())||(this._selectedDate=t,this._currentDate=new Date(t.getFullYear(),t.getMonth(),1),this.variant==="datetime-local"&&(this._selectedHour=t.getHours(),this._selectedMinute=t.getMinutes()))}}render(){if(!this.open)return d``;const e=this._currentDate.getFullYear(),t=this._currentDate.getMonth(),s=new Date,a=this._getMonthDays(e,t),n=Array.from({length:101},(o,i)=>s.getFullYear()-50+i),r=this.variant==="datetime-local"&&!this._showMonthDropdown&&!this._showYearDropdown;return d`
2
+ <div class="datepicker-popup popup">
3
3
  <div class="header">
4
4
  <div class="month-selector ${this._showMonthDropdown?"open":""} ${this._showYearDropdown?"disable":""}">
5
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>
@@ -36,43 +36,43 @@ import{a as g,r as h,n as p,i as w,x as i,t as m}from"../../vendor/vendor.js";im
36
36
  <scb-icon-button icon="chevron_right" @click=${this._nextYear} aria-label=${this.lang=="sv"?"Nästa år":"Next year"}></scb-icon-button>
37
37
  </div>
38
38
  </div>
39
- ${this._showMonthDropdown||this._showYearDropdown?i`<scb-divider></scb-divider>`:""}
39
+ ${this._showMonthDropdown||this._showYearDropdown?d`<scb-divider></scb-divider>`:""}
40
40
  <div class="datepicker-content" style="position:relative;">
41
- ${this._showMonthDropdown?i`
41
+ ${this._showMonthDropdown?d`
42
42
  <div class="dropdown-list">
43
- ${this._monthNames.map((o,s)=>i`
43
+ ${this._monthNames.map((o,i)=>d`
44
44
  <div
45
- @keydown=${n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),this._onMonthChangeCustom(s))}}
45
+ @keydown=${l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),this._onMonthChangeCustom(i))}}
46
46
  tabindex="0"
47
- class="dropdown-item${s===t?" selected":""}"
48
- @click=${()=>this._onMonthChangeCustom(s)}
49
- id=${s===t?"selected-month":""}
47
+ class="dropdown-item${i===t?" selected":""}"
48
+ @click=${()=>this._onMonthChangeCustom(i)}
49
+ id=${i===t?"selected-month":""}
50
50
  >
51
- ${s===t?i`<md-icon>check</md-icon>`:""}
51
+ ${i===t?d`<md-icon>check</md-icon>`:""}
52
52
  ${o}
53
53
  <md-ripple></md-ripple><md-focus-ring inward></md-focus-ring>
54
54
  </div>
55
55
  `)}
56
56
  </div>
57
57
  `:""}
58
- ${this._showYearDropdown?i`
58
+ ${this._showYearDropdown?d`
59
59
  <div class="dropdown-list">
60
- ${r.map(o=>i`
60
+ ${n.map(o=>d`
61
61
  <div
62
- @keydown=${s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),this._onYearChangeCustom(o))}}
62
+ @keydown=${i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),this._onYearChangeCustom(o))}}
63
63
  tabindex="0"
64
64
  class="dropdown-item${o===e?" selected":""}"
65
65
  @click=${()=>this._onYearChangeCustom(o)}
66
66
  id=${o===e?"selected-year":""}
67
67
  >
68
- ${o===e?i`<md-icon>check</md-icon>`:""}
68
+ ${o===e?d`<md-icon>check</md-icon>`:""}
69
69
  ${o}
70
70
  <md-ripple></md-ripple><md-focus-ring inward></md-focus-ring>
71
71
  </div>
72
72
  `)}
73
73
  </div>
74
74
  `:""}
75
- ${!this._showMonthDropdown&&!this._showYearDropdown?i`
75
+ ${!this._showMonthDropdown&&!this._showYearDropdown?d`
76
76
  <div class="datepicker-calendar">
77
77
  <table>
78
78
  <thead>
@@ -81,19 +81,19 @@ import{a as g,r as h,n as p,i as w,x as i,t as m}from"../../vendor/vendor.js";im
81
81
  </tr>
82
82
  </thead>
83
83
  <tbody>
84
- ${c.map(o=>i`
84
+ ${a.map(o=>d`
85
85
  <tr>
86
- ${o.map(s=>s?i`
86
+ ${o.map(i=>i?d`
87
87
  <td>
88
88
  <div
89
- @keydown=${n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),this._selectDate(s))}}
89
+ @keydown=${l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),this._selectDate(i))}}
90
90
  role="button"
91
91
  tabindex="0"
92
- class="day${this._isToday(s,a)?" today":""}${this._isSelected(s)?" selected":""}"
93
- @click=${()=>this._selectDate(s)}
94
- >${s.getDate()}<md-ripple></md-ripple><md-focus-ring></md-focus-ring></div>
92
+ class="day${this._isToday(i,s)?" today":""}${this._isSelected(i)?" selected":""}"
93
+ @click=${()=>this._selectDate(i)}
94
+ >${i.getDate()}<md-ripple></md-ripple><md-focus-ring></md-focus-ring></div>
95
95
  </td>
96
- `:i`<td></td>`)}
96
+ `:d`<td></td>`)}
97
97
  </tr>
98
98
  `)}
99
99
  </tbody>
@@ -101,13 +101,21 @@ import{a as g,r as h,n as p,i as w,x as i,t as m}from"../../vendor/vendor.js";im
101
101
  </div>
102
102
  `:""}
103
103
  </div>
104
+ ${r?d`
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
+ `:""}
104
112
  <div class="datepicker-footer">
105
- ${!this._showMonthDropdown&&!this._showYearDropdown&&this.variant=="popup"?i`
113
+ ${!this._showMonthDropdown&&!this._showYearDropdown?d`
106
114
  <scb-button variant="text" label=${this.lang=="sv"?"Stäng":"Close"} @click=${this._close}></scb-button>
107
115
  `:""}
108
116
  </div>
109
117
  </div>
110
- `}_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){this._selectedDate=e;const t=e.toISOString().slice(0,10);this.dispatchEvent(new CustomEvent("date-selected",{detail:{value:t},bubbles:!0,composed:!0}))}};d.styles=[g`
118
+ `}_getMonthDays(e,t){const s=new Date(Date.UTC(e,t,1)),a=new Date(Date.UTC(e,t+1,0)),n=[];let r=[],o=s.getUTCDay(),i=o===0?6:o-1;for(let l=0;l<i;l++)r.push(null);for(let l=1;l<=a.getUTCDate();l++){const g=new Date(Date.UTC(e,t,l));r.push(g),r.length===7&&(n.push(r),r=[])}if(r.length){for(;r.length<7;)r.push(null);n.push(r)}return n}_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 s=n=>n.toString().padStart(2,"0"),a=`${t.getFullYear()}-${s(t.getMonth()+1)}-${s(t.getDate())} ${s(t.getHours())}:${s(t.getMinutes())}`;this.dispatchEvent(new CustomEvent("date-selected",{detail:{value:a},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=a=>a.toString().padStart(2,"0"),s=`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())} ${t(e.getHours())}:${t(e.getMinutes())}`;this.dispatchEvent(new CustomEvent("date-selected",{detail:{value:s},bubbles:!0,composed:!0}))}}};c.styles=[m`
111
119
  :host {
112
120
  --scb-datepicker-width: 380px;
113
121
  max-width: var(--scb-datepicker-width);
@@ -273,4 +281,4 @@ import{a as g,r as h,n as p,i as w,x as i,t as m}from"../../vendor/vendor.js";im
273
281
  .close-datepicker:hover {
274
282
  background: var(--md-sys-color-primary-container, #e3f2fd);
275
283
  }
276
- `];l([h()],d.prototype,"_currentDate",2);l([h()],d.prototype,"_selectedDate",2);l([h()],d.prototype,"_showMonthDropdown",2);l([h()],d.prototype,"_showYearDropdown",2);l([p({type:String})],d.prototype,"variant",2);l([p({type:String})],d.prototype,"lang",2);l([p({type:String})],d.prototype,"selectedValue",2);l([p({type:Boolean})],d.prototype,"open",2);d=l([m("scb-datepicker")],d);
284
+ `];h([p()],c.prototype,"_currentDate",2);h([p()],c.prototype,"_selectedDate",2);h([p()],c.prototype,"_showMonthDropdown",2);h([p()],c.prototype,"_showYearDropdown",2);h([u({type:String})],c.prototype,"variant",2);h([u({type:String})],c.prototype,"lang",2);h([u({type:String})],c.prototype,"selectedValue",2);h([u({type:Boolean})],c.prototype,"open",2);h([p()],c.prototype,"_selectedHour",2);h([p()],c.prototype,"_selectedMinute",2);c=h([_("scb-datepicker")],c);
@@ -1,4 +1,4 @@
1
- import{a as v,n as a,r as x,i as g,x as h,t as y}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 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,o){try{customElements.get(i)||e(i,n,o)}catch(p){var c=String(p||"");if(c.indexOf("already been used")===-1&&c.indexOf("NotSupportedError")===-1)throw p}}}}catch{}})();var _=Object.defineProperty,w=Object.getOwnPropertyDescriptor,m=t=>{throw TypeError(t)},r=(t,e,i,n)=>{for(var o=n>1?void 0:n?w(e,i):e,c=t.length-1,p;c>=0;c--)(p=t[c])&&(o=(n?p(e,i,o):p(o))||o);return n&&o&&_(e,i,o),o},k=(t,e,i)=>e.has(t)||m("Cannot "+i),$=(t,e,i)=>e.has(t)?m("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),d=(t,e,i)=>(k(t,e,"access private method"),i),l,f,b,u;let s=class extends g{constructor(){super(),$(this,l),this._internals=null,this._inputFocused=!1,this._kbShouldShowRing=!1,this._onGlobalKeydown=t=>{t.key==="Tab"&&(this._kbShouldShowRing=!0,this._inputFocused&&d(this,l,u).call(this))},this._onGlobalPointerDown=()=>{this._kbShouldShowRing=!1,this._inputFocused&&d(this,l,u).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.spacing="",this.spacingTop="",this.spacingBottom="",this._form=null,this._formSubmitHandler=null,this._formResetHandler=null,this._initialValue="",this._inputId="",this._showDatepicker=!1,this._toggleDatepicker=()=>{this._showDatepicker=!this._showDatepicker},this._onDateSelected=t=>{if(this.value=t.detail.value,this._showDatepicker=!1,this._internals){const e=this.disabled?null:this.value;this._internals.setFormValue(e)}if(this.pattern){const e=new RegExp(this.pattern);this.error=!e.test(this.value)}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())}render(){const t=this.leadingIcon?h`<md-icon class="scb-textfield-icon">${this.leadingIcon}</md-icon>`:null,e=this.error?h`<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,n=this.type==="search"&&this.value?h`
1
+ import{a as v,n as a,r as x,i as g,x as d,t as y}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 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,l,n){try{customElements.get(i)||e(i,l,n)}catch(h){var p=String(h||"");if(p.indexOf("already been used")===-1&&p.indexOf("NotSupportedError")===-1)throw h}}}}catch{}})();var _=Object.defineProperty,w=Object.getOwnPropertyDescriptor,m=t=>{throw TypeError(t)},r=(t,e,i,l)=>{for(var n=l>1?void 0:l?w(e,i):e,p=t.length-1,h;p>=0;p--)(h=t[p])&&(n=(l?h(e,i,n):h(n))||n);return l&&n&&_(e,i,n),n},$=(t,e,i)=>e.has(t)||m("Cannot "+i),k=(t,e,i)=>e.has(t)?m("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),c=(t,e,i)=>($(t,e,"access private method"),i),o,f,b,u;let s=class extends g{constructor(){super(),k(this,o),this._internals=null,this._inputFocused=!1,this._kbShouldShowRing=!1,this._onGlobalKeydown=t=>{t.key==="Tab"&&(this._kbShouldShowRing=!0,this._inputFocused&&c(this,o,u).call(this))},this._onGlobalPointerDown=()=>{this._kbShouldShowRing=!1,this._inputFocused&&c(this,o,u).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.spacing="",this.spacingTop="",this.spacingBottom="",this._form=null,this._formSubmitHandler=null,this._formResetHandler=null,this._initialValue="",this._inputId="",this._showDatepicker=!1,this._toggleDatepicker=()=>{this._showDatepicker=!this._showDatepicker},this._onDateSelected=t=>{if(this.value=t.detail.value,this._showDatepicker=!1,this._internals){const e=this.disabled?null:this.value;this._internals.setFormValue(e)}if(this.pattern){const e=new RegExp(this.pattern);this.error=!e.test(this.value)}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())}render(){const t=this.leadingIcon?d`<md-icon class="scb-textfield-icon">${this.leadingIcon}</md-icon>`:null,e=this.error?d`<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,l=this.type==="search"&&this.value?d`
2
2
  <button
3
3
  type="button"
4
4
  class="scb-textfield-clear"
@@ -32,7 +32,7 @@ import{a as v,n as a,r as x,i as g,x as h,t as y}from"../../vendor/vendor.js";im
32
32
  ></line>
33
33
  </svg>
34
34
  </button>
35
- `:null;return this.type==="textarea"?h`
35
+ `:null;return this.type==="textarea"?d`
36
36
  <label class="scb-textfield-label" for="${this._inputId}">${this.label}</label>
37
37
  <span
38
38
  class="scb-textfield-supporting-text"
@@ -56,7 +56,7 @@ ${this.value}</textarea
56
56
  <md-focus-ring class="input-ring"></md-focus-ring>
57
57
  </div>
58
58
  </div>
59
- `:this.type==="date"?h`
59
+ `:this.type==="date"?d`
60
60
  <label class="scb-textfield-label" for="${this._inputId}">${this.label}</label>
61
61
  <span
62
62
  class="scb-textfield-supporting-text"
@@ -77,25 +77,96 @@ ${this.value}</textarea
77
77
  aria-invalid=${this.error?"true":"false"}
78
78
  aria-describedby=${i}
79
79
  readonly
80
+ @focus=${this._toggleDatepicker}
81
+ @click=${this._toggleDatepicker}
80
82
  />
81
- ${e}
82
83
  <md-ripple></md-ripple>
83
84
  <md-focus-ring class="input-ring"></md-focus-ring>
84
85
  </div>
85
- <scb-icon-button
86
- class="scb-textfield-datepicker-button"
87
- icon="calendar_today"
86
+ ${this.error?e:d`
87
+ <scb-icon-button
88
+ class="scb-textfield-datepicker-button"
89
+ icon="calendar_today"
90
+ @click=${this._toggleDatepicker}
91
+ aria-label="Välj datum"
92
+ ></scb-icon-button>`}
93
+ <scb-datepicker
94
+ .selectedValue=${this.value}
95
+ .open=${this._showDatepicker}
96
+ @date-selected=${this._onDateSelected}
97
+ ></scb-datepicker>
98
+ </div>
99
+ `:this.type==="datetime-local"?d`
100
+ <label class="scb-textfield-label" for="${this._inputId}">${this.label}</label>
101
+ <span
102
+ class="scb-textfield-supporting-text"
103
+ id="${this.underLabel?`${this._inputId}-supporting-text`:""}"
104
+ >${this.underLabel}</span
105
+ >
106
+ <div class="scb-textfield-wrapper" style="position:relative;">
107
+ ${t}
108
+ <div class="ripple-wrapper">
109
+ <input
110
+ class="scb-textfield${this.error?" has-error-icon":""}"
111
+ .value=${this.value}
112
+ type="text"
113
+ name="${this.name}"
114
+ id="${this._inputId}"
115
+ ?disabled=${this.disabled}
116
+ ?required=${this.required}
117
+ aria-invalid=${this.error?"true":"false"}
118
+ aria-describedby=${i}
119
+ readonly
120
+ @focus=${this._toggleDatepicker}
88
121
  @click=${this._toggleDatepicker}
89
- aria-label="Välj datum"
90
- ></scb-icon-button>
122
+ />
123
+
124
+ <md-ripple></md-ripple>
125
+ <md-focus-ring class="input-ring"></md-focus-ring>
126
+ </div>
127
+
128
+ ${this.error?e:d`
129
+ <scb-icon-button
130
+ class="scb-textfield-datepicker-button"
131
+ icon="calendar_today"
132
+ @click=${this._toggleDatepicker}
133
+ aria-label="Välj datum"
134
+ ></scb-icon-button>`}
91
135
  <scb-datepicker
92
- variant="popup"
136
+ variant="datetime-local"
93
137
  .selectedValue=${this.value}
94
138
  .open=${this._showDatepicker}
95
139
  @date-selected=${this._onDateSelected}
96
140
  ></scb-datepicker>
97
141
  </div>
98
- `:h`
142
+ `:this.type==="time"?d`
143
+ <label class="scb-textfield-label" for="${this._inputId}">${this.label}</label>
144
+ <span
145
+ class="scb-textfield-supporting-text"
146
+ id="${this.underLabel?`${this._inputId}-supporting-text`:""}"
147
+ >${this.underLabel}</span
148
+ >
149
+ <div class="scb-textfield-wrapper">
150
+ ${t}
151
+ <div class="ripple-wrapper">
152
+ <input
153
+ class="scb-textfield${this.error?" has-error-icon":""}"
154
+ .value=${this.value}
155
+ type="time"
156
+ name="${this.name}"
157
+ id="${this._inputId}"
158
+ ?disabled=${this.disabled}
159
+ ?required=${this.required}
160
+ aria-invalid=${this.error?"true":"false"}
161
+ aria-describedby=${i}
162
+ @input=${n=>{const p=n.target;if(this.value=p.value,this._internals){const h=this.disabled?null:this.value;this._internals.setFormValue(h)}this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("onValueChanged",{detail:{value:this.value},bubbles:!0,composed:!0}))}}
163
+ />
164
+ ${e}
165
+ <md-ripple></md-ripple>
166
+ <md-focus-ring class="input-ring"></md-focus-ring>
167
+ </div>
168
+ </div>
169
+ `:d`
99
170
  <label class="scb-textfield-label" for="${this._inputId}">${this.label}</label>
100
171
  <span
101
172
  class="scb-textfield-supporting-text"
@@ -116,13 +187,13 @@ ${this.value}</textarea
116
187
  aria-invalid=${this.error?"true":"false"}
117
188
  aria-describedby=${i}
118
189
  />
119
- ${n}
190
+ ${l}
120
191
  ${e}
121
192
  <md-ripple></md-ripple>
122
193
  <md-focus-ring class="input-ring"></md-focus-ring>
123
194
  </div>
124
195
  </div>
125
- `}firstUpdated(t){super.firstUpdated(t),this._initialValue=this.value;const e=this.shadowRoot?.querySelector(".scb-textfield");e&&(e.addEventListener("input",()=>{const i=e;if(this.value=i.value,this._internals){const n=this.disabled?null:this.value;this._internals.setFormValue(n)}if(this.pattern){const n=new RegExp(this.pattern);this.error=!n.test(this.value)}this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("onValueChanged",{detail:{value:this.value},bubbles:!0,composed:!0}))}),e.addEventListener("change",()=>{this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),e.addEventListener("select",()=>{this.dispatchEvent(new Event("select",{bubbles:!0,composed:!0}))}),e.addEventListener("focus",()=>{this._inputFocused=!0,d(this,l,u).call(this)}),e.addEventListener("blur",()=>{this._inputFocused=!1,d(this,l,u).call(this)})),d(this,l,f).call(this)}updated(t){if(super.updated(t),this.toggleAttribute("aria-disabled",this.disabled),this._internals&&(t.has("value")||t.has("disabled"))){const e=this.disabled?null:this.value;this._internals.setFormValue(e)}(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom"))&&d(this,l,f).call(this)}formDisabledCallback(t){this.disabled=t}connectedCallback(){super.connectedCallback(),this._inputId=this.id||`scb-textfield-${Math.random().toString(36).substr(2,9)}`,this._formSubmitHandler=t=>{this.reportValidity()||(t.preventDefault(),t.stopPropagation())},this._form=this.closest("form"),this._form&&(this._form.addEventListener("submit",this._formSubmitHandler,!0),this._formResetHandler=()=>{this.value=this._initialValue;const t=this.shadowRoot?.querySelector(".scb-textfield");t&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.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)),window.removeEventListener("keydown",this._onGlobalKeydown,!0),window.removeEventListener("pointerdown",this._onGlobalPointerDown,!0)}reportValidity(){const t=this.shadowRoot?.querySelector(".scb-textfield");if(t&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)){this.required&&!t.value?t.setCustomValidity(this.errorText||"Ogiltig inmatning."):t.setCustomValidity("");const e=t.reportValidity();this.error=!e;const i=e?"":this.errorText||t.validationMessage||"Ogiltig inmatning.";return e||(this.errorText=i),this._internals&&(e?this._internals.setValidity({}):this._internals.setValidity({customError:!0},i,t)),e}return!0}_onClearClick(){const t=this.shadowRoot?.querySelector(".scb-textfield");if(t&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)){if(t.value="",this.value="",this._internals){const e=this.disabled?null:this.value;this._internals.setFormValue(e),this._internals.setValidity({})}this.error=!1,t.setCustomValidity(""),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("onValueChanged",{detail:{value:this.value},bubbles:!0,composed:!0})),t.focus()}}};l=new WeakSet;f=function(){const t=d(this,l,b).call(this,this.spacing),e=d(this,l,b).call(this,this.spacingTop)??t,i=d(this,l,b).call(this,this.spacingBottom)??t;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")};b=function(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};u=function(){const t=this.renderRoot?.querySelector(".ripple-wrapper");t&&(this._inputFocused&&this._kbShouldShowRing?t.setAttribute("data-kb-focus","true"):t.removeAttribute("data-kb-focus"))};s.formAssociated=!0;s.styles=[v`
196
+ `}firstUpdated(t){super.firstUpdated(t),this._initialValue=this.value;const e=this.shadowRoot?.querySelector(".scb-textfield");e&&(e.addEventListener("input",()=>{const i=e;if(this.value=i.value,this._internals){const l=this.disabled?null:this.value;this._internals.setFormValue(l)}if(this.pattern){const l=new RegExp(this.pattern);this.error=!l.test(this.value)}this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("onValueChanged",{detail:{value:this.value},bubbles:!0,composed:!0}))}),e.addEventListener("change",()=>{this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),e.addEventListener("select",()=>{this.dispatchEvent(new Event("select",{bubbles:!0,composed:!0}))}),e.addEventListener("focus",()=>{this._inputFocused=!0,c(this,o,u).call(this)}),e.addEventListener("blur",()=>{this._inputFocused=!1,c(this,o,u).call(this)})),c(this,o,f).call(this)}updated(t){if(super.updated(t),this.toggleAttribute("aria-disabled",this.disabled),this._internals&&(t.has("value")||t.has("disabled"))){const e=this.disabled?null:this.value;this._internals.setFormValue(e)}(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom"))&&c(this,o,f).call(this)}formDisabledCallback(t){this.disabled=t}connectedCallback(){super.connectedCallback(),this._inputId=this.id||`scb-textfield-${Math.random().toString(36).substr(2,9)}`,this._formSubmitHandler=t=>{this.reportValidity()||(t.preventDefault(),t.stopPropagation())},this._form=this.closest("form"),this._form&&(this._form.addEventListener("submit",this._formSubmitHandler,!0),this._formResetHandler=()=>{this.value=this._initialValue;const t=this.shadowRoot?.querySelector(".scb-textfield");t&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.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)),window.removeEventListener("keydown",this._onGlobalKeydown,!0),window.removeEventListener("pointerdown",this._onGlobalPointerDown,!0)}reportValidity(){const t=this.shadowRoot?.querySelector(".scb-textfield");if(t&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)){this.required&&!t.value?t.setCustomValidity(this.errorText||"Ogiltig inmatning."):t.setCustomValidity("");const e=t.reportValidity();this.error=!e;const i=e?"":this.errorText||t.validationMessage||"Ogiltig inmatning.";return e||(this.errorText=i),this._internals&&(e?this._internals.setValidity({}):this._internals.setValidity({customError:!0},i,t)),e}return!0}_onClearClick(){const t=this.shadowRoot?.querySelector(".scb-textfield");if(t&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)){if(t.value="",this.value="",this._internals){const e=this.disabled?null:this.value;this._internals.setFormValue(e),this._internals.setValidity({})}this.error=!1,t.setCustomValidity(""),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("onValueChanged",{detail:{value:this.value},bubbles:!0,composed:!0})),t.focus()}}};o=new WeakSet;f=function(){const t=c(this,o,b).call(this,this.spacing),e=c(this,o,b).call(this,this.spacingTop)??t,i=c(this,o,b).call(this,this.spacingBottom)??t;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")};b=function(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};u=function(){const t=this.renderRoot?.querySelector(".ripple-wrapper");t&&(this._inputFocused&&this._kbShouldShowRing?t.setAttribute("data-kb-focus","true"):t.removeAttribute("data-kb-focus"))};s.formAssociated=!0;s.styles=[v`
126
197
  :host {
127
198
  --scb-textfield-number-max-width: 280px;
128
199
  --scb-textfield-text-max-width: 400px;
@@ -148,6 +219,12 @@ ${this.value}</textarea
148
219
  :host([type='text']) {
149
220
  --scb-textfield-max-width: var(--scb-textfield-text-max-width);
150
221
  }
222
+ :host([type='date']) {
223
+ --scb-textfield-max-width: var(--scb-textfield-text-max-width);
224
+ }
225
+ :host([type='datetime-local']) {
226
+ --scb-textfield-max-width: var(--scb-textfield-text-max-width);
227
+ }
151
228
  :host([type='search']) {
152
229
  --scb-textfield-max-width: var(--scb-textfield-search-max-width);
153
230
  }
@@ -169,6 +246,13 @@ ${this.value}</textarea
169
246
  :host([type='date']) {
170
247
  --scb-textfield-max-width: var(--scb-textfield-text-max-width);
171
248
  }
249
+ :host([type='time']) {
250
+ --scb-textfield-max-width: var(--scb-textfield-text-max-width);
251
+ }
252
+ input[type="time"]::-webkit-calendar-picker-indicator {
253
+ display: none;
254
+ background: none;
255
+ }
172
256
 
173
257
  :host {
174
258
  display: flex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scb-wc-test",
3
- "version": "0.1.115",
3
+ "version": "0.1.116",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -345,5 +345,5 @@
345
345
  },
346
346
  "./mvc/*": "./mvc/*"
347
347
  },
348
- "buildHash": "5280B566602038551107484C2861902B88628F01ED032DDCA25F777E945D869F"
348
+ "buildHash": "227F3119B18DEE6767015D3DC4AF88BD68195127792285728F8C3D4A93FEC42D"
349
349
  }
@@ -4,26 +4,30 @@ export declare class ScbDatepicker extends LitElement {
4
4
  private _selectedDate;
5
5
  private _showMonthDropdown;
6
6
  private _showYearDropdown;
7
- variant: 'static' | 'popup';
7
+ variant: 'datetime-local' | 'date';
8
8
  lang: 'sv' | 'en';
9
9
  selectedValue: string;
10
10
  open: boolean;
11
+ private _selectedHour;
12
+ private _selectedMinute;
11
13
  static styles: import('lit').CSSResult[];
12
14
  updated(changed: PropertyValues): void;
13
- private _getMonthDays;
14
- private _outsideClickHandler;
15
15
  private _monthNames;
16
16
  render(): TemplateResult;
17
+ private _getMonthDays;
18
+ private _outsideClickHandler;
17
19
  private _toggleMonthDropdown;
18
20
  private _toggleYearDropdown;
19
21
  private _onMonthChangeCustom;
20
22
  private _onYearChangeCustom;
23
+ private _prevMonth;
21
24
  private _prevYear;
25
+ private _nextMonth;
22
26
  private _nextYear;
23
27
  private _isToday;
24
28
  private _isSelected;
25
29
  private _selectDate;
26
- private _prevMonth;
27
- private _nextMonth;
30
+ private _fireDateTimeChange;
31
+ private _onTimeChange;
28
32
  private _close;
29
33
  }