@oslokommune/punkt-elements 12.17.2 → 12.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alert-BbVWu2lm.cjs +27 -0
- package/dist/alert-Dh6A96vo.js +159 -0
- package/dist/{index-D2jSRMrn.js → calendar-BUqcNvfI.js} +41 -29
- package/dist/calendar-QSulz7im.cjs +108 -0
- package/dist/card-B0GPdG5M.cjs +23 -0
- package/dist/card-kWt0BA2a.js +170 -0
- package/dist/{class-map-a5HUzP83.cjs → class-map-Boa7BqCc.cjs} +2 -2
- package/dist/{class-map-CBvUV2N3.js → class-map-hz16xq5a.js} +9 -10
- package/dist/datepicker-BHepKxof.cjs +154 -0
- package/dist/datepicker-iNCYioZ9.js +659 -0
- package/dist/helptext--4FLdAWi.js +194 -0
- package/dist/helptext-iZEgxz2U.cjs +23 -0
- package/dist/icon-CdMQ6zBT.cjs +250 -0
- package/dist/{index-CFDwiDTU.js → icon-wUXeHiBk.js} +7371 -7559
- package/dist/if-defined-DEDlGbAc.cjs +5 -0
- package/dist/if-defined-ZFE4ti2t.js +10 -0
- package/dist/index.d.ts +96 -51
- package/dist/input-element-D1Vls6A5.js +184 -0
- package/dist/input-element-DPKoFVwJ.cjs +1 -0
- package/dist/{input-wrapper-6vTrKtsW.js → input-wrapper-BTQk3W8T.js} +10 -10
- package/dist/input-wrapper-D-PNRJB_.cjs +46 -0
- package/dist/link-BpqavGSD.cjs +8 -0
- package/dist/link-Bx9nVgZi.js +108 -0
- package/dist/{linkcard-BlWQ8jOv.js → linkcard-CUrbzjLK.js} +16 -17
- package/dist/linkcard-DSu3A4Yx.cjs +13 -0
- package/dist/messagebox-C1aWoQbu.cjs +12 -0
- package/dist/messagebox-LpiVQIoM.js +107 -0
- package/dist/{modal-DYTVJjYh.cjs → modal-Avai5eVz.cjs} +2 -2
- package/dist/{modal-3OZTPqee.js → modal-Co1YFmHi.js} +8 -8
- package/dist/pkt-alert.cjs +1 -27
- package/dist/pkt-alert.js +4 -157
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +4 -7
- package/dist/pkt-card.cjs +1 -23
- package/dist/pkt-card.js +4 -168
- package/dist/pkt-datepicker.cjs +1 -154
- package/dist/pkt-datepicker.js +4 -657
- 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 +4 -4
- package/dist/pkt-index.cjs +29 -1
- package/dist/pkt-index.js +127 -30
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-link.cjs +1 -8
- package/dist/pkt-link.js +4 -107
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +1 -1
- package/dist/pkt-messagebox.cjs +1 -12
- package/dist/pkt-messagebox.js +4 -105
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/pkt-progressbar.cjs +1 -0
- package/dist/pkt-progressbar.js +6 -0
- package/dist/pkt-slot-controller-Ckk_yV0j.cjs +1 -0
- package/dist/pkt-slot-controller-RJvOnbF4.js +61 -0
- package/dist/pkt-tag.cjs +1 -17
- package/dist/pkt-tag.js +4 -148
- 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/progressbar-BS_oawSB.js +150 -0
- package/dist/progressbar-CuXkbAhJ.cjs +32 -0
- package/dist/ref-DCOsLZQg.cjs +13 -0
- package/dist/ref-DuFGTLVX.js +142 -0
- package/dist/state-BfyXV7EL.js +12 -0
- package/dist/state-SKYD8kRO.cjs +5 -0
- package/dist/stringutils-CkVRq4jP.cjs +1 -0
- package/dist/stringutils-DJjRa8dG.js +7 -0
- package/dist/tag-CGy2mSLE.cjs +17 -0
- package/dist/tag-DGFgUF3l.js +150 -0
- package/dist/{textarea-BTpJjEhO.js → textarea-BAGWR1Hi.js} +29 -29
- package/dist/textarea-BiUrhAlk.cjs +48 -0
- package/dist/{textinput-BIhQEr8z.cjs → textinput-CHOR5PPp.cjs} +2 -2
- package/dist/{textinput-CVo5wG14.js → textinput-pJ3N8m6g.js} +23 -23
- package/package.json +2 -2
- package/src/components/alert/alert.ts +115 -0
- package/src/components/alert/index.ts +4 -113
- package/src/components/calendar/calendar.ts +711 -0
- package/src/components/calendar/index.ts +3 -711
- package/src/components/card/card.ts +78 -0
- package/src/components/card/index.ts +4 -77
- package/src/components/datepicker/datepicker.ts +619 -0
- package/src/components/datepicker/index.ts +3 -618
- package/src/components/helptext/helptext.ts +2 -2
- package/src/components/icon/icon.ts +99 -0
- package/src/components/icon/index.ts +3 -98
- package/src/components/index.ts +29 -15
- package/src/components/input-wrapper/input-wrapper.ts +2 -2
- package/src/components/link/index.ts +3 -56
- package/src/components/link/link.ts +57 -0
- package/src/components/linkcard/index.ts +1 -1
- package/src/components/linkcard/linkcard.ts +5 -6
- package/src/components/messagebox/index.ts +4 -69
- package/src/components/messagebox/messagebox.ts +69 -0
- package/src/components/modal/index.ts +0 -1
- package/src/components/modal/modal.ts +5 -7
- package/src/components/progressbar/index.ts +12 -0
- package/src/components/progressbar/progressbar.ts +144 -0
- package/src/components/tag/index.ts +4 -109
- package/src/components/tag/tag.ts +118 -0
- package/src/components/textarea/textarea.ts +5 -4
- package/src/components/textinput/textinput.ts +3 -3
- package/dist/converters-DNCwIFwr.js +0 -17
- package/dist/converters-DhM11VlY.cjs +0 -1
- package/dist/custom-element-B-TlBwRu.cjs +0 -9
- package/dist/custom-element-CWfU4dcr.js +0 -38
- package/dist/element.d.ts +0 -8
- package/dist/helptext-DBolvFI4.js +0 -72
- package/dist/helptext-_fMLOOCL.cjs +0 -23
- package/dist/index-CR7t1zY9.cjs +0 -238
- package/dist/index-CmTjXoAb.cjs +0 -9
- package/dist/index-RwtTBIhT.js +0 -88
- package/dist/index-tvpcg-ad.cjs +0 -108
- package/dist/input-wrapper-DX41tnbj.cjs +0 -46
- package/dist/linkcard-Det6CJ5D.cjs +0 -13
- package/dist/pkt-component-template.cjs +0 -29
- package/dist/pkt-component-template.js +0 -99
- package/dist/pkt-element.cjs +0 -1
- package/dist/pkt-element.js +0 -5
- package/dist/ref-C2yPtMJA.cjs +0 -13
- package/dist/ref-CaiKp3S2.js +0 -202
- package/dist/textarea-B45ZZYpx.cjs +0 -48
- package/src/components/component-template/index.ts +0 -129
- package/src/components/element/index.ts +0 -353
- /package/dist/{component-template.d.ts → progressbar.d.ts} +0 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { PktElement } from '@/base-elements/element'
|
|
2
|
+
import { html, PropertyValues } from 'lit'
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js'
|
|
4
|
+
import { unsafeSVG } from 'lit/directives/unsafe-svg.js'
|
|
5
|
+
|
|
6
|
+
// Allow global override of icon fetch
|
|
7
|
+
window.pktFetch = window.pktFetch === undefined ? fetch : window.pktFetch
|
|
8
|
+
window.pktIconPath = window.pktIconPath || 'https://punkt-cdn.oslo.kommune.no/latest/icons/'
|
|
9
|
+
|
|
10
|
+
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
|
|
11
|
+
const errorSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"></svg>'
|
|
12
|
+
const dlStatus: { [key: string]: string } = {}
|
|
13
|
+
|
|
14
|
+
const downloadIconOrGetFromCache = async (
|
|
15
|
+
name: string,
|
|
16
|
+
path: string | undefined,
|
|
17
|
+
): Promise<string | null> => {
|
|
18
|
+
let i = 0
|
|
19
|
+
while (dlStatus[path + name + '.svg'] === 'fetching') {
|
|
20
|
+
i++
|
|
21
|
+
if (i > 50) break
|
|
22
|
+
await sleep(50)
|
|
23
|
+
}
|
|
24
|
+
if (localStorage.getItem(path + name + '.svg')) {
|
|
25
|
+
return Promise.resolve(localStorage.getItem(path + name + '.svg'))
|
|
26
|
+
} else if (typeof window.pktFetch === 'function') {
|
|
27
|
+
dlStatus[path + name + '.svg'] = 'fetching'
|
|
28
|
+
return Promise.resolve(
|
|
29
|
+
window
|
|
30
|
+
.pktFetch(path + name + '.svg')
|
|
31
|
+
.then((response) => {
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
// eslint-disable-next-line no-console
|
|
34
|
+
console.error('Missing icon: ' + path + name + '.svg')
|
|
35
|
+
return errorSvg
|
|
36
|
+
} else {
|
|
37
|
+
return response.text()
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
.then((text) => {
|
|
41
|
+
if (text !== errorSvg) {
|
|
42
|
+
localStorage.setItem(path + name + '.svg', text)
|
|
43
|
+
}
|
|
44
|
+
dlStatus[path + name + '.svg'] = 'fetched'
|
|
45
|
+
return text
|
|
46
|
+
}),
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
return Promise.resolve(errorSvg)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@customElement('pkt-icon')
|
|
53
|
+
export class PktIcon extends PktElement {
|
|
54
|
+
@property({ type: String, reflect: false })
|
|
55
|
+
path: string | undefined = window.pktIconPath
|
|
56
|
+
|
|
57
|
+
@property({ type: String, reflect: true })
|
|
58
|
+
name: string = ''
|
|
59
|
+
|
|
60
|
+
@property({ type: SVGElement })
|
|
61
|
+
private icon: any = unsafeSVG(errorSvg)
|
|
62
|
+
|
|
63
|
+
@property({ type: Array, noAccessor: true })
|
|
64
|
+
private _updatedProps: string[] = []
|
|
65
|
+
|
|
66
|
+
connectedCallback(): void {
|
|
67
|
+
super.connectedCallback()
|
|
68
|
+
this.classList.add('pkt-icon')
|
|
69
|
+
}
|
|
70
|
+
async attributeChangedCallback(name: string, _old: string | null, value: string | null) {
|
|
71
|
+
super.attributeChangedCallback(name, _old, value)
|
|
72
|
+
if (name === 'name' || name === 'path') this.getIcon(this.name)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
protected async updated(_changedProperties: PropertyValues) {
|
|
76
|
+
super.updated(_changedProperties)
|
|
77
|
+
if (_changedProperties.has('name') || _changedProperties.has('path')) {
|
|
78
|
+
this.getIcon(this.name)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
protected async getIcon(name = '') {
|
|
83
|
+
if (this._updatedProps.length > 0) {
|
|
84
|
+
if (!this.path) this.path === window.pktIconPath
|
|
85
|
+
this.icon = unsafeSVG(
|
|
86
|
+
await downloadIconOrGetFromCache(this.name || '', this.path).then((res) => res),
|
|
87
|
+
) as SVGElement
|
|
88
|
+
this._updatedProps = []
|
|
89
|
+
} else {
|
|
90
|
+
if (!this._updatedProps.includes(name)) {
|
|
91
|
+
this._updatedProps.push(name)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
render() {
|
|
97
|
+
return html`${this.name && this.icon}`
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -1,99 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { html, PropertyValues } from 'lit'
|
|
3
|
-
import { customElement, property } from 'lit/decorators.js'
|
|
4
|
-
import { unsafeSVG } from 'lit/directives/unsafe-svg.js'
|
|
1
|
+
import { PktIcon } from './icon'
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
window.pktIconPath = window.pktIconPath || 'https://punkt-cdn.oslo.kommune.no/latest/icons/'
|
|
9
|
-
|
|
10
|
-
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
|
|
11
|
-
const errorSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"></svg>'
|
|
12
|
-
const dlStatus: { [key: string]: string } = {}
|
|
13
|
-
|
|
14
|
-
const downloadIconOrGetFromCache = async (
|
|
15
|
-
name: string,
|
|
16
|
-
path: string | undefined,
|
|
17
|
-
): Promise<string | null> => {
|
|
18
|
-
let i = 0
|
|
19
|
-
while (dlStatus[path + name + '.svg'] === 'fetching') {
|
|
20
|
-
i++
|
|
21
|
-
if (i > 50) break
|
|
22
|
-
await sleep(50)
|
|
23
|
-
}
|
|
24
|
-
if (localStorage.getItem(path + name + '.svg')) {
|
|
25
|
-
return Promise.resolve(localStorage.getItem(path + name + '.svg'))
|
|
26
|
-
} else if (typeof window.pktFetch === 'function') {
|
|
27
|
-
dlStatus[path + name + '.svg'] = 'fetching'
|
|
28
|
-
return Promise.resolve(
|
|
29
|
-
window
|
|
30
|
-
.pktFetch(path + name + '.svg')
|
|
31
|
-
.then((response) => {
|
|
32
|
-
if (!response.ok) {
|
|
33
|
-
// eslint-disable-next-line no-console
|
|
34
|
-
console.error('Missing icon: ' + path + name + '.svg')
|
|
35
|
-
return errorSvg
|
|
36
|
-
} else {
|
|
37
|
-
return response.text()
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
.then((text) => {
|
|
41
|
-
if (text !== errorSvg) {
|
|
42
|
-
localStorage.setItem(path + name + '.svg', text)
|
|
43
|
-
}
|
|
44
|
-
dlStatus[path + name + '.svg'] = 'fetched'
|
|
45
|
-
return text
|
|
46
|
-
}),
|
|
47
|
-
)
|
|
48
|
-
}
|
|
49
|
-
return Promise.resolve(errorSvg)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@customElement('pkt-icon')
|
|
53
|
-
export class PktIcon extends PktElement {
|
|
54
|
-
@property({ type: String, reflect: false })
|
|
55
|
-
path: string | undefined = window.pktIconPath
|
|
56
|
-
|
|
57
|
-
@property({ type: String, reflect: true })
|
|
58
|
-
name: string = ''
|
|
59
|
-
|
|
60
|
-
@property({ type: SVGElement })
|
|
61
|
-
private icon: any = unsafeSVG(errorSvg)
|
|
62
|
-
|
|
63
|
-
@property({ type: Array, noAccessor: true })
|
|
64
|
-
private _updatedProps: string[] = []
|
|
65
|
-
|
|
66
|
-
connectedCallback(): void {
|
|
67
|
-
super.connectedCallback()
|
|
68
|
-
this.classList.add('pkt-icon')
|
|
69
|
-
}
|
|
70
|
-
async attributeChangedCallback(name: string, _old: string | null, value: string | null) {
|
|
71
|
-
super.attributeChangedCallback(name, _old, value)
|
|
72
|
-
if (name === 'name' || name === 'path') this.getIcon(this.name)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
protected async updated(_changedProperties: PropertyValues) {
|
|
76
|
-
super.updated(_changedProperties)
|
|
77
|
-
if (_changedProperties.has('name') || _changedProperties.has('path')) {
|
|
78
|
-
this.getIcon(this.name)
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
protected async getIcon(name = '') {
|
|
83
|
-
if (this._updatedProps.length > 0) {
|
|
84
|
-
if (!this.path) this.path === window.pktIconPath
|
|
85
|
-
this.icon = unsafeSVG(
|
|
86
|
-
await downloadIconOrGetFromCache(this.name || '', this.path).then((res) => res),
|
|
87
|
-
) as SVGElement
|
|
88
|
-
this._updatedProps = []
|
|
89
|
-
} else {
|
|
90
|
-
if (!this._updatedProps.includes(name)) {
|
|
91
|
-
this._updatedProps.push(name)
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
render() {
|
|
97
|
-
return html`${this.name && this.icon}`
|
|
98
|
-
}
|
|
99
|
-
}
|
|
3
|
+
export { PktIcon }
|
|
4
|
+
export default PktIcon
|
package/src/components/index.ts
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
1
|
+
// Export components
|
|
2
|
+
export { PktAlert } from '@/components/alert'
|
|
3
|
+
export { PktCalendar } from '@/components/calendar'
|
|
4
|
+
export { PktCard } from '@/components/card'
|
|
5
|
+
export { PktComponent } from '../base-elements/component-template.js'
|
|
6
|
+
export { PktDatepicker } from '@/components/datepicker/datepicker.js'
|
|
7
|
+
export { PktHelptext } from '@/components/helptext'
|
|
8
|
+
export { PktIcon } from '@/components/icon'
|
|
9
|
+
export { PktInputWrapper } from '@/components/input-wrapper'
|
|
10
|
+
export { PktLink } from '@/components/link'
|
|
11
|
+
export { PktLinkCard } from '@/components/linkcard'
|
|
12
|
+
export { PktMessagebox } from '@/components/messagebox'
|
|
13
|
+
export { PktModal } from '@/components/modal'
|
|
14
|
+
export { PktProgressbar } from '@/components/progressbar'
|
|
15
|
+
export { PktTag } from '@/components/tag'
|
|
16
|
+
export { PktTextarea } from '@/components/textarea'
|
|
17
|
+
export { PktTextinput } from '@/components/textinput'
|
|
18
|
+
|
|
19
|
+
// Export types
|
|
20
|
+
export type {
|
|
21
|
+
IPktProgressbar,
|
|
22
|
+
TProgressbarRole,
|
|
23
|
+
TProgressbarSkin,
|
|
24
|
+
TProgressbarStatusPlacement,
|
|
25
|
+
TProgressbarStatusType,
|
|
26
|
+
TProgressbarTitlePosition,
|
|
27
|
+
} from '@/components/progressbar'
|
|
28
|
+
|
|
29
|
+
export type { TTagSkin, TTagType } from '@/components/tag'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PktElement } from '
|
|
1
|
+
import { PktElement } from '@/base-elements/element'
|
|
2
2
|
import { PktSlotController } from '../../controllers/pkt-slot-controller'
|
|
3
3
|
import { ref, Ref, createRef } from 'lit/directives/ref.js'
|
|
4
4
|
import { html, nothing } from 'lit'
|
|
@@ -7,8 +7,8 @@ import { classMap } from 'lit/directives/class-map.js'
|
|
|
7
7
|
import { customElement, property } from 'lit/decorators.js'
|
|
8
8
|
import { uuidish } from '@/utils/stringutils'
|
|
9
9
|
import specs from 'componentSpecs/input-wrapper.json'
|
|
10
|
-
import '../icon'
|
|
11
10
|
import '../helptext'
|
|
11
|
+
import '../icon/icon'
|
|
12
12
|
|
|
13
13
|
@customElement('pkt-input-wrapper')
|
|
14
14
|
export class PktInputWrapper extends PktElement {
|
|
@@ -1,57 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PktSlotController } from '../../controllers/pkt-slot-controller'
|
|
3
|
-
import { ref, Ref, createRef } from 'lit/directives/ref.js'
|
|
4
|
-
import { html, nothing } from 'lit'
|
|
5
|
-
import { classMap } from 'lit/directives/class-map.js'
|
|
6
|
-
import { customElement, property } from 'lit/decorators.js'
|
|
7
|
-
import specs from 'componentSpecs/link.json'
|
|
8
|
-
import '../icon'
|
|
1
|
+
import { PktLink } from './link'
|
|
9
2
|
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
defaultSlot: Ref<HTMLElement> = createRef()
|
|
13
|
-
|
|
14
|
-
constructor() {
|
|
15
|
-
super()
|
|
16
|
-
this.slotController = new PktSlotController(this, this.defaultSlot)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Element attributes
|
|
21
|
-
*/
|
|
22
|
-
@property({ type: String, reflect: true }) href: string = specs.props.href.default
|
|
23
|
-
@property({ type: String, reflect: true }) iconName: string | undefined = undefined
|
|
24
|
-
@property({ type: String, reflect: true }) iconPosition: string | undefined = undefined
|
|
25
|
-
@property({ type: Boolean, reflect: true }) external: boolean = specs.props.external.default
|
|
26
|
-
@property({ type: String, reflect: true }) target: string | null = specs.props.target.default
|
|
27
|
-
|
|
28
|
-
render() {
|
|
29
|
-
const classes = {
|
|
30
|
-
'pkt-link': true,
|
|
31
|
-
'pkt-link--icon-left':
|
|
32
|
-
(!!this.iconName && this.iconPosition === 'left') ||
|
|
33
|
-
!!(this.iconName && !this.iconPosition),
|
|
34
|
-
'pkt-link--icon-right': !!this.iconName && this.iconPosition === 'right',
|
|
35
|
-
'pkt-link--external': this.external,
|
|
36
|
-
}
|
|
37
|
-
return html`<a
|
|
38
|
-
class=${classMap(classes)}
|
|
39
|
-
href=${this.href}
|
|
40
|
-
@click=${this.handleClick}
|
|
41
|
-
.target=${this.target}
|
|
42
|
-
.rel=${this.external ? 'noopener noreferrer' : nothing}
|
|
43
|
-
>${this.iconName
|
|
44
|
-
? html`<pkt-icon name=${this.iconName} class="pkt-link__icon"></pkt-icon>`
|
|
45
|
-
: ''} <span ${ref(this.defaultSlot)}>Link</span></a
|
|
46
|
-
>`
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private handleClick() {
|
|
50
|
-
this.dispatchEvent(
|
|
51
|
-
new CustomEvent('click', {
|
|
52
|
-
detail: 'pkt-link-clicked',
|
|
53
|
-
bubbles: true,
|
|
54
|
-
}),
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
3
|
+
export { PktLink }
|
|
4
|
+
export default PktLink
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { PktElement } from '@/base-elements/element'
|
|
2
|
+
import { PktSlotController } from '@/controllers/pkt-slot-controller'
|
|
3
|
+
import { ref, Ref, createRef } from 'lit/directives/ref.js'
|
|
4
|
+
import { html, nothing } from 'lit'
|
|
5
|
+
import { classMap } from 'lit/directives/class-map.js'
|
|
6
|
+
import { customElement, property } from 'lit/decorators.js'
|
|
7
|
+
import specs from 'componentSpecs/link.json'
|
|
8
|
+
import '@/components/icon'
|
|
9
|
+
|
|
10
|
+
@customElement('pkt-link')
|
|
11
|
+
export class PktLink extends PktElement {
|
|
12
|
+
defaultSlot: Ref<HTMLElement> = createRef()
|
|
13
|
+
|
|
14
|
+
constructor() {
|
|
15
|
+
super()
|
|
16
|
+
this.slotController = new PktSlotController(this, this.defaultSlot)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Element attributes
|
|
21
|
+
*/
|
|
22
|
+
@property({ type: String, reflect: true }) href: string = specs.props.href.default
|
|
23
|
+
@property({ type: String, reflect: true }) iconName: string | undefined = undefined
|
|
24
|
+
@property({ type: String, reflect: true }) iconPosition: string | undefined = undefined
|
|
25
|
+
@property({ type: Boolean, reflect: true }) external: boolean = specs.props.external.default
|
|
26
|
+
@property({ type: String, reflect: true }) target: string | null = specs.props.target.default
|
|
27
|
+
|
|
28
|
+
render() {
|
|
29
|
+
const classes = {
|
|
30
|
+
'pkt-link': true,
|
|
31
|
+
'pkt-link--icon-left':
|
|
32
|
+
(!!this.iconName && this.iconPosition === 'left') ||
|
|
33
|
+
!!(this.iconName && !this.iconPosition),
|
|
34
|
+
'pkt-link--icon-right': !!this.iconName && this.iconPosition === 'right',
|
|
35
|
+
'pkt-link--external': this.external,
|
|
36
|
+
}
|
|
37
|
+
return html`<a
|
|
38
|
+
class=${classMap(classes)}
|
|
39
|
+
href=${this.href}
|
|
40
|
+
@click=${this.handleClick}
|
|
41
|
+
.target=${this.target}
|
|
42
|
+
.rel=${this.external ? 'noopener noreferrer' : nothing}
|
|
43
|
+
>${this.iconName
|
|
44
|
+
? html`<pkt-icon name=${this.iconName} class="pkt-link__icon"></pkt-icon>`
|
|
45
|
+
: ''} <span ${ref(this.defaultSlot)}>Link</span></a
|
|
46
|
+
>`
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private handleClick() {
|
|
50
|
+
this.dispatchEvent(
|
|
51
|
+
new CustomEvent('click', {
|
|
52
|
+
detail: 'pkt-link-clicked',
|
|
53
|
+
bubbles: true,
|
|
54
|
+
}),
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { html } from 'lit'
|
|
2
2
|
import { customElement, property } from 'lit/decorators.js'
|
|
3
|
-
import { PktElement } from '../element'
|
|
4
3
|
import { ref } from 'lit/directives/ref.js'
|
|
5
4
|
import { Ref, createRef } from 'lit/directives/ref.js'
|
|
6
|
-
|
|
7
|
-
import '../icon'
|
|
5
|
+
import { PktElement } from '@/base-elements/element'
|
|
8
6
|
import { PktSlotController } from '@/controllers/pkt-slot-controller'
|
|
7
|
+
import '@/components/icon'
|
|
9
8
|
|
|
10
|
-
export type
|
|
9
|
+
export type TLinkCardSkin =
|
|
11
10
|
| 'normal'
|
|
12
11
|
| 'blue'
|
|
13
12
|
| 'beige'
|
|
@@ -22,7 +21,7 @@ export interface IPktLinkCard {
|
|
|
22
21
|
iconName?: string
|
|
23
22
|
external?: boolean
|
|
24
23
|
openInNewTab?: boolean
|
|
25
|
-
skin?:
|
|
24
|
+
skin?: TLinkCardSkin
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
@customElement('pkt-linkcard')
|
|
@@ -34,7 +33,7 @@ export class PktLinkCard extends PktElement implements IPktLinkCard {
|
|
|
34
33
|
@property({ type: String, reflect: true }) iconName: string = ''
|
|
35
34
|
@property({ type: Boolean, reflect: true }) external: boolean = false
|
|
36
35
|
@property({ type: Boolean, reflect: true }) openInNewTab: boolean = false
|
|
37
|
-
@property({ type: String, reflect: true }) skin:
|
|
36
|
+
@property({ type: String, reflect: true }) skin: TLinkCardSkin = 'normal'
|
|
38
37
|
|
|
39
38
|
constructor() {
|
|
40
39
|
super()
|
|
@@ -1,69 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { html, nothing } from 'lit'
|
|
6
|
-
import { classMap } from 'lit/directives/class-map.js'
|
|
7
|
-
import { customElement, property, state } from 'lit/decorators.js'
|
|
8
|
-
import specs from 'componentSpecs/messagebox.json'
|
|
9
|
-
|
|
10
|
-
import '../icon'
|
|
11
|
-
|
|
12
|
-
type MessageboxSkin = 'beige' | 'blue' | 'red' | 'green'
|
|
13
|
-
|
|
14
|
-
export interface IPktMessagebox {
|
|
15
|
-
skin?: MessageboxSkin
|
|
16
|
-
title?: string
|
|
17
|
-
compact?: boolean
|
|
18
|
-
closable?: boolean
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@customElement('pkt-messagebox')
|
|
22
|
-
export class PktMessagebox extends PktElement {
|
|
23
|
-
defaultSlot: Ref<HTMLElement> = createRef()
|
|
24
|
-
|
|
25
|
-
constructor() {
|
|
26
|
-
super()
|
|
27
|
-
this.slotController = new PktSlotController(this, this.defaultSlot)
|
|
28
|
-
this._isClosed = false
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@property({ type: Boolean, reflect: true }) closable = specs.props.closable.default
|
|
32
|
-
@property({ type: Boolean, reflect: true }) compact = specs.props.compact.default
|
|
33
|
-
@property({ type: String, reflect: true }) title = ''
|
|
34
|
-
@property({ type: String, reflect: true }) skin = specs.props.skin.default as MessageboxSkin
|
|
35
|
-
|
|
36
|
-
@state() _isClosed: boolean = false
|
|
37
|
-
|
|
38
|
-
private close = (event: MouseEvent) => {
|
|
39
|
-
this._isClosed = true
|
|
40
|
-
this.dispatchEvent(new CustomEvent('close', { detail: { origin: event }, bubbles: true }))
|
|
41
|
-
// Historical support of old Vue implementations…
|
|
42
|
-
this.dispatchEvent(new CustomEvent('on-close', { detail: { origin: event }, bubbles: true }))
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
render() {
|
|
46
|
-
const classes = {
|
|
47
|
-
'pkt-messagebox': true,
|
|
48
|
-
'pkt-messagebox--compact': this.compact,
|
|
49
|
-
[`pkt-messagebox--${this.skin}`]: this.skin,
|
|
50
|
-
'pkt-messagebox--closable': this.closable,
|
|
51
|
-
'pkt-hide': this._isClosed,
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return html`<div class=${classMap(classes)}>
|
|
55
|
-
${this.closable
|
|
56
|
-
? html`<div class="pkt-messagebox__close">
|
|
57
|
-
<button
|
|
58
|
-
@click=${this.close}
|
|
59
|
-
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
60
|
-
>
|
|
61
|
-
<pkt-icon name="close" class="pkt-link__icon"></pkt-icon>
|
|
62
|
-
</button>
|
|
63
|
-
</div>`
|
|
64
|
-
: nothing}
|
|
65
|
-
${this.title ? html`<div class="pkt-messagebox__title">${this.title}</div>` : nothing}
|
|
66
|
-
<div class="pkt-messagebox__text" ${ref(this.defaultSlot)}></div>
|
|
67
|
-
</div>`
|
|
68
|
-
}
|
|
69
|
-
}
|
|
1
|
+
import { PktMessagebox } from './messagebox'
|
|
2
|
+
export { PktMessagebox } from './messagebox'
|
|
3
|
+
export type { IPktMessagebox, TMessageboxSkin } from './messagebox'
|
|
4
|
+
export default PktMessagebox
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { PktElement } from '@/base-elements/element'
|
|
2
|
+
import { PktSlotController } from '@/controllers/pkt-slot-controller'
|
|
3
|
+
import { ref } from 'lit/directives/ref.js'
|
|
4
|
+
import { Ref, createRef } from 'lit/directives/ref.js'
|
|
5
|
+
import { html, nothing } from 'lit'
|
|
6
|
+
import { classMap } from 'lit/directives/class-map.js'
|
|
7
|
+
import { customElement, property, state } from 'lit/decorators.js'
|
|
8
|
+
import specs from 'componentSpecs/messagebox.json'
|
|
9
|
+
|
|
10
|
+
import '@/components/icon'
|
|
11
|
+
|
|
12
|
+
export type TMessageboxSkin = 'beige' | 'blue' | 'red' | 'green'
|
|
13
|
+
|
|
14
|
+
export interface IPktMessagebox {
|
|
15
|
+
skin?: TMessageboxSkin
|
|
16
|
+
title?: string
|
|
17
|
+
compact?: boolean
|
|
18
|
+
closable?: boolean
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@customElement('pkt-messagebox')
|
|
22
|
+
export class PktMessagebox extends PktElement {
|
|
23
|
+
defaultSlot: Ref<HTMLElement> = createRef()
|
|
24
|
+
|
|
25
|
+
constructor() {
|
|
26
|
+
super()
|
|
27
|
+
this.slotController = new PktSlotController(this, this.defaultSlot)
|
|
28
|
+
this._isClosed = false
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@property({ type: Boolean, reflect: true }) closable = specs.props.closable.default
|
|
32
|
+
@property({ type: Boolean, reflect: true }) compact = specs.props.compact.default
|
|
33
|
+
@property({ type: String, reflect: true }) title = ''
|
|
34
|
+
@property({ type: String, reflect: true }) skin = specs.props.skin.default as TMessageboxSkin
|
|
35
|
+
|
|
36
|
+
@state() _isClosed: boolean = false
|
|
37
|
+
|
|
38
|
+
private close = (event: MouseEvent) => {
|
|
39
|
+
this._isClosed = true
|
|
40
|
+
this.dispatchEvent(new CustomEvent('close', { detail: { origin: event }, bubbles: true }))
|
|
41
|
+
// Historical support of old Vue implementations…
|
|
42
|
+
this.dispatchEvent(new CustomEvent('on-close', { detail: { origin: event }, bubbles: true }))
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
render() {
|
|
46
|
+
const classes = {
|
|
47
|
+
'pkt-messagebox': true,
|
|
48
|
+
'pkt-messagebox--compact': this.compact,
|
|
49
|
+
[`pkt-messagebox--${this.skin}`]: this.skin,
|
|
50
|
+
'pkt-messagebox--closable': this.closable,
|
|
51
|
+
'pkt-hide': this._isClosed,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return html`<div class=${classMap(classes)}>
|
|
55
|
+
${this.closable
|
|
56
|
+
? html`<div class="pkt-messagebox__close">
|
|
57
|
+
<button
|
|
58
|
+
@click=${this.close}
|
|
59
|
+
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
60
|
+
>
|
|
61
|
+
<pkt-icon name="close" class="pkt-link__icon"></pkt-icon>
|
|
62
|
+
</button>
|
|
63
|
+
</div>`
|
|
64
|
+
: nothing}
|
|
65
|
+
${this.title ? html`<div class="pkt-messagebox__title">${this.title}</div>` : nothing}
|
|
66
|
+
<div class="pkt-messagebox__text" ${ref(this.defaultSlot)}></div>
|
|
67
|
+
</div>`
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { classMap } from 'lit/directives/class-map.js'
|
|
2
2
|
import { customElement, property, state } from 'lit/decorators.js'
|
|
3
3
|
import { html, nothing } from 'lit'
|
|
4
|
-
import { PktElement } from '
|
|
4
|
+
import { PktElement } from '@/base-elements/element'
|
|
5
5
|
import { PktSlotController } from '@/controllers/pkt-slot-controller'
|
|
6
6
|
import { ref } from 'lit/directives/ref.js'
|
|
7
7
|
import { Ref, createRef } from 'lit/directives/ref.js'
|
|
8
|
+
import { TPktSize } from '@/types/size'
|
|
8
9
|
import specs from 'componentSpecs/modal.json'
|
|
9
|
-
import '
|
|
10
|
-
|
|
11
|
-
export type ModalSize = 'small' | 'medium' | 'large'
|
|
10
|
+
import '@/components/icon'
|
|
12
11
|
|
|
13
12
|
export interface IPktModal {
|
|
14
13
|
headingText?: string
|
|
15
14
|
removePadding?: boolean
|
|
16
15
|
hideCloseButton?: boolean
|
|
17
16
|
closeOnBackdropClick?: boolean
|
|
18
|
-
size?:
|
|
17
|
+
size?: TPktSize
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
@customElement('pkt-modal')
|
|
@@ -27,8 +26,7 @@ export class PktModal extends PktElement implements IPktModal {
|
|
|
27
26
|
specs.props.hideCloseButton.default
|
|
28
27
|
@property({ type: Boolean, reflect: true })
|
|
29
28
|
closeOnBackdropClick?: boolean = specs.props.closeOnBackdropClick.default
|
|
30
|
-
@property({ type: String, reflect: true }) size?:
|
|
31
|
-
.default as ModalSize
|
|
29
|
+
@property({ type: String, reflect: true }) size?: TPktSize = specs.props.size.default as TPktSize
|
|
32
30
|
|
|
33
31
|
defaultSlot: Ref<HTMLElement> = createRef()
|
|
34
32
|
dialogRef: Ref<HTMLDialogElement> = createRef()
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import PktProgressbar from './progressbar'
|
|
2
|
+
|
|
3
|
+
export { PktProgressbar } from './progressbar'
|
|
4
|
+
export type {
|
|
5
|
+
IPktProgressbar,
|
|
6
|
+
TProgressbarRole,
|
|
7
|
+
TProgressbarSkin,
|
|
8
|
+
TProgressbarStatusPlacement,
|
|
9
|
+
TProgressbarStatusType,
|
|
10
|
+
TProgressbarTitlePosition,
|
|
11
|
+
} from './progressbar'
|
|
12
|
+
export default PktProgressbar
|