@oslokommune/punkt-elements 16.14.0 → 16.15.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 +17 -1
- package/dist/calendar-Ch1dgnBo.js +656 -0
- package/dist/calendar-DkjXla0I.cjs +90 -0
- package/dist/{card-CQYxrtL0.cjs → card-C3POnP3O.cjs} +1 -1
- package/dist/{card-Bir3-pl2.js → card-CEDbo1t7.js} +2 -2
- package/dist/{checkbox-Cspxcvt_.js → checkbox-Bjp43NxA.js} +1 -1
- package/dist/{checkbox-BARDb9iV.cjs → checkbox-nTbihMxW.cjs} +1 -1
- package/dist/{combobox-CstFVsy1.cjs → combobox-C4Q6kQEs.cjs} +1 -1
- package/dist/{combobox-DtYloYZq.js → combobox-CL9BLuxt.js} +6 -6
- package/dist/components/fileupload/fileupload-base.d.ts +116 -0
- package/dist/components/fileupload/fileupload-operations.d.ts +4 -0
- package/dist/components/fileupload/fileupload-renderers.d.ts +28 -0
- package/dist/components/fileupload/fileupload-types.d.ts +70 -0
- package/dist/components/fileupload/fileupload.d.ts +25 -0
- package/dist/components/fileupload/fileupload.test.d.ts +0 -0
- package/dist/components/fileupload/index.d.ts +4 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/converters-Bffq_YDm.cjs +1 -0
- package/dist/converters-jauYkvNh.js +1378 -0
- package/dist/{datepicker-gO2EuaBX.js → datepicker-BUK1Qanw.js} +22 -21
- package/dist/{datepicker-DfSdjIjl.cjs → datepicker-DYd3JCs_.cjs} +10 -10
- package/dist/docs/components/fileupload.d.ts +27 -0
- package/dist/fileupload-BRqioKSY.cjs +396 -0
- package/dist/fileupload-Bnl303X0.js +1372 -0
- package/dist/fileupload.d.ts +1 -0
- package/dist/{header-DpU4HYdj.cjs → header-Dps8o-ZY.cjs} +1 -1
- package/dist/{header-BHrgTCxj.js → header-T5O6sfCN.js} +3 -3
- package/dist/{helptext-CCBKKLus.js → helptext-C5rG4VkA.js} +2 -2
- package/dist/{helptext-D-3QfZv5.cjs → helptext-DQgStO4D.cjs} +1 -1
- package/dist/{input-element-Bw1s6NlF.js → input-element-CjebcQd1.js} +3 -3
- package/dist/{input-element-B1yxcfz4.cjs → input-element-FGcr5hGd.cjs} +1 -1
- package/dist/{input-wrapper-CzS4rUrK.cjs → input-wrapper-B_XFi211.cjs} +1 -1
- package/dist/{input-wrapper-XuUnGN_U.js → input-wrapper-DBpMVSxt.js} +4 -4
- package/dist/{listbox-DuBgTFvH.js → listbox-0NHJvNjz.js} +2 -2
- package/dist/{listbox-DCA2JoPV.cjs → listbox-CcThiNBY.cjs} +1 -1
- package/dist/{modal-CBEWrAi2.cjs → modal-B6591sWa.cjs} +1 -1
- package/dist/{modal-pPp8nia6.js → modal-DyIC3uhs.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 -0
- package/dist/pkt-fileupload.js +2 -0
- 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-index.cjs +1 -1
- package/dist/pkt-index.js +25 -24
- 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-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-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-CdXtmOBb.cjs → progressbar-CrwpnIkv.cjs} +1 -1
- package/dist/{progressbar-Dy9AiYQz.js → progressbar-uC-0W6o4.js} +1 -1
- package/dist/{radiobutton-V_KPbup_.js → radiobutton-B-8-wWFf.js} +1 -1
- package/dist/{radiobutton-GOnpUbCW.cjs → radiobutton-DvXr7tDk.cjs} +1 -1
- package/dist/{select-Cwzq_O8S.cjs → select-B75wzvyz.cjs} +1 -1
- package/dist/{select-Bo-w84pI.js → select-D9B8Ighz.js} +3 -3
- package/dist/shared-types/fileupload.d.ts +73 -0
- package/dist/shared-types/index.d.ts +2 -0
- package/dist/shared-utils/fileupload/announcements.d.ts +11 -0
- package/dist/shared-utils/fileupload/filename.d.ts +13 -0
- package/dist/shared-utils/fileupload/focus-trap.d.ts +12 -0
- package/dist/shared-utils/fileupload/formats.d.ts +30 -0
- package/dist/shared-utils/fileupload/index.d.ts +15 -0
- package/dist/shared-utils/fileupload/navigation.d.ts +5 -0
- package/dist/shared-utils/fileupload/size.d.ts +12 -0
- package/dist/shared-utils/fileupload/transfers.d.ts +17 -0
- package/dist/shared-utils/fileupload/truncate.d.ts +13 -0
- package/dist/shared-utils/fileupload/validation.d.ts +24 -0
- package/dist/tests/component-registry.d.ts +2 -0
- package/dist/{textarea-DYInBFHP.js → textarea-CIWXMaAD.js} +2 -2
- package/dist/{textarea-CbqiuSE8.cjs → textarea-CjqprL6Y.cjs} +1 -1
- package/dist/{textinput-Bp-UeGOq.cjs → textinput-B0VWmVIF.cjs} +1 -1
- package/dist/{textinput-DO9RldRk.js → textinput-CxzAxM8E.js} +2 -2
- package/dist/{timepicker-BpBcPB-r.cjs → timepicker-Cv9juQeB.cjs} +1 -1
- package/dist/{timepicker-D_XpQJXa.js → timepicker-DXrpg5C7.js} +2 -2
- package/package.json +2 -2
- package/src/components/fileupload/fileupload-base.ts +557 -0
- package/src/components/fileupload/fileupload-operations.ts +213 -0
- package/src/components/fileupload/fileupload-renderers.ts +769 -0
- package/src/components/fileupload/fileupload-types.ts +88 -0
- package/src/components/fileupload/fileupload.test.ts +949 -0
- package/src/components/fileupload/fileupload.ts +469 -0
- package/src/components/fileupload/index.ts +34 -0
- package/src/components/index.ts +16 -0
- package/dist/calendar-BzEtOJla.js +0 -2031
- package/dist/calendar-E5jJLt8D.cjs +0 -90
- /package/dist/{booleanish-jJLlnr6-.cjs → booleanish-B5EFqFpJ.cjs} +0 -0
- /package/dist/{booleanish-BmcOU-43.js → booleanish-CRaKZ75t.js} +0 -0
- /package/dist/{consent-DeB_5sWH.js → consent-f_IGyHss.js} +0 -0
- /package/dist/{consent-hwu7pp3S.cjs → consent-zh2npq2K.cjs} +0 -0
- /package/dist/{dialog-polyfill.esm-1hPr0gl9.js → dialog-polyfill.esm-BmVHGRTX.js} +0 -0
- /package/dist/{dialog-polyfill.esm-D3Oinvk0.cjs → dialog-polyfill.esm-CXDsb3l-.cjs} +0 -0
- /package/dist/{heading-DiQLPxdf.js → heading-BxvE80bb.js} +0 -0
- /package/dist/{heading-BgSWIRii.cjs → heading-DRJTS27k.cjs} +0 -0
- /package/dist/{input-wrapper-Dwd-_sKm.cjs → input-wrapper-CYCCx8MP.cjs} +0 -0
- /package/dist/{input-wrapper-CDyHTR1V.js → input-wrapper-kw2y6Jp_.js} +0 -0
- /package/dist/{link-CyTCpI0k.cjs → link-B8zYc5WK.cjs} +0 -0
- /package/dist/{link-CKAFMz9j.js → link-CjJcwcxR.js} +0 -0
- /package/dist/{linkcard-BE4-FewK.cjs → linkcard-C4x-NJMi.cjs} +0 -0
- /package/dist/{linkcard-B0KOGaGj.js → linkcard-Ddh5R_L-.js} +0 -0
- /package/dist/{loader-CX2rsC01.cjs → loader-CGQXAuyM.cjs} +0 -0
- /package/dist/{loader-6kFZUErT.js → loader-DeizpX45.js} +0 -0
- /package/dist/{messagebox-Din9X53b.cjs → messagebox-Ccu29rDv.cjs} +0 -0
- /package/dist/{messagebox-Cwlg5sOr.js → messagebox-DqoPqo4K.js} +0 -0
- /package/dist/{pkt-options-controller-CXUGx134.cjs → pkt-options-controller-BPBb_O2K.cjs} +0 -0
- /package/dist/{pkt-options-controller-CRrI6WMk.js → pkt-options-controller-DbLrdRwH.js} +0 -0
- /package/dist/{repeat-Cepr3469.js → repeat-DV1O43YU.js} +0 -0
- /package/dist/{repeat-CqcDYBxr.cjs → repeat-DaDFvx86.cjs} +0 -0
- /package/dist/{tabs-Rc9N9HWa.js → tabs-4eWA7CsK.js} +0 -0
- /package/dist/{tabs-BfurI6C3.cjs → tabs-RnDtIFv3.cjs} +0 -0
- /package/dist/{tag-DLthw5b4.cjs → tag-DWtajZk6.cjs} +0 -0
- /package/dist/{tag-VwykmuQR.js → tag-hl59gziI.js} +0 -0
- /package/dist/{utils-CUqCKGvp.js → utils-BOOZ0ppt.js} +0 -0
- /package/dist/{utils-CjAbIttF.cjs → utils-CM67Oudc.cjs} +0 -0
package/dist/pkt-tabs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "./tabs-
|
|
1
|
+
import { n as e, r as t, t as n } from "./tabs-4eWA7CsK.js";
|
|
2
2
|
export { e as PktTabItem, t as PktTabs, n as default };
|
package/dist/pkt-tag.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./tag-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./tag-DWtajZk6.cjs`);exports.PktTag=e.n,exports.default=e.t;
|
package/dist/pkt-tag.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, t } from "./tag-
|
|
1
|
+
import { n as e, t } from "./tag-hl59gziI.js";
|
|
2
2
|
export { e as PktTag, t as default };
|
package/dist/pkt-textarea.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./textarea-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./textarea-CjqprL6Y.cjs`);exports.PktTextarea=e.n,exports.default=e.t;
|
package/dist/pkt-textarea.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, t } from "./textarea-
|
|
1
|
+
import { n as e, t } from "./textarea-CIWXMaAD.js";
|
|
2
2
|
export { e as PktTextarea, t as default };
|
package/dist/pkt-textinput.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./textinput-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./textinput-B0VWmVIF.cjs`);exports.PktTextinput=e.n,exports.default=e.t;
|
package/dist/pkt-textinput.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, t } from "./textinput-
|
|
1
|
+
import { n as e, t } from "./textinput-CxzAxM8E.js";
|
|
2
2
|
export { e as PktTextinput, t as default };
|
package/dist/pkt-timepicker.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./timepicker-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./timepicker-Cv9juQeB.cjs`);exports.PktTimepicker=e.t;
|
package/dist/pkt-timepicker.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "./timepicker-
|
|
1
|
+
import { t as e } from "./timepicker-DXrpg5C7.js";
|
|
2
2
|
export { e as PktTimepicker };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./directive-CJ2giQBZ.cjs`),n=require(`./class-map-CJ-msbHs.cjs`);require(`./icon-Dr8sfT2X.cjs`);const r=require(`./ref-BaJ0mBT_.cjs`),i=require(`./utils-
|
|
1
|
+
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./directive-CJ2giQBZ.cjs`),n=require(`./class-map-CJ-msbHs.cjs`);require(`./icon-Dr8sfT2X.cjs`);const r=require(`./ref-BaJ0mBT_.cjs`),i=require(`./utils-CM67Oudc.cjs`);var a=`important`,o=` !`+a,s=t.t(class extends t.n{constructor(e){if(super(e),e.type!==t.r.ATTRIBUTE||e.name!==`style`||e.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce((t,n)=>{let r=e[n];return r==null?t:t+`${n=n.includes(`-`)?n:n.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,`-$&`).toLowerCase()}:${r};`},``)}update(t,[n]){let{style:r}=t.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(n)),this.render(n);for(let e of this.ft)n[e]??(this.ft.delete(e),e.includes(`-`)?r.removeProperty(e):r[e]=null);for(let e in n){let t=n[e];if(t!=null){this.ft.add(e);let n=typeof t==`string`&&t.endsWith(o);e.includes(`-`)||n?r.setProperty(e,n?t.slice(0,-11):t,n?a:``):r[e]=t}}return e.u}}),c=class extends e.t{constructor(){super(),this.ariaLabel=null,this.ariaLabelledby=null,this.ariaValueText=null,this.ariaLive=`polite`,this.id=i.n(),this.role=`progressbar`,this.skin=`dark-blue`,this.statusPlacement=`following`,this.statusType=`none`,this.title=``,this.titlePosition=`left`,this.valueCurrent=0,this.valueMax=100,this.valueMin=0,this.labelWidth=0,this.progressbarId=this.id,this.computedAriaLabelledby=null,this.computedAriaValueText=``,this.labelRef=r.t(),this.progressBarRef=r.t()}firstUpdated(e){super.firstUpdated(e),this.setComputedValues(),this.syncAttributes()}updated(e){super.updated(e),e.has(`valueCurrent`)&&this.labelRef.value&&(this.labelWidth=this.labelRef.value.getBoundingClientRect().width||0),e.has(`id`)&&this.id&&(this.progressBarId=this.id),(e.has(`statusType`)||e.has(`id`)||e.has(`ariaLabelledby`))&&(this.progressbarId=this.id||i.n(),this.computedAriaLabelledby=this.ariaLabelledby||`${this.progressbarId}-title`),(e.has(`ariaValueText`)||e.has(`valueCurrent`)||e.has(`valueMax`))&&(this.computedAriaValueText=this.statusType===`fraction`&&!this.ariaValueText?`${this.valueCurrent} av ${this.valueMax-this.valueMin}`:this.ariaValueText||``),this.syncAttributes()}render(){let t=this.statusType!==`none`,i=this.valueMax-this.valueMin,a=this.valueCurrent/i*100,o=this.statusType===`fraction`?Math.round(a):Math.round((this.valueCurrent-this.valueMin)/(this.valueMax-this.valueMin)*100),c=`${this.valueCurrent} av ${i}`,l=n.t({"pkt-progressbar__bar":!0,[`pkt-progressbar__bar--${this.skin}`]:!!this.skin}),u=n.t({"pkt-progressbar__title":!0,"pkt-progressbar__title-center":this.titlePosition===`center`}),d=n.t({"pkt-progressbar__status":!0,"pkt-progressbar__status--center":this.statusPlacement===`center`}),f=n.t({"pkt-progressbar__status-placement--following":this.statusPlacement===`following`,"pkt-progressbar__status-placement--center":this.statusPlacement===`center`,"pkt-progressbar__status-placement--left":this.statusPlacement===`left`});return e.d` <div
|
|
2
2
|
class="pkt-progressbar__container"
|
|
3
3
|
.ref=${this.progressBarRef}
|
|
4
4
|
style=${s({"--pkt-progress-label-width":`${this.labelWidth}px`,"--pkt-progress-width":`${o}%`})}
|
|
@@ -3,7 +3,7 @@ import { n as c, r as l, t as u } from "./directive-3THFsVew.js";
|
|
|
3
3
|
import { t as d } from "./class-map-C8HuhNzZ.js";
|
|
4
4
|
import "./icon-Co72KtgF.js";
|
|
5
5
|
import { n as f, t as p } from "./ref-RS8Uv6uC.js";
|
|
6
|
-
import { n as m } from "./utils-
|
|
6
|
+
import { n as m } from "./utils-BOOZ0ppt.js";
|
|
7
7
|
//#region ../../node_modules/lit-html/directives/style-map.js
|
|
8
8
|
var h = "important", g = " !" + h, _ = u(class extends c {
|
|
9
9
|
constructor(e) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as e, d as t, l as n, o as r, r as i, s as a } from "./element-cZ85T_aa.js";
|
|
2
2
|
import { t as o } from "./class-map-C8HuhNzZ.js";
|
|
3
3
|
import { n as s, t as c } from "./ref-RS8Uv6uC.js";
|
|
4
|
-
import { t as l } from "./input-element-
|
|
4
|
+
import { t as l } from "./input-element-CjebcQd1.js";
|
|
5
5
|
//#region src/components/radiobutton/radiobutton.ts
|
|
6
6
|
var u = class extends l {
|
|
7
7
|
constructor(...e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`),n=require(`./ref-BaJ0mBT_.cjs`),r=require(`./input-element-
|
|
1
|
+
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`),n=require(`./ref-BaJ0mBT_.cjs`),r=require(`./input-element-FGcr5hGd.cjs`);var i=class extends r.t{constructor(...e){super(...e),this.inputRef=n.t(),this.value=``,this.checkHelptext=null,this.defaultChecked=!1,this.hasTile=!1,this.checked=null,this.type=`radio`,this.tagText=null,this.optionalTag=!1,this.optionalText=`Valgfritt`,this.requiredTag=!1,this.requiredText=`Må fylles ut`,this._checked=!1}connectedCallback(){super.connectedCallback()}attributeChangedCallback(e,t,n){e===`defaultChecked`&&(this._checked=this.defaultChecked),e===`checked`&&(this._checked=this.checked===``||this.checked===`true`||this.checked===!0),super.attributeChangedCallback(e,t,n)}render(){let r=t.t({"pkt-input-check__input":!0,"pkt-input-check__input--tile":this.hasTile,"pkt-input-check__input--tile-disabled":this.disabled&&this.hasTile}),i=t.t({"pkt-input-check__input-checkbox":!0,"pkt-input-check__input-checkbox--error":this.hasError}),a=t.t({"pkt-input-check__input-label":!0,"pkt-input-check__input-label--disabled":this.disabled,"pkt-sr-only":this.hideLabel}),o=`pkt-tag pkt-tag--small pkt-tag--thin-text`;return e.d`
|
|
2
2
|
<div class="pkt-input-check">
|
|
3
3
|
<div class=${r}>
|
|
4
4
|
<input
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./element-with-slot-CWoTGA1B.cjs`),n=require(`./if-defined-XKOD_t_V.cjs`),r=require(`./ref-BaJ0mBT_.cjs`),i=require(`./input-element-
|
|
1
|
+
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./element-with-slot-CWoTGA1B.cjs`),n=require(`./if-defined-XKOD_t_V.cjs`),r=require(`./ref-BaJ0mBT_.cjs`),i=require(`./input-element-FGcr5hGd.cjs`),a=require(`./pkt-options-controller-BPBb_O2K.cjs`);require(`./input-wrapper-B_XFi211.cjs`);var o=class extends i.t{constructor(...e){super(...e),this._optionsProp=[],this._options=[]}get options(){return this._options.map(e=>({...e,selected:this.isOptionSelected(e)}))}set options(e){this._optionsProp=e,this.requestUpdate(`_optionsProp`,this._options)}isOptionSelected(e){return Array.isArray(this.value)?this.value.includes(e.value):e.value===this.value}findOptionByValue(e){return this._options.find(t=>t.value===e)}getSelectedOptions(){return this._options.filter(e=>this.isOptionSelected(e))}parseOptions(){let e=this._optionsProp.length>0,t=this.optionsController?.nodes?.length&&this.optionsController.nodes.length>0;e?this._options=this._optionsProp:t&&(this._options=this.optionsController.options)}willUpdate(e){super.willUpdate(e),this.parseOptions()}};e.r([e.s({type:Array,attribute:`options`})],o.prototype,`_optionsProp`,void 0),e.r([e.o()],o.prototype,`_options`,void 0);var s=class extends o{constructor(){super(),this.inputRef=r.t(),this.value=``,this.selectedIndex=-1,this.selectedOptions=void 0,this.optionsController=new a.t(this)}connectedCallback(){super.connectedCallback(),this.parseOptions(),this._options.forEach(e=>{e.selected&&!this.value&&(this.value=e.value)})}add(e,t){let n={value:e.value||e.text,label:e.text||e.value,selected:e.selected,disabled:e.disabled};if(t===void 0)this._options.push(n);else if(typeof t==`number`)this._options.splice(t,0,n);else{let e=t.value||t.text,r=this._options.findIndex(t=>t.value===e);r>=0?this._options.splice(r,0,n):this._options.push(n)}e.selected&&(this.value=e.value||e.text,this.selectedIndex=this._options.findIndex(e=>e.value===this.value)),this.requestUpdate()}remove(e){typeof e==`number`&&(this.selectedIndex===e&&(this.value=this._options[0]?.value||``),this._options.splice(e,1),this.requestUpdate())}item(e){return this.inputRef.value?.item(e)}namedItem(e){return this.inputRef.value?.namedItem(e)}showPicker(){this.inputRef.value&&`showPicker`in this.inputRef.value&&this.inputRef.value.showPicker()}attributeChangedCallback(e,t,n){e===`options`&&(this._options=n?JSON.parse(n):[]),e===`value`&&this.value!==t&&(this.selectedIndex=this.touched?this.returnNumberOrNull(this.inputRef.value?.selectedIndex):this._options.findIndex(e=>e.value===n),this.selectedOptions=this.inputRef.value?.selectedOptions,this.valueChanged(n,t)),super.attributeChangedCallback(e,t,n)}update(e){super.update(e),e.has(`_optionsProp`)&&this._optionsProp.length>0&&(this._options=this._optionsProp,this.requestUpdate(`_options`),!this.value&&this._options.length>0&&(this.value=this._options[0].value,this.selectedIndex=0)),e.has(`value`)&&this.value!==e.get(`value`)&&(this.selectedIndex=this.touched?this.returnNumberOrNull(this.inputRef.value?.selectedIndex):this._options.findIndex(e=>e.value===this.value),this.selectedOptions=this.inputRef.value?.selectedOptions,this.valueChanged(this.value,e.get(`value`))),e.has(`id`)&&!this.name&&this.id&&(this.name=this.id)}firstUpdated(e){super.firstUpdated(e),this._optionsProp.length&&(this._options=this._optionsProp),!this.value&&this._options.length>0?(this.value=this._options[0].value,this.selectedIndex=0):this.selectedIndex=this._options.findIndex(e=>e.value===this.value),this.selectedOptions=this.inputRef.value?.selectedOptions}render(){let i=`pkt-input ${this.fullwidth?`pkt-input--fullwidth`:``}`;return e.d`
|
|
2
2
|
<pkt-input-wrapper
|
|
3
3
|
?counter=${this.counter}
|
|
4
4
|
?disabled=${this.disabled}
|
|
@@ -2,9 +2,9 @@ import { c as e, d as t, o as n, r, s as i } from "./element-cZ85T_aa.js";
|
|
|
2
2
|
import { n as a } from "./element-with-slot-4J2o3SeU.js";
|
|
3
3
|
import { t as o } from "./if-defined-Cjj8qN-Z.js";
|
|
4
4
|
import { n as s, t as c } from "./ref-RS8Uv6uC.js";
|
|
5
|
-
import { t as l } from "./input-element-
|
|
6
|
-
import { t as u } from "./pkt-options-controller-
|
|
7
|
-
import "./input-wrapper-
|
|
5
|
+
import { t as l } from "./input-element-CjebcQd1.js";
|
|
6
|
+
import { t as u } from "./pkt-options-controller-DbLrdRwH.js";
|
|
7
|
+
import "./input-wrapper-DBpMVSxt.js";
|
|
8
8
|
//#region src/base-elements/options-input-element.ts
|
|
9
9
|
var d = class extends l {
|
|
10
10
|
constructor(...e) {
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fileupload.ts
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the fileupload component.
|
|
5
|
+
* Used by both Elements and React implementations.
|
|
6
|
+
*/
|
|
7
|
+
export type TUploadStrategy = 'form' | 'custom';
|
|
8
|
+
export type TFileUploadItemRenderer = 'filename' | 'thumbnail';
|
|
9
|
+
export type TFilesChangedReason = 'add' | 'remove' | 'update';
|
|
10
|
+
export type TFileValidator = (file: File) => string | null;
|
|
11
|
+
export type TTransferProgress = number | 'done' | 'error' | 'canceled' | 'queued';
|
|
12
|
+
/** A selected file plus metadata used by the FileUpload UI. */
|
|
13
|
+
export interface IFileItem {
|
|
14
|
+
fileId: string;
|
|
15
|
+
file?: File;
|
|
16
|
+
attributes: {
|
|
17
|
+
targetFilename: string;
|
|
18
|
+
} & Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/** Transfer status for a file when using `uploadStrategy="custom"`. */
|
|
21
|
+
export interface IFileTransfer {
|
|
22
|
+
fileId: string;
|
|
23
|
+
progress: TTransferProgress;
|
|
24
|
+
errorMessage?: string;
|
|
25
|
+
showProgress?: boolean;
|
|
26
|
+
lastProgress?: number;
|
|
27
|
+
}
|
|
28
|
+
/** Detail payload for the `file-validate` event (Lit) / callback equivalent (React). */
|
|
29
|
+
export interface IFileValidateDetail {
|
|
30
|
+
file: File;
|
|
31
|
+
errorMessage: string | null;
|
|
32
|
+
}
|
|
33
|
+
/** Detail payload for `transfer-cancelled` event / `onTransferCancelled` callback. */
|
|
34
|
+
export interface ITransferCancelledDetail {
|
|
35
|
+
fileId: string;
|
|
36
|
+
file?: File;
|
|
37
|
+
attributes: {
|
|
38
|
+
targetFilename: string;
|
|
39
|
+
} & Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
/** Detail payload for the `files-changed` event. */
|
|
42
|
+
export interface IFilesChangedDetail {
|
|
43
|
+
files: IFileItem[];
|
|
44
|
+
reason: TFilesChangedReason;
|
|
45
|
+
changedFileIds?: string[];
|
|
46
|
+
}
|
|
47
|
+
/** Default Norwegian Bokmål strings used by both implementations. */
|
|
48
|
+
export interface IFileUploadStrings {
|
|
49
|
+
dropZoneDragMultiple: string;
|
|
50
|
+
dropZoneDragSingle: string;
|
|
51
|
+
dropZoneDragMultipleThumbnail: string;
|
|
52
|
+
dropZoneDragSingleThumbnail: string;
|
|
53
|
+
dropZoneDragActiveMultiple: string;
|
|
54
|
+
dropZoneDragActiveSingle: string;
|
|
55
|
+
dropZoneDragActiveMultipleThumbnail: string;
|
|
56
|
+
dropZoneDragActiveSingleThumbnail: string;
|
|
57
|
+
dropZoneOpenFileDialogMultiple: string;
|
|
58
|
+
dropZoneOpenFileDialogSingle: string;
|
|
59
|
+
dropZoneOpenFileDialogMultipleThumbnail: string;
|
|
60
|
+
dropZoneOpenFileDialogSingleThumbnail: string;
|
|
61
|
+
supportedFormatsPrefix: string;
|
|
62
|
+
invalidFormatDefault: (formats: string) => string;
|
|
63
|
+
sizeTooLargeDefault: (maxSize: string) => string;
|
|
64
|
+
requiredMissing: string;
|
|
65
|
+
genericValidationRejection: string;
|
|
66
|
+
unknownFilename: string;
|
|
67
|
+
fileLabel: (count: number) => string;
|
|
68
|
+
srFileAdded: (filename: string) => string;
|
|
69
|
+
srFilesAdded: (count: number) => string;
|
|
70
|
+
srFilesUploadedOfTotal: (uploaded: number, total: number, label: string) => string;
|
|
71
|
+
srFilesFailedOfTotal: (failed: number, total: number, label: string) => string;
|
|
72
|
+
}
|
|
73
|
+
export declare const defaultFileUploadStrings: IFileUploadStrings;
|
|
@@ -15,3 +15,5 @@ export type { ITimepickerStrings } from './timepicker';
|
|
|
15
15
|
export { defaultTimepickerStrings } from './timepicker';
|
|
16
16
|
export type { TProgressbarRole, TProgressbarSkin, TProgressbarStatusPlacement, TProgressbarStatusType, TProgressbarTitlePosition, } from './progressbar';
|
|
17
17
|
export type { IPktComboboxOption, TPktComboboxTagSkin, TPktComboboxDisplayValue, TPktComboboxTagPlacement, } from './combobox';
|
|
18
|
+
export type { TUploadStrategy as TFileUploadStrategy, TFileUploadItemRenderer, TFilesChangedReason, TFileValidator, TTransferProgress, IFileItem, IFileTransfer, IFileValidateDetail, ITransferCancelledDetail, IFilesChangedDetail, IFileUploadStrings, } from './fileupload';
|
|
19
|
+
export { defaultFileUploadStrings } from './fileupload';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IFileItem, IFileTransfer } from '../../shared-types';
|
|
2
|
+
export interface IFileUploadCounts {
|
|
3
|
+
totalCount: number;
|
|
4
|
+
uploadedCount: number;
|
|
5
|
+
failedCount: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Count how many files have reached `done` vs `error` based on the supplied
|
|
9
|
+
* transfer list. Pure — both runtimes share this for their aria-live summaries.
|
|
10
|
+
*/
|
|
11
|
+
export declare function countFileTransferStates(files: IFileItem[], transfers: IFileTransfer[] | undefined): IFileUploadCounts;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** MIME / accept fallback for the thumbnail view (image-only upload mode). */
|
|
2
|
+
export declare const THUMBNAIL_ACCEPT = ".jpeg, .jpg, .png, .gif, .webp, .heic";
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the display name for a file item, preferring the (possibly renamed)
|
|
5
|
+
* `attributes.targetFilename`, falling back to the underlying File, and finally
|
|
6
|
+
* a localized "unknown file" label.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getDisplayFilename(item: {
|
|
9
|
+
file?: File | null;
|
|
10
|
+
attributes?: {
|
|
11
|
+
targetFilename?: string;
|
|
12
|
+
};
|
|
13
|
+
}, fallback?: string): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a list of focusable elements inside a container (same selector used by
|
|
3
|
+
* Lit and React fileupload preview modals). Hidden elements are filtered out.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getFocusableElements(container: HTMLElement | null | undefined): HTMLElement[];
|
|
6
|
+
/**
|
|
7
|
+
* Keyboard handler that wraps Tab / Shift-Tab focus around the first and last
|
|
8
|
+
* focusable elements inside a container. Returns `true` if the event was handled.
|
|
9
|
+
*
|
|
10
|
+
* Call from a `keydown` listener on the modal root.
|
|
11
|
+
*/
|
|
12
|
+
export declare function trapTabInside(event: KeyboardEvent, container: HTMLElement | null | undefined): boolean;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize an `allowedFormats` value (array or undefined) to lowercase, trimmed, non-empty tokens.
|
|
3
|
+
*/
|
|
4
|
+
export declare function normalizeAllowedFormats(formats: string[] | undefined | null): string[];
|
|
5
|
+
/**
|
|
6
|
+
* Parse a native `accept` attribute value (comma-separated) into normalized tokens.
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseAcceptTokens(accept: string | undefined | null): string[];
|
|
9
|
+
/**
|
|
10
|
+
* Return `true` when a file matches one of the normalized allowed-format tokens.
|
|
11
|
+
* Supports plain extensions (`'pdf'`, `'.pdf'`), exact MIME types (`'application/pdf'`),
|
|
12
|
+
* and wildcards (`'image/*'`).
|
|
13
|
+
*/
|
|
14
|
+
export declare function matchesAllowedFormat(token: string, fileExtension: string, fileMimeType: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Check whether a `File` matches any of the allowed formats.
|
|
17
|
+
* An empty list is treated as "accept everything".
|
|
18
|
+
*/
|
|
19
|
+
export declare function isFileAllowed(file: File, allowedFormats: string[]): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Build a `accept=""` string from allowed formats, falling back to an explicit accept when provided.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveAcceptAttribute(explicitAccept: string | undefined, allowedFormats: string[] | undefined): string;
|
|
24
|
+
/** Human-readable token for the "Format: …" help line. */
|
|
25
|
+
export declare function formatTokenForDisplay(token: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Produce the "Format: PDF, JPG, …" list used under the drop zone.
|
|
28
|
+
* Falls back to `accept` tokens when `allowedFormats` is empty.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getSupportedFormatsText(allowedFormats: string[] | undefined, accept: string | undefined): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared fileupload utilities for use by both Elements and React packages.
|
|
3
|
+
*/
|
|
4
|
+
export { parseFileSize, formatFileSize } from './size';
|
|
5
|
+
export { normalizeAllowedFormats, parseAcceptTokens, matchesAllowedFormat, isFileAllowed, resolveAcceptAttribute, formatTokenForDisplay, getSupportedFormatsText, } from './formats';
|
|
6
|
+
export { validateFile, applyErrorTemplate, isImageFileLike } from './validation';
|
|
7
|
+
export type { IValidateFileOptions } from './validation';
|
|
8
|
+
export { getProgressState, mergeFilesAndTransfers } from './transfers';
|
|
9
|
+
export type { IFileAndTransfer, TProgressState } from './transfers';
|
|
10
|
+
export { getFocusableElements, trapTabInside } from './focus-trap';
|
|
11
|
+
export { splitFilenameForTruncation } from './truncate';
|
|
12
|
+
export { navigateCyclic } from './navigation';
|
|
13
|
+
export { countFileTransferStates } from './announcements';
|
|
14
|
+
export type { IFileUploadCounts } from './announcements';
|
|
15
|
+
export { getDisplayFilename, THUMBNAIL_ACCEPT } from './filename';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a file-size string like `"5MB"`, `"500KB"`, `"1GB"`, or a raw byte number.
|
|
3
|
+
* Returns `undefined` for invalid input and logs a warning.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* parseFileSize('5MB') // 5_242_880
|
|
7
|
+
* parseFileSize('500KB') // 512_000
|
|
8
|
+
* parseFileSize(1024) // 1024
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseFileSize(size: string | number | undefined | null): number | undefined;
|
|
11
|
+
/** Format bytes to a compact human-readable string (e.g. `"500 KB"`, `"5 MB"`). */
|
|
12
|
+
export declare function formatFileSize(bytes: number): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IFileItem, IFileTransfer, TFileUploadStrategy, TTransferProgress } from '../../shared-types';
|
|
2
|
+
export type TProgressState = 'in-progress' | 'error' | 'idle';
|
|
3
|
+
/** Bucket a raw progress value into a sort-priority class. */
|
|
4
|
+
export declare function getProgressState(progress: TTransferProgress): TProgressState;
|
|
5
|
+
export interface IFileAndTransfer extends IFileItem {
|
|
6
|
+
progress: TTransferProgress;
|
|
7
|
+
errorMessage?: string;
|
|
8
|
+
showProgress?: boolean;
|
|
9
|
+
lastProgress?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Merge a `FileItem[]` list with a `TFileTransfer[]` list and sort by priority
|
|
13
|
+
* (in-progress first, then errors, then done/queued).
|
|
14
|
+
*
|
|
15
|
+
* Used by both Lit (`getFilesAndTransfers`) and React (`useFilesAndTransfers`).
|
|
16
|
+
*/
|
|
17
|
+
export declare function mergeFilesAndTransfers(files: IFileItem[], transfers: IFileTransfer[] | undefined, uploadStrategy: TFileUploadStrategy): IFileAndTransfer[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decide how to split a filename for middle-truncation (head + fixed-length tail,
|
|
3
|
+
* so the extension stays visible).
|
|
4
|
+
*
|
|
5
|
+
* Returns `null` when no split should happen — either the caller didn't ask for
|
|
6
|
+
* a tail, or the filename is so short that splitting would produce visual noise
|
|
7
|
+
* (we use a threshold of `tail + 3` characters, same as the React Truncate
|
|
8
|
+
* component has used since it was introduced).
|
|
9
|
+
*/
|
|
10
|
+
export declare function splitFilenameForTruncation(filename: string, tail: number | undefined): {
|
|
11
|
+
head: string;
|
|
12
|
+
tail: string;
|
|
13
|
+
} | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TFileValidator } from '../../shared-types';
|
|
2
|
+
export interface IValidateFileOptions {
|
|
3
|
+
allowedFormats?: string[];
|
|
4
|
+
maxFileSize?: string | number;
|
|
5
|
+
formatErrorMessage?: string;
|
|
6
|
+
sizeErrorMessage?: string;
|
|
7
|
+
onFileValidation?: TFileValidator;
|
|
8
|
+
}
|
|
9
|
+
/** Apply `{formats}` / `{maxSize}` placeholders to a user-supplied message, falling back to the default. */
|
|
10
|
+
export declare function applyErrorTemplate(template: string | undefined | null, fallback: string, placeholders: Record<string, string>): string;
|
|
11
|
+
/**
|
|
12
|
+
* Run the shared validation pipeline (format → size → user callback).
|
|
13
|
+
* Returns the first error string, or `null` if the file is accepted.
|
|
14
|
+
*
|
|
15
|
+
* The `onFileValidation` callback is called last and can veto an otherwise-valid file.
|
|
16
|
+
*/
|
|
17
|
+
export declare function validateFile(file: File, options: IValidateFileOptions): string | null;
|
|
18
|
+
/** Detect whether a file (or an item with `.file` and `.attributes.targetFilename`) is an image. */
|
|
19
|
+
export declare function isImageFileLike(input: {
|
|
20
|
+
file?: File | null;
|
|
21
|
+
attributes?: {
|
|
22
|
+
targetFilename?: string;
|
|
23
|
+
};
|
|
24
|
+
}): boolean;
|
|
@@ -9,6 +9,7 @@ import { PktCalendar } from '../components/calendar/calendar';
|
|
|
9
9
|
import { PktCheckbox } from '../components/checkbox/checkbox';
|
|
10
10
|
import { PktCombobox } from '../components/combobox/combobox';
|
|
11
11
|
import { PktConsent } from '../components/consent/consent';
|
|
12
|
+
import { PktFileUpload } from '../components/fileupload/fileupload';
|
|
12
13
|
import { PktDatepicker } from '../components/datepicker/datepicker';
|
|
13
14
|
import { PktHeading } from '../components/heading/heading';
|
|
14
15
|
import { PktHelptext } from '../components/helptext/helptext';
|
|
@@ -40,6 +41,7 @@ export declare const customElementComponentRegistry: {
|
|
|
40
41
|
readonly 'pkt-checkbox': typeof PktCheckbox;
|
|
41
42
|
readonly 'pkt-combobox': typeof PktCombobox;
|
|
42
43
|
readonly 'pkt-consent': typeof PktConsent;
|
|
44
|
+
readonly 'pkt-fileupload': typeof PktFileUpload;
|
|
43
45
|
readonly 'pkt-datepicker': typeof PktDatepicker;
|
|
44
46
|
readonly 'pkt-header-service': typeof PktHeaderService;
|
|
45
47
|
readonly 'pkt-heading': typeof PktHeading;
|
|
@@ -6,8 +6,8 @@ import { n as p } from "./element-with-slot-4J2o3SeU.js";
|
|
|
6
6
|
import "./icon-Co72KtgF.js";
|
|
7
7
|
import { t as m } from "./if-defined-Cjj8qN-Z.js";
|
|
8
8
|
import { n as h, t as g } from "./ref-RS8Uv6uC.js";
|
|
9
|
-
import { t as _ } from "./input-element-
|
|
10
|
-
import "./input-wrapper-
|
|
9
|
+
import { t as _ } from "./input-element-CjebcQd1.js";
|
|
10
|
+
import "./input-wrapper-DBpMVSxt.js";
|
|
11
11
|
//#region ../../node_modules/lit-html/directives/live.js
|
|
12
12
|
var v = l(class extends s {
|
|
13
13
|
constructor(e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./directive-CJ2giQBZ.cjs`),n=require(`./class-map-CJ-msbHs.cjs`),r=require(`./directive-helpers-D1QSxY17.cjs`),i=require(`./element-with-slot-CWoTGA1B.cjs`);require(`./icon-Dr8sfT2X.cjs`);const a=require(`./if-defined-XKOD_t_V.cjs`),o=require(`./ref-BaJ0mBT_.cjs`),s=require(`./input-element-
|
|
1
|
+
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./directive-CJ2giQBZ.cjs`),n=require(`./class-map-CJ-msbHs.cjs`),r=require(`./directive-helpers-D1QSxY17.cjs`),i=require(`./element-with-slot-CWoTGA1B.cjs`);require(`./icon-Dr8sfT2X.cjs`);const a=require(`./if-defined-XKOD_t_V.cjs`),o=require(`./ref-BaJ0mBT_.cjs`),s=require(`./input-element-FGcr5hGd.cjs`);require(`./input-wrapper-B_XFi211.cjs`);var c=t.t(class extends t.n{constructor(e){if(super(e),e.type!==t.r.PROPERTY&&e.type!==t.r.ATTRIBUTE&&e.type!==t.r.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!r.i(e))throw Error("`live` bindings can only contain a single expression")}render(e){return e}update(n,[i]){if(i===e.u||i===e.l)return i;let a=n.element,o=n.name;if(n.type===t.r.PROPERTY){if(i===a[o])return e.u}else if(n.type===t.r.BOOLEAN_ATTRIBUTE){if(!!i===a.hasAttribute(o))return e.u}else if(n.type===t.r.ATTRIBUTE&&a.getAttribute(o)===i+``)return e.u;return r.r(n),i}}),l=class extends s.t{constructor(...e){super(...e),this.inputRef=o.t(),this.value=``,this.autocomplete=`off`,this.rows=null,this.counterCurrent=0}attributeChangedCallback(e,t,n){e===`value`&&this.value!==t&&(this.counterCurrent=n?n.length:0,this.valueChanged(n,t)),super.attributeChangedCallback(e,t,n)}updated(e){super.updated(e),e.has(`value`)&&(this.counterCurrent=this.value?.length||0,this.valueChanged(this.value,e.get(`value`))),e.has(`id`)&&!this.name&&this.id&&(this.name=this.id)}render(){let t=n.t({"pkt-input":!0,"pkt-input--fullwidth":this.fullwidth,"pkt-input--counter-error":this.counter&&this.counterMaxLength&&this.value.length&&this.value.length>this.counterMaxLength}),r=this.ariaLabelledby||`${this.id}-input-label`;return e.d`<pkt-input-wrapper
|
|
2
2
|
label=${this.label}
|
|
3
3
|
?counter=${this.counter}
|
|
4
4
|
?disabled=${this.disabled}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`),n=require(`./element-with-slot-CWoTGA1B.cjs`);require(`./icon-Dr8sfT2X.cjs`);const r=require(`./if-defined-XKOD_t_V.cjs`),i=require(`./ref-BaJ0mBT_.cjs`),a=require(`./input-element-
|
|
1
|
+
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`),n=require(`./element-with-slot-CWoTGA1B.cjs`);require(`./icon-Dr8sfT2X.cjs`);const r=require(`./if-defined-XKOD_t_V.cjs`),i=require(`./ref-BaJ0mBT_.cjs`),a=require(`./input-element-FGcr5hGd.cjs`);require(`./input-wrapper-B_XFi211.cjs`);var o=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,this.valueChanged(n,t)),super.attributeChangedCallback(e,t,n)}updated(e){super.updated(e),e.has(`value`)&&(this.counterCurrent=this.value?.length||0,this.valueChanged(this.value,e.get(`value`))),e.has(`id`)&&!this.name&&this.id&&(this.name=this.id)}render(){let a=this.type===`search`&&!this.iconNameRight&&!this.omitSearchIcon,o=t.t({"pkt-input":!0,"pkt-input--fullwidth":this.fullwidth,"pkt-input--counter-error":this.counter&&this.counterMaxLength&&this.value.length&&this.value.length>this.counterMaxLength}),s=this.ariaLabelledby||`${this.id}-input-label`;return e.d`
|
|
2
2
|
<pkt-input-wrapper
|
|
3
3
|
label="${this.label}"
|
|
4
4
|
?counter=${this.counter}
|
|
@@ -4,8 +4,8 @@ import { n as s } from "./element-with-slot-4J2o3SeU.js";
|
|
|
4
4
|
import "./icon-Co72KtgF.js";
|
|
5
5
|
import { t as c } from "./if-defined-Cjj8qN-Z.js";
|
|
6
6
|
import { n as l, t as u } from "./ref-RS8Uv6uC.js";
|
|
7
|
-
import { t as d } from "./input-element-
|
|
8
|
-
import "./input-wrapper-
|
|
7
|
+
import { t as d } from "./input-element-CjebcQd1.js";
|
|
8
|
+
import "./input-wrapper-DBpMVSxt.js";
|
|
9
9
|
//#region src/components/textinput/textinput.ts
|
|
10
10
|
var f = class extends d {
|
|
11
11
|
constructor(...e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`),n=require(`./element-with-slot-CWoTGA1B.cjs`);require(`./icon-Dr8sfT2X.cjs`);const r=require(`./if-defined-XKOD_t_V.cjs`),i=require(`./ref-BaJ0mBT_.cjs`),a=require(`./input-element-B1yxcfz4.cjs`);require(`./input-wrapper-CzS4rUrK.cjs`);var o=e=>/^\d{2}:\d{2}$/.test(e)&&parseInt(e.slice(0,2),10)<=23&&parseInt(e.slice(3),10)<=59,s=e=>{let[t,n]=e.split(`:`).map(Number);return t*60+n},c=e=>e?Math.max(1,Math.round(e/60)):1,l=(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)},u=e=>{let t=c(e);return Array.from({length:Math.floor(60/t)},(e,n)=>n*t)},d=(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`)}},f=class extends a.t{constructor(...e){super(...e),this.hiddenInputRef=i.t(),this.hoursInputRef=i.t(),this.minutesInputRef=i.t(),this.buttonRef=i.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();break}}}get inputRef(){return this.hiddenInputRef}manageValidity(t){let n=this.hoursInputRef.value;if(!n)return;if(this.required&&!this.value){this.internals.setValidity({valueMissing:!0},e.i.forms.messages.required,n),this._setAriaInvalid(!0);return}if(!this.value){this.internals.setValidity({}),this._setAriaInvalid(!1);return}let r=s(this.value),i=c(this.step);if(this.min&&r<s(String(this.min))){this.internals.setValidity({rangeUnderflow:!0},e.i.forms.messages.rangeUnderflowMin.replace(`{min}`,String(this.min)),n),this._setAriaInvalid(!0);return}if(this.max&&r>s(String(this.max))){this.internals.setValidity({rangeOverflow:!0},e.i.forms.messages.rangeOverflowMax.replace(`{max}`,String(this.max)),n),this._setAriaInvalid(!0);return}if(this.step&&r%i!==0){let t=i===60?e.i.forms.messages.timeStepMismatchHour:i===30?e.i.forms.messages.timeStepMismatchHalfHour:e.i.forms.messages.timeStepMismatch.replace(`{step}`,`${i}, ${i*2}, ${i*3}`);this.internals.setValidity({stepMismatch:!0},t,n),this._setAriaInvalid(!0);return}this.internals.setValidity({}),this._setAriaInvalid(!1)}_setAriaInvalid(e){if(!this.touched&&e)return;let t=this.hoursInputRef.value,n=this.minutesInputRef.value;e?(t?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-invalid`,`true`)):(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.toggle(`pkt-timepicker--stepper`,this.stepArrows),this.classList.toggle(`pkt-timepicker--fullwidth`,this.fullwidth),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=o(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 c(this.step)}get _hourOptions(){return l(this.min,this.max)}get _minuteOptions(){return u(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=d(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.d`
|
|
1
|
+
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`),n=require(`./element-with-slot-CWoTGA1B.cjs`);require(`./icon-Dr8sfT2X.cjs`);const r=require(`./if-defined-XKOD_t_V.cjs`),i=require(`./ref-BaJ0mBT_.cjs`),a=require(`./input-element-FGcr5hGd.cjs`);require(`./input-wrapper-B_XFi211.cjs`);var o=e=>/^\d{2}:\d{2}$/.test(e)&&parseInt(e.slice(0,2),10)<=23&&parseInt(e.slice(3),10)<=59,s=e=>{let[t,n]=e.split(`:`).map(Number);return t*60+n},c=e=>e?Math.max(1,Math.round(e/60)):1,l=(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)},u=e=>{let t=c(e);return Array.from({length:Math.floor(60/t)},(e,n)=>n*t)},d=(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`)}},f=class extends a.t{constructor(...e){super(...e),this.hiddenInputRef=i.t(),this.hoursInputRef=i.t(),this.minutesInputRef=i.t(),this.buttonRef=i.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();break}}}get inputRef(){return this.hiddenInputRef}manageValidity(t){let n=this.hoursInputRef.value;if(!n)return;if(this.required&&!this.value){this.internals.setValidity({valueMissing:!0},e.i.forms.messages.required,n),this._setAriaInvalid(!0);return}if(!this.value){this.internals.setValidity({}),this._setAriaInvalid(!1);return}let r=s(this.value),i=c(this.step);if(this.min&&r<s(String(this.min))){this.internals.setValidity({rangeUnderflow:!0},e.i.forms.messages.rangeUnderflowMin.replace(`{min}`,String(this.min)),n),this._setAriaInvalid(!0);return}if(this.max&&r>s(String(this.max))){this.internals.setValidity({rangeOverflow:!0},e.i.forms.messages.rangeOverflowMax.replace(`{max}`,String(this.max)),n),this._setAriaInvalid(!0);return}if(this.step&&r%i!==0){let t=i===60?e.i.forms.messages.timeStepMismatchHour:i===30?e.i.forms.messages.timeStepMismatchHalfHour:e.i.forms.messages.timeStepMismatch.replace(`{step}`,`${i}, ${i*2}, ${i*3}`);this.internals.setValidity({stepMismatch:!0},t,n),this._setAriaInvalid(!0);return}this.internals.setValidity({}),this._setAriaInvalid(!1)}_setAriaInvalid(e){if(!this.touched&&e)return;let t=this.hoursInputRef.value,n=this.minutesInputRef.value;e?(t?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-invalid`,`true`)):(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.toggle(`pkt-timepicker--stepper`,this.stepArrows),this.classList.toggle(`pkt-timepicker--fullwidth`,this.fullwidth),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=o(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 c(this.step)}get _hourOptions(){return l(this.min,this.max)}get _minuteOptions(){return u(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=d(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.d`
|
|
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"
|
|
@@ -4,8 +4,8 @@ import { n as c } from "./element-with-slot-4J2o3SeU.js";
|
|
|
4
4
|
import "./icon-Co72KtgF.js";
|
|
5
5
|
import { t as l } from "./if-defined-Cjj8qN-Z.js";
|
|
6
6
|
import { n as u, t as d } from "./ref-RS8Uv6uC.js";
|
|
7
|
-
import { t as f } from "./input-element-
|
|
8
|
-
import "./input-wrapper-
|
|
7
|
+
import { t as f } from "./input-element-CjebcQd1.js";
|
|
8
|
+
import "./input-wrapper-DBpMVSxt.js";
|
|
9
9
|
//#region ../../shared-utils/timepicker/time-utils.ts
|
|
10
10
|
var p = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && parseInt(e.slice(3), 10) <= 59, m = (e) => {
|
|
11
11
|
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": "16.
|
|
3
|
+
"version": "16.15.0",
|
|
4
4
|
"description": "Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo Origo",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
79
79
|
},
|
|
80
80
|
"license": "MIT",
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "5147b31531bab9ff64963a1f091a717bb93d35cf"
|
|
82
82
|
}
|