@oslokommune/punkt-react 16.8.0 → 16.8.2

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.2](https://github.com/oslokommune/punkt/compare/16.8.1...16.8.2) (2026-04-21)
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
+
25
+ ## [16.8.1](https://github.com/oslokommune/punkt/compare/16.8.0...16.8.1) (2026-04-17)
26
+
27
+ ### ⚠ BREAKING CHANGES
28
+ Ingen
29
+
30
+ ### Features
31
+ Ingen
32
+
33
+ ### Bug Fixes
34
+ * Datepicker, Combobox og Timepicker mangler `id` (#3423). Dette er en glipp i konvertering til React-versjoner
35
+
36
+
37
+ ### Chores
38
+ Ingen
39
+
40
+ ---
41
+
42
+
8
43
  ## [16.8.0](https://github.com/oslokommune/punkt/compare/16.7.7...16.8.0) (2026-04-16)
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({
@@ -14130,6 +14166,7 @@ var zl = s((e, t) => {
14130
14166
  return /* @__PURE__ */ b("div", {
14131
14167
  className: r,
14132
14168
  ref: n.wrapperRef,
14169
+ id: n.id || void 0,
14133
14170
  children: [/* @__PURE__ */ b(ml, {
14134
14171
  forId: a,
14135
14172
  hasFieldset: !i,
@@ -14653,6 +14690,7 @@ var ru = s((e, t) => {
14653
14690
  let n = nu(e, t);
14654
14691
  return /* @__PURE__ */ b("div", {
14655
14692
  className: ["pkt-datepicker", n.className].filter(Boolean).join(" "),
14693
+ id: n.id || void 0,
14656
14694
  children: [
14657
14695
  /* @__PURE__ */ y(ml, {
14658
14696
  ref: n.wrapperRef,
@@ -17071,41 +17109,54 @@ var zd = ({ className: e, compact: t = !1, skin: n = "basic", responsiveView: r
17071
17109
  role: "row",
17072
17110
  ...n,
17073
17111
  children: t
17074
- }), Gd = s(({ children: e, active: t, href: n, onClick: r, icon: i, controls: a, tag: o, tagSkin: s, index: c = 0 }, l) => {
17075
- let { arrowNav: u, registerTabRef: d, handleKeyPress: f, selectTab: p } = qd(), m = {
17076
- "aria-selected": u ? !!t : void 0,
17077
- "aria-controls": a,
17078
- role: u ? "tab" : void 0,
17079
- onKeyUp: (e) => f(c, e),
17112
+ }), 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) => {
17113
+ let { arrowNav: d, registerTabRef: f, handleKeyPress: p, selectTab: m } = qd(), h = !!t && !n, g = {
17114
+ "aria-selected": d ? h : void 0,
17115
+ "aria-controls": o,
17116
+ role: d ? "tab" : void 0,
17117
+ onKeyDown: (e) => {
17118
+ if (n && (e.key === "Enter" || e.key === " " || e.key === "Spacebar")) {
17119
+ e.preventDefault(), e.stopPropagation();
17120
+ return;
17121
+ }
17122
+ p(l, e);
17123
+ },
17080
17124
  onClick: (e) => {
17081
- p(c), r?.(e);
17125
+ if (n) {
17126
+ e.preventDefault(), e.stopPropagation();
17127
+ return;
17128
+ }
17129
+ m(l), i?.(e);
17082
17130
  },
17083
- tabIndex: t || !u ? void 0 : -1,
17131
+ tabIndex: n ? -1 : h || !d ? void 0 : -1,
17084
17132
  ref: (e) => {
17085
- d(c, e), typeof l == "function" ? l(e) : l && (l.current = e);
17133
+ f(l, e, n), typeof u == "function" ? u(e) : u && (u.current = e);
17086
17134
  }
17087
- }, h = /* @__PURE__ */ b(v, { children: [
17088
- i && /* @__PURE__ */ y(Q, {
17089
- name: i,
17135
+ }, _ = /* @__PURE__ */ b(v, { children: [
17136
+ a && /* @__PURE__ */ y(Q, {
17137
+ name: a,
17090
17138
  className: "pkt-icon--small"
17091
17139
  }),
17092
17140
  e,
17093
- o && /* @__PURE__ */ y(dl, {
17094
- skin: s,
17141
+ s && /* @__PURE__ */ y(dl, {
17142
+ skin: c,
17095
17143
  size: "small",
17096
- children: o
17144
+ children: s
17097
17145
  })
17098
17146
  ] });
17099
- return n ? /* @__PURE__ */ y("a", {
17100
- ...m,
17101
- href: n,
17102
- className: `pkt-tabs__link ${t ? "active" : ""}`,
17103
- children: h
17147
+ return r ? /* @__PURE__ */ y("a", {
17148
+ ...g,
17149
+ href: n ? void 0 : r,
17150
+ "aria-disabled": n || void 0,
17151
+ className: `pkt-tabs__link ${h ? "active" : ""} ${n ? "pkt-tabs__item--disabled" : ""}`,
17152
+ children: _
17104
17153
  }) : /* @__PURE__ */ y("button", {
17105
- ...m,
17154
+ ...g,
17106
17155
  type: "button",
17107
- className: `pkt-tabs__button pkt-link-button ${t ? "active" : ""}`,
17108
- children: h
17156
+ disabled: n,
17157
+ "aria-disabled": n || void 0,
17158
+ className: `pkt-tabs__button pkt-link-button ${h ? "active" : ""} ${n ? "pkt-tabs__item--disabled" : ""}`,
17159
+ children: _
17109
17160
  });
17110
17161
  });
17111
17162
  Gd.displayName = "PktTabItem";
@@ -17116,21 +17167,44 @@ var Kd = i(null), qd = () => {
17116
17167
  if (!e) throw Error("TabItem must be used within a Tabs component");
17117
17168
  return e;
17118
17169
  }, Jd = s(({ arrowNav: e = !0, disableArrowNav: n = !1, tabs: r, onTabSelected: i, children: a }, o) => {
17119
- let s = g([]), c = e && !n, l = a && t.count(a) > 0 ? t.count(a) : r?.length || 0;
17170
+ let s = g([]), c = g({}), l = e && !n, u = a && t.count(a) > 0 ? t.count(a) : r?.length || 0;
17120
17171
  d(() => {
17121
- s.current = s.current.slice(0, l);
17122
- }, [l]);
17123
- let u = (e) => {
17172
+ s.current = s.current.slice(0, u), Object.keys(c.current).forEach((e) => {
17173
+ let t = Number(e);
17174
+ t >= u && delete c.current[t];
17175
+ });
17176
+ }, [u]);
17177
+ let f = (e) => r ? !!r[e]?.disabled : !!c.current[e], p = (e) => {
17178
+ if (f(e)) return;
17124
17179
  let t = r?.[e];
17125
17180
  t?.action && t.action(e), i && i(e);
17126
- }, f = (e, t) => {
17127
- 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));
17128
- }, p = (e, t) => {
17129
- s.current[e] = t;
17130
- }, m = r?.map((e, t) => /* @__PURE__ */ y(Gd, {
17131
- active: e.active,
17181
+ }, m = (e, t) => {
17182
+ let n = e + t;
17183
+ for (; n >= 0 && n < u;) {
17184
+ if (!f(n)) return n;
17185
+ n += t;
17186
+ }
17187
+ return null;
17188
+ }, h = (e, t) => {
17189
+ if (l) {
17190
+ if (t.key === "ArrowLeft") {
17191
+ t.preventDefault();
17192
+ let n = m(e, -1);
17193
+ n !== null && s.current[n]?.focus();
17194
+ }
17195
+ if (t.key === "ArrowRight") {
17196
+ t.preventDefault();
17197
+ let n = m(e, 1);
17198
+ n !== null && s.current[n]?.focus();
17199
+ }
17200
+ (t.key === "Enter" || t.key === " " || t.key === "Spacebar" || t.key === "ArrowDown") && (t.preventDefault(), f(e) || p(e));
17201
+ }
17202
+ }, _ = (e, t, n = !1) => {
17203
+ s.current[e] = t, c.current[e] = n;
17204
+ }, v = r?.map((e, t) => /* @__PURE__ */ y(Gd, {
17205
+ active: e.disabled ? !1 : e.active,
17206
+ disabled: e.disabled,
17132
17207
  href: e.href,
17133
- onClick: () => u(t),
17134
17208
  icon: e.icon,
17135
17209
  controls: e.controls,
17136
17210
  tag: e.tag?.text,
@@ -17140,18 +17214,18 @@ var Kd = i(null), qd = () => {
17140
17214
  }, t));
17141
17215
  return /* @__PURE__ */ y(Kd.Provider, {
17142
17216
  value: {
17143
- arrowNav: c,
17144
- registerTabRef: p,
17145
- handleKeyPress: f,
17146
- selectTab: u
17217
+ arrowNav: l,
17218
+ registerTabRef: _,
17219
+ handleKeyPress: h,
17220
+ selectTab: p
17147
17221
  },
17148
17222
  children: /* @__PURE__ */ y("div", {
17149
17223
  className: "pkt-tabs",
17150
17224
  ref: o,
17151
17225
  children: /* @__PURE__ */ y("div", {
17152
17226
  className: "pkt-tabs__list",
17153
- role: c ? "tablist" : "navigation",
17154
- children: a || m
17227
+ role: l ? "tablist" : "navigation",
17228
+ children: a || v
17155
17229
  })
17156
17230
  })
17157
17231
  });
@@ -17834,6 +17908,7 @@ var lf = s((e, t) => {
17834
17908
  return /* @__PURE__ */ y("div", {
17835
17909
  ref: i.containerRef,
17836
17910
  className: i.outerClasses,
17911
+ id: i.id || void 0,
17837
17912
  onFocus: i.handleFocusIn,
17838
17913
  onBlur: i.handleFocusOut,
17839
17914
  children: /* @__PURE__ */ y(ml, {