@oslokommune/punkt-elements 19.5.1 → 19.6.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 (77) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/base-elements/checkable-native-parity.test.d.ts +0 -0
  3. package/dist/base-elements/form-disabled.test.d.ts +0 -0
  4. package/dist/base-elements/input-element.d.ts +12 -3
  5. package/dist/checkbox-D69leWDh.cjs +40 -0
  6. package/dist/{checkbox-DKeErDb5.js → checkbox-Tq8ESzwH.js} +14 -11
  7. package/dist/{combobox-BKnHg_-E.js → combobox-CWzWHBaw.js} +14 -14
  8. package/dist/{combobox-C7FUvv5T.cjs → combobox-FCguoyDH.cjs} +6 -6
  9. package/dist/components/checkbox/checkbox.d.ts +2 -1
  10. package/dist/components/input-wrapper/input-wrapper.d.ts +4 -2
  11. package/dist/components/radiobutton/radiobutton.d.ts +2 -0
  12. package/dist/{datepicker-COFEJpB4.js → datepicker-Bs7Z3EFn.js} +6 -6
  13. package/dist/{datepicker-CeUpoQuG.cjs → datepicker-CWHYYj-H.cjs} +5 -5
  14. package/dist/docs/components/radio-checkbox-sizes.d.ts +10 -0
  15. package/dist/{fileupload-CUPl41uN.js → fileupload-BQFJx1ok.js} +1 -1
  16. package/dist/{fileupload-CaZGBvZr.cjs → fileupload-CMIFZWJ5.cjs} +1 -1
  17. package/dist/{header-CgP3-6-b.cjs → header-C4Uojzoy.cjs} +1 -1
  18. package/dist/{header-Cq6INZmI.js → header-Cc1Cy0U3.js} +1 -1
  19. package/dist/input-element-CSfDGslx.cjs +1 -0
  20. package/dist/{input-element-5hsxasU3.js → input-element-lLzfwdim.js} +198 -173
  21. package/dist/{input-wrapper-DACDx6Ie.js → input-wrapper-BoTugCvh.js} +33 -23
  22. package/dist/input-wrapper-J3mEKhvR.cjs +59 -0
  23. package/dist/pkt-checkbox.cjs +1 -1
  24. package/dist/pkt-checkbox.js +1 -1
  25. package/dist/pkt-combobox.cjs +1 -1
  26. package/dist/pkt-combobox.js +1 -1
  27. package/dist/pkt-datepicker.cjs +1 -1
  28. package/dist/pkt-datepicker.js +1 -1
  29. package/dist/pkt-fileupload.cjs +1 -1
  30. package/dist/pkt-fileupload.js +1 -1
  31. package/dist/pkt-header.cjs +1 -1
  32. package/dist/pkt-header.js +1 -1
  33. package/dist/pkt-index.cjs +1 -1
  34. package/dist/pkt-index.js +11 -11
  35. package/dist/pkt-input-wrapper.cjs +1 -1
  36. package/dist/pkt-input-wrapper.js +1 -1
  37. package/dist/pkt-radiobutton.cjs +1 -1
  38. package/dist/pkt-radiobutton.js +1 -1
  39. package/dist/pkt-select.cjs +1 -1
  40. package/dist/pkt-select.js +1 -1
  41. package/dist/pkt-textarea.cjs +1 -1
  42. package/dist/pkt-textarea.js +1 -1
  43. package/dist/pkt-textinput.cjs +1 -1
  44. package/dist/pkt-textinput.js +1 -1
  45. package/dist/pkt-timepicker.cjs +1 -1
  46. package/dist/pkt-timepicker.js +1 -1
  47. package/dist/{radiobutton-oEYrBiT6.cjs → radiobutton-BPr22VmL.cjs} +4 -4
  48. package/dist/{radiobutton-DP791tUe.js → radiobutton-l_3oGDbb.js} +11 -8
  49. package/dist/{select-QobXCtIL.cjs → select-CZYQ5Dmx.cjs} +3 -3
  50. package/dist/{select-B97S4g1v.js → select-DYjKMmHa.js} +4 -4
  51. package/dist/shared-types/checkbox.d.ts +3 -1
  52. package/dist/shared-types/size.d.ts +2 -1
  53. package/dist/{textarea-DgW0hRV5.js → textarea-C2oaRlfb.js} +4 -4
  54. package/dist/{textarea-ZMbtZNp3.cjs → textarea-H1Lt2o6K.cjs} +3 -3
  55. package/dist/{textinput-s-qz2xSC.js → textinput-C0eu70sH.js} +4 -4
  56. package/dist/{textinput-DfT_1aGb.cjs → textinput-C2Tx-OrN.cjs} +3 -3
  57. package/dist/{timepicker-Crj4isb9.js → timepicker-B8TwchA2.js} +9 -9
  58. package/dist/{timepicker-BAa_VEnf.cjs → timepicker-DZG_gHIa.cjs} +8 -8
  59. package/package.json +2 -2
  60. package/src/components/checkbox/checkbox.test.ts +26 -0
  61. package/src/components/checkbox/checkbox.ts +9 -11
  62. package/src/components/combobox/combobox-handlers.ts +6 -6
  63. package/src/components/combobox/combobox-value.ts +1 -1
  64. package/src/components/combobox/combobox.ts +5 -5
  65. package/src/components/datepicker/datepicker.ts +4 -4
  66. package/src/components/input-wrapper/input-wrapper.test.ts +90 -0
  67. package/src/components/input-wrapper/input-wrapper.ts +23 -7
  68. package/src/components/input-wrapper/wrapper-parity.test.ts +9 -0
  69. package/src/components/radiobutton/radiobutton.test.ts +26 -0
  70. package/src/components/radiobutton/radiobutton.ts +6 -7
  71. package/src/components/select/select.ts +2 -2
  72. package/src/components/textarea/textarea.ts +2 -2
  73. package/src/components/textinput/textinput.ts +2 -2
  74. package/src/components/timepicker/timepicker.ts +7 -7
  75. package/dist/checkbox-DIyi1Cya.cjs +0 -40
  76. package/dist/input-element-Ctkz5fQk.cjs +0 -1
  77. package/dist/input-wrapper-Cf__-4E-.cjs +0 -59
@@ -389,6 +389,25 @@ describe('PktInputWrapper', () => {
389
389
  document.body.innerHTML = ''
390
390
  })
391
391
 
392
+ test('links the error message to the fieldset', async () => {
393
+ const fieldset = await mountFieldset('hasError errorMessage="Velg ett alternativ"')
394
+
395
+ expect(describedByIds(fieldset)).toContain('g-error')
396
+ expect(document.getElementById('g-error')).toBeInTheDocument()
397
+ })
398
+
399
+ test('links both helptext and error message to the fieldset', async () => {
400
+ const fieldset = await mountFieldset('helptext="Velg ett" hasError errorMessage="Mangler"')
401
+
402
+ expect(describedByIds(fieldset)).toEqual(['g-helptext', 'g-error'])
403
+ })
404
+
405
+ test('does not link an error message when hasError is off', async () => {
406
+ const fieldset = await mountFieldset('errorMessage="Mangler"')
407
+
408
+ expect(fieldset.hasAttribute('aria-describedby')).toBe(false)
409
+ })
410
+
392
411
  test('links slotted helptext to the fieldset', async () => {
393
412
  const fieldset = await mountFieldset('', '<div class="pkt-contents" slot="helptext">Velg ett</div>')
394
413
 
@@ -420,6 +439,23 @@ describe('PktInputWrapper', () => {
420
439
  expect(describedByIds(fieldset)).toEqual(['g-helptext'])
421
440
  expect(document.getElementById('g-helptext')?.textContent).toContain('Velg ett')
422
441
  })
442
+
443
+ test('only references ids that are rendered', async () => {
444
+ const fieldset = await mountFieldset('helptext="Velg ett" hasError errorMessage="Mangler"')
445
+
446
+ describedByIds(fieldset).forEach((id) => {
447
+ expect(document.getElementById(id)).toBeInTheDocument()
448
+ })
449
+ })
450
+
451
+ test('names the fieldset with a hidden legend when useWrapper is off', async () => {
452
+ const fieldset = await mountFieldset('useWrapper="false"')
453
+
454
+ const legend = fieldset.querySelector(':scope > legend')
455
+ expect(legend).toHaveClass('pkt-sr-only')
456
+ expect(legend?.textContent?.trim()).toBe('Gruppe')
457
+ expect(fieldset.querySelector('label')).toBeNull()
458
+ })
423
459
  })
424
460
 
425
461
  describe('Wrapper functionality', () => {
@@ -597,3 +633,57 @@ describe('PktInputWrapper', () => {
597
633
  })
598
634
  })
599
635
  })
