@oslokommune/punkt-elements 14.3.0 → 14.5.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.
Files changed (149) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/{accordionitem-C_URrDjP.js → accordionitem-DB3tAjIZ.js} +4 -4
  3. package/dist/{accordionitem-DCZrHVNR.cjs → accordionitem-DHYmPA-o.cjs} +1 -1
  4. package/dist/{alert-UFQFbbzZ.js → alert-DqXar67l.js} +6 -6
  5. package/dist/{alert-SvqEDHuW.cjs → alert-GrKyqxuR.cjs} +1 -1
  6. package/dist/{backlink-C7qUmUzs.js → backlink-CqUcmiPQ.js} +11 -11
  7. package/dist/{backlink-BrIIpgJ7.cjs → backlink-QDcQd6vK.cjs} +1 -1
  8. package/dist/{button-DaM4jvhJ.cjs → button-R4l10Nqd.cjs} +1 -1
  9. package/dist/{button-CjXih_Nx.js → button-f36menSU.js} +5 -5
  10. package/dist/{calendar-CvfMj3fA.js → calendar-DiNuZ8Ai.js} +7 -8
  11. package/dist/{calendar-ZzLAjDpv.cjs → calendar-wuD6ZH0t.cjs} +3 -3
  12. package/dist/{card-C1gRTfXb.cjs → card-C2hWaMev.cjs} +1 -1
  13. package/dist/{card-CO3D8wQE.js → card-CnINxZma.js} +7 -7
  14. package/dist/{checkbox-C0TPnShf.cjs → checkbox-B-0FOdwi.cjs} +1 -1
  15. package/dist/{checkbox-CnhA52o_.js → checkbox-CkAwPK_E.js} +4 -4
  16. package/dist/{class-map-C_erArZz.cjs → class-map-CApIYSRo.cjs} +1 -1
  17. package/dist/{class-map-wy7PUk0P.js → class-map-Dt2jXOlF.js} +1 -1
  18. package/dist/{combobox-Dcp_fHcL.js → combobox-Dxa7XjLz.js} +55 -55
  19. package/dist/{combobox-C1xwAju5.cjs → combobox-yy6hIGmB.cjs} +13 -13
  20. package/dist/{consent-Daj-Xa7w.cjs → consent-FbFS1pmz.cjs} +1 -1
  21. package/dist/{consent-BO3Ga8N4.js → consent-c9PhWxnP.js} +3 -3
  22. package/dist/{datepicker-Bjb9GK1E.js → datepicker-C7GWMtXH.js} +222 -241
  23. package/dist/{datepicker-COIRRau0.cjs → datepicker-D_3vYgMt.cjs} +25 -25
  24. package/dist/{directive-helpers-BzAtj9by.js → directive-helpers-CQef4qUQ.js} +1 -1
  25. package/dist/{directive-helpers-4oOjKnGY.cjs → directive-helpers-CYIEJ8pI.cjs} +1 -1
  26. package/dist/{element-CRDRygXu.js → element-BXsf_NlG.js} +3 -3
  27. package/dist/{element-CJ_QKaki.cjs → element-aUzIoa1s.cjs} +3 -3
  28. package/dist/{heading-Dv_cH6N1.cjs → heading-CBepYb7H.cjs} +1 -1
  29. package/dist/{heading-BUdy170t.js → heading-J7dN9nRi.js} +13 -13
  30. package/dist/{helptext-hlcc584n.cjs → helptext-DebHGRsD.cjs} +1 -1
  31. package/dist/{helptext-Bn17Picx.js → helptext-DuyRRfCn.js} +5 -5
  32. package/dist/{icon-BB7e5iQN.js → icon-BgG6oO4Q.js} +1 -1
  33. package/dist/{icon-MRx-m0Or.cjs → icon-Dl9ZPqe6.cjs} +1 -1
  34. package/dist/{if-defined-Bc9-_I01.cjs → if-defined-BElHLTlB.cjs} +1 -1
  35. package/dist/{if-defined-BWZGb3bh.js → if-defined-CxHgig4I.js} +1 -1
  36. package/dist/index.d.ts +213 -55
  37. package/dist/input-element-DVZhYDJ_.js +840 -0
  38. package/dist/input-element-RBQVA8i0.cjs +1 -0
  39. package/dist/{input-wrapper-1PCXqtiu.js → input-wrapper-3qfjLkrP.js} +7 -7
  40. package/dist/{input-wrapper-CtBiAb04.cjs → input-wrapper-rgXsRNkk.cjs} +1 -1
  41. package/dist/{link-BboUBUcg.js → link-CZvcdRek.js} +4 -4
  42. package/dist/{link-Dw39h-YN.cjs → link-D85g20GS.cjs} +1 -1
  43. package/dist/{linkcard-DUA3kGGd.cjs → linkcard-B-9K02q8.cjs} +1 -1
  44. package/dist/{linkcard-BqJmHFu8.js → linkcard-C3RTcMqc.js} +4 -4
  45. package/dist/{listbox-mvKKzH-v.js → listbox-CLtowV6W.js} +36 -36
  46. package/dist/{listbox-DnoqOo5u.cjs → listbox-C_0RhGhk.cjs} +2 -2
  47. package/dist/{loader-DjGxT7C3.cjs → loader-1EXLdxfq.cjs} +1 -1
  48. package/dist/{loader-DIum_s_D.js → loader-Dci0SrOz.js} +5 -5
  49. package/dist/{messagebox-aPlConlJ.js → messagebox-CnZlttZp.js} +5 -5
  50. package/dist/{messagebox-ChIKVTO_.cjs → messagebox-dscnWgCd.cjs} +1 -1
  51. package/dist/{modal-B4qq0VFB.cjs → modal-ncKVjcyZ.cjs} +1 -1
  52. package/dist/{modal-jAUtM-NP.js → modal-wSGthXAC.js} +5 -5
  53. package/dist/pkt-accordion.cjs +1 -1
  54. package/dist/pkt-accordion.js +2 -2
  55. package/dist/pkt-alert.cjs +1 -1
  56. package/dist/pkt-alert.js +1 -1
  57. package/dist/pkt-backlink.cjs +1 -1
  58. package/dist/pkt-backlink.js +1 -1
  59. package/dist/pkt-button.cjs +1 -1
  60. package/dist/pkt-button.js +1 -1
  61. package/dist/pkt-calendar.cjs +1 -1
  62. package/dist/pkt-calendar.js +1 -1
  63. package/dist/pkt-card.cjs +1 -1
  64. package/dist/pkt-card.js +1 -1
  65. package/dist/pkt-checkbox.cjs +1 -1
  66. package/dist/pkt-checkbox.js +1 -1
  67. package/dist/pkt-combobox.cjs +1 -1
  68. package/dist/pkt-combobox.js +1 -1
  69. package/dist/pkt-consent.cjs +1 -1
  70. package/dist/pkt-consent.js +1 -1
  71. package/dist/pkt-datepicker.cjs +1 -1
  72. package/dist/pkt-datepicker.js +2 -2
  73. package/dist/pkt-header.cjs +1 -1
  74. package/dist/pkt-header.js +9 -9
  75. package/dist/pkt-heading.cjs +1 -1
  76. package/dist/pkt-heading.js +1 -1
  77. package/dist/pkt-helptext.cjs +1 -1
  78. package/dist/pkt-helptext.js +1 -1
  79. package/dist/pkt-icon.cjs +1 -1
  80. package/dist/pkt-icon.js +1 -1
  81. package/dist/pkt-index.cjs +1 -29
  82. package/dist/pkt-index.js +60 -157
  83. package/dist/pkt-input-wrapper.cjs +1 -1
  84. package/dist/pkt-input-wrapper.js +1 -1
  85. package/dist/pkt-link.cjs +1 -1
  86. package/dist/pkt-link.js +1 -1
  87. package/dist/pkt-linkcard.cjs +1 -1
  88. package/dist/pkt-linkcard.js +1 -1
  89. package/dist/pkt-listbox.cjs +1 -1
  90. package/dist/pkt-listbox.js +1 -1
  91. package/dist/pkt-loader.cjs +1 -1
  92. package/dist/pkt-loader.js +1 -1
  93. package/dist/pkt-messagebox.cjs +1 -1
  94. package/dist/pkt-messagebox.js +1 -1
  95. package/dist/pkt-modal.cjs +1 -1
  96. package/dist/pkt-modal.js +1 -1
  97. package/dist/pkt-options-controller-DjBCEHU4.cjs +1 -0
  98. package/dist/{pkt-options-controller-CZO1nxZ8.js → pkt-options-controller-zn5cmMvL.js} +3 -3
  99. package/dist/pkt-progressbar.cjs +1 -1
  100. package/dist/pkt-progressbar.js +2 -2
  101. package/dist/pkt-radiobutton.cjs +1 -1
  102. package/dist/pkt-radiobutton.js +1 -1
  103. package/dist/pkt-select.cjs +1 -1
  104. package/dist/pkt-select.js +1 -1
  105. package/dist/pkt-tabs.cjs +1 -1
  106. package/dist/pkt-tabs.js +2 -2
  107. package/dist/pkt-tag.cjs +1 -1
  108. package/dist/pkt-tag.js +1 -1
  109. package/dist/pkt-textarea.cjs +1 -1
  110. package/dist/pkt-textarea.js +1 -1
  111. package/dist/pkt-textinput.cjs +1 -1
  112. package/dist/pkt-textinput.js +1 -1
  113. package/dist/{progressbar-CmAQ-DVW.cjs → progressbar-ClY1WgnM.cjs} +1 -1
  114. package/dist/{progressbar-CVt73-JQ.js → progressbar-D5WBW1Dm.js} +5 -5
  115. package/dist/{radiobutton-BkqaqO5E.cjs → radiobutton-iHuLnuAn.cjs} +1 -1
  116. package/dist/{radiobutton-Caq8-GhM.js → radiobutton-oA20HijB.js} +15 -15
  117. package/dist/{ref-Xa5dbh--.js → ref-BxiKhrfa.js} +2 -2
  118. package/dist/{ref-BFa5Utho.cjs → ref-C5iJMIE1.cjs} +1 -1
  119. package/dist/{repeat-CJ79egkN.js → repeat-B55jMEsG.js} +2 -2
  120. package/dist/{repeat-BZb41H64.cjs → repeat-DcYSFU2y.cjs} +1 -1
  121. package/dist/select-Bug9sfr5.js +228 -0
  122. package/dist/select-jbIbD7hW.cjs +49 -0
  123. package/dist/{state-DS_kr2Fy.js → state-DgnkjP0q.js} +1 -1
  124. package/dist/{state-DSjcvzDN.cjs → state-GDzxl12x.cjs} +1 -1
  125. package/dist/{tabitem-D5zyipN1.cjs → tabitem-CtltSqDK.cjs} +1 -1
  126. package/dist/{tabitem-NV2fzs_-.js → tabitem-CypTmORF.js} +30 -30
  127. package/dist/{tag-B02fKJ66.cjs → tag-BfjOlIyS.cjs} +1 -1
  128. package/dist/{tag-CES41g0D.js → tag-DgoTYNVA.js} +6 -6
  129. package/dist/{textarea-a6T4aJJU.js → textarea-Da9E3RM7.js} +9 -9
  130. package/dist/{textarea-DyUy8u7X.cjs → textarea-Dfa4_ZBy.cjs} +1 -1
  131. package/dist/{textinput-IN3b0nSH.cjs → textinput-CLM9fRjm.cjs} +1 -1
  132. package/dist/{textinput-DIuM70dd.js → textinput-DaMYc5gd.js} +8 -8
  133. package/package.json +2 -2
  134. package/src/components/checkbox/checkbox.ts +1 -1
  135. package/src/components/combobox/combobox.ts +2 -2
  136. package/src/components/datepicker/datepicker-utils.test.ts +0 -25
  137. package/src/components/datepicker/datepicker-utils.ts +0 -28
  138. package/src/components/datepicker/datepicker.ts +0 -6
  139. package/src/components/header/header.ts +2 -0
  140. package/src/components/index.ts +0 -1
  141. package/src/components/radiobutton/radiobutton.ts +1 -1
  142. package/src/components/select/select.ts +14 -47
  143. package/src/components/textarea/textarea.ts +1 -1
  144. package/src/components/textinput/textinput.ts +1 -1
  145. package/dist/input-element-B8M8Nppd.js +0 -708
  146. package/dist/input-element-D697OAJo.cjs +0 -1
  147. package/dist/pkt-options-controller-CiuBG6Lt.cjs +0 -1
  148. package/dist/select-3dwlk22G.cjs +0 -49
  149. package/dist/select-_C-yztI0.js +0 -173
