@oslokommune/punkt-elements 13.8.0 → 13.9.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 CHANGED
@@ -5,6 +5,23 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
5
5
 
6
6
  ---
7
7
 
8
+ ## [13.9.0](https://github.com/oslokommune/punkt/compare/13.8.1...13.9.0) (2025-10-17)
9
+
10
+ ### ⚠ BREAKING CHANGES
11
+ Ingen
12
+
13
+ ### Features
14
+ Ingen
15
+
16
+ ### Bug Fixes
17
+ Ingen
18
+
19
+ ### Chores
20
+ Ingen
21
+
22
+ ---
23
+
24
+
8
25
  ## [13.8.0](https://github.com/oslokommune/punkt/compare/13.7.0...13.8.0) (2025-10-15)
9
26
 
10
27
  ### ⚠ BREAKING CHANGES
package/dist/index.d.ts CHANGED
@@ -308,6 +308,21 @@ declare interface IPktSelect {
308
308
  value: string;
309
309
  }
310
310
 
311
+ export declare interface IPktTabItem {
312
+ active?: boolean;
313
+ href?: string;
314
+ icon?: string;
315
+ controls?: string;
316
+ tag?: string;
317
+ tagSkin?: TTabItemSkin;
318
+ index?: number;
319
+ }
320
+
321
+ export declare interface IPktTabs {
322
+ arrowNav?: boolean;
323
+ disableArrowNav?: boolean;
324
+ }
325
+
311
326
  declare interface IPktTag {
312
327
  closeTag?: boolean;
313
328
  size?: TPktSize;
@@ -1251,6 +1266,42 @@ declare class PktSlotController implements ReactiveController {
1251
1266
  private handleSlotMutations;
1252
1267
  }
1253
1268
 
1269
+ export declare class PktTabItem extends PktElement<IPktTabItem> implements IPktTabItem {
1270
+ active: boolean;
1271
+ href: string;
1272
+ icon: string;
1273
+ controls: string;
1274
+ tag: string;
1275
+ tagSkin: TTabItemSkin;
1276
+ index: number;
1277
+ context?: TabsContext;
1278
+ elementRef: Ref<HTMLAnchorElement | HTMLButtonElement>;
1279
+ defaultSlot: Ref<HTMLElement>;
1280
+ slotController: PktSlotController;
1281
+ constructor();
1282
+ connectedCallback(): void;
1283
+ private handleClick;
1284
+ private handleKeyUp;
1285
+ render(): TemplateResult<1>;
1286
+ }
1287
+
1288
+ export declare class PktTabs extends PktElement<IPktTabs> implements IPktTabs {
1289
+ arrowNav: boolean;
1290
+ disableArrowNav: boolean;
1291
+ private tabRefs;
1292
+ private tabCount;
1293
+ private get useArrowNav();
1294
+ defaultSlot: Ref<HTMLElement>;
1295
+ slotController: PktSlotController;
1296
+ constructor();
1297
+ private context;
1298
+ updated(changedProperties: PropertyValues): void;
1299
+ private registerTab;
1300
+ private handleClick;
1301
+ private handleKeyUp;
1302
+ render(): TemplateResult<1>;
1303
+ }
1304
+
1254
1305
  export declare class PktTag extends PktElement<IPktTag> implements IPktTag {
1255
1306
  slotController: PktSlotController;
1256
1307
  defaultSlot: Ref<HTMLElement>;
@@ -1330,6 +1381,25 @@ declare type Props_8 = ElementProps<PktTextarea, 'autocomplete' | 'rows'>;
1330
1381
 
1331
1382
  declare type Props_9 = ElementProps<PktTextinput, 'value' | 'type' | 'size' | 'autocomplete' | 'iconNameRight' | 'prefix' | 'suffix' | 'omitSearchIcon'>;
1332
1383
 
1384
+ declare interface TabsContext {
1385
+ /**
1386
+ * Whether arrow navigation is enabled (computed from arrowNav && !disableArrowNav)
1387
+ */
1388
+ useArrowNav: boolean;
1389
+ /**
1390
+ * Register a tab item with the parent tabs container
1391
+ */
1392
+ registerTab: (element: HTMLElement, index: number) => void;
1393
+ /**
1394
+ * Handle click event from a tab item
1395
+ */
1396
+ handleClick: (index: number) => void;
1397
+ /**
1398
+ * Handle keyboard event from a tab item
1399
+ */
1400
+ handleKeyUp: (event: KeyboardEvent, index: number) => void;
1401
+ }
1402
+
1333
1403
  declare type TAlertSkin = 'error' | 'success' | 'warning' | 'info';
1334
1404
 
1335
1405
  declare type TAriaAutoComplete = 'none' | 'inline' | 'list' | 'both';
@@ -1430,6 +1500,8 @@ export declare type TSelectOption = {
1430
1500
  hidden?: boolean;
1431
1501
  };
1432
1502
 
1503
+ export declare type TTabItemSkin = 'blue' | 'green' | 'red' | 'beige' | 'yellow' | 'grey' | 'gray' | 'blue-light';
1504
+
1433
1505
  export declare type TTagSkin = 'blue' | 'blue-dark' | 'blue-light' | 'green' | 'red' | 'yellow' | 'beige' | 'gray' | 'grey';
1434
1506
 
1435
1507
  export declare type TTagType = 'button' | 'reset' | 'submit';
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./alert-Ci7WvRXi.cjs"),l=require("./accordionitem-DCZrHVNR.cjs"),b=require("./backlink-BzEvli8m.cjs"),m=require("./button-CXJQ_Wgl.cjs"),P=require("./calendar-BaMrdMDZ.cjs"),g=require("./card-Cf-UcGAP.cjs"),h=require("./combobox-BJ1gA0f0.cjs"),f=require("./consent-BeOjxQdR.cjs"),y=require("./checkbox-CTxc8wQe.cjs"),t=require("./element-CJ_QKaki.cjs"),O=require("./pkt-slot-controller-BzddBp7z.cjs"),s=require("./ref-BFa5Utho.cjs"),j=require("./class-map-C_erArZz.cjs"),k=require("./datepicker-DVqmQAOe.cjs"),q=require("./helptext-CVQP3pis.cjs"),x=require("./heading--JKFppLS.cjs"),C=require("./icon-BGuizDwk.cjs"),v=require("./input-wrapper-BsQ7oFMd.cjs"),S=require("./link-Da3pZ_CW.cjs"),$=require("./linkcard-BM23gzhS.cjs"),L=require("./loader-Bo8RCbCJ.cjs"),T=require("./messagebox-C76IcXTl.cjs"),_=require("./modal-Cdz9JcCX.cjs"),A=require("./progressbar-CazcIzVT.cjs"),p=require("./radiobutton-D1fihs8R.cjs"),B=require("./tag-EFUKrc8q.cjs"),I=require("./textarea-aUG3S7C2.cjs"),D=require("./textinput-mUERucRy.cjs"),M=require("./select-D-m1PhpA.cjs");var R=Object.defineProperty,H=Object.getOwnPropertyDescriptor,o=(a,e,r,i)=>{for(var n=i>1?void 0:i?H(e,r):e,u=a.length-1,c;u>=0;u--)(c=a[u])&&(n=(i?c(e,r,n):c(n))||n);return i&&n&&R(e,r,n),n};exports.PktComponent=class extends t.PktElement{constructor(){super(),this.string="",this.strings=[],this.darkmode=!1,this._list=[],this.defaultSlot=s.e(),this.namedSlot=s.e(),this.slotController=new O.PktSlotController(this,this.defaultSlot,this.namedSlot)}connectedCallback(){this.strings.length&&this.strings.forEach(e=>{this._list.push(e.toUpperCase())}),super.connectedCallback()}render(){const e={"pkt-component":!0,"pkt-component--has-list":this.strings.length>0,"pkt-darkmode":this.darkmode};return t.x`
2
- <div class="${j.e(e)}">
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./alert-Ci7WvRXi.cjs"),l=require("./accordionitem-DCZrHVNR.cjs"),m=require("./backlink-BzEvli8m.cjs"),g=require("./button-CXJQ_Wgl.cjs"),P=require("./calendar-BaMrdMDZ.cjs"),h=require("./card-Cf-UcGAP.cjs"),f=require("./combobox-BJ1gA0f0.cjs"),y=require("./consent-BeOjxQdR.cjs"),O=require("./checkbox-CTxc8wQe.cjs"),t=require("./element-CJ_QKaki.cjs"),j=require("./pkt-slot-controller-BzddBp7z.cjs"),s=require("./ref-BFa5Utho.cjs"),q=require("./class-map-C_erArZz.cjs"),k=require("./datepicker-DVqmQAOe.cjs"),x=require("./helptext-CVQP3pis.cjs"),C=require("./heading--JKFppLS.cjs"),v=require("./icon-BGuizDwk.cjs"),S=require("./input-wrapper-BsQ7oFMd.cjs"),T=require("./link-Da3pZ_CW.cjs"),$=require("./linkcard-BM23gzhS.cjs"),L=require("./loader-Bo8RCbCJ.cjs"),_=require("./messagebox-C76IcXTl.cjs"),I=require("./modal-Cdz9JcCX.cjs"),A=require("./progressbar-CazcIzVT.cjs"),p=require("./radiobutton-D1fihs8R.cjs"),B=require("./tag-EFUKrc8q.cjs"),d=require("./tabitem-D5zyipN1.cjs"),D=require("./textarea-aUG3S7C2.cjs"),M=require("./textinput-mUERucRy.cjs"),R=require("./select-D-m1PhpA.cjs");var H=Object.defineProperty,w=Object.getOwnPropertyDescriptor,o=(a,e,r,i)=>{for(var n=i>1?void 0:i?w(e,r):e,u=a.length-1,c;u>=0;u--)(c=a[u])&&(n=(i?c(e,r,n):c(n))||n);return i&&n&&H(e,r,n),n};exports.PktComponent=class extends t.PktElement{constructor(){super(),this.string="",this.strings=[],this.darkmode=!1,this._list=[],this.defaultSlot=s.e(),this.namedSlot=s.e(),this.slotController=new j.PktSlotController(this,this.defaultSlot,this.namedSlot)}connectedCallback(){this.strings.length&&this.strings.forEach(e=>{this._list.push(e.toUpperCase())}),super.connectedCallback()}render(){const e={"pkt-component":!0,"pkt-component--has-list":this.strings.length>0,"pkt-darkmode":this.darkmode};return t.x`
2
+ <div class="${q.e(e)}">
3
3
  <h1 class="pkt-txt-28">${this.string}</h1>
4
4
 
5
5
  <h2 class="pkt-txt-22">Innhold fra attributter og funksjoner</h2>
@@ -26,4 +26,4 @@
26
26
  <ul>
27
27
  ${e.map(r=>t.x`<li>${r}</li>`)}
28
28
  </ul>
29
- `}doStuff(e){return e.reverse()}handleGreeting(){this.dispatchEvent(new CustomEvent("pkt-greeting",{detail:"Hei på deg!"}))}};o([t.n({type:String})],exports.PktComponent.prototype,"string",2);o([t.n({converter:P.csvToArray})],exports.PktComponent.prototype,"strings",2);o([t.n({type:Boolean})],exports.PktComponent.prototype,"darkmode",2);o([t.n({type:Array})],exports.PktComponent.prototype,"_list",2);exports.PktComponent=o([t.t("pkt-component")],exports.PktComponent);Object.defineProperty(exports,"PktAlert",{enumerable:!0,get:()=>d.PktAlert});exports.PktAccordion=l.PktAccordion;exports.PktAccordionItem=l.PktAccordionItem;Object.defineProperty(exports,"PktBackLink",{enumerable:!0,get:()=>b.PktBackLink});Object.defineProperty(exports,"PktButton",{enumerable:!0,get:()=>m.PktButton});Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>P.PktCalendar});Object.defineProperty(exports,"PktCard",{enumerable:!0,get:()=>g.PktCard});Object.defineProperty(exports,"PktCombobox",{enumerable:!0,get:()=>h.PktCombobox});Object.defineProperty(exports,"PktConsent",{enumerable:!0,get:()=>f.PktConsent});Object.defineProperty(exports,"PktCheckbox",{enumerable:!0,get:()=>y.PktCheckbox});Object.defineProperty(exports,"PktDateTags",{enumerable:!0,get:()=>k.PktDateTags});Object.defineProperty(exports,"PktDatepicker",{enumerable:!0,get:()=>k.PktDatepicker});Object.defineProperty(exports,"PktHelptext",{enumerable:!0,get:()=>q.PktHelptext});Object.defineProperty(exports,"PktHeading",{enumerable:!0,get:()=>x.PktHeading});Object.defineProperty(exports,"PktIcon",{enumerable:!0,get:()=>C.PktIcon});Object.defineProperty(exports,"PktInputWrapper",{enumerable:!0,get:()=>v.PktInputWrapper});Object.defineProperty(exports,"PktLink",{enumerable:!0,get:()=>S.PktLink});Object.defineProperty(exports,"PktLinkCard",{enumerable:!0,get:()=>$.PktLinkCard});Object.defineProperty(exports,"PktLoader",{enumerable:!0,get:()=>L.PktLoader});Object.defineProperty(exports,"PktMessagebox",{enumerable:!0,get:()=>T.PktMessagebox});Object.defineProperty(exports,"PktModal",{enumerable:!0,get:()=>_.PktModal});Object.defineProperty(exports,"PktProgressbar",{enumerable:!0,get:()=>A.PktProgressbar});Object.defineProperty(exports,"PktRadioButton",{enumerable:!0,get:()=>p.PktRadioButton});Object.defineProperty(exports,"PktRadiobutton",{enumerable:!0,get:()=>p.PktRadioButton});Object.defineProperty(exports,"PktTag",{enumerable:!0,get:()=>B.PktTag});Object.defineProperty(exports,"PktTextarea",{enumerable:!0,get:()=>I.PktTextarea});Object.defineProperty(exports,"PktTextinput",{enumerable:!0,get:()=>D.PktTextinput});Object.defineProperty(exports,"PktSelect",{enumerable:!0,get:()=>M.PktSelect});
29
+ `}doStuff(e){return e.reverse()}handleGreeting(){this.dispatchEvent(new CustomEvent("pkt-greeting",{detail:"Hei på deg!"}))}};o([t.n({type:String})],exports.PktComponent.prototype,"string",2);o([t.n({converter:P.csvToArray})],exports.PktComponent.prototype,"strings",2);o([t.n({type:Boolean})],exports.PktComponent.prototype,"darkmode",2);o([t.n({type:Array})],exports.PktComponent.prototype,"_list",2);exports.PktComponent=o([t.t("pkt-component")],exports.PktComponent);Object.defineProperty(exports,"PktAlert",{enumerable:!0,get:()=>b.PktAlert});exports.PktAccordion=l.PktAccordion;exports.PktAccordionItem=l.PktAccordionItem;Object.defineProperty(exports,"PktBackLink",{enumerable:!0,get:()=>m.PktBackLink});Object.defineProperty(exports,"PktButton",{enumerable:!0,get:()=>g.PktButton});Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>P.PktCalendar});Object.defineProperty(exports,"PktCard",{enumerable:!0,get:()=>h.PktCard});Object.defineProperty(exports,"PktCombobox",{enumerable:!0,get:()=>f.PktCombobox});Object.defineProperty(exports,"PktConsent",{enumerable:!0,get:()=>y.PktConsent});Object.defineProperty(exports,"PktCheckbox",{enumerable:!0,get:()=>O.PktCheckbox});Object.defineProperty(exports,"PktDateTags",{enumerable:!0,get:()=>k.PktDateTags});Object.defineProperty(exports,"PktDatepicker",{enumerable:!0,get:()=>k.PktDatepicker});Object.defineProperty(exports,"PktHelptext",{enumerable:!0,get:()=>x.PktHelptext});Object.defineProperty(exports,"PktHeading",{enumerable:!0,get:()=>C.PktHeading});Object.defineProperty(exports,"PktIcon",{enumerable:!0,get:()=>v.PktIcon});Object.defineProperty(exports,"PktInputWrapper",{enumerable:!0,get:()=>S.PktInputWrapper});Object.defineProperty(exports,"PktLink",{enumerable:!0,get:()=>T.PktLink});Object.defineProperty(exports,"PktLinkCard",{enumerable:!0,get:()=>$.PktLinkCard});Object.defineProperty(exports,"PktLoader",{enumerable:!0,get:()=>L.PktLoader});Object.defineProperty(exports,"PktMessagebox",{enumerable:!0,get:()=>_.PktMessagebox});Object.defineProperty(exports,"PktModal",{enumerable:!0,get:()=>I.PktModal});Object.defineProperty(exports,"PktProgressbar",{enumerable:!0,get:()=>A.PktProgressbar});Object.defineProperty(exports,"PktRadioButton",{enumerable:!0,get:()=>p.PktRadioButton});Object.defineProperty(exports,"PktRadiobutton",{enumerable:!0,get:()=>p.PktRadioButton});Object.defineProperty(exports,"PktTag",{enumerable:!0,get:()=>B.PktTag});exports.PktTabItem=d.PktTabItem;exports.PktTabs=d.PktTabs;Object.defineProperty(exports,"PktTextarea",{enumerable:!0,get:()=>D.PktTextarea});Object.defineProperty(exports,"PktTextinput",{enumerable:!0,get:()=>M.PktTextinput});Object.defineProperty(exports,"PktSelect",{enumerable:!0,get:()=>R.PktSelect});
package/dist/pkt-index.js CHANGED
@@ -1,14 +1,14 @@
1
- import { P as A } from "./alert-Dh1YhaBq.js";
2
- import { P as w, a as B } from "./accordionitem-C_URrDjP.js";
3
- import { P as E } from "./backlink-CI_jMGzZ.js";
1
+ import { P as T } from "./alert-Dh1YhaBq.js";
2
+ import { P as I, a as w } from "./accordionitem-C_URrDjP.js";
3
+ import { P as D } from "./backlink-CI_jMGzZ.js";
4
4
  import { P as O } from "./button-CCFAUJa0.js";