636
+
637
+ describe('PktInputWrapper options container', () => {
638
+ const mount = async (attributes: string) => {
639
+ document.body.innerHTML = `<pkt-input-wrapper forId="g" label="Gruppe" ${attributes}><span class="valg">Valg</span></pkt-input-wrapper>`
640
+ const wrapper = document.querySelector('pkt-input-wrapper') as CustomElementFor<'pkt-input-wrapper'>
641
+ await wrapper.updateComplete
642
+ return wrapper
643
+ }
644
+
645
+ afterEach(() => {
646
+ document.body.innerHTML = ''
647
+ })
648
+
649
+ test('wraps the options of a fieldset in a vertical options container', async () => {
650
+ const wrapper = await mount('hasFieldset')
651
+
652
+ const options = wrapper.querySelector('.pkt-inputwrapper__options')
653
+ expect(options).not.toHaveClass('pkt-inputwrapper__options--horizontal')
654
+ expect(options?.querySelector('.valg')).toBeInTheDocument()
655
+ })
656
+
657
+ test('lays the options out horizontally with layout="horizontal"', async () => {
658
+ const wrapper = await mount('hasFieldset layout="horizontal"')
659
+
660
+ expect(wrapper.querySelector('.pkt-inputwrapper__options')).toHaveClass(
661
+ 'pkt-inputwrapper__options--horizontal',
662
+ )
663
+ })
664
+
665
+ test('uses the options container for horizontal layout without a fieldset', async () => {
666
+ const wrapper = await mount('layout="horizontal"')
667
+
668
+ expect(wrapper.querySelector('.pkt-inputwrapper__options--horizontal .valg')).toBeInTheDocument()
669
+ })
670
+
671
+ test('keeps the markup unchanged without a fieldset and horizontal layout', async () => {
672
+ const wrapper = await mount('')
673
+
674
+ expect(wrapper.querySelector('.pkt-inputwrapper__options')).toBeNull()
675
+ expect(wrapper.querySelector('.pkt-contents .valg')).toBeInTheDocument()
676
+ })
677
+
678
+ test('switches layout when the property changes', async () => {
679
+ const wrapper = await mount('hasFieldset')
680
+
681
+ wrapper.layout = 'horizontal'
682
+ await wrapper.updateComplete
683
+
684
+ expect(wrapper.querySelector('.pkt-inputwrapper__options')).toHaveClass(
685
+ 'pkt-inputwrapper__options--horizontal',
686
+ )
687
+ expect(wrapper.querySelectorAll('.valg')).toHaveLength(1)
688
+ })
689
+ })
@@ -8,7 +8,7 @@ import { unsafeHTML } from 'lit/directives/unsafe-html.js'
8
8
  import { customElement, property } from 'lit/decorators.js'
9
9
  import { ElementProps } from '@/types/typeUtils'
10
10
  import { uuidish } from 'shared-utils/utils'
11
- import { booleanishConverter, type Booleanish } from 'shared-types'
11
+ import { booleanishConverter, type Booleanish, type TLayout } from 'shared-types'
12
12
  import { FocusModalityController } from '@/controllers/focus-modality-controller'
13
13
  import specs from 'componentSpecs/input-wrapper.json'
14
14
  import '@/components/helptext'
@@ -38,6 +38,7 @@ type Props = ElementProps<
38
38
  | 'inline'
39
39
  | 'ariaDescribedby'
40
40
  | 'hasFieldset'
41
+ | 'layout'
41
42
  | 'useWrapper'
42
43
  | 'role'
43
44
  > &
@@ -71,6 +72,7 @@ export class PktInputWrapper extends PktElementWithSlot<Props> {
71
72
  @property({ type: Boolean }) inline: boolean = specs.props.inline.default
72
73
  @property({ type: String }) ariaDescribedby: string | undefined = undefined
73
74
  @property({ type: Boolean }) hasFieldset: boolean = specs.props.hasFieldset.default
75
+ @property({ type: String }) layout: TLayout = specs.props.layout.default as TLayout
74
76
  @property({ type: String, reflect: true }) role: string | null = null
75
77
  @property({ type: Boolean, reflect: true, converter: booleanishConverter })
76
78
  useWrapper: Booleanish = specs.props.useWrapper.default
@@ -100,11 +102,16 @@ export class PktInputWrapper extends PktElementWithSlot<Props> {
100
102
  const tagClasses = 'pkt-tag pkt-tag--small pkt-tag--thin-text'
101
103
 
102
104
  const hasHelptext = !!this.helptext || this.hasSlotContent('helptext')
103
- const describedBy = this.ariaDescribedby
104
- ? this.ariaDescribedby
105
- : hasHelptext
106
- ? `${this.forId}-helptext`
107
- : nothing
105
+ const describedByIds = new Set(
106
+ [
107
+ this.ariaDescribedby || (hasHelptext ? `${this.forId}-helptext` : ''),
108
+ this.hasError && this.errorMessage ? `${this.forId}-error` : '',
109
+ ]
110
+ .join(' ')
111
+ .split(' ')
112
+ .filter(Boolean),
113
+ )
114
+ const describedBy = describedByIds.size ? [...describedByIds].join(' ') : nothing
108
115
 
109
116
  const formStrings = this.pktStrings.get('forms')
110
117
 
@@ -145,6 +152,8 @@ export class PktInputWrapper extends PktElementWithSlot<Props> {
145
152
  >${this.label}${tagElement()}</label
146
153
  >`
147
154
  }
155
+ } else if (this.hasFieldset) {
156
+ return html`<legend class="pkt-sr-only" id="${this.forId}-label">${this.label}</legend>`
148
157
  } else {
149
158
  return html`<label for="${this.forId}" class="pkt-sr-only" id="${this.forId}-label">
150
159
  ${this.label}
@@ -214,7 +223,7 @@ export class PktInputWrapper extends PktElementWithSlot<Props> {
214
223
  ${labelElement()}
215
224
  ${helptextElement()}
216
225
  ${this.counterPosition === 'top' ? counterElement() : nothing}
217
- <div class="pkt-contents">${slotContent(this)}</div>
226
+ <div class=${this.optionsClass()}>${slotContent(this)}</div>
218
227
  ${this.counterPosition === 'bottom' ? counterElement() : nothing}
219
228
  ${errorElement()}
220
229
  `
@@ -231,6 +240,13 @@ export class PktInputWrapper extends PktElementWithSlot<Props> {
231
240
  return wrapperElement()
232
241
  }
233
242
 
243
+ private optionsClass(): string {
244
+ if (!this.hasFieldset && this.layout !== 'horizontal') return 'pkt-contents'
245
+ return this.layout === 'horizontal'
246
+ ? 'pkt-inputwrapper__options pkt-inputwrapper__options--horizontal'
247
+ : 'pkt-inputwrapper__options'
248
+ }
249
+
234
250
  private toggleDropdown(e: CustomEvent) {
235
251
  this.dispatchEvent(
236
252
  new CustomEvent('toggleHelpText', {
@@ -64,6 +64,15 @@ const OMITTED: Record<string, Partial<Record<keyof typeof COMPONENTS, string>>>
64
64
  timepicker: 'teller over feltet er aldri støttet',
65
65
  fileupload: 'teller over feltet er aldri støttet',
66
66
  },
67
+ layout: {
68
+ textinput: 'layout gjelder alternativer i en gruppe, ikke ett felt',
69
+ textarea: 'layout gjelder alternativer i en gruppe, ikke ett felt',
70
+ select: 'layout gjelder alternativer i en gruppe, ikke ett felt',
71
+ combobox: 'layout gjelder alternativer i en gruppe, ikke ett felt',
72
+ datepicker: 'layout gjelder alternativer i en gruppe, ikke ett felt',
73
+ timepicker: 'layout gjelder alternativer i en gruppe, ikke ett felt',
74
+ fileupload: 'layout gjelder alternativer i en gruppe, ikke ett felt',
75
+ },
67
76
  hasFieldset: {
68
77
  fileupload: 'ikke støttet',
69
78
  },
@@ -271,3 +271,29 @@ describe('pkt-radiobutton', () => {
271
271
  expect(results).toHaveNoViolations()
272
272
  })
273
273
  })
274
+
275
+ describe('pkt-radiobutton inputSize', () => {
276
+ const root = async (attributes = '') => {
277
+ document.body.innerHTML = `<pkt-radiobutton id="s" name="s" label="Valg" ${attributes}></pkt-radiobutton>`
278
+ const el = document.querySelector('pkt-radiobutton') as HTMLElement & { updateComplete: Promise<unknown> }
279
+ await el.updateComplete
280
+ return el.querySelector('.pkt-input-check') as HTMLElement
281
+ }
282
+
283
+ afterEach(() => {
284
+ document.body.innerHTML = ''
285
+ })
286
+
287
+ test('adds no size class without input-size, so the size is inherited', async () => {
288
+ expect((await root()).className).toBe('pkt-input-check')
289
+ })
290
+
291
+ test('adds the size class for input-size', async () => {
292
+ expect(await root('input-size="small"')).toHaveClass('pkt-input-check--small')
293
+ expect(await root('input-size="xsmall"')).toHaveClass('pkt-input-check--xsmall')
294
+ })
295
+
296
+ test('adds the medium class when medium is set explicitly', async () => {
297
+ expect(await root('input-size="medium"')).toHaveClass('pkt-input-check--medium')
298
+ })
299
+ })
@@ -5,6 +5,7 @@ import { Ref, createRef, ref } from 'lit/directives/ref.js'
5
5
  import { html, nothing } from 'lit'
6
6
  import { classMap } from 'lit/directives/class-map.js'
7
7
  import { ElementProps } from '@/types/typeUtils'
8
+ import type { TPktInputSize } from 'shared-types'
8
9
 
9
10
  type Props = ElementProps<
10
11
  PktRadioButton,
@@ -27,6 +28,7 @@ export class PktRadioButton extends PktInputElement<Props> {
27
28
  @property({ type: Boolean }) hasTile: boolean = false
28
29
  @property({ type: Boolean, reflect: true }) checked: boolean | string | null = null
29
30
  @property({ type: String, reflect: true }) type: string = 'radio'
31
+ @property({ type: String, attribute: 'input-size' }) inputSize: TPktInputSize | undefined = undefined
30
32
  @property({ type: String }) tagText: string | null = null
31
33
  @property({ type: Boolean }) optionalTag: boolean = false
32
34
  /** @deprecated Bruk `strings={{ forms: { optional: '…' } }}` eller `setPktStrings()`. */
@@ -42,9 +44,6 @@ export class PktRadioButton extends PktInputElement<Props> {
42
44
  }
43
45
 
44
46
  attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
45
- if (name === 'defaultChecked') {
46
- this._checked = this.defaultChecked
47
- }
48
47
  if (name === 'checked') {
49
48
  this._checked = this.checked === '' || this.checked === 'true' || this.checked === true
50
49
  }
@@ -55,7 +54,7 @@ export class PktRadioButton extends PktInputElement<Props> {
55
54
  const inputTileClasses = classMap({
56
55
  'pkt-input-check__input': true,
57
56
  'pkt-input-check__input--tile': this.hasTile,
58
- 'pkt-input-check__input--tile-disabled': this.disabled && this.hasTile,
57
+ 'pkt-input-check__input--tile-disabled': this.isDisabled && this.hasTile,
59
58
  })
60
59
 
61
60
  const inputCheckBoxClasses = classMap({
@@ -65,7 +64,7 @@ export class PktRadioButton extends PktInputElement<Props> {
65
64
 
66
65
  const labelClasses = classMap({
67
66
  'pkt-input-check__input-label': true,
68
- 'pkt-input-check__input-label--disabled': this.disabled,
67
+ 'pkt-input-check__input-label--disabled': this.isDisabled,
69
68
  'pkt-sr-only': this.hideLabel,
70
69
  })
71
70
 
@@ -116,13 +115,13 @@ export class PktRadioButton extends PktInputElement<Props> {
116
115
  }
117
116
 
118
117
  return html`
119
- <div class="pkt-input-check">
118
+ <div class="pkt-input-check${this.inputSize ? ` pkt-input-check--${this.inputSize}` : ''}">
120
119
  <div class=${inputTileClasses}>
121
120
  <input
122
121
  id=${this.id + '-internal'}
123
122
  class=${inputCheckBoxClasses}
124
123
  type="radio"
125
- ?disabled=${this.disabled}
124
+ ?disabled=${this.isDisabled}
126
125
  form=""
127
126
  name=${this.name + '-internal'}
128
127
  ${ref(this.inputRef)}
@@ -185,7 +185,7 @@ export class PktSelect extends PktOptionsInputElement<{}, TSelectOption> impleme
185
185
  ${forwardSlots(this, ['helptext'])}
186
186
  .strings=${this.strings}
187
187
  .size=${this.inputSize}
188
- ?disabled=${this.disabled}
188
+ ?disabled=${this.isDisabled}
189
189
  ?hasError=${this.hasError}
190
190
  ?hasFieldset=${this.effectiveHasFieldset(false)}
191
191
  ?inline=${this.inline}
@@ -216,7 +216,7 @@ export class PktSelect extends PktOptionsInputElement<{}, TSelectOption> impleme
216
216
  }),
217
217
  )}
