@oslokommune/punkt-elements 19.20.0 → 20.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +71 -0
- package/dist/{alert-UbQzzkXb.js → alert-CA1fDbyc.js} +2 -2
- package/dist/{alert-KxCE28nq.cjs → alert-DkyTTo7S.cjs} +1 -1
- package/dist/{backlink-bbYpIZJI.js → backlink-CDBRcaAu.js} +1 -1
- package/dist/{backlink-CqRcFURx.cjs → backlink-CXOxMeyt.cjs} +1 -1
- package/dist/{breadcrumbs-D7gddV5F.js → breadcrumbs-5oUaCef3.js} +1 -1
- package/dist/{breadcrumbs-C_JR4ZI_.cjs → breadcrumbs-zfUto2U5.cjs} +1 -1
- package/dist/{button-BJ6QLwxJ.js → button-Bswo1C0M.js} +1 -1
- package/dist/{button-pFlrTF2P.cjs → button-bVWAX98x.cjs} +1 -1
- package/dist/{calendar-CYsQEfZn.js → calendar-BOd-9PDd.js} +1 -1
- package/dist/{calendar-Fk5ubNGR.cjs → calendar-CDTCgTJn.cjs} +1 -1
- package/dist/card-BbV4OBqb.cjs +67 -0
- package/dist/{card-CKu696QC.js → card-CKStAH0Q.js} +40 -38
- package/dist/{checkbox-BLmQSdWB.js → checkbox-DIJbuqWm.js} +1 -1
- package/dist/{checkbox-group-DFKzbaHC.js → checkbox-group-DLLbWgQb.js} +2 -2
- package/dist/{checkbox-group-B9TtWVpG.cjs → checkbox-group-Kua6HuRE.cjs} +1 -1
- package/dist/{checkbox-PAtsn1TO.cjs → checkbox-iMOdzpJ_.cjs} +1 -1
- package/dist/{combobox-CJAmzQFD.cjs → combobox-CWL8T3UK.cjs} +1 -1
- package/dist/{combobox-KnYdXXRm.js → combobox-Pxa80TeZ.js} +3 -3
- package/dist/components/card/card.d.ts +0 -10
- package/dist/components/card/index.d.ts +2 -2
- package/dist/components/link/link.d.ts +1 -1
- package/dist/components/linkcard/linkcard.d.ts +0 -1
- package/dist/components/tabs/tabitem.d.ts +2 -1
- package/dist/components/tag/tag.d.ts +5 -11
- package/dist/{consent-BjWx64Gv.cjs → consent-UkinU27V.cjs} +1 -1
- package/dist/{consent-CeJKY2EB.js → consent-p-0n2b9x.js} +1 -1
- package/dist/{datepicker-Cco0rRLa.js → datepicker-BpxUWiIC.js} +8 -6
- package/dist/{datepicker-IMxHS-ex.cjs → datepicker-Cpiu_Nrf.cjs} +2 -2
- package/dist/{fileupload-CjqIhSJ1.cjs → fileupload-DXJtAagE.cjs} +1 -1
- package/dist/{fileupload-BrSWPUcy.js → fileupload-vPDmtXiM.js} +4 -4
- package/dist/{footer-BJCxJUW9.cjs → footer-CpE05IW2.cjs} +1 -1
- package/dist/{footer-DQq09VjI.js → footer-D8t0PCPC.js} +2 -2
- package/dist/{header-C_BUBeOQ.js → header-ChT1hHNA.js} +6 -6
- package/dist/{header-_KjqW2oJ.cjs → header-CiwHNHKD.cjs} +1 -1
- package/dist/{header-menu-BV0XlRez.js → header-menu-BrjsNjBH.js} +1 -1
- package/dist/{header-menu-BiW5cNun.cjs → header-menu-Dq9lwNr1.cjs} +1 -1
- package/dist/{helptext-CL1vxEaL.js → helptext-BFQzrOw4.js} +1 -1
- package/dist/{helptext-B4h3Xlqa.cjs → helptext-Bse1LpRd.cjs} +1 -1
- package/dist/icon-5A378_yh.cjs +1 -0
- package/dist/{icon-C82IxnSO.js → icon-C1oCGwEe.js} +1 -1
- package/dist/{input-wrapper-BNu6kOOn.cjs → input-wrapper-C_Rzwxx7.cjs} +2 -2
- package/dist/{input-wrapper-DowJHbGF.js → input-wrapper-DkpJS1hR.js} +4 -4
- package/dist/{link-D9kjggXZ.js → link-DLPpwjq4.js} +13 -7
- package/dist/{link-DqPFlWxz.cjs → link-pkFJ11Zd.cjs} +3 -3
- package/dist/linkcard-DIG6VYpl.cjs +15 -0
- package/dist/{linkcard-BEmG-2lN.js → linkcard-Dr-r8jBO.js} +22 -18
- package/dist/{loader-lDVe6rUf.js → loader-CFidlqSG.js} +1 -1
- package/dist/{loader-C4fbS8vr.cjs → loader-DTIrOtTo.cjs} +1 -1
- package/dist/messagebox-BLYx3AL7.cjs +16 -0
- package/dist/{messagebox-C8dsqW20.js → messagebox-B_07P0QA.js} +22 -13
- package/dist/{modal-EgQREcb8.cjs → modal-BvTfLfFq.cjs} +1 -1
- package/dist/{modal-D389hSbe.js → modal-CA_M2Ix6.js} +1 -1
- package/dist/{option-group-element-DhYJmGgW.cjs → option-group-element-CVNaBIlP.cjs} +1 -1
- package/dist/{option-group-element-CB0Qqev_.js → option-group-element-DzM8YznZ.js} +1 -1
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +1 -1
- package/dist/pkt-backlink.cjs +1 -1
- package/dist/pkt-backlink.js +1 -1
- package/dist/pkt-breadcrumbs.cjs +1 -1
- package/dist/pkt-breadcrumbs.js +1 -1
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +1 -1
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +1 -1
- package/dist/pkt-checkbox-group.cjs +1 -1
- package/dist/pkt-checkbox-group.js +1 -1
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-fileupload.cjs +1 -1
- package/dist/pkt-fileupload.js +1 -1
- package/dist/pkt-footer.cjs +1 -1
- package/dist/pkt-footer.js +1 -1
- package/dist/pkt-header-menu.cjs +1 -1
- package/dist/pkt-header-menu.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +1 -1
- package/dist/pkt-icon.cjs +1 -1
- package/dist/pkt-icon.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +35 -35
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +1 -1
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +1 -1
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +1 -1
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/pkt-radio-group.cjs +1 -1
- package/dist/pkt-radio-group.js +1 -1
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/pkt-searchinput.cjs +1 -1
- package/dist/pkt-searchinput.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-tabs.cjs +1 -1
- package/dist/pkt-tabs.js +1 -1
- package/dist/pkt-tag.cjs +1 -1
- package/dist/pkt-tag.js +1 -1
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/pkt-timepicker.cjs +1 -1
- package/dist/pkt-timepicker.js +1 -1
- package/dist/{radio-group-CSs8YnEO.js → radio-group-BRY_74od.js} +2 -2
- package/dist/{radio-group-DRNGFfUh.cjs → radio-group-CsUgnEv0.cjs} +1 -1
- package/dist/{radiobutton-Be66H6On.cjs → radiobutton-CQhuG2lj.cjs} +1 -1
- package/dist/{radiobutton-BN67oAvC.js → radiobutton-lHnq8wX_.js} +1 -1
- package/dist/{searchinput-B26-Xp00.js → searchinput-BLGaXkP6.js} +1 -1
- package/dist/{searchinput-Trn6uU2J.cjs → searchinput-TAqMUJ0B.cjs} +1 -1
- package/dist/{select-DZftfjQt.js → select-BvtUxW0Q.js} +1 -1
- package/dist/{select-o6iuy9hC.cjs → select-Dle67Uwv.cjs} +1 -1
- package/dist/shared-types/card.d.ts +5 -17
- package/dist/shared-types/combobox.d.ts +3 -3
- package/dist/shared-types/icon.d.ts +2 -2
- package/dist/shared-types/index.d.ts +10 -8
- package/dist/shared-types/linkcard.d.ts +7 -4
- package/dist/shared-types/messagebox.d.ts +4 -2
- package/dist/shared-types/skin.d.ts +1 -4
- package/dist/shared-types/tag.d.ts +46 -0
- package/dist/{tabs-gRjrFqeG.cjs → tabs-B96Orh6O.cjs} +1 -1
- package/dist/{tabs-Bu9PP33-.js → tabs-BmmTUKuC.js} +1 -1
- package/dist/tag-BZdC0voc.cjs +27 -0
- package/dist/{tag-CtdOrK18.js → tag-Cam7ISOF.js} +14 -81
- package/dist/{textarea-Cc2aQLbm.cjs → textarea-DSX3jMlI.cjs} +1 -1
- package/dist/{textarea-DP7GVL2c.js → textarea-Djp5L2Zd.js} +2 -2
- package/dist/{textinput-Dhwotaxv.js → textinput-CBrOZcvL.js} +2 -2
- package/dist/{textinput-B6FPNOJB.cjs → textinput-CN2F3Q3H.cjs} +1 -1
- package/dist/{timepicker-DxwQ7-Bl.js → timepicker-CT4wfrgQ.js} +2 -2
- package/dist/{timepicker-Ce9hXP0B.cjs → timepicker-CkaJkIGn.cjs} +1 -1
- package/package.json +3 -3
- package/src/components/card/card.test.ts +50 -53
- package/src/components/card/card.ts +14 -24
- package/src/components/card/index.ts +2 -2
- package/src/components/checkbox/checkbox.test.ts +3 -3
- package/src/components/checkbox/checkbox.ts +1 -1
- package/src/components/input-wrapper/input-wrapper.ts +1 -1
- package/src/components/link/link.test.ts +14 -18
- package/src/components/link/link.ts +2 -3
- package/src/components/linkcard/linkcard.test.ts +18 -6
- package/src/components/linkcard/linkcard.ts +5 -7
- package/src/components/messagebox/messagebox.test.ts +14 -1
- package/src/components/messagebox/messagebox.ts +13 -2
- package/src/components/radiobutton/radiobutton.test.ts +1 -1
- package/src/components/radiobutton/radiobutton.ts +1 -1
- package/src/components/tabs/tabitem.ts +6 -2
- package/src/components/tag/tag.test.ts +27 -12
- package/src/components/tag/tag.ts +22 -19
- package/dist/card-Da0JkVcv.cjs +0 -64
- package/dist/icon-B3YGHHa7.cjs +0 -1
- package/dist/linkcard-BMJvjo7R.cjs +0 -14
- package/dist/messagebox-DFaDuvHQ.cjs +0 -13
- package/dist/tag-BgHEzLM3.cjs +0 -27
|
@@ -141,7 +141,7 @@ export class PktInputWrapper extends PktElementWithSlot<Props> implements IPktIn
|
|
|
141
141
|
? html`<span class=${tagClasses + ' pkt-tag--gray'}>${this.tagText}</span>`
|
|
142
142
|
: nothing}
|
|
143
143
|
${this.optionalTag
|
|
144
|
-
? html`<span class=${tagClasses + ' pkt-tag--blue-
|
|
144
|
+
? html`<span class=${tagClasses + ' pkt-tag--blue-pale'}
|
|
145
145
|
>${this.optionalText ?? formStrings.optional}</span
|
|
146
146
|
>`
|
|
147
147
|
: nothing}
|
|
@@ -16,7 +16,7 @@ export interface LinkTestConfig extends BaseTestConfig {
|
|
|
16
16
|
iconName?: string
|
|
17
17
|
iconPosition?: string
|
|
18
18
|
openInNewTab?: boolean
|
|
19
|
-
|
|
19
|
+
rel?: string
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
// Use shared framework
|
|
@@ -63,7 +63,7 @@ describe('PktLink', () => {
|
|
|
63
63
|
await link.updateComplete
|
|
64
64
|
|
|
65
65
|
expect(link.href).toBe('#')
|
|
66
|
-
expect(link.
|
|
66
|
+
expect(link.rel).toBeNull()
|
|
67
67
|
expect(link.iconName).toBeUndefined()
|
|
68
68
|
expect(link.target).toBe('_self')
|
|
69
69
|
})
|
|
@@ -79,14 +79,14 @@ describe('PktLink', () => {
|
|
|
79
79
|
expect(anchor?.href).toBe('https://example.com/')
|
|
80
80
|
})
|
|
81
81
|
|
|
82
|
-
test('sets
|
|
82
|
+
test('sets rel property correctly', async () => {
|
|
83
83
|
const { link } = await createLinkTest({
|
|
84
84
|
href: 'https://example.com',
|
|
85
|
-
|
|
85
|
+
rel: 'noopener noreferrer',
|
|
86
86
|
})
|
|
87
87
|
await link.updateComplete
|
|
88
88
|
|
|
89
|
-
expect(link.
|
|
89
|
+
expect(link.rel).toBe('noopener noreferrer')
|
|
90
90
|
})
|
|
91
91
|
})
|
|
92
92
|
|
|
@@ -116,16 +116,15 @@ describe('PktLink', () => {
|
|
|
116
116
|
})
|
|
117
117
|
})
|
|
118
118
|
|
|
119
|
-
describe('
|
|
120
|
-
test('
|
|
119
|
+
describe('Rel attribute', () => {
|
|
120
|
+
test('passes rel to the anchor', async () => {
|
|
121
121
|
const { link } = await createLinkTest({
|
|
122
122
|
href: 'https://example.com',
|
|
123
|
-
|
|
123
|
+
rel: 'noopener noreferrer',
|
|
124
124
|
})
|
|
125
125
|
await link.updateComplete
|
|
126
126
|
|
|
127
127
|
const anchor = link.querySelector('a')
|
|
128
|
-
expect(anchor?.classList.contains('pkt-link--external')).toBe(true)
|
|
129
128
|
expect(anchor?.rel).toBe('noopener noreferrer')
|
|
130
129
|
})
|
|
131
130
|
|
|
@@ -171,19 +170,16 @@ describe('PktLink', () => {
|
|
|
171
170
|
expect(anchor?.href).toBe('https://updated.com/')
|
|
172
171
|
})
|
|
173
172
|
|
|
174
|
-
test('updates
|
|
173
|
+
test('updates rel property dynamically', async () => {
|
|
175
174
|
const { link } = await createLinkTest({
|
|
176
175
|
href: 'https://example.com',
|
|
177
176
|
})
|
|
178
177
|
await link.updateComplete
|
|
179
178
|
|
|
180
|
-
link.
|
|
179
|
+
link.rel = 'noopener noreferrer'
|
|
181
180
|
await link.updateComplete
|
|
182
181
|
|
|
183
|
-
expect(link.
|
|
184
|
-
const anchor = link.querySelector('a')
|
|
185
|
-
expect(anchor?.classList.contains('pkt-link--external')).toBe(true)
|
|
186
|
-
expect(anchor?.rel).toBe('noopener noreferrer')
|
|
182
|
+
expect(link.querySelector('a')?.rel).toBe('noopener noreferrer')
|
|
187
183
|
})
|
|
188
184
|
})
|
|
189
185
|
|
|
@@ -206,7 +202,7 @@ describe('PktLink', () => {
|
|
|
206
202
|
href: 'https://external-site.com',
|
|
207
203
|
iconName: 'external',
|
|
208
204
|
iconPosition: 'right',
|
|
209
|
-
|
|
205
|
+
rel: 'noopener noreferrer',
|
|
210
206
|
target: '_blank',
|
|
211
207
|
content: 'Complex External Link',
|
|
212
208
|
})
|
|
@@ -214,11 +210,11 @@ describe('PktLink', () => {
|
|
|
214
210
|
|
|
215
211
|
expect(link.href).toBe('https://external-site.com')
|
|
216
212
|
expect(link.iconName).toBe('external')
|
|
217
|
-
expect(link.
|
|
213
|
+
expect(link.rel).toBe('noopener noreferrer')
|
|
218
214
|
expect(link.target).toBe('_blank')
|
|
219
215
|
|
|
220
216
|
const anchor = link.querySelector('a')
|
|
221
|
-
expect(anchor?.
|
|
217
|
+
expect(anchor?.rel).toBe('noopener noreferrer')
|
|
222
218
|
expect(anchor?.classList.contains('pkt-link--icon-right')).toBe(true)
|
|
223
219
|
})
|
|
224
220
|
})
|
|
@@ -17,7 +17,7 @@ export class PktLink extends PktElementWithSlot {
|
|
|
17
17
|
@property({ type: String, reflect: true }) href: string = specDefaults.href.default as string
|
|
18
18
|
@property({ type: String, reflect: true }) iconName: string | undefined = undefined
|
|
19
19
|
@property({ type: String, reflect: true }) iconPosition: string | undefined = undefined
|
|
20
|
-
@property({ type:
|
|
20
|
+
@property({ type: String, reflect: true }) rel: string | null = null
|
|
21
21
|
@property({ type: String, reflect: true }) target: string | null =
|
|
22
22
|
specDefaults.target.default as string
|
|
23
23
|
|
|
@@ -28,7 +28,6 @@ export class PktLink extends PktElementWithSlot {
|
|
|
28
28
|
(!!this.iconName && this.iconPosition === 'left') ||
|
|
29
29
|
!!(this.iconName && !this.iconPosition),
|
|
30
30
|
'pkt-link--icon-right': !!this.iconName && this.iconPosition === 'right',
|
|
31
|
-
'pkt-link--external': this.external,
|
|
32
31
|
}
|
|
33
32
|
const target = this.target && this.target !== '_self' ? this.target : nothing
|
|
34
33
|
|
|
@@ -36,7 +35,7 @@ export class PktLink extends PktElementWithSlot {
|
|
|
36
35
|
class=${classMap(classes)}
|
|
37
36
|
href=${this.href}
|
|
38
37
|
target=${target}
|
|
39
|
-
|
|
38
|
+
rel=${this.rel || nothing}
|
|
40
39
|
>${this.iconName
|
|
41
40
|
? html`<pkt-icon name=${this.iconName} class="pkt-link__icon"></pkt-icon>`
|
|
42
41
|
: ''}${slotContent(this)}</a
|
|
@@ -28,13 +28,14 @@ expect.extend(toHaveNoViolations)
|
|
|
28
28
|
|
|
29
29
|
// Test data constants
|
|
30
30
|
const VALID_SKINS: TLinkCardSkin[] = [
|
|
31
|
-
'
|
|
32
|
-
'
|
|
31
|
+
'gray',
|
|
32
|
+
'outlined',
|
|
33
|
+
'transparent',
|
|
34
|
+
'white',
|
|
33
35
|
'blue',
|
|
34
|
-
'beige',
|
|
35
36
|
'green',
|
|
36
|
-
'
|
|
37
|
-
'
|
|
37
|
+
'beige',
|
|
38
|
+
'normal',
|
|
38
39
|
'gray-outline',
|
|
39
40
|
]
|
|
40
41
|
|
|
@@ -65,7 +66,6 @@ describe('PktLinkCard', () => {
|
|
|
65
66
|
expect(linkCard.iconName).toBe('')
|
|
66
67
|
expect(linkCard.openInNewTab).toBe(false)
|
|
67
68
|
expect(linkCard.skin).toBeUndefined()
|
|
68
|
-
expect(linkCard.external).toBe(false)
|
|
69
69
|
|
|
70
70
|
expect(link.getAttribute('href')).toBe('#')
|
|
71
71
|
expect(link.getAttribute('target')).toBe('_self')
|
|
@@ -221,6 +221,18 @@ describe('PktLinkCard', () => {
|
|
|
221
221
|
}
|
|
222
222
|
})
|
|
223
223
|
|
|
224
|
+
test('keeps light-only skins in light mode', async () => {
|
|
225
|
+
for (const skin of ['white', 'blue', 'green', 'beige'] as const) {
|
|
226
|
+
const { link } = await createLinkCardTest({ skin })
|
|
227
|
+
expect(link).toHaveAttribute('data-mode', 'light')
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
for (const skin of ['gray', 'outlined', 'transparent', 'normal', 'gray-outline'] as const) {
|
|
231
|
+
const { link } = await createLinkCardTest({ skin })
|
|
232
|
+
expect(link).not.toHaveAttribute('data-mode')
|
|
233
|
+
}
|
|
234
|
+
})
|
|
235
|
+
|
|
224
236
|
test('handles skin property changes', async () => {
|
|
225
237
|
const { linkCard, link } = await createLinkCardTest({ skin: 'blue' })
|
|
226
238
|
|
|
@@ -4,7 +4,7 @@ import { PktElementWithSlot } from '@/base-elements/element-with-slot'
|
|
|
4
4
|
import { slotContent } from '@/directives/slot-content'
|
|
5
5
|
import '@/components/icon'
|
|
6
6
|
import { ifDefined } from 'lit/directives/if-defined.js'
|
|
7
|
-
import type
|
|
7
|
+
import { LINKCARD_LIGHT_ONLY_SKINS, type IPktLinkCardBase, type TLinkCardSkin } from 'shared-types'
|
|
8
8
|
|
|
9
9
|
export type { TLinkCardSkin }
|
|
10
10
|
|
|
@@ -14,7 +14,6 @@ export class PktLinkCard extends PktElementWithSlot<IPktLinkCard> implements IPk
|
|
|
14
14
|
@property({ type: String, reflect: true }) title: string = ''
|
|
15
15
|
@property({ type: String, reflect: true }) href: string = '#'
|
|
16
16
|
@property({ type: String, reflect: true }) iconName: string = ''
|
|
17
|
-
@property({ type: Boolean, reflect: true }) external: boolean = false
|
|
18
17
|
@property({ type: Boolean, reflect: true }) openInNewTab: boolean = false
|
|
19
18
|
@property({ type: String, reflect: true }) skin?: TLinkCardSkin = undefined
|
|
20
19
|
|
|
@@ -23,10 +22,6 @@ export class PktLinkCard extends PktElementWithSlot<IPktLinkCard> implements IPk
|
|
|
23
22
|
.filter(Boolean)
|
|
24
23
|
.join(' ')
|
|
25
24
|
|
|
26
|
-
const titleClasses = ['pkt-linkcard__title', this.external && 'pkt-link pkt-link--external']
|
|
27
|
-
.filter(Boolean)
|
|
28
|
-
.join(' ')
|
|
29
|
-
|
|
30
25
|
const s = this.pktStrings.get('linkcard')
|
|
31
26
|
const newTabLabel = this.openInNewTab ? s.openInNewTab : ''
|
|
32
27
|
|
|
@@ -34,11 +29,14 @@ export class PktLinkCard extends PktElementWithSlot<IPktLinkCard> implements IPk
|
|
|
34
29
|
<a
|
|
35
30
|
href=${this.href}
|
|
36
31
|
class=${classes}
|
|
32
|
+
data-mode=${ifDefined(
|
|
33
|
+
this.skin && LINKCARD_LIGHT_ONLY_SKINS.includes(this.skin) ? 'light' : undefined,
|
|
34
|
+
)}
|
|
37
35
|
target=${this.openInNewTab ? '_blank' : '_self'}
|
|
38
36
|
rel=${ifDefined(this.openInNewTab ? 'noopener noreferrer' : undefined)}
|
|
39
37
|
>
|
|
40
38
|
${this.iconName && html`<pkt-icon class="pkt-link__icon" name="${this.iconName}"></pkt-icon>`}
|
|
41
|
-
${this.title && html`<div class
|
|
39
|
+
${this.title && html`<div class="pkt-linkcard__title">${this.title}</div>`}
|
|
42
40
|
${newTabLabel ? html`<span class="pkt-sr-only">${newTabLabel}</span>` : ''}
|
|
43
41
|
|
|
44
42
|
<div class="pkt-linkcard__text">${slotContent(this)}</div>
|
|
@@ -72,7 +72,11 @@ describe('PktMessagebox', () => {
|
|
|
72
72
|
expect(messagebox.closable).toBe(false)
|
|
73
73
|
expect(messagebox.compact).toBe(false)
|
|
74
74
|
expect(messagebox.title).toBe('')
|
|
75
|
-
expect(messagebox.skin).toBe('
|
|
75
|
+
expect(messagebox.skin).toBe('gray')
|
|
76
|
+
|
|
77
|
+
const messageboxDiv = messagebox.querySelector('.pkt-messagebox')
|
|
78
|
+
expect(messageboxDiv?.classList.contains('pkt-messagebox--gray')).toBe(true)
|
|
79
|
+
expect(messageboxDiv?.hasAttribute('data-mode')).toBe(false)
|
|
76
80
|
})
|
|
77
81
|
|
|
78
82
|
test('sets properties correctly', async () => {
|
|
@@ -91,6 +95,15 @@ describe('PktMessagebox', () => {
|
|
|
91
95
|
})
|
|
92
96
|
|
|
93
97
|
describe('Skin variants', () => {
|
|
98
|
+
test('keeps light-only skins in light mode', async () => {
|
|
99
|
+
for (const skin of ['beige', 'blue', 'red', 'green'] as const) {
|
|
100
|
+
const { messagebox } = await createMessageboxTest({ skin })
|
|
101
|
+
|
|
102
|
+
const messageboxDiv = messagebox.querySelector('.pkt-messagebox')
|
|
103
|
+
expect(messageboxDiv?.getAttribute('data-mode')).toBe('light')
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
|
|
94
107
|
test('applies beige skin correctly', async () => {
|
|
95
108
|
const { messagebox } = await createMessageboxTest({ skin: 'beige' })
|
|
96
109
|
|
|
@@ -2,11 +2,17 @@ import { PktElementWithSlot } from '@/base-elements/element-with-slot'
|
|
|
2
2
|
import { slotContent } from '@/directives/slot-content'
|
|
3
3
|
import { html, nothing, PropertyValues } from 'lit'
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js'
|
|
5
|
+
import { ifDefined } from 'lit/directives/if-defined.js'
|
|
5
6
|
import { customElement, property, state } from 'lit/decorators.js'
|
|
6
7
|
|
|
7
8
|
import '@/components/icon'
|
|
8
9
|
import { updateClassAttribute } from '@/utils/classutils'
|
|
9
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
MESSAGEBOX_DEFAULTS,
|
|
12
|
+
MESSAGEBOX_LIGHT_ONLY_SKINS,
|
|
13
|
+
type IPktMessageboxBase,
|
|
14
|
+
type TMessageboxSkin,
|
|
15
|
+
} from 'shared-types'
|
|
10
16
|
|
|
11
17
|
export type { TMessageboxSkin }
|
|
12
18
|
|
|
@@ -48,7 +54,12 @@ export class PktMessagebox extends PktElementWithSlot implements IPktMessagebox
|
|
|
48
54
|
'pkt-hide': this._isClosed,
|
|
49
55
|
}
|
|
50
56
|
|
|
51
|
-
return html`<div
|
|
57
|
+
return html`<div
|
|
58
|
+
class=${classMap(classes)}
|
|
59
|
+
data-mode=${ifDefined(
|
|
60
|
+
this.skin && MESSAGEBOX_LIGHT_ONLY_SKINS.includes(this.skin) ? 'light' : undefined,
|
|
61
|
+
)}
|
|
62
|
+
>
|
|
52
63
|
${this.closable
|
|
53
64
|
? html`<div class="pkt-messagebox__close">
|
|
54
65
|
<button
|
|
@@ -187,7 +187,7 @@ describe('pkt-radiobutton', () => {
|
|
|
187
187
|
optionalTag: true,
|
|
188
188
|
})
|
|
189
189
|
|
|
190
|
-
const tag = radiobutton.querySelector('.pkt-tag--blue-
|
|
190
|
+
const tag = radiobutton.querySelector('.pkt-tag--blue-pale')
|
|
191
191
|
expect(tag).toBeInTheDocument()
|
|
192
192
|
expect(tag?.textContent).toBe('Valgfritt')
|
|
193
193
|
})
|
|
@@ -97,7 +97,7 @@ export class PktRadioButton extends PktInputElement<Props> implements IPktRadioB
|
|
|
97
97
|
}
|
|
98
98
|
${
|
|
99
99
|
this.optionalTag
|
|
100
|
-
? html`<span class=${tagClasses + ' pkt-tag--blue-
|
|
100
|
+
? html`<span class=${tagClasses + ' pkt-tag--blue-pale'}
|
|
101
101
|
>${this.optionalText ?? formStrings.optional}</span
|
|
102
102
|
>`
|
|
103
103
|
: nothing
|
|
@@ -6,9 +6,10 @@ import { consume } from '@lit/context'
|
|
|
6
6
|
import { createRef, Ref, ref } from 'lit/directives/ref.js'
|
|
7
7
|
import { ifDefined } from 'lit/directives/if-defined.js'
|
|
8
8
|
import { tabsContext, type TabsContext } from './tabs-context'
|
|
9
|
+
import type { TTagSkin } from 'shared-types'
|
|
9
10
|
import '@/components/tag'
|
|
10
11
|
|
|
11
|
-
export type TSkin =
|
|
12
|
+
export type TSkin = TTagSkin
|
|
12
13
|
|
|
13
14
|
export interface IPktTabItem {
|
|
14
15
|
active?: boolean
|
|
@@ -85,7 +86,10 @@ export class PktTabItem extends PktElementWithSlot<IPktTabItem> implements IPktT
|
|
|
85
86
|
render() {
|
|
86
87
|
const useArrowNav = this.context?.useArrowNav ?? true
|
|
87
88
|
const isActive = this.active && !this.disabled
|
|
88
|
-
const commonClasses = [
|
|
89
|
+
const commonClasses = [
|
|
90
|
+
isActive ? 'active' : '',
|
|
91
|
+
this.disabled ? 'pkt-tabs__item--disabled' : '',
|
|
92
|
+
]
|
|
89
93
|
.filter(Boolean)
|
|
90
94
|
.join(' ')
|
|
91
95
|
const role = useArrowNav ? 'tab' : undefined
|
|
@@ -2,6 +2,7 @@ import '@testing-library/jest-dom'
|
|
|
2
2
|
import { axe, toHaveNoViolations } from 'jest-axe'
|
|
3
3
|
import { fireEvent } from '@testing-library/dom'
|
|
4
4
|
import { vi } from 'vitest'
|
|
5
|
+
import { TAG_SKINS, TAG_STATES } from 'shared-types'
|
|
5
6
|
import { createElementTest, BaseTestConfig } from '../../tests/test-framework'
|
|
6
7
|
import { CustomElementFor } from '../../tests/component-registry'
|
|
7
8
|
import { type IPktTag } from './tag'
|
|
@@ -25,17 +26,8 @@ export const createTagTest = async (config: TagTestConfig = {}) => {
|
|
|
25
26
|
expect.extend(toHaveNoViolations)
|
|
26
27
|
|
|
27
28
|
// Test data constants
|
|
28
|
-
const VALID_SKINS =
|
|
29
|
-
|
|
30
|
-
'blue-dark',
|
|
31
|
-
'blue-light',
|
|
32
|
-
'green',
|
|
33
|
-
'red',
|
|
34
|
-
'yellow',
|
|
35
|
-
'beige',
|
|
36
|
-
'gray',
|
|
37
|
-
'grey',
|
|
38
|
-
] as const
|
|
29
|
+
const VALID_SKINS = TAG_SKINS
|
|
30
|
+
const VALID_STATES = TAG_STATES
|
|
39
31
|
const VALID_SIZES = ['small', 'medium', 'large'] as const
|
|
40
32
|
const VALID_TYPES = ['button', 'reset', 'submit'] as const
|
|
41
33
|
|
|
@@ -54,7 +46,9 @@ describe('PktTag', () => {
|
|
|
54
46
|
const { tag } = await createTagTest()
|
|
55
47
|
expect(tag.closeTag).toBe(false)
|
|
56
48
|
expect(tag.size).toBe('medium')
|
|
57
|
-
expect(tag.skin).toBe('
|
|
49
|
+
expect(tag.skin).toBe('gray')
|
|
50
|
+
expect(tag.state).toBe(null)
|
|
51
|
+
expect(tag.textStyle).toBe('normal-text')
|
|
58
52
|
expect(tag.type).toBe('button')
|
|
59
53
|
})
|
|
60
54
|
|
|
@@ -76,6 +70,22 @@ describe('PktTag', () => {
|
|
|
76
70
|
})
|
|
77
71
|
})
|
|
78
72
|
|
|
73
|
+
describe('Forced States', () => {
|
|
74
|
+
test('applies forced state classes correctly', async () => {
|
|
75
|
+
for (const state of VALID_STATES) {
|
|
76
|
+
const { tag } = await createTagTest({ state })
|
|
77
|
+
const tagElement = tag.querySelector('span') || tag.querySelector('button')
|
|
78
|
+
expect(tagElement).toHaveClass(`pkt-tag--${state}`)
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
test('applies no state class by default', async () => {
|
|
83
|
+
const { tag } = await createTagTest()
|
|
84
|
+
const tagElement = tag.querySelector('span')
|
|
85
|
+
expect(tagElement?.className).not.toContain('pkt-tag--null')
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
|
|
79
89
|
describe('Size Variations', () => {
|
|
80
90
|
test('applies different size classes correctly', async () => {
|
|
81
91
|
for (const size of VALID_SIZES) {
|
|
@@ -147,6 +157,11 @@ describe('PktTag', () => {
|
|
|
147
157
|
})
|
|
148
158
|
|
|
149
159
|
describe('Text Style', () => {
|
|
160
|
+
test('applies normal-text class by default', async () => {
|
|
161
|
+
const { tag } = await createTagTest()
|
|
162
|
+
expect(tag.querySelector('.pkt-tag')).toHaveClass('pkt-tag--normal-text')
|
|
163
|
+
})
|
|
164
|
+
|
|
150
165
|
test('applies text style class when provided', async () => {
|
|
151
166
|
const { tag } = await createTagTest({ textStyle: 'thin-text' })
|
|
152
167
|
const tagElement = tag.querySelector('span') || tag.querySelector('button')
|
|
@@ -3,26 +3,26 @@ import { customElement, property, state } from 'lit/decorators.js'
|
|
|
3
3
|
import { html, PropertyValues } from 'lit'
|
|
4
4
|
import { PktElementWithSlot } from '@/base-elements/element-with-slot'
|
|
5
5
|
import { getSlotManager, slotContent } from '@/directives/slot-content'
|
|
6
|
-
import specs from 'componentSpecs/tag.json'
|
|
7
6
|
|
|
8
7
|
import '@/components/icon'
|
|
9
|
-
import
|
|
8
|
+
import {
|
|
9
|
+
TAG_DEFAULTS,
|
|
10
|
+
type IPktTagBase,
|
|
11
|
+
type THTMLButtonType,
|
|
12
|
+
type TTagSkin,
|
|
13
|
+
type TTagState,
|
|
14
|
+
type TTagTextStyle,
|
|
15
|
+
type TPktSizeBase,
|
|
16
|
+
} from 'shared-types'
|
|
10
17
|
import { PktIconName } from '@oslokommune/punkt-assets/dist/icons/icon'
|
|
11
18
|
import { ifDefined } from 'lit/directives/if-defined.js'
|
|
12
|
-
import { formatString
|
|
19
|
+
import { formatString } from 'shared-strings'
|
|
13
20
|
|
|
14
|
-
export type TTagSkin
|
|
15
|
-
'blue' | 'blue-dark' | 'blue-light' | 'green' | 'red' | 'yellow' | 'beige' | 'gray' | 'grey'
|
|
21
|
+
export type { TTagSkin, TTagState }
|
|
16
22
|
export type TTagType = THTMLButtonType
|
|
17
23
|
|
|
18
|
-
export interface IPktTag extends
|
|
19
|
-
closeTag?: boolean
|
|
20
|
-
size?: TPktSizeBase
|
|
21
|
-
skin?: TTagSkin
|
|
22
|
-
textStyle?: string | null
|
|
24
|
+
export interface IPktTag extends IPktTagBase {
|
|
23
25
|
iconName?: PktIconName
|
|
24
|
-
type?: TTagType
|
|
25
|
-
ariaLabel?: IAriaAttributes['aria-label'] | null
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export class PktTag extends PktElementWithSlot<IPktTag> implements IPktTag {
|
|
@@ -34,13 +34,14 @@ export class PktTag extends PktElementWithSlot<IPktTag> implements IPktTag {
|
|
|
34
34
|
/**
|
|
35
35
|
* Element attributes
|
|
36
36
|
*/
|
|
37
|
-
@property({ type: Boolean, reflect: true }) closeTag: boolean =
|
|
38
|
-
@property({ type: String, reflect: true }) size: TPktSizeBase =
|
|
39
|
-
|
|
40
|
-
@property({ type: String, reflect: true })
|
|
41
|
-
@property({ type: String, reflect: true }) textStyle:
|
|
37
|
+
@property({ type: Boolean, reflect: true }) closeTag: boolean = TAG_DEFAULTS.closeTag
|
|
38
|
+
@property({ type: String, reflect: true }) size: TPktSizeBase = TAG_DEFAULTS.size
|
|
39
|
+
@property({ type: String, reflect: true }) skin: TTagSkin = TAG_DEFAULTS.skin
|
|
40
|
+
@property({ type: String, reflect: true }) state: TTagState | null = null
|
|
41
|
+
@property({ type: String, reflect: true }) textStyle: TTagTextStyle | null =
|
|
42
|
+
TAG_DEFAULTS.textStyle
|
|
42
43
|
@property({ type: String, reflect: true }) iconName: string | undefined = undefined
|
|
43
|
-
@property({ type: String }) type: TTagType =
|
|
44
|
+
@property({ type: String }) type: TTagType = TAG_DEFAULTS.type
|
|
44
45
|
@property({ type: String }) ariaLabel: string | null = null
|
|
45
46
|
@property({ type: Number, attribute: 'button-tabindex' }) buttonTabindex: number | undefined =
|
|
46
47
|
undefined
|
|
@@ -78,7 +79,7 @@ export class PktTag extends PktElementWithSlot<IPktTag> implements IPktTag {
|
|
|
78
79
|
this.dispatchEvent(
|
|
79
80
|
new CustomEvent('close', { detail: { origin: event }, bubbles: false, composed: true }),
|
|
80
81
|
)
|
|
81
|
-
//
|
|
82
|
+
// Deprecated: beholdt for eldre Vue-oppsett. Bruk `close`, `on-close` fjernes i en senere hovedversjon.
|
|
82
83
|
this.dispatchEvent(
|
|
83
84
|
new CustomEvent('on-close', { detail: { origin: event }, bubbles: false, composed: true }),
|
|
84
85
|
)
|
|
@@ -89,6 +90,7 @@ export class PktTag extends PktElementWithSlot<IPktTag> implements IPktTag {
|
|
|
89
90
|
'pkt-tag': true,
|
|
90
91
|
[`pkt-tag--${this.size}`]: !!this.size,
|
|
91
92
|
[`pkt-tag--${this.skin}`]: !!this.skin,
|
|
93
|
+
[`pkt-tag--${this.state}`]: !!this.state,
|
|
92
94
|
[`pkt-tag--${this.textStyle}`]: !!this.textStyle,
|
|
93
95
|
}
|
|
94
96
|
|
|
@@ -97,6 +99,7 @@ export class PktTag extends PktElementWithSlot<IPktTag> implements IPktTag {
|
|
|
97
99
|
[`pkt-tag--${this.textStyle}`]: !!this.textStyle,
|
|
98
100
|
[`pkt-tag--${this.size}`]: !!this.size,
|
|
99
101
|
[`pkt-tag--${this.skin}`]: !!this.skin,
|
|
102
|
+
[`pkt-tag--${this.state}`]: !!this.state,
|
|
100
103
|
'pkt-hide': this._isClosed,
|
|
101
104
|
}
|
|
102
105
|
|
package/dist/card-Da0JkVcv.cjs
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
const e=require("./element-CEarCnHH.cjs"),t=require("./class-map-C82GtM1w.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-CeKuRE3_.cjs");require("./shared-types-BvRk9kiK.cjs"),require("./icon-B3YGHHa7.cjs");const i=require("./if-defined-Ci4ZQsgL.cjs");require("./tag-BgHEzLM3.cjs");var a=[`outlined`,`outlined-beige`,`gray`,`blue`,`beige`,`green`],o={headingLevel:3,layout:`vertical`,skin:`outlined`,padding:`default`,tagPosition:`top`,openLinkInNewTab:!1,borderOnHover:!0,zoom:!1,imageShape:`square`,restrictImageHeight:!1},s=class extends r.t{constructor(...e){super(...e),this.ariaLabel=``,this.metaLead=null,this.borderOnHover=o.borderOnHover,this.zoom=o.zoom,this.imageAspect=null,this.restrictImageHeight=o.restrictImageHeight,this.clickCardLink=null,this.metaTrail=null,this.layout=o.layout,this.heading=``,this.headingLevel=o.headingLevel,this.image={src:``,alt:``},this.imageShape=o.imageShape,this.openLinkInNewTab=o.openLinkInNewTab,this.padding=o.padding,this.skin=o.skin,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,"pkt-card--zoom":this.zoom},r=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=${i.t(this.clickCardLink?r: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,[`pkt-card__image-aspect-${this.imageAspect}`]:!!this.imageAspect,"pkt-card__image-restricted":this.restrictImageHeight};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
|
-
`}renderHeadingTag(t,n){let r=this.headingLevel&&this.headingLevel>=1&&this.headingLevel<=6?this.headingLevel:3,i=`pkt-heading pkt-heading--medium pkt-heading--fw-regular ${t}`;switch(r){case 1:return e._`<h1 class=${i}>${n}</h1>`;case 2:return e._`<h2 class=${i}>${n}</h2>`;case 4:return e._`<h4 class=${i}>${n}</h4>`;case 5:return e._`<h5 class=${i}>${n}</h5>`;case 6:return e._`<h6 class=${i}>${n}</h6>`;default:return e._`<h3 class=${i}>${n}</h3>`}}renderHeading(){return!this.heading||this.clickCardLink?e.h:this.renderHeadingTag(`pkt-card__heading`,this.heading)}renderLinkHeading(){return this.clickCardLink?this.renderHeadingTag(`pkt-card__link-heading pkt-card__heading`,e._`<a
|
|
22
|
-
class="pkt-card__link"
|
|
23
|
-
href=${this.clickCardLink}
|
|
24
|
-
target=${this.openLinkInNewTab?`_blank`:`_self`}
|
|
25
|
-
rel=${i.t(this.openLinkInNewTab?`noopener noreferrer`:void 0)}
|
|
26
|
-
>${this.heading}</a
|
|
27
|
-
>`):e.h}renderSubheading(){return e._`
|
|
28
|
-
${this.subheading?e._` <p class="pkt-card__subheading ">${this.subheading}</p> `:e.h}
|
|
29
|
-
`}renderHeader(){let t=!!this.heading||!!this.subheading;return e._`
|
|
30
|
-
${t?e._`
|
|
31
|
-
<header class="pkt-card__header">
|
|
32
|
-
${this.renderHeading()}
|
|
33
|
-
${this.renderLinkHeading()}
|
|
34
|
-
${this.renderSubheading()}
|
|
35
|
-
</header>
|
|
36
|
-
`:e.h}
|
|
37
|
-
`}renderTags(){let r={"pkt-card__tags":!0,[`pkt-card__tags-${this.tagPosition}`]:this.tagPosition};return e._`
|
|
38
|
-
${this.tags.length>0?e._`
|
|
39
|
-
<div
|
|
40
|
-
class=${t.t(r)}
|
|
41
|
-
role="list"
|
|
42
|
-
aria-label=${n.n(this.tags.length,this.pktStrings.get(`card`).tagsLabelOne,this.pktStrings.get(`card`).tagsLabelOther)}
|
|
43
|
-
>
|
|
44
|
-
${this.tags.map(t=>e._`
|
|
45
|
-
<pkt-tag
|
|
46
|
-
role="listitem"
|
|
47
|
-
textStyle="normal-text"
|
|
48
|
-
size="medium"
|
|
49
|
-
skin=${i.t(t.skin)}
|
|
50
|
-
iconName=${i.t(t.iconName)}
|
|
51
|
-
>
|
|
52
|
-
<span>${t.text}</span>
|
|
53
|
-
</pkt-tag>
|
|
54
|
-
`)}
|
|
55
|
-
</div>
|
|
56
|
-
`:e.h}
|
|
57
|
-
`}renderSlot(){return e._`<section class="pkt-card__content">${r.i(this)}</section>`}renderMetadata(){return e._`
|
|
58
|
-
${this.metaLead||this.metaTrail?e._`
|
|
59
|
-
<footer class="pkt-card__metadata">
|
|
60
|
-
${this.metaLead?e._`<span class="pkt-card__metadata-lead">${this.metaLead}</span>`:e.h}
|
|
61
|
-
${this.metaTrail?e._`<span class="pkt-card__metadata-trail">${this.metaTrail}</span>`:e.h}
|
|
62
|
-
</footer>
|
|
63
|
-
`:e.h}
|
|
64
|
-
`}};e.n([e.u({type:String})],s.prototype,`ariaLabel`,void 0),e.n([e.u({type:String})],s.prototype,`metaLead`,void 0),e.n([e.u({type:Boolean})],s.prototype,`borderOnHover`,void 0),e.n([e.u({type:Boolean})],s.prototype,`zoom`,void 0),e.n([e.u({type:String})],s.prototype,`imageAspect`,void 0),e.n([e.u({type:Boolean})],s.prototype,`restrictImageHeight`,void 0),e.n([e.u({type:String,reflect:!0})],s.prototype,`clickCardLink`,void 0),e.n([e.u({type:String})],s.prototype,`metaTrail`,void 0),e.n([e.u({type:String})],s.prototype,`layout`,void 0),e.n([e.u({type:String})],s.prototype,`heading`,void 0),e.n([e.u({type:Number,attribute:`headinglevel`})],s.prototype,`headingLevel`,void 0),e.n([e.u({type:Object})],s.prototype,`image`,void 0),e.n([e.u({type:String})],s.prototype,`imageShape`,void 0),e.n([e.u({type:Boolean})],s.prototype,`openLinkInNewTab`,void 0),e.n([e.u({type:String})],s.prototype,`padding`,void 0),e.n([e.u({type:String,converter:{fromAttribute:e=>{let t=a;return e&&t.includes(e)?e:(e&&!t.includes(e)&&console.warn(`Invalid skin value "${e}". Using default skin "${o.skin}".`),o.skin)},toAttribute:e=>e}})],s.prototype,`skin`,void 0),e.n([e.u({type:String})],s.prototype,`subheading`,void 0),e.n([e.u({type:String})],s.prototype,`tagPosition`,void 0),e.n([e.u({type:Array})],s.prototype,`tags`,void 0);try{e.d(`pkt-card`)(s)}catch{console.warn(`Forsøker å definere <pkt-card>, 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}});
|
package/dist/icon-B3YGHHa7.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./element-CEarCnHH.cjs");require("./shared-types-BvRk9kiK.cjs");var t=`https://punkt-cdn.oslo.kommune.no/latest/icons/`,n=`https://punkt-cdn.oslo.kommune.no/latest/animations/`,r={name:``,path:t},i=class extends e.p{constructor(t){if(super(t),this.it=e.h,t.type!==e.m.CHILD)throw Error(this.constructor.directiveName+`() can only be used in child bindings`)}render(t){if(t===e.h||t==null)return this._t=void 0,this.it=t;if(t===e.g)return t;if(typeof t!=`string`)throw Error(this.constructor.directiveName+`() called with a non-string value`);if(t===this.it)return this._t;this.it=t;let n=[t];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}};i.directiveName=`unsafeHTML`,i.resultType=1;var a=e.f(i),o=class extends i{};o.directiveName=`unsafeSVG`,o.resultType=2;var s=e.f(o);typeof window<`u`&&(window.pktFetch=window.pktFetch===void 0?fetch:window.pktFetch,window.pktIconPath=window.pktIconPath||r.path);var c=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"></svg>`,l={},u=2,d=1500,f=(()=>{try{return typeof Storage<`u`&&typeof sessionStorage<`u`}catch{return!1}})(),p=e=>window.pktFetch(e).then(t=>{if(!t.ok)throw Error(`Missing icon: `+e);return t.text()}),m=async(e,t=u)=>{try{return await p(e)}catch{return t>0?(await new Promise(e=>setTimeout(e,d)),m(e,t-1)):(console.error(`Failed to fetch icon: `+e),c)}},h=async(e,t)=>{let n=t+e+`.svg`;return f&&sessionStorage.getItem(n)?sessionStorage.getItem(n):n in l?l[n]:typeof window<`u`&&typeof window.pktFetch==`function`?(l[n]=m(n).then(e=>(e!==c&&f&&sessionStorage.setItem(n,e),delete l[n],e)),l[n]):c},g=class extends e.t{constructor(...e){super(...e),this.path=typeof window<`u`?window.pktIconPath:r.path,this.name=r.name,this.ariaHidden=null,this.ariaLabel=null,this.icon=s(c),this._updatedProps=[]}get effectiveAriaHidden(){return this.ariaHidden!==null&&this.ariaHidden!==void 0?this.ariaHidden===``||this.ariaHidden===`true`:!this.ariaLabel}get effectiveAriaLabel(){return this.effectiveAriaHidden?null:this.ariaLabel||this.name||null}connectedCallback(){super.connectedCallback(),this.classList.add(`pkt-icon`)}async attributeChangedCallback(e,t,n){super.attributeChangedCallback(e,t,n),(e===`name`||e===`path`)&&this.getIcon(this.name)}async updated(e){super.updated(e),(e.has(`name`)||e.has(`path`))&&this.getIcon(this.name),this.applyAriaToSvg()}applyAriaToSvg(){let e=this.querySelector(`svg`);if(!e)return;e.setAttribute(`aria-hidden`,String(this.effectiveAriaHidden));let t=this.effectiveAriaLabel;t?e.setAttribute(`aria-label`,t):e.removeAttribute(`aria-label`)}async getIcon(e=``){if(this._updatedProps.length>0){this.path||=typeof window<`u`?window.pktIconPath:r.path;try{this.icon=s(await h(this.name||``,this.path))}catch{this.icon=s(c)}this._updatedProps=[]}else this._updatedProps.includes(e)||this._updatedProps.push(e)}render(){return e._`${this.name&&this.icon}`}};e.n([e.u({type:String,reflect:!1})],g.prototype,`path`,void 0),e.n([e.u({type:String,reflect:!0})],g.prototype,`name`,void 0),e.n([e.u({type:String,attribute:`aria-hidden`,reflect:!0})],g.prototype,`ariaHidden`,void 0),e.n([e.u({type:String,attribute:`aria-label`,reflect:!0})],g.prototype,`ariaLabel`,void 0),e.n([e.u({type:SVGElement})],g.prototype,`icon`,void 0),e.n([e.u({type:Array,noAccessor:!0})],g.prototype,`_updatedProps`,void 0);try{e.d(`pkt-icon`)(g)}catch{console.warn(`Forsøker å definere <pkt-icon>, men den er allerede definert`)}var _=g;Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return _}});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const e=require("./element-CEarCnHH.cjs"),t=require("./element-with-slot-CeKuRE3_.cjs");require("./icon-B3YGHHa7.cjs");const n=require("./if-defined-Ci4ZQsgL.cjs");var r=class extends t.t{constructor(...e){super(...e),this.title=``,this.href=`#`,this.iconName=``,this.external=!1,this.openInNewTab=!1,this.skin=void 0}render(){let r=[`pkt-linkcard`,this.skin&&`pkt-linkcard--${this.skin}`].filter(Boolean).join(` `),i=[`pkt-linkcard__title`,this.external&&`pkt-link pkt-link--external`].filter(Boolean).join(` `),a=this.pktStrings.get(`linkcard`),o=this.openInNewTab?a.openInNewTab:``;return e._`
|
|
2
|
-
<a
|
|
3
|
-
href=${this.href}
|
|
4
|
-
class=${r}
|
|
5
|
-
target=${this.openInNewTab?`_blank`:`_self`}
|
|
6
|
-
rel=${n.t(this.openInNewTab?`noopener noreferrer`:void 0)}
|
|
7
|
-
>
|
|
8
|
-
${this.iconName&&e._`<pkt-icon class="pkt-link__icon" name="${this.iconName}"></pkt-icon>`}
|
|
9
|
-
${this.title&&e._`<div class=${i}>${this.title}</div>`}
|
|
10
|
-
${o?e._`<span class="pkt-sr-only">${o}</span>`:``}
|
|
11
|
-
|
|
12
|
-
<div class="pkt-linkcard__text">${t.i(this)}</div>
|
|
13
|
-
</a>
|
|
14
|
-
`}};e.n([e.u({type:String,reflect:!0})],r.prototype,`title`,void 0),e.n([e.u({type:String,reflect:!0})],r.prototype,`href`,void 0),e.n([e.u({type:String,reflect:!0})],r.prototype,`iconName`,void 0),e.n([e.u({type:Boolean,reflect:!0})],r.prototype,`external`,void 0),e.n([e.u({type:Boolean,reflect:!0})],r.prototype,`openInNewTab`,void 0),e.n([e.u({type:String,reflect:!0})],r.prototype,`skin`,void 0);try{e.d(`pkt-linkcard`)(r)}catch{console.warn(`Forsøker å definere <pkt-linkcard>, men den er allerede definert`)}var i=r;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const e=require("./element-CEarCnHH.cjs"),t=require("./class-map-C82GtM1w.cjs"),n=require("./element-with-slot-CeKuRE3_.cjs");require("./shared-types-BvRk9kiK.cjs"),require("./icon-B3YGHHa7.cjs");const r=require("./classutils-CbklAJDe.cjs");var i={skin:`beige`,compact:!1,closable:!1},a=class extends n.t{constructor(){super(),this.closable=i.closable,this.compact=i.compact,this.title=``,this.skin=i.skin,this._isClosed=!1,this.close=e=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent(`close`,{detail:{origin:e},bubbles:!0})),this.dispatchEvent(new CustomEvent(`on-close`,{detail:{origin:e},bubbles:!0}))},this._isClosed=!1}updated(e){super.updated(e),e.has(`_isClosed`)&&r.t(this,`pkt-hide`,this._isClosed)}render(){let r={"pkt-messagebox":!0,"pkt-messagebox--compact":this.compact,[`pkt-messagebox--${this.skin}`]:!!this.skin,"pkt-messagebox--closable":this.closable,"pkt-hide":this._isClosed};return e._`<div class=${t.t(r)}>
|
|
2
|
-
${this.closable?e._`<div class="pkt-messagebox__close">
|
|
3
|
-
<button
|
|
4
|
-
@click=${this.close}
|
|
5
|
-
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
6
|
-
aria-label=${this.pktStrings.get(`generic`).close}
|
|
7
|
-
>
|
|
8
|
-
<pkt-icon name="close" class="pkt-link__icon"></pkt-icon>
|
|
9
|
-
</button>
|
|
10
|
-
</div>`:e.h}
|
|
11
|
-
${this.title?e._`<div class="pkt-messagebox__title">${this.title}</div>`:e.h}
|
|
12
|
-
<div class="pkt-messagebox__text">${n.i(this)}</div>
|
|
13
|
-
</div>`}};e.n([e.u({type:Boolean,reflect:!0})],a.prototype,`closable`,void 0),e.n([e.u({type:Boolean,reflect:!0})],a.prototype,`compact`,void 0),e.n([e.u({type:String,reflect:!0})],a.prototype,`title`,void 0),e.n([e.u({type:String,reflect:!0})],a.prototype,`skin`,void 0),e.n([e.l()],a.prototype,`_isClosed`,void 0);try{e.d(`pkt-messagebox`)(a)}catch{console.warn(`Forsøker å definere <pkt-messagebox>, 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}});
|
package/dist/tag-BgHEzLM3.cjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const e=require("./element-CEarCnHH.cjs"),t=require("./class-map-C82GtM1w.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-CeKuRE3_.cjs");require("./icon-B3YGHHa7.cjs");const i=require("./if-defined-Ci4ZQsgL.cjs");var a={name:`pkt-tag`,react:`PktTag`,"css-class":`pkt-tag`,isElement:!0,"dark-mode":!0,props:{size:{name:`Størrelse`,description:`Størrelsen på taggen`,required:!1,default:`medium`,type:[`small`,`medium`,`large`],category:`ui`},iconName:{name:`Ikon`,description:`Navnet på ikonet som skal vises i taggen`,type:`icon`,required:!1,category:`ui`},skin:{name:`Utseende`,description:`Utseendet til taggen`,required:!1,default:`blue`,type:[`blue`,`blue-light`,`blue-dark`,`green`,`red`,`beige`,`yellow`,`gray`],category:`ui`},closeTag:{name:`Lukk tag`,description:`Skal taggen ha en lukkeknapp?`,type:`boolean`,required:!1,default:!1,category:`ui`},textStyle:{name:`Tekststil`,description:`Stilen på teksten i taggen`,required:!1,default:`normal-text`,type:[`thin-text`,`normal-text`],category:`ui`},type:{name:`Type, dersom lukkeknapp`,description:`Type tag, brukes for å spesifisere om det er en knapp, submit eller reset`,required:!1,default:`button`,type:[`button`,`submit`,`reset`],category:`tech`},ariaLabel:{name:`aria-label`,description:`aria-label for taggen, brukes for tilgjengelighet`,type:`string`,required:!1,category:`accessibility`}},slots:{default:{description:`Teksten til tag`}}},o=class extends r.t{constructor(){super(),this.closeTag=a.props.closeTag.default,this.size=a.props.size.default,this.skin=a.props.skin.default,this.textStyle=null,this.iconName=void 0,this.type=a.props.type.default,this.ariaLabel=null,this.buttonTabindex=void 0,this._isClosed=!1,this._ariaDescription=null,this.close=e=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent(`close`,{detail:{origin:e},bubbles:!1,composed:!0})),this.dispatchEvent(new CustomEvent(`on-close`,{detail:{origin:e},bubbles:!1,composed:!0}))},this._isClosed=!1}willUpdate(e){if(super.willUpdate(e),this.closeTag&&!this.ariaLabel){let e=r.r(this).getNodes().map(e=>e.textContent??``).join(``).trim();e&&(this._ariaDescription=n.t(this.pktStrings.get(`tag`).remove,{label:e}))}}render(){let n={"pkt-tag":!0,[`pkt-tag--${this.size}`]:!!this.size,[`pkt-tag--${this.skin}`]:!!this.skin,[`pkt-tag--${this.textStyle}`]:!!this.textStyle},a={"pkt-tag":!0,[`pkt-tag--${this.textStyle}`]:!!this.textStyle,[`pkt-tag--${this.size}`]:!!this.size,[`pkt-tag--${this.skin}`]:!!this.skin,"pkt-hide":this._isClosed};return this.closeTag?e._`
|
|
2
|
-
<button
|
|
3
|
-
class=${t.t(a)}
|
|
4
|
-
type=${this.type}
|
|
5
|
-
tabindex=${i.t(this.buttonTabindex)}
|
|
6
|
-
@click=${this.close}
|
|
7
|
-
aria-label=${i.t(this.ariaLabel||void 0)}
|
|
8
|
-
aria-description=${i.t(this._ariaDescription||void 0)}
|
|
9
|
-
>
|
|
10
|
-
${this.iconName&&e._`<pkt-icon
|
|
11
|
-
class="pkt-tag__icon"
|
|
12
|
-
name=${this.iconName}
|
|
13
|
-
aria-hidden="true"
|
|
14
|
-
></pkt-icon>`}
|
|
15
|
-
<span>${r.i(this)}</span>
|
|
16
|
-
<pkt-icon class="pkt-tag__close-btn" name="close"></pkt-icon>
|
|
17
|
-
</button>
|
|
18
|
-
`:e._`
|
|
19
|
-
<span class=${t.t(n)}>
|
|
20
|
-
${this.iconName&&e._`<pkt-icon
|
|
21
|
-
class="pkt-tag__icon"
|
|
22
|
-
name=${this.iconName}
|
|
23
|
-
aria-hidden="true"
|
|
24
|
-
></pkt-icon>`}
|
|
25
|
-
<span>${r.i(this)}</span>
|
|
26
|
-
</span>
|
|
27
|
-
`}};e.n([e.u({type:Boolean,reflect:!0})],o.prototype,`closeTag`,void 0),e.n([e.u({type:String,reflect:!0})],o.prototype,`size`,void 0),e.n([e.u({type:String,reflect:!0})],o.prototype,`skin`,void 0),e.n([e.u({type:String,reflect:!0})],o.prototype,`textStyle`,void 0),e.n([e.u({type:String,reflect:!0})],o.prototype,`iconName`,void 0),e.n([e.u({type:String})],o.prototype,`type`,void 0),e.n([e.u({type:String})],o.prototype,`ariaLabel`,void 0),e.n([e.u({type:Number,attribute:`button-tabindex`})],o.prototype,`buttonTabindex`,void 0),e.n([e.l()],o.prototype,`_isClosed`,void 0),e.n([e.l()],o.prototype,`_ariaDescription`,void 0);try{e.d(`pkt-tag`)(o)}catch{console.warn(`Forsøker å definere <pkt-tag>, men den er allerede definert`)}var s=o;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
|