@oslokommune/punkt-elements 18.3.1 → 18.5.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.
Files changed (154) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/{accordion-4eAsO-Sr.js → accordion-D814csFx.js} +6 -6
  3. package/dist/{accordion-DOa5vubf.cjs → accordion-E0-pLzBq.cjs} +6 -6
  4. package/dist/{alert-DKNJTlMQ.js → alert-DNZtr3gd.js} +39 -31
  5. package/dist/alert-DqM9l5as.cjs +40 -0
  6. package/dist/{backlink-CA5R69FX.cjs → backlink-DYO8qA9C.cjs} +1 -1
  7. package/dist/{button-Dqolsuwj.js → button-Drwt7Qe5.js} +29 -26
  8. package/dist/button-jJfzE9C7.cjs +32 -0
  9. package/dist/{card-DgRvtnnk.js → card-BhmJZOGh.js} +90 -70
  10. package/dist/card-D-1JMn_h.cjs +64 -0
  11. package/dist/{combobox-q8kzy-S_.js → combobox-BNstYIC5.js} +20 -20
  12. package/dist/{combobox-D3zyAi_o.cjs → combobox-CRdBlMz1.cjs} +17 -17
  13. package/dist/components/alert/alert.d.ts +2 -0
  14. package/dist/components/button/button.d.ts +4 -21
  15. package/dist/components/button/index.d.ts +1 -1
  16. package/dist/components/card/card.d.ts +12 -3
  17. package/dist/components/index.d.ts +1 -1
  18. package/dist/components/linkcard/linkcard.d.ts +1 -1
  19. package/dist/components/loader/loader.d.ts +2 -2
  20. package/dist/components/messagebox/messagebox.d.ts +1 -1
  21. package/dist/components/progressbar/progressbar.d.ts +2 -6
  22. package/dist/{consent-Cqetmc5Q.cjs → consent-DaOFbopy.cjs} +1 -1
  23. package/dist/{consent-Dkyp-UbI.js → consent-Yvw7gZI_.js} +1 -1
  24. package/dist/{datepicker-8KnaI9Xj.cjs → datepicker-DjvL_Nb8.cjs} +16 -16
  25. package/dist/{datepicker-9ulmApjN.js → datepicker-DzTdWHkX.js} +3 -3
  26. package/dist/docs/components/button.d.ts +0 -1
  27. package/dist/{fileupload-XQAilDRd.js → fileupload-B8Uhfx2d.js} +24 -24
  28. package/dist/{fileupload-EWBE4h3V.cjs → fileupload-BJVYPl8u.cjs} +15 -15
  29. package/dist/{footer-BpuYmm5V.cjs → footer-BGC5PkLa.cjs} +1 -1
  30. package/dist/{footer-BXmN43ol.js → footer-BPxKLaut.js} +2 -2
  31. package/dist/{header-BPQHiw4v.js → header-BPzlBRhY.js} +30 -30
  32. package/dist/{header-BQ32MqUl.cjs → header-CAqegPzW.cjs} +34 -34
  33. package/dist/{header-menu-DpQbRKcm.cjs → header-menu-DBy7Yrd_.cjs} +1 -1
  34. package/dist/{header-menu-Dgem4HO9.js → header-menu-DWiPoQ58.js} +1 -1
  35. package/dist/{helptext-Ds8Q9IGV.cjs → helptext-BwDhf6VB.cjs} +2 -2
  36. package/dist/{helptext-BzLJKMMO.js → helptext-mf-67-fv.js} +2 -2
  37. package/dist/{input-wrapper-DzEgz7nZ.js → input-wrapper-BetB7OLQ.js} +16 -15
  38. package/dist/{input-wrapper-B0eSdZs3.cjs → input-wrapper-CS0qrYcm.cjs} +8 -7
  39. package/dist/{link-CpwR3BLX.cjs → link-DXnoMJIo.cjs} +3 -3
  40. package/dist/{link-C9xAIILf.js → link-DkO7a3Fs.js} +3 -3
  41. package/dist/{linkcard-Bzv3CEw5.cjs → linkcard-2l6z1M2U.cjs} +3 -3
  42. package/dist/{linkcard-C6ljKc0B.js → linkcard-aVKL5JPP.js} +8 -8
  43. package/dist/{loader-D6dau_7w.js → loader-CRVUJ-HU.js} +1 -1
  44. package/dist/{loader-Bv-1vwju.cjs → loader-D23kzlaR.cjs} +1 -1
  45. package/dist/{messagebox-CmhjIh0n.js → messagebox-CqI6_Ah7.js} +2 -2
  46. package/dist/{messagebox-DNUfv2FN.cjs → messagebox-DP06cyqc.cjs} +1 -1
  47. package/dist/pkt-accordion.cjs +1 -1
  48. package/dist/pkt-accordion.js +1 -1
  49. package/dist/pkt-alert.cjs +1 -1
  50. package/dist/pkt-alert.js +1 -1
  51. package/dist/pkt-backlink.cjs +1 -1
  52. package/dist/pkt-backlink.js +1 -1
  53. package/dist/pkt-button.cjs +1 -1
  54. package/dist/pkt-button.js +1 -1
  55. package/dist/pkt-card.cjs +1 -1
  56. package/dist/pkt-card.js +1 -1
  57. package/dist/pkt-combobox.cjs +1 -1
  58. package/dist/pkt-combobox.js +1 -1
  59. package/dist/pkt-consent.cjs +1 -1
  60. package/dist/pkt-consent.js +1 -1
  61. package/dist/pkt-datepicker.cjs +1 -1
  62. package/dist/pkt-datepicker.js +1 -1
  63. package/dist/pkt-fileupload.cjs +1 -1
  64. package/dist/pkt-fileupload.js +1 -1
  65. package/dist/pkt-footer.cjs +1 -1
  66. package/dist/pkt-footer.js +1 -1
  67. package/dist/pkt-header-menu.cjs +1 -1
  68. package/dist/pkt-header-menu.js +1 -1
  69. package/dist/pkt-header.cjs +1 -1
  70. package/dist/pkt-header.js +1 -1
  71. package/dist/pkt-helptext.cjs +1 -1
  72. package/dist/pkt-helptext.js +1 -1
  73. package/dist/pkt-index.cjs +1 -1
  74. package/dist/pkt-index.js +31 -31
  75. package/dist/pkt-input-wrapper.cjs +1 -1
  76. package/dist/pkt-input-wrapper.js +1 -1
  77. package/dist/pkt-link.cjs +1 -1
  78. package/dist/pkt-link.js +1 -1
  79. package/dist/pkt-linkcard.cjs +1 -1
  80. package/dist/pkt-linkcard.js +1 -1
  81. package/dist/pkt-loader.cjs +1 -1
  82. package/dist/pkt-loader.js +1 -1
  83. package/dist/pkt-messagebox.cjs +1 -1
  84. package/dist/pkt-messagebox.js +1 -1
  85. package/dist/pkt-progressbar.cjs +1 -1
  86. package/dist/pkt-progressbar.js +1 -1
  87. package/dist/pkt-radiobutton.cjs +1 -1
  88. package/dist/pkt-radiobutton.js +1 -1
  89. package/dist/pkt-searchinput.cjs +1 -1
  90. package/dist/pkt-searchinput.js +1 -1
  91. package/dist/pkt-select.cjs +1 -1
  92. package/dist/pkt-select.js +1 -1
  93. package/dist/pkt-tabs.cjs +1 -1
  94. package/dist/pkt-tabs.js +1 -1
  95. package/dist/pkt-tag.cjs +1 -1
  96. package/dist/pkt-tag.js +1 -1
  97. package/dist/pkt-textarea.cjs +1 -1
  98. package/dist/pkt-textarea.js +1 -1
  99. package/dist/pkt-textinput.cjs +1 -1
  100. package/dist/pkt-textinput.js +1 -1
  101. package/dist/pkt-timepicker.cjs +1 -1
  102. package/dist/pkt-timepicker.js +1 -1
  103. package/dist/progressbar-BPHLC7ce.js +117 -0
  104. package/dist/progressbar-BpcsDCnG.cjs +31 -0
  105. package/dist/{radiobutton-B_j_nYCC.js → radiobutton-B2e9Vyp8.js} +0 -1
  106. package/dist/{radiobutton-DsL-FNDd.cjs → radiobutton-C3nmL9rA.cjs} +0 -1
  107. package/dist/{searchinput-Dm3T0tGS.cjs → searchinput-CiPB8xvh.cjs} +3 -2
  108. package/dist/{searchinput-D7Dd2W2z.js → searchinput-DrUcPajl.js} +14 -12
  109. package/dist/{select-BqAZsLKy.js → select-B7TvZGIL.js} +15 -16
  110. package/dist/{select-VqzZdE-T.cjs → select-qxjHJ8bu.cjs} +13 -14
  111. package/dist/shared-types/button.d.ts +45 -0
  112. package/dist/shared-types/index.d.ts +2 -0
  113. package/dist/{tabs-DPdDkHSk.js → tabs-C_tCCdBK.js} +18 -18
  114. package/dist/{tabs-nvIpMwHK.cjs → tabs-DBanbSG1.cjs} +15 -15
  115. package/dist/tag-BDlwKjgT.cjs +27 -0
  116. package/dist/{tag-DBCzfbPE.js → tag-CdiDs9zb.js} +10 -10
  117. package/dist/{textarea-D17CiySU.cjs → textarea-DgFwd2LY.cjs} +10 -10
  118. package/dist/{textarea-C0a-K05x.js → textarea-YL6JYsB5.js} +14 -14
  119. package/dist/{textinput-D0QasOZ9.cjs → textinput-CIxMtaIo.cjs} +10 -10
  120. package/dist/{textinput-DKl04Y3e.js → textinput-CrJYDOHb.js} +12 -12
  121. package/dist/{timepicker-DVvI4uEk.js → timepicker-BHWOqlr8.js} +11 -11
  122. package/dist/{timepicker-BcnFL6Bj.cjs → timepicker-avaMu1hN.cjs} +8 -8
  123. package/package.json +2 -2
  124. package/src/components/accordion/accordion.ts +2 -1
  125. package/src/components/alert/alert.test.ts +2 -1
  126. package/src/components/alert/alert.ts +21 -3
  127. package/src/components/button/button.test.ts +0 -3
  128. package/src/components/button/button.ts +57 -62
  129. package/src/components/button/index.ts +0 -2
  130. package/src/components/card/card.test.ts +7 -7
  131. package/src/components/card/card.ts +99 -80
  132. package/src/components/helptext/helptext.ts +2 -2
  133. package/src/components/index.ts +0 -2
  134. package/src/components/input-wrapper/input-wrapper.ts +1 -0
  135. package/src/components/link/link.ts +4 -2
  136. package/src/components/linkcard/linkcard.test.ts +3 -3
  137. package/src/components/linkcard/linkcard.ts +1 -1
  138. package/src/components/loader/loader.test.ts +1 -1
  139. package/src/components/loader/loader.ts +3 -3
  140. package/src/components/messagebox/messagebox.test.ts +1 -1
  141. package/src/components/messagebox/messagebox.ts +2 -2
  142. package/src/components/progressbar/progressbar.test.ts +10 -8
  143. package/src/components/progressbar/progressbar.ts +63 -84
  144. package/src/components/radiobutton/radiobutton.ts +0 -1
  145. package/src/components/searchinput/searchinput.ts +3 -1
  146. package/src/components/select/select.test.ts +2 -1
  147. package/src/components/select/select.ts +0 -1
  148. package/dist/alert-BlHM1zEi.cjs +0 -35
  149. package/dist/button-CVMhQT3X.cjs +0 -30
  150. package/dist/card-DMKvuvNv.cjs +0 -87
  151. package/dist/progressbar-Bk_RsEjW.js +0 -112
  152. package/dist/progressbar-T5_MpZGN.cjs +0 -17
  153. package/dist/tag-Bp9gJnYh.cjs +0 -27
  154. package/dist/{backlink-BYUtL8cO.js → backlink-BHtxOlTw.js} +1 -1