218
218
  aria-labelledby=${ifDefined(this.ariaLabelledby)}
219
- ?disabled=${this.disabled}
219
+ ?disabled=${this.isDisabled}
220
220
  id=${this.id + '-input'}
221
221
  name=${(this.name || this.id) + '-input'}
222
222
  @change=${(e: Event) => {
@@ -66,7 +66,7 @@ export class PktTextarea extends PktInputElement<Props> {
66
66
  label=${this.label}
67
67
  ?counter=${showCounter}
68
68
  ?hasFieldset=${this.effectiveHasFieldset(false)}
69
- ?disabled=${this.disabled}
69
+ ?disabled=${this.isDisabled}
70
70
  ?hasError=${this.hasError}
71
71
  ?inline=${this.inline}
72
72
  ?optionalTag=${this.optionalTag}
@@ -110,7 +110,7 @@ export class PktTextarea extends PktInputElement<Props> {
110
110
  )}
111
111
  rows=${ifDefined(this.rows ?? undefined)}
112
112
  cols=${ifDefined(this.cols ?? undefined)}
113
- ?disabled=${this.disabled}
113
+ ?disabled=${this.isDisabled}
114
114
  @input=${(e: InputEvent) => {
115
115
  this.value = (e.target as HTMLInputElement).value
116
116
  this.onInput()
@@ -82,7 +82,7 @@ export class PktTextinput extends PktInputElement<Props> {
82
82
  label="${this.label}"
83
83
  ?counter=${showCounter}
84
84
  ?hasFieldset=${this.effectiveHasFieldset(false)}
85
- ?disabled=${this.disabled}
85
+ ?disabled=${this.isDisabled}
86
86
  ?hasError=${this.hasError}
87
87
  ?inline=${this.inline}
88
88
  ?optionalTag=${this.optionalTag}
@@ -121,7 +121,7 @@ export class PktTextinput extends PktInputElement<Props> {
121
121
  ?readonly=${this.readonly}
122
122
  size=${this.size || nothing}
123
123
  .value=${this.value}
124
- ?disabled=${this.disabled}
124
+ ?disabled=${this.isDisabled}
125
125
  aria-invalid=${this.hasError}
126
126
  aria-errormessage=${ifDefined(this.hasError ? `${this.id}-input-error` : undefined)}
127
127
  aria-describedby=${ifDefined(
@@ -643,7 +643,7 @@ export class PktTimepicker extends PktInputElement<Props> {
643
643
  .inputSize} pkt-timepicker__button pkt-timepicker__button--prev"
644
644
  type="button"
645
645
  aria-label=${this.pktStrings.get('timepicker').prevTime}
646
- ?disabled=${this.disabled}
646
+ ?disabled=${this.isDisabled}
647
647
  @click=${() => this._stepTime(-1)}
648
648
  >
649
649
  <pkt-icon name="chevron-thin-left"></pkt-icon>
@@ -677,7 +677,7 @@ export class PktTimepicker extends PktInputElement<Props> {
677
677
  ? `${this._hours} ${hoursLabel.toLowerCase()}`
678
678
  : nothing}
679
679
  autocomplete="off"
680
- ?disabled=${this.disabled}
680
+ ?disabled=${this.isDisabled}
681
681
  @keydown=${this._handleHoursKeydown}
682
682
  @blur=${this._handleHoursBlur}
683
683
  @focus=${(e: FocusEvent) => {
@@ -710,7 +710,7 @@ export class PktTimepicker extends PktInputElement<Props> {
710
710
  ? `${this._minutes} ${minutesLabel.toLowerCase()}`
711
711
  : nothing}
712
712
  autocomplete="off"
713
- ?disabled=${this.disabled}
713
+ ?disabled=${this.isDisabled}
714
714
  @keydown=${this._handleMinutesKeydown}
715
715
  @blur=${this._handleMinutesBlur}
716
716
  @focus=${(e: FocusEvent) => {
@@ -736,7 +736,7 @@ export class PktTimepicker extends PktInputElement<Props> {
736
736
  aria-haspopup="listbox"
737
737
  aria-expanded=${this._isOpen ? 'true' : 'false'}
738
738
  aria-controls=${this.id + '-popup'}
739
- ?disabled=${this.disabled}
739
+ ?disabled=${this.isDisabled}
740
740
  @click=${this._togglePopup}
741
741
  >
742
742
  <pkt-icon name="clock"></pkt-icon>
@@ -753,7 +753,7 @@ export class PktTimepicker extends PktInputElement<Props> {
753
753
  .inputSize} pkt-timepicker__button pkt-timepicker__button--next"
754
754
  type="button"
755
755
  aria-label=${this.pktStrings.get('timepicker').nextTime}
756
- ?disabled=${this.disabled}
756
+ ?disabled=${this.isDisabled}
757
757
  @click=${() => this._stepTime(1)}
758
758
  >
759
759
  <pkt-icon name="chevron-thin-right"></pkt-icon>
@@ -774,7 +774,7 @@ export class PktTimepicker extends PktInputElement<Props> {
774
774
  max=${ifDefined(this.max ?? undefined)}
775
775
  step=${ifDefined(this.step ?? undefined)}
776
776
  ?required=${this.required}
777
- ?disabled=${this.disabled}
777
+ ?disabled=${this.isDisabled}
778
778
  tabindex="-1"
779
779
  />
780
780
  </div>
@@ -787,7 +787,7 @@ export class PktTimepicker extends PktInputElement<Props> {
787
787
  ${forwardSlots(this, ['helptext'])}
788
788
  .strings=${this.strings}
789
789
  label="${this.label}"
790
- ?disabled=${this.disabled}
790
+ ?disabled=${this.isDisabled}
791
791
  ?fullwidth=${this.fullwidth}
792
792
  ?hasError=${this.hasError}
793
793
  ?hasFieldset=${this.effectiveHasFieldset(false)}
@@ -1,40 +0,0 @@
1
- const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./ref-Emu5PNxk.cjs"),r=require("./input-element-Ctkz5fQk.cjs");var i={defaultChecked:!1,indeterminate:!1,hasTile:!1,disabled:!1,hasError:!1,isSwitch:!1,hideLabel:!1,labelPosition:`right`,requiredTag:!1,optionalTag:!1},a=class extends r.t{constructor(...e){super(...e),this.inputRef=n.t(),this.value=``,this.checkHelptext=null,this.defaultChecked=i.defaultChecked,this.hasTile=i.hasTile,this.isSwitch=i.isSwitch,this.labelPosition=i.labelPosition,this.hideLabel=i.hideLabel,this.checked=null,this.indeterminate=i.indeterminate,this.type=`checkbox`,this.tagText=null,this.optionalTag=i.optionalTag,this.requiredTag=i.requiredTag}connectedCallback(){super.connectedCallback()}attributeChangedCallback(e,t,n){e===`defaultChecked`&&!this.checked&&(this.checked=this.defaultChecked),e===`checked`&&(this.checked=this.checked===``||this.checked===`true`||this.checked===!0,this.inputRef.value&&(this.inputRef.value.checked=this.checked)),e===`indeterminate`&&(this.indeterminate=this.indeterminate===``||this.indeterminate===`true`||this.indeterminate===!0,this.inputRef.value&&(this.inputRef.value.indeterminate=this.indeterminate)),super.attributeChangedCallback(e,t,n)}firstUpdated(e){this.inputRef.value&&(this.inputRef.value.indeterminate=this.indeterminate===``||this.indeterminate===`true`||this.indeterminate===!0),super.firstUpdated(e)}willUpdate(e){super.willUpdate(e),e.has(`defaultChecked`)&&!this.checked&&(this.checked=this.defaultChecked)}updated(e){e.has(`checked`)&&this.inputRef.value&&(this.inputRef.value.checked=this.checked===``||this.checked===`true`||this.checked===!0),e.has(`indeterminate`)&&this.inputRef.value&&(this.inputRef.value.indeterminate=this.indeterminate===``||this.indeterminate===`true`||this.indeterminate===!0),super.updated(e)}render(){let r=t.t({"pkt-input-check__input":!0,"pkt-input-check__input--tile":this.hasTile,"pkt-input-check__input--tile-disabled":this.disabled&&this.hasTile}),i=t.t({"pkt-input-check__input-checkbox":!0,"pkt-input-check__input-checkbox--error":this.hasError}),a=t.t({"pkt-input-check__input-label":!0,"pkt-input-check__input-label--disabled":this.disabled,"pkt-input-check__input-label--left":this.labelPosition===`left`,"pkt-input-check__input-label--right":this.labelPosition===`right`,"pkt-sr-only":this.hideLabel}),o=`pkt-tag pkt-tag--small pkt-tag--thin-text`,s=this.pktStrings.get(`forms`),c=()=>e._`
2
- ${this.tagText?e._`<span class=${o+` pkt-tag--gray`}>${this.tagText}</span>`:e.h}
3
- ${this.optionalTag?e._`<span class=${o+` pkt-tag--blue-light`}
4
- >${this.optionalText??s.optional}</span
5
- >`:e.h}
6
- ${this.requiredTag?e._`<span class=${o+` pkt-tag--beige`}
7
- >${this.requiredText??s.required}</span
8
- >`:e.h}
9
- `,l=this.id+`-check-label`,u=this.id+`-check-helptext`,d=()=>e._`
10
- <label class=${a} for=${this.id+`-internal`}>
11
- <span id=${l}>${this.label} ${c()}</span>
12
- ${this.checkHelptext?e._`<div id=${u} class="pkt-input-check__input-helptext">
13
- ${this.checkHelptext}
14
- </div>`:e.h}
15
- </label>
16
- `;return e._`
17
- <div class="pkt-input-check">
18
- <div class=${r}>
19
- ${this.labelPosition===`left`?d():e.h}
20
- <input
21
- id=${this.id+`-internal`}
22
- class=${i}
23
- type="checkbox"
24
- ?disabled=${this.disabled}
25
- name=${this.name+`-internal`}
26
- ${n.n(this.inputRef)}
27
- @change=${this.handleChange}
28
- @input=${this.handleInput}
29
- @click=${this.handleClick}
30
- @blur=${this.onBlur}
31
- @focus=${this.onFocus}
32
- ?checked=${this.checked}
33
- role=${this.isSwitch?`switch`:`checkbox`}
34
- aria-labelledby=${this.label?l:e.h}
35
- aria-describedby=${this.checkHelptext?u:e.h}
36
- />
37
- ${this.labelPosition===`right`?d():e.h}
38
- </div>
39
- </div>
40
- `}handleInput(e){e.stopImmediatePropagation(),this.onInput()}handleClick(e){if(this.disabled)return e.preventDefault(),e.stopImmediatePropagation(),!1}handleChange(e){if(this.disabled)return e.preventDefault(),e.stopImmediatePropagation(),!1;this.toggleChecked(e)}toggleChecked(e){if(this.disabled){e.preventDefault(),e.stopImmediatePropagation();return}let t=e.target;if(t&&t.disabled){e.preventDefault(),e.stopImmediatePropagation();return}e.stopImmediatePropagation(),this.touched=!0,this.inputRef.value&&(this.checked=this.inputRef.value.matches(`:checked`),this.valueChecked(this.checked))}};e.n([e.u({type:String,reflect:!0})],a.prototype,`value`,void 0),e.n([e.u({type:String})],a.prototype,`checkHelptext`,void 0),e.n([e.u({type:Boolean})],a.prototype,`defaultChecked`,void 0),e.n([e.u({type:Boolean})],a.prototype,`hasTile`,void 0),e.n([e.u({type:Boolean})],a.prototype,`isSwitch`,void 0),e.n([e.u({type:String})],a.prototype,`labelPosition`,void 0),e.n([e.u({type:Boolean})],a.prototype,`hideLabel`,void 0),e.n([e.u({type:Boolean,reflect:!0})],a.prototype,`checked`,void 0),e.n([e.u({type:Boolean,reflect:!0})],a.prototype,`indeterminate`,void 0),e.n([e.u({type:String,reflect:!0})],a.prototype,`type`,void 0),e.n([e.u({type:String})],a.prototype,`tagText`,void 0),e.n([e.u({type:Boolean})],a.prototype,`optionalTag`,void 0),e.n([e.u({type:String})],a.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean})],a.prototype,`requiredTag`,void 0),e.n([e.u({type:String})],a.prototype,`requiredText`,void 0);try{e.d(`pkt-checkbox`)(a)}catch{console.warn(`Forsøker å definere <pkt-checkbox>, 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 +0,0 @@
1
- const e=require("./element-BOmr9YLv.cjs"),t=require("./format-B8meU8Tm.cjs"),n=require("./element-with-slot-D7sTqOr3.cjs"),r=require("./booleanish-BF8l4scU.cjs"),i=require("./utils-63cRpWut.cjs");var a=new WeakMap,o=new WeakMap,s=new WeakMap,c=new WeakMap,l=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakMap,p=new WeakMap,m=new WeakMap,h=new WeakMap,g=new WeakMap,_=new WeakMap,v=new WeakMap,y=new WeakMap,b=(e,t,n)=>{e.getAttribute(t)!==n&&e.setAttribute(t,n)},x=(e,t)=>{e.toggleAttribute(`internals-disabled`,t),t?b(e,`aria-disabled`,`true`):e.removeAttribute(`aria-disabled`),e.formDisabledCallback&&e.formDisabledCallback.apply(e,[t])},S=e=>{s.get(e).forEach(e=>{e.remove()}),s.set(e,[])},C=(e,t)=>{let n=document.createElement(`input`);return n.type=`hidden`,n.name=e.getAttribute(`name`),e.after(n),s.get(t).push(n),n},w=(e,t)=>{if(t.length){let n=Array.from(t);n.forEach(t=>t.addEventListener(`click`,e.click.bind(e)));let[r]=n,i=r.id;r.id||=(i=`${r.htmlFor}_Label`,i),b(e,`aria-labelledby`,i)}},T=e=>{let t=Array.from(e.elements).filter(e=>!e.tagName.includes(`-`)&&e.validity).map(e=>e.validity.valid),n=f.get(e)||[],r=Array.from(n).filter(e=>e.isConnected).map(e=>c.get(e).validity.valid),i=[...t,...r].includes(!1);e.toggleAttribute(`internals-invalid`,i),e.toggleAttribute(`internals-valid`,!i)},ee=e=>{T(O(e.target))},E=e=>{T(O(e.target))},te=e=>{let t=[`button[type=submit]`,`input[type=submit]`,`button:not([type])`].map(e=>`${e}:not([disabled])`).map(t=>`${t}:not([form])${e.id?`,${t}[form='${e.id}']`:``}`).join(`,`);e.addEventListener(`click`,n=>{if(n.target.closest(t)){let t=f.get(e);if(e.noValidate)return;t.size&&Array.from(t).reverse().map(e=>c.get(e).reportValidity()).includes(!1)&&n.preventDefault()}})},ne=e=>{let t=f.get(e.target);t&&t.size&&t.forEach(e=>{e.constructor.formAssociated&&e.formResetCallback&&e.formResetCallback.apply(e)})},D=(e,t,n)=>{if(t){let r=f.get(t);if(r)r.add(e);else{let n=new Set;n.add(e),f.set(t,n),te(t),t.addEventListener(`reset`,ne),t.addEventListener(`input`,ee),t.addEventListener(`change`,E)}u.set(t,{ref:e,internals:n}),e.constructor.formAssociated&&e.formAssociatedCallback&&setTimeout(()=>{e.formAssociatedCallback.apply(e,[t])},0),T(t)}},O=e=>{let t=e.parentNode;return t&&t.tagName!==`FORM`&&(t=O(t)),t},k=(e,t,n=DOMException)=>{if(!e.constructor.formAssociated)throw new n(t)},A=(e,t,n)=>{let r=f.get(e);return r&&r.size&&r.forEach(e=>{c.get(e)[n]()||(t=!1)}),t},j=e=>{let t=!1;if(e.constructor.formAssociated){let n=c.get(e);n===void 0&&(e.attachInternals(),n=c.get(e),t=!0);let{labels:r,form:i}=n;w(e,r),D(e,i,n)}return t};function M(){return typeof MutationObserver<`u`}var N={ariaAtomic:`aria-atomic`,ariaAutoComplete:`aria-autocomplete`,ariaBrailleLabel:`aria-braillelabel`,ariaBrailleRoleDescription:`aria-brailleroledescription`,ariaBusy:`aria-busy`,ariaChecked:`aria-checked`,ariaColCount:`aria-colcount`,ariaColIndex:`aria-colindex`,ariaColIndexText:`aria-colindextext`,ariaColSpan:`aria-colspan`,ariaCurrent:`aria-current`,ariaDescription:`aria-description`,ariaDisabled:`aria-disabled`,ariaExpanded:`aria-expanded`,ariaHasPopup:`aria-haspopup`,ariaHidden:`aria-hidden`,ariaInvalid:`aria-invalid`,ariaKeyShortcuts:`aria-keyshortcuts`,ariaLabel:`aria-label`,ariaLevel:`aria-level`,ariaLive:`aria-live`,ariaModal:`aria-modal`,ariaMultiLine:`aria-multiline`,ariaMultiSelectable:`aria-multiselectable`,ariaOrientation:`aria-orientation`,ariaPlaceholder:`aria-placeholder`,ariaPosInSet:`aria-posinset`,ariaPressed:`aria-pressed`,ariaReadOnly:`aria-readonly`,ariaRelevant:`aria-relevant`,ariaRequired:`aria-required`,ariaRoleDescription:`aria-roledescription`,ariaRowCount:`aria-rowcount`,ariaRowIndex:`aria-rowindex`,ariaRowIndexText:`aria-rowindextext`,ariaRowSpan:`aria-rowspan`,ariaSelected:`aria-selected`,ariaSetSize:`aria-setsize`,ariaSort:`aria-sort`,ariaValueMax:`aria-valuemax`,ariaValueMin:`aria-valuemin`,ariaValueNow:`aria-valuenow`,ariaValueText:`aria-valuetext`,role:`role`},P=(e,t)=>{for(let n in N){t[n]=null;let r=null,i=N[n];Object.defineProperty(t,n,{get(){return r},set(n){r=n,e.isConnected?b(e,i,n):m.set(e,t)}})}},re=(e,t)=>{s.set(t,[]),R.observe?.(e,L)};function F(e){let t=c.get(e),{form:n}=t;D(e,n,t),w(e,t.labels)}var I=(e,t=!1)=>{let n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(e){return c.has(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}}),r=n.nextNode(),i=!t||e.disabled;for(;r;)r.formDisabledCallback&&i&&x(r,e.disabled),r=n.nextNode()},L={attributes:!0,attributeFilter:[`disabled`,`name`]},R=M()?new MutationObserver(e=>{for(let t of e){let e=t.target;if(t.attributeName===`disabled`&&(e.constructor.formAssociated?x(e,e.hasAttribute(`disabled`)):e.localName===`fieldset`&&I(e)),t.attributeName===`name`&&e.constructor.formAssociated){let t=c.get(e),n=p.get(e);t.setFormValue(n)}}}):{};function z(e){e.forEach(e=>{let{addedNodes:t,removedNodes:n}=e,r=Array.from(t),i=Array.from(n);r.forEach(e=>{if(c.has(e)&&e.constructor.formAssociated&&F(e),m.has(e)){let t=m.get(e);Object.keys(N).filter(e=>t[e]!==null).forEach(n=>{b(e,N[n],t[n])}),m.delete(e)}if(y.has(e)){let t=y.get(e);b(e,`internals-valid`,t.validity.valid.toString()),b(e,`internals-invalid`,(!t.validity.valid).toString()),b(e,`aria-invalid`,(!t.validity.valid).toString()),y.delete(e)}if(e.localName===`form`){let t=f.get(e),n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(e){return c.has(e)&&e.constructor.formAssociated&&!(t&&t.has(e))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}}),r=n.nextNode();for(;r;)F(r),r=n.nextNode()}e.localName===`fieldset`&&(R.observe?.(e,L),I(e,!0))}),i.forEach(e=>{let t=c.get(e);t&&s.get(t)&&S(t),d.has(e)&&d.get(e).disconnect()})})}function ie(e){e.forEach(e=>{let{removedNodes:t}=e;t.forEach(t=>{let n=_.get(e.target);c.has(t)&&j(t),n.disconnect()})})}var ae=e=>{let t=new MutationObserver(ie);window?.ShadyDOM?.inUse&&e.mode&&e.host&&(e=e.host),t.observe?.(e,{childList:!0}),_.set(e,t)};M()&&new MutationObserver(z);var B={childList:!0,subtree:!0},oe=class{constructor(){this.badInput=!1,this.customError=!1,this.patternMismatch=!1,this.rangeOverflow=!1,this.rangeUnderflow=!1,this.stepMismatch=!1,this.tooLong=!1,this.tooShort=!1,this.typeMismatch=!1,this.valid=!0,this.valueMissing=!1,Object.seal(this)}},se=e=>(e.badInput=!1,e.customError=!1,e.patternMismatch=!1,e.rangeOverflow=!1,e.rangeUnderflow=!1,e.stepMismatch=!1,e.tooLong=!1,e.tooShort=!1,e.typeMismatch=!1,e.valid=!0,e.valueMissing=!1,e),ce=(e,t,n)=>(e.valid=le(t),Object.keys(t).forEach(n=>e[n]=t[n]),n&&T(n),e),le=e=>{let t=!0;for(let n in e)n!==`valid`&&e[n]!==!1&&(t=!1);return t},V=new WeakMap;function H(e,t){e.toggleAttribute(t,!0),e.part&&e.part.add(t)}var U=class extends Set{static get isPolyfilled(){return!0}constructor(e){if(super(),!e||!e.tagName||e.tagName.indexOf(`-`)===-1)throw TypeError(`Illegal constructor`);V.set(this,e)}add(e){if(!/^--/.test(e)||typeof e!=`string`)throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${e} must start with '--'.`);let t=super.add(e),n=V.get(this),r=`state${e}`;return n.isConnected?H(n,r):setTimeout(()=>{H(n,r)}),t}clear(){for(let[e]of this.entries())this.delete(e);super.clear()}delete(e){let t=super.delete(e),n=V.get(this);return n.isConnected?(n.toggleAttribute(`state${e}`,!1),n.part&&n.part.remove(`state${e}`)):setTimeout(()=>{n.toggleAttribute(`state${e}`,!1),n.part&&n.part.remove(`state${e}`)}),t}},ue=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},W=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},G,de=class{constructor(e){G.set(this,void 0),ue(this,G,e,`f`);for(let t=0;t<e.length;t++){let n=e[t];this[t]=n,n.hasAttribute(`name`)&&(this[n.getAttribute(`name`)]=n)}Object.freeze(this)}get length(){return W(this,G,`f`).length}[(G=new WeakMap,Symbol.iterator)](){return W(this,G,`f`)[Symbol.iterator]()}item(e){return this[e]==null?null:this[e]}namedItem(e){return this[e]==null?null:this[e]}};function fe(){let e=HTMLFormElement.prototype.checkValidity;HTMLFormElement.prototype.checkValidity=n;let t=HTMLFormElement.prototype.reportValidity;HTMLFormElement.prototype.reportValidity=r;function n(...t){let n=e.apply(this,t);return A(this,n,`checkValidity`)}function r(...e){let n=t.apply(this,e);return A(this,n,`reportValidity`)}let{get:i}=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,`elements`);Object.defineProperty(HTMLFormElement.prototype,"elements",{get(...e){let t=i.call(this,...e),n=Array.from(f.get(this)||[]);return n.length===0?t:new de(Array.from(t).concat(n).sort((e,t)=>e.compareDocumentPosition?e.compareDocumentPosition(t)&2?1:-1:0))}})}var K=class{static get isPolyfilled(){return!0}constructor(e){if(!e||!e.tagName||e.tagName.indexOf(`-`)===-1)throw TypeError(`Illegal constructor`);let t=e.getRootNode(),n=new oe;this.states=new U(e),a.set(this,e),o.set(this,n),c.set(e,this),P(e,this),re(e,this),Object.seal(this),t instanceof DocumentFragment&&ae(t)}checkValidity(){let e=a.get(this);if(k(e,`Failed to execute 'checkValidity' on 'ElementInternals': The target element is not a form-associated custom element.`),!this.willValidate)return!0;let t=o.get(this);if(!t.valid){let t=new Event(`invalid`,{bubbles:!1,cancelable:!0,composed:!1});e.dispatchEvent(t)}return t.valid}get form(){let e=a.get(this);k(e,`Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.`);let t;return e.constructor.formAssociated===!0&&(t=O(e)),t}get labels(){let e=a.get(this);k(e,`Failed to read the 'labels' property from 'ElementInternals': The target element is not a form-associated custom element.`);let t=e.getAttribute(`id`),n=e.getRootNode();return n&&t?n.querySelectorAll(`[for="${t}"]`):[]}reportValidity(){let e=a.get(this);if(k(e,`Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.`),!this.willValidate)return!0;let t=this.checkValidity(),n=g.get(this);if(n&&!e.constructor.formAssociated)throw new DOMException(`Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.`);return!t&&n&&(e.focus(),n.focus()),t}setFormValue(e){let t=a.get(this);if(k(t,`Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element.`),S(this),e!=null&&!(e instanceof FormData)){if(t.getAttribute(`name`)){let n=C(t,this);n.value=e}}else e!=null&&e instanceof FormData&&Array.from(e).reverse().forEach(([e,n])=>{if(typeof n==`string`){let r=C(t,this);r.name=e,r.value=n}});p.set(t,e)}setValidity(e,t,n){let r=a.get(this);if(k(r,`Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element.`),!e)throw TypeError(`Failed to execute 'setValidity' on 'ElementInternals': 1 argument required, but only 0 present.`);g.set(this,n);let i=o.get(this),s={};for(let t in e)s[t]=e[t];Object.keys(s).length===0&&se(i);let c={...i,...s};delete c.valid;let{valid:u}=ce(i,c,this.form);if(!u&&!t)throw new DOMException(`Failed to execute 'setValidity' on 'ElementInternals': The second argument should not be empty if one or more flags in the first argument are true.`);l.set(this,u?``:t),r.isConnected?(r.toggleAttribute(`internals-invalid`,!u),r.toggleAttribute(`internals-valid`,u),b(r,`aria-invalid`,`${!u}`)):y.set(r,this)}get shadowRoot(){let e=a.get(this);return h.get(e)||null}get validationMessage(){return k(a.get(this),`Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element.`),l.get(this)}get validity(){return k(a.get(this),`Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element.`),o.get(this)}get willValidate(){let e=a.get(this);return k(e,`Failed to read the 'willValidate' property from 'ElementInternals': The target element is not a form-associated custom element.`),!(e.matches(`:disabled`)||e.disabled||e.hasAttribute(`disabled`)||e.hasAttribute(`readonly`))}};function pe(){if(typeof window>`u`||!window.ElementInternals||!HTMLElement.prototype.attachInternals)return!1;class e extends HTMLElement{constructor(){super(),this.internals=this.attachInternals()}}let t=`element-internals-feature-detection-${Math.random().toString(36).replace(/[^a-z]+/g,``)}`;customElements.define(t,e);let n=new e;return[`shadowRoot`,`form`,`willValidate`,`validity`,`validationMessage`,`labels`,`setFormValue`,`setValidity`,`checkValidity`,`reportValidity`].every(e=>e in n.internals)}var q=!1,J=!1;function Y(e){J||(J=!0,window.CustomStateSet=U,e&&(HTMLElement.prototype.attachInternals=function(...t){let n=e.call(this,t);return n.states=new U(this),n}))}function me(e=!0){let t=!1;if(!q){if(q=!0,typeof window<`u`&&(window.ElementInternals=K),typeof CustomElementRegistry<`u`){let e=CustomElementRegistry.prototype.define;CustomElementRegistry.prototype.define=function(n,r,i){if(r.formAssociated){let e=r.prototype.connectedCallback;r.prototype.connectedCallback=function(){v.has(this)||(v.set(this,!0),this.hasAttribute(`disabled`)&&x(this,!0)),e?.apply(this),t=j(this)}}e.call(this,n,r,i)}}if(typeof HTMLElement<`u`&&(HTMLElement.prototype.attachInternals=function(){if(!this.tagName)return{};if(this.tagName.indexOf(`-`)===-1)throw Error(`Failed to execute 'attachInternals' on 'HTMLElement': Unable to attach ElementInternals to non-custom elements.`);if(c.has(this)&&!t)throw new DOMException(`DOMException: Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.`);return new K(this)}),typeof Element<`u`){function n(...t){let n=e.apply(this,t);if(h.set(this,n),M()){let e=new MutationObserver(z);window.ShadyDOM?e.observe(this,B):e.observe(n,B),d.set(this,e)}return n}let e=Element.prototype.attachShadow;Element.prototype.attachShadow=n}M()&&typeof document<`u`&&new MutationObserver(z).observe(document.documentElement,B),typeof HTMLFormElement<`u`&&fe(),(e||typeof window<`u`&&!window.CustomStateSet)&&Y()}}customElements.polyfillWrapFlushCallback||(pe()?typeof window<`u`&&!window.CustomStateSet&&Y(HTMLElement.prototype.attachInternals):me(!1));var X=`on`,Z=`--checked`,Q=`,`,$=class extends n.t{static get formAssociated(){return!0}get form(){let e=this.getAttribute(`form`);if(e!==null){if(!e)return null;let t=this.getRootNode(),n=typeof t.getElementById==`function`?t.getElementById(e):this.ownerDocument?.getElementById(e);return n instanceof HTMLFormElement?n:null}return this.internals?.form??this.closest(`form`)}get ariaDescribedBy(){return this.ariaDescribedby}set ariaDescribedBy(e){this.ariaDescribedby=e}effectiveCounter(e){return this.counter??e}effectiveHasFieldset(e){return this.hasFieldset??e}constructor(){super(),this.defaultValue=null,this.disabled=!1,this.readonly=!1,this.required=!1,this.max=null,this.maxlength=null,this.min=null,this.minlength=null,this.step=null,this.ariaDescribedby=null,this.ariaLabelledby=null,this.name=``,this.pattern=null,this.placeholder=null,this.id=i.n(),this.counter=null,this.hasError=!1,this.inline=!1,this.hasFieldset=null,this.optionalTag=!1,this.requiredTag=!1,this.skipForwardTestid=!1,this.useWrapper=!0,this.fullwidth=!1,this.counterMaxLength=0,this.errorMessage=``,this.helptext=``,this.helptextDropdown=``,this.helptextDropdownButton=null,this.label=null,this.tagText=null,this.inputSize=`medium`,this.dataTestid=``,this.touched=!1,this._initialized=!1,this._didInitDerivedState=!1,this.internals=this.attachInternals()}manageValidity(e){if(!e){console.warn(`manageValidity called without valid input element`);return}let n=this.pktStrings.get(`validation`);this.required&&!this.value?this.internals.setValidity({valueMissing:!0},n.valueMissing,e):e.validity?.typeMismatch||e.validity?.badInput?this.internals.setValidity({typeMismatch:!0},n.typeMismatch,e):e.validity?.patternMismatch?this.internals.setValidity({patternMismatch:!0},n.patternMismatch,e):e.validity?.tooShort||this.minlength&&this.minlength>0&&this.value.length<this.minlength?this.internals.setValidity({tooShort:!0},n.tooShort,e):e.validity?.tooLong||this.maxlength&&this.maxlength>0&&this.value.length>this.maxlength?this.internals.setValidity({tooLong:!0},n.tooLong,e):e.validity?.rangeUnderflow?this.internals.setValidity({rangeUnderflow:!0},this.min?t.t(n.rangeUnderflowMin,{min:this.min.toString()}):n.rangeUnderflow,e):e.validity?.stepMismatch?this.internals.setValidity({stepMismatch:!0},n.typeMismatch,e):e.validity?.rangeOverflow?this.internals.setValidity({rangeOverflow:!0},this.max?t.t(n.rangeOverflowMax,{max:this.max.toString()}):n.rangeOverflow,e):e.validity?.customError?this.internals.setValidity({customError:!0},e.validationMessage,e):this.internals.setValidity({})}setFormValue(e){if(this.internals){if(Array.isArray(e)){let t=new FormData;e.forEach(e=>{t.append(this.name,e)}),this.internals.setFormValue(t)}else this.internals.setFormValue(e)}}radioGroupMembers(){let e=this.getRootNode();if(typeof e.querySelectorAll!=`function`)return[];let t=this.form;return Array.from(e.querySelectorAll(`pkt-radiobutton, input[type="radio"]`)).filter(e=>e!==this&&e.getAttribute(`name`)===this.name&&e.form===t)}coordinateRadioGroup(){!this.name||this.type!==`radio`||this.radioGroupMembers().forEach(e=>{if(e.getAttribute(`value`)===this.value)return;let t=e;t.checked&&(t.checked=!1,t.internals&&(t.internals.setFormValue(null),t.internals.states?.delete(Z)))})}valueChecked(e){if(this.touched){if(this.type===`radio`&&this.coordinateRadioGroup(),typeof e==`string`?(this.checked=e===`true`,this.internals.ariaChecked=String(e===`true`)):typeof e==`boolean`&&(this.checked=e,this.internals.ariaChecked=String(e)),this.checked){let e=(typeof this.value==`string`?this.value:``)||X;this.internals.setFormValue(e),this.internals.states.add(Z)}else this.internals.setFormValue(null),this.internals.states.delete(Z);this.dispatchChangeEvents(this.checked),this.internals.reportValidity()}}valueChanged(e,t){let n=e;if(typeof n==`number`||typeof n==`boolean`)e=String(n);else if(n!=null&&typeof n!=`string`&&!Array.isArray(n)){let e=typeof n==`object`?n?.constructor?.name??`object`:typeof n;console.warn(`${this.localName}: value må være en streng eller et tall, men fikk ${e}. Verdien ignoreres. For dato-/tidsfelt, send en ISO-formatert streng (f.eks. "2026-07-09" eller "13:45").`)}(t!==this.value||t!==this._value)&&(typeof e==`string`?((this.multiple||this.range)&&e.includes(Q)&&(e=e.split(Q)),this.value=e,this._value=Array.isArray(e)?e:[e]):Array.isArray(e)?(this.value=this.multiple||this.range?e:e[0],this._value=e):(this.value=``,this._value=[]),(!this.value||this.value.length===0)&&t&&t.length!==0?this.clearInputValue():this.value&&this.value.toString()!==t?.toString()&&this.onChange(this.value))}dispatchChangeEvents(e){this.dispatchEvent(new Event(`change`,{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`value-change`,{detail:e,bubbles:!0,composed:!0}))}clearInputValue(){let e=this.multiple||this.range?[]:``;this.value=e,this.setFormValue(e),this.dispatchChangeEvents(e)}onFocus(){this.dispatchEvent(new FocusEvent(`focus`,{bubbles:!0,composed:!0}))}onBlur(){this.dispatchEvent(new FocusEvent(`blur`,{bubbles:!0,composed:!0}))}onInput(){this.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0}))}normalizeValue(e){return(this.range||this.multiple)&&typeof e==`string`&&e.includes(Q)?e.split(Q):!this.multiple&&!this.range&&Array.isArray(e)?e[0]||``:e}validate(){this.inputRef?.value&&this.manageValidity(this.inputRef.value),this.inputRefTo?.value&&this.manageValidity(this.inputRefTo.value)}onChange(e){if(this.touched=!0,typeof e!=`string`&&!Array.isArray(e))return;let t=this.normalizeValue(e);this.setFormValue(t),this.validate(),this._initialized&&this.dispatchChangeEvents(t)}formResetCallback(){if(this.touched=!1,this._options&&this._options.length&&this._options.forEach(e=>{`selected`in e&&(e.selected=!1)}),this.checked!==void 0)this.checked=!1,this.internals.ariaChecked=`false`,this.internals.setFormValue(``),this.inputRef?.value&&`checked`in this.inputRef.value&&(this.inputRef.value.checked=!1),this.valueChecked(this.checked);else{this.internals.setFormValue(``);let e=this.defaultValue||(this.multiple||this.range?[]:``);this.value=e,this._value=Array.isArray(e)?e:[e],this.valueChanged(this.value,null)}this.internals.ariaInvalid=`false`}updated(e){super.updated(e),e.has(`dataTestid`)&&this.dataTestid&&this.inputRef.value&&(this.skipForwardTestid?this.hasAttribute(`data-testid`)||this.setAttribute(`data-testid`,this.dataTestid):(this.inputRef.value.dataset.testid=this.dataTestid,this.removeAttribute(`data-testid`)))}willUpdate(e){super.willUpdate(e),!this._didInitDerivedState&&(this._didInitDerivedState=!0,this.defaultChecked&&(this.checked=!0),this.id&&!this.name&&(this.name=this.id),this.value&&this.defaultValue===null&&(this.defaultValue=this.value),this.defaultValue!==null&&!this.value&&this.valueChanged(this.defaultValue,null))}firstUpdated(e){if(super.firstUpdated(e),this.value&&this.defaultValue===null&&(this.defaultValue=this.value),this.defaultValue!==null&&!this.value&&this.valueChanged(this.defaultValue,null),this.defaultChecked&&(this.internals.ariaChecked=`true`),this.required&&(this.internals.ariaRequired=`true`),this.disabled&&(this.internals.ariaDisabled=`true`),this.checked!==void 0){let e=this.checked===``||this.checked===`true`||this.checked===!0;this.internals.ariaChecked=String(e);let t=e?(typeof this.value==`string`?this.value:``)||X:null;this.internals.setFormValue(t)}else this.setFormValue(this.value);this.inputRef&&this.inputRef.value&&(this.inputRef.value.setAttribute(`form`,``),this.manageValidity(this.inputRef.value)),this.inputRefTo&&this.inputRefTo.value&&(this.inputRefTo.value.setAttribute(`form`,``),this.manageValidity(this.inputRefTo.value)),this.updateComplete.then(()=>{this._initialized=!0})}};e.n([e.u({type:Boolean,reflect:!0})],$.prototype,`checked`,void 0),e.n([e.u({type:Boolean})],$.prototype,`defaultChecked`,void 0),e.n([e.u({type:Boolean})],$.prototype,`multiple`,void 0),e.n([e.u({type:Boolean})],$.prototype,`range`,void 0),e.n([e.u({type:String,reflect:!0})],$.prototype,`type`,void 0),e.n([e.u()],$.prototype,`defaultValue`,void 0),e.n([e.u({type:Boolean,reflect:!0})],$.prototype,`disabled`,void 0),e.n([e.u({type:Boolean,reflect:!0})],$.prototype,`readonly`,void 0),e.n([e.u({type:Boolean,reflect:!0})],$.prototype,`required`,void 0),e.n([e.u({reflect:!0,converter:{fromAttribute:e=>e,toAttribute:e=>e?.toString()??null}})],$.prototype,`max`,void 0),e.n([e.u({type:Number,reflect:!0})],$.prototype,`maxlength`,void 0),e.n([e.u({reflect:!0,converter:{fromAttribute:e=>e,toAttribute:e=>e?.toString()??null}})],$.prototype,`min`,void 0),e.n([e.u({type:Number,reflect:!0})],$.prototype,`minlength`,void 0),e.n([e.u({type:Number,reflect:!0})],$.prototype,`step`,void 0),e.n([e.u({type:String,attribute:`aria-describedby`})],$.prototype,`ariaDescribedby`,void 0),e.n([e.u({type:String,attribute:`aria-labelledby`})],$.prototype,`ariaLabelledby`,void 0),e.n([e.u({type:String,reflect:!0})],$.prototype,`name`,void 0),e.n([e.u({type:String,reflect:!0})],$.prototype,`pattern`,void 0),e.n([e.u({type:String,reflect:!0})],$.prototype,`placeholder`,void 0),e.n([e.u({type:String,reflect:!0})],$.prototype,`id`,void 0),e.n([e.u({type:Boolean,converter:r.n})],$.prototype,`counter`,void 0),e.n([e.u({type:Boolean})],$.prototype,`hasError`,void 0),e.n([e.u({type:Boolean})],$.prototype,`inline`,void 0),e.n([e.u({type:Boolean,converter:r.n})],$.prototype,`hasFieldset`,void 0),e.n([e.u({type:Boolean})],$.prototype,`optionalTag`,void 0),e.n([e.u({type:Boolean})],$.prototype,`requiredTag`,void 0),e.n([e.u({type:Boolean})],$.prototype,`skipForwardTestid`,void 0),e.n([e.u({type:Boolean,reflect:!0,converter:r.t})],$.prototype,`useWrapper`,void 0),e.n([e.u({type:Boolean,reflect:!0})],$.prototype,`fullwidth`,void 0),e.n([e.u({type:Number})],$.prototype,`counterMaxLength`,void 0),e.n([e.u({type:String})],$.prototype,`errorMessage`,void 0),e.n([e.u({type:String})],$.prototype,`helptext`,void 0),e.n([e.u({type:String})],$.prototype,`helptextDropdown`,void 0),e.n([e.u({type:String,reflect:!1})],$.prototype,`helptextDropdownButton`,void 0),e.n([e.u({type:String})],$.prototype,`label`,void 0),e.n([e.u({type:String,reflect:!1})],$.prototype,`optionalText`,void 0),e.n([e.u({type:String,reflect:!1})],$.prototype,`requiredText`,void 0),e.n([e.u({type:String,reflect:!1})],$.prototype,`tagText`,void 0),e.n([e.u({type:String,attribute:`input-size`})],$.prototype,`inputSize`,void 0),e.n([e.u({type:String,attribute:`data-testid`})],$.prototype,`dataTestid`,void 0),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return $}});
@@ -1,59 +0,0 @@
1
- const e=require("./element-BOmr9YLv.cjs"),t=require("./format-B8meU8Tm.cjs"),n=require("./element-with-slot-D7sTqOr3.cjs"),r=require("./booleanish-BF8l4scU.cjs");require("./alert-IaZzEgyI.cjs");const i=require("./icon-Dnv6LtPC.cjs"),a=require("./if-defined-2mkIDgOm.cjs"),o=require("./utils-63cRpWut.cjs");require("./helptext-BCkwSz1m.cjs");const s=require("./focus-modality-controller-C1ocyv2J.cjs");var c=e=>{let t=[];return e.hasHelptext&&t.push(`${e.id}-helptext`),e.hasCounter&&t.push(`${e.id}-counter-status`),e.ariaDescribedby&&t.push(e.ariaDescribedby),t.length?t.join(` `):void 0},l=e=>`${e}-counter-status`,u=(e,t)=>!!t&&t>0&&(e??0)>t,d={name:`pkt-input-wrapper`,react:`PktInputWrapper`,"css-class":`pkt-inputwrapper`,isElement:!0,isPureReact:!0,"dark-mode":!0,events:{toggleHelpText:{description:`Event for å vise eller skjule hjelpetekst i dropdown`}},slots:{default:{description:`Innholdet i input-wrapperen, som kan være et skjemaelement eller en annen komponent`}},props:{forId:{name:`For ID`,description:`Id-en til skjemaelementet som dette wrapper rundt`,type:`string`,required:!0,category:`tech`},label:{name:`Merkelapp`,description:`Merkelapp for skjemaelementet`,type:`string`,required:!0,category:`contents`},helptext:{name:`Hjelpetekst`,description:`Hjelpetekst for skjemaelementet`,type:`string`,category:`contents`},helptextDropdown:{name:`Hjelpetekst i dropdown`,description:`Hjelpetekst som vises i ekspanderende felt`,type:`string`,category:`contents`},helptextDropdownButton:{name:`Tekst i hjelpetekst-knapp`,description:`Tekst som vises i knappen for å vise hjelpetekst i dropdown`,default:`Les mer <span class='pkt-sr-only'>om feltet</span>`,type:`string`,category:`contents`},ariaDescribedby:{name:`aria-describedby`,description:`Id-en til elementet som beskriver skjemaelementet`,type:`string`,category:`accessibility`},counter:{name:`Teller`,description:`Teller for antall tegn i skjemaelementet`,type:`boolean`,default:!1,category:`ui`},counterCurrent:{name:`Tellerverdi`,description:`Tellerens nåværende verdi`,type:`number`,category:`ui`,showIf:{counter:!0}},counterMaxLength:{name:`Maks tegn i teller`,description:`Maks antall tegn som kan skrives i skjemaelementet`,type:`number`,category:`ui`,showIf:{counter:!0}},counterPosition:{name:`Tellerplassering`,description:`Telleren sin plassering i forhold til elementet`,type:[`top`,`bottom`],default:`bottom`,category:`ui`,showIf:{counter:!0}},optionalTag:{name:`Vise valgfritt-merking`,description:`Viser en merking som indikerer at feltet er valgfritt`,type:`boolean`,default:!1,category:`ui`},optionalText:{name:`Valgfritt-tekst`,description:`Tekst som vises i valgfritt-merkingen`,type:`string`,default:`Valgfritt`,category:`contents`},requiredTag:{name:`Vise påkrevd-merking`,description:`Viser en merking som indikerer at feltet er påkrevd`,type:`boolean`,default:!1,category:`ui`},requiredText:{name:`Påkrevd-tekst`,description:`Tekst som vises i påkrevd-merkingen`,type:`string`,default:`Må fylles ut`,category:`contents`},tagText:{type:`string`,name:`Tag-tekst`,description:`Tekst som vises i en tag ved siden av label`,category:`ui`},hasError:{name:`Feil`,description:`Indikerer at skjemaelementet har en feil`,type:`boolean`,default:!1,category:`ui`},errorMessage:{name:`Feilmelding`,description:`Feilmelding som vises når skjemaelementet har en feil`,type:`string`,category:`contents`},disabled:{name:`Deaktivert`,description:`Indikerer at skjemaelementet er deaktivert`,type:`boolean`,default:!1,category:`tech`},inline:{name:`Inline`,description:`Indikerer at skjemaelementet skal flyte sammen med sidens innhold`,type:`boolean`,default:!1,category:`ui`},hasFieldset:{name:`Er fieldset`,description:`Indikerer at innholdet er et fieldset`,type:`boolean`,default:!1,category:`ui`},useWrapper:{name:`Bruk wrapper`,description:`Indikerer om skjemaelementet skal bruke en wrapper`,type:`boolean`,displayAsFalse:!0,default:!0,category:`ui`},role:{name:`Rolle`,description:`ARIA-rolle på wrapperen. Settes ikke som standard. Bruk hasFieldset for reelle grupper.`,type:`string`,default:null,category:`accessibility`},size:{name:`Størrelse`,description:`Visuell størrelse. small: kompakt wrapper og felt (42px). xsmall: samme wrapper som small, felt 36px.`,attribute:`input-wrapper-size`,type:[`small`,`medium`,`xsmall`],default:`medium`,category:`ui`}}},f=class extends n.t{constructor(...e){super(...e),this.forId=o.n(),this.label=``,this.helptext=null,this.helptextDropdown=null,this.helptextDropdownButton=null,this.counter=d.props.counter.default,this.counterCurrent=0,this.counterMaxLength=0,this.counterError=null,this.counterPosition=`bottom`,this.optionalTag=d.props.optionalTag.default,this.requiredTag=d.props.requiredTag.default,this.tagText=null,this.hasError=d.props.hasError.default,this.errorMessage=``,this.disabled=d.props.disabled.default,this.inline=d.props.inline.default,this.ariaDescribedby=void 0,this.hasFieldset=d.props.hasFieldset.default,this.role=null,this.useWrapper=d.props.useWrapper.default,this.size=`medium`,this.focusModality=new s.t(this)}updated(e){super.updated(e),this.classList.add(`pkt-inputwrapper`),this.classList.toggle(`pkt-inputwrapper--error`,this.hasError),this.classList.toggle(`pkt-inputwrapper--disabled`,this.disabled),this.classList.toggle(`pkt-inputwrapper--inline`,this.inline),this.classList.toggle(`pkt-inputwrapper--medium`,this.size===`medium`),this.classList.toggle(`pkt-inputwrapper--small`,this.size===`small`),this.classList.toggle(`pkt-inputwrapper--xsmall`,this.size===`xsmall`),this.role?this.setAttribute(`aria-labelledby`,`${this.forId}-label`):this.removeAttribute(`aria-labelledby`)}render(){let r=`pkt-tag pkt-tag--small pkt-tag--thin-text`,o=!!this.helptext||this.hasSlotContent(`helptext`),s=this.ariaDescribedby?this.ariaDescribedby:o?`${this.forId}-helptext`:e.h,c=this.pktStrings.get(`forms`),d=()=>e._`
2
- ${this.tagText?e._`<span class=${r+` pkt-tag--gray`}>${this.tagText}</span>`:e.h}
3
- ${this.optionalTag?e._`<span class=${r+` pkt-tag--blue-light`}
4
- >${this.optionalText??c.optional}</span
5
- >`:e.h}
6
- ${this.requiredTag?e._`<span class=${r+` pkt-tag--beige`}
7
- >${this.requiredText??c.required}</span
8
- >`:e.h}
9
- `,f=()=>this.useWrapper?this.hasFieldset?e._`<legend
10
- class="pkt-inputwrapper__legend"
11
- id="${this.forId}-label"
12
- @click=${this.handleLabelClick}
13
- >
14
- ${this.label} ${d()}
15
- </legend>`:e._`<label
16
- class="pkt-inputwrapper__label"
17
- for="${this.forId}"
18
- id="${this.forId}-label"
19
- @click=${this.handleLabelClick}
20
- >${this.label}${d()}</label
21
- >`:e._`<label for="${this.forId}" class="pkt-sr-only" id="${this.forId}-label">
22
- ${this.label}
23
- </label>`,p=()=>!o&&!this.helptextDropdown?e.h:e._`
24
- <pkt-helptext
25
- ${n.n(this,{helptext:null})}
26
- class="${a.t(this.useWrapper?void 0:`pkt-hide`)}"
27
- .forId=${this.forId}
28
- .helptext=${this.helptext}
29
- .helptextDropdown=${this.helptextDropdown}
30
- .helptextDropdownButton=${this.helptextDropdownButton??c.readMore}
31
- @toggleHelpText=${e=>{this.toggleDropdown(e)}}
32
- ></pkt-helptext>
33
- `,m=()=>{if(!this.counter)return e.h;let n=u(this.counterCurrent,this.counterMaxLength);return e._`<div class="pkt-input__counter" aria-hidden="true">
34
- ${this.counterError?this.counterError:e.h} ${this.counterCurrent||0}
35
- ${this.counterMaxLength?`/${this.counterMaxLength}`:e.h}
36
- </div>
37
- <div class="pkt-sr-only" id=${l(this.forId)} aria-live="polite">
38
- ${n?t.t(this.pktStrings.get(`validation`).counterExceeded,{current:this.counterCurrent??0,max:this.counterMaxLength}):``}
39
- </div>`},h=()=>{if(this.hasError&&this.errorMessage){let t=this.size===`medium`?`small`:`xsmall`;return e._`<div class="pkt-inputwrapper__alert-wrapper">
40
- <pkt-alert
41
- skin="error"
42
- .size=${t}
43
- .role=${`alert`}
44
- id=${`${this.forId}-error`}
45
- aria-live="assertive"
46
- aria-atomic="true"
47
- >
48
- ${i.r(this.errorMessage)}
49
- </pkt-alert>
50
- </div>`}return e.h},g=()=>e._`
51
- ${f()}
52
- ${p()}
53
- ${this.counterPosition===`top`?m():e.h}
54
- <div class="pkt-contents">${n.i(this)}</div>
55
- ${this.counterPosition===`bottom`?m():e.h}
56
- ${h()}
57
- `;return this.hasFieldset?e._`<fieldset class="pkt-inputwrapper__fieldset" aria-describedby="${s}">
58
- ${g()}
59
- </fieldset>`:e._`<div class="pkt-inputwrapper__fieldset">${g()}</div>`}toggleDropdown(e){this.dispatchEvent(new CustomEvent(`toggleHelpText`,{bubbles:!1,detail:{isOpen:e.detail.isOpen}}))}handleLabelClick(){this.dispatchEvent(new CustomEvent(`labelClick`,{bubbles:!0,composed:!0,detail:`label clicked`}))}};e.n([e.u({type:String})],f.prototype,`forId`,void 0),e.n([e.u({type:String})],f.prototype,`label`,void 0),e.n([e.u({type:String})],f.prototype,`helptext`,void 0),e.n([e.u({type:String})],f.prototype,`helptextDropdown`,void 0),e.n([e.u({type:String})],f.prototype,`helptextDropdownButton`,void 0),e.n([e.u({type:Boolean})],f.prototype,`counter`,void 0),e.n([e.u({type:Number})],f.prototype,`counterCurrent`,void 0),e.n([e.u({type:Number})],f.prototype,`counterMaxLength`,void 0),e.n([e.u({type:String})],f.prototype,`counterError`,void 0),e.n([e.u({type:String,reflect:!1})],f.prototype,`counterPosition`,void 0),e.n([e.u({type:Boolean})],f.prototype,`optionalTag`,void 0),e.n([e.u({type:String})],f.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean})],f.prototype,`requiredTag`,void 0),e.n([e.u({type:String})],f.prototype,`requiredText`,void 0),e.n([e.u({type:String})],f.prototype,`tagText`,void 0),e.n([e.u({type:Boolean})],f.prototype,`hasError`,void 0),e.n([e.u({type:String})],f.prototype,`errorMessage`,void 0),e.n([e.u({type:Boolean})],f.prototype,`disabled`,void 0),e.n([e.u({type:Boolean})],f.prototype,`inline`,void 0),e.n([e.u({type:String})],f.prototype,`ariaDescribedby`,void 0),e.n([e.u({type:Boolean})],f.prototype,`hasFieldset`,void 0),e.n([e.u({type:String,reflect:!0})],f.prototype,`role`,void 0),e.n([e.u({type:Boolean,reflect:!0,converter:r.t})],f.prototype,`useWrapper`,void 0),e.n([e.u({type:String,attribute:`input-wrapper-size`})],f.prototype,`size`,void 0);try{e.d(`pkt-input-wrapper`)(f)}catch{console.warn(`Forsøker å definere <pkt-input-wrapper>, men den er allerede definert`)}var p=f;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return p}});