@oslokommune/punkt-react 16.8.1 → 16.8.3

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,41 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
5
5
 
6
6
  ---
7
7
 
8
+ ## [16.8.3](https://github.com/oslokommune/punkt/compare/16.8.2...16.8.3) (2026-04-21)
9
+
10
+ ### ⚠ BREAKING CHANGES
11
+ Ingen
12
+
13
+ ### Features
14
+ Ingen
15
+
16
+ ### Bug Fixes
17
+ * Backlink trenger className-støtte (#3429).
18
+
19
+
20
+ ### Chores
21
+ Ingen
22
+
23
+ ---
24
+
25
+
26
+ ## [16.8.2](https://github.com/oslokommune/punkt/compare/16.8.1...16.8.2) (2026-04-21)
27
+
28
+ ### ⚠ BREAKING CHANGES
29
+ Ingen
30
+
31
+ ### Features
32
+ Ingen
33
+
34
+ ### Bug Fixes
35
+ Ingen
36
+
37
+ ### Chores
38
+ Ingen
39
+
40
+ ---
41
+
42
+
8
43
  ## [16.8.1](https://github.com/oslokommune/punkt/compare/16.8.0...16.8.1) (2026-04-17)
9
44
 
10
45
  ### ⚠ BREAKING CHANGES
package/dist/index.d.ts CHANGED
@@ -746,6 +746,7 @@ export declare interface IPktTab {
746
746
  text: string;
747
747
  href?: string;
748
748
  action?: (index: number) => void;
749
+ disabled?: boolean;
749
750
  icon?: string;
750
751
  controls?: string;
751
752
  tag?: {
@@ -758,6 +759,7 @@ export declare interface IPktTab {
758
759
  declare interface IPktTabItem {
759
760
  children: ReactNode;
760
761
  active?: boolean;
762
+ disabled?: boolean;
761
763
  href?: string;
762
764
  onClick?: (event: MouseEvent_2) => void;
763
765
  icon?: string;
@@ -9497,7 +9497,7 @@ try {
9497
9497
  console.warn("Forsøker å definere <pkt-radiobutton>, men den er allerede definert");
9498
9498
  }
9499
9499
  //#endregion
9500
- //#region ../elements/dist/tabs-Y7utmJi9.js
9500
+ //#region ../elements/dist/tabs-C0DWPmn2.js
9501
9501
  var Co = class extends Event {
9502
9502
  constructor(e, t, n, r) {
9503
9503
  super("context-request", {
@@ -9656,7 +9656,7 @@ function Ao({ context: e, subscribe: t }) {
9656
9656
  }
9657
9657
  var jo = wo(Symbol("pkt-tabs-context")), Mo = class extends Vt {
9658
9658
  constructor(...e) {
9659
- super(...e), this.arrowNav = !0, this.disableArrowNav = !1, this.tabRefs = [], this.tabCount = 0, this.context = {
9659
+ super(...e), this.arrowNav = !0, this.disableArrowNav = !1, this.tabRefs = [], this.disabledMap = {}, this.tabCount = 0, this.context = {
9660
9660
  useArrowNav: this.useArrowNav,
9661
9661
  registerTab: this.registerTab.bind(this),
9662
9662
  handleClick: this.handleClick.bind(this),
@@ -9672,22 +9672,41 @@ var jo = wo(Symbol("pkt-tabs-context")), Mo = class extends Vt {
9672
9672
  useArrowNav: this.useArrowNav
9673
9673
  });
9674
9674
  }
9675
- registerTab(e, t) {
9676
- this.tabRefs[t] = e, this.tabCount = Math.max(this.tabCount, t + 1);
9675
+ registerTab(e, t, n = !1) {
9676
+ this.tabRefs[t] = e, this.disabledMap[t] = n, this.tabCount = Math.max(this.tabCount, t + 1);
9677
+ }
9678
+ isTabDisabled(e) {
9679
+ return !!this.disabledMap[e];
9680
+ }
9681
+ findEnabledIndex(e, t) {
9682
+ let n = e + t;
9683
+ for (; n >= 0 && n < this.tabCount;) {
9684
+ if (!this.isTabDisabled(n)) return n;
9685
+ n += t;
9686
+ }
9687
+ return null;
9677
9688
  }
9678
9689
  handleClick(e) {
9679
- this.dispatchEvent(new CustomEvent("tab-selected", {
9690
+ this.isTabDisabled(e) || this.dispatchEvent(new CustomEvent("tab-selected", {
9680
9691
  detail: { index: e },
9681
9692
  bubbles: !0,
9682
9693
  composed: !0
9683
9694
  }));
9684
9695
  }
9685
9696
  handleKeyUp(e, t) {
9686
- this.useArrowNav && (e.code === "ArrowLeft" && t !== 0 && this.tabRefs[t - 1]?.focus(), e.code === "ArrowRight" && t < this.tabCount - 1 && this.tabRefs[t + 1]?.focus(), (e.code === "ArrowDown" || e.code === "Space") && this.dispatchEvent(new CustomEvent("tab-selected", {
9687
- detail: { index: t },
9688
- bubbles: !0,
9689
- composed: !0
9690
- })));
9697
+ if (this.useArrowNav) {
9698
+ if (e.key === "ArrowLeft") {
9699
+ e.preventDefault();
9700
+ let n = this.findEnabledIndex(t, -1);
9701
+ n !== null && this.tabRefs[n]?.focus();
9702
+ }
9703
+ if (e.key === "ArrowRight") {
9704
+ e.preventDefault();
9705
+ let n = this.findEnabledIndex(t, 1);
9706
+ n !== null && this.tabRefs[n]?.focus();
9707
+ }
9708
+ (e.key === "Enter" || e.key === " " || e.key === "Spacebar" || e.key === "ArrowDown") && (e.preventDefault(), this.handleClick(t));
9709
+ }
9691
9710
  }
9692
9711
  render() {
9693
9712
  return z`
@@ -9705,7 +9724,7 @@ J([K({
9705
9724
  type: Boolean,
9706
9725
  reflect: !0,
9707
9726
  attribute: "disable-arrow-nav"
9708
- })], Mo.prototype, "disableArrowNav", void 0), J([q()], Mo.prototype, "tabRefs", void 0), J([q()], Mo.prototype, "tabCount", void 0), J([ko({ context: jo }), q()], Mo.prototype, "context", void 0);
9727
+ })], Mo.prototype, "disableArrowNav", void 0), J([q()], Mo.prototype, "tabRefs", void 0), J([q()], Mo.prototype, "disabledMap", void 0), J([q()], Mo.prototype, "tabCount", void 0), J([ko({ context: jo }), q()], Mo.prototype, "context", void 0);
9709
9728
  try {
9710
9729
  G("pkt-tabs")(Mo);
9711
9730
  } catch {
@@ -9713,21 +9732,32 @@ try {
9713
9732
  }
9714
9733
  var No = class extends Vt {
9715
9734
  constructor() {
9716
- super(), this.active = !1, this.href = "", this.icon = "", this.controls = "", this.tag = "", this.tagSkin = "blue", this.index = 0, this.elementRef = sn();
9735
+ super(), this.active = !1, this.disabled = !1, this.href = "", this.icon = "", this.controls = "", this.tag = "", this.tagSkin = "blue", this.index = 0, this.elementRef = sn();
9717
9736
  }
9718
9737
  connectedCallback() {
9719
9738
  super.connectedCallback(), this.updateComplete.then(() => {
9720
- this.elementRef.value && this.context && this.context.registerTab(this.elementRef.value, this.index);
9739
+ this.elementRef.value && this.context && this.context.registerTab(this.elementRef.value, this.index, this.disabled);
9721
9740
  });
9722
9741
  }
9723
- handleClick() {
9742
+ updated() {
9743
+ this.elementRef.value && this.context && this.context.registerTab(this.elementRef.value, this.index, this.disabled);
9744
+ }
9745
+ handleClick(e) {
9746
+ if (this.disabled) {
9747
+ e.preventDefault(), e.stopPropagation();
9748
+ return;
9749
+ }
9724
9750
  this.context && this.context.handleClick(this.index);
9725
9751
  }
9726
- handleKeyUp(e) {
9752
+ handleKeyDown(e) {
9753
+ if (this.disabled && (e.key === "Enter" || e.key === " " || e.key === "Spacebar")) {
9754
+ e.preventDefault(), e.stopPropagation();
9755
+ return;
9756
+ }
9727
9757
  this.context && this.context.handleKeyUp(e, this.index);
9728
9758
  }
9729
9759
  render() {
9730
- let e = this.context?.useArrowNav ?? !0, t = this.active ? "active" : "", n = e ? "tab" : void 0, r = e ? this.active : void 0, i = this.active || !e ? void 0 : -1, a = z`
9760
+ let e = this.context?.useArrowNav ?? !0, t = this.active && !this.disabled, n = [t ? "active" : "", this.disabled ? "pkt-tabs__item--disabled" : ""].filter(Boolean).join(" "), r = e ? "tab" : void 0, i = e ? t : void 0, a = this.disabled ? -1 : t || !e ? void 0 : -1, o = z`
9731
9761
  ${this.icon ? z`<pkt-icon name=${this.icon} class="pkt-icon--small"></pkt-icon>` : ""}
9732
9762
  <span>${Bt(this)}</span>
9733
9763
  ${this.tag ? z`<pkt-tag skin=${this.tagSkin} size="small">${this.tag}</pkt-tag>` : ""}
@@ -9735,30 +9765,33 @@ var No = class extends Vt {
9735
9765
  return this.href ? z`
9736
9766
  <a
9737
9767
  ${un(this.elementRef)}
9738
- href=${this.href}
9739
- class="pkt-tabs__link ${t}"
9740
- role=${X(n)}
9741
- aria-selected=${X(r)}
9768
+ href=${X(this.disabled ? void 0 : this.href)}
9769
+ class="pkt-tabs__link ${n}"
9770
+ role=${X(r)}
9771
+ aria-selected=${X(i)}
9772
+ aria-disabled=${X(this.disabled ? "true" : void 0)}
9742
9773
  aria-controls=${X(this.controls || void 0)}
9743
- tabindex=${X(i)}
9774
+ tabindex=${X(a)}
9744
9775
  @click=${this.handleClick}
9745
- @keyup=${this.handleKeyUp}
9776
+ @keydown=${this.handleKeyDown}
9746
9777
  >
9747
- ${a}
9778
+ ${o}
9748
9779
  </a>
9749
9780
  ` : z`
9750
9781
  <button
9751
9782
  ${un(this.elementRef)}
9752
9783
  type="button"
9753
- class="pkt-tabs__button pkt-link-button ${t}"
9754
- role=${X(n)}
9755
- aria-selected=${X(r)}
9784
+ class="pkt-tabs__button pkt-link-button ${n}"
9785
+ ?disabled=${this.disabled}
9786
+ aria-disabled=${X(this.disabled ? "true" : void 0)}
9787
+ role=${X(r)}
9788
+ aria-selected=${X(i)}
9756
9789
  aria-controls=${X(this.controls || void 0)}
9757
- tabindex=${X(i)}
9790
+ tabindex=${X(a)}
9758
9791
  @click=${this.handleClick}
9759
- @keyup=${this.handleKeyUp}
9792
+ @keydown=${this.handleKeyDown}
9760
9793
  >
9761
- ${a}
9794
+ ${o}
9762
9795
  </button>
9763
9796
  `;
9764
9797
  }
@@ -9767,6 +9800,9 @@ J([K({
9767
9800
  type: Boolean,
9768
9801
  reflect: !0
9769
9802
  })], No.prototype, "active", void 0), J([K({
9803
+ type: Boolean,
9804
+ reflect: !0
9805
+ })], No.prototype, "disabled", void 0), J([K({
9770
9806
  type: String,
9771
9807
  reflect: !0
9772
9808
  })], No.prototype, "href", void 0), J([K({
@@ -10686,29 +10722,32 @@ var $ = /* @__PURE__ */ te((/* @__PURE__ */ D(((e, t) => {
10686
10722
  Ko.displayName = "PktAlert";
10687
10723
  //#endregion
10688
10724
  //#region src/components/backlink/BackLink.tsx
10689
- var qo = s(({ href: e = "/", text: t = "Forsiden", ariaLabel: n, renderLink: r, ...i }, a) => /* @__PURE__ */ y("nav", {
10690
- className: "pkt-back-link",
10691
- "aria-label": n || " tilbake til forrige side",
10692
- ref: a,
10693
- children: (r || (({ href: e, className: t, children: n, props: r }) => /* @__PURE__ */ y("a", {
10725
+ var qo = s(({ href: e = "/", text: t = "Forsiden", ariaLabel: n, renderLink: r, className: i, ...a }, o) => {
10726
+ let s = /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y(Q, {
10727
+ className: "pkt-back-link__icon pkt-icon pkt-link__icon",
10728
+ name: "chevron-thin-left",
10729
+ "aria-hidden": "true"
10730
+ }), /* @__PURE__ */ y("span", {
10731
+ className: "pkt-back-link__text",
10732
+ children: t
10733
+ })] }), c = r || (({ href: e, className: t, children: n, props: r }) => /* @__PURE__ */ y("a", {
10694
10734
  href: e,
10695
10735
  className: t,
10696
10736
  ...r,
10697
10737
  children: n
10698
- })))({
10699
- href: e,
10700
- className: "pkt-link pkt-link--icon-left",
10701
- children: /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y(Q, {
10702
- className: "pkt-back-link__icon pkt-icon pkt-link__icon",
10703
- name: "chevron-thin-left",
10704
- "aria-hidden": "true"
10705
- }), /* @__PURE__ */ y("span", {
10706
- className: "pkt-back-link__text",
10707
- children: t
10708
- })] }),
10709
- props: i
10710
- })
10711
- }));
10738
+ }));
10739
+ return /* @__PURE__ */ y("nav", {
10740
+ className: ["pkt-back-link", i].filter(Boolean).join(" "),
10741
+ "aria-label": n || "Gå tilbake til forrige side",
10742
+ ref: o,
10743
+ children: c({
10744
+ href: e,
10745
+ className: "pkt-link pkt-link--icon-left",
10746
+ children: s,
10747
+ props: a
10748
+ })
10749
+ });
10750
+ });
10712
10751
  qo.displayName = "PktBackLink";
10713
10752
  //#endregion
10714
10753
  //#region src/components/breadcrumbs/Breadcrumbs.tsx
@@ -17073,41 +17112,54 @@ var zd = ({ className: e, compact: t = !1, skin: n = "basic", responsiveView: r
17073
17112
  role: "row",
17074
17113
  ...n,
17075
17114
  children: t
17076
- }), Gd = s(({ children: e, active: t, href: n, onClick: r, icon: i, controls: a, tag: o, tagSkin: s, index: c = 0 }, l) => {
17077
- let { arrowNav: u, registerTabRef: d, handleKeyPress: f, selectTab: p } = qd(), m = {
17078
- "aria-selected": u ? !!t : void 0,
17079
- "aria-controls": a,
17080
- role: u ? "tab" : void 0,
17081
- onKeyUp: (e) => f(c, e),
17115
+ }), Gd = s(({ children: e, active: t, disabled: n = !1, href: r, onClick: i, icon: a, controls: o, tag: s, tagSkin: c, index: l = 0 }, u) => {
17116
+ let { arrowNav: d, registerTabRef: f, handleKeyPress: p, selectTab: m } = qd(), h = !!t && !n, g = {
17117
+ "aria-selected": d ? h : void 0,
17118
+ "aria-controls": o,
17119
+ role: d ? "tab" : void 0,
17120
+ onKeyDown: (e) => {
17121
+ if (n && (e.key === "Enter" || e.key === " " || e.key === "Spacebar")) {
17122
+ e.preventDefault(), e.stopPropagation();
17123
+ return;
17124
+ }
17125
+ p(l, e);
17126
+ },
17082
17127
  onClick: (e) => {
17083
- p(c), r?.(e);
17128
+ if (n) {
17129
+ e.preventDefault(), e.stopPropagation();
17130
+ return;
17131
+ }
17132
+ m(l), i?.(e);
17084
17133
  },
17085
- tabIndex: t || !u ? void 0 : -1,
17134
+ tabIndex: n ? -1 : h || !d ? void 0 : -1,
17086
17135
  ref: (e) => {
17087
- d(c, e), typeof l == "function" ? l(e) : l && (l.current = e);
17136
+ f(l, e, n), typeof u == "function" ? u(e) : u && (u.current = e);
17088
17137
  }
17089
- }, h = /* @__PURE__ */ b(v, { children: [
17090
- i && /* @__PURE__ */ y(Q, {
17091
- name: i,
17138
+ }, _ = /* @__PURE__ */ b(v, { children: [
17139
+ a && /* @__PURE__ */ y(Q, {
17140
+ name: a,
17092
17141
  className: "pkt-icon--small"
17093
17142
  }),
17094
17143
  e,
17095
- o && /* @__PURE__ */ y(dl, {
17096
- skin: s,
17144
+ s && /* @__PURE__ */ y(dl, {
17145
+ skin: c,
17097
17146
  size: "small",
17098
- children: o
17147
+ children: s
17099
17148
  })
17100
17149
  ] });
17101
- return n ? /* @__PURE__ */ y("a", {
17102
- ...m,
17103
- href: n,
17104
- className: `pkt-tabs__link ${t ? "active" : ""}`,
17105
- children: h
17150
+ return r ? /* @__PURE__ */ y("a", {
17151
+ ...g,
17152
+ href: n ? void 0 : r,
17153
+ "aria-disabled": n || void 0,
17154
+ className: `pkt-tabs__link ${h ? "active" : ""} ${n ? "pkt-tabs__item--disabled" : ""}`,
17155
+ children: _
17106
17156
  }) : /* @__PURE__ */ y("button", {
17107
- ...m,
17157
+ ...g,
17108
17158
  type: "button",
17109
- className: `pkt-tabs__button pkt-link-button ${t ? "active" : ""}`,
17110
- children: h
17159
+ disabled: n,
17160
+ "aria-disabled": n || void 0,
17161
+ className: `pkt-tabs__button pkt-link-button ${h ? "active" : ""} ${n ? "pkt-tabs__item--disabled" : ""}`,
17162
+ children: _
17111
17163
  });
17112
17164
  });
17113
17165
  Gd.displayName = "PktTabItem";
@@ -17118,21 +17170,44 @@ var Kd = i(null), qd = () => {
17118
17170
  if (!e) throw Error("TabItem must be used within a Tabs component");
17119
17171
  return e;
17120
17172
  }, Jd = s(({ arrowNav: e = !0, disableArrowNav: n = !1, tabs: r, onTabSelected: i, children: a }, o) => {
17121
- let s = g([]), c = e && !n, l = a && t.count(a) > 0 ? t.count(a) : r?.length || 0;
17173
+ let s = g([]), c = g({}), l = e && !n, u = a && t.count(a) > 0 ? t.count(a) : r?.length || 0;
17122
17174
  d(() => {
17123
- s.current = s.current.slice(0, l);
17124
- }, [l]);
17125
- let u = (e) => {
17175
+ s.current = s.current.slice(0, u), Object.keys(c.current).forEach((e) => {
17176
+ let t = Number(e);
17177
+ t >= u && delete c.current[t];
17178
+ });
17179
+ }, [u]);
17180
+ let f = (e) => r ? !!r[e]?.disabled : !!c.current[e], p = (e) => {
17181
+ if (f(e)) return;
17126
17182
  let t = r?.[e];
17127
17183
  t?.action && t.action(e), i && i(e);
17128
- }, f = (e, t) => {
17129
- c && (t.code === "ArrowLeft" && e !== 0 && s.current[e - 1]?.focus(), t.code === "ArrowRight" && e < l - 1 && s.current[e + 1]?.focus(), (t.code === "ArrowDown" || t.code === "Space") && u(e));
17130
- }, p = (e, t) => {
17131
- s.current[e] = t;
17132
- }, m = r?.map((e, t) => /* @__PURE__ */ y(Gd, {
17133
- active: e.active,
17184
+ }, m = (e, t) => {
17185
+ let n = e + t;
17186
+ for (; n >= 0 && n < u;) {
17187
+ if (!f(n)) return n;
17188
+ n += t;
17189
+ }
17190
+ return null;
17191
+ }, h = (e, t) => {
17192
+ if (l) {
17193
+ if (t.key === "ArrowLeft") {
17194
+ t.preventDefault();
17195
+ let n = m(e, -1);
17196
+ n !== null && s.current[n]?.focus();
17197
+ }
17198
+ if (t.key === "ArrowRight") {
17199
+ t.preventDefault();
17200
+ let n = m(e, 1);
17201
+ n !== null && s.current[n]?.focus();
17202
+ }
17203
+ (t.key === "Enter" || t.key === " " || t.key === "Spacebar" || t.key === "ArrowDown") && (t.preventDefault(), f(e) || p(e));
17204
+ }
17205
+ }, _ = (e, t, n = !1) => {
17206
+ s.current[e] = t, c.current[e] = n;
17207
+ }, v = r?.map((e, t) => /* @__PURE__ */ y(Gd, {
17208
+ active: e.disabled ? !1 : e.active,
17209
+ disabled: e.disabled,
17134
17210
  href: e.href,
17135
- onClick: () => u(t),
17136
17211
  icon: e.icon,
17137
17212
  controls: e.controls,
17138
17213
  tag: e.tag?.text,
@@ -17142,18 +17217,18 @@ var Kd = i(null), qd = () => {
17142
17217
  }, t));
17143
17218
  return /* @__PURE__ */ y(Kd.Provider, {
17144
17219
  value: {
17145
- arrowNav: c,
17146
- registerTabRef: p,
17147
- handleKeyPress: f,
17148
- selectTab: u
17220
+ arrowNav: l,
17221
+ registerTabRef: _,
17222
+ handleKeyPress: h,
17223
+ selectTab: p
17149
17224
  },
17150
17225
  children: /* @__PURE__ */ y("div", {
17151
17226
  className: "pkt-tabs",
17152
17227
  ref: o,
17153
17228
  children: /* @__PURE__ */ y("div", {
17154
17229
  className: "pkt-tabs__list",
17155
- role: c ? "tablist" : "navigation",
17156
- children: a || m
17230
+ role: l ? "tablist" : "navigation",
17231
+ children: a || v
17157
17232
  })
17158
17233
  })
17159
17234
  });