5
- import { c as d } from "./calendar-DtJh7UYD.js";
5
+ import { c as f } from "./calendar-DtJh7UYD.js";
6
6
  import { P as j } from "./calendar-DtJh7UYD.js";
7
7
  import { P as G } from "./card-M1X36b6i.js";
8
8
  import { P as K } from "./combobox-Ct0NNY1p.js";
9
9
  import { P as U } from "./consent-B2hIQh4b.js";
10
10
  import { P as q } from "./checkbox-_5LbXU7N.js";
11
- import { P as f, t as h, x as P, n, a as c } from "./element-CRDRygXu.js";
11
+ import { P as d, t as h, x as P, n, a as c } from "./element-CRDRygXu.js";
12
12
  import { P as x } from "./pkt-slot-controller-BPGj-LC5.js";
13
13
  import { e as m, n as k } from "./ref-Xa5dbh--.js";
14
14
  import { e as u } from "./class-map-wy7PUk0P.js";
@@ -22,18 +22,19 @@ import { P as nt } from "./linkcard-RIK5xqbd.js";
22
22
  import { P as pt } from "./loader-BVvBzaPI.js";
23
23
  import { P as Pt } from "./messagebox-DwdMXoAe.js";
24
24
  import { P as kt } from "./modal-BGXk3f9u.js";
