@oslokommune/punkt-elements 12.41.0 → 12.42.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/dist/index.d.ts CHANGED
@@ -95,6 +95,7 @@ declare interface IPktAlert {
95
95
  ariaLive?: TAriaLive | null;
96
96
  'aria-live'?: TAriaLive | null;
97
97
  compact?: boolean;
98
+ role?: string;
98
99
  }
99
100
 
100
101
  export declare interface IPktBackLink {
@@ -163,6 +164,7 @@ export declare interface IPktCombobox {
163
164
  optionalTag?: boolean;
164
165
  optionalText?: string;
165
166
  options?: IPktComboboxOption[];
167
+ defaultOptions?: IPktComboboxOption[];
166
168
  placeholder?: string | null;
167
169
  requiredTag?: boolean;
168
170
  requiredText?: string;
@@ -338,6 +340,7 @@ export declare class PktAlert extends PktElement implements IPktAlert {
338
340
  'aria-live': TAriaLive | null;
339
341
  closeAlert: boolean;
340
342
  date: string | null;
343
+ role: string;
341
344
  _isClosed: boolean;
342
345
  connectedCallback(): void;
343
346
  attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
@@ -512,6 +515,7 @@ export declare class PktCombobox extends PktInputElement implements IPktCombobox
512
515
  constructor();
513
516
  value: string | string[];
514
517
  options: IPktComboboxOption[];
518
+ defaultOptions: IPktComboboxOption[];
515
519
  allowUserInput: boolean;
516
520
  typeahead: boolean;
517
521
  includeSearch: boolean;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./alert-D2PhTV94.cjs"),t=e.PktAlert;Object.defineProperty(exports,"PktAlert",{enumerable:!0,get:()=>e.PktAlert});exports.default=t;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./alert-BY97zZYx.cjs"),t=e.PktAlert;Object.defineProperty(exports,"PktAlert",{enumerable:!0,get:()=>e.PktAlert});exports.default=t;
package/dist/pkt-alert.js CHANGED
@@ -1,4 +1,4 @@
1
- import { P as t } from "./alert-CoGYPbs-.js";
1
+ import { P as t } from "./alert-oh7nc3ip.js";
2
2
  const e = t;
3
3
  export {
4
4
  t as PktAlert,
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./combobox-lds6Lryq.cjs"),o=e.PktCombobox;Object.defineProperty(exports,"PktCombobox",{enumerable:!0,get:()=>e.PktCombobox});exports.default=o;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./combobox-DMkMUJfx.cjs"),o=e.PktCombobox;Object.defineProperty(exports,"PktCombobox",{enumerable:!0,get:()=>e.PktCombobox});exports.default=o;
@@ -1,4 +1,4 @@
1
- import { P as o } from "./combobox-Ct7-a2Vy.js";
1
+ import { P as o } from "./combobox-CavDENt-.js";
2
2
  const b = o;
3
3
  export {
4
4
  o as PktCombobox,
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./alert-D2PhTV94.cjs"),l=require("./accordionitem-Dz6jwPpb.cjs"),d=require("./backlink-CcAZfB1d.cjs"),b=require("./button-KzBZ-Bff.cjs"),k=require("./calendar-BDeaGBaH.cjs"),m=require("./card-CmdIb2X9.cjs"),g=require("./combobox-lds6Lryq.cjs"),h=require("./consent-D1r9LYda.cjs"),f=require("./checkbox-CiXWukkL.cjs"),t=require("./element-90YeMNbV.cjs"),y=require("./pkt-slot-controller-Da-RgXfS.cjs"),s=require("./ref-B-w1vCo8.cjs"),O=require("./class-map-DWDPOqjO.cjs"),j=require("./datepicker-DpQV8G6g.cjs"),q=require("./helptext-AqNI_oFG.cjs"),x=require("./heading-CxJ0IqpU.cjs"),C=require("./icon-B1_BRNqf.cjs"),v=require("./input-wrapper-B_TtkGqo.cjs"),S=require("./link-BWJrqWi7.cjs"),$=require("./linkcard-0KLDuaGM.cjs"),L=require("./loader--5h6NKGl.cjs"),_=require("./messagebox-IJOkv427.cjs"),A=require("./modal-CBURcXBd.cjs"),B=require("./progressbar-BrXtjUvh.cjs"),p=require("./radiobutton-x10h-JEh.cjs"),T=require("./tag-lU4vz70a.cjs"),I=require("./textarea-j8kBS-hf.cjs"),M=require("./textinput-kmcj-FlC.cjs"),R=require("./select-BUvu5SFp.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 y.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`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./alert-BY97zZYx.cjs"),l=require("./accordionitem-Dz6jwPpb.cjs"),d=require("./backlink-CcAZfB1d.cjs"),b=require("./button-KzBZ-Bff.cjs"),k=require("./calendar-BDeaGBaH.cjs"),m=require("./card-CmdIb2X9.cjs"),g=require("./combobox-DMkMUJfx.cjs"),h=require("./consent-D1r9LYda.cjs"),f=require("./checkbox-CiXWukkL.cjs"),t=require("./element-90YeMNbV.cjs"),y=require("./pkt-slot-controller-Da-RgXfS.cjs"),s=require("./ref-B-w1vCo8.cjs"),O=require("./class-map-DWDPOqjO.cjs"),j=require("./datepicker-DpQV8G6g.cjs"),q=require("./helptext-AqNI_oFG.cjs"),x=require("./heading-CxJ0IqpU.cjs"),C=require("./icon-B1_BRNqf.cjs"),v=require("./input-wrapper-B_TtkGqo.cjs"),S=require("./link-BWJrqWi7.cjs"),$=require("./linkcard-0KLDuaGM.cjs"),L=require("./loader--5h6NKGl.cjs"),_=require("./messagebox-IJOkv427.cjs"),A=require("./modal-CBURcXBd.cjs"),B=require("./progressbar-BrXtjUvh.cjs"),p=require("./radiobutton-x10h-JEh.cjs"),T=require("./tag-lU4vz70a.cjs"),I=require("./textarea-j8kBS-hf.cjs"),M=require("./textinput-kmcj-FlC.cjs"),R=require("./select-BUvu5SFp.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 y.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
2
  <div class="${O.e(e)}">
3
3
  <h1 class="pkt-txt-28">${this.string}</h1>
4
4
 
package/dist/pkt-index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { P as A } from "./alert-CoGYPbs-.js";
1
+ import { P as A } from "./alert-oh7nc3ip.js";
2
2
  import { P as B, a as E } from "./accordionitem-DkE9or0K.js";
3
3
  import { P as O } from "./backlink-BnlrDl9O.js";
4
4
  import { P as T } from "./button-OLSvT2Im.js";
5
5
  import { c as f } from "./calendar-Beno8yU7.js";
6
6
  import { P as D } from "./calendar-Beno8yU7.js";
7
7
  import { P as G } from "./card-BxHlJq4J.js";
8
- import { P as K } from "./combobox-Ct7-a2Vy.js";
8
+ import { P as K } from "./combobox-CavDENt-.js";
9
9
  import { P as U } from "./consent-a09DlJZT.js";
10
10
  import { P as q } from "./checkbox-B67_cfqW.js";
11
11
  import { P as k, t as h, x as P, n, a as c } from "./element-gAd63VwC.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-elements",
3
- "version": "12.41.0",
3
+ "version": "12.42.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",
@@ -59,5 +59,5 @@
59
59
  "url": "https://github.com/oslokommune/punkt/issues"
60
60
  },
61
61
  "license": "MIT",
62
- "gitHead": "0fa02d9d211044739d7b86ec9f24f334df782a1d"
62
+ "gitHead": "fdb019a20d3a46f588a23a1648fce810c54578a8"
63
63
  }
@@ -20,6 +20,7 @@ export interface IPktAlert {
20
20
  ariaLive?: TAriaLive | null
21
21
  'aria-live'?: TAriaLive | null
22
22
  compact?: boolean
23
+ role?: string
23
24
  }
24
25
  @customElement('pkt-alert')
25
26
  export class PktAlert extends PktElement implements IPktAlert {
@@ -41,6 +42,7 @@ export class PktAlert extends PktElement implements IPktAlert {
41
42
  @property({ type: String, reflect: true }) 'aria-live': TAriaLive | null = null
42
43
  @property({ type: Boolean, reflect: true }) closeAlert = specs.props.closeAlert.default
43
44
  @property({ type: String, reflect: true }) date: string | null = null
45
+ @property({ type: String, reflect: true }) role: string = 'status'
44
46
 
45
47
  @state() _isClosed: boolean = false
46
48
 
@@ -85,7 +87,7 @@ export class PktAlert extends PktElement implements IPktAlert {
85
87
  }
86
88
 
87
89
  return html`
88
- <div class=${classMap(classes)}>
90
+ <div class=${classMap(classes)} aria-live=${this['aria-live']}>
89
91
  <div class=${classMap(gridClasses)}>
90
92
  <pkt-icon
91
93
  class="pkt-alert__icon"
@@ -49,6 +49,7 @@ export interface IPktCombobox {
49
49
  optionalTag?: boolean
50
50
  optionalText?: string
51
51
  options?: IPktComboboxOption[]
52
+ defaultOptions?: IPktComboboxOption[]
52
53
  placeholder?: string | null
53
54
  requiredTag?: boolean
54
55
  requiredText?: string
@@ -79,6 +80,7 @@ export class PktCombobox extends PktInputElement implements IPktCombobox {
79
80
  // Props / Attributes
80
81
  @property({ type: String, reflect: true }) value: string | string[] = ''
81
82
  @property({ type: Array }) options: IPktComboboxOption[] = []
83
+ @property({ type: Array }) defaultOptions: IPktComboboxOption[] = []
82
84
  @property({ type: Boolean }) allowUserInput: boolean = false
83
85
  @property({ type: Boolean }) typeahead: boolean = false
84
86
  @property({ type: Boolean }) includeSearch: boolean = false
@@ -118,6 +120,15 @@ export class PktCombobox extends PktInputElement implements IPktCombobox {
118
120
  })
119
121
 
120
122
  this._options = []
123
+
124
+ // Deep clone defaultOptions into options, preserving userAdded options
125
+ if (this.defaultOptions && this.defaultOptions.length) {
126
+ const userAdded = this.options?.filter((opt) => opt.userAdded) || []
127
+ this.options = [...userAdded, ...structuredClone(this.defaultOptions)]
128
+ this._options = [...this.options]
129
+ }
130
+
131
+ // If options are provided via the options slot, we need to extract them
121
132
  if (this.optionsController.nodes.length) {
122
133
  const options: IPktComboboxOption[] = []
123
134
  this.optionsController.nodes.forEach((node: Element) => {
@@ -156,8 +167,23 @@ export class PktCombobox extends PktInputElement implements IPktCombobox {
156
167
  }
157
168
  this.isMaxItemsReached()
158
169
  }
170
+
171
+ // If defaultOptions changed, update options (preserving userAdded)
172
+ if (changedProperties.has('defaultOptions') && this.defaultOptions.length) {
173
+ const userAdded = this.options?.filter((opt) => opt.userAdded) || []
174
+ this.options = [...userAdded, ...structuredClone(this.defaultOptions)]
175
+ this._options = [...this.options]
176
+ }
177
+
159
178
  if (changedProperties.has('options') && this.options.length) {
160
- this._options = this.options
179
+ // If options change, we need to update _options, but we need to preserve userAdded values
180
+ const userAddedValues = this._options.filter((option) => option.userAdded)
181
+ // Filter out userAddedValues that are overridden by this.options
182
+ const filteredUserAdded = userAddedValues.filter(
183
+ (userOpt) => !this.options.some((opt) => opt.value === userOpt.value),
184
+ )
185
+ // Merge, giving precedence to this.options
186
+ this._options = [...filteredUserAdded, ...this.options]
161
187
  this._options.forEach((option) => {
162
188
  if (option.value && !option.label) {
163
189
  option.label = option.value
@@ -1,32 +0,0 @@
1
- "use strict";const c=require("./class-map-DWDPOqjO.cjs"),e=require("./element-90YeMNbV.cjs"),u=require("./state-D-Recv7U.cjs"),h=require("./pkt-slot-controller-Da-RgXfS.cjs"),d=require("./ref-B-w1vCo8.cjs"),k=require("./classutils-BwNK82ZQ.cjs");require("./icon-B1_BRNqf.cjs");const v={skin:{default:"info"},ariaLive:{default:"polite"},compact:{default:!1},closeAlert:{default:!1}},a={props:v};var f=Object.defineProperty,_=Object.getOwnPropertyDescriptor,i=(o,t,s,l)=>{for(var r=l>1?void 0:l?_(t,s):t,p=o.length-1,n;p>=0;p--)(n=o[p])&&(r=(l?n(t,s,r):n(r))||r);return l&&r&&f(t,s,r),r};exports.PktAlert=class extends e.PktElement{constructor(){super(),this.defaultSlot=d.e(),this.compact=a.props.compact.default,this.title="",this.skin=a.props.skin.default,this.ariaLive=a.props.ariaLive.default,this["aria-live"]=null,this.closeAlert=a.props.closeAlert.default,this.date=null,this._isClosed=!1,this.close=t=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent("close",{detail:{origin:t},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("on-close",{detail:{origin:t},bubbles:!0,composed:!0}))},this.slotController=new h.PktSlotController(this,this.defaultSlot),this._isClosed=!1}connectedCallback(){super.connectedCallback(),this["aria-live"]=this.getAttribute("aria-live")||this.ariaLive}attributeChangedCallback(t,s,l){t==="ariaLive"&&(this["aria-live"]=l),super.attributeChangedCallback(t,s,l)}updated(t){super.updated(t),t.has("ariaLive")&&(this["aria-live"]=this.ariaLive),t.has("_isClosed")&&k.updateClassAttribute(this,"pkt-hide",this._isClosed)}render(){const t={"pkt-alert":!0,"pkt-alert--compact":this.compact,[`pkt-alert--${this.skin}`]:this.skin,"pkt-hide":this._isClosed},s={"pkt-alert__grid":!0,"pkt-alert__noTitle":!this.title,"pkt-alert__noDate":!this.date};return e.x`
2
- <div class=${c.e(t)}>
3
- <div class=${c.e(s)}>
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.x`
11
- <div class="pkt-alert__close">
12
- <pkt-button
13
- tabindex="0"
14
- aria-label="close"
15
- size=${this.compact?"small":"medium"}
16
- type="button"
17
- skin="tertiary"
18
- iconName="close"
19
- variant="icon-only"
20
- @click=${this.close}
21
- >
22
- </pkt-button>
23
- </div>
24
- `:e.E}
25
- ${this.title?e.x`<div class="pkt-alert__title">${this.title}</div>`:e.E}
26
-
27
- <div class="pkt-alert__text" ${d.n(this.defaultSlot)}></div>
28
-
29
- ${this.date?e.x`<div class="pkt-alert__date">Sist oppdatert: ${this.date}</div>`:e.E}
30
- </div>
31
- </div>
32
- `}};i([e.n({type:Boolean,reflect:!1})],exports.PktAlert.prototype,"compact",2);i([e.n({type:String,reflect:!0})],exports.PktAlert.prototype,"title",2);i([e.n({type:String,reflect:!0})],exports.PktAlert.prototype,"skin",2);i([e.n({type:String})],exports.PktAlert.prototype,"ariaLive",2);i([e.n({type:String,reflect:!0})],exports.PktAlert.prototype,"aria-live",2);i([e.n({type:Boolean,reflect:!0})],exports.PktAlert.prototype,"closeAlert",2);i([e.n({type:String,reflect:!0})],exports.PktAlert.prototype,"date",2);i([u.r()],exports.PktAlert.prototype,"_isClosed",2);exports.PktAlert=i([e.t("pkt-alert")],exports.PktAlert);