@oslokommune/punkt-elements 12.2.0 → 12.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -0
- package/dist/alert.d.ts +1 -0
- package/dist/calendar.d.ts +1 -0
- package/dist/card.d.ts +1 -0
- package/dist/class-map-CA8wadiN.cjs +5 -0
- package/dist/class-map-DiT0qP3E.js +34 -0
- package/dist/component-template.d.ts +1 -0
- package/dist/converters-DNCwIFwr.js +17 -0
- package/dist/converters-DhM11VlY.cjs +1 -0
- package/dist/datepicker.d.ts +1 -0
- package/dist/directive-19_ixLKS.cjs +9 -0
- package/dist/directive-DA0-wdk7.js +38 -0
- package/dist/element.d.ts +1 -0
- package/dist/icon.d.ts +1 -0
- package/dist/index-BHzxfdBK.js +807 -0
- package/dist/index-BJ_4AGO3.cjs +23 -0
- package/dist/index-BlHnvy7v.js +82 -0
- package/dist/index-CPvZ03uX.js +577 -0
- package/dist/index-DSplpVWQ.cjs +9 -0
- package/dist/index-DkGcZra2.cjs +90 -0
- package/dist/index.d.ts +393 -3
- package/dist/input-wrapper.d.ts +1 -0
- package/dist/link.d.ts +1 -0
- package/dist/messagebox.d.ts +1 -0
- package/dist/pkt-alert.cjs +27 -0
- package/dist/pkt-alert.js +86 -0
- package/dist/pkt-calendar.cjs +1 -0
- package/dist/pkt-calendar.js +10 -0
- package/dist/pkt-card.cjs +23 -0
- package/dist/pkt-card.js +177 -0
- package/dist/pkt-component-template.cjs +29 -0
- package/dist/{pkt-el-component-template.js → pkt-component-template.js} +25 -26
- package/dist/pkt-datepicker.cjs +140 -0
- package/dist/pkt-datepicker.js +1769 -0
- package/dist/pkt-element.cjs +1 -0
- package/dist/pkt-element.js +5 -0
- package/dist/pkt-icon.cjs +1 -0
- package/dist/pkt-icon.js +6 -0
- package/dist/pkt-index.cjs +1 -0
- package/dist/pkt-index.js +20 -0
- package/dist/pkt-input-wrapper.cjs +59 -0
- package/dist/pkt-input-wrapper.js +293 -0
- package/dist/pkt-link.cjs +3 -0
- package/dist/pkt-link.js +90 -0
- package/dist/pkt-messagebox.cjs +12 -0
- package/dist/pkt-messagebox.js +62 -0
- package/dist/pkt-tag.cjs +17 -0
- package/dist/pkt-tag.js +151 -0
- package/dist/ref-Bk590hog.cjs +13 -0
- package/dist/ref-Co_S0Cgj.js +173 -0
- package/dist/state-BRgFbJX9.js +12 -0
- package/dist/state-D2tUtTi6.cjs +5 -0
- package/dist/tag.d.ts +1 -0
- package/package.json +10 -7
- package/src/components/alert/index.ts +86 -0
- package/src/components/calendar/index.ts +391 -143
- package/src/components/card/index.ts +78 -0
- package/src/components/component-template/index.ts +25 -9
- package/src/components/datepicker/index.ts +546 -0
- package/src/components/element/index.ts +181 -8
- package/src/components/icon/index.ts +44 -49
- package/src/components/index.ts +7 -1
- package/src/components/input-wrapper/index.ts +260 -0
- package/src/components/link/index.ts +51 -0
- package/src/components/messagebox/index.ts +63 -0
- package/src/components/tag/index.ts +110 -0
- package/dist/components/calendar/index.d.ts +0 -59
- package/dist/components/component-template/index.d.ts +0 -34
- package/dist/components/element/index.d.ts +0 -24
- package/dist/components/icon/index.d.ts +0 -29
- package/dist/components/index.d.ts +0 -3
- package/dist/controllers/pkt-slot-controller.d.ts +0 -11
- package/dist/converters-Bi8tmNvQ.cjs +0 -5
- package/dist/converters-DMveycvc.js +0 -100
- package/dist/directive-C7mkmyiy.js +0 -573
- package/dist/directive-DfhMJ1ie.cjs +0 -23
- package/dist/helpers/converters.d.ts +0 -3
- package/dist/index-0PZgk9Oc.js +0 -159
- package/dist/index-xoVy6sfy.cjs +0 -13
- package/dist/pkt-el-calendar.cjs +0 -60
- package/dist/pkt-el-calendar.js +0 -1496
- package/dist/pkt-el-component-template.cjs +0 -29
- package/dist/pkt-el-element.cjs +0 -1
- package/dist/pkt-el-element.js +0 -5
- package/dist/pkt-el-icon.cjs +0 -9
- package/dist/pkt-el-icon.js +0 -98
- package/dist/pkt-el-index.cjs +0 -1
- package/dist/pkt-el-index.js +0 -8
- package/dist/property-BBVRv-DT.js +0 -47
- package/dist/property-CK6SFc5B.cjs +0 -9
- package/dist/src/translations/no.json.d.ts +0 -43
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";const r=require("./index-BJ_4AGO3.cjs"),w=require("./converters-DhM11VlY.cjs"),$=require("./directive-19_ixLKS.cjs"),x=require("./state-D2tUtTi6.cjs"),P=require("./class-map-CA8wadiN.cjs");require("./index-DSplpVWQ.cjs");function k(i){const e=Object.prototype.toString.call(i);return i instanceof Date||typeof i=="object"&&e==="[object Date]"?new i.constructor(+i):typeof i=="number"||e==="[object Number]"||typeof i=="string"||e==="[object String]"?new Date(i):new Date(NaN)}function D(i,e){return i instanceof Date?new i.constructor(e):new Date(e)}const M=6048e5,_=864e5;let A={};function v(){return A}function m(i,e){var h,c,d,p;const t=v(),s=(e==null?void 0:e.weekStartsOn)??((c=(h=e==null?void 0:e.locale)==null?void 0:h.options)==null?void 0:c.weekStartsOn)??t.weekStartsOn??((p=(d=t.locale)==null?void 0:d.options)==null?void 0:p.weekStartsOn)??0,n=k(i),a=n.getDay(),l=(a<s?7:0)+a-s;return n.setDate(n.getDate()-l),n.setHours(0,0,0,0),n}function b(i,e){const t=k(i.start),s=k(i.end);let n=+t>+s;const a=n?+t:+s,l=n?s:t;l.setHours(0,0,0,0);let h=1;const c=[];for(;+l<=a;)c.push(k(l)),l.setDate(l.getDate()+h),l.setHours(0,0,0,0);return n?c.reverse():c}function O(i,e){var p,u,f,y;const t=k(i),s=t.getFullYear(),n=v(),a=(e==null?void 0:e.firstWeekContainsDate)??((u=(p=e==null?void 0:e.locale)==null?void 0:p.options)==null?void 0:u.firstWeekContainsDate)??n.firstWeekContainsDate??((y=(f=n.locale)==null?void 0:f.options)==null?void 0:y.firstWeekContainsDate)??1,l=D(i,0);l.setFullYear(s+1,0,a),l.setHours(0,0,0,0);const h=m(l,e),c=D(i,0);c.setFullYear(s,0,a),c.setHours(0,0,0,0);const d=m(c,e);return t.getTime()>=h.getTime()?s+1:t.getTime()>=d.getTime()?s:s-1}function I(i,e){var h,c,d,p;const t=v(),s=(e==null?void 0:e.firstWeekContainsDate)??((c=(h=e==null?void 0:e.locale)==null?void 0:h.options)==null?void 0:c.firstWeekContainsDate)??t.firstWeekContainsDate??((p=(d=t.locale)==null?void 0:d.options)==null?void 0:p.firstWeekContainsDate)??1,n=O(i,e),a=D(i,0);return a.setFullYear(n,0,s),a.setHours(0,0,0,0),m(a,e)}function S(i,e){const t=k(i),s=+m(t,e)-+I(t,e);return Math.round(s/M)+1}function T(i){let t=k(i).getDay();return t===0&&(t=7),t}const E="pkt-calendar",R={id:{type:"string",name:"ID",description:"Unique identifier for the calendar"},currentmonth:{type:"date",converter:"stringToDate",description:"The current month to display"},selected:{type:"array",converter:"csvToArray",reflect:!0,items:{type:"date"},description:"Array of selected dates"},excludeweekdays:{type:"array",converter:"csvToArray",items:{type:"string"},description:"Array of weekdays (1-7) to exclude"},excludedates:{type:"array",converter:"stringsToDate",items:{type:"date"},description:"Array of specific dates to exclude"},earliest:{type:"date",converter:"stringToDate",default:null,description:"Earliest selectable date"},latest:{type:"date",converter:"stringToDate",default:null,description:"Latest selectable date"},weeknumbers:{type:"boolean",reflect:!0,default:!1,description:"Show week numbers in calendar"},withcontrols:{type:"boolean",reflect:!0,default:!1,description:"Show month and year navigation controls"},multiple:{type:"boolean",reflect:!0,default:!1,description:"Allow multiple date selection"},maxMultiple:{type:"number",default:4,description:"Maximum number of dates that can be selected"},range:{type:"boolean",reflect:!0,default:!1,description:"Allow date range selection"}},W={"date-selected":{description:"Returns ISO formatted date string"}},g={name:E,"css-class":"pkt-calendar",props:R,events:W};var H=Object.defineProperty,N=Object.getOwnPropertyDescriptor,o=(i,e,t,s)=>{for(var n=s>1?void 0:s?N(e,t):e,a=i.length-1,l;a>=0;a--)(l=i[a])&&(n=(s?l(e,t,n):l(n))||n);return s&&n&&H(e,t,n),n};exports.PktCalendar=class extends r.PktElement{constructor(){super(),this.multiple=g.props.multiple.default,this.maxMultiple=g.props.maxMultiple.default,this.range=g.props.range.default,this.weeknumbers=g.props.weeknumbers.default,this.withcontrols=g.props.withcontrols.default,this.focused=!1,this.selected=[],this.earliest=g.props.earliest.default,this.latest=g.props.latest.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=new Date,this.dayStrings=this.strings.dates.daysShort,this.monthStrings=this.strings.dates.months,this.weekString=this.strings.dates.week,this.prevMonthString=this.strings.dates.prevMonth,this.nextMonthString=this.strings.dates.nextMonth,this._selected=[],this.year=0,this.month=0,this.week=0,this.rangeHovered=null,this.inRange={},this.focusedDate=null,this.selectableDates=[]}connectedCallback(){const e=this.currentmonth;this.year=e.getFullYear(),this.month=e.getMonth(),this.week=S(new Date(this.year,this.month,1,12)),this.selected&&this.selected.length&&this.selected.forEach(t=>{this._selected.push(new Date(t))}),super.connectedCallback()}disconnectedCallback(){this.removeEventListener("keydown",this.handleKeydown),super.disconnectedCallback()}updated(e){if(e.has("selected")&&this.selected.length===2){const t=b({start:new Date(this.selected[0]),end:new Date(this.selected[1])});if(this.inRange={},Array.isArray(t)&&t.length){const s={};for(let n=0;n<t.length;n++)s[this.formatISODate(t[n])]=this.isInRange(t[n]);this.inRange=s}}super.updated(e)}firstUpdated(e){this.addEventListener("keydown",this.handleKeydown)}handleKeydown(e){switch(e.key){case"ArrowLeft":this.handleArrowKey(e,-1);break;case"ArrowRight":this.handleArrowKey(e,1);break;case"ArrowUp":this.handleArrowKey(e,-7);break;case"ArrowDown":this.handleArrowKey(e,7);break}}handleArrowKey(e,t){if(e.preventDefault(),!this.focusedDate)return;const s=new Date(this.focusedDate);let n=new Date(s.setDate(s.getDate()+t));if(n){let a=this.querySelector(`div[data-date="${this.formatISODate(n)}"]`);if(a instanceof HTMLDivElement){if(a.dataset.disabled){let l=new Date(s.setDate(s.getDate()+t)),h=this.querySelector(`div[data-date="${this.formatISODate(l)}"]`);for(;h&&h instanceof HTMLDivElement&&h.dataset.disabled;)l=new Date(l.setDate(l.getDate()+t)),h=this.querySelector(`div[data-date="${this.formatISODate(l)}"]`);a=h}a instanceof HTMLDivElement&&!a.dataset.disabled&&a.focus()}}}render(){return r.ke`
|
|
2
|
+
<div
|
|
3
|
+
class="pkt-calendar ${this.weeknumbers?"pkt-cal-weeknumbers":r.D}"
|
|
4
|
+
@focusout=${this.closeEvent}
|
|
5
|
+
@keydown=${e=>{e.key==="Escape"&&(e.preventDefault(),this.close())}}
|
|
6
|
+
>
|
|
7
|
+
<nav class="pkt-cal-month-nav">
|
|
8
|
+
<div
|
|
9
|
+
@click=${this.isPrevMonthAllowed()&&this.prevMonth}
|
|
10
|
+
@keydown=${e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.isNextMonthAllowed()&&this.prevMonth())}}
|
|
11
|
+
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
12
|
+
.data-disabled=${this.isPrevMonthAllowed()?r.D:"disabled"}
|
|
13
|
+
?aria-disabled=${!this.isPrevMonthAllowed()}
|
|
14
|
+
tabindex="0"
|
|
15
|
+
>
|
|
16
|
+
<pkt-icon class="pkt-btn__icon" name="chevron-thin-left"></pkt-icon>
|
|
17
|
+
<span class="pkt-btn__text">${this.prevMonthString}</span>
|
|
18
|
+
</div>
|
|
19
|
+
${this.renderMonthNav()}
|
|
20
|
+
<div
|
|
21
|
+
@click=${this.isNextMonthAllowed()&&this.nextMonth}
|
|
22
|
+
@keydown=${e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.isNextMonthAllowed()&&this.nextMonth())}}
|
|
23
|
+
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
24
|
+
.data-disabled=${this.isNextMonthAllowed()?r.D:"disabled"}
|
|
25
|
+
?aria-disabled=${!this.isNextMonthAllowed()}
|
|
26
|
+
tabindex="0"
|
|
27
|
+
>
|
|
28
|
+
<pkt-icon class="pkt-btn__icon" name="chevron-thin-right"></pkt-icon>
|
|
29
|
+
<span class="pkt-btn__text">${this.nextMonthString}</span>
|
|
30
|
+
</div>
|
|
31
|
+
</nav>
|
|
32
|
+
<table
|
|
33
|
+
class="pkt-cal-days pkt-txt-12-medium"
|
|
34
|
+
role="grid"
|
|
35
|
+
?aria-multiselectable=${this.range||this.multiple}
|
|
36
|
+
>
|
|
37
|
+
${this.renderDayNames()} ${this.renderCalendarBody()}
|
|
38
|
+
</table>
|
|
39
|
+
</div>
|
|
40
|
+
`}renderDayNames(){const e=[];this.weeknumbers&&e.push(r.ke`<td><div>${this.weekString}<div></td>`);for(let t=0;t<this.dayStrings.length;t++)e.push(r.ke`<td><div>${this.dayStrings[t]}</div></td>`);return r.ke`<tr class="pkt-cal-week-row" role="presentation">
|
|
41
|
+
${e}
|
|
42
|
+
</tr>`}renderMonthNav(){let e=[];return this.withcontrols?e.push(r.ke`<div class="pkt-cal-month-picker">
|
|
43
|
+
<select
|
|
44
|
+
class="pkt-input pkt-input-compact"
|
|
45
|
+
@change=${t=>{this.changeMonth(this.year,t.target.value)}}
|
|
46
|
+
>
|
|
47
|
+
${this.monthStrings.map((t,s)=>r.ke`<option value=${s} ?selected=${this.month===s}>${t}</option>`)}
|
|
48
|
+
</select>
|
|
49
|
+
<input
|
|
50
|
+
class="pkt-input pkt-cal-input-year pkt-input-compact"
|
|
51
|
+
type="number"
|
|
52
|
+
size="4"
|
|
53
|
+
placeholder="0000"
|
|
54
|
+
@change=${t=>{this.changeMonth(t.target.value,this.month)}}
|
|
55
|
+
value="${this.year}"
|
|
56
|
+
/>
|
|
57
|
+
</div> `):e.push(r.ke`<div class="pkt-txt-16-medium" aria-live="polite">
|
|
58
|
+
${this.monthStrings[this.month]} ${this.year}
|
|
59
|
+
</div>`),e}renderDayView(e,t,s){const n=new Date(this.year,this.month,e,12),a=this.formatISODate(n),l=a===this.formatISODate(t),h=this.selected.includes(a),c=this.isExcluded(s,n)||!h&&this.multiple&&this.maxMultiple>0&&this.selected.length>=this.maxMultiple,d=this.focusedDate?this.focusedDate===a?"0":"-1":e===1?"0":"-1";this.selectableDates.push({currentDateISO:a,isDisabled:c});const p={"pkt-cal-today":l,"pkt-cal-selected":h,"pkt-cal-in-range":this.inRange[a],"pkt-cal-excluded":this.isExcluded(s,n),"pkt-cal-in-range-first":this.range&&(this.selected.length===2||this.rangeHovered!==null)&&a===this.selected[0],"pkt-cal-in-range-last":this.range&&this.selected.length===2&&a===this.selected[1],"pkt-cal-range-hover":this.rangeHovered!==null&&a===this.formatISODate(this.rangeHovered)};return r.ke`<td class=${P.Rt(p)}>
|
|
60
|
+
<div
|
|
61
|
+
?aria-selected=${h}
|
|
62
|
+
role="gridcell"
|
|
63
|
+
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
|
|
64
|
+
@mouseover=${()=>this.range&&!this.isExcluded(s,n)&&this.handleRangeHover(n)}
|
|
65
|
+
@focus=${()=>{this.range&&!this.isExcluded(s,n)&&this.handleRangeHover(n),this.focusedDate=a}}
|
|
66
|
+
tabindex=${d}
|
|
67
|
+
data-disabled=${c?"disabled":r.D}
|
|
68
|
+
data-date=${a}
|
|
69
|
+
@keydown=${u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),this.handleDateSelect(n))}}
|
|
70
|
+
@click=${u=>{c||(u.preventDefault(),this.handleDateSelect(n))}}
|
|
71
|
+
>
|
|
72
|
+
<span class="pkt-btn__text pkt-txt-14-light">${e}</span>
|
|
73
|
+
</div>
|
|
74
|
+
</td>`}renderCalendarBody(){const e=new Date,t=new Date(this.year,this.month,1,12),s=new Date(this.year,this.month+1,0,12),n=(t.getDay()+6)%7,a=s.getDate(),l=Math.ceil((a+n)/7),c=new Date(this.year,this.month,0,12).getDate();let d=1;this.week=S(new Date(this.year,this.month,1,12));const p=[];for(let u=0;u<l;u++){const f=[];this.weeknumbers&&f.push(r.ke`<td class="pkt-cal-week">${this.week}</td>`),this.week++;for(let y=1;y<8;y++)if(u===0&&y<n+1){const C=c-(n-y-1);f.push(r.ke`<td class="pkt-cal-other">
|
|
75
|
+
<div
|
|
76
|
+
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
|
|
77
|
+
data-disabled="disabled"
|
|
78
|
+
>
|
|
79
|
+
<span class="pkt-btn__text pkt-txt-14-light">${C}</span>
|
|
80
|
+
</div>
|
|
81
|
+
</td>`)}else d>a?(f.push(r.ke`<td class="pkt-cal-other">
|
|
82
|
+
<div
|
|
83
|
+
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
|
|
84
|
+
data-disabled="disabled"
|
|
85
|
+
>
|
|
86
|
+
<span class="pkt-btn__text pkt-txt-14-light">${d-a}</span>
|
|
87
|
+
</div>
|
|
88
|
+
</td>`),d++):(f.push(this.renderDayView(d,e,y)),d++);p.push(r.ke`<tr class="pkt-cal-week-row" role="row">
|
|
89
|
+
${f}
|
|
90
|
+
</tr>`)}return p}isExcluded(e,t){return this.excludeweekdays.includes(e.toString())||this.earliest&&t<new Date(this.earliest)||this.latest&&t>new Date(this.latest)?!0:this.excludedates.some(s=>typeof s=="string"?s===this.formatISODate(t):s.toDateString()===t.toDateString())}formatISODate(e){return e.toISOString().split("T")[0]}isPrevMonthAllowed(){const e=new Date(this.year,this.month,0,12);return!(this.earliest&&new Date(this.earliest)>e)}prevMonth(){const e=this.month===0?11:this.month-1,t=this.month===0?this.year-1:this.year;this.changeMonth(t,e)}isNextMonthAllowed(){const e=new Date(this.year,this.month===11?0:this.month+1,1,12);return!(this.latest&&new Date(this.latest)<e)}nextMonth(){const 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=e,this.month=t,this.selectableDates=[],this.requestUpdate("currentmonth")}isInRange(e){if(this.range&&this.selected.length===2){if(e>new Date(this.selected[0])&&e<new Date(this.selected[1]))return!0}else if(this.range&&this.selected.length===1&&this.rangeHovered&&e>new Date(this.selected[0])&&e<this.rangeHovered)return!0;return!1}isRangeAllowed(e){let t=!0;if(this._selected.length===1){const s=b({start:this._selected[0],end:e});if(Array.isArray(s)&&s.length)for(let n=0;n<s.length;n++)this.excludedates.forEach(a=>{a>this._selected[0]&&a<e&&(t=!1)}),this.excludeweekdays.includes(T(s[n]).toString())&&(t=!1)}return t}emptySelected(){this.selected=[],this._selected=[],this.inRange={}}addToSelected(e){this.selected.includes(this.formatISODate(e))||(this.selected=[...this.selected,this.formatISODate(e)],this._selected=[...this._selected,e])}removeFromSelected(e){if(this.selected.length===1)this.emptySelected();else{const t=this.selected.indexOf(this.formatISODate(e)),s=[...this.selected],n=[...this._selected];s.splice(t,1),n.splice(t,1),this.selected=s,this._selected=n}}toggleSelected(e){const t=this.formatISODate(e);this.selected.includes(t)?this.removeFromSelected(e):this.maxMultiple&&this.selected.length>=this.maxMultiple||this.addToSelected(e)}handleRangeSelect(e){const t=this.formatISODate(e);return this.selected.includes(t)?this.selected.indexOf(t)===0?this.emptySelected():this.removeFromSelected(e):this.selected.length>1?(this.emptySelected(),this.addToSelected(e)):(this.selected.length===1&&!this.isRangeAllowed(e)&&this.emptySelected(),this.selected.length===1&&this._selected[0]>e&&this.emptySelected(),this.addToSelected(e)),Promise.resolve()}handleRangeHover(e){if(this.range&&this._selected.length===1&&this.isRangeAllowed(e)&&this._selected[0]<e){this.rangeHovered=e,this.inRange={};const t=b({start:this._selected[0],end:e});if(Array.isArray(t)&&t.length)for(let s=0;s<t.length;s++)this.inRange[this.formatISODate(t[s])]=this.isInRange(t[s])}else this.rangeHovered=null}handleDateSelect(e){if(e)return this.range?this.handleRangeSelect(e):this.multiple?this.toggleSelected(e):(this.selected.includes(this.formatISODate(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()}closeEvent(e){this.contains(e.relatedTarget)||this.close()}close(){this.dispatchEvent(new CustomEvent("close",{detail:!0,bubbles:!0,composed:!0}))}};o([r.n({type:Boolean,reflect:!0})],exports.PktCalendar.prototype,"multiple",2);o([r.n({type:Number})],exports.PktCalendar.prototype,"maxMultiple",2);o([r.n({type:Boolean,reflect:!0})],exports.PktCalendar.prototype,"range",2);o([r.n({type:Boolean,reflect:!0})],exports.PktCalendar.prototype,"weeknumbers",2);o([r.n({type:Boolean,reflect:!0})],exports.PktCalendar.prototype,"withcontrols",2);o([r.n({type:Boolean,reflect:!0})],exports.PktCalendar.prototype,"focused",2);o([r.n({converter:w.converters.csvToArray})],exports.PktCalendar.prototype,"selected",2);o([r.n({type:String,reflect:!0})],exports.PktCalendar.prototype,"earliest",2);o([r.n({type:String,reflect:!0})],exports.PktCalendar.prototype,"latest",2);o([r.n({converter:w.converters.stringsToDate})],exports.PktCalendar.prototype,"excludedates",2);o([r.n({converter:w.converters.csvToArray})],exports.PktCalendar.prototype,"excludeweekdays",2);o([r.n({converter:w.converters.stringToDate})],exports.PktCalendar.prototype,"currentmonth",2);o([r.n({type:Array})],exports.PktCalendar.prototype,"dayStrings",2);o([r.n({type:Array})],exports.PktCalendar.prototype,"monthStrings",2);o([r.n({type:String})],exports.PktCalendar.prototype,"weekString",2);o([r.n({type:String})],exports.PktCalendar.prototype,"prevMonthString",2);o([r.n({type:String})],exports.PktCalendar.prototype,"nextMonthString",2);o([r.n({type:Array})],exports.PktCalendar.prototype,"_selected",2);o([r.n({type:Number})],exports.PktCalendar.prototype,"year",2);o([r.n({type:Number})],exports.PktCalendar.prototype,"month",2);o([r.n({type:Number})],exports.PktCalendar.prototype,"week",2);o([r.n({type:Date})],exports.PktCalendar.prototype,"rangeHovered",2);o([x.r()],exports.PktCalendar.prototype,"inRange",2);o([x.r()],exports.PktCalendar.prototype,"focusedDate",2);o([x.r()],exports.PktCalendar.prototype,"selectableDates",2);exports.PktCalendar=o([$.t("pkt-calendar")],exports.PktCalendar);exports.constructFrom=D;exports.getDefaultOptions=v;exports.getWeek=S;exports.getWeekYear=O;exports.millisecondsInDay=_;exports.millisecondsInWeek=M;exports.startOfWeek=m;exports.toDate=k;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,393 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { nothing } from 'lit';
|
|
3
|
+
import { PropertyValues } from 'lit';
|
|
4
|
+
import { ReactiveController } from 'lit';
|
|
5
|
+
import { ReactiveControllerHost } from 'lit';
|
|
6
|
+
import { Ref } from 'lit/directives/ref.js';
|
|
7
|
+
import { StaticValue } from 'lit/static-html.js';
|
|
8
|
+
import { TemplateResult } from 'lit';
|
|
9
|
+
|
|
10
|
+
declare type ICardSkin = 'outlined' | 'gray' | 'beige' | 'green' | 'blue';
|
|
11
|
+
|
|
12
|
+
declare type IDirection = 'portrait' | 'landscape';
|
|
13
|
+
|
|
14
|
+
declare interface IPktTag {
|
|
15
|
+
closeTag?: boolean;
|
|
16
|
+
size?: TagSize;
|
|
17
|
+
skin?: 'blue' | 'green' | 'red' | 'yellow';
|
|
18
|
+
textStyle?: string;
|
|
19
|
+
iconName?: string;
|
|
20
|
+
type?: string;
|
|
21
|
+
ariaLabel?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export declare class PktCalendar extends PktElement {
|
|
25
|
+
/**
|
|
26
|
+
* Element attributes
|
|
27
|
+
*/
|
|
28
|
+
multiple: boolean;
|
|
29
|
+
maxMultiple: number;
|
|
30
|
+
range: boolean;
|
|
31
|
+
weeknumbers: boolean;
|
|
32
|
+
withcontrols: boolean;
|
|
33
|
+
focused: boolean;
|
|
34
|
+
selected: string[];
|
|
35
|
+
earliest: string | null;
|
|
36
|
+
latest: string | null;
|
|
37
|
+
excludedates: Date[];
|
|
38
|
+
excludeweekdays: string[];
|
|
39
|
+
currentmonth: Date;
|
|
40
|
+
/**
|
|
41
|
+
* If we are initializing props, slots and events from specs, we should do it in the constructor
|
|
42
|
+
*/
|
|
43
|
+
constructor();
|
|
44
|
+
/**
|
|
45
|
+
* Strings
|
|
46
|
+
*/
|
|
47
|
+
dayStrings: string[];
|
|
48
|
+
monthStrings: string[];
|
|
49
|
+
weekString: string;
|
|
50
|
+
prevMonthString: string;
|
|
51
|
+
nextMonthString: string;
|
|
52
|
+
/**
|
|
53
|
+
* Private properties
|
|
54
|
+
*/
|
|
55
|
+
private _selected;
|
|
56
|
+
private year;
|
|
57
|
+
private month;
|
|
58
|
+
private week;
|
|
59
|
+
private rangeHovered;
|
|
60
|
+
private inRange;
|
|
61
|
+
private focusedDate;
|
|
62
|
+
private selectableDates;
|
|
63
|
+
/**
|
|
64
|
+
* Runs on mount, used to set up various values and whatever you need to run
|
|
65
|
+
*/
|
|
66
|
+
connectedCallback(): void;
|
|
67
|
+
disconnectedCallback(): void;
|
|
68
|
+
updated(changedProperties: PropertyValues): void;
|
|
69
|
+
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
70
|
+
handleKeydown(e: KeyboardEvent): void;
|
|
71
|
+
handleArrowKey(e: KeyboardEvent, direction: number): void;
|
|
72
|
+
/**
|
|
73
|
+
* Component functionality and render
|
|
74
|
+
*/
|
|
75
|
+
render(): TemplateResult<1>;
|
|
76
|
+
private renderDayNames;
|
|
77
|
+
private renderMonthNav;
|
|
78
|
+
private renderDayView;
|
|
79
|
+
private renderCalendarBody;
|
|
80
|
+
private isExcluded;
|
|
81
|
+
private formatISODate;
|
|
82
|
+
isPrevMonthAllowed(): boolean;
|
|
83
|
+
private prevMonth;
|
|
84
|
+
isNextMonthAllowed(): boolean;
|
|
85
|
+
private nextMonth;
|
|
86
|
+
private changeMonth;
|
|
87
|
+
private isInRange;
|
|
88
|
+
private isRangeAllowed;
|
|
89
|
+
private emptySelected;
|
|
90
|
+
addToSelected(selectedDate: Date): void;
|
|
91
|
+
removeFromSelected(selectedDate: Date): void;
|
|
92
|
+
toggleSelected(selectedDate: Date): void;
|
|
93
|
+
private handleRangeSelect;
|
|
94
|
+
private handleRangeHover;
|
|
95
|
+
handleDateSelect(selectedDate: Date | null): Promise<void> | undefined;
|
|
96
|
+
closeEvent(e: FocusEvent): void;
|
|
97
|
+
close(): void;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export declare class PktCard extends PktElement {
|
|
101
|
+
defaultSlot: Ref<HTMLElement>;
|
|
102
|
+
constructor();
|
|
103
|
+
skin: ICardSkin;
|
|
104
|
+
direction: IDirection;
|
|
105
|
+
image: {
|
|
106
|
+
src: string;
|
|
107
|
+
alt: string;
|
|
108
|
+
};
|
|
109
|
+
heading: string;
|
|
110
|
+
subheading: string;
|
|
111
|
+
tags: (Omit<IPktTag, 'closeTag'> & {
|
|
112
|
+
text: string;
|
|
113
|
+
})[];
|
|
114
|
+
connectedCallback(): void;
|
|
115
|
+
render(): TemplateResult<1>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export declare class PktComponent extends PktElement {
|
|
119
|
+
/**
|
|
120
|
+
* Element attributes => props
|
|
121
|
+
* Example:
|
|
122
|
+
* <pkt-component string="hei" strings="hei,og,hallo" darkmode>
|
|
123
|
+
* Hei!
|
|
124
|
+
* </pkt-component>
|
|
125
|
+
*/
|
|
126
|
+
string: string;
|
|
127
|
+
strings: string[];
|
|
128
|
+
darkmode: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Private properties, for internal use only
|
|
131
|
+
*/
|
|
132
|
+
private _list;
|
|
133
|
+
/**
|
|
134
|
+
* Runs on mount, used to set up various values and whatever you need to run
|
|
135
|
+
*/
|
|
136
|
+
connectedCallback(): void;
|
|
137
|
+
/**
|
|
138
|
+
* Set up slot support for Light DOM
|
|
139
|
+
*/
|
|
140
|
+
slotController: PktSlotController;
|
|
141
|
+
defaultSlot: Ref<HTMLElement>;
|
|
142
|
+
namedSlot: Ref<HTMLElement>;
|
|
143
|
+
constructor();
|
|
144
|
+
/**
|
|
145
|
+
* Render functions
|
|
146
|
+
*/
|
|
147
|
+
render(): TemplateResult<1>;
|
|
148
|
+
private renderList;
|
|
149
|
+
/**
|
|
150
|
+
* Add other functionality under here
|
|
151
|
+
*/
|
|
152
|
+
private doStuff;
|
|
153
|
+
/**
|
|
154
|
+
* Handlers for returning data from the component
|
|
155
|
+
*/
|
|
156
|
+
private handleGreeting;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export declare class PktDatepicker extends PktInputElement {
|
|
160
|
+
/**
|
|
161
|
+
* Element attributes and properties
|
|
162
|
+
*/
|
|
163
|
+
value: string | string[];
|
|
164
|
+
_value: string[];
|
|
165
|
+
label: string;
|
|
166
|
+
helptext: string;
|
|
167
|
+
helptextDropdown: string;
|
|
168
|
+
helptextDropdownButton: string;
|
|
169
|
+
dateformat: string;
|
|
170
|
+
multiple: boolean;
|
|
171
|
+
maxlength: number | null;
|
|
172
|
+
range: boolean;
|
|
173
|
+
weeknumbers: boolean;
|
|
174
|
+
withcontrols: boolean;
|
|
175
|
+
fullwidth: boolean;
|
|
176
|
+
excludedates: string[];
|
|
177
|
+
excludeweekdays: string[];
|
|
178
|
+
currentmonth: string;
|
|
179
|
+
calendarOpen: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Housekeeping / lifecycle methods
|
|
182
|
+
*/
|
|
183
|
+
connectedCallback(): Promise<void>;
|
|
184
|
+
disconnectedCallback(): void;
|
|
185
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
186
|
+
updated(changedProperties: PropertyValues): void;
|
|
187
|
+
/**
|
|
188
|
+
* Element references
|
|
189
|
+
*/
|
|
190
|
+
inputRef: Ref<HTMLInputElement>;
|
|
191
|
+
inputRefTo: Ref<HTMLInputElement>;
|
|
192
|
+
btnRef: Ref<HTMLButtonElement>;
|
|
193
|
+
calRef: Ref<PktCalendar>;
|
|
194
|
+
popupRef: Ref<HTMLDivElement>;
|
|
195
|
+
/**
|
|
196
|
+
* CSS classes
|
|
197
|
+
*/
|
|
198
|
+
inputClasses: {
|
|
199
|
+
'pkt-input': boolean;
|
|
200
|
+
'pkt-datepicker__input': boolean;
|
|
201
|
+
'pkt-input--fullwidth': boolean;
|
|
202
|
+
};
|
|
203
|
+
buttonClasses: {
|
|
204
|
+
'pkt-input-icon': boolean;
|
|
205
|
+
'pkt-btn': boolean;
|
|
206
|
+
'pkt-btn--icon-only': boolean;
|
|
207
|
+
'pkt-btn--tertiary': boolean;
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Date value manipulation
|
|
211
|
+
*/
|
|
212
|
+
private formatISODate;
|
|
213
|
+
fromISOToDate: (date: string | null) => Date | null;
|
|
214
|
+
fromISOtoLocal: (date: string) => string;
|
|
215
|
+
massageDates: (dates: (string | undefined)[]) => string[];
|
|
216
|
+
renderInput(): TemplateResult<1>;
|
|
217
|
+
renderRangeInput(): TemplateResult<1>;
|
|
218
|
+
renderMultipleInput(): TemplateResult<1>;
|
|
219
|
+
renderTags(): TemplateResult<1>;
|
|
220
|
+
renderCalendar(): TemplateResult<1>;
|
|
221
|
+
render(): TemplateResult<1>;
|
|
222
|
+
/**
|
|
223
|
+
* Handlers
|
|
224
|
+
*/
|
|
225
|
+
handleCalendarPosition(): void;
|
|
226
|
+
addToSelected: (e: Event | KeyboardEvent) => void;
|
|
227
|
+
private handleFocusOut;
|
|
228
|
+
showCalendar(): Promise<void>;
|
|
229
|
+
hideCalendar(): void;
|
|
230
|
+
toggleCalendar(e: Event): void;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Base class for all Punkt elements
|
|
235
|
+
* @extends LitElement
|
|
236
|
+
*/
|
|
237
|
+
declare class PktElement extends LitElement {
|
|
238
|
+
[key: string]: any;
|
|
239
|
+
strings: any;
|
|
240
|
+
/**
|
|
241
|
+
* Runs on mount, used to set up various values and whatever you need to run
|
|
242
|
+
*/
|
|
243
|
+
connectedCallback(): void;
|
|
244
|
+
/**
|
|
245
|
+
* Make sure the component renders in light DOM instead of shadow DOM
|
|
246
|
+
*/
|
|
247
|
+
createRenderRoot(): this;
|
|
248
|
+
/**
|
|
249
|
+
* Add support for Hot Module Reloading in dev mode
|
|
250
|
+
*/
|
|
251
|
+
hotReplacedCallback(): void;
|
|
252
|
+
/**
|
|
253
|
+
* Add extra stuff here whenever we decide what should be added here…
|
|
254
|
+
*/
|
|
255
|
+
constructor();
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export declare class PktIcon extends PktElement {
|
|
259
|
+
constructor();
|
|
260
|
+
protected willUpdate(_changedProperties: PropertyValues): void;
|
|
261
|
+
path: string | undefined;
|
|
262
|
+
name: string;
|
|
263
|
+
private icon;
|
|
264
|
+
private _updatedProps;
|
|
265
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): Promise<void>;
|
|
266
|
+
render(): TemplateResult<1>;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Base class for all Punkt input elements
|
|
271
|
+
* @extends PktElement
|
|
272
|
+
*/
|
|
273
|
+
declare class PktInputElement extends PktElement {
|
|
274
|
+
static get formAssociated(): boolean;
|
|
275
|
+
id: string;
|
|
276
|
+
name: string;
|
|
277
|
+
required: boolean;
|
|
278
|
+
disabled: boolean;
|
|
279
|
+
placeholder: string;
|
|
280
|
+
min: string | number | null;
|
|
281
|
+
max: string | number | null;
|
|
282
|
+
minlength: number;
|
|
283
|
+
maxlength: number | null;
|
|
284
|
+
pattern: string;
|
|
285
|
+
optionalTag: boolean;
|
|
286
|
+
optionalText: string;
|
|
287
|
+
requiredTag: boolean;
|
|
288
|
+
requiredText: string;
|
|
289
|
+
hasError: boolean;
|
|
290
|
+
errorMessage: string;
|
|
291
|
+
constructor();
|
|
292
|
+
protected manageValidity(input: HTMLInputElement): void;
|
|
293
|
+
protected onInput(value: string | string[]): void;
|
|
294
|
+
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export declare class PktInputWrapper extends PktElement {
|
|
298
|
+
defaultSlot: Ref<HTMLElement>;
|
|
299
|
+
constructor();
|
|
300
|
+
/**
|
|
301
|
+
* Element attributes
|
|
302
|
+
*/
|
|
303
|
+
forId: string;
|
|
304
|
+
label: string;
|
|
305
|
+
helptext: string;
|
|
306
|
+
helptextDropdown: string;
|
|
307
|
+
helptextDropdownButton: string;
|
|
308
|
+
counter: boolean;
|
|
309
|
+
counterCurrent: number;
|
|
310
|
+
counterMaxLength: number;
|
|
311
|
+
optionalTag: boolean;
|
|
312
|
+
optionalText: string;
|
|
313
|
+
requiredTag: boolean;
|
|
314
|
+
requiredText: string;
|
|
315
|
+
hasError: boolean;
|
|
316
|
+
errorMessage: string;
|
|
317
|
+
disabled: boolean;
|
|
318
|
+
inline: boolean;
|
|
319
|
+
ariaDescribedby: string | undefined;
|
|
320
|
+
hasFieldset: boolean;
|
|
321
|
+
useWrapper: boolean;
|
|
322
|
+
private isHelpTextOpen;
|
|
323
|
+
wrapperType: StaticValue;
|
|
324
|
+
render(): TemplateResult<1>;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export declare class PktLink extends PktElement {
|
|
328
|
+
defaultSlot: Ref<HTMLElement>;
|
|
329
|
+
constructor();
|
|
330
|
+
/**
|
|
331
|
+
* Element attributes
|
|
332
|
+
*/
|
|
333
|
+
href: string;
|
|
334
|
+
iconName: string | undefined;
|
|
335
|
+
iconPosition: string | undefined;
|
|
336
|
+
external: boolean;
|
|
337
|
+
render(): TemplateResult<1>;
|
|
338
|
+
private handleClick;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export declare class PktMessagebox extends PktElement {
|
|
342
|
+
defaultSlot: Ref<HTMLElement>;
|
|
343
|
+
constructor();
|
|
344
|
+
closable: boolean;
|
|
345
|
+
compact: boolean;
|
|
346
|
+
title: string;
|
|
347
|
+
skin: string;
|
|
348
|
+
isDisplayed: boolean;
|
|
349
|
+
onClose?: () => void;
|
|
350
|
+
handleClose(): void;
|
|
351
|
+
render(): TemplateResult<1> | typeof nothing;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
declare class PktSlotController implements ReactiveController {
|
|
355
|
+
host: LitElement & ReactiveControllerHost;
|
|
356
|
+
nodes: Element[];
|
|
357
|
+
slots: Ref<HTMLElement>[];
|
|
358
|
+
constructor(host: LitElement & ReactiveControllerHost, ...slots: Ref<HTMLElement>[]);
|
|
359
|
+
hostConnected(): void;
|
|
360
|
+
hostUpdated(): void;
|
|
361
|
+
private nodeFromElement;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export declare class PktTag extends PktElement {
|
|
365
|
+
slotController: PktSlotController;
|
|
366
|
+
defaultSlot: Ref<HTMLElement>;
|
|
367
|
+
constructor();
|
|
368
|
+
/**
|
|
369
|
+
* Element attributes
|
|
370
|
+
*/
|
|
371
|
+
closeTag: boolean;
|
|
372
|
+
size: TagSize;
|
|
373
|
+
skin: TagSkin;
|
|
374
|
+
textStyle: string;
|
|
375
|
+
iconName: string | undefined;
|
|
376
|
+
type: string;
|
|
377
|
+
ariaLabel: string;
|
|
378
|
+
/**
|
|
379
|
+
* Element state
|
|
380
|
+
*/
|
|
381
|
+
_isClosed: boolean;
|
|
382
|
+
/**
|
|
383
|
+
* Element functions
|
|
384
|
+
*/
|
|
385
|
+
private close;
|
|
386
|
+
render(): TemplateResult<1> | typeof nothing;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
declare type TagSize = 'small' | 'medium' | 'large';
|
|
390
|
+
|
|
391
|
+
declare type TagSkin = 'blue' | 'green' | 'red' | 'yellow';
|
|
392
|
+
|
|
393
|
+
export { }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { }
|
package/dist/link.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { }
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-BJ_4AGO3.cjs"),p=require("./ref-Bk590hog.cjs"),c=require("./class-map-CA8wadiN.cjs"),k=require("./directive-19_ixLKS.cjs");require("./index-DSplpVWQ.cjs");var h=Object.defineProperty,u=Object.getOwnPropertyDescriptor,e=(s,r,o,i)=>{for(var l=i>1?void 0:i?u(r,o):r,a=s.length-1,n;a>=0;a--)(n=s[a])&&(l=(i?n(r,o,l):n(l))||l);return i&&l&&h(r,o,l),l};exports.PktAlert=class extends t.PktElement{constructor(){super(),this.defaultSlot=p.ii(),this.closable=!1,this.compact=!1,this.title="",this.skin="info",this.isDisplayed=!0,this.ariaLive="polite",this.closeAlert=!1,this.date="",this.slotController=new p.PktSlotController(this,this.defaultSlot)}handleClose(){this.isDisplayed=!1,this.onClose&&this.onClose()}render(){const r={"pkt-alert":!0,"pkt-alert--compact":this.compact,[`pkt-alert--${this.skin}`]:this.skin,"pkt-alert--closable":this.closable};return this.isDisplayed?t.ke`
|
|
2
|
+
<div class=${c.Rt(r)} aria-live=${this.ariaLive}>
|
|
3
|
+
<pkt-icon
|
|
4
|
+
class="pkt-alert__icon"
|
|
5
|
+
name=${this.skin==="info"?"alert-information":`alert-${this.skin}`}
|
|
6
|
+
></pkt-icon>
|
|
7
|
+
|
|
8
|
+
${this.closable?t.ke`
|
|
9
|
+
<div class="pkt-alert__close">
|
|
10
|
+
<button
|
|
11
|
+
type="button"
|
|
12
|
+
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
13
|
+
tabindex="0"
|
|
14
|
+
aria-label="close"
|
|
15
|
+
@click=${this.handleClose}
|
|
16
|
+
>
|
|
17
|
+
<pkt-icon name="close" class="pkt-btn__icon" aria-hidden="true"></pkt-icon>
|
|
18
|
+
</button>
|
|
19
|
+
</div>
|
|
20
|
+
`:t.D}
|
|
21
|
+
${this.title?t.ke`<div class="pkt-alert__title">${this.title}</div>`:t.D}
|
|
22
|
+
|
|
23
|
+
<div class="pkt-alert__text" ${p.Kt(this.defaultSlot)}></div>
|
|
24
|
+
|
|
25
|
+
${this.date?t.ke`<div class="pkt-alert__date">Sist oppdatert: ${this.date}</div>`:t.D}
|
|
26
|
+
</div>
|
|
27
|
+
`:t.D}};e([t.n({type:Boolean,reflect:!0})],exports.PktAlert.prototype,"closable",2);e([t.n({type:Boolean,reflect:!0})],exports.PktAlert.prototype,"compact",2);e([t.n({type:String,reflect:!0})],exports.PktAlert.prototype,"title",2);e([t.n({type:String,reflect:!0})],exports.PktAlert.prototype,"skin",2);e([t.n({type:Boolean,reflect:!0})],exports.PktAlert.prototype,"isDisplayed",2);e([t.n({type:Function,reflect:!0})],exports.PktAlert.prototype,"onClose",2);e([t.n({type:String,reflect:!0})],exports.PktAlert.prototype,"ariaLive",2);e([t.n({type:Boolean,reflect:!0})],exports.PktAlert.prototype,"closeAlert",2);e([t.n({type:String,reflect:!0})],exports.PktAlert.prototype,"date",2);exports.PktAlert=e([k.t("pkt-alert")],exports.PktAlert);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { P as f, D as a, k as p, n as i } from "./index-BHzxfdBK.js";
|
|
2
|
+
import { i as d, P as k, K as u } from "./ref-Co_S0Cgj.js";
|
|
3
|
+
import { R as y } from "./class-map-DiT0qP3E.js";
|
|
4
|
+
import { t as v } from "./directive-DA0-wdk7.js";
|
|
5
|
+
import "./index-BlHnvy7v.js";
|
|
6
|
+
var m = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, e = (l, r, n, o) => {
|
|
7
|
+
for (var s = o > 1 ? void 0 : o ? _(r, n) : r, c = l.length - 1, h; c >= 0; c--)
|
|
8
|
+
(h = l[c]) && (s = (o ? h(r, n, s) : h(s)) || s);
|
|
9
|
+
return o && s && m(r, n, s), s;
|
|
10
|
+
};
|
|
11
|
+
let t = class extends f {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(), this.defaultSlot = d(), this.closable = !1, this.compact = !1, this.title = "", this.skin = "info", this.isDisplayed = !0, this.ariaLive = "polite", this.closeAlert = !1, this.date = "", this.slotController = new k(this, this.defaultSlot);
|
|
14
|
+
}
|
|
15
|
+
handleClose() {
|
|
16
|
+
this.isDisplayed = !1, this.onClose && this.onClose();
|
|
17
|
+
}
|
|
18
|
+
render() {
|
|
19
|
+
const l = {
|
|
20
|
+
"pkt-alert": !0,
|
|
21
|
+
"pkt-alert--compact": this.compact,
|
|
22
|
+
[`pkt-alert--${this.skin}`]: this.skin,
|
|
23
|
+
"pkt-alert--closable": this.closable
|
|
24
|
+
};
|
|
25
|
+
return this.isDisplayed ? p`
|
|
26
|
+
<div class=${y(l)} aria-live=${this.ariaLive}>
|
|
27
|
+
<pkt-icon
|
|
28
|
+
class="pkt-alert__icon"
|
|
29
|
+
name=${this.skin === "info" ? "alert-information" : `alert-${this.skin}`}
|
|
30
|
+
></pkt-icon>
|
|
31
|
+
|
|
32
|
+
${this.closable ? p`
|
|
33
|
+
<div class="pkt-alert__close">
|
|
34
|
+
<button
|
|
35
|
+
type="button"
|
|
36
|
+
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
37
|
+
tabindex="0"
|
|
38
|
+
aria-label="close"
|
|
39
|
+
@click=${this.handleClose}
|
|
40
|
+
>
|
|
41
|
+
<pkt-icon name="close" class="pkt-btn__icon" aria-hidden="true"></pkt-icon>
|
|
42
|
+
</button>
|
|
43
|
+
</div>
|
|
44
|
+
` : a}
|
|
45
|
+
${this.title ? p`<div class="pkt-alert__title">${this.title}</div>` : a}
|
|
46
|
+
|
|
47
|
+
<div class="pkt-alert__text" ${u(this.defaultSlot)}></div>
|
|
48
|
+
|
|
49
|
+
${this.date ? p`<div class="pkt-alert__date">Sist oppdatert: ${this.date}</div>` : a}
|
|
50
|
+
</div>
|
|
51
|
+
` : a;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
e([
|
|
55
|
+
i({ type: Boolean, reflect: !0 })
|
|
56
|
+
], t.prototype, "closable", 2);
|
|
57
|
+
e([
|
|
58
|
+
i({ type: Boolean, reflect: !0 })
|
|
59
|
+
], t.prototype, "compact", 2);
|
|
60
|
+
e([
|
|
61
|
+
i({ type: String, reflect: !0 })
|
|
62
|
+
], t.prototype, "title", 2);
|
|
63
|
+
e([
|
|
64
|
+
i({ type: String, reflect: !0 })
|
|
65
|
+
], t.prototype, "skin", 2);
|
|
66
|
+
e([
|
|
67
|
+
i({ type: Boolean, reflect: !0 })
|
|
68
|
+
], t.prototype, "isDisplayed", 2);
|
|
69
|
+
e([
|
|
70
|
+
i({ type: Function, reflect: !0 })
|
|
71
|
+
], t.prototype, "onClose", 2);
|
|
72
|
+
e([
|
|
73
|
+
i({ type: String, reflect: !0 })
|
|
74
|
+
], t.prototype, "ariaLive", 2);
|
|
75
|
+
e([
|
|
76
|
+
i({ type: Boolean, reflect: !0 })
|
|
77
|
+
], t.prototype, "closeAlert", 2);
|
|
78
|
+
e([
|
|
79
|
+
i({ type: String, reflect: !0 })
|
|
80
|
+
], t.prototype, "date", 2);
|
|
81
|
+
t = e([
|
|
82
|
+
v("pkt-alert")
|
|
83
|
+
], t);
|
|
84
|
+
export {
|
|
85
|
+
t as PktAlert
|
|
86
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-BJ_4AGO3.cjs");require("./converters-DhM11VlY.cjs");require("./directive-19_ixLKS.cjs");require("./state-D2tUtTi6.cjs");require("./class-map-CA8wadiN.cjs");const e=require("./index-DkGcZra2.cjs");require("./index-DSplpVWQ.cjs");Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>e.PktCalendar});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "./index-BHzxfdBK.js";
|
|
2
|
+
import "./converters-DNCwIFwr.js";
|
|
3
|
+
import "./directive-DA0-wdk7.js";
|
|
4
|
+
import "./state-BRgFbJX9.js";
|
|
5
|
+
import "./class-map-DiT0qP3E.js";
|
|
6
|
+
import { P } from "./index-CPvZ03uX.js";
|
|
7
|
+
import "./index-BlHnvy7v.js";
|
|
8
|
+
export {
|
|
9
|
+
P as PktCalendar
|
|
10
|
+
};
|