25
- import { P as ft } from "./progressbar-BbVei20_.js";
25
+ import { P as dt } from "./progressbar-BbVei20_.js";
26
26
  import { P as ct, P as xt } from "./radiobutton-DODROIBF.js";
27
27
  import { P as gt } from "./tag-CqMgt01I.js";
28
- import { P as St } from "./textarea-DCKKhs1B.js";
29
- import { P as Ct } from "./textinput-B5Ai5R8L.js";
30
- import { P as yt } from "./select-BG2MBQbh.js";
28
+ import { a as bt, P as St } from "./tabitem-NV2fzs_-.js";
29
+ import { P as $t } from "./textarea-DCKKhs1B.js";
30
+ import { P as _t } from "./textinput-B5Ai5R8L.js";
31
+ import { P as Tt } from "./select-BG2MBQbh.js";
31
32
  var g = Object.defineProperty, v = Object.getOwnPropertyDescriptor, s = (t, e, i, a) => {
32
33
  for (var r = a > 1 ? void 0 : a ? v(e, i) : e, p = t.length - 1, l; p >= 0; p--)
33
34
  (l = t[p]) && (r = (a ? l(e, i, r) : l(r)) || r);
34
35
  return a && r && g(e, i, r), r;
35
36
  };
36
- let o = class extends f {
37
+ let o = class extends d {
37
38
  constructor() {
38
39
  super(), this.string = "", this.strings = [], this.darkmode = !1, this._list = [], this.defaultSlot = m(), this.namedSlot = m(), this.slotController = new x(this, this.defaultSlot, this.namedSlot);
39
40
  }
@@ -108,7 +109,7 @@ s([
108
109
  n({ type: String })
109
110
  ], o.prototype, "string", 2);
110
111
  s([
111
- n({ converter: d })
112
+ n({ converter: f })
112
113
  ], o.prototype, "strings", 2);
113
114
  s([
114
115
  n({ type: Boolean })
@@ -120,10 +121,10 @@ o = s([
120
121
  c("pkt-component")
121
122
  ], o);
122
123
  export {
123
- w as PktAccordion,
124
- B as PktAccordionItem,
125
- A as PktAlert,
126
- E as PktBackLink,
124
+ I as PktAccordion,
125
+ w as PktAccordionItem,
126
+ T as PktAlert,
127
+ D as PktBackLink,
127
128
  O as PktButton,
128
129
  j as PktCalendar,
129
130
  G as PktCard,
@@ -142,11 +143,13 @@ export {
142
143
  pt as PktLoader,
143
144
  Pt as PktMessagebox,
144
145
  kt as PktModal,
145
- ft as PktProgressbar,
146
+ dt as PktProgressbar,
146
147
  ct as PktRadioButton,
147
148
  xt as PktRadiobutton,
148
- yt as PktSelect,
149
+ Tt as PktSelect,
150
+ bt as PktTabItem,
151
+ St as PktTabs,
149
152
  gt as PktTag,
150
- St as PktTextarea,
151
- Ct as PktTextinput
153
+ $t as PktTextarea,
154
+ _t as PktTextinput
152
155
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./tabitem-D5zyipN1.cjs");exports.PktTabItem=e.PktTabItem;exports.PktTabs=e.PktTabs;exports.default=e.PktTabs;
@@ -0,0 +1,7 @@
1
+ import { P as t } from "./tabitem-NV2fzs_-.js";
2
+ import { a as e } from "./tabitem-NV2fzs_-.js";
3
+ export {
4
+ e as PktTabItem,
5
+ t as PktTabs,
6
+ t as default
7
+ };
@@ -0,0 +1,65 @@
1
+ "use strict";const a=require("./element-CJ_QKaki.cjs"),g=require("./pkt-slot-controller-BzddBp7z.cjs"),v=require("./state-DSjcvzDN.cjs"),p=require("./ref-BFa5Utho.cjs"),u=require("./if-defined-Bc9-_I01.cjs");/**
2
+ * @license
3
+ * Copyright 2021 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */let C=class extends Event{constructor(t,s,i,e){super("context-request",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=s,this.callback=i,this.subscribe=e??!1}};/**
6
+ * @license
7
+ * Copyright 2021 Google LLC
8
+ * SPDX-License-Identifier: BSD-3-Clause
9
+ *//**
10
+ * @license
11
+ * Copyright 2021 Google LLC
12
+ * SPDX-License-Identifier: BSD-3-Clause
13
+ */let k=class{constructor(t,s,i,e){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(n,r)=>{this.unsubscribe&&(this.unsubscribe!==r&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=n,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(n,r)),this.unsubscribe=r},this.host=t,s.context!==void 0){const n=s;this.context=n.context,this.callback=n.callback,this.subscribe=n.subscribe??!1}else this.context=s,this.callback=i,this.subscribe=e??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new C(this.context,this.host,this.t,this.subscribe))}};/**
14
+ * @license
15
+ * Copyright 2021 Google LLC
16
+ * SPDX-License-Identifier: BSD-3-Clause
17
+ */class ${get value(){return this.o}set value(t){this.setValue(t)}setValue(t,s=!1){const i=s||!Object.is(t,this.o);this.o=t,i&&this.updateObservers()}constructor(t){this.subscriptions=new Map,this.updateObservers=()=>{for(const[s,{disposer:i}]of this.subscriptions)s(this.o,i)},t!==void 0&&(this.value=t)}addCallback(t,s,i){if(!i)return void t(this.value);this.subscriptions.has(t)||this.subscriptions.set(t,{disposer:()=>{this.subscriptions.delete(t)},consumerHost:s});const{disposer:e}=this.subscriptions.get(t);t(this.value,e)}clearCallbacks(){this.subscriptions.clear()}}/**
18
+ * @license
19
+ * Copyright 2021 Google LLC
20
+ * SPDX-License-Identifier: BSD-3-Clause
21
+ */let m=class extends Event{constructor(t,s){super("context-provider",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=s}};class w extends ${constructor(t,s,i){var e,n;super(s.context!==void 0?s.initialValue:i),this.onContextRequest=r=>{if(r.context!==this.context)return;const c=r.contextTarget??r.composedPath()[0];c!==this.host&&(r.stopPropagation(),this.addCallback(r.callback,c,r.subscribe))},this.onProviderRequest=r=>{if(r.context!==this.context||(r.contextTarget??r.composedPath()[0])===this.host)return;const c=new Set;for(const[f,{consumerHost:x}]of this.subscriptions)c.has(f)||(c.add(f),x.dispatchEvent(new C(this.context,x,f,!0)));r.stopPropagation()},this.host=t,s.context!==void 0?this.context=s.context:this.context=s,this.attachListeners(),(n=(e=this.host).addController)==null||n.call(e,this)}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest)}hostConnected(){this.host.dispatchEvent(new m(this.context,this.host))}}/**
22
+ * @license
23
+ * Copyright 2017 Google LLC
24
+ * SPDX-License-Identifier: BSD-3-Clause
25
+ */function P({context:o}){return(t,s)=>{const i=new WeakMap;if(typeof s=="object")return{get(){return t.get.call(this)},set(e){return i.get(this).setValue(e),t.set.call(this,e)},init(e){return i.set(this,new w(this,{context:o,initialValue:e})),e}};{t.constructor.addInitializer((r=>{i.set(r,new w(r,{context:o}))}));const e=Object.getOwnPropertyDescriptor(t,s);let n;if(e===void 0){const r=new WeakMap;n={get(){return r.get(this)},set(c){i.get(this).setValue(c),r.set(this,c)},configurable:!0,enumerable:!0}}else{const r=e.set;n={...e,set(c){i.get(this).setValue(c),r==null||r.call(this,c)}}}return void Object.defineProperty(t,s,n)}}}/**
26
+ * @license
27
+ * Copyright 2022 Google LLC
28
+ * SPDX-License-Identifier: BSD-3-Clause
29
+ */function S({context:o,subscribe:t}){return(s,i)=>{typeof i=="object"?i.addInitializer((function(){new k(this,{context:o,callback:e=>{s.set.call(this,e)},subscribe:t})})):s.constructor.addInitializer((e=>{new k(e,{context:o,callback:n=>{e[i]=n},subscribe:t})}))}}const y=Symbol("pkt-tabs-context");var N=Object.defineProperty,_=Object.getOwnPropertyDescriptor,d=(o,t,s,i)=>{for(var e=i>1?void 0:i?_(t,s):t,n=o.length-1,r;n>=0;n--)(r=o[n])&&(e=(i?r(t,s,e):r(e))||e);return i&&e&&N(t,s,e),e};let b=class extends a.PktElement{constructor(){super(),this.arrowNav=!0,this.disableArrowNav=!1,this.tabRefs=[],this.tabCount=0,this.defaultSlot=p.e(),this.context={useArrowNav:this.useArrowNav,registerTab:this.registerTab.bind(this),handleClick:this.handleClick.bind(this),handleKeyUp:this.handleKeyUp.bind(this)},this.slotController=new g.PktSlotController(this,this.defaultSlot)}get useArrowNav(){return this.arrowNav&&!this.disableArrowNav}updated(o){(o.has("arrowNav")||o.has("disableArrowNav"))&&(this.context={...this.context,useArrowNav:this.useArrowNav})}registerTab(o,t){this.tabRefs[t]=o,this.tabCount=Math.max(this.tabCount,t+1)}handleClick(o){this.dispatchEvent(new CustomEvent("tab-selected",{detail:{index:o},bubbles:!0,composed:!0}))}handleKeyUp(o,t){var s,i;this.useArrowNav&&(o.code==="ArrowLeft"&&t!==0&&((s=this.tabRefs[t-1])==null||s.focus()),o.code==="ArrowRight"&&t<this.tabCount-1&&((i=this.tabRefs[t+1])==null||i.focus()),(o.code==="ArrowDown"||o.code==="Space")&&this.dispatchEvent(new CustomEvent("tab-selected",{detail:{index:t},bubbles:!0,composed:!0})))}render(){const o=this.useArrowNav?"tablist":"navigation";return a.x`
30
+ <div class="pkt-tabs">
31
+ <div class="pkt-tabs__list" role=${o} ${p.n(this.defaultSlot)}></div>
32
+ </div>
33
+ `}};d([a.n({type:Boolean,reflect:!0,attribute:"arrow-nav"})],b.prototype,"arrowNav",2);d([a.n({type:Boolean,reflect:!0,attribute:"disable-arrow-nav"})],b.prototype,"disableArrowNav",2);d([v.r()],b.prototype,"tabRefs",2);d([v.r()],b.prototype,"tabCount",2);d([P({context:y}),v.r()],b.prototype,"context",2);b=d([a.t("pkt-tabs")],b);const R=b;var A=Object.defineProperty,q=Object.getOwnPropertyDescriptor,l=(o,t,s,i)=>{for(var e=i>1?void 0:i?q(t,s):t,n=o.length-1,r;n>=0;n--)(r=o[n])&&(e=(i?r(t,s,e):r(e))||e);return i&&e&&A(t,s,e),e};let h=class extends a.PktElement{constructor(){super(),this.active=!1,this.href="",this.icon="",this.controls="",this.tag="",this.tagSkin="blue",this.index=0,this.elementRef=p.e(),this.defaultSlot=p.e(),this.slotController=new g.PktSlotController(this,this.defaultSlot)}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{this.elementRef.value&&this.context&&this.context.registerTab(this.elementRef.value,this.index)})}handleClick(){this.context&&this.context.handleClick(this.index)}handleKeyUp(o){this.context&&this.context.handleKeyUp(o,this.index)}render(){var r;const o=((r=this.context)==null?void 0:r.useArrowNav)??!0,t=this.active?"active":"",s=o?"tab":void 0,i=o?this.active:void 0,e=this.active||!o?void 0:-1,n=a.x`
34
+ ${this.icon?a.x`<pkt-icon name=${this.icon} class="pkt-icon--small"></pkt-icon>`:""}
35
+ <span ${p.n(this.defaultSlot)}></span>
36
+ ${this.tag?a.x`<pkt-tag skin=${this.tagSkin} size="small">${this.tag}</pkt-tag>`:""}
37
+ `;return this.href?a.x`
38
+ <a
39
+ ${p.n(this.elementRef)}
40
+ href=${this.href}
41
+ class="pkt-tabs__link ${t}"
42
+ role=${u.o(s)}
43
+ aria-selected=${u.o(i)}
44
+ aria-controls=${u.o(this.controls||void 0)}
45
+ tabindex=${u.o(e)}
46
+ @click=${this.handleClick}
47
+ @keyup=${this.handleKeyUp}
48
+ >
49
+ ${n}
50
+ </a>
51
+ `:a.x`
52
+ <button
53
+ ${p.n(this.elementRef)}
54
+ type="button"
55
+ class="pkt-tabs__button pkt-link-button ${t}"
56
+ role=${u.o(s)}
57
+ aria-selected=${u.o(i)}
58
+ aria-controls=${u.o(this.controls||void 0)}
59
+ tabindex=${u.o(e)}
60
+ @click=${this.handleClick}
61
+ @keyup=${this.handleKeyUp}
62
+ >
63
+ ${n}
64
+ </button>
65
+ `}};l([a.n({type:Boolean,reflect:!0})],h.prototype,"active",2);l([a.n({type:String,reflect:!0})],h.prototype,"href",2);l([a.n({type:String,reflect:!0})],h.prototype,"icon",2);l([a.n({type:String,reflect:!0})],h.prototype,"controls",2);l([a.n({type:String,reflect:!0})],h.prototype,"tag",2);l([a.n({type:String,reflect:!0,attribute:"tag-skin"})],h.prototype,"tagSkin",2);l([a.n({type:Number,reflect:!0})],h.prototype,"index",2);l([S({context:y,subscribe:!0}),a.n({attribute:!1})],h.prototype,"context",2);h=l([a.t("pkt-tab-item")],h);const O=h;exports.PktTabItem=O;exports.PktTabs=R;
@@ -0,0 +1,332 @@
1
+ import { P as $, x as p, n as h, a as y } from "./element-CRDRygXu.js";
2
+ import { P as C } from "./pkt-slot-controller-BPGj-LC5.js";
3
+ import { r as w } from "./state-DS_kr2Fy.js";
4
+ import { e as x, n as f } from "./ref-Xa5dbh--.js";
5
+ import { o as u } from "./if-defined-BWZGb3bh.js";
6
+ /**
7
+ * @license
8
+ * Copyright 2021 Google LLC
9
+ * SPDX-License-Identifier: BSD-3-Clause
10
+ */
11
+ let P = class extends Event {
12
+ constructor(t, s, i, e) {
13
+ super("context-request", { bubbles: !0, composed: !0 }), this.context = t, this.contextTarget = s, this.callback = i, this.subscribe = e ?? !1;
14
+ }
15
+ };
16
+ /**
17
+ * @license
18
+ * Copyright 2021 Google LLC
19
+ * SPDX-License-Identifier: BSD-3-Clause
20
+ */
21
+ /**
22
+ * @license
23
+ * Copyright 2021 Google LLC
24
+ * SPDX-License-Identifier: BSD-3-Clause
25
+ */
26
+ let m = class {
27
+ constructor(t, s, i, e) {
28
+ if (this.subscribe = !1, this.provided = !1, this.value = void 0, this.t = (a, r) => {
29
+ this.unsubscribe && (this.unsubscribe !== r && (this.provided = !1, this.unsubscribe()), this.subscribe || this.unsubscribe()), this.value = a, this.host.requestUpdate(), this.provided && !this.subscribe || (this.provided = !0, this.callback && this.callback(a, r)), this.unsubscribe = r;
30
+ }, this.host = t, s.context !== void 0) {
31
+ const a = s;
32
+ this.context = a.context, this.callback = a.callback, this.subscribe = a.subscribe ?? !1;
33
+ } else this.context = s, this.callback = i, this.subscribe = e ?? !1;
34
+ this.host.addController(this);
35
+ }
36
+ hostConnected() {
37
+ this.dispatchRequest();
38
+ }
39
+ hostDisconnected() {
40
+ this.unsubscribe && (this.unsubscribe(), this.unsubscribe = void 0);
41
+ }
42
+ dispatchRequest() {
43
+ this.host.dispatchEvent(new P(this.context, this.host, this.t, this.subscribe));
44
+ }
45
+ };
46
+ /**
47
+ * @license
48
+ * Copyright 2021 Google LLC
49
+ * SPDX-License-Identifier: BSD-3-Clause
50
+ */
51
+ class N {
52
+ get value() {
53
+ return this.o;
54
+ }
55
+ set value(t) {
56
+ this.setValue(t);
57
+ }
58
+ setValue(t, s = !1) {
59
+ const i = s || !Object.is(t, this.o);
60
+ this.o = t, i && this.updateObservers();
61
+ }
62
+ constructor(t) {
63
+ this.subscriptions = /* @__PURE__ */ new Map(), this.updateObservers = () => {
64
+ for (const [s, { disposer: i }] of this.subscriptions) s(this.o, i);
65
+ }, t !== void 0 && (this.value = t);
66
+ }
67
+ addCallback(t, s, i) {
68
+ if (!i) return void t(this.value);
69
+ this.subscriptions.has(t) || this.subscriptions.set(t, { disposer: () => {
70
+ this.subscriptions.delete(t);
71
+ }, consumerHost: s });
72
+ const { disposer: e } = this.subscriptions.get(t);
73
+ t(this.value, e);
74
+ }
75
+ clearCallbacks() {
76
+ this.subscriptions.clear();
77
+ }
78
+ }
79
+ /**
80
+ * @license
81
+ * Copyright 2021 Google LLC
82
+ * SPDX-License-Identifier: BSD-3-Clause
83
+ */
84
+ let _ = class extends Event {
85
+ constructor(t, s) {
86
+ super("context-provider", { bubbles: !0, composed: !0 }), this.context = t, this.contextTarget = s;
87
+ }
88
+ };
89
+ class g extends N {
90
+ constructor(t, s, i) {
91
+ var e, a;
92
+ super(s.context !== void 0 ? s.initialValue : i), this.onContextRequest = (r) => {
93
+ if (r.context !== this.context) return;
94
+ const n = r.contextTarget ?? r.composedPath()[0];
95
+ n !== this.host && (r.stopPropagation(), this.addCallback(r.callback, n, r.subscribe));
96
+ }, this.onProviderRequest = (r) => {
97
+ if (r.context !== this.context || (r.contextTarget ?? r.composedPath()[0]) === this.host) return;
98
+ const n = /* @__PURE__ */ new Set();
99
+ for (const [v, { consumerHost: k }] of this.subscriptions) n.has(v) || (n.add(v), k.dispatchEvent(new P(this.context, k, v, !0)));
100
+ r.stopPropagation();
101
+ }, this.host = t, s.context !== void 0 ? this.context = s.context : this.context = s, this.attachListeners(), (a = (e = this.host).addController) == null || a.call(e, this);
102
+ }
103
+ attachListeners() {
104
+ this.host.addEventListener("context-request", this.onContextRequest), this.host.addEventListener("context-provider", this.onProviderRequest);
105
+ }
106
+ hostConnected() {
107
+ this.host.dispatchEvent(new _(this.context, this.host));
108
+ }
109
+ }
110
+ /**
111
+ * @license
112
+ * Copyright 2017 Google LLC
113
+ * SPDX-License-Identifier: BSD-3-Clause
114
+ */
115
+ function R({ context: o }) {
116
+ return (t, s) => {
117
+ const i = /* @__PURE__ */ new WeakMap();
118
+ if (typeof s == "object") return { get() {
119
+ return t.get.call(this);
120
+ }, set(e) {
121
+ return i.get(this).setValue(e), t.set.call(this, e);
122
+ }, init(e) {
123
+ return i.set(this, new g(this, { context: o, initialValue: e })), e;
124
+ } };
125
+ {
126
+ t.constructor.addInitializer(((r) => {
127
+ i.set(r, new g(r, { context: o }));
128
+ }));
129
+ const e = Object.getOwnPropertyDescriptor(t, s);
130
+ let a;
131
+ if (e === void 0) {
132
+ const r = /* @__PURE__ */ new WeakMap();
133
+ a = { get() {
134
+ return r.get(this);
135
+ }, set(n) {
136
+ i.get(this).setValue(n), r.set(this, n);
137
+ }, configurable: !0, enumerable: !0 };
138
+ } else {
139
+ const r = e.set;
140
+ a = { ...e, set(n) {
141
+ i.get(this).setValue(n), r == null || r.call(this, n);
142
+ } };
143
+ }
144
+ return void Object.defineProperty(t, s, a);
145
+ }
146
+ };
147
+ }
148
+ /**
149
+ * @license
150
+ * Copyright 2022 Google LLC
151
+ * SPDX-License-Identifier: BSD-3-Clause
152
+ */
153
+ function A({ context: o, subscribe: t }) {
154
+ return (s, i) => {
155
+ typeof i == "object" ? i.addInitializer((function() {
156
+ new m(this, { context: o, callback: (e) => {
157
+ s.set.call(this, e);
158
+ }, subscribe: t });
159
+ })) : s.constructor.addInitializer(((e) => {
160
+ new m(e, { context: o, callback: (a) => {
161
+ e[i] = a;
162
+ }, subscribe: t });
163
+ }));
164
+ };
165
+ }
166
+ const S = Symbol("pkt-tabs-context");
167
+ var O = Object.defineProperty, T = Object.getOwnPropertyDescriptor, d = (o, t, s, i) => {
168
+ for (var e = i > 1 ? void 0 : i ? T(t, s) : t, a = o.length - 1, r; a >= 0; a--)
169
+ (r = o[a]) && (e = (i ? r(t, s, e) : r(e)) || e);
170
+ return i && e && O(t, s, e), e;
171
+ };
172
+ let b = class extends $ {
173
+ constructor() {
174
+ super(), this.arrowNav = !0, this.disableArrowNav = !1, this.tabRefs = [], this.tabCount = 0, this.defaultSlot = x(), this.context = {
175
+ useArrowNav: this.useArrowNav,
176
+ registerTab: this.registerTab.bind(this),
177
+ handleClick: this.handleClick.bind(this),
178
+ handleKeyUp: this.handleKeyUp.bind(this)
179
+ }, this.slotController = new C(this, this.defaultSlot);
180
+ }
181
+ get useArrowNav() {
182
+ return this.arrowNav && !this.disableArrowNav;
183
+ }
184
+ // Update context when properties change
185
+ updated(o) {
186
+ (o.has("arrowNav") || o.has("disableArrowNav")) && (this.context = {
187
+ ...this.context,
188
+ useArrowNav: this.useArrowNav
189
+ });
190
+ }
191
+ registerTab(o, t) {
192
+ this.tabRefs[t] = o, this.tabCount = Math.max(this.tabCount, t + 1);
193
+ }
194
+ handleClick(o) {
195
+ this.dispatchEvent(
196
+ new CustomEvent("tab-selected", {
197
+ detail: { index: o },
198
+ bubbles: !0,
199
+ composed: !0
200
+ })
201
+ );
202
+ }
203
+ handleKeyUp(o, t) {
204
+ var s, i;
205
+ this.useArrowNav && (o.code === "ArrowLeft" && t !== 0 && ((s = this.tabRefs[t - 1]) == null || s.focus()), o.code === "ArrowRight" && t < this.tabCount - 1 && ((i = this.tabRefs[t + 1]) == null || i.focus()), (o.code === "ArrowDown" || o.code === "Space") && this.dispatchEvent(
206
+ new CustomEvent("tab-selected", {
207
+ detail: { index: t },
208
+ bubbles: !0,
209
+ composed: !0
210
+ })
211
+ ));
212
+ }
213
+ render() {
214
+ const o = this.useArrowNav ? "tablist" : "navigation";
215
+ return p`
216
+ <div class="pkt-tabs">
217
+ <div class="pkt-tabs__list" role=${o} ${f(this.defaultSlot)}></div>
218
+ </div>
219
+ `;
220
+ }
221
+ };
222
+ d([
223
+ h({ type: Boolean, reflect: !0, attribute: "arrow-nav" })
224
+ ], b.prototype, "arrowNav", 2);
225
+ d([
226
+ h({ type: Boolean, reflect: !0, attribute: "disable-arrow-nav" })
227
+ ], b.prototype, "disableArrowNav", 2);
228
+ d([
229
+ w()
230
+ ], b.prototype, "tabRefs", 2);
231
+ d([
232
+ w()
233
+ ], b.prototype, "tabCount", 2);
234
+ d([
235
+ R({ context: S }),
236
+ w()
237
+ ], b.prototype, "context", 2);
238
+ b = d([
239
+ y("pkt-tabs")
240
+ ], b);
241
+ const M = b;
242
+ var j = Object.defineProperty, q = Object.getOwnPropertyDescriptor, l = (o, t, s, i) => {
243
+ for (var e = i > 1 ? void 0 : i ? q(t, s) : t, a = o.length - 1, r; a >= 0; a--)
244
+ (r = o[a]) && (e = (i ? r(t, s, e) : r(e)) || e);
245
+ return i && e && j(t, s, e), e;
246
+ };
247
+ let c = class extends $ {
248
+ constructor() {
249
+ super(), this.active = !1, this.href = "", this.icon = "", this.controls = "", this.tag = "", this.tagSkin = "blue", this.index = 0, this.elementRef = x(), this.defaultSlot = x(), this.slotController = new C(this, this.defaultSlot);
250
+ }
251
+ connectedCallback() {
252
+ super.connectedCallback(), this.updateComplete.then(() => {
253
+ this.elementRef.value && this.context && this.context.registerTab(this.elementRef.value, this.index);
254
+ });
255
+ }
256
+ handleClick() {
257
+ this.context && this.context.handleClick(this.index);
258
+ }
259
+ handleKeyUp(o) {
260
+ this.context && this.context.handleKeyUp(o, this.index);
261
+ }
262
+ render() {
263
+ var r;
264
+ const o = ((r = this.context) == null ? void 0 : r.useArrowNav) ?? !0, t = this.active ? "active" : "", s = o ? "tab" : void 0, i = o ? this.active : void 0, e = this.active || !o ? void 0 : -1, a = p`
265
+ ${this.icon ? p`<pkt-icon name=${this.icon} class="pkt-icon--small"></pkt-icon>` : ""}
266
+ <span ${f(this.defaultSlot)}></span>
267
+ ${this.tag ? p`<pkt-tag skin=${this.tagSkin} size="small">${this.tag}</pkt-tag>` : ""}
268
+ `;
269
+ return this.href ? p`
270
+ <a
271
+ ${f(this.elementRef)}
272
+ href=${this.href}
273
+ class="pkt-tabs__link ${t}"
274
+ role=${u(s)}
275
+ aria-selected=${u(i)}
276
+ aria-controls=${u(this.controls || void 0)}
277
+ tabindex=${u(e)}
278
+ @click=${this.handleClick}
279
+ @keyup=${this.handleKeyUp}
280
+ >
281
+ ${a}
282
+ </a>
283
+ ` : p`
284
+ <button
285
+ ${f(this.elementRef)}
286
+ type="button"
287
+ class="pkt-tabs__button pkt-link-button ${t}"
288
+ role=${u(s)}
289
+ aria-selected=${u(i)}
290
+ aria-controls=${u(this.controls || void 0)}
291
+ tabindex=${u(e)}
292
+ @click=${this.handleClick}
293
+ @keyup=${this.handleKeyUp}
294
+ >
295
+ ${a}
296
+ </button>
297
+ `;
298
+ }
299
+ };
300
+ l([
301
+ h({ type: Boolean, reflect: !0 })
302
+ ], c.prototype, "active", 2);
303
+ l([
304
+ h({ type: String, reflect: !0 })
305
+ ], c.prototype, "href", 2);
306
+ l([
307
+ h({ type: String, reflect: !0 })
308
+ ], c.prototype, "icon", 2);
309
+ l([
310
+ h({ type: String, reflect: !0 })
311
+ ], c.prototype, "controls", 2);
312
+ l([
313
+ h({ type: String, reflect: !0 })
314
+ ], c.prototype, "tag", 2);
315
+ l([
316
+ h({ type: String, reflect: !0, attribute: "tag-skin" })
317
+ ], c.prototype, "tagSkin", 2);
318
+ l([
319
+ h({ type: Number, reflect: !0 })
320
+ ], c.prototype, "index", 2);
321
+ l([
322
+ A({ context: S, subscribe: !0 }),
323
+ h({ attribute: !1 })
324
+ ], c.prototype, "context", 2);
325
+ c = l([
326
+ y("pkt-tab-item")
327
+ ], c);
328
+ const B = c;
329
+ export {
330
+ M as P,
331
+ B as a
332
+ };
package/dist/tabs.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { }