@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,144 @@
|
|
|
1
|
+
import { ifDefined } from 'lit/directives/if-defined.js'
|
|
2
|
+
import { classMap } from 'lit/directives/class-map.js'
|
|
3
|
+
import { customElement, property, state } from 'lit/decorators.js'
|
|
4
|
+
import { html } from 'lit'
|
|
5
|
+
import { PktElement } from '@/base-elements/element'
|
|
6
|
+
import { Ref, createRef, ref } from 'lit/directives/ref.js'
|
|
7
|
+
import { styleMap } from 'lit/directives/style-map.js'
|
|
8
|
+
import { uuidish } from '@/utils/stringutils'
|
|
9
|
+
|
|
10
|
+
import '@/components/icon'
|
|
11
|
+
|
|
12
|
+
export type TProgressbarRole = 'progressbar' | 'meter'
|
|
13
|
+
export type TProgressbarSkin = 'dark-blue' | 'light-blue' | 'green' | 'red'
|
|
14
|
+
export type TProgressbarStatusPlacement = 'center' | 'left' | 'following'
|
|
15
|
+
export type TProgressbarStatusType = 'none' | 'percentage' | 'fraction'
|
|
16
|
+
export type TProgressbarTitlePosition = 'left' | 'center'
|
|
17
|
+
|
|
18
|
+
export interface IPktProgressbar {
|
|
19
|
+
valueCurrent: number
|
|
20
|
+
valueMax?: number
|
|
21
|
+
valueMin?: number
|
|
22
|
+
ariaValueText?: string
|
|
23
|
+
skin?: TProgressbarSkin
|
|
24
|
+
title?: string
|
|
25
|
+
titlePosition?: TProgressbarTitlePosition
|
|
26
|
+
statusType?: TProgressbarStatusType
|
|
27
|
+
statusPlacement?: TProgressbarStatusPlacement
|
|
28
|
+
ariaLabel?: string
|
|
29
|
+
ariaLabelledby?: string
|
|
30
|
+
role?: TProgressbarRole
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@customElement('pkt-progressbar')
|
|
34
|
+
export class PktProgressbar extends PktElement implements IPktProgressbar {
|
|
35
|
+
// Public properties
|
|
36
|
+
@property({ type: Number, reflect: true }) valueCurrent: number = 0
|
|
37
|
+
@property({ type: Number, reflect: true }) valueMax: number = 100
|
|
38
|
+
@property({ type: Number, reflect: true }) valueMin: number = 0
|
|
39
|
+
@property({ type: String, reflect: true }) skin: TProgressbarSkin = 'dark-blue'
|
|
40
|
+
@property({ type: String, reflect: true }) title: string = ''
|
|
41
|
+
@property({ type: String, reflect: true }) titlePosition: TProgressbarTitlePosition = 'left'
|
|
42
|
+
@property({ type: String, reflect: true }) statusType: TProgressbarStatusType = 'none'
|
|
43
|
+
@property({ type: String, reflect: true }) statusPlacement: TProgressbarStatusPlacement =
|
|
44
|
+
'following'
|
|
45
|
+
@property({ type: String, reflect: true }) ariaLabel: string = ''
|
|
46
|
+
@property({ type: String, reflect: true }) ariaLabelledby: string = ''
|
|
47
|
+
@property({ type: String, reflect: true }) ariaValueText: string = ''
|
|
48
|
+
@property({ type: String, reflect: true }) role: TProgressbarRole = 'progressbar'
|
|
49
|
+
|
|
50
|
+
// State
|
|
51
|
+
@state() private labelWidth: number = 0
|
|
52
|
+
@state() private progressBarId: string = this.id
|
|
53
|
+
|
|
54
|
+
// Private properties
|
|
55
|
+
private labelRef: Ref<HTMLSpanElement> = createRef()
|
|
56
|
+
private progressBarRef: Ref<HTMLDivElement> = createRef()
|
|
57
|
+
|
|
58
|
+
firstUpdated(changedProperties: Map<string | number | symbol, unknown>) {
|
|
59
|
+
super.firstUpdated(changedProperties)
|
|
60
|
+
if (!this.id) {
|
|
61
|
+
this.progressBarId = uuidish()
|
|
62
|
+
} else {
|
|
63
|
+
this.progressBarId = this.id
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
updated(changedProperties: Map<string | number | symbol, unknown>) {
|
|
68
|
+
super.updated(changedProperties)
|
|
69
|
+
if (changedProperties.has('valueCurrent') && this.labelRef.value) {
|
|
70
|
+
this.labelWidth = this.labelRef.value.getBoundingClientRect().width || 0
|
|
71
|
+
}
|
|
72
|
+
if (changedProperties.has('id') && this.id) {
|
|
73
|
+
this.progressBarId = this.id
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
render() {
|
|
78
|
+
const totalSteps = this.valueMax - this.valueMin
|
|
79
|
+
const percentageOfSteps = (this.valueCurrent / totalSteps) * 100
|
|
80
|
+
const currentPercentage =
|
|
81
|
+
this.valueMax !== 100 || this.valueMin !== 0
|
|
82
|
+
? Math.round(percentageOfSteps)
|
|
83
|
+
: this.valueCurrent
|
|
84
|
+
const formattedTitle = `${this.valueCurrent} av ${this.valueMax}`
|
|
85
|
+
const hasStatus = this.statusType !== 'none'
|
|
86
|
+
|
|
87
|
+
const ariaLabelledbyText =
|
|
88
|
+
this.ariaLabelledby || (this.progressBarId && `${this.progressBarId}-title`)
|
|
89
|
+
|
|
90
|
+
const barClasses = classMap({
|
|
91
|
+
'pkt-progressbar__bar': true,
|
|
92
|
+
[`pkt-progressbar__bar--${this.skin}`]: !!this.skin,
|
|
93
|
+
})
|
|
94
|
+
const titleClasses = classMap({
|
|
95
|
+
'pkt-progressbar__title': true,
|
|
96
|
+
[`pkt-progressbar__title-center`]: this.titlePosition === 'center',
|
|
97
|
+
})
|
|
98
|
+
const statusClasses = classMap({
|
|
99
|
+
'pkt-progressbar__status': true,
|
|
100
|
+
[`pkt-progressbar__status--center`]: this.statusPlacement === 'center',
|
|
101
|
+
})
|
|
102
|
+
const placementClasses = classMap({
|
|
103
|
+
[`pkt-progressbar__status-placement--following`]: this.statusPlacement === 'following',
|
|
104
|
+
[`pkt-progressbar__status-placement--center`]: this.statusPlacement === 'center',
|
|
105
|
+
[`pkt-progressbar__status-placement--left`]: this.statusPlacement === 'left',
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
return html` <div
|
|
109
|
+
id=${this.progressBarId}
|
|
110
|
+
class="pkt-progressbar__container"
|
|
111
|
+
.ref=${this.progressBarRef}
|
|
112
|
+
style=${styleMap({
|
|
113
|
+
'--pkt-progress-label-width': `${this.labelWidth}px`,
|
|
114
|
+
'--pkt-progress-width': `${currentPercentage}%`,
|
|
115
|
+
})}
|
|
116
|
+
>
|
|
117
|
+
${this.title &&
|
|
118
|
+
html`<p id=${`${this.progressBarId}-title`} class=${titleClasses}>${this.title}</p>`}
|
|
119
|
+
|
|
120
|
+
<div
|
|
121
|
+
.id=${this.progressBarId}
|
|
122
|
+
role=${this.role as any}
|
|
123
|
+
class="pkt-progressbar__bar-wrapper"
|
|
124
|
+
aria-valuemin=${this.valueMin}
|
|
125
|
+
aria-valuemax=${this.valueMax}
|
|
126
|
+
aria-valuenow=${this.valueCurrent}
|
|
127
|
+
aria-labelledby=${ifDefined(ariaLabelledbyText)}
|
|
128
|
+
aria-label=${ifDefined(this.ariaLabel)}
|
|
129
|
+
aria-valuetext=${ifDefined(this.ariaValueText)}
|
|
130
|
+
>
|
|
131
|
+
<div class=${barClasses}></div>
|
|
132
|
+
</div>
|
|
133
|
+
|
|
134
|
+
${hasStatus &&
|
|
135
|
+
html`<div class=${statusClasses}>
|
|
136
|
+
<span class=${placementClasses} ${ref(this.labelRef)}>
|
|
137
|
+
${this.statusType === 'percentage' ? `${currentPercentage}%` : formattedTitle}
|
|
138
|
+
</span>
|
|
139
|
+
</div>`}
|
|
140
|
+
</div>`
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export default PktProgressbar
|
|
@@ -1,110 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { PktElement } from '../element'
|
|
5
|
-
import { PktSlotController } from '@/controllers/pkt-slot-controller'
|
|
6
|
-
import { ref } from 'lit/directives/ref.js'
|
|
7
|
-
import { Ref, createRef } from 'lit/directives/ref.js'
|
|
8
|
-
import specs from 'componentSpecs/tag.json'
|
|
1
|
+
import { PktTag } from './tag'
|
|
2
|
+
export { PktTag } from './tag'
|
|
3
|
+
export default PktTag
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type TagSize = 'small' | 'medium' | 'large'
|
|
13
|
-
type TagSkin = 'blue' | 'green' | 'red' | 'yellow' | 'beige' | 'blue-light' | 'gray' | 'grey'
|
|
14
|
-
type TagType = 'button' | 'reset' | 'submit'
|
|
15
|
-
|
|
16
|
-
export interface IPktTag {
|
|
17
|
-
closeTag?: boolean
|
|
18
|
-
size?: TagSize
|
|
19
|
-
skin?: TagSkin
|
|
20
|
-
textStyle?: string
|
|
21
|
-
iconName?: string
|
|
22
|
-
type?: TagType
|
|
23
|
-
ariaLabel?: string
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@customElement('pkt-tag')
|
|
27
|
-
export class PktTag extends PktElement {
|
|
28
|
-
slotController: PktSlotController
|
|
29
|
-
defaultSlot: Ref<HTMLElement> = createRef()
|
|
30
|
-
|
|
31
|
-
constructor() {
|
|
32
|
-
super()
|
|
33
|
-
this.slotController = new PktSlotController(this, this.defaultSlot)
|
|
34
|
-
this._isClosed = false
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Element attributes
|
|
39
|
-
*/
|
|
40
|
-
@property({ type: Boolean, reflect: true }) closeTag: boolean = specs.props.closeTag.default
|
|
41
|
-
@property({ type: String, reflect: true }) size: TagSize = specs.props.size.default as TagSize
|
|
42
|
-
@property({ type: String, reflect: true }) skin: TagSkin = specs.props.skin.default as TagSkin
|
|
43
|
-
@property({ type: String, reflect: true }) textStyle: string = specs.props.textStyle.default
|
|
44
|
-
@property({ type: String, reflect: true }) iconName: string | undefined = undefined
|
|
45
|
-
@property({ type: String, reflect: true }) type: TagType = specs.props.type.default as TagType
|
|
46
|
-
@property({ type: String, reflect: true }) ariaLabel: string = specs.props.ariaLabel.default
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Element state
|
|
50
|
-
*/
|
|
51
|
-
@state() _isClosed: boolean = false
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Element functions
|
|
55
|
-
*/
|
|
56
|
-
private close = (event: MouseEvent) => {
|
|
57
|
-
this._isClosed = true
|
|
58
|
-
this.dispatchEvent(
|
|
59
|
-
new CustomEvent('close', { detail: { origin: event }, bubbles: true, composed: true }),
|
|
60
|
-
)
|
|
61
|
-
// Historical support of old Vue implementations…
|
|
62
|
-
this.dispatchEvent(
|
|
63
|
-
new CustomEvent('on-close', { detail: { origin: event }, bubbles: true, composed: true }),
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
render() {
|
|
68
|
-
const classes = {
|
|
69
|
-
'pkt-tag': true,
|
|
70
|
-
[`pkt-tag--${this.size}`]: !!this.size,
|
|
71
|
-
[`pkt-tag--${this.skin}`]: !!this.skin,
|
|
72
|
-
[`pkt-tag--${this.textStyle}`]: !!this.textStyle,
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const btnClasses = {
|
|
76
|
-
'pkt-tag': true,
|
|
77
|
-
'pkt-btn': true,
|
|
78
|
-
'pkt-btn--tertiary': true,
|
|
79
|
-
[`pkt-tag--${this.size}`]: !!this.size,
|
|
80
|
-
[`pkt-tag--${this.skin}`]: !!this.skin,
|
|
81
|
-
[`pkt-tag--${this.textStyle}`]: !!this.textStyle,
|
|
82
|
-
'pkt-btn--icons-right-and-left': this.closeTag && !!this.iconName,
|
|
83
|
-
'pkt-hide': this._isClosed,
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (this.closeTag) {
|
|
87
|
-
return html`
|
|
88
|
-
<button
|
|
89
|
-
class=${classMap(btnClasses)}
|
|
90
|
-
type=${this.type}
|
|
91
|
-
aria-label=${this.ariaLabel}
|
|
92
|
-
@click=${this.close}
|
|
93
|
-
>
|
|
94
|
-
${this.iconName &&
|
|
95
|
-
html`<pkt-icon class="pkt-tag__icon" name=${this.iconName}></pkt-icon>`}
|
|
96
|
-
<span ${ref(this.defaultSlot)}></span>
|
|
97
|
-
<pkt-icon class="pkt-tag__close-btn" name="close"></pkt-icon>
|
|
98
|
-
</button>
|
|
99
|
-
`
|
|
100
|
-
} else {
|
|
101
|
-
return html`
|
|
102
|
-
<span class=${classMap(classes)}>
|
|
103
|
-
${this.iconName &&
|
|
104
|
-
html` <pkt-icon class="pkt-tag__icon" name=${this.iconName}></pkt-icon> `}
|
|
105
|
-
<span ${ref(this.defaultSlot)}></span>
|
|
106
|
-
</span>
|
|
107
|
-
`
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
5
|
+
export type { TTagSkin, TTagType } from './tag'
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { classMap } from 'lit/directives/class-map.js'
|
|
2
|
+
import { customElement, property, state } from 'lit/decorators.js'
|
|
3
|
+
import { html } from 'lit'
|
|
4
|
+
import { PktElement } from '@/base-elements/element'
|
|
5
|
+
import { PktSlotController } from '@/controllers/pkt-slot-controller'
|
|
6
|
+
import { ref } from 'lit/directives/ref.js'
|
|
7
|
+
import { Ref, createRef } from 'lit/directives/ref.js'
|
|
8
|
+
import { TPktSize } from '@/types/size'
|
|
9
|
+
import specs from 'componentSpecs/tag.json'
|
|
10
|
+
|
|
11
|
+
import '@/components/icon'
|
|
12
|
+
|
|
13
|
+
export type TTagSkin =
|
|
14
|
+
| 'blue'
|
|
15
|
+
| 'green'
|
|
16
|
+
| 'red'
|
|
17
|
+
| 'yellow'
|
|
18
|
+
| 'beige'
|
|
19
|
+
| 'blue-light'
|
|
20
|
+
| 'gray'
|
|
21
|
+
| 'grey'
|
|
22
|
+
export type TTagType = 'button' | 'reset' | 'submit'
|
|
23
|
+
|
|
24
|
+
export interface IPktTag {
|
|
25
|
+
closeTag?: boolean
|
|
26
|
+
size?: TPktSize
|
|
27
|
+
skin?: TTagSkin
|
|
28
|
+
textStyle?: string
|
|
29
|
+
iconName?: string
|
|
30
|
+
type?: TTagType
|
|
31
|
+
ariaLabel?: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@customElement('pkt-tag')
|
|
35
|
+
export class PktTag extends PktElement {
|
|
36
|
+
slotController: PktSlotController
|
|
37
|
+
defaultSlot: Ref<HTMLElement> = createRef()
|
|
38
|
+
|
|
39
|
+
constructor() {
|
|
40
|
+
super()
|
|
41
|
+
this.slotController = new PktSlotController(this, this.defaultSlot)
|
|
42
|
+
this._isClosed = false
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Element attributes
|
|
47
|
+
*/
|
|
48
|
+
@property({ type: Boolean, reflect: true }) closeTag: boolean = specs.props.closeTag.default
|
|
49
|
+
@property({ type: String, reflect: true }) size: TPktSize = specs.props.size.default as TPktSize
|
|
50
|
+
@property({ type: String, reflect: true }) skin: TTagSkin = specs.props.skin.default as TTagSkin
|
|
51
|
+
@property({ type: String, reflect: true }) textStyle: string = specs.props.textStyle.default
|
|
52
|
+
@property({ type: String, reflect: true }) iconName: string | undefined = undefined
|
|
53
|
+
@property({ type: String, reflect: true }) type: TTagType = specs.props.type.default as TTagType
|
|
54
|
+
@property({ type: String, reflect: true }) ariaLabel: string = specs.props.ariaLabel.default
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Element state
|
|
58
|
+
*/
|
|
59
|
+
@state() _isClosed: boolean = false
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Element functions
|
|
63
|
+
*/
|
|
64
|
+
private close = (event: MouseEvent) => {
|
|
65
|
+
this._isClosed = true
|
|
66
|
+
this.dispatchEvent(
|
|
67
|
+
new CustomEvent('close', { detail: { origin: event }, bubbles: true, composed: true }),
|
|
68
|
+
)
|
|
69
|
+
// Historical support of old Vue implementations…
|
|
70
|
+
this.dispatchEvent(
|
|
71
|
+
new CustomEvent('on-close', { detail: { origin: event }, bubbles: true, composed: true }),
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
render() {
|
|
76
|
+
const classes = {
|
|
77
|
+
'pkt-tag': true,
|
|
78
|
+
[`pkt-tag--${this.size}`]: !!this.size,
|
|
79
|
+
[`pkt-tag--${this.skin}`]: !!this.skin,
|
|
80
|
+
[`pkt-tag--${this.textStyle}`]: !!this.textStyle,
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const btnClasses = {
|
|
84
|
+
'pkt-tag': true,
|
|
85
|
+
'pkt-btn': true,
|
|
86
|
+
'pkt-btn--tertiary': true,
|
|
87
|
+
[`pkt-tag--${this.size}`]: !!this.size,
|
|
88
|
+
[`pkt-tag--${this.skin}`]: !!this.skin,
|
|
89
|
+
[`pkt-tag--${this.textStyle}`]: !!this.textStyle,
|
|
90
|
+
'pkt-btn--icons-right-and-left': this.closeTag && !!this.iconName,
|
|
91
|
+
'pkt-hide': this._isClosed,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (this.closeTag) {
|
|
95
|
+
return html`
|
|
96
|
+
<button
|
|
97
|
+
class=${classMap(btnClasses)}
|
|
98
|
+
type=${this.type}
|
|
99
|
+
aria-label=${this.ariaLabel}
|
|
100
|
+
@click=${this.close}
|
|
101
|
+
>
|
|
102
|
+
${this.iconName &&
|
|
103
|
+
html`<pkt-icon class="pkt-tag__icon" name=${this.iconName}></pkt-icon>`}
|
|
104
|
+
<span ${ref(this.defaultSlot)}></span>
|
|
105
|
+
<pkt-icon class="pkt-tag__close-btn" name="close"></pkt-icon>
|
|
106
|
+
</button>
|
|
107
|
+
`
|
|
108
|
+
} else {
|
|
109
|
+
return html`
|
|
110
|
+
<span class=${classMap(classes)}>
|
|
111
|
+
${this.iconName &&
|
|
112
|
+
html` <pkt-icon class="pkt-tag__icon" name=${this.iconName}></pkt-icon> `}
|
|
113
|
+
<span ${ref(this.defaultSlot)}></span>
|
|
114
|
+
</span>
|
|
115
|
+
`
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -3,9 +3,10 @@ import { customElement, property, state } from 'lit/decorators.js'
|
|
|
3
3
|
import { Ref, createRef, ref } from 'lit/directives/ref.js'
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js'
|
|
5
5
|
import { live } from 'lit/directives/live.js'
|
|
6
|
-
import { PktInputElement } from '
|
|
7
|
-
|
|
8
|
-
import '
|
|
6
|
+
import { PktInputElement } from '@/base-elements/input-element'
|
|
7
|
+
|
|
8
|
+
import '@/components/input-wrapper'
|
|
9
|
+
import '@/components/icon'
|
|
9
10
|
|
|
10
11
|
@customElement('pkt-textarea')
|
|
11
12
|
export class PktTextarea extends PktInputElement {
|
|
@@ -57,7 +58,7 @@ export class PktTextarea extends PktInputElement {
|
|
|
57
58
|
const labelledBy = this.ariaLabelledby || `${this.id}-input-label`
|
|
58
59
|
|
|
59
60
|
return html`<pkt-input-wrapper
|
|
60
|
-
label
|
|
61
|
+
label=${this.label}
|
|
61
62
|
?counter=${this.counter}
|
|
62
63
|
?disabled=${this.disabled}
|
|
63
64
|
?hasError=${this.hasError}
|
|
@@ -2,9 +2,9 @@ import { html, nothing, PropertyValues } from 'lit'
|
|
|
2
2
|
import { customElement, property, state } from 'lit/decorators.js'
|
|
3
3
|
import { Ref, createRef, ref } from 'lit/directives/ref.js'
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js'
|
|
5
|
-
import { PktInputElement } from '
|
|
6
|
-
import '
|
|
7
|
-
import '
|
|
5
|
+
import { PktInputElement } from '@/base-elements/input-element'
|
|
6
|
+
import '@/components/input-wrapper'
|
|
7
|
+
import '@/components/icon'
|
|
8
8
|
|
|
9
9
|
@customElement('pkt-textinput')
|
|
10
10
|
export class PktTextinput extends PktInputElement {
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const n = (r) => {
|
|
2
|
-
if (Array.isArray(r)) return r;
|
|
3
|
-
if (typeof r == "string") return r.split(",");
|
|
4
|
-
}, s = (r) => r ? new Date(r) : null, e = (r) => {
|
|
5
|
-
if (typeof r == "string")
|
|
6
|
-
return r.split(",").map((t) => new Date(t));
|
|
7
|
-
if (Array.isArray(r))
|
|
8
|
-
return r.map((t) => new Date(t));
|
|
9
|
-
}, i = {
|
|
10
|
-
csvToArray: n,
|
|
11
|
-
stringToDate: s,
|
|
12
|
-
stringsToDate: e
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
i as a,
|
|
16
|
-
n as c
|
|
17
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const n=r=>{if(Array.isArray(r))return r;if(typeof r=="string")return r.split(",")},s=r=>r?new Date(r):null,e=r=>{if(typeof r=="string")return r.split(",").map(t=>new Date(t));if(Array.isArray(r))return r.map(t=>new Date(t))},i={csvToArray:n,stringToDate:s,stringsToDate:e};exports.converters=i;exports.csvToArray=n;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2017 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/const r={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},n=i=>(...t)=>({_$litDirective$:i,values:t});class ${constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,s){this._$Ct=t,this._$AM=e,this._$Ci=s}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}/**
|
|
6
|
-
* @license
|
|
7
|
-
* Copyright 2017 Google LLC
|
|
8
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
|
-
*/const E=i=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(i,t)}):customElements.define(i,t)};exports.e=n;exports.i=$;exports.t=E;exports.t$1=r;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2017 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/
|
|
6
|
-
const r = { ATTRIBUTE: 1, CHILD: 2, PROPERTY: 3, BOOLEAN_ATTRIBUTE: 4, EVENT: 5, ELEMENT: 6 }, n = (i) => (...t) => ({ _$litDirective$: i, values: t });
|
|
7
|
-
class E {
|
|
8
|
-
constructor(t) {
|
|
9
|
-
}
|
|
10
|
-
get _$AU() {
|
|
11
|
-
return this._$AM._$AU;
|
|
12
|
-
}
|
|
13
|
-
_$AT(t, e, s) {
|
|
14
|
-
this._$Ct = t, this._$AM = e, this._$Ci = s;
|
|
15
|
-
}
|
|
16
|
-
_$AS(t, e) {
|
|
17
|
-
return this.update(t, e);
|
|
18
|
-
}
|
|
19
|
-
update(t, e) {
|
|
20
|
-
return this.render(...e);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* @license
|
|
25
|
-
* Copyright 2017 Google LLC
|
|
26
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
|
-
*/
|
|
28
|
-
const $ = (i) => (t, e) => {
|
|
29
|
-
e !== void 0 ? e.addInitializer(() => {
|
|
30
|
-
customElements.define(i, t);
|
|
31
|
-
}) : customElements.define(i, t);
|
|
32
|
-
};
|
|
33
|
-
export {
|
|
34
|
-
r as a,
|
|
35
|
-
n as e,
|
|
36
|
-
E as i,
|
|
37
|
-
$ as t
|
|
38
|
-
};
|
package/dist/element.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { r as d, P as c, u as _, s as f, x as s, n as i, E as a } from "./index-CFDwiDTU.js";
|
|
2
|
-
import { o as u } from "./index-RwtTBIhT.js";
|
|
3
|
-
import { e as w } from "./class-map-CBvUV2N3.js";
|
|
4
|
-
import { t as v } from "./custom-element-CWfU4dcr.js";
|
|
5
|
-
var b = Object.defineProperty, k = Object.getOwnPropertyDescriptor, p = (n, r, l, o) => {
|
|
6
|
-
for (var t = o > 1 ? void 0 : o ? k(r, l) : r, h = n.length - 1, x; h >= 0; h--)
|
|
7
|
-
(x = n[h]) && (t = (o ? x(r, l, t) : x(t)) || t);
|
|
8
|
-
return o && t && b(r, l, t), t;
|
|
9
|
-
};
|
|
10
|
-
let e = class extends c {
|
|
11
|
-
constructor() {
|
|
12
|
-
super(), this.forId = _(), this.helptext = "", this.helptextDropdown = "", this.helptextDropdownButton = f.props.helptextDropdownButton.default, this.isHelpTextOpen = !1;
|
|
13
|
-
}
|
|
14
|
-
render() {
|
|
15
|
-
const n = () => {
|
|
16
|
-
this.isHelpTextOpen = !this.isHelpTextOpen, this.dispatchEvent(
|
|
17
|
-
new CustomEvent("toggleHelpText", {
|
|
18
|
-
bubbles: !0,
|
|
19
|
-
detail: { isOpen: !this.isHelpTextOpen }
|
|
20
|
-
})
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
return s`${this.helptext || this.helptextDropdown ? s`<div>
|
|
24
|
-
${this.helptext ? s`<div class="pkt-inputwrapper__helptext" id="${this.forId}-helptext">
|
|
25
|
-
${u(this.helptext)}
|
|
26
|
-
</div>` : a}
|
|
27
|
-
${this.helptextDropdown ? s`<div class="pkt-inputwrapper__helptext-expandable">
|
|
28
|
-
<button
|
|
29
|
-
class="pkt-link pkt-link--icon-right pkt-btn pkt-btn--small pkt-btn--tertiary pkt-btn--icon-right"
|
|
30
|
-
type="button"
|
|
31
|
-
@click=${n}
|
|
32
|
-
>
|
|
33
|
-
<pkt-icon
|
|
34
|
-
class="pkt-btn__icon"
|
|
35
|
-
name="${this.isHelpTextOpen ? "chevron-thin-up" : "chevron-thin-down"}"
|
|
36
|
-
></pkt-icon>
|
|
37
|
-
<span class="pkt-btn__text">${u(this.helptextDropdownButton)}</span>
|
|
38
|
-
</button>
|
|
39
|
-
<div
|
|
40
|
-
class="${w({
|
|
41
|
-
"pkt-inputwrapper__helptext": !0,
|
|
42
|
-
"pkt-inputwrapper__helptext-expandable-open": this.isHelpTextOpen,
|
|
43
|
-
"pkt-inputwrapper__helptext-expandable-closed": !this.isHelpTextOpen
|
|
44
|
-
})}"
|
|
45
|
-
>
|
|
46
|
-
${u(this.helptextDropdown)}
|
|
47
|
-
</div>
|
|
48
|
-
</div>` : a}
|
|
49
|
-
</div>` : a}`;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
p([
|
|
53
|
-
i({ type: String, reflect: !0 })
|
|
54
|
-
], e.prototype, "forId", 2);
|
|
55
|
-
p([
|
|
56
|
-
i({ type: String, reflect: !0 })
|
|
57
|
-
], e.prototype, "helptext", 2);
|
|
58
|
-
p([
|
|
59
|
-
i({ type: String, reflect: !0 })
|
|
60
|
-
], e.prototype, "helptextDropdown", 2);
|
|
61
|
-
p([
|
|
62
|
-
i({ type: String, reflect: !0 })
|
|
63
|
-
], e.prototype, "helptextDropdownButton", 2);
|
|
64
|
-
p([
|
|
65
|
-
d()
|
|
66
|
-
], e.prototype, "isHelpTextOpen", 2);
|
|
67
|
-
e = p([
|
|
68
|
-
v("pkt-helptext")
|
|
69
|
-
], e);
|
|
70
|
-
export {
|
|
71
|
-
e as P
|
|
72
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";const t=require("./index-CR7t1zY9.cjs"),h=require("./index-CmTjXoAb.cjs"),x=require("./class-map-a5HUzP83.cjs"),c=require("./custom-element-B-TlBwRu.cjs");var u=Object.defineProperty,d=Object.getOwnPropertyDescriptor,n=(s,p,r,l)=>{for(var e=l>1?void 0:l?d(p,r):p,i=s.length-1,o;i>=0;i--)(o=s[i])&&(e=(l?o(p,r,e):o(e))||e);return l&&e&&u(p,r,e),e};exports.PktHelptext=class extends t.PktElement{constructor(){super(),this.forId=t.uuidish(),this.helptext="",this.helptextDropdown="",this.helptextDropdownButton=t.specs.props.helptextDropdownButton.default,this.isHelpTextOpen=!1}render(){const p=()=>{this.isHelpTextOpen=!this.isHelpTextOpen,this.dispatchEvent(new CustomEvent("toggleHelpText",{bubbles:!0,detail:{isOpen:!this.isHelpTextOpen}}))},r=()=>this.helptext||this.helptextDropdown?t.x`<div>
|
|
2
|
-
${this.helptext?t.x`<div class="pkt-inputwrapper__helptext" id="${this.forId}-helptext">
|
|
3
|
-
${h.o(this.helptext)}
|
|
4
|
-
</div>`:t.E}
|
|
5
|
-
${this.helptextDropdown?t.x`<div class="pkt-inputwrapper__helptext-expandable">
|
|
6
|
-
<button
|
|
7
|
-
class="pkt-link pkt-link--icon-right pkt-btn pkt-btn--small pkt-btn--tertiary pkt-btn--icon-right"
|
|
8
|
-
type="button"
|
|
9
|
-
@click=${p}
|
|
10
|
-
>
|
|
11
|
-
<pkt-icon
|
|
12
|
-
class="pkt-btn__icon"
|
|
13
|
-
name="${this.isHelpTextOpen?"chevron-thin-up":"chevron-thin-down"}"
|
|
14
|
-
></pkt-icon>
|
|
15
|
-
<span class="pkt-btn__text">${h.o(this.helptextDropdownButton)}</span>
|
|
16
|
-
</button>
|
|
17
|
-
<div
|
|
18
|
-
class="${x.e({"pkt-inputwrapper__helptext":!0,"pkt-inputwrapper__helptext-expandable-open":this.isHelpTextOpen,"pkt-inputwrapper__helptext-expandable-closed":!this.isHelpTextOpen})}"
|
|
19
|
-
>
|
|
20
|
-
${h.o(this.helptextDropdown)}
|
|
21
|
-
</div>
|
|
22
|
-
</div>`:t.E}
|
|
23
|
-
</div>`:t.E;return t.x`${r()}`}};n([t.n({type:String,reflect:!0})],exports.PktHelptext.prototype,"forId",2);n([t.n({type:String,reflect:!0})],exports.PktHelptext.prototype,"helptext",2);n([t.n({type:String,reflect:!0})],exports.PktHelptext.prototype,"helptextDropdown",2);n([t.n({type:String,reflect:!0})],exports.PktHelptext.prototype,"helptextDropdownButton",2);n([t.r()],exports.PktHelptext.prototype,"isHelpTextOpen",2);exports.PktHelptext=n([c.t("pkt-helptext")],exports.PktHelptext);
|