@oslokommune/punkt-elements 19.14.3 → 19.15.3
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/CHANGELOG.md +38 -0
- package/dist/calendar-5XCeDtZX.cjs +85 -0
- package/dist/{calendar-D9w8M99G.js → calendar-CtWc545R.js} +45 -60
- package/dist/{checkbox-group-adbFTj8y.cjs → checkbox-group-BLurd7sf.cjs} +1 -1
- package/dist/{checkbox-group-C8mo9dkO.js → checkbox-group-Bum7k828.js} +1 -1
- package/dist/{combobox-jsPpImVF.cjs → combobox-BsXDULXd.cjs} +1 -1
- package/dist/{combobox-B8IeuEF0.js → combobox-C7tUHbG4.js} +1 -1
- package/dist/components/modal/modal.d.ts +7 -0
- package/dist/components/modal/modal.test.d.ts +9 -0
- package/dist/{datepicker-CjUY_mLR.js → datepicker-CJLcIDVk.js} +2 -2
- package/dist/{datepicker-CZYpIyJd.cjs → datepicker-DmZi4CNk.cjs} +1 -1
- package/dist/docs/components/modal.d.ts +2 -0
- package/dist/{fileupload-CyLRyoVU.cjs → fileupload-A_suUEPU.cjs} +1 -1
- package/dist/{fileupload-BmfFC748.js → fileupload-DehKWas6.js} +2 -2
- package/dist/{header-BCrefip0.cjs → header-BzAPmAsZ.cjs} +1 -1
- package/dist/{header-20rqKJFb.js → header-C6xhv3Ib.js} +1 -1
- package/dist/{input-wrapper-BwzajfFX.cjs → input-wrapper-BEmV0DGo.cjs} +2 -3
- package/dist/{input-wrapper-Bb6CZxmg.js → input-wrapper-xRJo_iVf.js} +2 -3
- package/dist/{modal-B3CQEBBB.js → modal-0D0paY70.js} +42 -23
- package/dist/modal-wEEmCcUx.cjs +39 -0
- package/dist/{option-group-element-CzehfgVZ.cjs → option-group-element-A2cOZRWA.cjs} +1 -1
- package/dist/{option-group-element-D5PgGNdt.js → option-group-element-fpMneBWa.js} +1 -1
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +1 -1
- package/dist/pkt-checkbox-group.cjs +1 -1
- package/dist/pkt-checkbox-group.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-fileupload.cjs +1 -1
- package/dist/pkt-fileupload.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +13 -13
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/pkt-radio-group.cjs +1 -1
- package/dist/pkt-radio-group.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/pkt-timepicker.cjs +1 -1
- package/dist/pkt-timepicker.js +1 -1
- package/dist/{radio-group-CtZhXMF8.js → radio-group-BmJ3kcba.js} +1 -1
- package/dist/{radio-group-MxNLGu-0.cjs → radio-group-Q75EtJzu.cjs} +1 -1
- package/dist/{select-Bs-Z5Thd.js → select-ByPSk9WT.js} +1 -1
- package/dist/{select-Czz1y2nI.cjs → select-CCY2_EbI.cjs} +1 -1
- package/dist/shared-types/calendar.d.ts +0 -1
- package/dist/shared-utils/calendar/calendar-grid.d.ts +0 -4
- package/dist/shared-utils/calendar/index.d.ts +1 -1
- package/dist/{textarea-C-sdNBRk.cjs → textarea-D9RWiR6u.cjs} +1 -1
- package/dist/{textarea-COHaMHpP.js → textarea-DB7FMtTf.js} +1 -1
- package/dist/{textinput-0DZeMqBr.js → textinput-Djl_yr1D.js} +1 -1
- package/dist/{textinput-BqBgsBZF.cjs → textinput-l31MdBd4.cjs} +1 -1
- package/dist/{timepicker-C_k-K1jA.cjs → timepicker-Bw8zkwV9.cjs} +1 -1
- package/dist/{timepicker-CvdI7jDN.js → timepicker-D_gNCZ2v.js} +1 -1
- package/package.json +2 -2
- package/src/components/calendar/calendar.constraints.test.ts +15 -0
- package/src/components/calendar/calendar.core.test.ts +15 -0
- package/src/components/calendar/calendar.ts +7 -15
- package/src/components/input-wrapper/input-wrapper.test.ts +1 -0
- package/src/components/input-wrapper/input-wrapper.ts +2 -2
- package/src/components/modal/modal.test.ts +141 -0
- package/src/components/modal/modal.ts +24 -5
- package/dist/calendar-C5QwPrbk.cjs +0 -91
- package/dist/modal-BKeSXrzi.cjs +0 -35
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs");require("./icon-jPhyZD1z.cjs");const n=require("./converters-BJ9Fe0kW.cjs");var r={multiple:!1,maxMultiple:0,range:!1,earliest:null,latest:null,weeknumbers:!1,withcontrols:!1};function i(e,t,r){let i=n.y(e,r?.in);return isNaN(t)?n.b(r?.in||e,NaN):(t&&i.setDate(i.getDate()+t),i)}function a(e,t){let[r,i]=n.v(e,t.start,t.end);return{start:r,end:i}}function o(e,t){let{start:r,end:i}=a(t?.in,e),o=+r>+i,s=o?+r:+i,c=o?i:r;c.setHours(0,0,0,0);let l=t?.step??1;if(!l)return[];l<0&&(l=-l,o=!o);let u=[];for(;+c<=s;)u.push(n.b(r,c)),c.setDate(c.getDate()+l),c.setHours(0,0,0,0);return o?u.reverse():u}function s(e,t){let r=n.y(e,t?.in).getDay();return r===0?7:r}function c(e,t){let r=(t.excludedates??[]).map(e=>typeof e==`string`?e:n.a(e));return!n.l(e,t.earliest,t.latest,r,t.excludeweekdays??[])}function l(e,t,n,r){return!!(c(e,n)||!t&&r.multiple&&r.maxMultiple>0&&r.selectedCount>=r.maxMultiple)}function u(e,t,r){let i=n.p(e,t,0);return!(r&&n.d(r)>i)}function d(e,t,r){let i=n.p(t===11?e+1:e,t===11?0:t+1,1);return!(r&&n.d(r)<i)}function f(e,t){let r=n.p(e,t,1),i=n.p(e,t+1,0),a=(r.getDay()+6)%7,o=i.getDate();return{firstDayOfMonth:r,lastDayOfMonth:i,startingDay:a,numDays:o,numRows:Math.ceil((o+a)/7),numDaysPrevMonth:n.p(e,t,0).getDate(),initialWeek:n._(r)}}function p(e,t,n,r){let{startingDay:i,numDays:a}=r;return e===0&&t<i?`prev-month`:n>a?`next-month`:`current-month`}function m(e,t,n,r){let{startingDay:i,numDaysPrevMonth:a,numDays:o}=r;return e===`prev-month`?a-(i-t-1):e===`next-month`?n-o:n}function h(e){return typeof e==`string`&&(e=e.split(`,`)),e.length===1&&e[0]===``?[]:e.map(e=>n.m(e))}function g(e,t){let r=o({start:e,end:t}),i={};if(Array.isArray(r)&&r.length)for(let a=0;a<r.length;a++){let o=r[a],s=o>e&&o<t;i[n.a(o)]=s}return i}function _(e,t,n,r){if(t.length!==1)return!0;let i=o({start:t[0],end:e});if(!Array.isArray(i)||!i.length)return!0;for(let a=0;a<i.length;a++){for(let r of n??[])if(r>t[0]&&r<e)return!1;if((r??[]).includes(s(i[a]).toString()))return!1}return!0}function v(e,t){let r=n.a(e);return t.includes(r)?t:[...t,r]}function y(e,t){let r=n.a(e),i=t.indexOf(r);if(i===-1)return t;if(t.length===1)return[];let a=[...t];return a.splice(i,1),a}function b(e,t,r){let i=n.a(e);return t.includes(i)?y(e,t):r>0&&t.length>=r?t:v(e,t)}function x(e,t,r){let i=n.a(e),a=h(t);return t.includes(i)?t.indexOf(i)===0?[]:y(e,t):t.length>1||t.length===1&&(!_(e,a,r.excludedates,r.excludeweekdays)||a[0]>e)?[i]:v(e,t)}var S={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7};function C(e){let t=e.nodeName;return t===`INPUT`||t===`SELECT`||t===`BUTTON`&&!e.dataset?.date}function w(e,t,r){let a=i(e,t);if(!a)return null;let o=r(`button[data-date="${n.a(a)}"]`);for(;o instanceof HTMLButtonElement&&o.dataset.disabled;)if(a=i(a,t),o=r(`button[data-date="${n.a(a)}"]`),!o)return null;return a}function T(e){return S[e]??null}var E=class extends e.t{constructor(...e){super(...e),this.selected=[],this.multiple=r.multiple,this.maxMultiple=r.maxMultiple,this.range=r.range,this.earliest=r.earliest,this.latest=r.latest,this.excludedates=[],this.excludeweekdays=[],this.weeknumbers=r.weeknumbers,this.withcontrols=r.withcontrols,this.currentmonth=null,this.today=null,this._selected=[],this.inRange={},this.rangeHovered=null,this.year=0,this.month=0,this.week=0,this.currentmonthtouched=!1,this.focusedDate=null,this.selectableDates=[],this.tabIndexSet=0}get calendarStrings(){let e=this.pktStrings.get(`dates`),t=this.pktStrings.get(`calendar`);return{daysShort:this.dayStrings??e.daysShort,days:this.dayStringsLong??e.days,months:this.monthStrings??e.months,week:this.weekString??e.week,prevMonth:this.prevMonthString??t.prevMonth,nextMonth:this.nextMonthString??t.nextMonth}}get todayDate(){return this.today?n.m(this.today):n.g()}firstUpdated(e){this.addEventListener(`keydown`,this.handleKeydown)}disconnectedCallback(){this.removeEventListener(`keydown`,this.handleKeydown),super.disconnectedCallback()}updated(e){super.updated(e),e.has(`selected`)&&this.convertSelected()}convertSelected(){typeof this.selected==`string`&&(this.selected=this.selected.split(`,`)),this.selected.length===1&&this.selected[0]===``&&(this.selected=[]),this._selected=h(this.selected),this.range&&this.selected.length===2&&(this.inRange=g(this._selected[0],this._selected[1])),this.setCurrentMonth()}setCurrentMonth(){if(this.currentmonth===null&&!this.currentmonthtouched&&(this.currentmonthtouched=!0),this.selected.length&&this.selected[0]!==``){let e=n.m(this.selected[this.selected.length-1]);this.currentmonth=isNaN(e.getTime())?n.f(this.todayDate):e}else this.currentmonth===null&&(this.currentmonth=n.f(this.todayDate));(!this.currentmonth||isNaN(this.currentmonth.getTime()))&&(this.currentmonth=n.f(this.todayDate)),this.year=this.currentmonth.getFullYear(),this.month=this.currentmonth.getMonth()}handleKeydown(e){let t=T(e.key);t!==null&&this.handleArrowKey(e,t)}handleArrowKey(e,t){let r=e.target;if(C(r))return;if(e.preventDefault(),!this.focusedDate){this.focusOnCurrentDate();return}let i=w(this.focusedDate?n.d(this.focusedDate):n.p(this.year,this.month,1),t,this.querySelector.bind(this));if(i){let e=this.querySelector(`button[data-date="${n.a(i)}"]`);e instanceof HTMLButtonElement&&!e.dataset.disabled&&(this.focusedDate=n.a(i),e.focus())}}render(){return e._`
|
|
2
|
-
<div
|
|
3
|
-
class="pkt-calendar ${this.weeknumbers?`pkt-cal-weeknumbers`:``}"
|
|
4
|
-
@focusout=${this.closeEvent}
|
|
5
|
-
@keydown=${e=>{e.key===`Escape`&&(e.preventDefault(),this.close())}}
|
|
6
|
-
>
|
|
7
|
-
<nav class="pkt-cal-month-nav">
|
|
8
|
-
${this.renderMonthNavButton(`prev`)} ${this.renderMonthNav()}
|
|
9
|
-
${this.renderMonthNavButton(`next`)}
|
|
10
|
-
</nav>
|
|
11
|
-
<table
|
|
12
|
-
class="pkt-cal-days pkt-txt-12-medium pkt-calendar__body"
|
|
13
|
-
role="grid"
|
|
14
|
-
?aria-multiselectable=${this.range||this.multiple}
|
|
15
|
-
>
|
|
16
|
-
<thead>
|
|
17
|
-
${this.renderDayNames()}
|
|
18
|
-
</thead>
|
|
19
|
-
<tbody>
|
|
20
|
-
${this.renderCalendarBody()}
|
|
21
|
-
</tbody>
|
|
22
|
-
</table>
|
|
23
|
-
</div>
|
|
24
|
-
`}renderMonthNavButton(t){let n=t===`prev`,r=n?this.isPrevMonthAllowed():this.isNextMonthAllowed(),{prevMonth:i,nextMonth:a}=this.calendarStrings,o=n?i:a,s=n?`chevron-thin-left`:`chevron-thin-right`,c=n?`pkt-calendar__prev-month`:`pkt-calendar__next-month`,l=n?()=>this.prevMonth():()=>this.nextMonth();return e._`<div>
|
|
25
|
-
<button
|
|
26
|
-
type="button"
|
|
27
|
-
aria-label="${o}"
|
|
28
|
-
@click=${()=>r&&l()}
|
|
29
|
-
@keydown=${e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r&&l())}}
|
|
30
|
-
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only ${c} ${r?``:`pkt-invisible`}"
|
|
31
|
-
.data-disabled=${r?e.h:`disabled`}
|
|
32
|
-
?aria-disabled=${!r}
|
|
33
|
-
tabindex=${r?`0`:`-1`}
|
|
34
|
-
>
|
|
35
|
-
<pkt-icon class="pkt-btn__icon" name="${s}"></pkt-icon>
|
|
36
|
-
<span class="pkt-btn__text">${o}</span>
|
|
37
|
-
</button>
|
|
38
|
-
</div>`}renderDayNames(){let t=[];this.weeknumbers&&t.push(e._`<th><div class="pkt-calendar__week-number">${this.calendarStrings.week}</div></th>`);let{days:n,daysShort:r}=this.calendarStrings;for(let i=0;i<r.length;i++)t.push(e._`<th>
|
|
39
|
-
<div class="pkt-calendar__day-name" aria-label="${n[i]}">${r[i]}</div>
|
|
40
|
-
</th>`);return e._`<tr class="pkt-cal-week-row">
|
|
41
|
-
${t}
|
|
42
|
-
</tr>`}renderMonthNav(){let t=this.pktStrings.get(`dates`);return this.withcontrols?e._`<div class="pkt-cal-month-picker">
|
|
43
|
-
<label for="${this.id}-monthnav" class="pkt-hide">${t.month}</label>
|
|
44
|
-
<select
|
|
45
|
-
aria-label="${t.month}"
|
|
46
|
-
class="pkt-input pkt-input-compact"
|
|
47
|
-
id="${this.id}-monthnav"
|
|
48
|
-
@change=${e=>{e.stopImmediatePropagation();let t=e.target;this.changeMonth(this.year,parseInt(t.value))}}
|
|
49
|
-
>
|
|
50
|
-
${this.calendarStrings.months.map((t,n)=>e._`<option value=${n} ?selected=${this.month===n}>${t}</option>`)}
|
|
51
|
-
</select>
|
|
52
|
-
<label for="${this.id}-yearnav" class="pkt-hide">${t.year}</label>
|
|
53
|
-
<input
|
|
54
|
-
aria-label="${t.year}"
|
|
55
|
-
class="pkt-input pkt-cal-input-year pkt-input-compact"
|
|
56
|
-
id="${this.id}-yearnav"
|
|
57
|
-
type="number"
|
|
58
|
-
size="4"
|
|
59
|
-
placeholder="0000"
|
|
60
|
-
@change=${e=>{e.stopImmediatePropagation();let t=e.target;this.changeMonth(parseInt(t.value),this.month)}}
|
|
61
|
-
.value=${this.year}
|
|
62
|
-
/>
|
|
63
|
-
</div>`:e._`<div class="pkt-txt-16-medium pkt-calendar__month-title" aria-live="polite">
|
|
64
|
-
${this.calendarStrings.months[this.month]} ${this.year}
|
|
65
|
-
</div>`}getDayViewData(e,t){let r=n.p(this.year,this.month,e),i=n.a(r),a=i===n.a(t),o=this.selected.includes(i),s=this.isDayDisabled(r,o),c=this.calculateTabIndex(i,s,e);return{currentDate:r,currentDateISO:i,isToday:a,isSelected:o,isDisabled:s,ariaLabel:n.o(r),tabindex:c}}getDateConstraints(){return{earliest:this.earliest,latest:this.latest,excludedates:this.excludedates,excludeweekdays:this.excludeweekdays}}isDayDisabled(e,t){return l(e,t,this.getDateConstraints(),{multiple:this.multiple,maxMultiple:this.maxMultiple,selectedCount:this.selected.length})}calculateTabIndex(e,t,n){return this.focusedDate?this.focusedDate===e&&!t?`0`:`-1`:!t&&this.tabIndexSet===0?(this.tabIndexSet=n,`0`):this.tabIndexSet===n?`0`:`-1`}getDayCellClasses(e){let{currentDateISO:t,isToday:r,isSelected:i}=e,a=this.range&&(this.selected.length===2||this.rangeHovered!==null)&&t===this.selected[0],o=this.range&&this.selected.length===2&&t===this.selected[1];return{"pkt-cal-today":r,"pkt-cal-selected":i,"pkt-cal-in-range":this.inRange[t],"pkt-cal-excluded":this.isExcluded(e.currentDate),"pkt-cal-in-range-first":a,"pkt-cal-in-range-last":o,"pkt-cal-range-hover":this.rangeHovered!==null&&t===n.a(this.rangeHovered)}}getDayButtonClasses(e){let{currentDateISO:t,isToday:r,isSelected:i,isDisabled:a}=e,o=this.range&&(this.selected.length===2||this.rangeHovered!==null)&&t===this.selected[0],s=this.range&&this.selected.length===2&&t===this.selected[1];return{"pkt-calendar__date":!0,"pkt-calendar__date--today":r,"pkt-calendar__date--selected":i,"pkt-calendar__date--disabled":a,"pkt-calendar__date--in-range":this.inRange[t],"pkt-calendar__date--in-range-hover":this.rangeHovered!==null&&t===n.a(this.rangeHovered),"pkt-calendar__date--range-start":o,"pkt-calendar__date--range-end":s}}handleDayFocus(e,t){this.range&&!this.isExcluded(e)&&this.handleRangeHover(e),this.focusedDate=t}renderDayView(n,r){let i=this.getDayViewData(n,r),{currentDate:a,currentDateISO:o,isSelected:s,isDisabled:c,ariaLabel:l,tabindex:u}=i;this.selectableDates.push({currentDateISO:o,isDisabled:c,tabindex:u});let d=this.getDayCellClasses(i),f=this.getDayButtonClasses(i);return e._`<td class=${t.t(d)}>
|
|
66
|
-
<button
|
|
67
|
-
type="button"
|
|
68
|
-
aria-pressed=${s?`true`:`false`}
|
|
69
|
-
?disabled=${c}
|
|
70
|
-
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only ${t.t(f)}"
|
|
71
|
-
@mouseover=${()=>this.range&&!this.isExcluded(a)&&this.handleRangeHover(a)}
|
|
72
|
-
@focus=${()=>this.handleDayFocus(a,o)}
|
|
73
|
-
aria-label="${l}"
|
|
74
|
-
tabindex=${u}
|
|
75
|
-
data-disabled=${c?`disabled`:e.h}
|
|
76
|
-
data-date=${o}
|
|
77
|
-
@keydown=${e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),this.handleDateSelect(a))}}
|
|
78
|
-
@click=${e=>{c||(e.preventDefault(),this.handleDateSelect(a))}}
|
|
79
|
-
>
|
|
80
|
-
<span class="pkt-btn__text pkt-txt-14-light">${n}</span>
|
|
81
|
-
</button>
|
|
82
|
-
</td>`}renderEmptyDayCell(t){return e._`<td class="pkt-cal-other">
|
|
83
|
-
<div
|
|
84
|
-
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
|
|
85
|
-
data-disabled="disabled"
|
|
86
|
-
>
|
|
87
|
-
<span class="pkt-btn__text pkt-txt-14-light">${t}</span>
|
|
88
|
-
</div>
|
|
89
|
-
</td>`}renderWeekRow(t){return e._`<tr class="pkt-cal-week-row" role="row">
|
|
90
|
-
${t}
|
|
91
|
-
</tr>`}renderCalendarBody(){let t=this.todayDate,n=f(this.year,this.month);this.selectableDates=[],this.tabIndexSet=0;let r=1;this.week=n.initialWeek;let i=[];for(let a=0;a<n.numRows;a++){let o=[];this.weeknumbers&&o.push(e._`<td class="pkt-cal-week">${this.week}</td>`),this.week++;for(let e=0;e<7;e++){let i=p(a,e,r,n);if(i===`current-month`)o.push(this.renderDayView(r,t)),r++;else{let t=m(i,e,r,n);o.push(this.renderEmptyDayCell(t)),i===`next-month`&&r++}}i.push(this.renderWeekRow(o))}return i}isExcluded(e){return c(e,this.getDateConstraints())}isPrevMonthAllowed(){return u(this.year,this.month,this.earliest)}prevMonth(){let e=this.month===0?11:this.month-1,t=this.month===0?this.year-1:this.year;this.changeMonth(t,e)}isNextMonthAllowed(){return d(this.year,this.month,this.latest)}nextMonth(){let e=this.month===11?0:this.month+1,t=this.month===11?this.year+1:this.year;this.changeMonth(t,e)}changeMonth(e,t){this.year=typeof e==`string`?parseInt(e):e,this.month=typeof t==`string`?parseInt(t):t,this.currentmonth=n.f(new Date(this.year,this.month,1)),this.tabIndexSet=0,this.focusedDate=null,this.selectableDates=[]}emptySelected(){this.selected=[],this._selected=[],this.inRange={}}normalizeSelected(){return typeof this.selected==`string`?this.selected.split(`,`):this.selected}addToSelected(e){this.selected=v(e,this.normalizeSelected()),this._selected=h(this.selected),this.range&&this.selected.length===2&&(this.convertSelected(),this.close())}removeFromSelected(e){this.selected=y(e,this.normalizeSelected()),this._selected=h(this.selected)}toggleSelected(e){this.selected=b(e,this.normalizeSelected(),this.maxMultiple),this._selected=h(this.selected)}isRangeAllowed(e){return _(e,this._selected,this.excludedates,this.excludeweekdays)}handleRangeSelect(e){return this.selected=x(e,this.normalizeSelected(),{excludedates:this.excludedates,excludeweekdays:this.excludeweekdays}),this._selected=h(this.selected),this.selected.length===2?(this.convertSelected(),this.close()):this.selected.length===1&&(this.inRange={}),Promise.resolve()}handleRangeHover(e){if(!this.range||this._selected.length!==1||!this.isRangeAllowed(e)||this._selected[0]>=e){this.rangeHovered=null;return}this.rangeHovered=e,this.inRange=g(this._selected[0],e)}handleDateSelect(e){return e?(this.range?this.handleRangeSelect(e):this.multiple?this.toggleSelected(e):(this.selected.includes(n.a(e))?this.emptySelected():(this.emptySelected(),this.addToSelected(e)),this.close()),this.dispatchEvent(new CustomEvent(`date-selected`,{detail:this.selected,bubbles:!0,composed:!0})),Promise.resolve()):Promise.resolve()}focusOnCurrentDate(){let e=n.a(n.f(this.todayDate)),t=this.querySelector(`button[data-date="${e}"]`);if(t instanceof HTMLButtonElement){this.focusedDate=e,t.focus();return}let r=this.selectableDates.find(e=>!e.isDisabled);if(r){let e=this.querySelector(`button[data-date="${r.currentDateISO}"]`);e instanceof HTMLButtonElement&&(this.focusedDate=r.currentDateISO,e.focus())}}closeEvent(e){let t=e.target,n=e.relatedTarget;this.contains(n)||t.classList.contains(`pkt-invisible`)||t.closest(`.pkt-cal-month-picker`)||this.close()}close(){this.dispatchEvent(new CustomEvent(`close`,{detail:!0,bubbles:!0,composed:!0}))}};e.n([e.u({converter:n.t.csvToArray})],E.prototype,`selected`,void 0),e.n([e.u({type:Boolean})],E.prototype,`multiple`,void 0),e.n([e.u({type:Number,attribute:`max-multiple`})],E.prototype,`maxMultiple`,void 0),e.n([e.u({type:Boolean})],E.prototype,`range`,void 0),e.n([e.u({type:String})],E.prototype,`earliest`,void 0),e.n([e.u({type:String})],E.prototype,`latest`,void 0),e.n([e.u({converter:n.t.stringsToDate})],E.prototype,`excludedates`,void 0),e.n([e.u({converter:n.t.csvToArray})],E.prototype,`excludeweekdays`,void 0),e.n([e.u({type:Boolean})],E.prototype,`weeknumbers`,void 0),e.n([e.u({type:Boolean})],E.prototype,`withcontrols`,void 0),e.n([e.u({converter:n.t.stringToDate})],E.prototype,`currentmonth`,void 0),e.n([e.u({type:String})],E.prototype,`today`,void 0),e.n([e.u({type:Array,attribute:`day-strings`})],E.prototype,`dayStrings`,void 0),e.n([e.u({type:Array,attribute:`day-strings-long`})],E.prototype,`dayStringsLong`,void 0),e.n([e.u({type:Array,attribute:`month-strings`})],E.prototype,`monthStrings`,void 0),e.n([e.u({type:String,attribute:`week-string`})],E.prototype,`weekString`,void 0),e.n([e.u({type:String,attribute:`prev-month-string`})],E.prototype,`prevMonthString`,void 0),e.n([e.u({type:String,attribute:`next-month-string`})],E.prototype,`nextMonthString`,void 0),e.n([e.u({type:Array})],E.prototype,`_selected`,void 0),e.n([e.l()],E.prototype,`inRange`,void 0),e.n([e.u({type:Date})],E.prototype,`rangeHovered`,void 0),e.n([e.u({type:Number})],E.prototype,`year`,void 0),e.n([e.u({type:Number})],E.prototype,`month`,void 0),e.n([e.u({type:Number})],E.prototype,`week`,void 0),e.n([e.l()],E.prototype,`currentmonthtouched`,void 0),e.n([e.l()],E.prototype,`focusedDate`,void 0);try{e.d(`pkt-calendar`)(E)}catch{console.warn(`Forsøker å definere <pkt-calendar>, men den er allerede definert`)}var D=E;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return D}});
|
package/dist/modal-BKeSXrzi.cjs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./element-with-slot-CcJPCLgn.cjs");require("./icon-jPhyZD1z.cjs");const r=require("./ref-CB7e9nMY.cjs"),i=require("./scroll-lock-B46ur0FF.cjs");var a={name:`pkt-modal`,react:`PktModal`,"css-class":`pkt-modal`,isElement:!0,isPureReact:!0,events:{"background-click":{description:`Event som trigges når bakgrunnen trykkes på`},close:{description:`Event som trigges når meldingsboksen lukkes`}},props:{open:{name:`Åpen`,description:`Deklarativ styring av modalens åpen/lukket-tilstand. Kan brukes i stedet for showModal()/close()-metodene.`,type:`boolean`,category:`tech`,default:!1},headingText:{name:`Heading text`,description:`Heading tekst på modalen`,type:`string`,category:`contents`},hideCloseButton:{name:`Gjem 'Lukk'-knapp`,description:`Gjemmer lukkeknappen. Dersom denne er satt til true, vil ikke lukkeknappen vises, og dermed er det viktig at man tilbyr en annen måte som f.eks. en knapp for å lukke modalen på.`,type:`boolean`,category:`ui`,default:!1},closeOnBackdropClick:{name:`Lukk modalen når bakgrunnen trykkes på`,description:`Lukk modalen når bakgrunnen trykkes på`,type:`boolean`,category:`tech`,default:!1},closeButtonSkin:{name:`Stil på lukkeknappen`,description:`Stil på lukkeknappen`,type:[`blue`,`yellow-filled`],category:`ui`,default:`blue`},size:{name:`Størrelse`,description:`Størrelsen på modalen`,type:[`small`,`medium`,`large`,`fit-content`],category:`ui`,default:`medium`},variant:{name:`Variant`,description:`Standard dialog eller skuff`,type:[`dialog`,`drawer`],category:`ui`,default:`dialog`},drawerPosition:{name:`Skuffposisjon`,description:`Posisjonen til skuffen`,type:[`left`,`right`],category:`ui`,default:`right`},transparentBackdrop:{name:`Gjennomsiktig bakgrunn`,description:`Bakgrunnen er gjennomsiktig`,type:`boolean`,category:`ui`,default:!1},removePadding:{name:`Fjern padding`,description:`Fjerner paddingen rundt innholdet i modalen`,type:`boolean`,category:`ui`,default:!1}},slots:{default:{description:`Innholdet i meldingen. Her tilbyr vi støtteklasser for å style 1-3 knapper i modalen.`}}},o=class extends n.t{constructor(){super(),this.open=!1,this.headingText=``,this.removePadding=!1,this.hideCloseButton=a.props.hideCloseButton.default,this.closeOnBackdropClick=a.props.closeOnBackdropClick.default,this.closeButtonSkin=`blue`,this.size=a.props.size.default,this.variant=`dialog`,this.drawerPosition=`right`,this.transparentBackdrop=!1,this.dialogRef=r.t(),this._scrollLockToken=i.t(),this._isOpen=!1,this.close=(e,t=!1)=>{if(!this._isOpen)return;this._isOpen=!1,this.open=!1,i.n(this._scrollLockToken,!1);let n=document.activeElement;n&&!this.isElementInViewport(n)&&n.scrollIntoView({behavior:`smooth`,block:`nearest`}),this.dispatchEvent(new CustomEvent(`close`,{detail:{origin:e},bubbles:!0,composed:!0})),t||this.dialogRef.value?.close(),this.requestUpdate()},this.showModal=(e=null)=>{this._isOpen=!0,this.open=!0,this.dialogRef.value?.showModal(),i.n(this._scrollLockToken,!0),this.dispatchEvent(new CustomEvent(`showModal`,{detail:{origin:e},bubbles:!0,composed:!0})),this.requestUpdate()},this._isOpen=!1}async connectedCallback(){super.connectedCallback(),document.addEventListener(`keydown`,this.handleKeyDown.bind(this)),document.addEventListener(`click`,this.handleBackdropClick.bind(this))}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`click`,this.handleBackdropClick),i.n(this._scrollLockToken,!1)}updated(e){super.updated(e),e.has(`open`)&&(this.open&&!this._isOpen?this.showModal():!this.open&&this._isOpen&&this.close(new Event(`close`),!1))}async firstUpdated(e){super.firstUpdated(e),this.dialogRef.value&&!window.HTMLDialogElement&&!this.dialogRef.value.showModal&&(`document`in window&&`createElement`in document&&(await Promise.resolve().then(()=>require("./dialog-polyfill.esm-B-g35ove.cjs")).then(e=>e.default)).registerDialog(this.dialogRef.value),this.dialogRef.value.addEventListener(`close`,()=>{this.close(new Event(`close`),!0)}))}handleKeyDown(e){e.key===`Escape`&&this.close(e)}handleBackdropClick(e){this.closeOnBackdropClick&&e.target===this.dialogRef?.value&&this.close(e)}isElementInViewport(e){let t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}render(){let i={"pkt-modal":!0,"pkt-modal--removePadding":this.removePadding??!1,"pkt-modal--noHeadingText":this.headingText===``||this.headingText===void 0,"pkt-modal--noShadow":this.closeButtonSkin===`yellow-filled`,"pkt-modal--transparentBackdrop":this.transparentBackdrop??!1,[`pkt-modal--${this.size}`]:this.size!==void 0,[`pkt-modal__${this.variant}`]:this.variant!==void 0,[`pkt-modal__drawer--${this.drawerPosition}`]:this.variant===`drawer`},a={"pkt-modal__headingText":!0,"pkt-txt-24":!0},o={"pkt-modal__content":!0,"pkt-txt-18-light":!0},s=this.closeButtonSkin===`blue`,c={"pkt-modal__closeButton":!0,[`pkt-modal__closeButton--${this.closeButtonSkin}`]:!0};return e._`
|
|
2
|
-
<dialog
|
|
3
|
-
class=${t.t(i)}
|
|
4
|
-
${r.n(this.dialogRef)}
|
|
5
|
-
aria-labelledby=${this.headingText?`pkt-modal__headingText`:e.h}
|
|
6
|
-
aria-describedby="pkt-modal__content"
|
|
7
|
-
@close=${e=>this.close(e,!0)}
|
|
8
|
-
>
|
|
9
|
-
<div class="pkt-modal__wrapper">
|
|
10
|
-
${this.headingText||!this.hideCloseButton?e._`<div class="pkt-modal__header">
|
|
11
|
-
<div class="pkt-modal__header-background"></div>
|
|
12
|
-
${this.headingText?e._`<h1 id="pkt-modal__headingText" class=${t.t(a)}>
|
|
13
|
-
${this.headingText}
|
|
14
|
-
</h1>`:e._`<div class="pkt-modal__headingText"></div>`}
|
|
15
|
-
${this.hideCloseButton?e._`<div class="pkt-modal__noCloseButton"></div>`:e._`<div class="${t.t(c)}">
|
|
16
|
-
<pkt-button
|
|
17
|
-
@click=${e=>this.close(e)}
|
|
18
|
-
aria-label=${this.pktStrings.get(`generic`).close}
|
|
19
|
-
iconname="close"
|
|
20
|
-
variant="icon-only"
|
|
21
|
-
size="medium"
|
|
22
|
-
skin=${s?`tertiary`:`primary`}
|
|
23
|
-
>
|
|
24
|
-
${this.pktStrings.get(`generic`).close}
|
|
25
|
-
</pkt-button>
|
|
26
|
-
</div>`}
|
|
27
|
-
</div>`:e.h}
|
|
28
|
-
<div class="pkt-modal__container">
|
|
29
|
-
<div id="pkt-modal__content" class=${t.t(o)}>
|
|
30
|
-
${n.i(this)}
|
|
31
|
-
</div>
|
|
32
|
-
</div>
|
|
33
|
-
</div>
|
|
34
|
-
</dialog>
|
|
35
|
-
`}};e.n([e.u({type:Boolean,reflect:!0})],o.prototype,`open`,void 0),e.n([e.u({type:String})],o.prototype,`headingText`,void 0),e.n([e.u({type:Boolean})],o.prototype,`removePadding`,void 0),e.n([e.u({type:Boolean})],o.prototype,`hideCloseButton`,void 0),e.n([e.u({type:Boolean})],o.prototype,`closeOnBackdropClick`,void 0),e.n([e.u({type:String})],o.prototype,`closeButtonSkin`,void 0),e.n([e.u({type:String})],o.prototype,`size`,void 0),e.n([e.u({type:String})],o.prototype,`variant`,void 0),e.n([e.u({type:String})],o.prototype,`drawerPosition`,void 0),e.n([e.u({type:Boolean})],o.prototype,`transparentBackdrop`,void 0),e.n([e.l()],o.prototype,`_isOpen`,void 0);try{e.d(`pkt-modal`)(o)}catch{console.warn(`Forsøker å definere <pkt-modal>, men den er allerede definert`)}var s=o;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
|