@oslokommune/punkt-elements 19.18.5 → 19.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/dist/components/textinput/index.d.ts +1 -0
- package/dist/components/textinput/textinput.d.ts +22 -1
- package/dist/{fileupload-D7nEdIgL.js → fileupload-CEwnpxZj.js} +1 -1
- package/dist/{fileupload-BLAQqG3-.cjs → fileupload-M66Pd-QJ.cjs} +1 -1
- package/dist/{header-Cptdf4fW.js → header-BYNzxXCo.js} +1 -1
- package/dist/{header-Cj08flhl.cjs → header-BqheRQpR.cjs} +1 -1
- package/dist/{modal-Dt35SMQH.js → modal-BafCTC4M.js} +1 -0
- package/dist/modal-C5AiVm5g.cjs +37 -0
- package/dist/pkt-fileupload.cjs +1 -1
- package/dist/pkt-fileupload.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +18 -18
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/shared-types/index.d.ts +2 -0
- package/dist/shared-types/table.d.ts +3 -2
- package/dist/shared-types/textinput.d.ts +82 -0
- package/dist/{textinput-75MKBqas.cjs → textinput-C5KWIB21.cjs} +2 -2
- package/dist/{textinput-D_V3b327.js → textinput-CRlErItw.js} +22 -7
- package/package.json +3 -3
- package/src/components/textinput/index.ts +1 -0
- package/src/components/textinput/textinput.test.ts +1 -1
- package/src/components/textinput/textinput.ts +46 -4
- package/dist/modal-DyaAoMeB.cjs +0 -37
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,11 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
## [19.20.0](https://github.com/oslokommune/punkt/compare/19.19.0...19.20.0) (2026-11-03)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
|
|
8
13
|
## [19.19.0](https://github.com/oslokommune/punkt/compare/19.18.4...19.19.0) (2026-10-22)
|
|
9
14
|
|
|
10
15
|
---
|
|
@@ -2,8 +2,29 @@ import { PropertyValues } from 'lit';
|
|
|
2
2
|
import { Ref } from 'lit/directives/ref.js';
|
|
3
3
|
import { ElementProps } from '../../types/typeUtils';
|
|
4
4
|
import { PktInputElement } from '../../base-elements/input-element';
|
|
5
|
+
import { Booleanish, IPktTextinputBase } from '../../shared-types';
|
|
5
6
|
type Props = ElementProps<PktTextinput, 'value' | 'type' | 'size' | 'autocomplete' | 'iconNameRight' | 'prefix' | 'suffix' | 'omitSearchIcon'>;
|
|
6
|
-
export
|
|
7
|
+
export interface IPktTextinput extends Omit<IPktTextinputBase, 'form' | 'label' | 'placeholder' | 'size' | 'prefix' | 'suffix' | 'iconNameRight' | 'min' | 'max' | 'minLength' | 'maxLength' | 'step' | 'readOnly' | 'autoComplete' | 'ariaDescribedby' | 'ariaLabelledby' | 'helptextDropdownButton' | 'useWrapper'> {
|
|
8
|
+
label?: string | null;
|
|
9
|
+
placeholder?: string | null;
|
|
10
|
+
size?: number | null;
|
|
11
|
+
prefix?: string | null;
|
|
12
|
+
suffix?: string | null;
|
|
13
|
+
iconNameRight?: string | null;
|
|
14
|
+
min?: string | number | null;
|
|
15
|
+
max?: string | number | null;
|
|
16
|
+
minlength?: number | null;
|
|
17
|
+
maxlength?: number | null;
|
|
18
|
+
step?: number | null;
|
|
19
|
+
readonly?: boolean;
|
|
20
|
+
autocomplete?: string | null;
|
|
21
|
+
ariaDescribedby?: string | null;
|
|
22
|
+
ariaLabelledby?: string | null;
|
|
23
|
+
/** @deprecated Bruk `strings={{ forms: { readMore: '…' } }}` eller `setPktStrings()`. */
|
|
24
|
+
helptextDropdownButton?: string | null;
|
|
25
|
+
useWrapper?: Booleanish;
|
|
26
|
+
}
|
|
27
|
+
export declare class PktTextinput extends PktInputElement<Props> implements IPktTextinput {
|
|
7
28
|
inputRef: Ref<HTMLTextAreaElement>;
|
|
8
29
|
value: string;
|
|
9
30
|
type: string;
|
|
@@ -8,7 +8,7 @@ import { t as u } from "./if-defined-D18nY_K_.js";
|
|
|
8
8
|
import { t as d } from "./converters-CYgQrWVm.js";
|
|
9
9
|
import { n as f } from "./utils-BwF4QSrq.js";
|
|
10
10
|
import { r as p } from "./focus-trap-DG3pEuyJ.js";
|
|
11
|
-
import "./modal-
|
|
11
|
+
import "./modal-BafCTC4M.js";
|
|
12
12
|
import "./progressbar-BukfOcRk.js";
|
|
13
13
|
//#region ../../shared-utils/fileupload/size.ts
|
|
14
14
|
function m(e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./format-B8meU8Tm.cjs");require("./alert-Dy5N7qK-.cjs"),require("./icon-CrG6o7ZE.cjs"),require("./input-wrapper-QzdntWJX.cjs");const r=require("./if-defined-CiML3MTM.cjs"),i=require("./converters-CW6SN0TT.cjs"),a=require("./utils-63cRpWut.cjs"),o=require("./focus-trap-DSv4Ifqm.cjs");require("./modal-DyaAoMeB.cjs"),require("./progressbar-YfHSPmqI.cjs");function s(e){if(e==null||e===``)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=String(e).trim(),n=Number(t);if(!Number.isNaN(n)&&n>0)return n;let r=t.match(/^(\d+(?:\.\d+)?)\s*(B|KB|MB|GB)$/i);if(!r){console.warn(`PktFileUpload: Invalid maxFileSize format "${t}". Use format like "5MB", "500KB", "1GB", or bytes.`);return}let i=parseFloat(r[1]);switch(r[2].toUpperCase()){case`B`:return i;case`KB`:return i*1024;case`MB`:return i*1024*1024;case`GB`:return i*1024*1024*1024;default:return}}function c(e){return e<1024?`${Math.round(e)} B`:e<1048576?`${Math.round(e/1024)} KB`:e<1073741824?`${Math.round(e/1048576)} MB`:`${Math.round(e/1073741824)} GB`}function l(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function u(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function d(e,t,n){let r=e.toLowerCase().replace(/^\./,``);if(r.includes(`/`)){if(r.endsWith(`/*`)){let e=r.replace(`/*`,``);return n.startsWith(`${e}/`)}return n===r}return t===r}function f(e,t){let n=l(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>d(e,r,i))}function p(e,t){let n=(e??``).trim();if(n)return n;let r=l(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function m(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function h(e,t){let n=l(e);if(n.length>0)return n.map(m).join(`, `);let r=u(t);return r.length>0?r.map(m).join(`, `):``}function g(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function _(t,n){let r=l(n.allowedFormats);if(r.length>0&&!f(t,r)){let t=r.join(`, `),i=e.s.fileupload.invalidFormat;return g(n.formatErrorMessage,i,{formats:t})}let i=s(n.maxFileSize);if(i!==void 0&&t.size>i){let t=c(i),r=e.s.fileupload.sizeTooLarge;return g(n.sizeErrorMessage,r,{maxSize:t})}if(n.onFileValidation){let e=n.onFileValidation(t);if(e)return e}return null}function v(e){let t=e.file;if(t?.type?.startsWith(`image/`))return!0;let n=e.attributes?.targetFilename||t?.name||``;return/\.(jpe?g|png|gif|webp|heic|heif|bmp|svg)$/i.test(n)}function y(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function b(e,t,n){let r={"in-progress":0,error:1,idle:2};return e.map(e=>{let r=t?.find(t=>t.fileId===e.fileId);return{...e,progress:r?.progress??(n===`form`?`done`:`queued`),errorMessage:r?.errorMessage,showProgress:r?.showProgress,lastProgress:r?.lastProgress}}).sort((e,t)=>r[y(e.progress)]-r[y(t.progress)])}function x(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function S(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function C(e,t){let n=e.length;if(n===0||!t||t.length===0)return{totalCount:n,uploadedCount:0,failedCount:0};let r=0,i=0;for(let n of e){let e=t.find(e=>e.fileId===n.fileId);e?.progress===`done`?r++:e?.progress===`error`&&i++}return{totalCount:n,uploadedCount:r,failedCount:i}}function w(t,n=e.s.fileupload.unknownFilename){return t.attributes?.targetFilename||t.file?.name||n}var T=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${a.n()}`,this.name=`files`,this.label=``,this.helptext=``,this.helptextDropdown=``,this.required=!1,this.multiple=!1,this.disabled=!1,this.fullwidth=!1,this.uploadStrategy=`form`,this.itemRenderer=`filename`,this.accept=``,this.allowedFormats=[],this.formatErrorMessage=``,this.sizeErrorMessage=``,this.transfers=[],this.addCommentsEnabled=!1,this.renameFilesEnabled=!1,this.extraOperations=[],this.enableImagePreview=!1,this.hasError=!1,this.errorMessage=``,this.optionalTag=!1,this.requiredTag=!1,this.tagText=null,this.truncateTail=4,this.files=[],this.isDragActive=!1,this.validationErrorMessage=null,this.addedAnnouncement=``,this.thumbnailUrls={},this.hasInitializedValue=!1,this.hasWarnedInvalidValueCombo=!1,this.thumbnailFileById=new Map,this.connectedForm=null,this.addedAnnouncementTimer=null,this.onNativeFileChange=e=>{let t=e.target;this.addFiles(t.files?Array.from(t.files):[]),this.uploadStrategy===`custom`&&(t.value=``)},this.openFileDialog=e=>{e.preventDefault(),e.stopPropagation(),!this.disabled&&this.querySelector(`#${this.id}-input`)?.click()},this.onDropZoneClick=e=>{this.disabled||e.target.closest(`.pkt-fileupload__drop-zone__placeholder__title__open-file-dialog`)||this.querySelector(`#${this.id}-input`)?.click()},this.onDragOver=e=>{e.preventDefault(),!this.disabled&&(this.isDragActive=!0)},this.onDragLeave=()=>{this.isDragActive=!1},this.onDrop=e=>{if(e.preventDefault(),this.isDragActive=!1,this.disabled)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this.addFiles(t)},this.onHostFormSubmit=e=>{this.required&&this.uploadStrategy===`custom`&&(this.getCurrentFiles().length>0||(this.validationErrorMessage=this.requiredSelectionMessage,e.preventDefault()))}}get requiredSelectionMessage(){return this.pktStrings.get(`fileupload`).requiredMissing}get isControlled(){return this.value!==void 0}get hasEffectiveError(){return!!this.validationErrorMessage||this.hasError||!!this.errorMessage.trim()}get effectiveErrorMessage(){return this.validationErrorMessage??this.errorMessage??``}get hasValidationError(){return!!this.validationErrorMessage}firstUpdated(e){super.firstUpdated?.(e),this.value!==void 0&&this.defaultValue!==void 0&&this.warnInvalidValueCombo()}willUpdate(e){super.willUpdate(e),this.hasInitializedValue?this.isControlled&&(e.has(`value`)||e.has(`itemRenderer`)||e.has(`enableImagePreview`))&&(this.files=this.value??[],this.syncThumbnailUrls(this.files)):(this.files=this.value??this.defaultValue??[],this.syncThumbnailUrls(this.files),this.hasInitializedValue=!0)}updated(e){super.updated(e),(e.has(`uploadStrategy`)||e.has(`required`)||e.has(`value`)||e.has(`form`))&&this.syncFormSubmitListener(),this.uploadStrategy===`form`&&(e.has(`value`)||e.has(`files`)||e.has(`uploadStrategy`))&&this.syncNativeInputFiles()}syncNativeInputFiles(){let e=this.querySelector(`#${this.id}-input`);if(e&&typeof DataTransfer<`u`)try{let t=new DataTransfer;for(let e of this.getCurrentFiles())e.file&&t.items.add(e.file);e.files=t.files}catch{}}warnInvalidValueCombo(){this.hasWarnedInvalidValueCombo||=(console.warn(`PktFileUpload: Både value og defaultValue er angitt. Komponenten kan være enten kontrollert eller ukontrollert, ikke begge. value vil bli prioritert.`),!0)}disconnectedCallback(){this.teardownFormSubmitListener(),this.addedAnnouncementTimer&&=(clearTimeout(this.addedAnnouncementTimer),null),super.disconnectedCallback(),this.revokeAllThumbnailUrls()}setAddedAnnouncement(e){this.addedAnnouncement=e,this.addedAnnouncementTimer&&clearTimeout(this.addedAnnouncementTimer),this.addedAnnouncementTimer=setTimeout(()=>{this.addedAnnouncement=``,this.addedAnnouncementTimer=null},1500)}connectedCallback(){super.connectedCallback(),this.syncFormSubmitListener()}addFiles(e){if(e.length===0)return;let t=this.multiple?e:[e[0]];for(let e of t){let t=this.validateFile(e);if(t){this.validationErrorMessage=t;return}}this.validationErrorMessage=null;let r=t.map(e=>({fileId:a.n(),file:e,attributes:{targetFilename:e.name}})),i=this.pktStrings.get(`fileupload`);this.setAddedAnnouncement(r.length===1?n.t(i.srFileAdded,{filename:r[0].attributes.targetFilename}):n.t(i.srFilesAdded,{count:r.length}));let o=this.getCurrentFiles(),s=this.multiple?[...o,...r]:[r[0]];this.commitFiles(s,`add`,r.map(e=>e.fileId)),this.uploadStrategy===`custom`&&r.forEach(e=>{this.dispatchEvent(new CustomEvent(`file-upload-requested`,{detail:{fileId:e.fileId,file:e.file,attributes:e.attributes},bubbles:!0,composed:!0}))})}getCurrentFiles(){return this.isControlled?this.value??[]:this.files}cancelTransfer(e){if(this.disabled)return;let t=this.getCurrentFiles().find(t=>t.fileId===e);t&&(this.removeFileItem(e),this.dispatchEvent(new CustomEvent(`transfer-cancelled`,{detail:{fileId:t.fileId,file:t.file,attributes:t.attributes},bubbles:!0,composed:!0})))}removeFileItem(e){if(this.disabled)return;let t=this.getCurrentFiles(),n=t.filter(t=>t.fileId!==e);n.length!==t.length&&this.commitFiles(n,`remove`,[e])}updateFileItem(e,t){let n=this.getCurrentFiles().map(n=>n.fileId===e?{...n,...t}:n);this.commitFiles(n,`update`,[e])}commitFiles(e,t,n){this.isControlled||(this.files=e,this.syncThumbnailUrls(e)),this.validationErrorMessage===this.requiredSelectionMessage&&e.length>0&&(this.validationErrorMessage=null),this.dispatchEvent(new CustomEvent(`files-changed`,{detail:{files:e,reason:t,changedFileIds:n},bubbles:!0,composed:!0}))}getThumbnailUrl(e){return this.thumbnailUrls[e.fileId]}getTransferProgress(e){let t=this.transfers.find(t=>t.fileId===e);return t?t.progress:this.uploadStrategy===`form`?`done`:`queued`}getTransferForFile(e){return this.transfers.find(t=>t.fileId===e)}isImageFile(e){return v(e)}formatFileSize(e){return c(e)}getResolvedAcceptValue(){return p(this.accept,this.allowedFormats)}getSupportedFormatsText(){return h(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return b(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=_(e,{allowedFormats:this.allowedFormats,maxFileSize:this.maxFileSize,formatErrorMessage:this.formatErrorMessage,sizeErrorMessage:this.sizeErrorMessage,onFileValidation:this.onFileValidation});if(t)return t;let n={file:e,errorMessage:null},r=new CustomEvent(`file-validate`,{detail:n,bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(r),n.errorMessage?n.errorMessage:r.defaultPrevented?this.pktStrings.get(`fileupload`).genericValidationRejection:null}syncThumbnailUrls(e){if(typeof URL>`u`||typeof URL.createObjectURL!=`function`||typeof URL.revokeObjectURL!=`function`){this.thumbnailUrls={},this.thumbnailFileById.clear();return}let t=new Set(e.map(e=>e.fileId)),n={};for(let[e,n]of Object.entries(this.thumbnailUrls))t.has(e)||(URL.revokeObjectURL(n),this.thumbnailFileById.delete(e));for(let t of e){let e=this.thumbnailUrls[t.fileId],r=this.thumbnailFileById.get(t.fileId);if(!t.file||!this.isImageFile(t)){e&&(URL.revokeObjectURL(e),this.thumbnailFileById.delete(t.fileId));continue}if(e&&r===t.file){n[t.fileId]=e;continue}e&&r!==t.file&&URL.revokeObjectURL(e);let i=URL.createObjectURL(t.file);this.thumbnailFileById.set(t.fileId,t.file),n[t.fileId]=i}this.thumbnailUrls=n}revokeAllThumbnailUrls(){typeof URL>`u`||typeof URL.revokeObjectURL!=`function`?(this.thumbnailUrls={},this.thumbnailFileById.clear()):(Object.values(this.thumbnailUrls).forEach(e=>URL.revokeObjectURL(e)),this.thumbnailUrls={},this.thumbnailFileById.clear())}getSrUploadedMessage(){if(this.addedAnnouncement)return this.addedAnnouncement;let{totalCount:e,uploadedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesUploadedOfTotal,{uploaded:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesFailedOfTotal,{failed:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}get ownerForm(){if(this.form!==void 0){if(!this.form)return null;let e=this.ownerDocument?.getElementById(this.form);return e instanceof HTMLFormElement?e:null}return this.closest(`form`)}syncFormSubmitListener(){let e=this.ownerForm;this.connectedForm!==e&&(this.teardownFormSubmitListener(),this.connectedForm=e,this.connectedForm&&this.connectedForm.addEventListener(`submit`,this.onHostFormSubmit))}teardownFormSubmitListener(){this.connectedForm&&=(this.connectedForm.removeEventListener(`submit`,this.onHostFormSubmit),null)}};e.n([e.u({type:String})],T.prototype,`id`,void 0),e.n([e.u({type:String})],T.prototype,`name`,void 0),e.n([e.u({type:String,reflect:!0})],T.prototype,`form`,void 0),e.n([e.u({type:String})],T.prototype,`label`,void 0),e.n([e.u({type:String})],T.prototype,`helptext`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown`})],T.prototype,`helptextDropdown`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown-button`})],T.prototype,`helptextDropdownButton`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`required`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`multiple`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`disabled`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`fullwidth`})],T.prototype,`fullwidth`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`upload-strategy`})],T.prototype,`uploadStrategy`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`item-renderer`})],T.prototype,`itemRenderer`,void 0),e.n([e.u({type:String})],T.prototype,`accept`,void 0),e.n([e.u({converter:i.t.csvToArray,attribute:`allowed-formats`})],T.prototype,`allowedFormats`,void 0),e.n([e.u({type:String,attribute:`format-error-message`})],T.prototype,`formatErrorMessage`,void 0),e.n([e.u({attribute:`max-file-size`})],T.prototype,`maxFileSize`,void 0),e.n([e.u({type:String,attribute:`size-error-message`})],T.prototype,`sizeErrorMessage`,void 0),e.n([e.u({attribute:!1})],T.prototype,`onFileValidation`,void 0),e.n([e.u({attribute:!1})],T.prototype,`transfers`,void 0),e.n([e.u({type:Boolean,attribute:`add-comments-enabled`})],T.prototype,`addCommentsEnabled`,void 0),e.n([e.u({type:Boolean,attribute:`rename-files-enabled`})],T.prototype,`renameFilesEnabled`,void 0),e.n([e.u({attribute:!1})],T.prototype,`extraOperations`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],T.prototype,`enableImagePreview`,void 0),e.n([e.u({type:Boolean,attribute:`has-error`})],T.prototype,`hasError`,void 0),e.n([e.u({type:String,attribute:`error-message`})],T.prototype,`errorMessage`,void 0),e.n([e.u({type:Boolean,attribute:`optional-tag`})],T.prototype,`optionalTag`,void 0),e.n([e.u({type:String,attribute:`optional-text`})],T.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean,attribute:`required-tag`})],T.prototype,`requiredTag`,void 0),e.n([e.u({type:String,attribute:`required-text`})],T.prototype,`requiredText`,void 0),e.n([e.u({type:String,attribute:`tag-text`})],T.prototype,`tagText`,void 0),e.n([e.u({type:Number,attribute:`truncate-tail`})],T.prototype,`truncateTail`,void 0),e.n([e.u({attribute:!1})],T.prototype,`value`,void 0),e.n([e.u({attribute:!1})],T.prototype,`defaultValue`,void 0),e.n([e.l()],T.prototype,`files`,void 0),e.n([e.l()],T.prototype,`isDragActive`,void 0),e.n([e.l()],T.prototype,`validationErrorMessage`,void 0),e.n([e.l()],T.prototype,`addedAnnouncement`,void 0),e.n([e.l()],T.prototype,`thumbnailUrls`,void 0);var E=`comments`,D=(e,t)=>{let r=new Date(e);if(Number.isNaN(r.getTime()))return e;let i=String(r.getDate()).padStart(2,`0`),a=String(r.getMonth()+1).padStart(2,`0`),o=r.getFullYear(),s=String(r.getHours()).padStart(2,`0`),c=String(r.getMinutes()).padStart(2,`0`);return n.t(t.commentTimestamp,{date:`${i}.${a}.${o}`,time:`${s}:${c}`})},O=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},k=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},A=(e,t)=>({id:`remove`,title:t.remove,ariaLabel:t.removeFile,onClick:({file:t})=>e(t.fileId)}),j=t=>({id:`rename`,title:t.rename,ariaLabel:t.renameFile,renderInlineUI:n=>{let r=n.getAttribute(`targetFilename`)||n.file.attributes?.targetFilename||n.file.file?.name||``,i=`pkt-fileupload-rename-${n.file.fileId}`,a=()=>{let e=document.getElementById(i)?.value?.trim();e&&n.setAttribute(`targetFilename`,e),n.close()};return e._`
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./format-B8meU8Tm.cjs");require("./alert-Dy5N7qK-.cjs"),require("./icon-CrG6o7ZE.cjs"),require("./input-wrapper-QzdntWJX.cjs");const r=require("./if-defined-CiML3MTM.cjs"),i=require("./converters-CW6SN0TT.cjs"),a=require("./utils-63cRpWut.cjs"),o=require("./focus-trap-DSv4Ifqm.cjs");require("./modal-C5AiVm5g.cjs"),require("./progressbar-YfHSPmqI.cjs");function s(e){if(e==null||e===``)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=String(e).trim(),n=Number(t);if(!Number.isNaN(n)&&n>0)return n;let r=t.match(/^(\d+(?:\.\d+)?)\s*(B|KB|MB|GB)$/i);if(!r){console.warn(`PktFileUpload: Invalid maxFileSize format "${t}". Use format like "5MB", "500KB", "1GB", or bytes.`);return}let i=parseFloat(r[1]);switch(r[2].toUpperCase()){case`B`:return i;case`KB`:return i*1024;case`MB`:return i*1024*1024;case`GB`:return i*1024*1024*1024;default:return}}function c(e){return e<1024?`${Math.round(e)} B`:e<1048576?`${Math.round(e/1024)} KB`:e<1073741824?`${Math.round(e/1048576)} MB`:`${Math.round(e/1073741824)} GB`}function l(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function u(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function d(e,t,n){let r=e.toLowerCase().replace(/^\./,``);if(r.includes(`/`)){if(r.endsWith(`/*`)){let e=r.replace(`/*`,``);return n.startsWith(`${e}/`)}return n===r}return t===r}function f(e,t){let n=l(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>d(e,r,i))}function p(e,t){let n=(e??``).trim();if(n)return n;let r=l(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function m(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function h(e,t){let n=l(e);if(n.length>0)return n.map(m).join(`, `);let r=u(t);return r.length>0?r.map(m).join(`, `):``}function g(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function _(t,n){let r=l(n.allowedFormats);if(r.length>0&&!f(t,r)){let t=r.join(`, `),i=e.s.fileupload.invalidFormat;return g(n.formatErrorMessage,i,{formats:t})}let i=s(n.maxFileSize);if(i!==void 0&&t.size>i){let t=c(i),r=e.s.fileupload.sizeTooLarge;return g(n.sizeErrorMessage,r,{maxSize:t})}if(n.onFileValidation){let e=n.onFileValidation(t);if(e)return e}return null}function v(e){let t=e.file;if(t?.type?.startsWith(`image/`))return!0;let n=e.attributes?.targetFilename||t?.name||``;return/\.(jpe?g|png|gif|webp|heic|heif|bmp|svg)$/i.test(n)}function y(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function b(e,t,n){let r={"in-progress":0,error:1,idle:2};return e.map(e=>{let r=t?.find(t=>t.fileId===e.fileId);return{...e,progress:r?.progress??(n===`form`?`done`:`queued`),errorMessage:r?.errorMessage,showProgress:r?.showProgress,lastProgress:r?.lastProgress}}).sort((e,t)=>r[y(e.progress)]-r[y(t.progress)])}function x(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function S(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function C(e,t){let n=e.length;if(n===0||!t||t.length===0)return{totalCount:n,uploadedCount:0,failedCount:0};let r=0,i=0;for(let n of e){let e=t.find(e=>e.fileId===n.fileId);e?.progress===`done`?r++:e?.progress===`error`&&i++}return{totalCount:n,uploadedCount:r,failedCount:i}}function w(t,n=e.s.fileupload.unknownFilename){return t.attributes?.targetFilename||t.file?.name||n}var T=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${a.n()}`,this.name=`files`,this.label=``,this.helptext=``,this.helptextDropdown=``,this.required=!1,this.multiple=!1,this.disabled=!1,this.fullwidth=!1,this.uploadStrategy=`form`,this.itemRenderer=`filename`,this.accept=``,this.allowedFormats=[],this.formatErrorMessage=``,this.sizeErrorMessage=``,this.transfers=[],this.addCommentsEnabled=!1,this.renameFilesEnabled=!1,this.extraOperations=[],this.enableImagePreview=!1,this.hasError=!1,this.errorMessage=``,this.optionalTag=!1,this.requiredTag=!1,this.tagText=null,this.truncateTail=4,this.files=[],this.isDragActive=!1,this.validationErrorMessage=null,this.addedAnnouncement=``,this.thumbnailUrls={},this.hasInitializedValue=!1,this.hasWarnedInvalidValueCombo=!1,this.thumbnailFileById=new Map,this.connectedForm=null,this.addedAnnouncementTimer=null,this.onNativeFileChange=e=>{let t=e.target;this.addFiles(t.files?Array.from(t.files):[]),this.uploadStrategy===`custom`&&(t.value=``)},this.openFileDialog=e=>{e.preventDefault(),e.stopPropagation(),!this.disabled&&this.querySelector(`#${this.id}-input`)?.click()},this.onDropZoneClick=e=>{this.disabled||e.target.closest(`.pkt-fileupload__drop-zone__placeholder__title__open-file-dialog`)||this.querySelector(`#${this.id}-input`)?.click()},this.onDragOver=e=>{e.preventDefault(),!this.disabled&&(this.isDragActive=!0)},this.onDragLeave=()=>{this.isDragActive=!1},this.onDrop=e=>{if(e.preventDefault(),this.isDragActive=!1,this.disabled)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this.addFiles(t)},this.onHostFormSubmit=e=>{this.required&&this.uploadStrategy===`custom`&&(this.getCurrentFiles().length>0||(this.validationErrorMessage=this.requiredSelectionMessage,e.preventDefault()))}}get requiredSelectionMessage(){return this.pktStrings.get(`fileupload`).requiredMissing}get isControlled(){return this.value!==void 0}get hasEffectiveError(){return!!this.validationErrorMessage||this.hasError||!!this.errorMessage.trim()}get effectiveErrorMessage(){return this.validationErrorMessage??this.errorMessage??``}get hasValidationError(){return!!this.validationErrorMessage}firstUpdated(e){super.firstUpdated?.(e),this.value!==void 0&&this.defaultValue!==void 0&&this.warnInvalidValueCombo()}willUpdate(e){super.willUpdate(e),this.hasInitializedValue?this.isControlled&&(e.has(`value`)||e.has(`itemRenderer`)||e.has(`enableImagePreview`))&&(this.files=this.value??[],this.syncThumbnailUrls(this.files)):(this.files=this.value??this.defaultValue??[],this.syncThumbnailUrls(this.files),this.hasInitializedValue=!0)}updated(e){super.updated(e),(e.has(`uploadStrategy`)||e.has(`required`)||e.has(`value`)||e.has(`form`))&&this.syncFormSubmitListener(),this.uploadStrategy===`form`&&(e.has(`value`)||e.has(`files`)||e.has(`uploadStrategy`))&&this.syncNativeInputFiles()}syncNativeInputFiles(){let e=this.querySelector(`#${this.id}-input`);if(e&&typeof DataTransfer<`u`)try{let t=new DataTransfer;for(let e of this.getCurrentFiles())e.file&&t.items.add(e.file);e.files=t.files}catch{}}warnInvalidValueCombo(){this.hasWarnedInvalidValueCombo||=(console.warn(`PktFileUpload: Både value og defaultValue er angitt. Komponenten kan være enten kontrollert eller ukontrollert, ikke begge. value vil bli prioritert.`),!0)}disconnectedCallback(){this.teardownFormSubmitListener(),this.addedAnnouncementTimer&&=(clearTimeout(this.addedAnnouncementTimer),null),super.disconnectedCallback(),this.revokeAllThumbnailUrls()}setAddedAnnouncement(e){this.addedAnnouncement=e,this.addedAnnouncementTimer&&clearTimeout(this.addedAnnouncementTimer),this.addedAnnouncementTimer=setTimeout(()=>{this.addedAnnouncement=``,this.addedAnnouncementTimer=null},1500)}connectedCallback(){super.connectedCallback(),this.syncFormSubmitListener()}addFiles(e){if(e.length===0)return;let t=this.multiple?e:[e[0]];for(let e of t){let t=this.validateFile(e);if(t){this.validationErrorMessage=t;return}}this.validationErrorMessage=null;let r=t.map(e=>({fileId:a.n(),file:e,attributes:{targetFilename:e.name}})),i=this.pktStrings.get(`fileupload`);this.setAddedAnnouncement(r.length===1?n.t(i.srFileAdded,{filename:r[0].attributes.targetFilename}):n.t(i.srFilesAdded,{count:r.length}));let o=this.getCurrentFiles(),s=this.multiple?[...o,...r]:[r[0]];this.commitFiles(s,`add`,r.map(e=>e.fileId)),this.uploadStrategy===`custom`&&r.forEach(e=>{this.dispatchEvent(new CustomEvent(`file-upload-requested`,{detail:{fileId:e.fileId,file:e.file,attributes:e.attributes},bubbles:!0,composed:!0}))})}getCurrentFiles(){return this.isControlled?this.value??[]:this.files}cancelTransfer(e){if(this.disabled)return;let t=this.getCurrentFiles().find(t=>t.fileId===e);t&&(this.removeFileItem(e),this.dispatchEvent(new CustomEvent(`transfer-cancelled`,{detail:{fileId:t.fileId,file:t.file,attributes:t.attributes},bubbles:!0,composed:!0})))}removeFileItem(e){if(this.disabled)return;let t=this.getCurrentFiles(),n=t.filter(t=>t.fileId!==e);n.length!==t.length&&this.commitFiles(n,`remove`,[e])}updateFileItem(e,t){let n=this.getCurrentFiles().map(n=>n.fileId===e?{...n,...t}:n);this.commitFiles(n,`update`,[e])}commitFiles(e,t,n){this.isControlled||(this.files=e,this.syncThumbnailUrls(e)),this.validationErrorMessage===this.requiredSelectionMessage&&e.length>0&&(this.validationErrorMessage=null),this.dispatchEvent(new CustomEvent(`files-changed`,{detail:{files:e,reason:t,changedFileIds:n},bubbles:!0,composed:!0}))}getThumbnailUrl(e){return this.thumbnailUrls[e.fileId]}getTransferProgress(e){let t=this.transfers.find(t=>t.fileId===e);return t?t.progress:this.uploadStrategy===`form`?`done`:`queued`}getTransferForFile(e){return this.transfers.find(t=>t.fileId===e)}isImageFile(e){return v(e)}formatFileSize(e){return c(e)}getResolvedAcceptValue(){return p(this.accept,this.allowedFormats)}getSupportedFormatsText(){return h(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return b(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=_(e,{allowedFormats:this.allowedFormats,maxFileSize:this.maxFileSize,formatErrorMessage:this.formatErrorMessage,sizeErrorMessage:this.sizeErrorMessage,onFileValidation:this.onFileValidation});if(t)return t;let n={file:e,errorMessage:null},r=new CustomEvent(`file-validate`,{detail:n,bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(r),n.errorMessage?n.errorMessage:r.defaultPrevented?this.pktStrings.get(`fileupload`).genericValidationRejection:null}syncThumbnailUrls(e){if(typeof URL>`u`||typeof URL.createObjectURL!=`function`||typeof URL.revokeObjectURL!=`function`){this.thumbnailUrls={},this.thumbnailFileById.clear();return}let t=new Set(e.map(e=>e.fileId)),n={};for(let[e,n]of Object.entries(this.thumbnailUrls))t.has(e)||(URL.revokeObjectURL(n),this.thumbnailFileById.delete(e));for(let t of e){let e=this.thumbnailUrls[t.fileId],r=this.thumbnailFileById.get(t.fileId);if(!t.file||!this.isImageFile(t)){e&&(URL.revokeObjectURL(e),this.thumbnailFileById.delete(t.fileId));continue}if(e&&r===t.file){n[t.fileId]=e;continue}e&&r!==t.file&&URL.revokeObjectURL(e);let i=URL.createObjectURL(t.file);this.thumbnailFileById.set(t.fileId,t.file),n[t.fileId]=i}this.thumbnailUrls=n}revokeAllThumbnailUrls(){typeof URL>`u`||typeof URL.revokeObjectURL!=`function`?(this.thumbnailUrls={},this.thumbnailFileById.clear()):(Object.values(this.thumbnailUrls).forEach(e=>URL.revokeObjectURL(e)),this.thumbnailUrls={},this.thumbnailFileById.clear())}getSrUploadedMessage(){if(this.addedAnnouncement)return this.addedAnnouncement;let{totalCount:e,uploadedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesUploadedOfTotal,{uploaded:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesFailedOfTotal,{failed:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}get ownerForm(){if(this.form!==void 0){if(!this.form)return null;let e=this.ownerDocument?.getElementById(this.form);return e instanceof HTMLFormElement?e:null}return this.closest(`form`)}syncFormSubmitListener(){let e=this.ownerForm;this.connectedForm!==e&&(this.teardownFormSubmitListener(),this.connectedForm=e,this.connectedForm&&this.connectedForm.addEventListener(`submit`,this.onHostFormSubmit))}teardownFormSubmitListener(){this.connectedForm&&=(this.connectedForm.removeEventListener(`submit`,this.onHostFormSubmit),null)}};e.n([e.u({type:String})],T.prototype,`id`,void 0),e.n([e.u({type:String})],T.prototype,`name`,void 0),e.n([e.u({type:String,reflect:!0})],T.prototype,`form`,void 0),e.n([e.u({type:String})],T.prototype,`label`,void 0),e.n([e.u({type:String})],T.prototype,`helptext`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown`})],T.prototype,`helptextDropdown`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown-button`})],T.prototype,`helptextDropdownButton`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`required`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`multiple`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`disabled`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`fullwidth`})],T.prototype,`fullwidth`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`upload-strategy`})],T.prototype,`uploadStrategy`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`item-renderer`})],T.prototype,`itemRenderer`,void 0),e.n([e.u({type:String})],T.prototype,`accept`,void 0),e.n([e.u({converter:i.t.csvToArray,attribute:`allowed-formats`})],T.prototype,`allowedFormats`,void 0),e.n([e.u({type:String,attribute:`format-error-message`})],T.prototype,`formatErrorMessage`,void 0),e.n([e.u({attribute:`max-file-size`})],T.prototype,`maxFileSize`,void 0),e.n([e.u({type:String,attribute:`size-error-message`})],T.prototype,`sizeErrorMessage`,void 0),e.n([e.u({attribute:!1})],T.prototype,`onFileValidation`,void 0),e.n([e.u({attribute:!1})],T.prototype,`transfers`,void 0),e.n([e.u({type:Boolean,attribute:`add-comments-enabled`})],T.prototype,`addCommentsEnabled`,void 0),e.n([e.u({type:Boolean,attribute:`rename-files-enabled`})],T.prototype,`renameFilesEnabled`,void 0),e.n([e.u({attribute:!1})],T.prototype,`extraOperations`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],T.prototype,`enableImagePreview`,void 0),e.n([e.u({type:Boolean,attribute:`has-error`})],T.prototype,`hasError`,void 0),e.n([e.u({type:String,attribute:`error-message`})],T.prototype,`errorMessage`,void 0),e.n([e.u({type:Boolean,attribute:`optional-tag`})],T.prototype,`optionalTag`,void 0),e.n([e.u({type:String,attribute:`optional-text`})],T.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean,attribute:`required-tag`})],T.prototype,`requiredTag`,void 0),e.n([e.u({type:String,attribute:`required-text`})],T.prototype,`requiredText`,void 0),e.n([e.u({type:String,attribute:`tag-text`})],T.prototype,`tagText`,void 0),e.n([e.u({type:Number,attribute:`truncate-tail`})],T.prototype,`truncateTail`,void 0),e.n([e.u({attribute:!1})],T.prototype,`value`,void 0),e.n([e.u({attribute:!1})],T.prototype,`defaultValue`,void 0),e.n([e.l()],T.prototype,`files`,void 0),e.n([e.l()],T.prototype,`isDragActive`,void 0),e.n([e.l()],T.prototype,`validationErrorMessage`,void 0),e.n([e.l()],T.prototype,`addedAnnouncement`,void 0),e.n([e.l()],T.prototype,`thumbnailUrls`,void 0);var E=`comments`,D=(e,t)=>{let r=new Date(e);if(Number.isNaN(r.getTime()))return e;let i=String(r.getDate()).padStart(2,`0`),a=String(r.getMonth()+1).padStart(2,`0`),o=r.getFullYear(),s=String(r.getHours()).padStart(2,`0`),c=String(r.getMinutes()).padStart(2,`0`);return n.t(t.commentTimestamp,{date:`${i}.${a}.${o}`,time:`${s}:${c}`})},O=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},k=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},A=(e,t)=>({id:`remove`,title:t.remove,ariaLabel:t.removeFile,onClick:({file:t})=>e(t.fileId)}),j=t=>({id:`rename`,title:t.rename,ariaLabel:t.renameFile,renderInlineUI:n=>{let r=n.getAttribute(`targetFilename`)||n.file.attributes?.targetFilename||n.file.file?.name||``,i=`pkt-fileupload-rename-${n.file.fileId}`,a=()=>{let e=document.getElementById(i)?.value?.trim();e&&n.setAttribute(`targetFilename`,e),n.close()};return e._`
|
|
2
2
|
<label for=${i} class="pkt-sr-only">${t.renameInputLabel}</label>
|
|
3
3
|
<input
|
|
4
4
|
id=${i}
|
|
@@ -6,13 +6,13 @@ import { t as d } from "./booleanish-OQJTYSrw.js";
|
|
|
6
6
|
import "./shared-types-A6iGIX-f.js";
|
|
7
7
|
import { n as f, o as p, t as m } from "./fetch-header-footer-data-Pc32etrk.js";
|
|
8
8
|
import "./icon-CUU42bZ0.js";
|
|
9
|
+
import "./textinput-CRlErItw.js";
|
|
9
10
|
import { t as h } from "./if-defined-D18nY_K_.js";
|
|
10
11
|
import "./button-CF9k3ARf.js";
|
|
11
12
|
import { n as g, t as _ } from "./ref-D4OwQYdf.js";
|
|
12
13
|
import { n as v, t as y } from "./focus-trap-DG3pEuyJ.js";
|
|
13
14
|
import { n as b, t as x } from "./scroll-lock-CR-g54ai.js";
|
|
14
15
|
import "./link-BU6t5Tt9.js";
|
|
15
|
-
import "./textinput-D_V3b327.js";
|
|
16
16
|
import "./searchinput-BV2C1VbN.js";
|
|
17
17
|
import "./header-menu-DxOSBiTJ.js";
|
|
18
18
|
//#region ../../shared-types/header.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-B0Vp_OuR.cjs"),i=require("./booleanish-BF8l4scU.cjs");require("./shared-types-BvRk9kiK.cjs");const a=require("./fetch-header-footer-data-CUKV0biS.cjs");require("./icon-CrG6o7ZE.cjs");const o=require("./if-defined-CiML3MTM.cjs");require("./button-BBFI3FuT.cjs");const s=require("./ref-CB7e9nMY.cjs"),c=require("./focus-trap-DSv4Ifqm.cjs"),l=require("./scroll-lock-x0VxhKWZ.cjs");require("./link-a1ZK4J1j.cjs"),require("./
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-B0Vp_OuR.cjs"),i=require("./booleanish-BF8l4scU.cjs");require("./shared-types-BvRk9kiK.cjs");const a=require("./fetch-header-footer-data-CUKV0biS.cjs");require("./icon-CrG6o7ZE.cjs"),require("./textinput-C5KWIB21.cjs");const o=require("./if-defined-CiML3MTM.cjs");require("./button-BBFI3FuT.cjs");const s=require("./ref-CB7e9nMY.cjs"),c=require("./focus-trap-DSv4Ifqm.cjs"),l=require("./scroll-lock-x0VxhKWZ.cjs");require("./link-a1ZK4J1j.cjs"),require("./searchinput-DqD_iLxV.cjs"),require("./header-menu-De2DNAXd.cjs");var u=e=>typeof e.target==`string`?{title:e.title,iconName:e.iconName,href:e.target}:{title:e.title,iconName:e.iconName,onClick:e.target},d=e=>u(e),f=e=>{if(!e)return;let t=typeof e==`string`?new Date(e):e;if(!isNaN(t.getTime()))return t.toLocaleDateString(`nb-NO`,{day:`numeric`,month:`long`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})},p=class{constructor(e,t){this.isMobile=!1,this.isTablet=!1,this.isHidden=!1,this.pauseScrollHide=!1,this.componentWidth=typeof window<`u`?window.innerWidth:0,this.lastScrollPosition=0,this.scrollLockToken=l.t(),this.lastFocusedElement=null,this.shouldRestoreFocus=!1,this.initialWidthEstimated=!1,this.handleScroll=()=>{if(this.getOptions().scrollBehavior!==`hide`||this.pauseScrollHide)return;let e=window.pageYOffset||document.documentElement.scrollTop;if(e<0||Math.abs(e-this.lastScrollPosition)<60)return;let t=e>this.lastScrollPosition;this.lastScrollPosition=e,t!==this.isHidden&&(this.isHidden=t,this.host.requestUpdate())},this.host=e,this.getOptions=t,e.addController(this)}hostConnected(){window.addEventListener(`scroll`,this.handleScroll)}hostUpdate(){this.initialWidthEstimated||(this.initialWidthEstimated=!0,this.componentWidth=this.host.offsetWidth,this.applyBreakpoints())}hostDisconnected(){this.resizeObserver?.disconnect(),window.removeEventListener(`scroll`,this.handleScroll),l.n(this.scrollLockToken,!1)}observe(e){e&&(this.componentWidth=e.offsetWidth,this.refreshBreakpoints(),this.resizeObserver=new ResizeObserver(e=>{for(let t of e)this.componentWidth=t.borderBoxSize&&t.borderBoxSize.length>0?t.borderBoxSize[0].inlineSize:t.contentRect.width,this.refreshBreakpoints()}),this.resizeObserver.observe(e))}refreshBreakpoints(){this.applyBreakpoints()&&this.host.requestUpdate()}applyBreakpoints(){let{mobileBreakpoint:e,tabletBreakpoint:t}=this.getOptions(),n=this.componentWidth<e,r=this.componentWidth<t;return n===this.isMobile&&r===this.isTablet?!1:(this.isMobile=n,this.isTablet=r,!0)}setScrollLock(e){l.n(this.scrollLockToken,e)}captureFocus(){this.lastFocusedElement=document.activeElement}flagRestoreFocus(){this.shouldRestoreFocus=!0}restoreFocus(){this.shouldRestoreFocus&&this.lastFocusedElement&&document.contains(this.lastFocusedElement)&&this.lastFocusedElement.focus(),this.lastFocusedElement=null,this.shouldRestoreFocus=!1}},m=class extends e.t{constructor(...e){super(...e),this.canChangeRepresentation=!1,this.logoutOnClick=!1}handleChangeRepresentation(){this.dispatchEvent(new CustomEvent(`change-representation`,{bubbles:!0,composed:!0}))}handleLogout(){this.dispatchEvent(new CustomEvent(`log-out`,{bubbles:!0,composed:!0}))}handleMenuItemClick(e){`onClick`in e&&typeof e.onClick==`function`&&e.onClick()}renderLinkOrButton(n,r){let i=`href`in n,a=t.t({"pkt-user-menu__link":!0,"pkt-link-button":!i,"pkt-link":!i,"pkt-link--icon-left":!i,[r||``]:!!r});return i?e._`
|
|
2
2
|
<pkt-link
|
|
3
3
|
iconName=${n.iconName||e.h}
|
|
4
4
|
href=${n.href}
|
|
@@ -12,6 +12,7 @@ var m = {
|
|
|
12
12
|
"css-class": "pkt-modal",
|
|
13
13
|
isElement: !0,
|
|
14
14
|
isPureReact: !0,
|
|
15
|
+
"dark-mode": !0,
|
|
15
16
|
events: {
|
|
16
17
|
"background-click": { description: "Event som trigges når bakgrunnen trykkes på" },
|
|
17
18
|
close: { description: "Event som trigges når meldingsboksen lukkes" }
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./element-with-slot-B0Vp_OuR.cjs");require("./icon-CrG6o7ZE.cjs");const r=require("./if-defined-CiML3MTM.cjs"),i=require("./ref-CB7e9nMY.cjs"),a=require("./utils-63cRpWut.cjs"),o=require("./scroll-lock-x0VxhKWZ.cjs");var s={name:`pkt-modal`,react:`PktModal`,"css-class":`pkt-modal`,isElement:!0,isPureReact:!0,"dark-mode":!0,events:{"background-click":{description:`Event som trigges når bakgrunnen trykkes på`},close:{description:`Event som trigges når meldingsboksen lukkes`}},props:{open:{name:`Åpen`,description:`Deklarativ styring av modalens åpen/lukket-tilstand. Kan brukes i stedet for showModal()/close()-metodene.`,type:`boolean`,category:`tech`,default:!1},headingText:{name:`Heading text`,description:`Heading tekst på modalen`,type:`string`,category:`contents`},headingIconName:{name:`Ikon i overskriften`,description:`Navn på ikonet som vises foran overskriften. Vises bare når headingText er satt.`,type:`icon`,category:`ui`},headingIconPath:{name:`Ikon-sti for overskriften`,description:`Overstyr stien til ikonet i overskriften. Kan også settes globalt med window.pktIconPath.`,type:`string`,category:`tech`},hideCloseButton:{name:`Gjem 'Lukk'-knapp`,description:`Gjemmer lukkeknappen. Dersom denne er satt til true, vil ikke lukkeknappen vises, og dermed er det viktig at man tilbyr en annen måte som f.eks. en knapp for å lukke modalen på.`,type:`boolean`,category:`ui`,default:!1},closeOnBackdropClick:{name:`Lukk modalen når bakgrunnen trykkes på`,description:`Lukk modalen når bakgrunnen trykkes på`,type:`boolean`,category:`tech`,default:!1},closeButtonSkin:{name:`Stil på lukkeknappen`,description:`Stil på lukkeknappen`,type:[`blue`,`yellow-filled`],category:`ui`,default:`blue`},size:{name:`Størrelse`,description:`Størrelsen på modalen`,type:[`small`,`medium`,`large`,`fit-content`],category:`ui`,default:`medium`},variant:{name:`Variant`,description:`Standard dialog eller skuff`,type:[`dialog`,`drawer`],category:`ui`,default:`dialog`},drawerPosition:{name:`Skuffposisjon`,description:`Posisjonen til skuffen`,type:[`left`,`right`],category:`ui`,default:`right`},transparentBackdrop:{name:`Gjennomsiktig bakgrunn`,description:`Bakgrunnen er gjennomsiktig`,type:`boolean`,category:`ui`,default:!1},removePadding:{name:`Fjern padding`,description:`Fjerner paddingen rundt innholdet i modalen`,type:`boolean`,category:`ui`,default:!1}},slots:{default:{description:`Innholdet i meldingen. Her tilbyr vi støtteklasser for å style 1-3 knapper i modalen.`}}},c=class extends n.t{constructor(){super(),this.open=!1,this.headingText=``,this.removePadding=!1,this.hideCloseButton=s.props.hideCloseButton.default,this.closeOnBackdropClick=s.props.closeOnBackdropClick.default,this.closeButtonSkin=`blue`,this.size=s.props.size.default,this.variant=`dialog`,this.drawerPosition=`right`,this.transparentBackdrop=!1,this.dialogRef=i.t(),this._scrollLockToken=o.t(),this._idSuffix=a.n(),this._headingId=`pkt-modal__headingText-${this._idSuffix}`,this._contentId=`pkt-modal__content-${this._idSuffix}`,this._isOpen=!1,this.close=(e,t=!1)=>{if(!this._isOpen)return;this._isOpen=!1,this.open=!1,o.n(this._scrollLockToken,!1);let n=document.activeElement;n&&!this.isElementInViewport(n)&&n.scrollIntoView({behavior:`smooth`,block:`nearest`}),this.dispatchEvent(new CustomEvent(`close`,{detail:{origin:e},bubbles:!0,composed:!0})),t||this.dialogRef.value?.close()},this.showModal=(e=null)=>{this._isOpen=!0,this.open=!0,this.dialogRef.value?.showModal(),o.n(this._scrollLockToken,!0),this.dispatchEvent(new CustomEvent(`showModal`,{detail:{origin:e},bubbles:!0,composed:!0}))},this._isOpen=!1}async connectedCallback(){super.connectedCallback(),document.addEventListener(`keydown`,this.handleKeyDown.bind(this)),document.addEventListener(`click`,this.handleBackdropClick.bind(this))}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`click`,this.handleBackdropClick),o.n(this._scrollLockToken,!1)}updated(e){super.updated(e),e.has(`open`)&&(this.open&&!this._isOpen?this.showModal():!this.open&&this._isOpen&&this.close(new Event(`close`),!1))}async firstUpdated(e){super.firstUpdated(e),this.dialogRef.value&&!window.HTMLDialogElement&&!this.dialogRef.value.showModal&&(`document`in window&&`createElement`in document&&(await Promise.resolve().then(()=>require("./dialog-polyfill.esm-CW51hN2p.cjs")).then(e=>e.default)).registerDialog(this.dialogRef.value),this.dialogRef.value.addEventListener(`close`,()=>{this.close(new Event(`close`),!0)}))}handleKeyDown(e){e.key===`Escape`&&this.close(e)}handleBackdropClick(e){this.closeOnBackdropClick&&e.target===this.dialogRef?.value&&this.close(e)}isElementInViewport(e){let t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}render(){let a={"pkt-modal":!0,"pkt-modal--removePadding":this.removePadding??!1,"pkt-modal--noHeadingText":this.headingText===``||this.headingText===void 0,"pkt-modal--noShadow":this.closeButtonSkin===`yellow-filled`,"pkt-modal--transparentBackdrop":this.transparentBackdrop??!1,[`pkt-modal--${this.size}`]:this.size!==void 0,[`pkt-modal__${this.variant}`]:this.variant!==void 0,[`pkt-modal__drawer--${this.drawerPosition}`]:this.variant===`drawer`},o={"pkt-modal__headingText":!0,"pkt-txt-24":!0,"pkt-modal__headingText--hasIcon":!!this.headingIconName},s=this.headingIconName?e._`<pkt-icon
|
|
2
|
+
class="pkt-modal__headingIcon"
|
|
3
|
+
name=${this.headingIconName}
|
|
4
|
+
path=${r.t(this.headingIconPath)}
|
|
5
|
+
></pkt-icon>`:e.h,c={"pkt-modal__content":!0,"pkt-txt-18-light":!0},l=this.closeButtonSkin===`blue`,u={"pkt-modal__closeButton":!0,[`pkt-modal__closeButton--${this.closeButtonSkin}`]:!0};return e._`
|
|
6
|
+
<dialog
|
|
7
|
+
class=${t.t(a)}
|
|
8
|
+
${i.n(this.dialogRef)}
|
|
9
|
+
aria-labelledby=${this.headingText?this._headingId:e.h}
|
|
10
|
+
aria-describedby=${this._contentId}
|
|
11
|
+
@close=${e=>this.close(e,!0)}
|
|
12
|
+
>
|
|
13
|
+
<div class="pkt-modal__wrapper">
|
|
14
|
+
${this.headingText||!this.hideCloseButton?e._`<div class="pkt-modal__header">
|
|
15
|
+
<div class="pkt-modal__header-background"></div>
|
|
16
|
+
${this.headingText?e._`<h1 id=${this._headingId} class=${t.t(o)}>
|
|
17
|
+
${s}${this.headingText}
|
|
18
|
+
</h1>`:e._`<div class="pkt-modal__headingText"></div>`}
|
|
19
|
+
${this.hideCloseButton?e._`<div class="pkt-modal__noCloseButton"></div>`:e._`<div class="${t.t(u)}">
|
|
20
|
+
<pkt-button
|
|
21
|
+
@click=${e=>this.close(e)}
|
|
22
|
+
aria-label=${this.pktStrings.get(`generic`).close}
|
|
23
|
+
iconname="close"
|
|
24
|
+
variant="icon-only"
|
|
25
|
+
size="medium"
|
|
26
|
+
skin=${l?`tertiary`:`primary`}
|
|
27
|
+
>
|
|
28
|
+
${this.pktStrings.get(`generic`).close}
|
|
29
|
+
</pkt-button>
|
|
30
|
+
</div>`}
|
|
31
|
+
</div>`:e.h}
|
|
32
|
+
<div class="pkt-modal__container">
|
|
33
|
+
<div id=${this._contentId} class=${t.t(c)}>${n.i(this)}</div>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</dialog>
|
|
37
|
+
`}};e.n([e.u({type:Boolean,reflect:!0})],c.prototype,`open`,void 0),e.n([e.u({type:String})],c.prototype,`headingText`,void 0),e.n([e.u({type:String})],c.prototype,`headingIconName`,void 0),e.n([e.u({type:String})],c.prototype,`headingIconPath`,void 0),e.n([e.u({type:Boolean})],c.prototype,`removePadding`,void 0),e.n([e.u({type:Boolean})],c.prototype,`hideCloseButton`,void 0),e.n([e.u({type:Boolean})],c.prototype,`closeOnBackdropClick`,void 0),e.n([e.u({type:String})],c.prototype,`closeButtonSkin`,void 0),e.n([e.u({type:String})],c.prototype,`size`,void 0),e.n([e.u({type:String})],c.prototype,`variant`,void 0),e.n([e.u({type:String})],c.prototype,`drawerPosition`,void 0),e.n([e.u({type:Boolean})],c.prototype,`transparentBackdrop`,void 0);try{e.d(`pkt-modal`)(c)}catch{console.warn(`Forsøker å definere <pkt-modal>, men den er allerede definert`)}var l=c;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
|
package/dist/pkt-fileupload.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./fileupload-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./fileupload-M66Pd-QJ.cjs");Object.defineProperty(exports,"PktFileUpload",{enumerable:!0,get:function(){return e.n}}),exports.default=e.t;
|
package/dist/pkt-fileupload.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { n as PktFileUpload, t as default } from "./fileupload-
|
|
1
|
+
export { n as PktFileUpload, t as default } from "./fileupload-CEwnpxZj.js";
|
package/dist/pkt-header.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./header-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./header-BqheRQpR.cjs");exports.PktHeader=e.t,exports.PktHeaderGlobal=e.n,exports.PktHeaderService=e.r,exports.PktHeaderUserMenu=e.i,exports.formatLastLoggedIn=e.a;
|
package/dist/pkt-header.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as PktHeader, n as PktHeaderGlobal, r as PktHeaderService, i as PktHeaderUserMenu, a as formatLastLoggedIn } from "./header-
|
|
1
|
+
export { t as PktHeader, n as PktHeaderGlobal, r as PktHeaderService, i as PktHeaderUserMenu, a as formatLastLoggedIn } from "./header-BYNzxXCo.js";
|
package/dist/pkt-index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./element-C6WTyJFE.cjs"),t=require("./consent-DNHRe0zV.cjs"),n=require("./alert-Dy5N7qK-.cjs"),r=require("./header-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./element-C6WTyJFE.cjs"),t=require("./consent-DNHRe0zV.cjs"),n=require("./alert-Dy5N7qK-.cjs"),r=require("./header-BqheRQpR.cjs"),i=require("./card-mi3VKIoy.cjs"),a=require("./checkbox-B8foyiOW.cjs"),o=require("./radiobutton-IcDc6ze2.cjs"),s=require("./icon-CrG6o7ZE.cjs"),c=require("./loader-DwGMavG7.cjs"),l=require("./accordion-Bg4CMrUM.cjs"),u=require("./input-wrapper-QzdntWJX.cjs"),d=require("./textarea-B5OfR-QI.cjs"),f=require("./textinput-C5KWIB21.cjs"),p=require("./messagebox-DR-s6tyr.cjs"),m=require("./calendar-Dds9KFiE.cjs"),h=require("./combobox-DLDvyuDh.cjs"),g=require("./button-BBFI3FuT.cjs"),_=require("./backlink-BnWruRuj.cjs"),v=require("./breadcrumbs-CyWtnx2B.cjs"),y=require("./tag-DrFK8Wq3.cjs"),b=require("./helptext-BbrFE48Y.cjs"),x=require("./checkbox-group-BlBgrzKG.cjs"),S=require("./fileupload-M66Pd-QJ.cjs"),C=require("./modal-C5AiVm5g.cjs"),w=require("./progressbar-YfHSPmqI.cjs"),T=require("./datepicker-C7F1Yc5N.cjs"),E=require("./footer-HFL2sjAY.cjs"),D=require("./link-a1ZK4J1j.cjs"),O=require("./searchinput-DqD_iLxV.cjs"),k=require("./header-menu-De2DNAXd.cjs"),A=require("./heading--hGRDNX9.cjs"),j=require("./linkcard-Cu4Rh71U.cjs"),M=require("./radio-group-bpIEEMdL.cjs"),N=require("./tabs-BcnYrmjU.cjs"),P=require("./select-CHqM6kI-.cjs"),F=require("./timepicker-RxsG0mCF.cjs");exports.PktAccordion=l.r,exports.PktAccordionItem=l.n,exports.PktAlert=n.n,exports.PktBackLink=_.n,exports.PktBreadcrumbs=v.t,exports.PktButton=g.n,exports.PktCalendar=m.n,exports.PktCard=i.n,exports.PktCheckbox=a.n,exports.PktCheckboxGroup=x.n,exports.PktCombobox=h.n,exports.PktConsent=t.n,exports.PktDateTags=T.a,exports.PktDatepicker=T.t,Object.defineProperty(exports,"PktFileUpload",{enumerable:!0,get:function(){return S.n}}),exports.PktFooter=E.n,exports.PktFooterSimple=E.t,exports.PktHeader=r.t,exports.PktHeaderGlobal=r.n,exports.PktHeaderMenu=k.n,exports.PktHeaderService=r.r,exports.PktHeaderUserMenu=r.i,exports.PktHeading=A.n,exports.PktHelptext=b.n,exports.PktIcon=s.n,exports.PktInputWrapper=u.n,exports.PktLink=D.n,exports.PktLinkCard=j.n,exports.PktLoader=c.n,exports.PktMessagebox=p.n,exports.PktModal=C.n,exports.PktProgressbar=w.n,exports.PktRadioButton=o.n,exports.PktRadiobutton=o.n,exports.PktRadioGroup=M.n,exports.PktSearchInput=O.n,exports.PktSelect=P.n,exports.PktTabItem=N.n,exports.PktTabs=N.r,exports.PktTag=y.n,exports.PktTextarea=d.n,exports.PktTextinput=f.n,exports.PktTimepicker=F.t,exports.getPktStrings=e.r,exports.pktStringsNb=e.s,exports.resetPktStrings=e.i,exports.setPktStrings=e.a,exports.subscribePktStrings=e.o;
|
package/dist/pkt-index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as e, i as t, o as n, r, s as i } from "./element-ckeMVgMz.js";
|
|
2
2
|
import { n as a } from "./consent-BTw6uqFf.js";
|
|
3
3
|
import { n as o } from "./alert-BAaZIR3e.js";
|
|
4
|
-
import { i as s, n as c, r as l, t as u } from "./header-
|
|
4
|
+
import { i as s, n as c, r as l, t as u } from "./header-BYNzxXCo.js";
|
|
5
5
|
import { n as d } from "./card-Ddu0sQ0f.js";
|
|
6
6
|
import { n as f } from "./checkbox-D9-KugOh.js";
|
|
7
7
|
import { n as p } from "./radiobutton-DMvVv81Y.js";
|
|
@@ -10,22 +10,22 @@ import { n as h } from "./loader-Y8V3Q82X.js";
|
|
|
10
10
|
import { n as g, r as _ } from "./accordion-BHVzR-6Z.js";
|
|
11
11
|
import { n as v } from "./input-wrapper-CHwWQgZP.js";
|
|
12
12
|
import { n as y } from "./textarea-Du1Z9JUu.js";
|
|
13
|
-
import { n as b } from "./
|
|
14
|
-
import { n as x } from "./
|
|
15
|
-
import { n as S } from "./
|
|
16
|
-
import { n as C } from "./
|
|
17
|
-
import { n as w } from "./
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import { n as D } from "./
|
|
21
|
-
import { n as O } from "./
|
|
22
|
-
import { n as k } from "./
|
|
23
|
-
import { n as A } from "./
|
|
24
|
-
import { n as j } from "./
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import { n as I } from "./
|
|
28
|
-
import { n as L } from "./
|
|
13
|
+
import { n as b } from "./textinput-CRlErItw.js";
|
|
14
|
+
import { n as x } from "./messagebox-wJcXW5hI.js";
|
|
15
|
+
import { n as S } from "./calendar-BX3n3vhs.js";
|
|
16
|
+
import { n as C } from "./combobox-BAkblu9M.js";
|
|
17
|
+
import { n as w } from "./button-CF9k3ARf.js";
|
|
18
|
+
import { n as T } from "./backlink-Dlkyj0ns.js";
|
|
19
|
+
import { t as E } from "./breadcrumbs-Bfv8W2CF.js";
|
|
20
|
+
import { n as D } from "./tag-BOTH9kMz.js";
|
|
21
|
+
import { n as O } from "./helptext-BVYv8Lm9.js";
|
|
22
|
+
import { n as k } from "./checkbox-group-Dz1ypmbU.js";
|
|
23
|
+
import { n as A } from "./fileupload-CEwnpxZj.js";
|
|
24
|
+
import { n as j } from "./modal-BafCTC4M.js";
|
|
25
|
+
import { n as M } from "./progressbar-BukfOcRk.js";
|
|
26
|
+
import { a as N, t as P } from "./datepicker-9dmdHweu.js";
|
|
27
|
+
import { n as F, t as I } from "./footer-DZ4aA6fj.js";
|
|
28
|
+
import { n as L } from "./link-BU6t5Tt9.js";
|
|
29
29
|
import { n as R } from "./searchinput-BV2C1VbN.js";
|
|
30
30
|
import { n as z } from "./header-menu-DxOSBiTJ.js";
|
|
31
31
|
import { n as B } from "./heading-B1Ey3XzB.js";
|
|
@@ -34,4 +34,4 @@ import { n as H } from "./radio-group-Bg6ODpT3.js";
|
|
|
34
34
|
import { n as U, r as W } from "./tabs-B2RjklQl.js";
|
|
35
35
|
import { n as G } from "./select-DKBfPgJB.js";
|
|
36
36
|
import { t as K } from "./timepicker-DVqTAxt0.js";
|
|
37
|
-
export { _ as PktAccordion, g as PktAccordionItem, o as PktAlert,
|
|
37
|
+
export { _ as PktAccordion, g as PktAccordionItem, o as PktAlert, T as PktBackLink, E as PktBreadcrumbs, w as PktButton, S as PktCalendar, d as PktCard, f as PktCheckbox, k as PktCheckboxGroup, C as PktCombobox, a as PktConsent, N as PktDateTags, P as PktDatepicker, A as PktFileUpload, F as PktFooter, I as PktFooterSimple, u as PktHeader, c as PktHeaderGlobal, z as PktHeaderMenu, l as PktHeaderService, s as PktHeaderUserMenu, B as PktHeading, O as PktHelptext, m as PktIcon, v as PktInputWrapper, L as PktLink, V as PktLinkCard, h as PktLoader, x as PktMessagebox, j as PktModal, M as PktProgressbar, p as PktRadioButton, p as PktRadiobutton, H as PktRadioGroup, R as PktSearchInput, G as PktSelect, U as PktTabItem, W as PktTabs, D as PktTag, y as PktTextarea, b as PktTextinput, K as PktTimepicker, r as getPktStrings, i as pktStringsNb, t as resetPktStrings, e as setPktStrings, n as subscribePktStrings };
|
package/dist/pkt-modal.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./modal-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./modal-C5AiVm5g.cjs");exports.PktModal=e.n,exports.default=e.t;
|
package/dist/pkt-modal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { n as PktModal, t as default } from "./modal-
|
|
1
|
+
export { n as PktModal, t as default } from "./modal-BafCTC4M.js";
|
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-C5KWIB21.cjs");exports.PktTextinput=e.n,exports.default=e.t;
|
package/dist/pkt-textinput.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { n as PktTextinput, t as default } from "./textinput-
|
|
1
|
+
export { n as PktTextinput, t as default } from "./textinput-CRlErItw.js";
|
|
@@ -43,6 +43,8 @@ export type { IHelptextProps, ITagOptionalRequiredProps, IFormFieldLabelProps, I
|
|
|
43
43
|
export { COUNTER_POSITIONS, INPUT_WRAPPER_DEFAULTS } from './input-wrapper';
|
|
44
44
|
export { TEXTAREA_DEFAULTS } from './textarea';
|
|
45
45
|
export type { IPktTextareaBase, ITextareaSpecProps } from './textarea';
|
|
46
|
+
export { TEXTINPUT_DEFAULTS, TEXTINPUT_TYPES } from './textinput';
|
|
47
|
+
export type { TPktTextinputType, IPktTextinputBase, ITextinputSpecProps } from './textinput';
|
|
46
48
|
export type { TPktCounterPosition, IPktInputWrapperBase, IInputWrapperSpecProps, } from './input-wrapper';
|
|
47
49
|
export type { TTagSkin } from './skin';
|
|
48
50
|
export { MESSAGEBOX_SKINS, MESSAGEBOX_DEFAULTS } from './messagebox';
|
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Visual skins for pkt-table — shared runtime source for types, specs, and Preview.
|
|
10
10
|
*/
|
|
11
|
-
export declare const TABLE_SKINS: readonly ['basic', 'zebra
|
|
12
|
-
export type TPktTableSkin = (typeof TABLE_SKINS)[number];
|
|
11
|
+
export declare const TABLE_SKINS: readonly ['basic', 'zebra'];
|
|
12
|
+
export type TPktTableSkin = (typeof TABLE_SKINS)[number] | 'zebra-blue';
|
|
13
13
|
/**
|
|
14
14
|
* Table props shared by React and typed component specs.
|
|
15
15
|
*/
|
|
16
16
|
export interface IPktTableBase {
|
|
17
17
|
compact?: boolean;
|
|
18
|
+
/** `'zebra-blue'` er deprecated og fjernes i en kommende versjon. Bruk `'zebra'`. */
|
|
18
19
|
skin?: TPktTableSkin;
|
|
19
20
|
responsiveView?: boolean;
|
|
20
21
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* textinput.ts
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for pkt-textinput.
|
|
5
|
+
* Used by React, Elements, and typed component specs.
|
|
6
|
+
*/
|
|
7
|
+
import type { IFormFieldCommonProps } from './form-field';
|
|
8
|
+
import type { TPktInputSize } from './size';
|
|
9
|
+
/** `type`-verdier som dokumenteres for pkt-textinput. Komponenten godtar fortsatt en vanlig streng. */
|
|
10
|
+
export declare const TEXTINPUT_TYPES: readonly ['color', 'date', 'datetime-local', 'email', 'file', 'month', 'number', 'password', 'search', 'tel', 'text', 'time', 'url', 'week'];
|
|
11
|
+
export type TPktTextinputType = (typeof TEXTINPUT_TYPES)[number];
|
|
12
|
+
/**
|
|
13
|
+
* Textinput props shared by React, Elements, and typed component specs.
|
|
14
|
+
*
|
|
15
|
+
* @remarks Keys follow the React prop names. Elements uses lowercase properties instead:
|
|
16
|
+
* `autocomplete`, `minlength`, `maxlength` and `readonly`.
|
|
17
|
+
*
|
|
18
|
+
* React requires `id` and `label`, and widens `helptext`, `helptextDropdown` and
|
|
19
|
+
* `errorMessage` to `ReactNode`.
|
|
20
|
+
* Elements widens `label`, `placeholder`, `size`,
|
|
21
|
+
* `prefix`, `suffix`, `iconNameRight`, `ariaDescribedby`, `ariaLabelledby` and
|
|
22
|
+
* `helptextDropdownButton` to `| null`, `useWrapper` to `Booleanish`, and omits
|
|
23
|
+
* `form`. On Elements `form` is a getter that returns the associated
|
|
24
|
+
* `HTMLFormElement`, not the form id.
|
|
25
|
+
*
|
|
26
|
+
* `counter` and `hasFieldset` are tri-state: `null` means the component derives the value.
|
|
27
|
+
*/
|
|
28
|
+
export interface IPktTextinputBase extends IFormFieldCommonProps<'forms' | 'validation'> {
|
|
29
|
+
id?: string;
|
|
30
|
+
name?: string;
|
|
31
|
+
form?: string;
|
|
32
|
+
value?: string;
|
|
33
|
+
placeholder?: string;
|
|
34
|
+
type?: string;
|
|
35
|
+
/** Bredde i antall tegn (HTML-attributtet `size`), ikke den visuelle `inputSize`. */
|
|
36
|
+
size?: number;
|
|
37
|
+
omitSearchIcon?: boolean;
|
|
38
|
+
prefix?: string;
|
|
39
|
+
suffix?: string;
|
|
40
|
+
iconNameRight?: string;
|
|
41
|
+
min?: number | string;
|
|
42
|
+
max?: number | string;
|
|
43
|
+
minLength?: number;
|
|
44
|
+
maxLength?: number;
|
|
45
|
+
step?: number | string;
|
|
46
|
+
readOnly?: boolean;
|
|
47
|
+
autoComplete?: string;
|
|
48
|
+
required?: boolean;
|
|
49
|
+
ariaDescribedby?: string;
|
|
50
|
+
ariaLabelledby?: string;
|
|
51
|
+
inline?: boolean;
|
|
52
|
+
fullwidth?: boolean;
|
|
53
|
+
useWrapper?: boolean;
|
|
54
|
+
counter?: boolean | null;
|
|
55
|
+
counterMaxLength?: number;
|
|
56
|
+
inputSize?: TPktInputSize;
|
|
57
|
+
hasFieldset?: boolean | null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Documented Textinput props (subset of `IPktTextinputBase`).
|
|
61
|
+
* Used for typed component specs in documentation.
|
|
62
|
+
*/
|
|
63
|
+
export type ITextinputSpecProps = Pick<IPktTextinputBase, 'label' | 'name' | 'form' | 'placeholder' | 'helptext' | 'helptextDropdown' | 'helptextDropdownButton' | 'size' | 'type' | 'omitSearchIcon' | 'value' | 'autoComplete' | 'suffix' | 'prefix' | 'iconNameRight' | 'min' | 'max' | 'minLength' | 'maxLength' | 'step' | 'readOnly' | 'ariaLabelledby' | 'ariaDescribedby' | 'required' | 'requiredTag' | 'requiredText' | 'optionalTag' | 'optionalText' | 'tagText' | 'hasError' | 'errorMessage' | 'disabled' | 'inline' | 'fullwidth' | 'useWrapper' | 'id' | 'counter' | 'counterMaxLength' | 'inputSize' | 'hasFieldset'>;
|
|
64
|
+
/**
|
|
65
|
+
* Default values for pkt-textinput. Single source of truth for both frameworks.
|
|
66
|
+
* `counter` and `hasFieldset` are intentionally absent — `null` lets the component derive them.
|
|
67
|
+
*/
|
|
68
|
+
export declare const TEXTINPUT_DEFAULTS: {
|
|
69
|
+
readonly type: 'text';
|
|
70
|
+
readonly autoComplete: 'off';
|
|
71
|
+
readonly omitSearchIcon: false;
|
|
72
|
+
readonly required: false;
|
|
73
|
+
readonly readOnly: false;
|
|
74
|
+
readonly requiredTag: false;
|
|
75
|
+
readonly optionalTag: false;
|
|
76
|
+
readonly hasError: false;
|
|
77
|
+
readonly disabled: false;
|
|
78
|
+
readonly inline: false;
|
|
79
|
+
readonly fullwidth: false;
|
|
80
|
+
readonly useWrapper: true;
|
|
81
|
+
readonly inputSize: 'medium';
|
|
82
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./element-with-slot-B0Vp_OuR.cjs");require("./icon-CrG6o7ZE.cjs");const r=require("./input-wrapper-QzdntWJX.cjs"),i=require("./if-defined-CiML3MTM.cjs"),a=require("./ref-CB7e9nMY.cjs"),o=require("./input-element-D82laWtR.cjs");var s=class extends o.t{constructor(...e){super(...e),this.inputRef=a.t(),this.value=``,this.type
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./element-with-slot-B0Vp_OuR.cjs");require("./shared-types-BvRk9kiK.cjs"),require("./icon-CrG6o7ZE.cjs");const r=require("./input-wrapper-QzdntWJX.cjs"),i=require("./if-defined-CiML3MTM.cjs"),a=require("./ref-CB7e9nMY.cjs"),o=require("./input-element-D82laWtR.cjs");var s={type:`text`,autoComplete:`off`,omitSearchIcon:!1,required:!1,readOnly:!1,requiredTag:!1,optionalTag:!1,hasError:!1,disabled:!1,inline:!1,fullwidth:!1,useWrapper:!0,inputSize:`medium`},c=class extends o.t{constructor(...e){super(...e),this.inputRef=a.t(),this.value=``,this.type=s.type,this.size=null,this.autocomplete=s.autoComplete,this.iconNameRight=null,this.prefix=null,this.suffix=null,this.omitSearchIcon=s.omitSearchIcon,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`)&&typeof this.value!=`string`&&!Array.isArray(this.value)&&(this.value=this.coerceToString(this.value)),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 o=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
|
${n.n(this,[`helptext`])}
|
|
4
4
|
.strings=${this.strings}
|
|
@@ -69,4 +69,4 @@ const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),
|
|
|
69
69
|
${!this.suffix&&o?e._`<pkt-icon class="pkt-input-icon" name="magnifying-glass-big"></pkt-icon>`:e.h}
|
|
70
70
|
</div>
|
|
71
71
|
</pkt-input-wrapper>
|
|
72
|
-
`}};e.n([e.u({type:String,reflect:!0})],
|
|
72
|
+
`}};e.n([e.u({type:String,reflect:!0})],c.prototype,`value`,void 0),e.n([e.u({type:String})],c.prototype,`type`,void 0),e.n([e.u({type:Number})],c.prototype,`size`,void 0),e.n([e.u({type:String})],c.prototype,`autocomplete`,void 0),e.n([e.u({type:String})],c.prototype,`iconNameRight`,void 0),e.n([e.u({type:String})],c.prototype,`prefix`,void 0),e.n([e.u({type:String})],c.prototype,`suffix`,void 0),e.n([e.u({type:Boolean})],c.prototype,`omitSearchIcon`,void 0),e.n([e.l()],c.prototype,`counterCurrent`,void 0);try{e.d(`pkt-textinput`)(c)}catch{console.warn(`Forsøker å definere <pkt-textinput>, men den er allerede definert`)}var l=c;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
|
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-ckeMVgMz.js";
|
|
2
2
|
import { t as o } from "./class-map-BkEYw5uE.js";
|
|
3
3
|
import { n as s } from "./element-with-slot-Dp2Gzv-Q.js";
|
|
4
|
+
import "./shared-types-A6iGIX-f.js";
|
|
4
5
|
import "./icon-CUU42bZ0.js";
|
|
5
6
|
import { r as c } from "./input-wrapper-CHwWQgZP.js";
|
|
6
7
|
import { t as l } from "./if-defined-D18nY_K_.js";
|
|
7
8
|
import { n as u, t as d } from "./ref-D4OwQYdf.js";
|
|
8
9
|
import { t as f } from "./input-element-DczlJQb1.js";
|
|
9
|
-
//#region
|
|
10
|
-
var p =
|
|
10
|
+
//#region ../../shared-types/textinput.ts
|
|
11
|
+
var p = {
|
|
12
|
+
type: "text",
|
|
13
|
+
autoComplete: "off",
|
|
14
|
+
omitSearchIcon: !1,
|
|
15
|
+
required: !1,
|
|
16
|
+
readOnly: !1,
|
|
17
|
+
requiredTag: !1,
|
|
18
|
+
optionalTag: !1,
|
|
19
|
+
hasError: !1,
|
|
20
|
+
disabled: !1,
|
|
21
|
+
inline: !1,
|
|
22
|
+
fullwidth: !1,
|
|
23
|
+
useWrapper: !0,
|
|
24
|
+
inputSize: "medium"
|
|
25
|
+
}, m = class extends f {
|
|
11
26
|
constructor(...e) {
|
|
12
|
-
super(...e), this.inputRef = d(), this.value = "", this.type =
|
|
27
|
+
super(...e), this.inputRef = d(), this.value = "", this.type = p.type, this.size = null, this.autocomplete = p.autoComplete, this.iconNameRight = null, this.prefix = null, this.suffix = null, this.omitSearchIcon = p.omitSearchIcon, this.counterCurrent = 0;
|
|
13
28
|
}
|
|
14
29
|
attributeChangedCallback(e, t, n) {
|
|
15
30
|
e === "value" && this.value !== t && (this.counterCurrent = n ? n.length : 0), super.attributeChangedCallback(e, t, n);
|
|
@@ -122,14 +137,14 @@ var p = class extends f {
|
|
|
122
137
|
i([a({
|
|
123
138
|
type: String,
|
|
124
139
|
reflect: !0
|
|
125
|
-
})],
|
|
140
|
+
})], m.prototype, "value", void 0), i([a({ type: String })], m.prototype, "type", void 0), i([a({ type: Number })], m.prototype, "size", void 0), i([a({ type: String })], m.prototype, "autocomplete", void 0), i([a({ type: String })], m.prototype, "iconNameRight", void 0), i([a({ type: String })], m.prototype, "prefix", void 0), i([a({ type: String })], m.prototype, "suffix", void 0), i([a({ type: Boolean })], m.prototype, "omitSearchIcon", void 0), i([r()], m.prototype, "counterCurrent", void 0);
|
|
126
141
|
try {
|
|
127
|
-
t("pkt-textinput")(
|
|
142
|
+
t("pkt-textinput")(m);
|
|
128
143
|
} catch {
|
|
129
144
|
console.warn("Forsøker å definere <pkt-textinput>, men den er allerede definert");
|
|
130
145
|
}
|
|
131
146
|
//#endregion
|
|
132
147
|
//#region src/components/textinput/index.ts
|
|
133
|
-
var
|
|
148
|
+
var h = m;
|
|
134
149
|
//#endregion
|
|
135
|
-
export {
|
|
150
|
+
export { m as n, h as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.19.1",
|
|
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",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@lit-labs/router": "^0.1.4",
|
|
38
|
-
"@oslokommune/punkt-assets": "^19.
|
|
38
|
+
"@oslokommune/punkt-assets": "^19.19.0",
|
|
39
39
|
"@testing-library/dom": "^10.4.2",
|
|
40
40
|
"@testing-library/jest-dom": "^7.0.1",
|
|
41
41
|
"@types/jest-axe": "^3.5.9",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"engines": {
|
|
79
79
|
"node": "^22.19.0 || ^24.0.0 || ^26.0.0"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "8373ea76c93221f22496eb298b2382b41bef53ab"
|
|
82
82
|
}
|
|
@@ -67,7 +67,7 @@ describe('PktTextinput', () => {
|
|
|
67
67
|
const { textinput } = await createTextinputTest()
|
|
68
68
|
expect(textinput.type).toBe('text')
|
|
69
69
|
expect(textinput.value).toBe('')
|
|
70
|
-
expect(textinput.autocomplete).toBe(
|
|
70
|
+
expect(textinput.autocomplete).toBe('off')
|
|
71
71
|
})
|
|
72
72
|
|
|
73
73
|
test('renders input element', async () => {
|
|
@@ -10,6 +10,7 @@ import { forwardSlots } from '@/directives/slot-content'
|
|
|
10
10
|
import '@/components/input-wrapper'
|
|
11
11
|
import '@/components/icon'
|
|
12
12
|
import { describedByIds } from 'shared-utils/forms/described-by'
|
|
13
|
+
import { TEXTINPUT_DEFAULTS, type Booleanish, type IPktTextinputBase } from 'shared-types'
|
|
13
14
|
|
|
14
15
|
type Props = ElementProps<
|
|
15
16
|
PktTextinput,
|
|
@@ -23,17 +24,58 @@ type Props = ElementProps<
|
|
|
23
24
|
| 'omitSearchIcon'
|
|
24
25
|
>
|
|
25
26
|
|
|
26
|
-
export
|
|
27
|
+
export interface IPktTextinput extends Omit<
|
|
28
|
+
IPktTextinputBase,
|
|
29
|
+
| 'form'
|
|
30
|
+
| 'label'
|
|
31
|
+
| 'placeholder'
|
|
32
|
+
| 'size'
|
|
33
|
+
| 'prefix'
|
|
34
|
+
| 'suffix'
|
|
35
|
+
| 'iconNameRight'
|
|
36
|
+
| 'min'
|
|
37
|
+
| 'max'
|
|
38
|
+
| 'minLength'
|
|
39
|
+
| 'maxLength'
|
|
40
|
+
| 'step'
|
|
41
|
+
| 'readOnly'
|
|
42
|
+
| 'autoComplete'
|
|
43
|
+
| 'ariaDescribedby'
|
|
44
|
+
| 'ariaLabelledby'
|
|
45
|
+
| 'helptextDropdownButton'
|
|
46
|
+
| 'useWrapper'
|
|
47
|
+
> {
|
|
48
|
+
label?: string | null
|
|
49
|
+
placeholder?: string | null
|
|
50
|
+
size?: number | null
|
|
51
|
+
prefix?: string | null
|
|
52
|
+
suffix?: string | null
|
|
53
|
+
iconNameRight?: string | null
|
|
54
|
+
min?: string | number | null
|
|
55
|
+
max?: string | number | null
|
|
56
|
+
minlength?: number | null
|
|
57
|
+
maxlength?: number | null
|
|
58
|
+
step?: number | null
|
|
59
|
+
readonly?: boolean
|
|
60
|
+
autocomplete?: string | null
|
|
61
|
+
ariaDescribedby?: string | null
|
|
62
|
+
ariaLabelledby?: string | null
|
|
63
|
+
/** @deprecated Bruk `strings={{ forms: { readMore: '…' } }}` eller `setPktStrings()`. */
|
|
64
|
+
helptextDropdownButton?: string | null
|
|
65
|
+
useWrapper?: Booleanish
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export class PktTextinput extends PktInputElement<Props> implements IPktTextinput {
|
|
27
69
|
inputRef: Ref<HTMLTextAreaElement> = createRef()
|
|
28
70
|
|
|
29
71
|
@property({ type: String, reflect: true }) value: string = ''
|
|
30
|
-
@property({ type: String }) type: string =
|
|
72
|
+
@property({ type: String }) type: string = TEXTINPUT_DEFAULTS.type
|
|
31
73
|
@property({ type: Number }) size: number | null = null
|
|
32
|
-
@property({ type: String }) autocomplete: string | null =
|
|
74
|
+
@property({ type: String }) autocomplete: string | null = TEXTINPUT_DEFAULTS.autoComplete
|
|
33
75
|
@property({ type: String }) iconNameRight: string | null = null
|
|
34
76
|
@property({ type: String }) prefix: string | null = null
|
|
35
77
|
@property({ type: String }) suffix: string | null = null
|
|
36
|
-
@property({ type: Boolean }) omitSearchIcon: boolean =
|
|
78
|
+
@property({ type: Boolean }) omitSearchIcon: boolean = TEXTINPUT_DEFAULTS.omitSearchIcon
|
|
37
79
|
|
|
38
80
|
@state() counterCurrent = 0
|
|
39
81
|
|
package/dist/modal-DyaAoMeB.cjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./element-with-slot-B0Vp_OuR.cjs");require("./icon-CrG6o7ZE.cjs");const r=require("./if-defined-CiML3MTM.cjs"),i=require("./ref-CB7e9nMY.cjs"),a=require("./utils-63cRpWut.cjs"),o=require("./scroll-lock-x0VxhKWZ.cjs");var s={name:`pkt-modal`,react:`PktModal`,"css-class":`pkt-modal`,isElement:!0,isPureReact:!0,events:{"background-click":{description:`Event som trigges når bakgrunnen trykkes på`},close:{description:`Event som trigges når meldingsboksen lukkes`}},props:{open:{name:`Åpen`,description:`Deklarativ styring av modalens åpen/lukket-tilstand. Kan brukes i stedet for showModal()/close()-metodene.`,type:`boolean`,category:`tech`,default:!1},headingText:{name:`Heading text`,description:`Heading tekst på modalen`,type:`string`,category:`contents`},headingIconName:{name:`Ikon i overskriften`,description:`Navn på ikonet som vises foran overskriften. Vises bare når headingText er satt.`,type:`icon`,category:`ui`},headingIconPath:{name:`Ikon-sti for overskriften`,description:`Overstyr stien til ikonet i overskriften. Kan også settes globalt med window.pktIconPath.`,type:`string`,category:`tech`},hideCloseButton:{name:`Gjem 'Lukk'-knapp`,description:`Gjemmer lukkeknappen. Dersom denne er satt til true, vil ikke lukkeknappen vises, og dermed er det viktig at man tilbyr en annen måte som f.eks. en knapp for å lukke modalen på.`,type:`boolean`,category:`ui`,default:!1},closeOnBackdropClick:{name:`Lukk modalen når bakgrunnen trykkes på`,description:`Lukk modalen når bakgrunnen trykkes på`,type:`boolean`,category:`tech`,default:!1},closeButtonSkin:{name:`Stil på lukkeknappen`,description:`Stil på lukkeknappen`,type:[`blue`,`yellow-filled`],category:`ui`,default:`blue`},size:{name:`Størrelse`,description:`Størrelsen på modalen`,type:[`small`,`medium`,`large`,`fit-content`],category:`ui`,default:`medium`},variant:{name:`Variant`,description:`Standard dialog eller skuff`,type:[`dialog`,`drawer`],category:`ui`,default:`dialog`},drawerPosition:{name:`Skuffposisjon`,description:`Posisjonen til skuffen`,type:[`left`,`right`],category:`ui`,default:`right`},transparentBackdrop:{name:`Gjennomsiktig bakgrunn`,description:`Bakgrunnen er gjennomsiktig`,type:`boolean`,category:`ui`,default:!1},removePadding:{name:`Fjern padding`,description:`Fjerner paddingen rundt innholdet i modalen`,type:`boolean`,category:`ui`,default:!1}},slots:{default:{description:`Innholdet i meldingen. Her tilbyr vi støtteklasser for å style 1-3 knapper i modalen.`}}},c=class extends n.t{constructor(){super(),this.open=!1,this.headingText=``,this.removePadding=!1,this.hideCloseButton=s.props.hideCloseButton.default,this.closeOnBackdropClick=s.props.closeOnBackdropClick.default,this.closeButtonSkin=`blue`,this.size=s.props.size.default,this.variant=`dialog`,this.drawerPosition=`right`,this.transparentBackdrop=!1,this.dialogRef=i.t(),this._scrollLockToken=o.t(),this._idSuffix=a.n(),this._headingId=`pkt-modal__headingText-${this._idSuffix}`,this._contentId=`pkt-modal__content-${this._idSuffix}`,this._isOpen=!1,this.close=(e,t=!1)=>{if(!this._isOpen)return;this._isOpen=!1,this.open=!1,o.n(this._scrollLockToken,!1);let n=document.activeElement;n&&!this.isElementInViewport(n)&&n.scrollIntoView({behavior:`smooth`,block:`nearest`}),this.dispatchEvent(new CustomEvent(`close`,{detail:{origin:e},bubbles:!0,composed:!0})),t||this.dialogRef.value?.close()},this.showModal=(e=null)=>{this._isOpen=!0,this.open=!0,this.dialogRef.value?.showModal(),o.n(this._scrollLockToken,!0),this.dispatchEvent(new CustomEvent(`showModal`,{detail:{origin:e},bubbles:!0,composed:!0}))},this._isOpen=!1}async connectedCallback(){super.connectedCallback(),document.addEventListener(`keydown`,this.handleKeyDown.bind(this)),document.addEventListener(`click`,this.handleBackdropClick.bind(this))}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`click`,this.handleBackdropClick),o.n(this._scrollLockToken,!1)}updated(e){super.updated(e),e.has(`open`)&&(this.open&&!this._isOpen?this.showModal():!this.open&&this._isOpen&&this.close(new Event(`close`),!1))}async firstUpdated(e){super.firstUpdated(e),this.dialogRef.value&&!window.HTMLDialogElement&&!this.dialogRef.value.showModal&&(`document`in window&&`createElement`in document&&(await Promise.resolve().then(()=>require("./dialog-polyfill.esm-CW51hN2p.cjs")).then(e=>e.default)).registerDialog(this.dialogRef.value),this.dialogRef.value.addEventListener(`close`,()=>{this.close(new Event(`close`),!0)}))}handleKeyDown(e){e.key===`Escape`&&this.close(e)}handleBackdropClick(e){this.closeOnBackdropClick&&e.target===this.dialogRef?.value&&this.close(e)}isElementInViewport(e){let t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}render(){let a={"pkt-modal":!0,"pkt-modal--removePadding":this.removePadding??!1,"pkt-modal--noHeadingText":this.headingText===``||this.headingText===void 0,"pkt-modal--noShadow":this.closeButtonSkin===`yellow-filled`,"pkt-modal--transparentBackdrop":this.transparentBackdrop??!1,[`pkt-modal--${this.size}`]:this.size!==void 0,[`pkt-modal__${this.variant}`]:this.variant!==void 0,[`pkt-modal__drawer--${this.drawerPosition}`]:this.variant===`drawer`},o={"pkt-modal__headingText":!0,"pkt-txt-24":!0,"pkt-modal__headingText--hasIcon":!!this.headingIconName},s=this.headingIconName?e._`<pkt-icon
|
|
2
|
-
class="pkt-modal__headingIcon"
|
|
3
|
-
name=${this.headingIconName}
|
|
4
|
-
path=${r.t(this.headingIconPath)}
|
|
5
|
-
></pkt-icon>`:e.h,c={"pkt-modal__content":!0,"pkt-txt-18-light":!0},l=this.closeButtonSkin===`blue`,u={"pkt-modal__closeButton":!0,[`pkt-modal__closeButton--${this.closeButtonSkin}`]:!0};return e._`
|
|
6
|
-
<dialog
|
|
7
|
-
class=${t.t(a)}
|
|
8
|
-
${i.n(this.dialogRef)}
|
|
9
|
-
aria-labelledby=${this.headingText?this._headingId:e.h}
|
|
10
|
-
aria-describedby=${this._contentId}
|
|
11
|
-
@close=${e=>this.close(e,!0)}
|
|
12
|
-
>
|
|
13
|
-
<div class="pkt-modal__wrapper">
|
|
14
|
-
${this.headingText||!this.hideCloseButton?e._`<div class="pkt-modal__header">
|
|
15
|
-
<div class="pkt-modal__header-background"></div>
|
|
16
|
-
${this.headingText?e._`<h1 id=${this._headingId} class=${t.t(o)}>
|
|
17
|
-
${s}${this.headingText}
|
|
18
|
-
</h1>`:e._`<div class="pkt-modal__headingText"></div>`}
|
|
19
|
-
${this.hideCloseButton?e._`<div class="pkt-modal__noCloseButton"></div>`:e._`<div class="${t.t(u)}">
|
|
20
|
-
<pkt-button
|
|
21
|
-
@click=${e=>this.close(e)}
|
|
22
|
-
aria-label=${this.pktStrings.get(`generic`).close}
|
|
23
|
-
iconname="close"
|
|
24
|
-
variant="icon-only"
|
|
25
|
-
size="medium"
|
|
26
|
-
skin=${l?`tertiary`:`primary`}
|
|
27
|
-
>
|
|
28
|
-
${this.pktStrings.get(`generic`).close}
|
|
29
|
-
</pkt-button>
|
|
30
|
-
</div>`}
|
|
31
|
-
</div>`:e.h}
|
|
32
|
-
<div class="pkt-modal__container">
|
|
33
|
-
<div id=${this._contentId} class=${t.t(c)}>${n.i(this)}</div>
|
|
34
|
-
</div>
|
|
35
|
-
</div>
|
|
36
|
-
</dialog>
|
|
37
|
-
`}};e.n([e.u({type:Boolean,reflect:!0})],c.prototype,`open`,void 0),e.n([e.u({type:String})],c.prototype,`headingText`,void 0),e.n([e.u({type:String})],c.prototype,`headingIconName`,void 0),e.n([e.u({type:String})],c.prototype,`headingIconPath`,void 0),e.n([e.u({type:Boolean})],c.prototype,`removePadding`,void 0),e.n([e.u({type:Boolean})],c.prototype,`hideCloseButton`,void 0),e.n([e.u({type:Boolean})],c.prototype,`closeOnBackdropClick`,void 0),e.n([e.u({type:String})],c.prototype,`closeButtonSkin`,void 0),e.n([e.u({type:String})],c.prototype,`size`,void 0),e.n([e.u({type:String})],c.prototype,`variant`,void 0),e.n([e.u({type:String})],c.prototype,`drawerPosition`,void 0),e.n([e.u({type:Boolean})],c.prototype,`transparentBackdrop`,void 0);try{e.d(`pkt-modal`)(c)}catch{console.warn(`Forsøker å definere <pkt-modal>, men den er allerede definert`)}var l=c;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
|