@@ -38,7 +38,7 @@ describe('PktProgressbar', () => {
38
38
  const { progressbar } = await createProgressbarTest({ valueCurrent: 50 })
39
39
 
40
40
  expect(progressbar.valueCurrent).toBe(50)
41
- expect(progressbar.getAttribute('role')).toBe('progressbar')
41
+ expect(progressbar.querySelector('.pkt-progressbar')?.getAttribute('role')).toBe('progressbar')
42
42
  })
43
43
  })
44
44
 
@@ -150,10 +150,11 @@ describe('PktProgressbar', () => {
150
150
  ariaLabel: 'File upload progress',
151
151
  })
152
152
 
153
- expect(progressbar.getAttribute('aria-valuemin')).toBe('0')
154
- expect(progressbar.getAttribute('aria-valuemax')).toBe('100')
155
- expect(progressbar.getAttribute('aria-valuenow')).toBe('60')
156
- expect(progressbar.getAttribute('aria-label')).toBe('File upload progress')
153
+ const root = progressbar.querySelector('.pkt-progressbar')
154
+ expect(root?.getAttribute('aria-valuemin')).toBe('0')
155
+ expect(root?.getAttribute('aria-valuemax')).toBe('100')
156
+ expect(root?.getAttribute('aria-valuenow')).toBe('60')
157
+ expect(root?.getAttribute('aria-label')).toBe('File upload progress')
157
158
  })
158
159
 
159
160
  test('updates aria-valuenow when value changes', async () => {
@@ -162,7 +163,7 @@ describe('PktProgressbar', () => {
162
163
  progressbar.valueCurrent = 80
163
164
  await progressbar.updateComplete
164
165
 
165
- expect(progressbar.getAttribute('aria-valuenow')).toBe('80')
166
+ expect(progressbar.querySelector('.pkt-progressbar')?.getAttribute('aria-valuenow')).toBe('80')
166
167
  })
167
168
  })
168
169
 
@@ -170,13 +171,14 @@ describe('PktProgressbar', () => {
170
171
  test('uses progressbar role by default', async () => {
171
172
  const { progressbar } = await createProgressbarTest()
172
173
 
173
- expect(progressbar.getAttribute('role')).toBe('progressbar')
174
+ expect(progressbar.querySelector('.pkt-progressbar')?.getAttribute('role')).toBe('progressbar')
175
+ expect(progressbar.hasAttribute('role')).toBe(false)
174
176
  })
175
177
 
176
178
  test('uses meter role when specified', async () => {
177
179
  const { progressbar } = await createProgressbarTest({ role: 'meter' })
178
180
 
179
- expect(progressbar.getAttribute('role')).toBe('meter')
181
+ expect(progressbar.querySelector('.pkt-progressbar')?.getAttribute('role')).toBe('meter')
180
182
  })
181
183
  })
182
184
 
@@ -1,6 +1,7 @@
1
1
  import { classMap } from 'lit/directives/class-map.js'
2
2
  import { customElement, property, state } from 'lit/decorators.js'
3
3
  import { html, nothing } from 'lit'
4
+ import { ifDefined } from 'lit/directives/if-defined.js'
4
5
  import { PktElement } from '@/base-elements/element'
5
6
  import { Ref, createRef, ref } from 'lit/directives/ref.js'
6
7
  import { styleMap } from 'lit/directives/style-map.js'