@@ -27,34 +27,6 @@ import { PktCalendar } from '@/components/calendar/calendar'
27
27
  * Value parsing and validation utilities
28
28
  */
29
29
  export const valueUtils = {
30
- /**
31
- * Ensures name attribute ends with [] for multiple/range inputs
32
- *
33
- * For form submission to work correctly with multiple values,
34
- * the input name must end with [] to indicate it's an array.
35
- *
36
- * @param name - The original name attribute value
37
- * @param isMultiple - Whether this is a multiple-date picker
38
- * @param isRange - Whether this is a range date picker
39
- * @returns The normalized name with [] suffix if needed, or null if name is null
40
- *
41
- * @example
42
- * normalizeNameForMultiple('dates', true, false) // Returns 'dates[]'
43
- * normalizeNameForMultiple('dates[]', true, false) // Returns 'dates[]' (no change)
44
- * normalizeNameForMultiple('date', false, false) // Returns 'date' (no change)
45
- */
46
- normalizeNameForMultiple(
47
- name: string | null,
48
- isMultiple: boolean,
49
- isRange: boolean,
50
- ): string | null {
51
- if (!name) return null
52
- if ((isMultiple || isRange) && !name.endsWith('[]')) {
53
- return name + '[]'
54
- }
55
- return name
56
- },
57
-
58
30
  /**
59
31
  * Validates that a range has valid order (start <= end)
60
32
  *
@@ -142,8 +142,6 @@ export class PktDatepicker extends PktInputElement<Props> {
142
142
  if (this.timezone && this.timezone !== window.pktTz) {
143
143
  window.pktTz = this.timezone
144
144
  }
145
- this.name =
146
- valueUtils.normalizeNameForMultiple(this.name, this.multiple, this.range) || this.name
147
145
  }
148
146
 
149
147
  disconnectedCallback(): void {
@@ -211,10 +209,6 @@ export class PktDatepicker extends PktInputElement<Props> {
211
209
  const oldValueStr = Array.isArray(oldValue) ? oldValue.join(',') : oldValue
212
210
  this.valueChanged(newValue, oldValueStr)
213
211
  }
214
- if (changedProperties.has('multiple') || changedProperties.has('range')) {
215
- this.name =
216
- valueUtils.normalizeNameForMultiple(this.name, this.multiple, this.range) || this.name
217
- }
218
212
  if (changedProperties.has('multiple')) {
219
213
  if (this.multiple && !Array.isArray(this._value)) {
220
214
  this._value = valueToArray(this.value)
@@ -88,9 +88,11 @@ export class PktHeader extends PktElement<IPktHeader> implements IPktHeader {
88
88
 
89
89
  private emitDeprecationWarnings() {
90
90
  if (this.userMenuFooter !== undefined) {
91
+ // eslint-disable-next-line no-console -- Deprecation warnings are intentional for library consumers
91
92
  console.warn('[PktHeader] userMenuFooter is deprecated. Use userMenu instead.')
92
93
  }
93
94
  if (this.userOptions !== undefined) {
95
+ // eslint-disable-next-line no-console -- Deprecation warnings are intentional for library consumers
94
96
  console.warn('[PktHeader] userOptions is deprecated. Use userMenu instead.')
95
97
  }
96
98
  }
@@ -8,7 +8,6 @@ export { PktCard } from '@/components/card'
8
8
  export { PktCombobox } from './combobox'
9
9
  export { PktConsent } from './consent'
10
10
  export { PktCheckbox } from '@/components/checkbox'
11
- export { PktComponent } from '../base-elements/component-template.js'
12
11
  export { PktDateTags } from '@/components/datepicker/date-tags.js'
13
12
  export { PktDatepicker } from '@/components/datepicker/datepicker.js'
14
13
  export { PktHeader, PktHeaderService, PktHeaderUserMenu } from '@/components/header'
@@ -20,7 +20,7 @@ type Props = ElementProps<
20
20
 
21
21
  @customElement('pkt-radiobutton')
22
22
  export class PktRadioButton extends PktInputElement<Props> {
23
- private inputRef: Ref<HTMLInputElement> = createRef()
23
+ inputRef: Ref<HTMLInputElement> = createRef()
24
24
 
25
25
  @property({ type: String, reflect: true }) value: string = ''
26
26
  @property({ type: String }) checkHelptext: string | null = null
@@ -1,8 +1,8 @@
1
1
  import { html, PropertyValues } from 'lit'
2
- import { customElement, property, state } from 'lit/decorators.js'
2
+ import { customElement, property } from 'lit/decorators.js'
3
3
  import { Ref, createRef, ref } from 'lit/directives/ref.js'
4
4
  import { ifDefined } from 'lit/directives/if-defined.js'
5
- import { PktInputElement } from '@/base-elements/input-element'
5
+ import { PktOptionsInputElement } from '@/base-elements/options-input-element'
6
6
  import { PktOptionsSlotController } from '@/controllers/pkt-options-controller'
7
7
  import { PktSlotController } from '@/controllers/pkt-slot-controller'
8
8
  import '@/components/input-wrapper'
@@ -39,31 +39,15 @@ declare global {
39
39
  }
40
40
 
41
41
  @customElement('pkt-select')
42
- export class PktSelect extends PktInputElement implements IPktSelect {
43
- private inputRef: Ref<HTMLSelectElement> = createRef()
42
+ export class PktSelect extends PktOptionsInputElement<{}, TSelectOption> implements IPktSelect {
43
+ inputRef: Ref<HTMLSelectElement> = createRef()
44
44
  private helptextSlot: Ref<HTMLElement> = createRef()
45
45
 
46
- @property({ type: Array, attribute: 'options' }) private _optionsProp: TSelectOption[] = []
47
46
  @property({ type: String }) value: string = ''
48
47
 
49
- @state() _options: TSelectOption[] = []
50
-
51
48
  public selectedIndex: number | null = -1
52
49
  public selectedOptions: HTMLCollectionOf<HTMLOptionElement> | undefined = undefined
53
50
 
54
- // Getter and setter for options to expose the actual parsed options
55
- public get options(): TSelectOption[] {
56
- return this._options.map((option) => ({
57
- ...option,
58
- selected: option.value === this.value,
59
- }))
60
- }
61
-
62
- public set options(value: TSelectOption[]) {
63
- this._optionsProp = value
64
- this.requestUpdate('_optionsProp', this._options)
65
- }
66
-
67
51
  constructor() {
68
52
  super()
69
53
  this.optionsController = new PktOptionsSlotController(this)
@@ -74,34 +58,15 @@ export class PktSelect extends PktInputElement implements IPktSelect {
74
58
  connectedCallback(): void {
75
59
  super.connectedCallback()
76
60
 
77
- const optionsReceivedFromProps = this._optionsProp.length > 0
78
- const checkIfOptionNodesInSlot =
79
- this.optionsController.nodes.length && this.optionsController.nodes.length > 0
61
+ // Parse options from props or slots
62
+ this.parseOptions()
80
63
 
81
- if (!optionsReceivedFromProps && checkIfOptionNodesInSlot) {
82
- this.optionsController.nodes.forEach((node: Element) => {
83
- const option: TSelectOption = {
84
- value: node.hasAttribute('value')
85
- ? (node.getAttribute('value') ?? '')
86
- : (node.textContent ?? ''),
87
- label: node.textContent || node.getAttribute('value') || '',
88
- disabled: node.hasAttribute('disabled'),
89
- selected: node.hasAttribute('selected'),
90
- hidden: node.hasAttribute('data-hidden'),
91
- }
92
- if (node.getAttribute('selected') && !this.value) {
93
- this.value = option.value
94
- }
95
- this._options.push(option)
96
- })
97
- } else {
98
- this._options = this._optionsProp
99
- this._options.forEach((option) => {
100
- if (option.selected && !this.value) {
101
- this.value = option.value
102
- }
103
- })
104
- }
64
+ // Set initial value from selected option
65
+ this._options.forEach((option) => {
66
+ if (option.selected && !this.value) {
67
+ this.value = option.value
68
+ }
69
+ })
105
70
  }
106
71
 
107
72
  // Support native Select method `add`
@@ -160,6 +125,7 @@ export class PktSelect extends PktInputElement implements IPktSelect {
160
125
  // Support native Select method `showPicker`
161
126
  public showPicker() {
162
127
  if (this.inputRef.value && 'showPicker' in this.inputRef.value) {
128
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- showPicker is not in TypeScript's HTMLSelectElement type yet
163
129
  ;(this.inputRef.value as any).showPicker()
164
130
  }
165
131
  }
@@ -186,6 +152,7 @@ export class PktSelect extends PktInputElement implements IPktSelect {
186
152
 
187
153
  // If no value is set and we have options, set to first option
188
154
  if (!this.value && this._options.length > 0) {
155
+ // eslint-disable-next-line lit/no-property-change-update -- Initial value setup is intentional
189
156
  this.value = this._options[0].value
190
157
  this.selectedIndex = 0
191
158
  }
@@ -15,7 +15,7 @@ type Props = ElementProps<PktTextarea, 'autocomplete' | 'rows'>
15
15
 
16
16
  @customElement('pkt-textarea')
17
17
  export class PktTextarea extends PktInputElement<Props> {
18
- private inputRef: Ref<HTMLTextAreaElement> = createRef()
18
+ inputRef: Ref<HTMLTextAreaElement> = createRef()
19
19
  private helptextSlot: Ref<HTMLElement> = createRef()
20
20
 
21
21
  @property({ type: String, reflect: true }) value: string = ''
@@ -24,7 +24,7 @@ type Props = ElementProps<
24
24
 
25
25
  @customElement('pkt-textinput')
26
26
  export class PktTextinput extends PktInputElement<Props> {
27
- private inputRef: Ref<HTMLTextAreaElement> = createRef()
27
+ inputRef: Ref<HTMLTextAreaElement> = createRef()
28
28
  private helptextSlot: Ref<HTMLElement> = createRef()
29
29
 
30
30
  @property({ type: String, reflect: true }) value: string = ''