@oslokommune/punkt-elements 19.3.0 → 19.4.0
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 +13 -0
- package/dist/{accordion-BLMbI8SQ.cjs → accordion-CZ0O4c0_.cjs} +1 -1
- package/dist/{accordion-Bwka5Mxo.js → accordion-DFcdonl-.js} +5 -5
- package/dist/{alert-vIaasUjb.js → alert-BhvjSA5X.js} +7 -7
- package/dist/{alert-DsGNGcgd.cjs → alert-D1bQjZ7C.cjs} +2 -2
- package/dist/{async-directive-U0EE5r36.cjs → async-directive-BGoo_npW.cjs} +1 -1
- package/dist/{async-directive-C8UAk8Mv.js → async-directive-DsdqP_X7.js} +2 -2
- package/dist/{backlink-DM220m4q.cjs → backlink-Bw6IcRIo.cjs} +1 -1
- package/dist/{backlink-BjJwDjuP.js → backlink-DIdgvE2j.js} +3 -3
- package/dist/{breadcrumbs-B1pDtQy8.js → breadcrumbs-BfgCx3Xj.js} +2 -2
- package/dist/{breadcrumbs-BUmbj-hP.cjs → breadcrumbs-C10K1XLP.cjs} +1 -1
- package/dist/{button-BUl8uWWh.js → button-B5rWxfei.js} +5 -5
- package/dist/{button-CCR4eyt_.cjs → button-CmNrMH-c.cjs} +1 -1
- package/dist/{calendar-CtfdBqJN.cjs → calendar-D-Ow5DAp.cjs} +1 -1
- package/dist/{calendar-DWSW_GeN.js → calendar-U8xkRdgF.js} +3 -3
- package/dist/{card-27RxxKxW.js → card-D2YYPZr5.js} +23 -22
- package/dist/{card-B-RKnu_C.cjs → card-DW1uklP6.cjs} +6 -6
- package/dist/{checkbox-B-ejHbFP.js → checkbox-B2O0fkh9.js} +4 -4
- package/dist/{checkbox-B2G_B_bg.cjs → checkbox-C0zLtnCI.cjs} +1 -1
- package/dist/{class-map-D5GHsely.js → class-map-C4hdfSfY.js} +1 -1
- package/dist/{class-map-B0FX3YsK.cjs → class-map-Drv0_anQ.cjs} +1 -1
- package/dist/{combobox-nqNZDvBR.cjs → combobox-BgduqUpf.cjs} +1 -1
- package/dist/{combobox-DHL_CGYv.js → combobox-DpXTwNr4.js} +12 -12
- package/dist/components/card/card.d.ts +2 -1
- package/dist/components/checkbox/checkbox.d.ts +1 -1
- package/dist/components/consent/consent.d.ts +6 -38
- package/dist/components/fileupload/fileupload-operations.d.ts +6 -3
- package/dist/components/fileupload/fileupload-renderers.d.ts +5 -3
- package/dist/{consent-BeoP4rOa.js → consent-CbJG04C1.js} +21 -17
- package/dist/consent-DxpJLExu.cjs +18 -0
- package/dist/{datepicker-DvO3w0eM.cjs → datepicker-53rj_Qqx.cjs} +1 -1
- package/dist/{datepicker-BWp2PM9S.js → datepicker-BLBimRTT.js} +11 -11
- package/dist/{directive-helpers-BushnrQQ.cjs → directive-helpers-BRrz3Bcj.cjs} +1 -1
- package/dist/{directive-helpers-DpyLJPJm.js → directive-helpers-D96YEsht.js} +1 -1
- package/dist/{element-CewjrA4g.cjs → element-BOmr9YLv.cjs} +1 -1
- package/dist/{element-CqC-sGuC.js → element-mwwC2Rra.js} +37 -3
- package/dist/{element-with-slot-MCvSBwUv.cjs → element-with-slot-2PHu2w7O.cjs} +1 -1
- package/dist/{element-with-slot-D_OKDlYo.js → element-with-slot-FD826ooP.js} +2 -2
- package/dist/{fileupload-DDLvQaSS.cjs → fileupload-4wgr4iAi.cjs} +78 -76
- package/dist/{fileupload-DbtTD1aU.js → fileupload-BxfBFhFt.js} +120 -100
- package/dist/{footer-UT8MbnCT.js → footer-CBkKAuvh.js} +4 -4
- package/dist/{footer-CupUAe8d.cjs → footer-DOp_9VdY.cjs} +1 -1
- package/dist/{header-BxgtAiNM.js → header-CF-Re0nT.js} +14 -13
- package/dist/{header-wdEiBTI9.cjs → header-Cs4t2XMM.cjs} +4 -3
- package/dist/{header-menu-DGywRJCx.cjs → header-menu-BnqZagI6.cjs} +3 -3
- package/dist/{header-menu-CTEPH4St.js → header-menu-C9k9xG9V.js} +6 -6
- package/dist/{heading-ELXWxyTv.js → heading-BRHCV_5J.js} +2 -2
- package/dist/{heading-BDdX4JiM.cjs → heading-u9Arof4p.cjs} +1 -1
- package/dist/{helptext-DQe6GO75.cjs → helptext-DYgeTMtA.cjs} +1 -1
- package/dist/{helptext-BQkrYsoV.js → helptext-sRC8EJqL.js} +4 -4
- package/dist/{icon-Clz68-Kz.cjs → icon-CoBsgGUR.cjs} +1 -1
- package/dist/{icon-B2v30QUk.js → icon-DmRyYNlY.js} +1 -1
- package/dist/if-defined-2mkIDgOm.cjs +1 -0
- package/dist/{if-defined-BNXGXCwT.js → if-defined-Bebu3LXY.js} +1 -1
- package/dist/{input-element-BTzuDh4h.js → input-element-B1BntJeJ.js} +2 -2
- package/dist/{input-element-BdIWsDl-.cjs → input-element-W6Gklt2E.cjs} +1 -1
- package/dist/{input-wrapper-B5GdwzAM.js → input-wrapper-C1zXIKBU.js} +6 -6
- package/dist/{input-wrapper-BmPdpY4N.cjs → input-wrapper-CSPPa4uc.cjs} +1 -1
- package/dist/{link-BxKWhYsn.js → link-DcxVUj8s.js} +4 -4
- package/dist/{link-1JEWpEDG.cjs → link-EMsHusF7.cjs} +1 -1
- package/dist/{linkcard-DXOkeQUy.cjs → linkcard-CWeR6t2a.cjs} +1 -1
- package/dist/{linkcard-CICSZ7pK.js → linkcard-MJFR7FLT.js} +4 -4
- package/dist/{listbox-3fi7wQz4.cjs → listbox-BoBwzL4p.cjs} +6 -6
- package/dist/{listbox-7pQ0UjKV.js → listbox-DEzd-dxF.js} +65 -61
- package/dist/{loader-nIl61aTv.js → loader-CqFQoJlM.js} +4 -4
- package/dist/{loader-BA__N62k.cjs → loader-SJ6NauNT.cjs} +1 -1
- package/dist/{messagebox-D2xvSYWI.cjs → messagebox-D5GYIdjE.cjs} +2 -2
- package/dist/{messagebox-E8W7RyAJ.js → messagebox-DsKi_rKn.js} +5 -5
- package/dist/{modal-D5tGq-nN.js → modal-CJqe6y-V.js} +7 -7
- package/dist/{modal-i3Qxv38H.cjs → modal-DaerHpVi.cjs} +3 -3
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.js +1 -1
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +1 -1
- package/dist/pkt-backlink.cjs +1 -1
- package/dist/pkt-backlink.js +1 -1
- package/dist/pkt-breadcrumbs.cjs +1 -1
- package/dist/pkt-breadcrumbs.js +1 -1
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +1 -1
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +1 -1
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.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-footer.cjs +1 -1
- package/dist/pkt-footer.js +1 -1
- package/dist/pkt-header-menu.cjs +1 -1
- package/dist/pkt-header-menu.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-heading.cjs +1 -1
- package/dist/pkt-heading.js +1 -1
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +1 -1
- package/dist/pkt-icon.cjs +1 -1
- package/dist/pkt-icon.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +34 -34
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +1 -1
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +1 -1
- package/dist/pkt-listbox.cjs +1 -1
- package/dist/pkt-listbox.js +1 -1
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +1 -1
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/{pkt-options-controller-BClk341e.cjs → pkt-options-controller-Dz-rYCG1.cjs} +1 -1
- package/dist/{pkt-options-controller-v2bPM9iU.js → pkt-options-controller-sUzxHa5A.js} +1 -1
- package/dist/pkt-progressbar.cjs +1 -1
- package/dist/pkt-progressbar.js +1 -1
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/pkt-searchinput.cjs +1 -1
- package/dist/pkt-searchinput.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-tabs.cjs +1 -1
- package/dist/pkt-tabs.js +1 -1
- package/dist/pkt-tag.cjs +1 -1
- package/dist/pkt-tag.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/{progressbar-4WyR4T72.js → progressbar-Bd0DjiAb.js} +5 -5
- package/dist/{progressbar-CJFGbev-.cjs → progressbar-BrVlAcQI.cjs} +1 -1
- package/dist/{radiobutton-D7308uCY.js → radiobutton-B0V-jSEX.js} +4 -4
- package/dist/{radiobutton-BQRtv7PK.cjs → radiobutton-Cv1BlwLV.cjs} +1 -1
- package/dist/{ref-37-yxmc4.js → ref-CCSGk4MP.js} +2 -2
- package/dist/{ref-HT6KRjxp.cjs → ref-Emu5PNxk.cjs} +1 -1
- package/dist/{repeat-DntD73oB.js → repeat-CdxGS-_3.js} +2 -2
- package/dist/{repeat-Ddge5HTp.cjs → repeat-Dh9YKoeV.cjs} +1 -1
- package/dist/{searchinput-D1cJ73Ki.cjs → searchinput-7-VVdkss.cjs} +1 -1
- package/dist/{searchinput-j4IvYRzj.js → searchinput-CgzigmiI.js} +4 -4
- package/dist/{select-CDoA2rpC.cjs → select---PCiwmy.cjs} +1 -1
- package/dist/{select-BhK8veJn.js → select-BbcGPmPs.js} +7 -7
- package/dist/shared-strings/nb.d.ts +34 -0
- package/dist/shared-types/consent.d.ts +69 -0
- package/dist/shared-types/index.d.ts +2 -0
- package/dist/{tabs-DexV26qJ.js → tabs-B134M9k2.js} +4 -4
- package/dist/{tabs-95BpwB6j.cjs → tabs-Dw9E06fL.cjs} +1 -1
- package/dist/{tag-CQEyjF32.cjs → tag-HTYKd-iG.cjs} +1 -1
- package/dist/{tag-DoUC99hn.js → tag-wYnHhHLK.js} +5 -5
- package/dist/{textarea-sulH-Yk7.js → textarea-BcgVLLTt.js} +9 -9
- package/dist/{textarea-BLVuKEng.cjs → textarea-pA_xv8lI.cjs} +1 -1
- package/dist/{textinput-CSrBua2N.cjs → textinput-Czz2affL.cjs} +1 -1
- package/dist/{textinput-Di2lAf2R.js → textinput-Dpj1X5yr.js} +8 -8
- package/dist/{timepicker-Iq1-vWRn.cjs → timepicker-BwDZkSpo.cjs} +1 -1
- package/dist/{timepicker-BaDGjuOR.js → timepicker-CfQMZlaP.js} +8 -8
- package/package.json +2 -2
- package/src/components/alert/alert.test.ts +1 -1
- package/src/components/alert/alert.ts +1 -1
- package/src/components/card/card.ts +7 -2
- package/src/components/checkbox/checkbox.ts +1 -3
- package/src/components/consent/consent.test.ts +14 -0
- package/src/components/consent/consent.ts +28 -54
- package/src/components/fileupload/fileupload-operations.ts +31 -22
- package/src/components/fileupload/fileupload-renderers.ts +28 -17
- package/src/components/fileupload/fileupload.ts +26 -9
- package/src/components/header/header-global.ts +2 -1
- package/src/components/header/header-service.test.ts +15 -0
- package/src/components/header/header-user-menu.ts +1 -1
- package/src/components/header-menu/header-menu.ts +2 -2
- package/src/components/listbox/listbox.ts +9 -4
- package/src/components/messagebox/messagebox.ts +1 -1
- package/src/components/modal/modal.ts +2 -2
- package/dist/consent-Cle1hkPg.cjs +0 -18
- package/dist/if-defined-CjRKmMQs.cjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-
|
|
1
|
+
const e=require("./element-BOmr9YLv.cjs"),t=require("./if-defined-2mkIDgOm.cjs"),n=require("./element-with-slot-2PHu2w7O.cjs"),r=require("./consume-Le4HztPo.cjs"),i=require("./ref-Emu5PNxk.cjs");var a=r.r(Symbol(`pkt-tabs-context`)),o=class extends n.t{constructor(...e){super(...e),this.arrowNav=!0,this.disableArrowNav=!1,this.separatorIconName=``,this.separatorIconPath=``,this.tabRefs=[],this.disabledMap={},this.tabCount=0,this.context={useArrowNav:this.useArrowNav,registerTab:this.registerTab.bind(this),handleClick:this.handleClick.bind(this),handleKeyUp:this.handleKeyUp.bind(this)}}get useArrowNav(){return this.arrowNav&&!this.disableArrowNav}willUpdate(e){(e.has(`arrowNav`)||e.has(`disableArrowNav`))&&(this.context={...this.context,useArrowNav:this.useArrowNav})}updated(){this.updateComplete.then(()=>this.syncSeparators())}syncSeparators(){let e=this.querySelector(`.pkt-tabs__list`);if(!e||(e.querySelectorAll(`.pkt-tabs__separator`).forEach(e=>e.remove()),!(this.separatorIconName||this.separatorIconPath)))return;let t=Array.from(e.children).filter(e=>!e.classList.contains(`pkt-tabs__separator`));for(let e=0;e<t.length-1;e++){let n=document.createElement(`span`);if(n.className=`pkt-tabs__separator`,n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`role`,`presentation`),this.separatorIconPath){let e=document.createElement(`img`);e.setAttribute(`src`,this.separatorIconPath),e.setAttribute(`alt`,``),e.setAttribute(`aria-hidden`,`true`),n.appendChild(e)}else if(this.separatorIconName){let e=document.createElement(`pkt-icon`);e.setAttribute(`name`,this.separatorIconName),e.classList.add(`pkt-tabs__separator-icon`),n.appendChild(e)}t[e].after(n)}}registerTab(e,t,n=!1){this.tabRefs[t]=e,this.disabledMap[t]=n,this.tabCount=Math.max(this.tabCount,t+1)}isTabDisabled(e){return!!this.disabledMap[e]}findEnabledIndex(e,t){let n=e+t;for(;n>=0&&n<this.tabCount;){if(!this.isTabDisabled(n))return n;n+=t}return null}handleClick(e){this.isTabDisabled(e)||this.dispatchEvent(new CustomEvent(`tab-selected`,{detail:{index:e},bubbles:!0,composed:!0}))}handleKeyUp(e,t){if(this.useArrowNav){if(e.key===`ArrowLeft`){e.preventDefault();let n=this.findEnabledIndex(t,-1);n!==null&&this.tabRefs[n]?.focus()}if(e.key===`ArrowRight`){e.preventDefault();let n=this.findEnabledIndex(t,1);n!==null&&this.tabRefs[n]?.focus()}(e.key===`Enter`||e.key===` `||e.key===`Spacebar`||e.key===`ArrowDown`)&&(e.preventDefault(),this.handleClick(t))}}render(){let t=this.useArrowNav?`tablist`:`navigation`,r=this.separatorIconName||this.separatorIconPath?`pkt-tabs pkt-tabs--with-separator`:`pkt-tabs`;return e._`
|
|
2
2
|
<div class=${r}>
|
|
3
3
|
<div class="pkt-tabs__list" role=${t}>${n.r(this)}</div>
|
|
4
4
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-
|
|
1
|
+
const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./if-defined-2mkIDgOm.cjs"),r=require("./format-B8meU8Tm.cjs"),i=require("./element-with-slot-2PHu2w7O.cjs");require("./icon-CoBsgGUR.cjs");var a={name:`pkt-tag`,react:`PktTag`,"css-class":`pkt-tag`,isElement:!0,"dark-mode":!0,props:{size:{name:`Størrelse`,description:`Størrelsen på taggen`,required:!1,default:`medium`,type:[`small`,`medium`,`large`],category:`ui`},iconName:{name:`Ikon`,description:`Navnet på ikonet som skal vises i taggen`,type:`icon`,required:!1,category:`ui`},skin:{name:`Utseende`,description:`Utseendet til taggen`,required:!1,default:`blue`,type:[`blue`,`blue-light`,`blue-dark`,`green`,`red`,`beige`,`yellow`,`gray`],category:`ui`},closeTag:{name:`Lukk tag`,description:`Skal taggen ha en lukkeknapp?`,type:`boolean`,required:!1,default:!1,category:`ui`},textStyle:{name:`Tekststil`,description:`Stilen på teksten i taggen`,required:!1,default:`normal-text`,type:[`thin-text`,`normal-text`],category:`ui`},type:{name:`Type, dersom lukkeknapp`,description:`Type tag, brukes for å spesifisere om det er en knapp, submit eller reset`,required:!1,default:`button`,type:[`button`,`submit`,`reset`],category:`tech`},ariaLabel:{name:`aria-label`,description:`aria-label for taggen, brukes for tilgjengelighet`,type:`string`,required:!1,category:`accessibility`}},slots:{default:{description:`Teksten til tag`}}},o=class extends i.t{constructor(){super(),this.closeTag=a.props.closeTag.default,this.size=a.props.size.default,this.skin=a.props.skin.default,this.textStyle=null,this.iconName=void 0,this.type=a.props.type.default,this.ariaLabel=null,this.buttonTabindex=void 0,this._isClosed=!1,this._ariaDescription=null,this.close=e=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent(`close`,{detail:{origin:e},bubbles:!1,composed:!0})),this.dispatchEvent(new CustomEvent(`on-close`,{detail:{origin:e},bubbles:!1,composed:!0}))},this._isClosed=!1}willUpdate(e){if(super.willUpdate(e),this.closeTag&&!this.ariaLabel){let e=i.n(this).getNodes().map(e=>e.textContent??``).join(``).trim();e&&(this._ariaDescription=r.t(this.pktStrings.get(`tag`).remove,{label:e}))}}render(){let r={"pkt-tag":!0,[`pkt-tag--${this.size}`]:!!this.size,[`pkt-tag--${this.skin}`]:!!this.skin,[`pkt-tag--${this.textStyle}`]:!!this.textStyle},a={"pkt-tag":!0,[`pkt-tag--${this.textStyle}`]:!!this.textStyle,[`pkt-tag--${this.size}`]:!!this.size,[`pkt-tag--${this.skin}`]:!!this.skin,"pkt-hide":this._isClosed};return this.closeTag?e._`
|
|
2
2
|
<button
|
|
3
3
|
class=${t.t(a)}
|
|
4
4
|
type=${this.type}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { _ as e, d as t, l as n, n as r, u as i } from "./element-
|
|
2
|
-
import { t as a } from "./class-map-
|
|
3
|
-
import { t as o } from "./if-defined-
|
|
1
|
+
import { _ as e, d as t, l as n, n as r, u as i } from "./element-mwwC2Rra.js";
|
|
2
|
+
import { t as a } from "./class-map-C4hdfSfY.js";
|
|
3
|
+
import { t as o } from "./if-defined-Bebu3LXY.js";
|
|
4
4
|
import { t as s } from "./format-BTeSVkED.js";
|
|
5
|
-
import { n as c, r as l, t as u } from "./element-with-slot-
|
|
6
|
-
import "./icon-
|
|
5
|
+
import { n as c, r as l, t as u } from "./element-with-slot-FD826ooP.js";
|
|
6
|
+
import "./icon-DmRyYNlY.js";
|
|
7
7
|
var d = {
|
|
8
8
|
name: "pkt-tag",
|
|
9
9
|
react: "PktTag",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { _ as e, d as t, f as n, g as r, h as i, l as a, m as o, n as s, p as c, u as l } from "./element-
|
|
2
|
-
import { t as u } from "./class-map-
|
|
3
|
-
import { t as d } from "./if-defined-
|
|
4
|
-
import { i as f, r as p } from "./directive-helpers-
|
|
5
|
-
import { r as m } from "./element-with-slot-
|
|
6
|
-
import "./icon-
|
|
7
|
-
import { n as h, t as g } from "./ref-
|
|
8
|
-
import { t as _ } from "./input-element-
|
|
9
|
-
import { r as v } from "./input-wrapper-
|
|
1
|
+
import { _ as e, d as t, f as n, g as r, h as i, l as a, m as o, n as s, p as c, u as l } from "./element-mwwC2Rra.js";
|
|
2
|
+
import { t as u } from "./class-map-C4hdfSfY.js";
|
|
3
|
+
import { t as d } from "./if-defined-Bebu3LXY.js";
|
|
4
|
+
import { i as f, r as p } from "./directive-helpers-D96YEsht.js";
|
|
5
|
+
import { r as m } from "./element-with-slot-FD826ooP.js";
|
|
6
|
+
import "./icon-DmRyYNlY.js";
|
|
7
|
+
import { n as h, t as g } from "./ref-CCSGk4MP.js";
|
|
8
|
+
import { t as _ } from "./input-element-B1BntJeJ.js";
|
|
9
|
+
import { r as v } from "./input-wrapper-C1zXIKBU.js";
|
|
10
10
|
//#region ../../node_modules/lit-html/directives/live.js
|
|
11
11
|
var y = n(class extends c {
|
|
12
12
|
constructor(e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-
|
|
1
|
+
const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./if-defined-2mkIDgOm.cjs"),r=require("./directive-helpers-BRrz3Bcj.cjs"),i=require("./element-with-slot-2PHu2w7O.cjs");require("./icon-CoBsgGUR.cjs");const a=require("./ref-Emu5PNxk.cjs"),o=require("./input-element-W6Gklt2E.cjs"),s=require("./input-wrapper-CSPPa4uc.cjs");var c=e.f(class extends e.p{constructor(t){if(super(t),t.type!==e.m.PROPERTY&&t.type!==e.m.ATTRIBUTE&&t.type!==e.m.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!r.i(t))throw Error("`live` bindings can only contain a single expression")}render(e){return e}update(t,[n]){if(n===e.g||n===e.h)return n;let i=t.element,a=t.name;if(t.type===e.m.PROPERTY){if(n===i[a])return e.g}else if(t.type===e.m.BOOLEAN_ATTRIBUTE){if(!!n===i.hasAttribute(a))return e.g}else if(t.type===e.m.ATTRIBUTE&&i.getAttribute(a)===n+``)return e.g;return r.r(t),n}}),l=class extends o.t{constructor(...e){super(...e),this.inputRef=a.t(),this.value=``,this.autocomplete=`off`,this.rows=null,this.cols=null,this.counterCurrent=0}attributeChangedCallback(e,t,n){e===`value`&&this.value!==t&&(this.counterCurrent=n?n.length:0),super.attributeChangedCallback(e,t,n)}willUpdate(e){super.willUpdate(e),e.has(`value`)&&(this.counterCurrent=this.value?.length||0),e.has(`id`)&&!this.name&&this.id&&(this.name=this.id)}updated(e){super.updated(e),this.classList.add(`pkt-textinput`,`pkt-textarea`),e.has(`value`)&&this.valueChanged(this.value,e.get(`value`))}render(){let r=this.effectiveCounter(this.counterMaxLength>0),o=t.t({"pkt-input":!0,[`pkt-input--${this.inputSize}`]:!0,"pkt-input--fullwidth":this.fullwidth,"pkt-input--counter-error":r&&this.counterMaxLength>0&&this.value.length>this.counterMaxLength}),l=this.ariaLabelledby||`${this.id}-input-label`;return e._`<pkt-input-wrapper
|
|
2
2
|
.strings=${this.strings}
|
|
3
3
|
label=${this.label}
|
|
4
4
|
?counter=${r}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-
|
|
1
|
+
const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./if-defined-2mkIDgOm.cjs"),r=require("./element-with-slot-2PHu2w7O.cjs");require("./icon-CoBsgGUR.cjs");const i=require("./ref-Emu5PNxk.cjs"),a=require("./input-element-W6Gklt2E.cjs"),o=require("./input-wrapper-CSPPa4uc.cjs");var s=class extends a.t{constructor(...e){super(...e),this.inputRef=i.t(),this.value=``,this.type=`text`,this.size=null,this.autocomplete=null,this.iconNameRight=null,this.prefix=null,this.suffix=null,this.omitSearchIcon=!1,this.counterCurrent=0}attributeChangedCallback(e,t,n){e===`value`&&this.value!==t&&(this.counterCurrent=n?n.length:0),super.attributeChangedCallback(e,t,n)}willUpdate(e){super.willUpdate(e),e.has(`value`)&&(this.counterCurrent=this.value?.length||0),e.has(`id`)&&!this.name&&this.id&&(this.name=this.id)}updated(e){super.updated(e),this.classList.add(`pkt-textinput`),e.has(`value`)&&this.valueChanged(this.value,e.get(`value`))}render(){let a=this.type===`search`&&!this.iconNameRight&&!this.omitSearchIcon,s=this.effectiveCounter(this.counterMaxLength>0),c=t.t({"pkt-input":!0,[`pkt-input--${this.inputSize}`]:!0,"pkt-input--fullwidth":this.fullwidth,"pkt-input--counter-error":s&&this.counterMaxLength>0&&this.value.length>this.counterMaxLength}),l=this.ariaLabelledby||`${this.id}-input-label`;return e._`
|
|
2
2
|
<pkt-input-wrapper
|
|
3
3
|
.strings=${this.strings}
|
|
4
4
|
label="${this.label}"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-
|
|
2
|
-
import { t as o } from "./class-map-
|
|
3
|
-
import { t as s } from "./if-defined-
|
|
4
|
-
import { r as c } from "./element-with-slot-
|
|
5
|
-
import "./icon-
|
|
6
|
-
import { n as l, t as u } from "./ref-
|
|
7
|
-
import { t as d } from "./input-element-
|
|
8
|
-
import { r as f } from "./input-wrapper-
|
|
1
|
+
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-mwwC2Rra.js";
|
|
2
|
+
import { t as o } from "./class-map-C4hdfSfY.js";
|
|
3
|
+
import { t as s } from "./if-defined-Bebu3LXY.js";
|
|
4
|
+
import { r as c } from "./element-with-slot-FD826ooP.js";
|
|
5
|
+
import "./icon-DmRyYNlY.js";
|
|
6
|
+
import { n as l, t as u } from "./ref-CCSGk4MP.js";
|
|
7
|
+
import { t as d } from "./input-element-B1BntJeJ.js";
|
|
8
|
+
import { r as f } from "./input-wrapper-C1zXIKBU.js";
|
|
9
9
|
//#region src/components/textinput/textinput.ts
|
|
10
10
|
var p = class extends d {
|
|
11
11
|
constructor(...e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-CewjrA4g.cjs"),t=require("./class-map-B0FX3YsK.cjs"),n=require("./if-defined-CjRKmMQs.cjs"),r=require("./format-B8meU8Tm.cjs"),i=require("./element-with-slot-MCvSBwUv.cjs");require("./icon-Clz68-Kz.cjs");const a=require("./ref-HT6KRjxp.cjs"),o=require("./input-element-BdIWsDl-.cjs"),s=require("./input-wrapper-BmPdpY4N.cjs");var c=e=>/^\d{2}:\d{2}$/.test(e)&&parseInt(e.slice(0,2),10)<=23&&parseInt(e.slice(3),10)<=59,l=e=>{let[t,n]=e.split(`:`).map(Number);return t*60+n},u=e=>e?Math.max(1,Math.round(e/60)):1,d=(e,t)=>{let n=e?parseInt(String(e).split(`:`)[0],10):0,r=t?parseInt(String(t).split(`:`)[0],10):23;return Array.from({length:r-n+1},(e,t)=>t+n)},f=e=>{let t=u(e);return Array.from({length:Math.floor(60/t)},(e,n)=>n*t)},p=(e,t,n,r)=>{let i=e===``?n===1?0:23:parseInt(e,10),a=t===``?n===1?0:Math.floor(59/r)*r:parseInt(t,10);return a+=n*r,a>59?(a=0,i=(i+1)%24):a<0&&(a=Math.floor(59/r)*r,i=(i-1+24)%24),{hours:String(i).padStart(2,`0`),minutes:String(a).padStart(2,`0`)}},m=class extends o.t{constructor(...e){super(...e),this.hiddenInputRef=a.t(),this.hoursInputRef=a.t(),this.minutesInputRef=a.t(),this.buttonRef=a.t(),this.value=``,this.hidePicker=!1,this.stepArrows=!1,this._hours=``,this._minutes=``,this._isOpen=!1,this._hoursDigitCount=0,this._hoursFirstDigit=-1,this._minutesDigitCount=0,this._minutesFirstDigit=-1,this._hasFocus=!1,this._outsideClickHandler=e=>{this.contains(e.target)||this._closePopup()},this._handleComponentFocusIn=()=>{this._hasFocus||(this._hasFocus=!0,this.onFocus())},this._handleComponentFocusOut=e=>{this.contains(e.relatedTarget)||(this._hasFocus=!1,this.onBlur())},this._handleHoursKeydown=e=>{let t=e.target;switch(e.key){case`ArrowUp`:{e.preventDefault();let t=this._hours===``?0:parseInt(this._hours,10);this._hours=String((t+1)%24).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowDown`:{e.preventDefault();let t=this._hours===``?0:parseInt(this._hours,10);this._hours=String((t-1+24)%24).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowRight`:e.preventDefault(),this.minutesInputRef.value?.focus();break;case`Backspace`:case`Delete`:this._hoursDigitCount=0,this._hoursFirstDigit=-1;break;case`Tab`:break;case`Enter`:{e.preventDefault();let n=this.internals.form;n?n.requestSubmit():t.blur();break}default:if(/^\d$/.test(e.key)){e.preventDefault();let t=parseInt(e.key,10);if(this._hoursDigitCount===0)this._hoursFirstDigit=t,this._hours=String(t).padStart(2,`0`),this._hoursDigitCount=1,this.onInput(),t>=3&&(this._hoursFirstDigit=-1,this._hoursDigitCount=0,this._syncValueFromDisplay(),this.minutesInputRef.value?.focus());else{let e=this._hoursFirstDigit*10+t;this._hours=e<=23?String(e).padStart(2,`0`):String(t).padStart(2,`0`),this._hoursFirstDigit=-1,this._hoursDigitCount=0,this._syncValueFromDisplay(),this.onInput(),this.minutesInputRef.value?.focus()}}else e.preventDefault()}},this._handleHoursBlur=()=>{this._hours!==``&&(this._hours=String(parseInt(this._hours,10)).padStart(2,`0`)),this._hoursDigitCount=0,this._hoursFirstDigit=-1,this._syncValueFromDisplay()},this._handleMinutesKeydown=e=>{let t=e.target;switch(e.key){case`ArrowUp`:{e.preventDefault();let t=this._minutes===``?0:parseInt(this._minutes,10);this._minutes=String((t+this._minuteStep)%60).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowDown`:{e.preventDefault();let t=this._minutes===``?0:parseInt(this._minutes,10);this._minutes=String((t-this._minuteStep+60)%60).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowLeft`:e.preventDefault(),this.hoursInputRef.value?.focus();break;case`Backspace`:case`Delete`:this._minutesDigitCount=0,this._minutesFirstDigit=-1;break;case`Tab`:break;case`Enter`:{e.preventDefault();let n=this.internals.form;n?n.requestSubmit():t.blur();break}default:if(/^\d$/.test(e.key)){e.preventDefault();let t=parseInt(e.key,10);if(this._minutesDigitCount===0)this._minutesFirstDigit=t,this._minutes=String(t).padStart(2,`0`),this._minutesDigitCount=1,this.onInput(),t>=6&&(this._minutesFirstDigit=-1,this._minutesDigitCount=0,this._syncValueFromDisplay());else{let e=this._minutesFirstDigit*10+t;this._minutes=e<=59?String(e).padStart(2,`0`):String(t).padStart(2,`0`),this._minutesFirstDigit=-1,this._minutesDigitCount=0,this._syncValueFromDisplay(),this.onInput()}}else e.preventDefault()}},this._handleMinutesBlur=()=>{this._minutes!==``&&(this._minutes=String(parseInt(this._minutes,10)).padStart(2,`0`)),this._minutesDigitCount=0,this._minutesFirstDigit=-1,this._syncValueFromDisplay()},this._handlePopupKeydown=e=>{let t=document.activeElement,n=t.closest(`.pkt-timepicker-popup__col`);if(!n)return;let r=Array.from(n.querySelectorAll(`.pkt-timepicker-popup__option`)),i=r.indexOf(t),a=t.dataset.type??``;switch(e.key){case`ArrowDown`:e.preventDefault(),this._focusOptionAndSync(r[Math.min(i+1,r.length-1)],a);break;case`ArrowUp`:e.preventDefault(),this._focusOptionAndSync(r[Math.max(i-1,0)],a);break;case`Home`:e.preventDefault(),this._focusOptionAndSync(r[0],a);break;case`End`:e.preventDefault(),this._focusOptionAndSync(r[r.length-1],a);break;case`ArrowRight`:e.preventDefault(),a===`hour`&&(this._focusOptionAndSync(t,a),this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`minute`)}));break;case`ArrowLeft`:e.preventDefault(),a===`minute`&&(this._focusOptionAndSync(t,a),this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`hour`)}));break;case`Enter`:case` `:e.preventDefault(),t.click();break;case`Escape`:e.preventDefault(),this._closePopup(),this.buttonRef.value?.focus()}}}get inputRef(){return this.hiddenInputRef}manageValidity(e){let t=this.hoursInputRef.value;if(!t)return;let n=this.pktStrings.get(`validation`);if(this.required&&!this.value){this.internals.setValidity({valueMissing:!0},n.valueMissing,t),this._setAriaInvalid(!0);return}if(!this.value){this.internals.setValidity({}),this._setAriaInvalid(!1);return}let i=l(this.value),a=u(this.step);if(this.min&&i<l(String(this.min))){this.internals.setValidity({rangeUnderflow:!0},r.t(n.rangeUnderflowMin,{min:String(this.min)}),t),this._setAriaInvalid(!0);return}if(this.max&&i>l(String(this.max))){this.internals.setValidity({rangeOverflow:!0},r.t(n.rangeOverflowMax,{max:String(this.max)}),t),this._setAriaInvalid(!0);return}if(this.step&&i%a!==0){let e=a===60?n.timeStepMismatchHour:a===30?n.timeStepMismatchHalfHour:r.t(n.timeStepMismatch,{step:`${a}, ${a*2}, ${a*3}`});this.internals.setValidity({stepMismatch:!0},e,t),this._setAriaInvalid(!0);return}this.internals.setValidity({}),this._setAriaInvalid(!1)}_describedBy(){return s.r({id:`${this.id}-hours`,hasHelptext:!!this.helptext,ariaDescribedby:this.ariaDescribedby})}_setAriaInvalid(e){if(!this.touched&&e)return;let t=this.hoursInputRef.value,n=this.minutesInputRef.value;if(e)t?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-invalid`,`true`);else{if(this.hasError)return;t?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-invalid`)}}connectedCallback(){super.connectedCallback(),this.addEventListener(`focusin`,this._handleComponentFocusIn),this.addEventListener(`focusout`,this._handleComponentFocusOut),document.addEventListener(`click`,this._outsideClickHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`focusin`,this._handleComponentFocusIn),this.removeEventListener(`focusout`,this._handleComponentFocusOut),document.removeEventListener(`click`,this._outsideClickHandler)}willUpdate(e){super.willUpdate(e),e.has(`value`)&&this._syncDisplayFromValue()}updated(e){super.updated(e),this.classList.add(`pkt-timepicker`),this.classList.toggle(`pkt-timepicker--stepper`,this.stepArrows),this.classList.toggle(`pkt-timepicker--fullwidth`,this.fullwidth),this.classList.toggle(`pkt-timepicker--medium`,this.inputSize===`medium`),this.classList.toggle(`pkt-timepicker--small`,this.inputSize===`small`),this.classList.toggle(`pkt-timepicker--xsmall`,this.inputSize===`xsmall`),e.has(`step`)&&this.step!==null&&!this._isValidStep(this.step)&&console.warn(`pkt-timepicker: step="${this.step}" er ikke en gyldig verdi. Step må være et multiplum av 60 (hele minutter) eller nøyaktig 3600 (hel time).`)}formResetCallback(){super.formResetCallback(),this._hours=``,this._minutes=``,this._isOpen=!1}_isValidStep(e){return e===3600||e<3600&&3600%e==0&&e%60==0}_syncDisplayFromValue(){let e=c(this.value)?this.value.split(`:`):null;e?(this._hours=e[0],this._minutes=e[1]):(this._hours=``,this._minutes=``)}_syncValueFromDisplay(){if(this._hours!==``&&this._minutes!==``){let e=`${this._hours}:${this._minutes}`;e!==this.value&&(this.value=e,this.onChange(e))}else this.value!==``&&(this.value=``,this.onChange(``))}get _minuteStep(){return u(this.step)}get _hourOptions(){return d(this.min,this.max)}get _minuteOptions(){return f(this.step)}_openPopup(){this._isOpen=!0,this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`hour`)})}_closePopup(){this._isOpen=!1,this._syncValueFromDisplay()}_togglePopup(){this._isOpen?this._closePopup():this._openPopup()}_scrollToSelected(){let e=this.querySelector(`.pkt-timepicker-popup`);e&&e.querySelectorAll(`.pkt-timepicker-popup__col`).forEach(e=>{let t=e.querySelector(`.pkt-timepicker-popup__option--selected`);t&&t.scrollIntoView({block:`center`})})}_focusSelectedOrFirst(e){let t=this.querySelector(`.pkt-timepicker-popup`);if(!t)return;let n=t.querySelectorAll(`.pkt-timepicker-popup__col`),r=e===`hour`?n[0]:n[1];if(!r)return;let i=r.querySelector(`.pkt-timepicker-popup__option--selected`),a=r.querySelector(`.pkt-timepicker-popup__option`);(i||a)?.focus()}_handleOptionClick(e,t){let n=String(e).padStart(2,`0`);t===`hour`?(this._hours=n,this.updateComplete.then(()=>this._focusSelectedOrFirst(`minute`))):(this._minutes=n,this._closePopup(),this.buttonRef.value?.focus())}_focusOptionAndSync(e,t){if(!e)return;let n=parseInt(e.dataset.value??`0`,10);t===`hour`?this._hours=String(n).padStart(2,`0`):this._minutes=String(n).padStart(2,`0`),e.focus()}_stepTime(e){let t=p(this._hours,this._minutes,e,this._minuteStep);this._hours=t.hours,this._minutes=t.minutes,this._syncValueFromDisplay()}_renderOption(n,r){let i=String(n).padStart(2,`0`),a=n===(r===`hour`?this._hours===``?NaN:parseInt(this._hours,10):this._minutes===``?NaN:parseInt(this._minutes,10));return e._`
|
|
1
|
+
const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./if-defined-2mkIDgOm.cjs"),r=require("./format-B8meU8Tm.cjs"),i=require("./element-with-slot-2PHu2w7O.cjs");require("./icon-CoBsgGUR.cjs");const a=require("./ref-Emu5PNxk.cjs"),o=require("./input-element-W6Gklt2E.cjs"),s=require("./input-wrapper-CSPPa4uc.cjs");var c=e=>/^\d{2}:\d{2}$/.test(e)&&parseInt(e.slice(0,2),10)<=23&&parseInt(e.slice(3),10)<=59,l=e=>{let[t,n]=e.split(`:`).map(Number);return t*60+n},u=e=>e?Math.max(1,Math.round(e/60)):1,d=(e,t)=>{let n=e?parseInt(String(e).split(`:`)[0],10):0,r=t?parseInt(String(t).split(`:`)[0],10):23;return Array.from({length:r-n+1},(e,t)=>t+n)},f=e=>{let t=u(e);return Array.from({length:Math.floor(60/t)},(e,n)=>n*t)},p=(e,t,n,r)=>{let i=e===``?n===1?0:23:parseInt(e,10),a=t===``?n===1?0:Math.floor(59/r)*r:parseInt(t,10);return a+=n*r,a>59?(a=0,i=(i+1)%24):a<0&&(a=Math.floor(59/r)*r,i=(i-1+24)%24),{hours:String(i).padStart(2,`0`),minutes:String(a).padStart(2,`0`)}},m=class extends o.t{constructor(...e){super(...e),this.hiddenInputRef=a.t(),this.hoursInputRef=a.t(),this.minutesInputRef=a.t(),this.buttonRef=a.t(),this.value=``,this.hidePicker=!1,this.stepArrows=!1,this._hours=``,this._minutes=``,this._isOpen=!1,this._hoursDigitCount=0,this._hoursFirstDigit=-1,this._minutesDigitCount=0,this._minutesFirstDigit=-1,this._hasFocus=!1,this._outsideClickHandler=e=>{this.contains(e.target)||this._closePopup()},this._handleComponentFocusIn=()=>{this._hasFocus||(this._hasFocus=!0,this.onFocus())},this._handleComponentFocusOut=e=>{this.contains(e.relatedTarget)||(this._hasFocus=!1,this.onBlur())},this._handleHoursKeydown=e=>{let t=e.target;switch(e.key){case`ArrowUp`:{e.preventDefault();let t=this._hours===``?0:parseInt(this._hours,10);this._hours=String((t+1)%24).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowDown`:{e.preventDefault();let t=this._hours===``?0:parseInt(this._hours,10);this._hours=String((t-1+24)%24).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowRight`:e.preventDefault(),this.minutesInputRef.value?.focus();break;case`Backspace`:case`Delete`:this._hoursDigitCount=0,this._hoursFirstDigit=-1;break;case`Tab`:break;case`Enter`:{e.preventDefault();let n=this.internals.form;n?n.requestSubmit():t.blur();break}default:if(/^\d$/.test(e.key)){e.preventDefault();let t=parseInt(e.key,10);if(this._hoursDigitCount===0)this._hoursFirstDigit=t,this._hours=String(t).padStart(2,`0`),this._hoursDigitCount=1,this.onInput(),t>=3&&(this._hoursFirstDigit=-1,this._hoursDigitCount=0,this._syncValueFromDisplay(),this.minutesInputRef.value?.focus());else{let e=this._hoursFirstDigit*10+t;this._hours=e<=23?String(e).padStart(2,`0`):String(t).padStart(2,`0`),this._hoursFirstDigit=-1,this._hoursDigitCount=0,this._syncValueFromDisplay(),this.onInput(),this.minutesInputRef.value?.focus()}}else e.preventDefault()}},this._handleHoursBlur=()=>{this._hours!==``&&(this._hours=String(parseInt(this._hours,10)).padStart(2,`0`)),this._hoursDigitCount=0,this._hoursFirstDigit=-1,this._syncValueFromDisplay()},this._handleMinutesKeydown=e=>{let t=e.target;switch(e.key){case`ArrowUp`:{e.preventDefault();let t=this._minutes===``?0:parseInt(this._minutes,10);this._minutes=String((t+this._minuteStep)%60).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowDown`:{e.preventDefault();let t=this._minutes===``?0:parseInt(this._minutes,10);this._minutes=String((t-this._minuteStep+60)%60).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowLeft`:e.preventDefault(),this.hoursInputRef.value?.focus();break;case`Backspace`:case`Delete`:this._minutesDigitCount=0,this._minutesFirstDigit=-1;break;case`Tab`:break;case`Enter`:{e.preventDefault();let n=this.internals.form;n?n.requestSubmit():t.blur();break}default:if(/^\d$/.test(e.key)){e.preventDefault();let t=parseInt(e.key,10);if(this._minutesDigitCount===0)this._minutesFirstDigit=t,this._minutes=String(t).padStart(2,`0`),this._minutesDigitCount=1,this.onInput(),t>=6&&(this._minutesFirstDigit=-1,this._minutesDigitCount=0,this._syncValueFromDisplay());else{let e=this._minutesFirstDigit*10+t;this._minutes=e<=59?String(e).padStart(2,`0`):String(t).padStart(2,`0`),this._minutesFirstDigit=-1,this._minutesDigitCount=0,this._syncValueFromDisplay(),this.onInput()}}else e.preventDefault()}},this._handleMinutesBlur=()=>{this._minutes!==``&&(this._minutes=String(parseInt(this._minutes,10)).padStart(2,`0`)),this._minutesDigitCount=0,this._minutesFirstDigit=-1,this._syncValueFromDisplay()},this._handlePopupKeydown=e=>{let t=document.activeElement,n=t.closest(`.pkt-timepicker-popup__col`);if(!n)return;let r=Array.from(n.querySelectorAll(`.pkt-timepicker-popup__option`)),i=r.indexOf(t),a=t.dataset.type??``;switch(e.key){case`ArrowDown`:e.preventDefault(),this._focusOptionAndSync(r[Math.min(i+1,r.length-1)],a);break;case`ArrowUp`:e.preventDefault(),this._focusOptionAndSync(r[Math.max(i-1,0)],a);break;case`Home`:e.preventDefault(),this._focusOptionAndSync(r[0],a);break;case`End`:e.preventDefault(),this._focusOptionAndSync(r[r.length-1],a);break;case`ArrowRight`:e.preventDefault(),a===`hour`&&(this._focusOptionAndSync(t,a),this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`minute`)}));break;case`ArrowLeft`:e.preventDefault(),a===`minute`&&(this._focusOptionAndSync(t,a),this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`hour`)}));break;case`Enter`:case` `:e.preventDefault(),t.click();break;case`Escape`:e.preventDefault(),this._closePopup(),this.buttonRef.value?.focus()}}}get inputRef(){return this.hiddenInputRef}manageValidity(e){let t=this.hoursInputRef.value;if(!t)return;let n=this.pktStrings.get(`validation`);if(this.required&&!this.value){this.internals.setValidity({valueMissing:!0},n.valueMissing,t),this._setAriaInvalid(!0);return}if(!this.value){this.internals.setValidity({}),this._setAriaInvalid(!1);return}let i=l(this.value),a=u(this.step);if(this.min&&i<l(String(this.min))){this.internals.setValidity({rangeUnderflow:!0},r.t(n.rangeUnderflowMin,{min:String(this.min)}),t),this._setAriaInvalid(!0);return}if(this.max&&i>l(String(this.max))){this.internals.setValidity({rangeOverflow:!0},r.t(n.rangeOverflowMax,{max:String(this.max)}),t),this._setAriaInvalid(!0);return}if(this.step&&i%a!==0){let e=a===60?n.timeStepMismatchHour:a===30?n.timeStepMismatchHalfHour:r.t(n.timeStepMismatch,{step:`${a}, ${a*2}, ${a*3}`});this.internals.setValidity({stepMismatch:!0},e,t),this._setAriaInvalid(!0);return}this.internals.setValidity({}),this._setAriaInvalid(!1)}_describedBy(){return s.r({id:`${this.id}-hours`,hasHelptext:!!this.helptext,ariaDescribedby:this.ariaDescribedby})}_setAriaInvalid(e){if(!this.touched&&e)return;let t=this.hoursInputRef.value,n=this.minutesInputRef.value;if(e)t?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-invalid`,`true`);else{if(this.hasError)return;t?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-invalid`)}}connectedCallback(){super.connectedCallback(),this.addEventListener(`focusin`,this._handleComponentFocusIn),this.addEventListener(`focusout`,this._handleComponentFocusOut),document.addEventListener(`click`,this._outsideClickHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`focusin`,this._handleComponentFocusIn),this.removeEventListener(`focusout`,this._handleComponentFocusOut),document.removeEventListener(`click`,this._outsideClickHandler)}willUpdate(e){super.willUpdate(e),e.has(`value`)&&this._syncDisplayFromValue()}updated(e){super.updated(e),this.classList.add(`pkt-timepicker`),this.classList.toggle(`pkt-timepicker--stepper`,this.stepArrows),this.classList.toggle(`pkt-timepicker--fullwidth`,this.fullwidth),this.classList.toggle(`pkt-timepicker--medium`,this.inputSize===`medium`),this.classList.toggle(`pkt-timepicker--small`,this.inputSize===`small`),this.classList.toggle(`pkt-timepicker--xsmall`,this.inputSize===`xsmall`),e.has(`step`)&&this.step!==null&&!this._isValidStep(this.step)&&console.warn(`pkt-timepicker: step="${this.step}" er ikke en gyldig verdi. Step må være et multiplum av 60 (hele minutter) eller nøyaktig 3600 (hel time).`)}formResetCallback(){super.formResetCallback(),this._hours=``,this._minutes=``,this._isOpen=!1}_isValidStep(e){return e===3600||e<3600&&3600%e==0&&e%60==0}_syncDisplayFromValue(){let e=c(this.value)?this.value.split(`:`):null;e?(this._hours=e[0],this._minutes=e[1]):(this._hours=``,this._minutes=``)}_syncValueFromDisplay(){if(this._hours!==``&&this._minutes!==``){let e=`${this._hours}:${this._minutes}`;e!==this.value&&(this.value=e,this.onChange(e))}else this.value!==``&&(this.value=``,this.onChange(``))}get _minuteStep(){return u(this.step)}get _hourOptions(){return d(this.min,this.max)}get _minuteOptions(){return f(this.step)}_openPopup(){this._isOpen=!0,this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`hour`)})}_closePopup(){this._isOpen=!1,this._syncValueFromDisplay()}_togglePopup(){this._isOpen?this._closePopup():this._openPopup()}_scrollToSelected(){let e=this.querySelector(`.pkt-timepicker-popup`);e&&e.querySelectorAll(`.pkt-timepicker-popup__col`).forEach(e=>{let t=e.querySelector(`.pkt-timepicker-popup__option--selected`);t&&t.scrollIntoView({block:`center`})})}_focusSelectedOrFirst(e){let t=this.querySelector(`.pkt-timepicker-popup`);if(!t)return;let n=t.querySelectorAll(`.pkt-timepicker-popup__col`),r=e===`hour`?n[0]:n[1];if(!r)return;let i=r.querySelector(`.pkt-timepicker-popup__option--selected`),a=r.querySelector(`.pkt-timepicker-popup__option`);(i||a)?.focus()}_handleOptionClick(e,t){let n=String(e).padStart(2,`0`);t===`hour`?(this._hours=n,this.updateComplete.then(()=>this._focusSelectedOrFirst(`minute`))):(this._minutes=n,this._closePopup(),this.buttonRef.value?.focus())}_focusOptionAndSync(e,t){if(!e)return;let n=parseInt(e.dataset.value??`0`,10);t===`hour`?this._hours=String(n).padStart(2,`0`):this._minutes=String(n).padStart(2,`0`),e.focus()}_stepTime(e){let t=p(this._hours,this._minutes,e,this._minuteStep);this._hours=t.hours,this._minutes=t.minutes,this._syncValueFromDisplay()}_renderOption(n,r){let i=String(n).padStart(2,`0`),a=n===(r===`hour`?this._hours===``?NaN:parseInt(this._hours,10):this._minutes===``?NaN:parseInt(this._minutes,10));return e._`
|
|
2
2
|
<button
|
|
3
3
|
class=${t.t({"pkt-btn":!0,"pkt-btn--tertiary":!0,"pkt-btn--small":!0,"pkt-btn--label-only":!0,"pkt-timepicker-popup__option":!0,"pkt-timepicker-popup__option--selected":a})}
|
|
4
4
|
type="button"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-
|
|
2
|
-
import { t as o } from "./class-map-
|
|
3
|
-
import { t as s } from "./if-defined-
|
|
1
|
+
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-mwwC2Rra.js";
|
|
2
|
+
import { t as o } from "./class-map-C4hdfSfY.js";
|
|
3
|
+
import { t as s } from "./if-defined-Bebu3LXY.js";
|
|
4
4
|
import { t as c } from "./format-BTeSVkED.js";
|
|
5
|
-
import { r as l } from "./element-with-slot-
|
|
6
|
-
import "./icon-
|
|
7
|
-
import { n as u, t as d } from "./ref-
|
|
8
|
-
import { t as f } from "./input-element-
|
|
9
|
-
import { r as p } from "./input-wrapper-
|
|
5
|
+
import { r as l } from "./element-with-slot-FD826ooP.js";
|
|
6
|
+
import "./icon-DmRyYNlY.js";
|
|
7
|
+
import { n as u, t as d } from "./ref-CCSGk4MP.js";
|
|
8
|
+
import { t as f } from "./input-element-B1BntJeJ.js";
|
|
9
|
+
import { r as p } from "./input-wrapper-C1zXIKBU.js";
|
|
10
10
|
//#region ../../shared-utils/timepicker/time-utils.ts
|
|
11
11
|
var m = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && parseInt(e.slice(3), 10) <= 59, h = (e) => {
|
|
12
12
|
let [t, n] = e.split(":").map(Number);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.4.0",
|
|
4
4
|
"description": "Komponentbiblioteket til Punkt, designsystem for Oslo kommune",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo kommune",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"engines": {
|
|
85
85
|
"node": "^22.19.0 || ^24.0.0 || ^26.0.0"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "74057ff529f28056e96199ce2b2def5aee6ef9bf"
|
|
88
88
|
}
|
|
@@ -242,7 +242,7 @@ describe('PktAlert', () => {
|
|
|
242
242
|
expect(closeButton).toBeInTheDocument()
|
|
243
243
|
expect(closeButton?.getAttribute('skin')).toBe('tertiary')
|
|
244
244
|
expect(closeButton?.getAttribute('variant')).toBe('icon-only')
|
|
245
|
-
expect(closeButton?.querySelector('button')?.getAttribute('aria-label')).toBe('
|
|
245
|
+
expect(closeButton?.querySelector('button')?.getAttribute('aria-label')).toBe('Lukk')
|
|
246
246
|
expect(closeButton?.hasAttribute('aria-label')).toBe(false)
|
|
247
247
|
})
|
|
248
248
|
|
|
@@ -127,7 +127,7 @@ export class PktAlert extends PktElementWithSlot<IPktAlert> implements IPktAlert
|
|
|
127
127
|
<div class="pkt-alert__close">
|
|
128
128
|
<pkt-button
|
|
129
129
|
tabindex="0"
|
|
130
|
-
aria-label
|
|
130
|
+
aria-label=${this.pktStrings.get('generic').close}
|
|
131
131
|
size=${alertSize}
|
|
132
132
|
type="button"
|
|
133
133
|
skin="tertiary"
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
type TCardSkin,
|
|
17
17
|
type TLayout,
|
|
18
18
|
} from 'shared-types'
|
|
19
|
+
import { plural, type IPktStringsProps } from 'shared-strings'
|
|
19
20
|
|
|
20
21
|
export type { TCardSkin, TLayout }
|
|
21
22
|
export type TCardPadding = 'none' | 'default'
|
|
@@ -23,7 +24,7 @@ export type TCardImageShape = 'square' | 'round'
|
|
|
23
24
|
export type TCardImageAspect = 'auto' | '1-1' | '4-3' | '3-2' | '16-9' | '19-10'
|
|
24
25
|
export type TCardTagPosition = 'top' | 'bottom'
|
|
25
26
|
|
|
26
|
-
export interface IPktCard {
|
|
27
|
+
export interface IPktCard extends IPktStringsProps<'card'> {
|
|
27
28
|
ariaLabel?: IAriaAttributes['aria-label']
|
|
28
29
|
metaLead?: string | null
|
|
29
30
|
metaTrail?: string | null
|
|
@@ -232,7 +233,11 @@ export class PktCard extends PktElementWithSlot implements IPktCard {
|
|
|
232
233
|
<div
|
|
233
234
|
class=${classMap(tagClasses)}
|
|
234
235
|
role="list"
|
|
235
|
-
aria-label=${
|
|
236
|
+
aria-label=${plural(
|
|
237
|
+
this.tags.length,
|
|
238
|
+
this.pktStrings.get('card').tagsLabelOne,
|
|
239
|
+
this.pktStrings.get('card').tagsLabelOther,
|
|
240
|
+
)}
|
|
236
241
|
>
|
|
237
242
|
${this.tags.map(
|
|
238
243
|
(tag) => html`
|
|
@@ -5,9 +5,7 @@ import { Ref, createRef, ref } from 'lit/directives/ref.js'
|
|
|
5
5
|
import { html, nothing, PropertyValues } from 'lit'
|
|
6
6
|
import { classMap } from 'lit/directives/class-map.js'
|
|
7
7
|
import { ElementProps } from '@/types/typeUtils'
|
|
8
|
-
import { CHECKBOX_DEFAULTS,
|
|
9
|
-
|
|
10
|
-
export type { TCheckboxLabelPosition }
|
|
8
|
+
import { CHECKBOX_DEFAULTS,type TCheckboxLabelPosition } from 'shared-types'
|
|
11
9
|
|
|
12
10
|
type Props = ElementProps<
|
|
13
11
|
PktCheckbox,
|
|
@@ -158,6 +158,20 @@ describe('PktConsent', () => {
|
|
|
158
158
|
|
|
159
159
|
expect(consent.i18nLanguage).toBe('en')
|
|
160
160
|
})
|
|
161
|
+
|
|
162
|
+
test.each(['sv', 'constructor'])(
|
|
163
|
+
'falls back to bokmål trigger text when i18nLanguage is "%s"',
|
|
164
|
+
async (language) => {
|
|
165
|
+
const { consent } = await createConsentTest({
|
|
166
|
+
i18nLanguage: language,
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
await consent.updateComplete
|
|
170
|
+
|
|
171
|
+
const button = consent.querySelector('pkt-button')
|
|
172
|
+
expect(button?.textContent?.trim()).toBe('Innstillinger for informasjonskapsler')
|
|
173
|
+
},
|
|
174
|
+
)
|
|
161
175
|
})
|
|
162
176
|
|
|
163
177
|
describe('Trigger types', () => {
|
|
@@ -2,37 +2,20 @@ import { customElement, property } from 'lit/decorators.js'
|
|
|
2
2
|
import { html, PropertyValues } from 'lit'
|
|
3
3
|
import { PktElement } from '@/base-elements/element'
|
|
4
4
|
import { consentStrings } from './strings'
|
|
5
|
+
import {
|
|
6
|
+
CONSENT_DEFAULTS,
|
|
7
|
+
type IConsentValue,
|
|
8
|
+
type ICookieBannerApi,
|
|
9
|
+
type ICookieConsentEvent,
|
|
10
|
+
type ICookieEvents,
|
|
11
|
+
type IPktConsentBase,
|
|
12
|
+
type TConsentDetailsMap,
|
|
13
|
+
type TCookieEventHandler,
|
|
14
|
+
type TPktConsentTriggerType,
|
|
15
|
+
} from 'shared-types'
|
|
5
16
|
import '../button'
|
|
6
17
|
|
|
7
|
-
|
|
8
|
-
name: string
|
|
9
|
-
consent: boolean
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface ConsentValue {
|
|
13
|
-
items: ConsentItem[]
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface CookieConsentEvent {
|
|
17
|
-
value: string | ConsentValue
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
type ConsentDetailsMap = Record<string, boolean>
|
|
21
|
-
|
|
22
|
-
type CookieEventHandler = (consent: CookieConsentEvent) => void
|
|
23
|
-
|
|
24
|
-
interface CookieEvents {
|
|
25
|
-
on(eventName: string, handler: CookieEventHandler): void
|
|
26
|
-
off(eventName: string, handler: CookieEventHandler): void
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface CookieBannerApi {
|
|
30
|
-
cookieConsent: {
|
|
31
|
-
validateConsentCookie(): Promise<boolean>
|
|
32
|
-
getConsentCookie(): string | ConsentValue
|
|
33
|
-
}
|
|
34
|
-
openCookieModal(): void
|
|
35
|
-
}
|
|
18
|
+
export type { TPktConsentTriggerType }
|
|
36
19
|
|
|
37
20
|
declare global {
|
|
38
21
|
interface Window {
|
|
@@ -42,8 +25,8 @@ declare global {
|
|
|
42
25
|
cookieBanner_cookieExpiryDays?: string | null
|
|
43
26
|
cookieBanner_googleAnalyticsId?: string | null
|
|
44
27
|
cookieBanner_hotjarId?: string | null
|
|
45
|
-
cookieBanner?:
|
|
46
|
-
__cookieEvents?:
|
|
28
|
+
cookieBanner?: ICookieBannerApi
|
|
29
|
+
__cookieEvents?: ICookieEvents
|
|
47
30
|
}
|
|
48
31
|
}
|
|
49
32
|
|
|
@@ -84,32 +67,20 @@ const parseJsonOrPassThrough = <T>(value: T | string): T => {
|
|
|
84
67
|
}
|
|
85
68
|
}
|
|
86
69
|
|
|
87
|
-
const toConsentDetails = (consent:
|
|
88
|
-
const parsed = parseJsonOrPassThrough<
|
|
89
|
-
return parsed.items.reduce<
|
|
70
|
+
const toConsentDetails = (consent: ICookieConsentEvent): TConsentDetailsMap => {
|
|
71
|
+
const parsed = parseJsonOrPassThrough<IConsentValue>(consent.value)
|
|
72
|
+
return parsed.items.reduce<TConsentDetailsMap>((acc, item) => {
|
|
90
73
|
acc[item.name] = item.consent
|
|
91
74
|
return acc
|
|
92
75
|
}, {})
|
|
93
76
|
}
|
|
94
77
|
|
|
95
|
-
export type
|
|
96
|
-
|
|
97
|
-
export interface IPktConsent {
|
|
98
|
-
devMode?: boolean
|
|
99
|
-
cookieDomain?: string | null
|
|
100
|
-
cookieSecure?: string | null
|
|
101
|
-
cookieExpiryDays?: string | null
|
|
102
|
-
hotjarId?: string | null
|
|
103
|
-
googleAnalyticsId?: string | null
|
|
104
|
-
i18nLanguage?: string
|
|
105
|
-
triggerType?: TPktConsentTriggerType | null
|
|
106
|
-
triggerText?: string | null
|
|
107
|
-
}
|
|
78
|
+
export type IPktConsent = IPktConsentBase
|
|
108
79
|
|
|
109
80
|
export class PktConsent extends PktElement<IPktConsent> implements IPktConsent {
|
|
110
|
-
private _cookieEventHandler?:
|
|
81
|
+
private _cookieEventHandler?: TCookieEventHandler
|
|
111
82
|
|
|
112
|
-
@property({ type: Boolean }) devMode: boolean =
|
|
83
|
+
@property({ type: Boolean }) devMode: boolean = CONSENT_DEFAULTS.devMode
|
|
113
84
|
|
|
114
85
|
@property({ type: String }) hotjarId: string | null = null
|
|
115
86
|
@property({ type: String }) googleAnalyticsId: string | null = null
|
|
@@ -117,13 +88,16 @@ export class PktConsent extends PktElement<IPktConsent> implements IPktConsent {
|
|
|
117
88
|
@property({ type: String }) cookieSecure: string | null = null
|
|
118
89
|
@property({ type: String }) cookieExpiryDays: string | null = null
|
|
119
90
|
|
|
120
|
-
@property({ type: String }) triggerType: TPktConsentTriggerType | null =
|
|
91
|
+
@property({ type: String }) triggerType: TPktConsentTriggerType | null =
|
|
92
|
+
CONSENT_DEFAULTS.triggerType
|
|
121
93
|
@property({ type: String }) triggerText: string | null = null
|
|
122
|
-
@property({ type: String }) i18nLanguage: string =
|
|
94
|
+
@property({ type: String }) i18nLanguage: string = CONSENT_DEFAULTS.i18nLanguage
|
|
123
95
|
|
|
124
96
|
connectedCallback(): void {
|
|
125
97
|
super.connectedCallback()
|
|
126
|
-
const language =
|
|
98
|
+
const language = (
|
|
99
|
+
Object.hasOwn(consentStrings.i18n, this.i18nLanguage) ? this.i18nLanguage : 'nb'
|
|
100
|
+
) as keyof typeof consentStrings.i18n
|
|
127
101
|
this.triggerText =
|
|
128
102
|
this.triggerText || consentStrings.i18n[language].contentPresentation.buttons.settings
|
|
129
103
|
}
|
|
@@ -144,9 +118,9 @@ export class PktConsent extends PktElement<IPktConsent> implements IPktConsent {
|
|
|
144
118
|
return parseJsonOrPassThrough(obj)
|
|
145
119
|
}
|
|
146
120
|
|
|
147
|
-
emitCookieConsents(consent:
|
|
121
|
+
emitCookieConsents(consent: ICookieConsentEvent): void {
|
|
148
122
|
this.dispatchEvent(
|
|
149
|
-
new CustomEvent<
|
|
123
|
+
new CustomEvent<TConsentDetailsMap>('toggle-consent', {
|
|
150
124
|
detail: toConsentDetails(consent),
|
|
151
125
|
bubbles: true,
|
|
152
126
|
cancelable: false,
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { html } from 'lit'
|
|
2
|
+
import { formatString, type TPktStrings } from 'shared-strings'
|
|
2
3
|
|
|
3
4
|
import type { TFileComment, TQueueItemOperation, TQueueOperationContext } from './fileupload-types'
|
|
4
5
|
|
|
5
6
|
const COMMENTS_ATTRIBUTE = 'comments'
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
type TFileuploadStrings = TPktStrings['fileupload']
|
|
9
|
+
|
|
10
|
+
const formatTimestamp = (iso: string, strings: TFileuploadStrings): string => {
|
|
8
11
|
const date = new Date(iso)
|
|
9
12
|
if (Number.isNaN(date.getTime())) return iso
|
|
10
13
|
const day = String(date.getDate()).padStart(2, '0')
|
|
@@ -12,7 +15,10 @@ const formatTimestamp = (iso: string): string => {
|
|
|
12
15
|
const year = date.getFullYear()
|
|
13
16
|
const hours = String(date.getHours()).padStart(2, '0')
|
|
14
17
|
const minutes = String(date.getMinutes()).padStart(2, '0')
|
|
15
|
-
return
|
|
18
|
+
return formatString(strings.commentTimestamp, {
|
|
19
|
+
date: `${day}.${month}.${year}`,
|
|
20
|
+
time: `${hours}:${minutes}`,
|
|
21
|
+
})
|
|
16
22
|
}
|
|
17
23
|
|
|
18
24
|
const handleRenameKeydown = (event: KeyboardEvent, save: () => void, cancel: () => void) => {
|
|
@@ -41,17 +47,20 @@ const handleCommentTextareaKeydown = (event: KeyboardEvent, save: () => void, ca
|
|
|
41
47
|
}
|
|
42
48
|
}
|
|
43
49
|
|
|
44
|
-
export const createRemoveOperation = (
|
|
50
|
+
export const createRemoveOperation = (
|
|
51
|
+
removeFile: (fileId: string) => void,
|
|
52
|
+
strings: TFileuploadStrings,
|
|
53
|
+
): TQueueItemOperation => ({
|
|
45
54
|
id: 'remove',
|
|
46
|
-
title:
|
|
47
|
-
ariaLabel:
|
|
55
|
+
title: strings.remove,
|
|
56
|
+
ariaLabel: strings.removeFile,
|
|
48
57
|
onClick: ({ file }) => removeFile(file.fileId),
|
|
49
58
|
})
|
|
50
59
|
|
|
51
|
-
export const createRenameOperation = (): TQueueItemOperation => ({
|
|
60
|
+
export const createRenameOperation = (strings: TFileuploadStrings): TQueueItemOperation => ({
|
|
52
61
|
id: 'rename',
|
|
53
|
-
title:
|
|
54
|
-
ariaLabel:
|
|
62
|
+
title: strings.rename,
|
|
63
|
+
ariaLabel: strings.renameFile,
|
|
55
64
|
renderInlineUI: (context: TQueueOperationContext) => {
|
|
56
65
|
const currentName =
|
|
57
66
|
context.getAttribute<string>('targetFilename') ||
|
|
@@ -70,7 +79,7 @@ export const createRenameOperation = (): TQueueItemOperation => ({
|
|
|
70
79
|
}
|
|
71
80
|
|
|
72
81
|
return html`
|
|
73
|
-
<label for=${inputId} class="pkt-sr-only"
|
|
82
|
+
<label for=${inputId} class="pkt-sr-only">${strings.renameInputLabel}</label>
|
|
74
83
|
<input
|
|
75
84
|
id=${inputId}
|
|
76
85
|
type="text"
|
|
@@ -85,7 +94,7 @@ export const createRenameOperation = (): TQueueItemOperation => ({
|
|
|
85
94
|
?disabled=${context.disabled}
|
|
86
95
|
@click=${save}
|
|
87
96
|
>
|
|
88
|
-
|
|
97
|
+
${strings.save}
|
|
89
98
|
</button>
|
|
90
99
|
<button
|
|
91
100
|
type="button"
|
|
@@ -93,7 +102,7 @@ export const createRenameOperation = (): TQueueItemOperation => ({
|
|
|
93
102
|
?disabled=${context.disabled}
|
|
94
103
|
@click=${context.close}
|
|
95
104
|
>
|
|
96
|
-
|
|
105
|
+
${strings.cancel}
|
|
97
106
|
</button>
|
|
98
107
|
`
|
|
99
108
|
},
|
|
@@ -111,13 +120,13 @@ export const createRenameOperation = (): TQueueItemOperation => ({
|
|
|
111
120
|
},
|
|
112
121
|
})
|
|
113
122
|
|
|
114
|
-
export const createCommentOperation = (): TQueueItemOperation => ({
|
|
123
|
+
export const createCommentOperation = (strings: TFileuploadStrings): TQueueItemOperation => ({
|
|
115
124
|
id: 'comment',
|
|
116
125
|
title: (file) => {
|
|
117
126
|
const comments = (file.attributes?.[COMMENTS_ATTRIBUTE] as TFileComment[] | undefined) ?? []
|
|
118
|
-
return comments.length > 0 ? '' :
|
|
127
|
+
return comments.length > 0 ? '' : strings.addComment
|
|
119
128
|
},
|
|
120
|
-
ariaLabel:
|
|
129
|
+
ariaLabel: strings.addComment,
|
|
121
130
|
renderExtendedUI: (context: TQueueOperationContext) => {
|
|
122
131
|
const comments = context.getAttribute<TFileComment[]>(COMMENTS_ATTRIBUTE) ?? []
|
|
123
132
|
const existingComment = comments[0]
|
|
@@ -133,7 +142,7 @@ export const createCommentOperation = (): TQueueItemOperation => ({
|
|
|
133
142
|
|
|
134
143
|
return html`
|
|
135
144
|
<label for=${textareaId} class="pkt-fileupload__queue-display__item__comment-label">
|
|
136
|
-
${existingComment ?
|
|
145
|
+
${existingComment ? strings.editComment : strings.addComment}
|
|
137
146
|
</label>
|
|
138
147
|
<textarea
|
|
139
148
|
id=${textareaId}
|
|
@@ -141,7 +150,7 @@ export const createCommentOperation = (): TQueueItemOperation => ({
|
|
|
141
150
|
?disabled=${context.disabled}
|
|
142
151
|
.value=${existingComment?.text ?? ''}
|
|
143
152
|
rows="2"
|
|
144
|
-
placeholder
|
|
153
|
+
placeholder=${strings.commentPlaceholder}
|
|
145
154
|
@keydown=${(event: KeyboardEvent) => handleCommentTextareaKeydown(event, save, context.close)}
|
|
146
155
|
></textarea>
|
|
147
156
|
<button
|
|
@@ -150,7 +159,7 @@ export const createCommentOperation = (): TQueueItemOperation => ({
|
|
|
150
159
|
?disabled=${context.disabled}
|
|
151
160
|
@click=${save}
|
|
152
161
|
>
|
|
153
|
-
${existingComment ?
|
|
162
|
+
${existingComment ? strings.saveComment : strings.addComment}
|
|
154
163
|
</button>
|
|
155
164
|
<button
|
|
156
165
|
type="button"
|
|
@@ -158,7 +167,7 @@ export const createCommentOperation = (): TQueueItemOperation => ({
|
|
|
158
167
|
?disabled=${context.disabled}
|
|
159
168
|
@click=${context.close}
|
|
160
169
|
>
|
|
161
|
-
|
|
170
|
+
${strings.cancel}
|
|
162
171
|
</button>
|
|
163
172
|
`
|
|
164
173
|
},
|
|
@@ -171,18 +180,18 @@ export const createCommentOperation = (): TQueueItemOperation => ({
|
|
|
171
180
|
<div class="pkt-fileupload__queue-display__item__comments">
|
|
172
181
|
<div class="pkt-fileupload__queue-display__item__comment">
|
|
173
182
|
<div class="pkt-fileupload__queue-display__item__comment__content">
|
|
174
|
-
<span class="pkt-fileupload__queue-display__item__comment__text" aria-label
|
|
183
|
+
<span class="pkt-fileupload__queue-display__item__comment__text" aria-label=${strings.commentText}>
|
|
175
184
|
${comment.text}
|
|
176
185
|
</span>
|
|
177
186
|
<time class="pkt-fileupload__queue-display__item__comment__time">
|
|
178
|
-
${formatTimestamp(comment.timestamp)}
|
|
187
|
+
${formatTimestamp(comment.timestamp, strings)}
|
|
179
188
|
</time>
|
|
180
189
|
</div>
|
|
181
190
|
<div class="pkt-fileupload__queue-display__item__comment__actions">
|
|
182
191
|
<button
|
|
183
192
|
type="button"
|
|
184
193
|
class="pkt-fileupload__queue-display__item__comment__action"
|
|
185
|
-
aria-label
|
|
194
|
+
aria-label=${strings.editComment}
|
|
186
195
|
?disabled=${context.disabled}
|
|
187
196
|
@click=${context.activate}
|
|
188
197
|
>
|
|
@@ -191,7 +200,7 @@ export const createCommentOperation = (): TQueueItemOperation => ({
|
|
|
191
200
|
<button
|
|
192
201
|
type="button"
|
|
193
202
|
class="pkt-fileupload__queue-display__item__comment__action"
|
|
194
|
-
aria-label
|
|
203
|
+
aria-label=${strings.deleteComment}
|
|
195
204
|
?disabled=${context.disabled}
|
|
196
205
|
@click=${() => context.setAttribute(COMMENTS_ATTRIBUTE, undefined)}
|
|
197
206
|
>
|