@oslokommune/punkt-elements 18.3.0 → 18.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/dist/{accordion-CcUosZjL.js → accordion-4eAsO-Sr.js} +5 -5
- package/dist/{accordion-k0pWTG1X.cjs → accordion-DOa5vubf.cjs} +1 -1
- package/dist/{alert-Bmaly2Yo.js → alert-BUpd4yWu.js} +13 -7
- package/dist/alert-BYDWYgyL.cjs +35 -0
- package/dist/{async-directive-COqx0IYj.js → async-directive-CAZoZMez.js} +2 -2
- package/dist/{async-directive-DN2eg9gA.cjs → async-directive-DlB0Sf4j.cjs} +1 -1
- package/dist/{backlink-C_ZO-ZbR.js → backlink-BYUtL8cO.js} +3 -3
- package/dist/{backlink-Ch64Pivx.cjs → backlink-CA5R69FX.cjs} +1 -1
- package/dist/{breadcrumbs-CF_gAbUk.js → breadcrumbs-BlRDuZbZ.js} +2 -2
- package/dist/{breadcrumbs-CzzbardP.cjs → breadcrumbs-HG9wzGtr.cjs} +1 -1
- package/dist/button-C5BYwmoo.cjs +30 -0
- package/dist/{button-C1CQSASU.js → button-Dk6ued7E.js} +7 -7
- package/dist/{calendar-BxF81kB9.cjs → calendar-Cc0bjLPC.cjs} +1 -1
- package/dist/{calendar-DRmxORMc.js → calendar-iXilYFBa.js} +3 -3
- package/dist/{card-Cg1daj05.cjs → card-DMKvuvNv.cjs} +1 -1
- package/dist/{card-W_Jb0Tlo.js → card-DgRvtnnk.js} +7 -7
- package/dist/{checkbox-BHQv8lHq.cjs → checkbox--nYvm_Pc.cjs} +1 -1
- package/dist/{checkbox-BQw2dMSX.js → checkbox-CZTR2qHf.js} +4 -4
- package/dist/{class-map-C33ixq7O.cjs → class-map-BEib48YL.cjs} +1 -1
- package/dist/{class-map-wh4Yi3oj.js → class-map-BL_YL_Ed.js} +1 -1
- package/dist/{combobox-BpZow9OU.cjs → combobox-DQ0yPhEy.cjs} +1 -1
- package/dist/{combobox-C9wwnUfM.js → combobox-DuTrCV1l.js} +12 -12
- package/dist/components/button/button.d.ts +4 -21
- package/dist/components/button/index.d.ts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/linkcard/linkcard.d.ts +4 -9
- package/dist/{consent-CPtr7cBw.cjs → consent-agJtEZHc.cjs} +1 -1
- package/dist/{consent-D8MrqGKk.js → consent-yXeRsyAl.js} +2 -2
- package/dist/{datepicker-D4YnAtWG.js → datepicker-C7KtgfDs.js} +11 -11
- package/dist/{datepicker-DaoumZT9.cjs → datepicker-CYndy_BG.cjs} +1 -1
- package/dist/{directive-helpers-BWSAVe00.js → directive-helpers-CohhRNQz.js} +1 -1
- package/dist/{directive-helpers-C6J4AkFk.cjs → directive-helpers-Ddr8wUxL.cjs} +1 -1
- package/dist/docs/components/button.d.ts +0 -1
- package/dist/{element-DiFhBcIl.cjs → element-DRc10X2R.cjs} +1 -1
- package/dist/{element-WEzISABa.js → element-e2MAMNEP.js} +1 -0
- package/dist/{element-with-slot-BKYUx4gb.js → element-with-slot-COOwQUxM.js} +2 -2
- package/dist/{element-with-slot-CBK4zrdN.cjs → element-with-slot-MkibfzHp.cjs} +1 -1
- package/dist/{fileupload-DEHSETw0.js → fileupload-BcJSBp9e.js} +8 -8
- package/dist/{fileupload-DWu6FIMv.cjs → fileupload-CmxozEde.cjs} +1 -1
- package/dist/{footer-BJLEw6Ab.js → footer-DSrWdWxm.js} +4 -4
- package/dist/{footer-D_yYWkQ6.cjs → footer-J-fOEOj5.cjs} +1 -1
- package/dist/{header-B7_4Cwaq.cjs → header-DmJiygel.cjs} +1 -1
- package/dist/{header-DLVq7-dM.js → header-EtPWdXaI.js} +11 -11
- package/dist/{header-menu-BsrrTjpT.js → header-menu-Dgem4HO9.js} +4 -4
- package/dist/{header-menu-m7nOOC1g.cjs → header-menu-DpQbRKcm.cjs} +1 -1
- package/dist/{heading-_RPw2UW9.cjs → heading-BAoIzzJO.cjs} +1 -1
- package/dist/{heading-DSArgrDK.js → heading-NYqciBEJ.js} +2 -2
- package/dist/{helptext-dtVVufNH.js → helptext-BzLJKMMO.js} +4 -4
- package/dist/{helptext-QMVsW5g6.cjs → helptext-Ds8Q9IGV.cjs} +1 -1
- package/dist/{icon-DIavy2cB.cjs → icon-DBFTFd-J.cjs} +1 -1
- package/dist/{icon-DEtOSWRK.js → icon-jEFbKTB_.js} +1 -1
- package/dist/if-defined-BeVQnl3C.cjs +1 -0
- package/dist/{if-defined-BmnvvxtR.js → if-defined-r8tKY4tG.js} +1 -1
- package/dist/{input-element-IBypGOaV.js → input-element-DxHRTZ3K.js} +2 -2
- package/dist/{input-element-DQY1Rpbp.cjs → input-element-KpXXnGi0.cjs} +1 -1
- package/dist/{input-wrapper-mJZLVXy_.cjs → input-wrapper-B9wREHHW.cjs} +1 -1
- package/dist/{input-wrapper-CQgAL1Br.js → input-wrapper-DZhzHSxD.js} +6 -6
- package/dist/{link-DwLeY37f.js → link-C9xAIILf.js} +4 -4
- package/dist/{link-yk4IXDWm.cjs → link-CpwR3BLX.cjs} +1 -1
- package/dist/{linkcard-BinKnxQF.cjs → linkcard-Bzv3CEw5.cjs} +2 -1
- package/dist/{linkcard-D5DXpmXI.js → linkcard-C6ljKc0B.js} +6 -5
- package/dist/{listbox-C8ooO8qZ.js → listbox-CsP0qbU1.js} +4 -4
- package/dist/{listbox-C5zTRNAO.cjs → listbox-D95b5zAd.cjs} +1 -1
- package/dist/{loader-DHF7M5Vn.cjs → loader-Bv-1vwju.cjs} +1 -1
- package/dist/{loader-C3HyayzL.js → loader-D6dau_7w.js} +4 -4
- package/dist/{messagebox-u8i3R5QA.js → messagebox-CmhjIh0n.js} +4 -4
- package/dist/{messagebox-DqYf6VmQ.cjs → messagebox-DNUfv2FN.cjs} +1 -1
- package/dist/{modal-CnJ9y2TQ.cjs → modal-Bh0DGVfN.cjs} +1 -1
- package/dist/{modal-V-jEe0aY.js → modal-C7eV5vJr.js} +5 -5
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.js +1 -1
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +1 -1
- package/dist/pkt-backlink.cjs +1 -1
- package/dist/pkt-backlink.js +1 -1
- package/dist/pkt-breadcrumbs.cjs +1 -1
- package/dist/pkt-breadcrumbs.js +1 -1
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +1 -1
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +1 -1
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-fileupload.cjs +1 -1
- package/dist/pkt-fileupload.js +1 -1
- package/dist/pkt-footer.cjs +1 -1
- package/dist/pkt-footer.js +1 -1
- package/dist/pkt-header-menu.cjs +1 -1
- package/dist/pkt-header-menu.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-heading.cjs +1 -1
- package/dist/pkt-heading.js +1 -1
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +1 -1
- package/dist/pkt-icon.cjs +1 -1
- package/dist/pkt-icon.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +34 -34
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +1 -1
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +1 -1
- package/dist/pkt-listbox.cjs +1 -1
- package/dist/pkt-listbox.js +1 -1
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +1 -1
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/{pkt-options-controller-BhMNCWcc.cjs → pkt-options-controller-CJPuBqvH.cjs} +1 -1
- package/dist/{pkt-options-controller-CuQ6SClv.js → pkt-options-controller-DNDUGQno.js} +1 -1
- package/dist/pkt-progressbar.cjs +1 -1
- package/dist/pkt-progressbar.js +1 -1
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/pkt-searchinput.cjs +1 -1
- package/dist/pkt-searchinput.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-tabs.cjs +1 -1
- package/dist/pkt-tabs.js +1 -1
- package/dist/pkt-tag.cjs +1 -1
- package/dist/pkt-tag.js +1 -1
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/pkt-timepicker.cjs +1 -1
- package/dist/pkt-timepicker.js +1 -1
- package/dist/{progressbar-DS4i8IWq.js → progressbar-Bk_RsEjW.js} +4 -4
- package/dist/{progressbar-DY5hxImR.cjs → progressbar-T5_MpZGN.cjs} +1 -1
- package/dist/{radiobutton-BhvZztMZ.js → radiobutton-B_j_nYCC.js} +4 -4
- package/dist/{radiobutton-BswqwRnA.cjs → radiobutton-DsL-FNDd.cjs} +1 -1
- package/dist/{ref-DZmN5Qgj.cjs → ref-BkV4Cd8U.cjs} +1 -1
- package/dist/{ref-OU8ryfP6.js → ref-lE1mGUOL.js} +2 -2
- package/dist/{repeat-Dx2H127b.js → repeat-CCnTfedv.js} +2 -2
- package/dist/{repeat-DIa_g6WL.cjs → repeat-uBgVG8Ch.cjs} +1 -1
- package/dist/{searchinput-CJo1PpM7.js → searchinput-D7Dd2W2z.js} +4 -4
- package/dist/{searchinput-Cl46nW0r.cjs → searchinput-Dm3T0tGS.cjs} +1 -1
- package/dist/{select-CBrjauXT.js → select-CIGYIrl3.js} +7 -7
- package/dist/{select-Dman8Skr.cjs → select-DA5ZBqbg.cjs} +1 -1
- package/dist/shared-strings/nb.d.ts +3 -0
- package/dist/shared-types/button.d.ts +45 -0
- package/dist/shared-types/index.d.ts +4 -0
- package/dist/shared-types/linkcard.d.ts +24 -0
- package/dist/{tabs-Xu3mIedh.js → tabs-DPdDkHSk.js} +4 -4
- package/dist/{tabs-C1m5rSrR.cjs → tabs-nvIpMwHK.cjs} +1 -1
- package/dist/{tag-BS6dDPxY.cjs → tag-Bp9gJnYh.cjs} +1 -1
- package/dist/{tag-Azkjhkeu.js → tag-DBCzfbPE.js} +5 -5
- package/dist/{textarea-D4qXcVGD.js → textarea-BqK3V7uZ.js} +9 -9
- package/dist/{textarea-DftUkR6w.cjs → textarea-CST8hYg2.cjs} +1 -1
- package/dist/{textinput-iCgwwNPU.js → textinput-B3xYwLt3.js} +8 -8
- package/dist/{textinput-Ar-1Sbqy.cjs → textinput-DByVORsj.cjs} +1 -1
- package/dist/{timepicker-dpAF7h49.cjs → timepicker-Boj-9I40.cjs} +1 -1
- package/dist/{timepicker-W6HVWtmA.js → timepicker-DZwmwpWM.js} +8 -8
- package/package.json +2 -2
- package/src/components/button/button.test.ts +0 -1
- package/src/components/button/button.ts +25 -39
- package/src/components/button/index.ts +0 -2
- package/src/components/index.ts +0 -2
- package/src/components/linkcard/linkcard.test.ts +38 -0
- package/src/components/linkcard/linkcard.ts +8 -18
- package/dist/alert-BD8YVKia.cjs +0 -35
- package/dist/button-CF3dNKeI.cjs +0 -30
- package/dist/if-defined-Dc3xFDaM.cjs +0 -1
|
@@ -14,7 +14,11 @@ export type { THTMLButtonType, TSelectionMode } from './form';
|
|
|
14
14
|
export type { TPktInputSize, TSize3, TSize5, TSize7 } from './size';
|
|
15
15
|
export { ACCORDION_SKINS } from './accordion';
|
|
16
16
|
export type { TAccordionSkin, IPktAccordionBase, IPktAccordionItemBase, IAccordionSpecProps, IAccordionItemSpecProps, IAccordionVisualProps, } from './accordion';
|
|
17
|
+
export { BUTTON_SIZES, BUTTON_SKINS, BUTTON_COLORS, BUTTON_VARIANTS, BUTTON_STATES } from './button';
|
|
18
|
+
export type { TPktButtonSize, TPktButtonSkin, TPktButtonColor, TPktButtonVariant, TPktButtonState, IPktButtonBase, IButtonSpecProps, } from './button';
|
|
17
19
|
export type { IPktBackLinkBase, IBacklinkSpecProps } from './backlink';
|
|
20
|
+
export { LINKCARD_SKINS } from './linkcard';
|
|
21
|
+
export type { TLinkCardSkin, IPktLinkCardBase, ILinkcardSpecProps } from './linkcard';
|
|
18
22
|
export { BREADCRUMBS_NAVIGATION_TYPES } from './breadcrumbs';
|
|
19
23
|
export type { TBreadcrumbsNavigationType, IBreadcrumb, IBreadcrumbItem, IBreadcrumbs, IPktBreadcrumbsBase, IBreadcrumbsSpecProps, } from './breadcrumbs';
|
|
20
24
|
export type { IRenderLink, TRenderLink } from './render-link';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* linkcard.ts
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for pkt-linkcard.
|
|
5
|
+
* Used by React, Elements, and typed component specs.
|
|
6
|
+
*/
|
|
7
|
+
import type { IPktStringsProps } from '../shared-strings';
|
|
8
|
+
/** LinkCard skin variants — shared runtime source for types, specs, and Preview. */
|
|
9
|
+
export declare const LINKCARD_SKINS: readonly ['normal', 'no-padding', 'blue', 'beige', 'green', 'gray', 'beige-outline', 'gray-outline'];
|
|
10
|
+
export type TLinkCardSkin = (typeof LINKCARD_SKINS)[number];
|
|
11
|
+
/** Shared LinkCard props for React, Elements, and typed specs. */
|
|
12
|
+
export type IPktLinkCardBase = IPktStringsProps<'linkcard'> & {
|
|
13
|
+
title?: string;
|
|
14
|
+
href?: string;
|
|
15
|
+
skin?: TLinkCardSkin;
|
|
16
|
+
iconName?: string;
|
|
17
|
+
openInNewTab?: boolean;
|
|
18
|
+
external?: boolean;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Documented LinkCard props (subset of `IPktLinkCardBase`).
|
|
22
|
+
* Used for typed component specs in documentation.
|
|
23
|
+
*/
|
|
24
|
+
export type ILinkcardSpecProps = Pick<IPktLinkCardBase, 'title' | 'href' | 'skin' | 'iconName' | 'openInNewTab' | 'external'>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { _ as e, d as t, l as n, n as r, u as i } from "./element-
|
|
2
|
-
import { n as a, t as o } from "./element-with-slot-
|
|
3
|
-
import { t as s } from "./if-defined-
|
|
1
|
+
import { _ as e, d as t, l as n, n as r, u as i } from "./element-e2MAMNEP.js";
|
|
2
|
+
import { n as a, t as o } from "./element-with-slot-COOwQUxM.js";
|
|
3
|
+
import { t as s } from "./if-defined-r8tKY4tG.js";
|
|
4
4
|
import { n as c, r as l, t as u } from "./consume-BDnMAp2g.js";
|
|
5
|
-
import { n as d, t as f } from "./ref-
|
|
5
|
+
import { n as d, t as f } from "./ref-lE1mGUOL.js";
|
|
6
6
|
//#region src/components/tabs/tabs-context.ts
|
|
7
7
|
var p = l(Symbol("pkt-tabs-context")), m = class extends o {
|
|
8
8
|
constructor(...e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./element-with-slot-MkibfzHp.cjs"),n=require("./if-defined-BeVQnl3C.cjs"),r=require("./consume-Le4HztPo.cjs"),i=require("./ref-BkV4Cd8U.cjs");var a=r.r(Symbol(`pkt-tabs-context`)),o=class extends t.t{constructor(...e){super(...e),this.arrowNav=!0,this.disableArrowNav=!1,this.separatorIconName=``,this.separatorIconPath=``,this.tabRefs=[],this.disabledMap={},this.tabCount=0,this.context={useArrowNav:this.useArrowNav,registerTab:this.registerTab.bind(this),handleClick:this.handleClick.bind(this),handleKeyUp:this.handleKeyUp.bind(this)}}get useArrowNav(){return this.arrowNav&&!this.disableArrowNav}updated(e){(e.has(`arrowNav`)||e.has(`disableArrowNav`))&&(this.context={...this.context,useArrowNav:this.useArrowNav}),this.updateComplete.then(()=>this.syncSeparators())}syncSeparators(){let e=this.querySelector(`.pkt-tabs__list`);if(!e||(e.querySelectorAll(`.pkt-tabs__separator`).forEach(e=>e.remove()),!(this.separatorIconName||this.separatorIconPath)))return;let t=Array.from(e.children).filter(e=>!e.classList.contains(`pkt-tabs__separator`));for(let e=0;e<t.length-1;e++){let n=document.createElement(`span`);if(n.className=`pkt-tabs__separator`,n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`role`,`presentation`),this.separatorIconPath){let e=document.createElement(`img`);e.setAttribute(`src`,this.separatorIconPath),e.setAttribute(`alt`,``),e.setAttribute(`aria-hidden`,`true`),n.appendChild(e)}else if(this.separatorIconName){let e=document.createElement(`pkt-icon`);e.setAttribute(`name`,this.separatorIconName),e.classList.add(`pkt-tabs__separator-icon`),n.appendChild(e)}t[e].after(n)}}registerTab(e,t,n=!1){this.tabRefs[t]=e,this.disabledMap[t]=n,this.tabCount=Math.max(this.tabCount,t+1)}isTabDisabled(e){return!!this.disabledMap[e]}findEnabledIndex(e,t){let n=e+t;for(;n>=0&&n<this.tabCount;){if(!this.isTabDisabled(n))return n;n+=t}return null}handleClick(e){this.isTabDisabled(e)||this.dispatchEvent(new CustomEvent(`tab-selected`,{detail:{index:e},bubbles:!0,composed:!0}))}handleKeyUp(e,t){if(this.useArrowNav){if(e.key===`ArrowLeft`){e.preventDefault();let n=this.findEnabledIndex(t,-1);n!==null&&this.tabRefs[n]?.focus()}if(e.key===`ArrowRight`){e.preventDefault();let n=this.findEnabledIndex(t,1);n!==null&&this.tabRefs[n]?.focus()}(e.key===`Enter`||e.key===` `||e.key===`Spacebar`||e.key===`ArrowDown`)&&(e.preventDefault(),this.handleClick(t))}}render(){let n=this.useArrowNav?`tablist`:`navigation`,r=this.separatorIconName||this.separatorIconPath?`pkt-tabs pkt-tabs--with-separator`:`pkt-tabs`;return e._`
|
|
2
2
|
<div class=${r}>
|
|
3
3
|
<div class="pkt-tabs__list" role=${n}>${t.n(this)}</div>
|
|
4
4
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-MkibfzHp.cjs");require("./icon-DBFTFd-J.cjs");const i=require("./if-defined-BeVQnl3C.cjs");var a={name:`pkt-tag`,react:`PktTag`,"css-class":`pkt-tag`,isElement:!0,"dark-mode":!0,props:{size:{name:`Størrelse`,description:`Størrelsen på taggen`,required:!1,default:`medium`,type:[`small`,`medium`,`large`],category:`ui`},iconName:{name:`Ikon`,description:`Navnet på ikonet som skal vises i taggen`,type:`icon`,required:!1,category:`ui`},skin:{name:`Utseende`,description:`Utseendet til taggen`,required:!1,default:`blue`,type:[`blue`,`blue-light`,`blue-dark`,`green`,`red`,`beige`,`yellow`,`gray`],category:`ui`},closeTag:{name:`Lukk tag`,description:`Skal taggen ha en lukkeknapp?`,type:`boolean`,required:!1,default:!1,category:`ui`},textStyle:{name:`Tekststil`,description:`Stilen på teksten i taggen`,required:!1,default:`normal-text`,type:[`thin-text`,`normal-text`],category:`ui`},type:{name:`Type, dersom lukkeknapp`,description:`Type tag, brukes for å spesifisere om det er en knapp, submit eller reset`,required:!1,default:`button`,type:[`button`,`submit`,`reset`],category:`tech`},ariaLabel:{name:`aria-label`,description:`aria-label for taggen, brukes for tilgjengelighet`,type:`string`,required:!1,category:`accessibility`}},slots:{default:{description:`Teksten til tag`}}},o=class extends r.t{constructor(){super(),this.closeTag=a.props.closeTag.default,this.size=a.props.size.default,this.skin=a.props.skin.default,this.textStyle=null,this.iconName=void 0,this.type=a.props.type.default,this.ariaLabel=null,this.buttonTabindex=void 0,this._isClosed=!1,this._ariaDescription=null,this.close=e=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent(`close`,{detail:{origin:e},bubbles:!1,composed:!0})),this.dispatchEvent(new CustomEvent(`on-close`,{detail:{origin:e},bubbles:!1,composed:!0}))},this._isClosed=!1}firstUpdated(e){if(super.firstUpdated(e),this.closeTag&&!this.ariaLabel){let e=this.querySelector(`button span, .pkt-tag > span`)?.textContent?.trim();e&&(this._ariaDescription=n.t(this.pktStrings.get(`tag`).remove,{label:e}))}}render(){let n={"pkt-tag":!0,[`pkt-tag--${this.size}`]:!!this.size,[`pkt-tag--${this.skin}`]:!!this.skin,[`pkt-tag--${this.textStyle}`]:!!this.textStyle},a={"pkt-tag":!0,[`pkt-tag--${this.textStyle}`]:!!this.textStyle,[`pkt-tag--${this.size}`]:!!this.size,[`pkt-tag--${this.skin}`]:!!this.skin,"pkt-hide":this._isClosed};return this.closeTag?e._`
|
|
2
2
|
<button
|
|
3
3
|
class=${t.t(a)}
|
|
4
4
|
type=${this.type}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { _ as e, d as t, l as n, n as r, u as i } from "./element-
|
|
2
|
-
import { t as a } from "./class-map-
|
|
1
|
+
import { _ as e, d as t, l as n, n as r, u as i } from "./element-e2MAMNEP.js";
|
|
2
|
+
import { t as a } from "./class-map-BL_YL_Ed.js";
|
|
3
3
|
import { t as o } from "./format-BTeSVkED.js";
|
|
4
|
-
import { n as s, t as c } from "./element-with-slot-
|
|
5
|
-
import "./icon-
|
|
6
|
-
import { t as l } from "./if-defined-
|
|
4
|
+
import { n as s, t as c } from "./element-with-slot-COOwQUxM.js";
|
|
5
|
+
import "./icon-jEFbKTB_.js";
|
|
6
|
+
import { t as l } from "./if-defined-r8tKY4tG.js";
|
|
7
7
|
var u = {
|
|
8
8
|
name: "pkt-tag",
|
|
9
9
|
react: "PktTag",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { _ as e, d as t, f as n, g as r, h as i, l as a, m as o, n as s, p as c, u as l } from "./element-
|
|
2
|
-
import { t as u } from "./class-map-
|
|
3
|
-
import { i as d, r as f } from "./directive-helpers-
|
|
4
|
-
import { n as p } from "./element-with-slot-
|
|
5
|
-
import "./icon-
|
|
6
|
-
import { t as m } from "./if-defined-
|
|
7
|
-
import { n as h, t as g } from "./ref-
|
|
8
|
-
import { t as _ } from "./input-element-
|
|
9
|
-
import { r as v } from "./input-wrapper-
|
|
1
|
+
import { _ as e, d as t, f as n, g as r, h as i, l as a, m as o, n as s, p as c, u as l } from "./element-e2MAMNEP.js";
|
|
2
|
+
import { t as u } from "./class-map-BL_YL_Ed.js";
|
|
3
|
+
import { i as d, r as f } from "./directive-helpers-CohhRNQz.js";
|
|
4
|
+
import { n as p } from "./element-with-slot-COOwQUxM.js";
|
|
5
|
+
import "./icon-jEFbKTB_.js";
|
|
6
|
+
import { t as m } from "./if-defined-r8tKY4tG.js";
|
|
7
|
+
import { n as h, t as g } from "./ref-lE1mGUOL.js";
|
|
8
|
+
import { t as _ } from "./input-element-DxHRTZ3K.js";
|
|
9
|
+
import { r as v } from "./input-wrapper-DZhzHSxD.js";
|
|
10
10
|
//#region ../../node_modules/lit-html/directives/live.js
|
|
11
11
|
var y = n(class extends c {
|
|
12
12
|
constructor(e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./directive-helpers-Ddr8wUxL.cjs"),r=require("./element-with-slot-MkibfzHp.cjs");require("./icon-DBFTFd-J.cjs");const i=require("./if-defined-BeVQnl3C.cjs"),a=require("./ref-BkV4Cd8U.cjs"),o=require("./input-element-KpXXnGi0.cjs"),s=require("./input-wrapper-B9wREHHW.cjs");var c=e.f(class extends e.p{constructor(t){if(super(t),t.type!==e.m.PROPERTY&&t.type!==e.m.ATTRIBUTE&&t.type!==e.m.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!n.i(t))throw Error("`live` bindings can only contain a single expression")}render(e){return e}update(t,[r]){if(r===e.g||r===e.h)return r;let i=t.element,a=t.name;if(t.type===e.m.PROPERTY){if(r===i[a])return e.g}else if(t.type===e.m.BOOLEAN_ATTRIBUTE){if(!!r===i.hasAttribute(a))return e.g}else if(t.type===e.m.ATTRIBUTE&&i.getAttribute(a)===r+``)return e.g;return n.r(t),r}}),l=class extends o.t{constructor(...e){super(...e),this.inputRef=a.t(),this.value=``,this.autocomplete=`off`,this.rows=null,this.cols=null,this.counterCurrent=0}attributeChangedCallback(e,t,n){e===`value`&&this.value!==t&&(this.counterCurrent=n?n.length:0),super.attributeChangedCallback(e,t,n)}updated(e){super.updated(e),this.classList.add(`pkt-textinput`,`pkt-textarea`),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 n=this.effectiveCounter(this.counterMaxLength>0),o=t.t({"pkt-input":!0,[`pkt-input--${this.inputSize}`]:!0,"pkt-input--fullwidth":this.fullwidth,"pkt-input--counter-error":n&&this.counterMaxLength>0&&this.value.length>this.counterMaxLength}),l=this.ariaLabelledby||`${this.id}-input-label`;return e._`<pkt-input-wrapper
|
|
2
2
|
.strings=${this.strings}
|
|
3
3
|
label=${this.label}
|
|
4
4
|
?counter=${n}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-
|
|
2
|
-
import { t as o } from "./class-map-
|
|
3
|
-
import { n as s } from "./element-with-slot-
|
|
4
|
-
import "./icon-
|
|
5
|
-
import { t as c } from "./if-defined-
|
|
6
|
-
import { n as l, t as u } from "./ref-
|
|
7
|
-
import { t as d } from "./input-element-
|
|
8
|
-
import { r as f } from "./input-wrapper-
|
|
1
|
+
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-e2MAMNEP.js";
|
|
2
|
+
import { t as o } from "./class-map-BL_YL_Ed.js";
|
|
3
|
+
import { n as s } from "./element-with-slot-COOwQUxM.js";
|
|
4
|
+
import "./icon-jEFbKTB_.js";
|
|
5
|
+
import { t as c } from "./if-defined-r8tKY4tG.js";
|
|
6
|
+
import { n as l, t as u } from "./ref-lE1mGUOL.js";
|
|
7
|
+
import { t as d } from "./input-element-DxHRTZ3K.js";
|
|
8
|
+
import { r as f } from "./input-wrapper-DZhzHSxD.js";
|
|
9
9
|
//#region src/components/textinput/textinput.ts
|
|
10
10
|
var p = class extends d {
|
|
11
11
|
constructor(...e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./element-with-slot-MkibfzHp.cjs");require("./icon-DBFTFd-J.cjs");const r=require("./if-defined-BeVQnl3C.cjs"),i=require("./ref-BkV4Cd8U.cjs"),a=require("./input-element-KpXXnGi0.cjs"),o=require("./input-wrapper-B9wREHHW.cjs");var s=class extends a.t{constructor(...e){super(...e),this.inputRef=i.t(),this.value=``,this.type=`text`,this.size=null,this.autocomplete=null,this.iconNameRight=null,this.prefix=null,this.suffix=null,this.omitSearchIcon=!1,this.counterCurrent=0}attributeChangedCallback(e,t,n){e===`value`&&this.value!==t&&(this.counterCurrent=n?n.length:0),super.attributeChangedCallback(e,t,n)}updated(e){super.updated(e),this.classList.add(`pkt-textinput`),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,s=this.effectiveCounter(this.counterMaxLength>0),c=t.t({"pkt-input":!0,[`pkt-input--${this.inputSize}`]:!0,"pkt-input--fullwidth":this.fullwidth,"pkt-input--counter-error":s&&this.counterMaxLength>0&&this.value.length>this.counterMaxLength}),l=this.ariaLabelledby||`${this.id}-input-label`;return e._`
|
|
2
2
|
<pkt-input-wrapper
|
|
3
3
|
.strings=${this.strings}
|
|
4
4
|
label="${this.label}"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-DiFhBcIl.cjs"),t=require("./class-map-C33ixq7O.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-CBK4zrdN.cjs");require("./icon-DIavy2cB.cjs");const i=require("./if-defined-Dc3xFDaM.cjs"),a=require("./ref-DZmN5Qgj.cjs"),o=require("./input-element-DQY1Rpbp.cjs");require("./input-wrapper-mJZLVXy_.cjs");var s=e=>/^\d{2}:\d{2}$/.test(e)&&parseInt(e.slice(0,2),10)<=23&&parseInt(e.slice(3),10)<=59,c=e=>{let[t,n]=e.split(`:`).map(Number);return t*60+n},l=e=>e?Math.max(1,Math.round(e/60)):1,u=(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)},d=e=>{let t=l(e);return Array.from({length:Math.floor(60/t)},(e,n)=>n*t)},f=(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`)}},p=class extends o.t{constructor(...e){super(...e),this.hiddenInputRef=a.t(),this.hoursInputRef=a.t(),this.minutesInputRef=a.t(),this.buttonRef=a.t(),this.value=``,this.hidePicker=!1,this.stepArrows=!1,this._hours=``,this._minutes=``,this._isOpen=!1,this._hoursDigitCount=0,this._hoursFirstDigit=-1,this._minutesDigitCount=0,this._minutesFirstDigit=-1,this._hasFocus=!1,this._outsideClickHandler=e=>{this.contains(e.target)||this._closePopup()},this._handleComponentFocusIn=()=>{this._hasFocus||(this._hasFocus=!0,this.onFocus())},this._handleComponentFocusOut=e=>{this.contains(e.relatedTarget)||(this._hasFocus=!1,this.onBlur())},this._handleHoursKeydown=e=>{let t=e.target;switch(e.key){case`ArrowUp`:{e.preventDefault();let t=this._hours===``?0:parseInt(this._hours,10);this._hours=String((t+1)%24).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowDown`:{e.preventDefault();let t=this._hours===``?0:parseInt(this._hours,10);this._hours=String((t-1+24)%24).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowRight`:e.preventDefault(),this.minutesInputRef.value?.focus();break;case`Backspace`:case`Delete`:this._hoursDigitCount=0,this._hoursFirstDigit=-1;break;case`Tab`:break;case`Enter`:{e.preventDefault();let n=this.internals.form;n?n.requestSubmit():t.blur();break}default:if(/^\d$/.test(e.key)){e.preventDefault();let t=parseInt(e.key,10);if(this._hoursDigitCount===0)this._hoursFirstDigit=t,this._hours=String(t).padStart(2,`0`),this._hoursDigitCount=1,this.onInput(),t>=3&&(this._hoursFirstDigit=-1,this._hoursDigitCount=0,this._syncValueFromDisplay(),this.minutesInputRef.value?.focus());else{let e=this._hoursFirstDigit*10+t;this._hours=e<=23?String(e).padStart(2,`0`):String(t).padStart(2,`0`),this._hoursFirstDigit=-1,this._hoursDigitCount=0,this._syncValueFromDisplay(),this.onInput(),this.minutesInputRef.value?.focus()}}else e.preventDefault()}},this._handleHoursBlur=()=>{this._hours!==``&&(this._hours=String(parseInt(this._hours,10)).padStart(2,`0`)),this._hoursDigitCount=0,this._hoursFirstDigit=-1,this._syncValueFromDisplay()},this._handleMinutesKeydown=e=>{let t=e.target;switch(e.key){case`ArrowUp`:{e.preventDefault();let t=this._minutes===``?0:parseInt(this._minutes,10);this._minutes=String((t+this._minuteStep)%60).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowDown`:{e.preventDefault();let t=this._minutes===``?0:parseInt(this._minutes,10);this._minutes=String((t-this._minuteStep+60)%60).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowLeft`:e.preventDefault(),this.hoursInputRef.value?.focus();break;case`Backspace`:case`Delete`:this._minutesDigitCount=0,this._minutesFirstDigit=-1;break;case`Tab`:break;case`Enter`:{e.preventDefault();let n=this.internals.form;n?n.requestSubmit():t.blur();break}default:if(/^\d$/.test(e.key)){e.preventDefault();let t=parseInt(e.key,10);if(this._minutesDigitCount===0)this._minutesFirstDigit=t,this._minutes=String(t).padStart(2,`0`),this._minutesDigitCount=1,this.onInput(),t>=6&&(this._minutesFirstDigit=-1,this._minutesDigitCount=0,this._syncValueFromDisplay());else{let e=this._minutesFirstDigit*10+t;this._minutes=e<=59?String(e).padStart(2,`0`):String(t).padStart(2,`0`),this._minutesFirstDigit=-1,this._minutesDigitCount=0,this._syncValueFromDisplay(),this.onInput()}}else e.preventDefault()}},this._handleMinutesBlur=()=>{this._minutes!==``&&(this._minutes=String(parseInt(this._minutes,10)).padStart(2,`0`)),this._minutesDigitCount=0,this._minutesFirstDigit=-1,this._syncValueFromDisplay()},this._handlePopupKeydown=e=>{let t=document.activeElement,n=t.closest(`.pkt-timepicker-popup__col`);if(!n)return;let r=Array.from(n.querySelectorAll(`.pkt-timepicker-popup__option`)),i=r.indexOf(t),a=t.dataset.type??``;switch(e.key){case`ArrowDown`:e.preventDefault(),this._focusOptionAndSync(r[Math.min(i+1,r.length-1)],a);break;case`ArrowUp`:e.preventDefault(),this._focusOptionAndSync(r[Math.max(i-1,0)],a);break;case`Home`:e.preventDefault(),this._focusOptionAndSync(r[0],a);break;case`End`:e.preventDefault(),this._focusOptionAndSync(r[r.length-1],a);break;case`ArrowRight`:e.preventDefault(),a===`hour`&&(this._focusOptionAndSync(t,a),this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`minute`)}));break;case`ArrowLeft`:e.preventDefault(),a===`minute`&&(this._focusOptionAndSync(t,a),this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`hour`)}));break;case`Enter`:case` `:e.preventDefault(),t.click();break;case`Escape`:e.preventDefault(),this._closePopup(),this.buttonRef.value?.focus()}}}get inputRef(){return this.hiddenInputRef}manageValidity(e){let t=this.hoursInputRef.value;if(!t)return;let r=this.pktStrings.get(`validation`);if(this.required&&!this.value){this.internals.setValidity({valueMissing:!0},r.valueMissing,t),this._setAriaInvalid(!0);return}if(!this.value){this.internals.setValidity({}),this._setAriaInvalid(!1);return}let i=c(this.value),a=l(this.step);if(this.min&&i<c(String(this.min))){this.internals.setValidity({rangeUnderflow:!0},n.t(r.rangeUnderflowMin,{min:String(this.min)}),t),this._setAriaInvalid(!0);return}if(this.max&&i>c(String(this.max))){this.internals.setValidity({rangeOverflow:!0},n.t(r.rangeOverflowMax,{max:String(this.max)}),t),this._setAriaInvalid(!0);return}if(this.step&&i%a!==0){let e=a===60?r.timeStepMismatchHour:a===30?r.timeStepMismatchHalfHour:n.t(r.timeStepMismatch,{step:`${a}, ${a*2}, ${a*3}`});this.internals.setValidity({stepMismatch:!0},e,t),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;if(e)t?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-invalid`,`true`);else{if(this.hasError)return;t?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-invalid`)}}connectedCallback(){super.connectedCallback(),this.addEventListener(`focusin`,this._handleComponentFocusIn),this.addEventListener(`focusout`,this._handleComponentFocusOut),document.addEventListener(`click`,this._outsideClickHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`focusin`,this._handleComponentFocusIn),this.removeEventListener(`focusout`,this._handleComponentFocusOut),document.removeEventListener(`click`,this._outsideClickHandler)}willUpdate(e){super.willUpdate(e),e.has(`value`)&&this._syncDisplayFromValue()}updated(e){super.updated(e),this.classList.add(`pkt-timepicker`),this.classList.toggle(`pkt-timepicker--stepper`,this.stepArrows),this.classList.toggle(`pkt-timepicker--fullwidth`,this.fullwidth),this.classList.toggle(`pkt-timepicker--medium`,this.inputSize===`medium`),this.classList.toggle(`pkt-timepicker--small`,this.inputSize===`small`),this.classList.toggle(`pkt-timepicker--xsmall`,this.inputSize===`xsmall`),e.has(`step`)&&this.step!==null&&!this._isValidStep(this.step)&&console.warn(`pkt-timepicker: step="${this.step}" er ikke en gyldig verdi. Step må være et multiplum av 60 (hele minutter) eller nøyaktig 3600 (hel time).`)}formResetCallback(){super.formResetCallback(),this._hours=``,this._minutes=``,this._isOpen=!1}_isValidStep(e){return e===3600||e<3600&&3600%e==0&&e%60==0}_syncDisplayFromValue(){let e=s(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 l(this.step)}get _hourOptions(){return u(this.min,this.max)}get _minuteOptions(){return d(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=f(this._hours,this._minutes,e,this._minuteStep);this._hours=t.hours,this._minutes=t.minutes,this._syncValueFromDisplay()}_renderOption(n,r){let i=String(n).padStart(2,`0`),a=n===(r===`hour`?this._hours===``?NaN:parseInt(this._hours,10):this._minutes===``?NaN:parseInt(this._minutes,10));return e._`
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-MkibfzHp.cjs");require("./icon-DBFTFd-J.cjs");const i=require("./if-defined-BeVQnl3C.cjs"),a=require("./ref-BkV4Cd8U.cjs"),o=require("./input-element-KpXXnGi0.cjs");require("./input-wrapper-B9wREHHW.cjs");var s=e=>/^\d{2}:\d{2}$/.test(e)&&parseInt(e.slice(0,2),10)<=23&&parseInt(e.slice(3),10)<=59,c=e=>{let[t,n]=e.split(`:`).map(Number);return t*60+n},l=e=>e?Math.max(1,Math.round(e/60)):1,u=(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)},d=e=>{let t=l(e);return Array.from({length:Math.floor(60/t)},(e,n)=>n*t)},f=(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`)}},p=class extends o.t{constructor(...e){super(...e),this.hiddenInputRef=a.t(),this.hoursInputRef=a.t(),this.minutesInputRef=a.t(),this.buttonRef=a.t(),this.value=``,this.hidePicker=!1,this.stepArrows=!1,this._hours=``,this._minutes=``,this._isOpen=!1,this._hoursDigitCount=0,this._hoursFirstDigit=-1,this._minutesDigitCount=0,this._minutesFirstDigit=-1,this._hasFocus=!1,this._outsideClickHandler=e=>{this.contains(e.target)||this._closePopup()},this._handleComponentFocusIn=()=>{this._hasFocus||(this._hasFocus=!0,this.onFocus())},this._handleComponentFocusOut=e=>{this.contains(e.relatedTarget)||(this._hasFocus=!1,this.onBlur())},this._handleHoursKeydown=e=>{let t=e.target;switch(e.key){case`ArrowUp`:{e.preventDefault();let t=this._hours===``?0:parseInt(this._hours,10);this._hours=String((t+1)%24).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowDown`:{e.preventDefault();let t=this._hours===``?0:parseInt(this._hours,10);this._hours=String((t-1+24)%24).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowRight`:e.preventDefault(),this.minutesInputRef.value?.focus();break;case`Backspace`:case`Delete`:this._hoursDigitCount=0,this._hoursFirstDigit=-1;break;case`Tab`:break;case`Enter`:{e.preventDefault();let n=this.internals.form;n?n.requestSubmit():t.blur();break}default:if(/^\d$/.test(e.key)){e.preventDefault();let t=parseInt(e.key,10);if(this._hoursDigitCount===0)this._hoursFirstDigit=t,this._hours=String(t).padStart(2,`0`),this._hoursDigitCount=1,this.onInput(),t>=3&&(this._hoursFirstDigit=-1,this._hoursDigitCount=0,this._syncValueFromDisplay(),this.minutesInputRef.value?.focus());else{let e=this._hoursFirstDigit*10+t;this._hours=e<=23?String(e).padStart(2,`0`):String(t).padStart(2,`0`),this._hoursFirstDigit=-1,this._hoursDigitCount=0,this._syncValueFromDisplay(),this.onInput(),this.minutesInputRef.value?.focus()}}else e.preventDefault()}},this._handleHoursBlur=()=>{this._hours!==``&&(this._hours=String(parseInt(this._hours,10)).padStart(2,`0`)),this._hoursDigitCount=0,this._hoursFirstDigit=-1,this._syncValueFromDisplay()},this._handleMinutesKeydown=e=>{let t=e.target;switch(e.key){case`ArrowUp`:{e.preventDefault();let t=this._minutes===``?0:parseInt(this._minutes,10);this._minutes=String((t+this._minuteStep)%60).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowDown`:{e.preventDefault();let t=this._minutes===``?0:parseInt(this._minutes,10);this._minutes=String((t-this._minuteStep+60)%60).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowLeft`:e.preventDefault(),this.hoursInputRef.value?.focus();break;case`Backspace`:case`Delete`:this._minutesDigitCount=0,this._minutesFirstDigit=-1;break;case`Tab`:break;case`Enter`:{e.preventDefault();let n=this.internals.form;n?n.requestSubmit():t.blur();break}default:if(/^\d$/.test(e.key)){e.preventDefault();let t=parseInt(e.key,10);if(this._minutesDigitCount===0)this._minutesFirstDigit=t,this._minutes=String(t).padStart(2,`0`),this._minutesDigitCount=1,this.onInput(),t>=6&&(this._minutesFirstDigit=-1,this._minutesDigitCount=0,this._syncValueFromDisplay());else{let e=this._minutesFirstDigit*10+t;this._minutes=e<=59?String(e).padStart(2,`0`):String(t).padStart(2,`0`),this._minutesFirstDigit=-1,this._minutesDigitCount=0,this._syncValueFromDisplay(),this.onInput()}}else e.preventDefault()}},this._handleMinutesBlur=()=>{this._minutes!==``&&(this._minutes=String(parseInt(this._minutes,10)).padStart(2,`0`)),this._minutesDigitCount=0,this._minutesFirstDigit=-1,this._syncValueFromDisplay()},this._handlePopupKeydown=e=>{let t=document.activeElement,n=t.closest(`.pkt-timepicker-popup__col`);if(!n)return;let r=Array.from(n.querySelectorAll(`.pkt-timepicker-popup__option`)),i=r.indexOf(t),a=t.dataset.type??``;switch(e.key){case`ArrowDown`:e.preventDefault(),this._focusOptionAndSync(r[Math.min(i+1,r.length-1)],a);break;case`ArrowUp`:e.preventDefault(),this._focusOptionAndSync(r[Math.max(i-1,0)],a);break;case`Home`:e.preventDefault(),this._focusOptionAndSync(r[0],a);break;case`End`:e.preventDefault(),this._focusOptionAndSync(r[r.length-1],a);break;case`ArrowRight`:e.preventDefault(),a===`hour`&&(this._focusOptionAndSync(t,a),this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`minute`)}));break;case`ArrowLeft`:e.preventDefault(),a===`minute`&&(this._focusOptionAndSync(t,a),this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`hour`)}));break;case`Enter`:case` `:e.preventDefault(),t.click();break;case`Escape`:e.preventDefault(),this._closePopup(),this.buttonRef.value?.focus()}}}get inputRef(){return this.hiddenInputRef}manageValidity(e){let t=this.hoursInputRef.value;if(!t)return;let r=this.pktStrings.get(`validation`);if(this.required&&!this.value){this.internals.setValidity({valueMissing:!0},r.valueMissing,t),this._setAriaInvalid(!0);return}if(!this.value){this.internals.setValidity({}),this._setAriaInvalid(!1);return}let i=c(this.value),a=l(this.step);if(this.min&&i<c(String(this.min))){this.internals.setValidity({rangeUnderflow:!0},n.t(r.rangeUnderflowMin,{min:String(this.min)}),t),this._setAriaInvalid(!0);return}if(this.max&&i>c(String(this.max))){this.internals.setValidity({rangeOverflow:!0},n.t(r.rangeOverflowMax,{max:String(this.max)}),t),this._setAriaInvalid(!0);return}if(this.step&&i%a!==0){let e=a===60?r.timeStepMismatchHour:a===30?r.timeStepMismatchHalfHour:n.t(r.timeStepMismatch,{step:`${a}, ${a*2}, ${a*3}`});this.internals.setValidity({stepMismatch:!0},e,t),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;if(e)t?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-invalid`,`true`);else{if(this.hasError)return;t?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-invalid`)}}connectedCallback(){super.connectedCallback(),this.addEventListener(`focusin`,this._handleComponentFocusIn),this.addEventListener(`focusout`,this._handleComponentFocusOut),document.addEventListener(`click`,this._outsideClickHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`focusin`,this._handleComponentFocusIn),this.removeEventListener(`focusout`,this._handleComponentFocusOut),document.removeEventListener(`click`,this._outsideClickHandler)}willUpdate(e){super.willUpdate(e),e.has(`value`)&&this._syncDisplayFromValue()}updated(e){super.updated(e),this.classList.add(`pkt-timepicker`),this.classList.toggle(`pkt-timepicker--stepper`,this.stepArrows),this.classList.toggle(`pkt-timepicker--fullwidth`,this.fullwidth),this.classList.toggle(`pkt-timepicker--medium`,this.inputSize===`medium`),this.classList.toggle(`pkt-timepicker--small`,this.inputSize===`small`),this.classList.toggle(`pkt-timepicker--xsmall`,this.inputSize===`xsmall`),e.has(`step`)&&this.step!==null&&!this._isValidStep(this.step)&&console.warn(`pkt-timepicker: step="${this.step}" er ikke en gyldig verdi. Step må være et multiplum av 60 (hele minutter) eller nøyaktig 3600 (hel time).`)}formResetCallback(){super.formResetCallback(),this._hours=``,this._minutes=``,this._isOpen=!1}_isValidStep(e){return e===3600||e<3600&&3600%e==0&&e%60==0}_syncDisplayFromValue(){let e=s(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 l(this.step)}get _hourOptions(){return u(this.min,this.max)}get _minuteOptions(){return d(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=f(this._hours,this._minutes,e,this._minuteStep);this._hours=t.hours,this._minutes=t.minutes,this._syncValueFromDisplay()}_renderOption(n,r){let i=String(n).padStart(2,`0`),a=n===(r===`hour`?this._hours===``?NaN:parseInt(this._hours,10):this._minutes===``?NaN:parseInt(this._minutes,10));return e._`
|
|
2
2
|
<button
|
|
3
3
|
class=${t.t({"pkt-btn":!0,"pkt-btn--tertiary":!0,"pkt-btn--small":!0,"pkt-btn--label-only":!0,"pkt-timepicker-popup__option":!0,"pkt-timepicker-popup__option--selected":a})}
|
|
4
4
|
type="button"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-
|
|
2
|
-
import { t as o } from "./class-map-
|
|
1
|
+
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-e2MAMNEP.js";
|
|
2
|
+
import { t as o } from "./class-map-BL_YL_Ed.js";
|
|
3
3
|
import { t as s } from "./format-BTeSVkED.js";
|
|
4
|
-
import { n as c } from "./element-with-slot-
|
|
5
|
-
import "./icon-
|
|
6
|
-
import { t as l } from "./if-defined-
|
|
7
|
-
import { n as u, t as d } from "./ref-
|
|
8
|
-
import { t as f } from "./input-element-
|
|
9
|
-
import "./input-wrapper-
|
|
4
|
+
import { n as c } from "./element-with-slot-COOwQUxM.js";
|
|
5
|
+
import "./icon-jEFbKTB_.js";
|
|
6
|
+
import { t as l } from "./if-defined-r8tKY4tG.js";
|
|
7
|
+
import { n as u, t as d } from "./ref-lE1mGUOL.js";
|
|
8
|
+
import { t as f } from "./input-element-DxHRTZ3K.js";
|
|
9
|
+
import "./input-wrapper-DZhzHSxD.js";
|
|
10
10
|
//#region ../../shared-utils/timepicker/time-utils.ts
|
|
11
11
|
var p = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && parseInt(e.slice(3), 10) <= 59, m = (e) => {
|
|
12
12
|
let [t, n] = e.split(":").map(Number);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.4.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",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"engines": {
|
|
84
84
|
"node": "^22.19.0 || ^24.0.0 || ^26.0.0"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "8d8d40b4df4f0cfb7859b308dfde96a01784d08a"
|
|
87
87
|
}
|
|
@@ -114,7 +114,6 @@ describe('PktButton', () => {
|
|
|
114
114
|
expect(button.skin).toBe('primary')
|
|
115
115
|
expect(button.variant).toBe('label-only')
|
|
116
116
|
expect(button.type).toBe('button')
|
|
117
|
-
expect(button.mode).toBe('light')
|
|
118
117
|
expect(button.disabled).toBe(false)
|
|
119
118
|
expect(button.isLoading).toBe(false)
|
|
120
119
|
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { PktElementWithSlot } from '@/base-elements/element-with-slot'
|
|
2
2
|
import { slotContent } from '@/directives/slot-content'
|
|
3
3
|
import { PktIconName } from '@oslokommune/punkt-assets/dist/icons/icon'
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
Booleanish,
|
|
6
|
+
IPktButtonBase,
|
|
7
|
+
TPktButtonSize,
|
|
8
|
+
TPktButtonColor,
|
|
9
|
+
TPktButtonSkin,
|
|
10
|
+
TPktButtonVariant,
|
|
11
|
+
TPktButtonState,
|
|
12
|
+
THTMLButtonType,
|
|
13
|
+
} from 'shared-types'
|
|
5
14
|
import { html, nothing, PropertyValues } from 'lit'
|
|
6
15
|
import { property, customElement, state } from 'lit/decorators.js'
|
|
7
16
|
import { classMap } from 'lit/directives/class-map.js'
|
|
@@ -15,48 +24,26 @@ const defaultAnimationPath = 'https://punkt-cdn.oslo.kommune.no/latest/animation
|
|
|
15
24
|
if (typeof window !== 'undefined') {
|
|
16
25
|
window.pktAnimationPath = window.pktAnimationPath || defaultAnimationPath
|
|
17
26
|
}
|
|
18
|
-
|
|
19
|
-
export type
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
| 'red-outline'
|
|
33
|
-
export type TPktButtonSkin = 'primary' | 'secondary' | 'tertiary'
|
|
34
|
-
export type TPktButtonVariant =
|
|
35
|
-
| 'label-only'
|
|
36
|
-
| 'icon-left'
|
|
37
|
-
| 'icon-right'
|
|
38
|
-
| 'icon-only'
|
|
39
|
-
| 'icons-right-and-left'
|
|
40
|
-
export type TPktButtonState = 'normal' | 'focus' | 'hover' | 'active'
|
|
41
|
-
export type TPktButtonType = THTMLButtonType
|
|
42
|
-
|
|
43
|
-
export interface IPktButton {
|
|
27
|
+
|
|
28
|
+
export type {
|
|
29
|
+
TPktButtonSize,
|
|
30
|
+
TPktButtonColor,
|
|
31
|
+
TPktButtonSkin,
|
|
32
|
+
TPktButtonVariant,
|
|
33
|
+
TPktButtonState,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface IPktButton
|
|
37
|
+
extends Omit<
|
|
38
|
+
IPktButtonBase,
|
|
39
|
+
'iconName' | 'secondIconName' | 'fullWidth' | 'fullWidthOnMobile' | 'isLoading' | 'disabled'
|
|
40
|
+
> {
|
|
44
41
|
iconName?: PktIconName
|
|
45
42
|
secondIconName?: PktIconName
|
|
46
|
-
iconPath?: string
|
|
47
|
-
secondIconPath?: string
|
|
48
|
-
mode?: TPktButtonMode
|
|
49
|
-
size?: TPktButtonSize
|
|
50
43
|
fullWidth?: Booleanish
|
|
51
44
|
fullWidthOnMobile?: Booleanish
|
|
52
|
-
color?: TPktButtonColor
|
|
53
|
-
skin?: TPktButtonSkin
|
|
54
|
-
variant?: TPktButtonVariant
|
|
55
|
-
state?: TPktButtonState
|
|
56
|
-
type?: TPktButtonType
|
|
57
45
|
isLoading?: Booleanish
|
|
58
46
|
disabled?: Booleanish
|
|
59
|
-
loadingAnimationPath?: string
|
|
60
47
|
}
|
|
61
48
|
export class PktButton extends PktElementWithSlot<IPktButton> implements IPktButton {
|
|
62
49
|
// Properties
|
|
@@ -64,7 +51,6 @@ export class PktButton extends PktElementWithSlot<IPktButton> implements IPktBut
|
|
|
64
51
|
@property({ type: String }) secondIconName: string = 'user'
|
|
65
52
|
@property({ type: String }) iconPath: string | undefined
|
|
66
53
|
@property({ type: String }) secondIconPath: string | undefined
|
|
67
|
-
@property({ type: String }) mode?: TPktButtonMode = 'light'
|
|
68
54
|
@property({ type: String }) size: TPktButtonSize = 'medium'
|
|
69
55
|
@property({ type: Boolean, attribute: 'full-width' }) fullWidth: Booleanish = false
|
|
70
56
|
@property({ type: Boolean, attribute: 'full-width-on-mobile' }) fullWidthOnMobile: Booleanish =
|
|
@@ -73,7 +59,7 @@ export class PktButton extends PktElementWithSlot<IPktButton> implements IPktBut
|
|
|
73
59
|
@property({ type: String }) skin: TPktButtonSkin = 'primary'
|
|
74
60
|
@property({ type: String }) variant: TPktButtonVariant = 'label-only'
|
|
75
61
|
@property({ type: String, reflect: true }) state?: TPktButtonState = 'normal'
|
|
76
|
-
@property({ type: String, reflect: true }) type:
|
|
62
|
+
@property({ type: String, reflect: true }) type: THTMLButtonType = 'button'
|
|
77
63
|
@property({ type: String }) form: string | undefined = undefined
|
|
78
64
|
@property({ type: Boolean, reflect: true }) isLoading: Booleanish = false
|
|
79
65
|
@property({ type: Boolean, reflect: true }) disabled: Booleanish = false
|
package/src/components/index.ts
CHANGED
|
@@ -46,13 +46,11 @@ export type { IPktAccordion, IPktAccordionItem, TPktAccordionSkin } from '@/comp
|
|
|
46
46
|
|
|
47
47
|
export type {
|
|
48
48
|
IPktButton,
|
|
49
|
-
TPktButtonMode,
|
|
50
49
|
TPktButtonSize,
|
|
51
50
|
TPktButtonColor,
|
|
52
51
|
TPktButtonSkin,
|
|
53
52
|
TPktButtonVariant,
|
|
54
53
|
TPktButtonState,
|
|
55
|
-
TPktButtonType,
|
|
56
54
|
} from '@/components/button'
|
|
57
55
|
|
|
58
56
|
export type {
|
|
@@ -4,6 +4,7 @@ import { createElementTest, BaseTestConfig } from '../../tests/test-framework'
|
|
|
4
4
|
import { CustomElementFor } from '../../tests/component-registry'
|
|
5
5
|
import { PktLinkCard, type TLinkCardSkin } from './linkcard'
|
|
6
6
|
import type { IPktLinkCard } from './linkcard'
|
|
7
|
+
import { nb } from 'shared-strings'
|
|
7
8
|
import './linkcard'
|
|
8
9
|
|
|
9
10
|
export interface LinkCardTestConfig extends IPktLinkCard, BaseTestConfig {}
|
|
@@ -124,6 +125,41 @@ describe('PktLinkCard', () => {
|
|
|
124
125
|
|
|
125
126
|
expect(linkCard.openInNewTab).toBe(true)
|
|
126
127
|
expect(link.getAttribute('target')).toBe('_blank')
|
|
128
|
+
|
|
129
|
+
const srOnly = link.querySelector('.pkt-sr-only')
|
|
130
|
+
expect(srOnly).toBeInTheDocument()
|
|
131
|
+
expect(srOnly?.textContent).toBe(nb.linkcard.openInNewTab)
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
test('does not announce a new-tab string when openInNewTab is false', async () => {
|
|
135
|
+
const { link } = await createLinkCardTest({ openInNewTab: false })
|
|
136
|
+
expect(link.querySelector('.pkt-sr-only')).not.toBeInTheDocument()
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
test('uses the catalogue default when strings is omitted', async () => {
|
|
140
|
+
const { link } = await createLinkCardTest({ openInNewTab: true })
|
|
141
|
+
const srOnly = link.querySelector('.pkt-sr-only')
|
|
142
|
+
expect(srOnly).toBeInTheDocument()
|
|
143
|
+
expect(srOnly?.textContent).toBe(nb.linkcard.openInNewTab)
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
test('uses a custom override from the strings property', async () => {
|
|
147
|
+
const { linkCard, link } = await createLinkCardTest({ openInNewTab: true })
|
|
148
|
+
linkCard.strings = { linkcard: { openInNewTab: 'Opens in a new tab' } }
|
|
149
|
+
await linkCard.updateComplete
|
|
150
|
+
|
|
151
|
+
const srOnly = link.querySelector('.pkt-sr-only')
|
|
152
|
+
expect(srOnly?.textContent).toBe('Opens in a new tab')
|
|
153
|
+
expect(link.textContent).not.toContain(nb.linkcard.openInNewTab)
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
test('hides the announcement when the override is an empty string', async () => {
|
|
157
|
+
const { linkCard, link } = await createLinkCardTest({ openInNewTab: true })
|
|
158
|
+
linkCard.strings = { linkcard: { openInNewTab: '' } }
|
|
159
|
+
await linkCard.updateComplete
|
|
160
|
+
|
|
161
|
+
expect(link.querySelector('.pkt-sr-only')).not.toBeInTheDocument()
|
|
162
|
+
expect(link.textContent).not.toContain(nb.linkcard.openInNewTab)
|
|
127
163
|
})
|
|
128
164
|
|
|
129
165
|
test('handles openInNewTab false correctly', async () => {
|
|
@@ -226,11 +262,13 @@ describe('PktLinkCard', () => {
|
|
|
226
262
|
const { linkCard, link } = await createLinkCardTest({ openInNewTab: false })
|
|
227
263
|
|
|
228
264
|
expect(link.getAttribute('target')).toBe('_self')
|
|
265
|
+
expect(link.querySelector('.pkt-sr-only')).not.toBeInTheDocument()
|
|
229
266
|
|
|
230
267
|
linkCard.openInNewTab = true
|
|
231
268
|
await linkCard.updateComplete
|
|
232
269
|
|
|
233
270
|
expect(link.getAttribute('target')).toBe('_blank')
|
|
271
|
+
expect(link.querySelector('.pkt-sr-only')?.textContent).toBe(nb.linkcard.openInNewTab)
|
|
234
272
|
})
|
|
235
273
|
})
|
|
236
274
|
|
|
@@ -4,27 +4,13 @@ import { PktElementWithSlot } from '@/base-elements/element-with-slot'
|
|
|
4
4
|
import { slotContent } from '@/directives/slot-content'
|
|
5
5
|
import '@/components/icon'
|
|
6
6
|
import { ifDefined } from 'lit/directives/if-defined.js'
|
|
7
|
+
import type { IPktLinkCardBase, TLinkCardSkin } from 'shared-types'
|
|
7
8
|
|
|
8
|
-
export type TLinkCardSkin
|
|
9
|
-
| 'normal'
|
|
10
|
-
| 'no-padding'
|
|
11
|
-
| 'blue'
|
|
12
|
-
| 'beige'
|
|
13
|
-
| 'green'
|
|
14
|
-
| 'gray'
|
|
15
|
-
| 'beige-outline'
|
|
16
|
-
| 'gray-outline';
|
|
9
|
+
export type { TLinkCardSkin }
|
|
17
10
|
|
|
18
|
-
export interface IPktLinkCard {
|
|
19
|
-
title?: string
|
|
20
|
-
href?: string
|
|
21
|
-
iconName?: string
|
|
22
|
-
external?: boolean
|
|
23
|
-
openInNewTab?: boolean
|
|
24
|
-
skin?: TLinkCardSkin
|
|
25
|
-
}
|
|
11
|
+
export interface IPktLinkCard extends IPktLinkCardBase {}
|
|
26
12
|
|
|
27
|
-
export class PktLinkCard extends PktElementWithSlot implements IPktLinkCard {
|
|
13
|
+
export class PktLinkCard extends PktElementWithSlot<IPktLinkCard> implements IPktLinkCard {
|
|
28
14
|
@property({ type: String, reflect: true }) title: string = ''
|
|
29
15
|
@property({ type: String, reflect: true }) href: string = '#'
|
|
30
16
|
@property({ type: String, reflect: true }) iconName: string = ''
|
|
@@ -41,6 +27,9 @@ export class PktLinkCard extends PktElementWithSlot implements IPktLinkCard {
|
|
|
41
27
|
.filter(Boolean)
|
|
42
28
|
.join(' ')
|
|
43
29
|
|
|
30
|
+
const s = this.pktStrings.get('linkcard')
|
|
31
|
+
const newTabLabel = this.openInNewTab ? s.openInNewTab : ''
|
|
32
|
+
|
|
44
33
|
return html`
|
|
45
34
|
<a
|
|
46
35
|
href=${this.href}
|
|
@@ -50,6 +39,7 @@ export class PktLinkCard extends PktElementWithSlot implements IPktLinkCard {
|
|
|
50
39
|
>
|
|
51
40
|
${this.iconName && html`<pkt-icon class="pkt-link__icon" name="${this.iconName}" />`}
|
|
52
41
|
${this.title && html`<div class=${titleClasses}>${this.title}</div>`}
|
|
42
|
+
${newTabLabel ? html`<span class="pkt-sr-only">${newTabLabel}</span>` : ''}
|
|
53
43
|
|
|
54
44
|
<div class="pkt-linkcard__text">${slotContent(this)}</div>
|
|
55
45
|
</a>
|
package/dist/alert-BD8YVKia.cjs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const e=require("./element-DiFhBcIl.cjs"),t=require("./class-map-C33ixq7O.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-CBK4zrdN.cjs"),i=require("./classutils-CbklAJDe.cjs"),a=require("./define-component-spec-DBNd2FJY.cjs");require("./icon-DIavy2cB.cjs"),require("./button-CF3dNKeI.cjs");var o=[`off`,`polite`,`assertive`],s=[`info`,`success`,`warning`,`error`],c=[`medium`,`small`,`xsmall`],l=a.t({name:`pkt-alert`,react:`PktAlert`,"css-class":`pkt-alert`,"dark-mode":!0,isElement:!0,isPureReact:!0,events:{onClose:{description:`React: Klikk-event for 'Lukk'-knappen`},close:{description:`Vue: Klikk-event for 'Lukk'-knappen`}},props:{title:{name:`Tittel`,description:`Tittelen som vises øverst i på meldingen`,type:`string`,category:`contents`},skin:{name:`Utseende`,description:`Hvordan type melding er dette?`,type:[...s],default:`info`,category:`ui`},date:{name:`Sist oppdatert`,description:`Dato som vises nederst i på meldingen`,type:`string`,category:`contents`},ariaLive:{name:`aria-live`,description:`Hvordan skal skjermleseren lese opp meldingen?`,type:[...o],default:`polite`,category:`accessibility`},size:{name:`Størrelse`,description:`Endrer størrelsen på ulike elementer i alerten.`,type:[...c],default:`medium`,category:`ui`},closeAlert:{name:`Vis 'Lukk'-knapp`,description:`Viser 'Lukk'-knappen`,type:`boolean`,default:!1,category:`ui`}},slots:{default:{description:`Innholdet i meldingen`}},deprecated:{compact:{name:`Kompakt (deprecated)`,description:"Bruk `size` i stedet; uten eksplisitt `size` gir compact størrelsen 'small'.",type:`boolean`,category:`ui`,default:!1}}}),u=class extends r.t{constructor(){super(),this.compact=l.deprecated.compact.default,this.title=``,this.skin=l.props.skin.default,this.ariaLive=l.props.ariaLive.default,this.ariaLiveAttr=null,this.closeAlert=l.props.closeAlert.default,this.date=null,this.role=`status`,this._isClosed=!1,this.close=e=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent(`close`,{detail:{origin:e},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`on-close`,{detail:{origin:e},bubbles:!0,composed:!0}))},this._isClosed=!1}connectedCallback(){super.connectedCallback(),this.ariaLiveAttr=this.getAttribute(`aria-live`)||this.ariaLive}attributeChangedCallback(e,t,n){e===`ariaLive`&&(this.ariaLiveAttr=n),super.attributeChangedCallback(e,t,n)}updated(e){super.updated(e),e.has(`ariaLive`)&&(this.ariaLiveAttr=this.ariaLive),e.has(`_isClosed`)&&i.t(this,`pkt-hide`,this._isClosed)}render(){let i=this.size??(this.compact?`small`:`medium`),a={"pkt-alert":!0,[`pkt-alert--${i}`]:!0,[`pkt-alert--${this.skin}`]:!0,"pkt-hide":this._isClosed},o={"pkt-alert__grid":!0,"pkt-alert__noTitle":!this.title,"pkt-alert__noDate":!this.date};return e._`
|
|
2
|
-
<div class=${t.t(a)} aria-live=${this.ariaLiveAttr}>
|
|
3
|
-
<div class=${t.t(o)}>
|
|
4
|
-
<pkt-icon
|
|
5
|
-
class="pkt-alert__icon"
|
|
6
|
-
aria-hidden="true"
|
|
7
|
-
name=${this.skin===`info`?`alert-information`:`alert-${this.skin}`}
|
|
8
|
-
></pkt-icon>
|
|
9
|
-
|
|
10
|
-
${this.closeAlert?e._`
|
|
11
|
-
<div class="pkt-alert__close">
|
|
12
|
-
<pkt-button
|
|
13
|
-
tabindex="0"
|
|
14
|
-
aria-label="close"
|
|
15
|
-
size=${i}
|
|
16
|
-
type="button"
|
|
17
|
-
skin="tertiary"
|
|
18
|
-
iconName="close"
|
|
19
|
-
variant="icon-only"
|
|
20
|
-
@click=${this.close}
|
|
21
|
-
>
|
|
22
|
-
<span class="sr-only">${this.pktStrings.get(`generic`).close}</span>
|
|
23
|
-
</pkt-button>
|
|
24
|
-
</div>
|
|
25
|
-
`:e.h}
|
|
26
|
-
${this.title?e._`<div class="pkt-alert__title">${this.title}</div>`:e.h}
|
|
27
|
-
|
|
28
|
-
<div class="pkt-alert__text">${r.n(this)}</div>
|
|
29
|
-
|
|
30
|
-
${this.date?e._`<div class="pkt-alert__date">
|
|
31
|
-
${n.t(this.pktStrings.get(`alert`).lastUpdated,{date:this.date})}
|
|
32
|
-
</div>`:e.h}
|
|
33
|
-
</div>
|
|
34
|
-
</div>
|
|
35
|
-
`}};e.n([e.u({type:Boolean,reflect:!1})],u.prototype,`compact`,void 0),e.n([e.u({type:String,reflect:!0})],u.prototype,`title`,void 0),e.n([e.u({type:String,reflect:!0})],u.prototype,`skin`,void 0),e.n([e.u({type:String})],u.prototype,`ariaLive`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`aria-live`})],u.prototype,`ariaLiveAttr`,void 0),e.n([e.u({type:Boolean,reflect:!0})],u.prototype,`closeAlert`,void 0),e.n([e.u({type:String,reflect:!0})],u.prototype,`date`,void 0),e.n([e.u({type:String,reflect:!0})],u.prototype,`role`,void 0),e.n([e.u({type:String,attribute:`size`})],u.prototype,`size`,void 0),e.n([e.l()],u.prototype,`_isClosed`,void 0);try{e.d(`pkt-alert`)(u)}catch{console.warn(`Forsøker å definere <pkt-alert>, men den er allerede definert`)}var d=u;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return d}});
|
package/dist/button-CF3dNKeI.cjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const e=require("./element-DiFhBcIl.cjs"),t=require("./class-map-C33ixq7O.cjs"),n=require("./element-with-slot-CBK4zrdN.cjs");require("./icon-DIavy2cB.cjs");const r=require("./if-defined-Dc3xFDaM.cjs");var i=`https://punkt-cdn.oslo.kommune.no/latest/animations/`;typeof window<`u`&&(window.pktAnimationPath=window.pktAnimationPath||i);var a=class a extends n.t{constructor(...e){super(...e),this.iconName=`user`,this.secondIconName=`user`,this.mode=`light`,this.size=`medium`,this.fullWidth=!1,this.fullWidthOnMobile=!1,this.skin=`primary`,this.variant=`label-only`,this.state=`normal`,this.type=`button`,this.form=void 0,this.isLoading=!1,this.disabled=!1,this.loadingAnimationPath=typeof window<`u`?window.pktAnimationPath:i,this.relocatedAria={}}connectedCallback(){super.connectedCallback(),this.addEventListener(`click`,e=>{(this.disabled||this.hasAttribute(`disabled`)||this.isLoading)&&(e.preventDefault(),e.stopImmediatePropagation())},!0),this.addEventListener(`keydown`,e=>{(this.disabled||this.hasAttribute(`disabled`)||this.isLoading)&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopImmediatePropagation())},!0)}attributeChangedCallback(e,t,n){super.attributeChangedCallback(e,t,n),e===`disabled`&&n===`false`&&(this.disabled=!1),(e===`isloading`||e===`isLoading`)&&n===`false`&&(this.isLoading=!1)}static{this.relocatedAriaAttributes=[`aria-haspopup`,`aria-expanded`,`aria-controls`]}willUpdate(e){super.willUpdate(e);let t=!1,n={...this.relocatedAria};for(let e of a.relocatedAriaAttributes){let r=this.getAttribute(e);r!==null&&(n[e]=r,this.removeAttribute(e),t=!0)}t&&(this.relocatedAria=n)}firstUpdated(e){super.firstUpdated(e),this.disabled===`false`&&(this.disabled=!1),this.isLoading===`false`&&(this.isLoading=!1)}render(){let i=this.form??this.getAttribute(`form`)??void 0,a={"pkt-btn":!0,[`pkt-btn--${this.size}`]:!!this.size,[`pkt-btn--${this.skin}`]:!!this.skin,[`pkt-btn--${this.variant}`]:!!this.variant,[`pkt-btn--${this.color}`]:!!this.color,[`pkt-btn--${this.state}`]:!!this.state,"pkt-btn--full":!!this.fullWidth,"pkt-btn--full-small":!!this.fullWidthOnMobile,"pkt-btn--disabled":!!this.disabled,"pkt-btn--isLoading":!!this.isLoading};return e._`
|
|
2
|
-
<button
|
|
3
|
-
class=${t.t(a)}
|
|
4
|
-
type=${this.type}
|
|
5
|
-
?disabled=${!!this.disabled}
|
|
6
|
-
aria-busy=${r.t(this.isLoading?`true`:void 0)}
|
|
7
|
-
aria-disabled=${r.t(this.disabled||this.isLoading?`true`:void 0)}
|
|
8
|
-
aria-haspopup=${r.t(this.relocatedAria[`aria-haspopup`])}
|
|
9
|
-
aria-expanded=${r.t(this.relocatedAria[`aria-expanded`])}
|
|
10
|
-
aria-controls=${r.t(this.relocatedAria[`aria-controls`])}
|
|
11
|
-
form=${r.t(i)}
|
|
12
|
-
>
|
|
13
|
-
${this.isLoading?e._`<pkt-icon
|
|
14
|
-
class="pkt-btn__icon pkt-btn__spinner"
|
|
15
|
-
name="spinner-blue"
|
|
16
|
-
path=${r.t(this.loadingAnimationPath)}
|
|
17
|
-
></pkt-icon>`:e.h}
|
|
18
|
-
${this.variant===`label-only`?e.h:e._`<pkt-icon
|
|
19
|
-
class="pkt-btn__icon pkt-icon"
|
|
20
|
-
name=${this.iconName}
|
|
21
|
-
path=${r.t(this.iconPath)}
|
|
22
|
-
></pkt-icon>`}
|
|
23
|
-
<span class="pkt-btn__text">${n.n(this)}</span>
|
|
24
|
-
${this.variant===`icons-right-and-left`?e._`<pkt-icon
|
|
25
|
-
class="pkt-btn__icon"
|
|
26
|
-
name=${this.secondIconName}
|
|
27
|
-
path=${r.t(this.secondIconPath)}
|
|
28
|
-
></pkt-icon>`:e.h}
|
|
29
|
-
</button>
|
|
30
|
-
`}};e.n([e.u({type:String})],a.prototype,`iconName`,void 0),e.n([e.u({type:String})],a.prototype,`secondIconName`,void 0),e.n([e.u({type:String})],a.prototype,`iconPath`,void 0),e.n([e.u({type:String})],a.prototype,`secondIconPath`,void 0),e.n([e.u({type:String})],a.prototype,`mode`,void 0),e.n([e.u({type:String})],a.prototype,`size`,void 0),e.n([e.u({type:Boolean,attribute:`full-width`})],a.prototype,`fullWidth`,void 0),e.n([e.u({type:Boolean,attribute:`full-width-on-mobile`})],a.prototype,`fullWidthOnMobile`,void 0),e.n([e.u({type:String})],a.prototype,`color`,void 0),e.n([e.u({type:String})],a.prototype,`skin`,void 0),e.n([e.u({type:String})],a.prototype,`variant`,void 0),e.n([e.u({type:String,reflect:!0})],a.prototype,`state`,void 0),e.n([e.u({type:String,reflect:!0})],a.prototype,`type`,void 0),e.n([e.u({type:String})],a.prototype,`form`,void 0),e.n([e.u({type:Boolean,reflect:!0})],a.prototype,`isLoading`,void 0),e.n([e.u({type:Boolean,reflect:!0})],a.prototype,`disabled`,void 0),e.n([e.u({type:String})],a.prototype,`loadingAnimationPath`,void 0),e.n([e.l()],a.prototype,`relocatedAria`,void 0);try{e.d(`pkt-button`)(a)}catch{console.warn(`Forsøker å definere <pkt-button>, men den er allerede definert`)}var o=a;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./element-DiFhBcIl.cjs");var t=t=>t??e.h;Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return t}});
|