@@ -44,7 +45,7 @@ export class PktProgressbar extends PktElement implements IPktProgressbar {
44
45
  @property({ type: String, reflect: true }) ariaLabelledby: string | null = null
45
46
  @property({ type: String, reflect: true }) ariaValueText: string | null = null
46
47
  @property({ type: String }) ariaLive: TAriaLive = 'polite'
47
- @property({ type: String, reflect: true }) id: string = uuidish()
48
+ @property({ type: String }) id: string = uuidish()
48
49
  @property({ type: String }) role: TProgressbarRole = 'progressbar'
49
50
  @property({ type: String }) skin: TProgressbarSkin = 'dark-blue'
50
51
  @property({ type: String }) statusPlacement: TProgressbarStatusPlacement = 'following'
@@ -58,17 +59,29 @@ export class PktProgressbar extends PktElement implements IPktProgressbar {
58
59
  // State
59
60
  @state() private labelWidth = 0
60
61
  @state() private progressbarId: string = this.id
61
- @state() private computedAriaLabelledby: string | null = null
62
- @state() private computedAriaValueText = ''
62
+ @state() private resolvedRole: TProgressbarRole = 'progressbar'
63
63
 
64
64
  // Private refs
65
65
  private labelRef: Ref<HTMLSpanElement> = createRef()
66
66
  private progressBarRef: Ref<HTMLDivElement> = createRef()
67
67
 
68
- firstUpdated(changedProperties: Map<string | number | symbol, unknown>) {
69
- super.firstUpdated(changedProperties)
70
- this.setComputedValues()
71
- this.syncAttributes()
68
+ protected willUpdate(changedProperties: Map<string | number | symbol, unknown>) {
69
+ super.willUpdate(changedProperties)
70
+ if (this.hasAttribute('id')) {
71
+ this.progressbarId = this.getAttribute('id') || this.progressbarId
72
+ this.removeAttribute('id')
73
+ } else if (this.id) {
74
+ this.progressbarId = this.id
75
+ }
76
+ // Verdien må fanges FØR removeAttribute: den utløser attributeChangedCallback,
77
+ // som nuller propertyen.
78
+ const roleAttr = this.getAttribute('role')
79
+ if (roleAttr) {
80
+ this.resolvedRole = roleAttr as TProgressbarRole
81
+ this.removeAttribute('role')
82
+ } else if (this.role) {
83
+ this.resolvedRole = this.role
84
+ }
72
85
  }
73
86
 
74
87
  updated(changedProperties: Map<string | number | symbol, unknown>) {
@@ -77,30 +90,6 @@ export class PktProgressbar extends PktElement implements IPktProgressbar {
77
90
  if (changedProperties.has('valueCurrent') && this.labelRef.value) {
78
91
  this.labelWidth = this.labelRef.value.getBoundingClientRect().width || 0
79
92
  }
80
- if (changedProperties.has('id') && this.id) {
81
- this.progressBarId = this.id
82
- }
83
-
84
- if (
85
- changedProperties.has('statusType') ||
86
- changedProperties.has('id') ||
87
- changedProperties.has('ariaLabelledby')
88
- ) {
89
- this.progressbarId = this.id || uuidish()
90
- this.computedAriaLabelledby = this.ariaLabelledby || `${this.progressbarId}-title`
91
- }
92
- if (
93
- changedProperties.has('ariaValueText') ||
94
- changedProperties.has('valueCurrent') ||
95
- changedProperties.has('valueMax')
96
- ) {
97
- this.computedAriaValueText =
98
- this.statusType === 'fraction' && !this.ariaValueText
99
- ? `${this.valueCurrent} av ${this.valueMax - this.valueMin}`
100
- : this.ariaValueText || ''
101
- }
102
-
103
- this.syncAttributes()
104
93
  }
105
94
 
106
95
  render() {
@@ -114,6 +103,14 @@ export class PktProgressbar extends PktElement implements IPktProgressbar {
114
103
 
115
104
  const formattedTitle = `${this.valueCurrent} av ${totalSteps}`
116
105
 
106
+ const computedAriaValueText =
107
+ this.statusType === 'fraction' && !this.ariaValueText
108
+ ? `${this.valueCurrent} av ${this.valueMax - this.valueMin}`
109
+ : this.ariaValueText || ''
110
+ const computedAriaLabelledby = this.ariaLabel
111
+ ? undefined
112
+ : this.ariaLabelledby || `${this.progressbarId}-title`
113
+
117
114
  const barClasses = classMap({
118
115
  'pkt-progressbar__bar': true,
119
116
  [`pkt-progressbar__bar--${this.skin}`]: !!this.skin,
@@ -132,64 +129,46 @@ export class PktProgressbar extends PktElement implements IPktProgressbar {
132
129
  [`pkt-progressbar__status-placement--left`]: this.statusPlacement === 'left',
133
130
  })
134
131
 
135
- return html` <div
136
- class="pkt-progressbar__container"
137
- .ref=${this.progressBarRef}
138
- style=${styleMap({
139
- '--pkt-progress-label-width': `${this.labelWidth}px`,
140
- '--pkt-progress-width': `${currentPercentage}%`,
141
- })}
132
+ return html`<div
133
+ ${ref(this.progressBarRef)}
134
+ id=${this.progressbarId}
135
+ role=${this.resolvedRole}
136
+ aria-live=${ifDefined(this.ariaLive || undefined)}
137
+ aria-atomic="true"
138
+ aria-valuenow=${this.valueCurrent}
139
+ aria-valuemin=${this.valueMin}
140
+ aria-valuemax=${this.valueMax}
141
+ aria-valuetext=${ifDefined(computedAriaValueText || undefined)}
142
+ aria-label=${ifDefined(this.ariaLabel || undefined)}
143
+ aria-labelledby=${ifDefined(computedAriaLabelledby)}
144
+ class="pkt-progressbar"
142
145
  >
143
- ${this.title
144
- ? html`<p id=${`${this.progressBarId}-title`} class=${titleClasses}>${this.title}</p>`
145
- : nothing}
146
-
147
- <div class="pkt-progressbar__bar-wrapper">
148
- <div class=${barClasses}></div>
146
+ <div
147
+ class="pkt-progressbar__container"
148
+ style=${styleMap({
149
+ '--pkt-progress-label-width': `${this.labelWidth}px`,
150
+ '--pkt-progress-width': `${currentPercentage}%`,
151
+ })}
152
+ >
153
+ ${this.title
154
+ ? html`<p id=${`${this.progressbarId}-title`} class=${titleClasses}>${this.title}</p>`
155
+ : nothing}
156
+
157
+ <div class="pkt-progressbar__bar-wrapper">
158
+ <div class=${barClasses}></div>
159
+ </div>
160
+
161
+ ${hasStatus
162
+ ? html`<div class=${statusClasses}>
163
+ <span class=${placementClasses} ${ref(this.labelRef)}>
164
+ ${this.statusType === 'percentage' ? `${currentPercentage}%` : formattedTitle}
165
+ </span>
166
+ </div>`
167
+ : nothing}
149
168
  </div>
150
-
151
- ${hasStatus
152
- ? html`<div class=${statusClasses}>
153
- <span class=${placementClasses} ${ref(this.labelRef)}>
154
- ${this.statusType === 'percentage' ? `${currentPercentage}%` : formattedTitle}
155
- </span>
156
- </div>`
157
- : nothing}
158
169
  </div>`
159
170
  }
160
171
 
161
- // methods
162
- private setComputedValues() {
163
- this.progressbarId = this.id || uuidish()
164
- this.computedAriaLabelledby = this.ariaLabelledby || `${this.progressbarId}-title`
165
- this.computedAriaValueText =
166
- this.statusType === 'fraction' && !this.ariaValueText
167
- ? `${this.valueCurrent} av ${this.valueMax - this.valueMin}`
168
- : this.ariaValueText || ''
169
- }
170
-
171
- private syncAttributes() {
172
- this._handleAttribute('aria-live', this.ariaLive)
173
- this._handleAttribute('aria-valuenow', this.valueCurrent)
174
- this._handleAttribute('aria-valuemin', this.valueMin)
175
- this._handleAttribute('aria-valuemax', this.valueMax)
176
- this._handleAttribute('aria-valuetext', this.computedAriaValueText)
177
- this._handleAttribute('aria-label', this.ariaLabel)
178
- this._handleAttribute('role', this.role)
179
- this._handleAttribute('aria-atomic', 'true')
180
- this._handleAttribute('id', this.progressbarId)
181
- if (!this.ariaLabel) {
182
- this._handleAttribute('aria-labelledby', this.computedAriaLabelledby)
183
- }
184
- }
185
-
186
- private _handleAttribute(name: string, value: string | number | null) {
187
- if (value == null || value === '') {
188
- this.removeAttribute(name)
189
- } else {
190
- this.setAttribute(name, String(value))
191
- }
192
- }
193
172
  }
194
173
 
195
174
  export default PktProgressbar
@@ -105,7 +105,6 @@ export class PktRadioButton extends PktInputElement<Props> {
105
105
  id=${this.id + '-internal'}
106
106
  class=${inputCheckBoxClasses}
107
107
  type="radio"
108
- role="radio"
109
108
  ?disabled=${this.disabled}
110
109
  form=""
111
110
  name=${this.name + '-internal'}
@@ -1,4 +1,5 @@
1
1
  import { PktElement } from '@/base-elements/element'
2
+ import { uuidish } from 'shared-utils/utils'
2
3
  import { html, nothing, type PropertyValues } from 'lit'
3
4
  import { customElement, property, state } from 'lit/decorators.js'
4
5
  import { classMap } from 'lit/directives/class-map.js'
@@ -27,7 +28,7 @@ export class PktSearchInput extends PktElement<IPktSearchInput> implements IPktS
27
28
  @property({ type: String, attribute: 'input-size' }) inputSize: TPktInputSize = 'medium'
28
29
  @property({ type: Boolean, reflect: true }) disabled: boolean = false
29
30
  @property({ type: Boolean, reflect: true }) fullwidth: boolean = false
30
- @property({ type: String, reflect: true }) id: string = ''
31
+ @property({ type: String, reflect: true }) id: string = uuidish()
31
32
  @property({ type: String }) label: string | undefined
32
33
  @property({ type: String }) name: string | undefined
33
34
  /** @deprecated Bruk `strings={{ searchinput: { placeholder: '…' } }}` eller `setPktStrings()`. */
@@ -176,6 +177,7 @@ export class PktSearchInput extends PktElement<IPktSearchInput> implements IPktS
176
177
  name=${this.name || this.id}
177
178
  id=${this.id}
178
179
  placeholder=${this.placeholder || searchStrings.placeholder}
180
+ value=${this.value}
179
181
  .value=${this.value}
180
182
  ?disabled=${this.disabled}
181
183
  autocomplete="off"
@@ -82,7 +82,8 @@ describe('pkt-select', () => {
82
82
  expect(selectElement).toBeInTheDocument()
83
83
  expect(selectElement?.getAttribute('id')).toBe('my-select-input')
84
84
  expect(selectElement?.hasAttribute('disabled')).toBe(true)
85
- expect(selectElement?.getAttribute('value')).toBe('option2')
85
+ expect(selectElement?.hasAttribute('value')).toBe(false)
86
+ expect(select.value).toBe('option2')
86
87
  })
87
88
 
88
89
  test('handles options array property', async () => {
@@ -218,7 +218,6 @@ export class PktSelect extends PktOptionsInputElement<{}, TSelectOption> impleme
218
218
  ?disabled=${this.disabled}
219
219
  id=${this.id + '-input'}
220
220
  name=${(this.name || this.id) + '-input'}
221
- value=${this.value}
222
221
  @change=${(e: Event) => {
223
222
  this.touched = true
224
223
  this.value = (e.target as HTMLSelectElement).value
@@ -1,35 +0,0 @@
1
- const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-MkibfzHp.cjs"),i=require("./classutils-CbklAJDe.cjs"),a=require("./define-component-spec-DBNd2FJY.cjs");require("./icon-DBFTFd-J.cjs"),require("./button-CVMhQT3X.cjs");var o=[`off`,`polite`,`assertive`],s=[`info`,`success`,`warning`,`error`],c=[`medium`,`small`,`xsmall`],l=a.t({name:`pkt-alert`,react:`PktAlert`,"css-class":`pkt-alert`,"dark-mode":!0,isElement:!0,isPureReact:!0,events:{onClose:{reactOnly:!0,description:`React: Klikk-event for 'Lukk'-knappen`},close:{elementsOnly:!0,description:`Vue: Klikk-event for 'Lukk'-knappen`}},props:{title:{name:`Tittel`,description:`Tittelen som vises øverst i på meldingen`,type:`string`,category:`contents`},skin:{name:`Utseende`,description:`Hvordan type melding er dette?`,type:[...s],default:`info`,category:`ui`},date:{name:`Sist oppdatert`,description:`Dato som vises nederst i på meldingen`,type:`string`,category:`contents`},ariaLive:{name:`aria-live`,description:`Hvordan skal skjermleseren lese opp meldingen?`,type:[...o],default:`polite`,category:`accessibility`},size:{name:`Størrelse`,description:`Endrer størrelsen på ulike elementer i alerten.`,type:[...c],default:`medium`,category:`ui`},closeAlert:{name:`Vis 'Lukk'-knapp`,description:`Viser 'Lukk'-knappen`,type:`boolean`,default:!1,category:`ui`}},slots:{default:{description:`Innholdet i meldingen`}},deprecated:{compact:{name:`Kompakt (deprecated)`,description:"Bruk `size` i stedet; uten eksplisitt `size` gir compact størrelsen 'small'.",type:`boolean`,category:`ui`,default:!1}}}),u=class extends r.t{constructor(){super(),this.compact=l.deprecated.compact.default,this.title=``,this.skin=l.props.skin.default,this.ariaLive=l.props.ariaLive.default,this.ariaLiveAttr=null,this.closeAlert=l.props.closeAlert.default,this.date=null,this.role=`status`,this._isClosed=!1,this.close=e=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent(`close`,{detail:{origin:e},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`on-close`,{detail:{origin:e},bubbles:!0,composed:!0}))},this._isClosed=!1}connectedCallback(){super.connectedCallback(),this.ariaLiveAttr=this.getAttribute(`aria-live`)||this.ariaLive}attributeChangedCallback(e,t,n){e===`ariaLive`&&(this.ariaLiveAttr=n),super.attributeChangedCallback(e,t,n)}updated(e){super.updated(e),e.has(`ariaLive`)&&(this.ariaLiveAttr=this.ariaLive),e.has(`_isClosed`)&&i.t(this,`pkt-hide`,this._isClosed)}render(){let i=this.size??(this.compact?`small`:`medium`),a={"pkt-alert":!0,[`pkt-alert--${i}`]:!0,[`pkt-alert--${this.skin}`]:!0,"pkt-hide":this._isClosed},o={"pkt-alert__grid":!0,"pkt-alert__noTitle":!this.title,"pkt-alert__noDate":!this.date};return e._`
2
- <div class=${t.t(a)} aria-live=${this.ariaLiveAttr}>
3
- <div class=${t.t(o)}>
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._`
11
- <div class="pkt-alert__close">
12
- <pkt-button
13
- tabindex="0"
14
- aria-label="close"
15
- size=${i}
16
- type="button"
17
- skin="tertiary"
18
- iconName="close"
19
- variant="icon-only"
20
- @click=${this.close}
21
- >
22
- <span class="sr-only">${this.pktStrings.get(`generic`).close}</span>
23
- </pkt-button>
24
- </div>
25
- `:e.h}
26
- ${this.title?e._`<div class="pkt-alert__title">${this.title}</div>`:e.h}
27
-
28
- <div class="pkt-alert__text">${r.n(this)}</div>
29
-
30
- ${this.date?e._`<div class="pkt-alert__date">
31
- ${n.t(this.pktStrings.get(`alert`).lastUpdated,{date:this.date})}
32
- </div>`:e.h}
33
- </div>
34
- </div>
35
- `}};e.n([e.u({type:Boolean,reflect:!1})],u.prototype,`compact`,void 0),e.n([e.u({type:String,reflect:!0})],u.prototype,`title`,void 0),e.n([e.u({type:String,reflect:!0})],u.prototype,`skin`,void 0),e.n([e.u({type:String})],u.prototype,`ariaLive`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`aria-live`})],u.prototype,`ariaLiveAttr`,void 0),e.n([e.u({type:Boolean,reflect:!0})],u.prototype,`closeAlert`,void 0),e.n([e.u({type:String,reflect:!0})],u.prototype,`date`,void 0),e.n([e.u({type:String,reflect:!0})],u.prototype,`role`,void 0),e.n([e.u({type:String,attribute:`size`})],u.prototype,`size`,void 0),e.n([e.l()],u.prototype,`_isClosed`,void 0);try{e.d(`pkt-alert`)(u)}catch{console.warn(`Forsøker å definere <pkt-alert>, men den er allerede definert`)}var d=u;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return d}});
@@ -1,30 +0,0 @@
1
- const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./element-with-slot-MkibfzHp.cjs");require("./icon-DBFTFd-J.cjs");const r=require("./if-defined-BeVQnl3C.cjs");var i=`https://punkt-cdn.oslo.kommune.no/latest/animations/`;typeof window<`u`&&(window.pktAnimationPath=window.pktAnimationPath||i);var a=class a extends n.t{constructor(...e){super(...e),this.iconName=`user`,this.secondIconName=`user`,this.mode=`light`,this.size=`medium`,this.fullWidth=!1,this.fullWidthOnMobile=!1,this.skin=`primary`,this.variant=`label-only`,this.state=`normal`,this.type=`button`,this.form=void 0,this.isLoading=!1,this.disabled=!1,this.loadingAnimationPath=typeof window<`u`?window.pktAnimationPath:i,this.relocatedAria={}}connectedCallback(){super.connectedCallback(),this.addEventListener(`click`,e=>{(this.disabled||this.hasAttribute(`disabled`)||this.isLoading)&&(e.preventDefault(),e.stopImmediatePropagation())},!0),this.addEventListener(`keydown`,e=>{(this.disabled||this.hasAttribute(`disabled`)||this.isLoading)&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopImmediatePropagation())},!0)}attributeChangedCallback(e,t,n){super.attributeChangedCallback(e,t,n),e===`disabled`&&n===`false`&&(this.disabled=!1),(e===`isloading`||e===`isLoading`)&&n===`false`&&(this.isLoading=!1)}static{this.relocatedAriaAttributes=[`aria-haspopup`,`aria-expanded`,`aria-controls`]}willUpdate(e){super.willUpdate(e);let t=!1,n={...this.relocatedAria};for(let e of a.relocatedAriaAttributes){let r=this.getAttribute(e);r!==null&&(n[e]=r,this.removeAttribute(e),t=!0)}t&&(this.relocatedAria=n)}firstUpdated(e){super.firstUpdated(e),this.disabled===`false`&&(this.disabled=!1),this.isLoading===`false`&&(this.isLoading=!1)}render(){let i=this.form??this.getAttribute(`form`)??void 0,a={"pkt-btn":!0,[`pkt-btn--${this.size}`]:!!this.size,[`pkt-btn--${this.skin}`]:!!this.skin,[`pkt-btn--${this.variant}`]:!!this.variant,[`pkt-btn--${this.color}`]:!!this.color,[`pkt-btn--${this.state}`]:!!this.state,"pkt-btn--full":!!this.fullWidth,"pkt-btn--full-small":!!this.fullWidthOnMobile,"pkt-btn--disabled":!!this.disabled,"pkt-btn--isLoading":!!this.isLoading};return e._`
2
- <button
3
- class=${t.t(a)}
4
- type=${this.type}
5
- ?disabled=${!!this.disabled}
6
- aria-busy=${r.t(this.isLoading?`true`:void 0)}
7
- aria-disabled=${r.t(this.disabled||this.isLoading?`true`:void 0)}
8
- aria-haspopup=${r.t(this.relocatedAria[`aria-haspopup`])}
9
- aria-expanded=${r.t(this.relocatedAria[`aria-expanded`])}
10
- aria-controls=${r.t(this.relocatedAria[`aria-controls`])}
11
- form=${r.t(i)}
12
- >
13
- ${this.isLoading?e._`<pkt-icon
14
- class="pkt-btn__icon pkt-btn__spinner"
15
- name="spinner-blue"
16
- path=${r.t(this.loadingAnimationPath)}
17
- ></pkt-icon>`:e.h}
18
- ${this.variant===`label-only`?e.h:e._`<pkt-icon
19
- class="pkt-btn__icon pkt-icon"
20
- name=${this.iconName}
21
- path=${r.t(this.iconPath)}
22
- ></pkt-icon>`}
23
- <span class="pkt-btn__text">${n.n(this)}</span>
24
- ${this.variant===`icons-right-and-left`?e._`<pkt-icon
25
- class="pkt-btn__icon"
26
- name=${this.secondIconName}
27
- path=${r.t(this.secondIconPath)}
28
- ></pkt-icon>`:e.h}
29
- </button>
30
- `}};e.n([e.u({type:String})],a.prototype,`iconName`,void 0),e.n([e.u({type:String})],a.prototype,`secondIconName`,void 0),e.n([e.u({type:String})],a.prototype,`iconPath`,void 0),e.n([e.u({type:String})],a.prototype,`secondIconPath`,void 0),e.n([e.u({type:String})],a.prototype,`mode`,void 0),e.n([e.u({type:String})],a.prototype,`size`,void 0),e.n([e.u({type:Boolean,attribute:`full-width`})],a.prototype,`fullWidth`,void 0),e.n([e.u({type:Boolean,attribute:`full-width-on-mobile`})],a.prototype,`fullWidthOnMobile`,void 0),e.n([e.u({type:String})],a.prototype,`color`,void 0),e.n([e.u({type:String})],a.prototype,`skin`,void 0),e.n([e.u({type:String})],a.prototype,`variant`,void 0),e.n([e.u({type:String,reflect:!0})],a.prototype,`state`,void 0),e.n([e.u({type:String,reflect:!0})],a.prototype,`type`,void 0),e.n([e.u({type:String})],a.prototype,`form`,void 0),e.n([e.u({type:Boolean,reflect:!0})],a.prototype,`isLoading`,void 0),e.n([e.u({type:Boolean,reflect:!0})],a.prototype,`disabled`,void 0),e.n([e.u({type:String})],a.prototype,`loadingAnimationPath`,void 0),e.n([e.l()],a.prototype,`relocatedAria`,void 0);try{e.d(`pkt-button`)(a)}catch{console.warn(`Forsøker å definere <pkt-button>, men den er allerede definert`)}var o=a;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
@@ -1,87 +0,0 @@
1
- const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./element-with-slot-MkibfzHp.cjs");require("./icon-DBFTFd-J.cjs");const r=require("./if-defined-BeVQnl3C.cjs");require("./tag-Bp9gJnYh.cjs"),require("./heading-BAoIzzJO.cjs");var i={name:`pkt-card`,react:`PktCard`,"css-class":`pkt-card`,isElement:!0,isPureReact:!0,"dark-mode":!0,props:{heading:{type:`string`,name:`Overskrift`,description:`Tittel på card`,category:`contents`},headingLevel:{type:[1,2,3,4,5,6],name:`Overskriftsnivå`,description:`Nivået på headingen. Brukes for tilgjengelighet.`,default:3,category:`accessibility`},subheading:{type:`string`,name:`Undertittel`,description:`Undertittel på card`,category:`contents`},layout:{type:[`vertical`,`horizontal`],name:`Layout`,description:`Horisontal eller vertikal layout. Ved horisontal layout vil bildet være plassert til venstre for teksten på desktop, og over teksten på mobil.`,default:`vertical`,category:`ui`},skin:{type:[`outlined`,`outlined-beige`,`gray`,`blue`,`beige`,`green`],name:`Utseende`,description:`Fargen på card. Velg mellom outlined, outlined-beige, gray, blue, beige og green. Ved padding=none er det ikke mulighet for outlined-skin. Card med kombinasjonen av propsene padding=none + layout=vertical vil alltid være transparante.`,default:`outlined`,category:`ui`},padding:{type:[`none`,`default`],name:`Padding`,description:`Padding rundt card. Ved "none" strekker innholdet i card seg ut til kantene, og dette er derfor ikke mulig å kombinere med outlined skin.`,default:`default`,category:`ui`},metaLead:{type:`string`,name:`Forfatter eller annen metadata`,description:`Undertekst med fet skriftvekt`,default:!1,category:`contents`},metaTrail:{type:`string`,name:`Dato eller annen metadata`,description:`Undertekst med normal skriftvekt`,default:!1,category:`contents`},tagPosition:{type:[`top`,`bottom`],name:`Tagplassering`,description:`Plassering av tags i card`,default:`top`,category:`ui`},clickCardLink:{type:`string`,name:`Lenke for klikkbart card`,description:`Href sendes inn som streng for å gjøre card klikkbart. Ved bruk MÅ heading sendes inn da denne vil brukes som lenketekst i klikkbart card.`,category:`contents`},openLinkInNewTab:{type:`boolean`,name:`Åpne i ny fane`,description:`Velg denne dersom du ønsker at lenken i card skal åpnes i ny fane.`,default:!1,category:`tech`},borderOnHover:{type:`boolean`,name:`Hover border for klikkbart card`,description:`Vi anbefaler hoverborder på klikkbart card. Kan slås av ved behov.`,default:!0,category:`ui`},image:{type:`object`,name:`Bilde`,description:`Bildet på card. Tar inn et objekt av typen {src: string, alt: string}.`,properties:{src:{type:`string`,description:`Stien til bildet`,required:!0},alt:{type:`string`,description:`Tekst til skjermleser. Skal kun sendes inn for bilder som ikke er dekorative`,required:!1}},category:`contents`},imageShape:{type:[`square`,`round`],name:`Bildeform`,description:`Valg for om bildet skal ha rektangulær eller rund form.`,default:`square`,category:`contents`},tags:{type:`array`,description:`Liste av tags på card. Tar inn et array med objekter med følgende stringproperties: skin, iconName, ariaLabel, text`,name:`Tags`,items:{type:`object`,name:`Tag`,properties:{skin:{type:[`blue`,`green`,`red`,`yellow`],description:`Farge på tag`},iconName:{type:`icon`,description:`Id på ikonet du ønsker å bruke til tag`},ariaLabel:{type:`string`,description:`Tekst for aria-label`},text:{type:`string`,description:`Tekst på tag`,required:!0}}},category:`contents`},ariaLabel:{type:`string`,name:`Aria-label for card`,description:`Tekst til skjermleser for aria-label på card. Settes automatisk til headingen, eller subheadingen der heading ikke eksisterer. Ved bruk av klikkbart card må heading alltid sendes inn da denne brukes som lenketekst.`,category:`accessibility`}},slots:{default:{description:`Innholdet i card`}}},a=class extends n.t{constructor(...e){super(...e),this.ariaLabel=``,this.metaLead=null,this.borderOnHover=!0,this.clickCardLink=null,this.metaTrail=null,this.layout=i.props.layout.default,this.heading=``,this.headinglevel=3,this.image={src:``,alt:``},this.imageShape=`square`,this.openLinkInNewTab=!1,this.padding=i.props.padding.default,this.skin=i.props.skin.default,this.subheading=``,this.tagPosition=`top`,this.tags=[]}connectedCallback(){super.connectedCallback()}render(){let n={"pkt-card":!0,[`pkt-card--${this.skin}`]:this.skin,[`pkt-card--${this.layout}`]:this.layout,[`pkt-card--padding-${this.padding}`]:this.padding,"pkt-card--border-on-hover":this.borderOnHover},i=this.ariaLabel?.trim()||(this.heading?`${this.heading} lenkekort`:`lenkekort`),a=this.ariaLabel?.trim()||(this.heading?this.heading:`kort`);return e._`
2
- <article
3
- class=${t.t(n)}
4
- aria-label=${r.t(this.clickCardLink?i:a)}
5
- >
6
- ${this.renderImage()}
7
- <div class="pkt-card__wrapper">
8
- ${this.tagPosition===`top`?this.renderTags():e.h}
9
- ${this.renderHeader()}
10
- ${this.renderSlot()}
11
- ${this.tagPosition===`bottom`?this.renderTags():e.h}
12
- ${this.renderMetadata()}
13
- </div>
14
- </article>
15
- `}renderImage(){let n={"pkt-card__image":!0,[`pkt-card__image-${this.imageShape}`]:this.imageShape};return e._`
16
- ${this.image.src&&e._`
17
- <div class=${t.t(n)}>
18
- <img src=${this.image.src} alt=${this.image.alt||``} />
19
- </div>
20
- `}
21
- `}renderHeading(){return e._`
22
- ${this.heading&&!this.clickCardLink?e._`
23
- <pkt-heading
24
- class="pkt-card__heading"
25
- .level=${this.headinglevel||3}
26
- size="medium"
27
- nospacing
28
- weight="regular"
29
- >
30
- ${this.heading}
31
- </pkt-heading>
32
- `:e.h}
33
- `}renderLinkHeading(){return e._`
34
- ${this.clickCardLink?e._`
35
- <pkt-heading
36
- class="pkt-card__link-heading pkt-card__heading"
37
- .level=${this.headinglevel||3}
38
- size="medium"
39
- weight="regular"
40
- nospacing
41
- >
42
- <a
43
- class="pkt-card__link"
44
- href=${this.clickCardLink}
45
- target=${this.openLinkInNewTab?`_blank`:`_self`}
46
- >${this.heading}</a
47
- >
48
- </pkt-heading>
49
- `:e.h}
50
- `}renderSubheading(){return e._`
51
- ${this.subheading?e._` <p class="pkt-card__subheading ">${this.subheading}</p> `:e.h}
52
- `}renderHeader(){let t=!!this.heading||!!this.subheading;return e._`
53
- ${t?e._`
54
- <header class="pkt-card__header">
55
- ${this.renderHeading()}
56
- ${this.renderLinkHeading()}
57
- ${this.renderSubheading()}
58
- </header>
59
- `:e.h}
60
- `}renderTags(){let n={"pkt-card__tags":!0,[`pkt-card__tags-${this.tagPosition}`]:this.tagPosition};return e._`
61
- ${this.tags.length>0?e._`
62
- <div
63
- class=${t.t(n)}
64
- role="list"
65
- aria-label=${this.tags.length>1?`merkelapper`:`merkelapp`}
66
- >
67
- ${this.tags.map(t=>e._`
68
- <pkt-tag
69
- role="listitem"
70
- textStyle="normal-text"
71
- size="medium"
72
- skin=${r.t(t.skin)}
73
- iconName=${r.t(t.iconName)}
74
- >
75
- <span>${t.text}</span>
76
- </pkt-tag>
77
- `)}
78
- </div>
79
- `:e.h}
80
- `}renderSlot(){return e._`<section class="pkt-card__content">${n.n(this)}</section>`}renderMetadata(){return e._`
81
- ${this.metaLead||this.metaTrail?e._`
82
- <footer class="pkt-card__metadata">
83
- ${this.metaLead?e._`<span class="pkt-card__metadata-lead">${this.metaLead}</span>`:e.h}
84
- ${this.metaTrail?e._`<span class="pkt-card__metadata-trail">${this.metaTrail}</span>`:e.h}
85
- </footer>
86
- `:e.h}
87
- `}};e.n([e.u({type:String})],a.prototype,`ariaLabel`,void 0),e.n([e.u({type:String})],a.prototype,`metaLead`,void 0),e.n([e.u({type:Boolean})],a.prototype,`borderOnHover`,void 0),e.n([e.u({type:String,reflect:!0})],a.prototype,`clickCardLink`,void 0),e.n([e.u({type:String})],a.prototype,`metaTrail`,void 0),e.n([e.u({type:String})],a.prototype,`layout`,void 0),e.n([e.u({type:String})],a.prototype,`heading`,void 0),e.n([e.u({type:Number})],a.prototype,`headinglevel`,void 0),e.n([e.u({type:Object})],a.prototype,`image`,void 0),e.n([e.u({type:String})],a.prototype,`imageShape`,void 0),e.n([e.u({type:Boolean})],a.prototype,`openLinkInNewTab`,void 0),e.n([e.u({type:String})],a.prototype,`padding`,void 0),e.n([e.u({type:String,converter:{fromAttribute:e=>{let t=i.props.skin.type;return e&&t.includes(e)?e:(e&&!t.includes(e)&&console.warn(`Invalid skin value "${e}". Using default skin "${i.props.skin.default}".`),i.props.skin.default)},toAttribute:e=>e}})],a.prototype,`skin`,void 0),e.n([e.u({type:String})],a.prototype,`subheading`,void 0),e.n([e.u({type:String})],a.prototype,`tagPosition`,void 0),e.n([e.u({type:Array})],a.prototype,`tags`,void 0);try{e.d(`pkt-card`)(a)}catch{console.warn(`Forsøker å definere <pkt-card>, men den er allerede definert`)}var o=a;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
@@ -1,112 +0,0 @@
1
- import { _ as e, d as t, f as n, g as r, h as i, l as a, m as o, n as s, p as c, t as l, u } from "./element-e2MAMNEP.js";
2
- import { t as d } from "./class-map-BL_YL_Ed.js";
3
- import "./icon-jEFbKTB_.js";
4
- import { n as f, t as p } from "./ref-lE1mGUOL.js";
5
- import { n as m } from "./utils-BwF4QSrq.js";
6
- //#region ../../node_modules/lit-html/directives/style-map.js
7
- var h = "important", g = " !" + h, _ = n(class extends c {
8
- constructor(e) {
9
- if (super(e), e.type !== o.ATTRIBUTE || e.name !== "style" || e.strings?.length > 2) throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.");
10
- }
11
- render(e) {
12
- return Object.keys(e).reduce((t, n) => {
13
- let r = e[n];
14
- return r == null ? t : t + `${n = n.includes("-") ? n : n.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, "-$&").toLowerCase()}:${r};`;
15
- }, "");
16
- }
17
- update(e, [t]) {
18
- let { style: n } = e.element;
19
- if (this.ft === void 0) return this.ft = new Set(Object.keys(t)), this.render(t);
20
- for (let e of this.ft) t[e] ?? (this.ft.delete(e), e.includes("-") ? n.removeProperty(e) : n[e] = null);
21
- for (let e in t) {
22
- let r = t[e];
23
- if (r != null) {
24
- this.ft.add(e);
25
- let t = typeof r == "string" && r.endsWith(g);
26
- e.includes("-") || t ? n.setProperty(e, t ? r.slice(0, -11) : r, t ? h : "") : n[e] = r;
27
- }
28
- }
29
- return r;
30
- }
31
- }), v = class extends l {
32
- constructor() {
33
- super(), this.ariaLabel = null, this.ariaLabelledby = null, this.ariaValueText = null, this.ariaLive = "polite", this.id = m(), this.role = "progressbar", this.skin = "dark-blue", this.statusPlacement = "following", this.statusType = "none", this.title = "", this.titlePosition = "left", this.valueCurrent = 0, this.valueMax = 100, this.valueMin = 0, this.labelWidth = 0, this.progressbarId = this.id, this.computedAriaLabelledby = null, this.computedAriaValueText = "", this.labelRef = p(), this.progressBarRef = p();
34
- }
35
- firstUpdated(e) {
36
- super.firstUpdated(e), this.setComputedValues(), this.syncAttributes();
37
- }
38
- updated(e) {
39
- super.updated(e), e.has("valueCurrent") && this.labelRef.value && (this.labelWidth = this.labelRef.value.getBoundingClientRect().width || 0), e.has("id") && this.id && (this.progressBarId = this.id), (e.has("statusType") || e.has("id") || e.has("ariaLabelledby")) && (this.progressbarId = this.id || m(), this.computedAriaLabelledby = this.ariaLabelledby || `${this.progressbarId}-title`), (e.has("ariaValueText") || e.has("valueCurrent") || e.has("valueMax")) && (this.computedAriaValueText = this.statusType === "fraction" && !this.ariaValueText ? `${this.valueCurrent} av ${this.valueMax - this.valueMin}` : this.ariaValueText || ""), this.syncAttributes();
40
- }
41
- render() {
42
- let t = this.statusType !== "none", n = this.valueMax - this.valueMin, r = this.valueCurrent / n * 100, a = this.statusType === "fraction" ? Math.round(r) : Math.round((this.valueCurrent - this.valueMin) / (this.valueMax - this.valueMin) * 100), o = `${this.valueCurrent} av ${n}`, s = d({
43
- "pkt-progressbar__bar": !0,
44
- [`pkt-progressbar__bar--${this.skin}`]: !!this.skin
45
- }), c = d({
46
- "pkt-progressbar__title": !0,
47
- "pkt-progressbar__title-center": this.titlePosition === "center"
48
- }), l = d({
49
- "pkt-progressbar__status": !0,
50
- "pkt-progressbar__status--center": this.statusPlacement === "center"
51
- }), u = d({
52
- "pkt-progressbar__status-placement--following": this.statusPlacement === "following",
53
- "pkt-progressbar__status-placement--center": this.statusPlacement === "center",
54
- "pkt-progressbar__status-placement--left": this.statusPlacement === "left"
55
- });
56
- return e` <div
57
- class="pkt-progressbar__container"
58
- .ref=${this.progressBarRef}
59
- style=${_({
60
- "--pkt-progress-label-width": `${this.labelWidth}px`,
61
- "--pkt-progress-width": `${a}%`
62
- })}
63
- >
64
- ${this.title ? e`<p id=${`${this.progressBarId}-title`} class=${c}>${this.title}</p>` : i}
65
-
66
- <div class="pkt-progressbar__bar-wrapper">
67
- <div class=${s}></div>
68
- </div>
69
-
70
- ${t ? e`<div class=${l}>
71
- <span class=${u} ${f(this.labelRef)}>
72
- ${this.statusType === "percentage" ? `${a}%` : o}
73
- </span>
74
- </div>` : i}
75
- </div>`;
76
- }
77
- setComputedValues() {
78
- this.progressbarId = this.id || m(), this.computedAriaLabelledby = this.ariaLabelledby || `${this.progressbarId}-title`, this.computedAriaValueText = this.statusType === "fraction" && !this.ariaValueText ? `${this.valueCurrent} av ${this.valueMax - this.valueMin}` : this.ariaValueText || "";
79
- }
80
- syncAttributes() {
81
- this._handleAttribute("aria-live", this.ariaLive), this._handleAttribute("aria-valuenow", this.valueCurrent), this._handleAttribute("aria-valuemin", this.valueMin), this._handleAttribute("aria-valuemax", this.valueMax), this._handleAttribute("aria-valuetext", this.computedAriaValueText), this._handleAttribute("aria-label", this.ariaLabel), this._handleAttribute("role", this.role), this._handleAttribute("aria-atomic", "true"), this._handleAttribute("id", this.progressbarId), this.ariaLabel || this._handleAttribute("aria-labelledby", this.computedAriaLabelledby);
82
- }
83
- _handleAttribute(e, t) {
84
- t == null || t === "" ? this.removeAttribute(e) : this.setAttribute(e, String(t));
85
- }
86
- };
87
- s([u({ type: String })], v.prototype, "ariaLabel", void 0), s([u({
88
- type: String,
89
- reflect: !0
90
- })], v.prototype, "ariaLabelledby", void 0), s([u({
91
- type: String,
92
- reflect: !0
93
- })], v.prototype, "ariaValueText", void 0), s([u({ type: String })], v.prototype, "ariaLive", void 0), s([u({
94
- type: String,
95
- reflect: !0
96
- })], v.prototype, "id", void 0), s([u({ type: String })], v.prototype, "role", void 0), s([u({ type: String })], v.prototype, "skin", void 0), s([u({ type: String })], v.prototype, "statusPlacement", void 0), s([u({ type: String })], v.prototype, "statusType", void 0), s([u({
97
- type: String,
98
- reflect: !0
99
- })], v.prototype, "title", void 0), s([u({ type: String })], v.prototype, "titlePosition", void 0), s([u({
100
- type: Number,
101
- reflect: !0
102
- })], v.prototype, "valueCurrent", void 0), s([u({ type: Number })], v.prototype, "valueMax", void 0), s([u({ type: Number })], v.prototype, "valueMin", void 0), s([a()], v.prototype, "labelWidth", void 0), s([a()], v.prototype, "progressbarId", void 0), s([a()], v.prototype, "computedAriaLabelledby", void 0), s([a()], v.prototype, "computedAriaValueText", void 0);
103
- try {
104
- t("pkt-progressbar")(v);
105
- } catch {
106
- console.warn("Forsøker å definere <pkt-progressbar>, men den er allerede definert");
107
- }
108
- //#endregion
109
- //#region src/components/progressbar/index.ts
110
- var y = v;
111
- //#endregion
112
- export { v as n, y as t };
@@ -1,17 +0,0 @@
1
- const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs");require("./icon-DBFTFd-J.cjs");const n=require("./ref-BkV4Cd8U.cjs"),r=require("./utils-63cRpWut.cjs");var i=`important`,a=` !`+i,o=e.f(class extends e.p{constructor(t){if(super(t),t.type!==e.m.ATTRIBUTE||t.name!==`style`||t.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce((t,n)=>{let r=e[n];return r==null?t:t+`${n=n.includes(`-`)?n:n.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,`-$&`).toLowerCase()}:${r};`},``)}update(t,[n]){let{style:r}=t.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(n)),this.render(n);for(let e of this.ft)n[e]??(this.ft.delete(e),e.includes(`-`)?r.removeProperty(e):r[e]=null);for(let e in n){let t=n[e];if(t!=null){this.ft.add(e);let n=typeof t==`string`&&t.endsWith(a);e.includes(`-`)||n?r.setProperty(e,n?t.slice(0,-11):t,n?i:``):r[e]=t}}return e.g}}),s=class extends e.t{constructor(){super(),this.ariaLabel=null,this.ariaLabelledby=null,this.ariaValueText=null,this.ariaLive=`polite`,this.id=r.n(),this.role=`progressbar`,this.skin=`dark-blue`,this.statusPlacement=`following`,this.statusType=`none`,this.title=``,this.titlePosition=`left`,this.valueCurrent=0,this.valueMax=100,this.valueMin=0,this.labelWidth=0,this.progressbarId=this.id,this.computedAriaLabelledby=null,this.computedAriaValueText=``,this.labelRef=n.t(),this.progressBarRef=n.t()}firstUpdated(e){super.firstUpdated(e),this.setComputedValues(),this.syncAttributes()}updated(e){super.updated(e),e.has(`valueCurrent`)&&this.labelRef.value&&(this.labelWidth=this.labelRef.value.getBoundingClientRect().width||0),e.has(`id`)&&this.id&&(this.progressBarId=this.id),(e.has(`statusType`)||e.has(`id`)||e.has(`ariaLabelledby`))&&(this.progressbarId=this.id||r.n(),this.computedAriaLabelledby=this.ariaLabelledby||`${this.progressbarId}-title`),(e.has(`ariaValueText`)||e.has(`valueCurrent`)||e.has(`valueMax`))&&(this.computedAriaValueText=this.statusType===`fraction`&&!this.ariaValueText?`${this.valueCurrent} av ${this.valueMax-this.valueMin}`:this.ariaValueText||``),this.syncAttributes()}render(){let r=this.statusType!==`none`,i=this.valueMax-this.valueMin,a=this.valueCurrent/i*100,s=this.statusType===`fraction`?Math.round(a):Math.round((this.valueCurrent-this.valueMin)/(this.valueMax-this.valueMin)*100),c=`${this.valueCurrent} av ${i}`,l=t.t({"pkt-progressbar__bar":!0,[`pkt-progressbar__bar--${this.skin}`]:!!this.skin}),u=t.t({"pkt-progressbar__title":!0,"pkt-progressbar__title-center":this.titlePosition===`center`}),d=t.t({"pkt-progressbar__status":!0,"pkt-progressbar__status--center":this.statusPlacement===`center`}),f=t.t({"pkt-progressbar__status-placement--following":this.statusPlacement===`following`,"pkt-progressbar__status-placement--center":this.statusPlacement===`center`,"pkt-progressbar__status-placement--left":this.statusPlacement===`left`});return e._` <div
2
- class="pkt-progressbar__container"
3
- .ref=${this.progressBarRef}
4
- style=${o({"--pkt-progress-label-width":`${this.labelWidth}px`,"--pkt-progress-width":`${s}%`})}
5
- >
6
- ${this.title?e._`<p id=${`${this.progressBarId}-title`} class=${u}>${this.title}</p>`:e.h}
7
-
8
- <div class="pkt-progressbar__bar-wrapper">
9
- <div class=${l}></div>
10
- </div>
11
-
12
- ${r?e._`<div class=${d}>
13
- <span class=${f} ${n.n(this.labelRef)}>
14
- ${this.statusType===`percentage`?`${s}%`:c}
15
- </span>
16
- </div>`:e.h}
17
- </div>`}setComputedValues(){this.progressbarId=this.id||r.n(),this.computedAriaLabelledby=this.ariaLabelledby||`${this.progressbarId}-title`,this.computedAriaValueText=this.statusType===`fraction`&&!this.ariaValueText?`${this.valueCurrent} av ${this.valueMax-this.valueMin}`:this.ariaValueText||``}syncAttributes(){this._handleAttribute(`aria-live`,this.ariaLive),this._handleAttribute(`aria-valuenow`,this.valueCurrent),this._handleAttribute(`aria-valuemin`,this.valueMin),this._handleAttribute(`aria-valuemax`,this.valueMax),this._handleAttribute(`aria-valuetext`,this.computedAriaValueText),this._handleAttribute(`aria-label`,this.ariaLabel),this._handleAttribute(`role`,this.role),this._handleAttribute(`aria-atomic`,`true`),this._handleAttribute(`id`,this.progressbarId),this.ariaLabel||this._handleAttribute(`aria-labelledby`,this.computedAriaLabelledby)}_handleAttribute(e,t){t==null||t===``?this.removeAttribute(e):this.setAttribute(e,String(t))}};e.n([e.u({type:String})],s.prototype,`ariaLabel`,void 0),e.n([e.u({type:String,reflect:!0})],s.prototype,`ariaLabelledby`,void 0),e.n([e.u({type:String,reflect:!0})],s.prototype,`ariaValueText`,void 0),e.n([e.u({type:String})],s.prototype,`ariaLive`,void 0),e.n([e.u({type:String,reflect:!0})],s.prototype,`id`,void 0),e.n([e.u({type:String})],s.prototype,`role`,void 0),e.n([e.u({type:String})],s.prototype,`skin`,void 0),e.n([e.u({type:String})],s.prototype,`statusPlacement`,void 0),e.n([e.u({type:String})],s.prototype,`statusType`,void 0),e.n([e.u({type:String,reflect:!0})],s.prototype,`title`,void 0),e.n([e.u({type:String})],s.prototype,`titlePosition`,void 0),e.n([e.u({type:Number,reflect:!0})],s.prototype,`valueCurrent`,void 0),e.n([e.u({type:Number})],s.prototype,`valueMax`,void 0),e.n([e.u({type:Number})],s.prototype,`valueMin`,void 0),e.n([e.l()],s.prototype,`labelWidth`,void 0),e.n([e.l()],s.prototype,`progressbarId`,void 0),e.n([e.l()],s.prototype,`computedAriaLabelledby`,void 0),e.n([e.l()],s.prototype,`computedAriaValueText`,void 0);try{e.d(`pkt-progressbar`)(s)}catch{console.warn(`Forsøker å definere <pkt-progressbar>, men den er allerede definert`)}var c=s;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}});