@oslokommune/punkt-elements 12.26.0 → 12.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/{alert-MKb7NX3r.js → alert-BvN80UkI.js} +1 -1
  2. package/dist/{alert-3DZNN48_.cjs → alert-uNzcOJR9.cjs} +1 -1
  3. package/dist/{card-D3ka94lj.cjs → card-BaxqXP-k.cjs} +1 -1
  4. package/dist/{card-ChaNVDWw.js → card-Br6A74Q1.js} +2 -2
  5. package/dist/{datepicker-DdQVxt5g.cjs → datepicker-BC0e34ws.cjs} +16 -15
  6. package/dist/{datepicker-wDY2qm00.js → datepicker-ONV4HuJt.js} +84 -82
  7. package/dist/helptext-DHfBEO42.js +78 -0
  8. package/dist/helptext-xUdEGuNQ.cjs +24 -0
  9. package/dist/index.d.ts +19 -6
  10. package/dist/input-wrapper-DeCY6nta.cjs +50 -0
  11. package/dist/input-wrapper-Df18_PvD.js +172 -0
  12. package/dist/{link-B3PDtnXT.js → link-0N9wG5l8.js} +1 -1
  13. package/dist/{link-BnL83t0x.cjs → link-I_LKEBVK.cjs} +1 -1
  14. package/dist/{linkcard-C4q7HCwY.js → linkcard-BJeRbpq_.js} +1 -1
  15. package/dist/{linkcard-RyOjvpmF.cjs → linkcard-ClXGVwdJ.cjs} +1 -1
  16. package/dist/{messagebox-BDfhozc3.js → messagebox-C5M56R8f.js} +1 -1
  17. package/dist/{messagebox-CuM1y2P_.cjs → messagebox-CC3j63Wp.cjs} +1 -1
  18. package/dist/{modal-gLMGJSSY.cjs → modal-BkchlKkL.cjs} +1 -1
  19. package/dist/{modal-CYv8Qk0Y.js → modal-PKDnp91S.js} +1 -1
  20. package/dist/pkt-alert.cjs +1 -1
  21. package/dist/pkt-alert.js +1 -1
  22. package/dist/pkt-card.cjs +1 -1
  23. package/dist/pkt-card.js +1 -1
  24. package/dist/pkt-datepicker.cjs +1 -1
  25. package/dist/pkt-datepicker.js +1 -1
  26. package/dist/pkt-helptext.cjs +1 -1
  27. package/dist/pkt-helptext.js +1 -1
  28. package/dist/pkt-index.cjs +1 -1
  29. package/dist/pkt-index.js +14 -14
  30. package/dist/pkt-input-wrapper.cjs +1 -1
  31. package/dist/pkt-input-wrapper.js +1 -1
  32. package/dist/pkt-link.cjs +1 -1
  33. package/dist/pkt-link.js +1 -1
  34. package/dist/pkt-linkcard.cjs +1 -1
  35. package/dist/pkt-linkcard.js +1 -1
  36. package/dist/pkt-messagebox.cjs +1 -1
  37. package/dist/pkt-messagebox.js +1 -1
  38. package/dist/pkt-modal.cjs +1 -1
  39. package/dist/pkt-modal.js +1 -1
  40. package/dist/pkt-select.cjs +1 -1
  41. package/dist/pkt-select.js +1 -1
  42. package/dist/pkt-slot-controller-Clbye6cM.js +85 -0
  43. package/dist/pkt-slot-controller-Oc32unDk.cjs +1 -0
  44. package/dist/pkt-tag.cjs +1 -1
  45. package/dist/pkt-tag.js +1 -1
  46. package/dist/pkt-textarea.cjs +1 -1
  47. package/dist/pkt-textarea.js +1 -1
  48. package/dist/pkt-textinput.cjs +1 -1
  49. package/dist/pkt-textinput.js +1 -1
  50. package/dist/select-DFlu7Eq6.cjs +48 -0
  51. package/dist/{select-BJr30hL7.js → select-DVyh7z8C.js} +60 -43
  52. package/dist/{tag-BpAs2fq6.cjs → tag-DGywzHJ5.cjs} +2 -2
  53. package/dist/{tag-DX31g1rQ.js → tag-W9Lf1doW.js} +17 -17
  54. package/dist/{textarea-Da-bIu5d.js → textarea-80zuPTTD.js} +35 -33
  55. package/dist/textarea-WWRAA1LV.cjs +49 -0
  56. package/dist/{textinput-C9pkRR6S.cjs → textinput-CE5AzOur.cjs} +4 -3
  57. package/dist/{textinput-Buj2CAKl.js → textinput-CZIE3v3S.js} +44 -42
  58. package/package.json +3 -3
  59. package/src/components/datepicker/datepicker.ts +8 -0
  60. package/src/components/helptext/helptext.ts +41 -35
  61. package/src/components/input-wrapper/input-wrapper.ts +28 -19
  62. package/src/components/select/select.ts +41 -8
  63. package/src/components/tag/tag.ts +2 -2
  64. package/src/components/textarea/textarea.ts +9 -1
  65. package/src/components/textinput/textinput.ts +10 -1
  66. package/dist/helptext-CNgXo34f.js +0 -75
  67. package/dist/helptext-XPScYIkx.cjs +0 -23
  68. package/dist/input-wrapper-CWvzXs6X.js +0 -160
  69. package/dist/input-wrapper-nvacN4EY.cjs +0 -48
  70. package/dist/pkt-slot-controller-BEDVscvU.cjs +0 -1
  71. package/dist/pkt-slot-controller-DhwCJd_0.js +0 -67
  72. package/dist/select-B19JEWYw.cjs +0 -44
  73. package/dist/textarea-D7uvC79V.cjs +0 -48
@@ -4,6 +4,7 @@ import { Ref, createRef, ref } from 'lit/directives/ref.js'
4
4
  import { ifDefined } from 'lit/directives/if-defined.js'
5
5
  import { PktInputElement } from '@/base-elements/input-element'
6
6
  import { PktOptionsSlotController } from '@/controllers/pkt-options-controller'
7
+ import { PktSlotController } from '@/controllers/pkt-slot-controller'
7
8
  import '@/components/input-wrapper'
8
9
 
9
10
  export type TSelectOption = {
@@ -31,17 +32,19 @@ export interface IPktSelect {
31
32
 
32
33
  @customElement('pkt-select')
33
34
  export class PktSelect extends PktInputElement implements IPktSelect {
34
- private selectRef: Ref<HTMLSelectElement> = createRef()
35
- defaultSlot: Ref<HTMLElement> = createRef()
35
+ private inputRef: Ref<HTMLSelectElement> = createRef()
36
+ private helptextSlot: Ref<HTMLElement> = createRef()
36
37
 
37
38
  @property({ type: Array }) options: TSelectOption[] = []
38
- @property({ type: String }) value: string = ''
39
+ @property({ type: String, reflect: true }) value: string = ''
39
40
 
40
41
  @state() private _options: TSelectOption[] = []
41
42
 
42
43
  constructor() {
43
44
  super()
44
45
  this.optionsController = new PktOptionsSlotController(this)
46
+ this.slotController = new PktSlotController(this, this.helptextSlot)
47
+ this.slotController.skipOptions = true
45
48
  }
46
49
 
47
50
  // Used for initilization
@@ -73,9 +76,23 @@ export class PktSelect extends PktInputElement implements IPktSelect {
73
76
  if (name === 'options') {
74
77
  this._options = value ? JSON.parse(value) : []
75
78
  }
79
+ if (name === 'value' && this.value !== _old) {
80
+ this.valueChanged(value, _old)
81
+ }
76
82
  super.attributeChangedCallback(name, _old, value)
77
83
  }
78
84
 
85
+ updated(changedProperties: PropertyValues) {
86
+ super.updated(changedProperties)
87
+ if (changedProperties.has('value')) {
88
+ this.counterCurrent = this.value?.length || 0
89
+ this.valueChanged(this.value, changedProperties.get('value'))
90
+ }
91
+ if (changedProperties.has('id')) {
92
+ !this.name && this.id && (this.name = this.id)
93
+ }
94
+ }
95
+
79
96
  protected firstUpdated(_changedProperties: PropertyValues): void {
80
97
  super.firstUpdated(_changedProperties)
81
98
  if (this.options.length) {
@@ -100,7 +117,7 @@ export class PktSelect extends PktInputElement implements IPktSelect {
100
117
  .counterMaxLength=${this.counterMaxLength}
101
118
  class="pkt-select"
102
119
  errorMessage=${ifDefined(this.errorMessage)}
103
- forId=${this.id}
120
+ forId=${this.id + '-input'}
104
121
  helptext=${ifDefined(this.helptext)}
105
122
  helptextDropdown=${ifDefined(this.helptextDropdown)}
106
123
  helptextDropdownButton=${ifDefined(this.helptextDropdownButton)}
@@ -114,11 +131,26 @@ export class PktSelect extends PktInputElement implements IPktSelect {
114
131
  aria-errormessage=${`${this.id}-error`}
115
132
  aria-labelledby=${ifDefined(this.ariaLabelledby)}
116
133
  ?disabled=${this.disabled}
117
- id=${this.id}
118
- name=${this.name || this.id}
134
+ id=${this.id + '-input'}
135
+ name=${(this.name || this.id) + '-input'}
119
136
  value=${this.value}
120
- ${ref(this.selectRef)}
121
- ${ref(this.defaultSlot)}
137
+ @change=${(e: Event) => {
138
+ this.value = (e.target as HTMLSelectElement).value
139
+ e.stopImmediatePropagation()
140
+ }}
141
+ @input=${(e: Event) => {
142
+ this.onInput()
143
+ e.stopImmediatePropagation()
144
+ }}
145
+ @focus=${(e: FocusEvent) => {
146
+ this.onFocus()
147
+ e.stopImmediatePropagation()
148
+ }}
149
+ @blur=${(e: FocusEvent) => {
150
+ this.onBlur()
151
+ e.stopImmediatePropagation()
152
+ }}
153
+ ${ref(this.inputRef)}
122
154
  >
123
155
  ${this._options.length > 0 &&
124
156
  this._options.map(
@@ -132,6 +164,7 @@ export class PktSelect extends PktInputElement implements IPktSelect {
132
164
  </option>`,
133
165
  )}
134
166
  </select>
167
+ <div class="pkt-contents" ${ref(this.helptextSlot)} name="helptext" slot="helptext"></div>
135
168
  </pkt-input-wrapper>
136
169
  `
137
170
  }
@@ -51,8 +51,8 @@ export class PktTag extends PktElement {
51
51
  @property({ type: String, reflect: true }) skin: TTagSkin = specs.props.skin.default as TTagSkin
52
52
  @property({ type: String, reflect: true }) textStyle: string = specs.props.textStyle.default
53
53
  @property({ type: String, reflect: true }) iconName: string | undefined = undefined
54
- @property({ type: String, reflect: true }) type: TTagType = specs.props.type.default as TTagType
55
- @property({ type: String, reflect: true }) ariaLabel: string = specs.props.ariaLabel.default
54
+ @property({ type: String }) type: TTagType = specs.props.type.default as TTagType
55
+ @property({ type: String }) ariaLabel: string = specs.props.ariaLabel.default
56
56
 
57
57
  /**
58
58
  * Element state
@@ -4,12 +4,16 @@ 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
6
  import { PktInputElement } from '@/base-elements/input-element'
7
+ import { PktSlotController } from '@/controllers/pkt-slot-controller'
7
8
 
8
9
  import '@/components/input-wrapper'
9
10
  import '@/components/icon'
10
11
 
11
12
  @customElement('pkt-textarea')
12
13
  export class PktTextarea extends PktInputElement {
14
+ private inputRef: Ref<HTMLTextAreaElement> = createRef()
15
+ private helptextSlot: Ref<HTMLElement> = createRef()
16
+
13
17
  @property({ type: String, reflect: true })
14
18
  value: string = ''
15
19
 
@@ -24,7 +28,10 @@ export class PktTextarea extends PktInputElement {
24
28
 
25
29
  @state() counterCurrent = 0
26
30
 
27
- private inputRef: Ref<HTMLTextAreaElement> = createRef()
31
+ constructor() {
32
+ super()
33
+ this.slotController = new PktSlotController(this, this.helptextSlot)
34
+ }
28
35
 
29
36
  attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
30
37
  if (name === 'value' && this.value !== _old) {
@@ -79,6 +86,7 @@ export class PktTextarea extends PktInputElement {
79
86
  .requiredText=${this.requiredText}
80
87
  class="pkt-textarea"
81
88
  >
89
+ <div class="pkt-contents" ${ref(this.helptextSlot)} name="helptext" slot="helptext"></div>
82
90
  <textarea
83
91
  ${ref(this.inputRef)}
84
92
  class=${inputClasses}
@@ -3,11 +3,16 @@ 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 { PktInputElement } from '@/base-elements/input-element'
6
+ import { PktSlotController } from '@/controllers/pkt-slot-controller'
7
+
6
8
  import '@/components/input-wrapper'
7
9
  import '@/components/icon'
8
10
 
9
11
  @customElement('pkt-textinput')
10
12
  export class PktTextinput extends PktInputElement {
13
+ private inputRef: Ref<HTMLTextAreaElement> = createRef()
14
+ private helptextSlot: Ref<HTMLElement> = createRef()
15
+
11
16
  @property({ type: String, reflect: true })
12
17
  value: string = ''
13
18
 
@@ -34,7 +39,10 @@ export class PktTextinput extends PktInputElement {
34
39
 
35
40
  @state() counterCurrent = 0
36
41
 
37
- private inputRef: Ref<HTMLInputElement> = createRef()
42
+ constructor() {
43
+ super()
44
+ this.slotController = new PktSlotController(this, this.helptextSlot)
45
+ }
38
46
 
39
47
  attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
40
48
  if (name === 'value' && this.value !== _old) {
@@ -92,6 +100,7 @@ export class PktTextinput extends PktInputElement {
92
100
  .requiredText=${this.requiredText}
93
101
  class="pkt-textinput"
94
102
  >
103
+ <div class="pkt-contents" ${ref(this.helptextSlot)} name="helptext" slot="helptext"></div>
95
104
  <div class="pkt-input__container">
96
105
  ${this.prefix ? html`<div class="pkt-input-prefix">${this.prefix}</div>` : nothing}
97
106
  <input
@@ -1,75 +0,0 @@
1
- import { P as d, x as s, n as l, t as c, E as a } from "./element-BKrU5soj.js";
2
- import { o as u } from "./icon-Bsb0MB2h.js";
3
- import { e as f } from "./class-map-CQzsZCwS.js";
4
- import { r as _ } from "./state-C36ZmZgt.js";
5
- import { u as w } from "./stringutils-DJjRa8dG.js";
6
- import { s as m } from "./input-wrapper-Bw9tARAD.js";
7
- var v = Object.defineProperty, b = Object.getOwnPropertyDescriptor, r = (o, n, p, i) => {
8
- for (var t = i > 1 ? void 0 : i ? b(n, p) : n, h = o.length - 1, x; h >= 0; h--)
9
- (x = o[h]) && (t = (i ? x(n, p, t) : x(t)) || t);
10
- return i && t && v(n, p, t), t;
11
- };
12
- let e = class extends d {
13
- constructor() {
14
- super(), this.forId = w(), this.helptext = "", this.helptextDropdown = "", this.helptextDropdownButton = m.props.helptextDropdownButton.default, this.isHelpTextOpen = !1;
15
- }
16
- render() {
17
- const o = () => {
18
- const p = !this.isHelpTextOpen;
19
- this.isHelpTextOpen = p, this.dispatchEvent(
20
- new CustomEvent("toggleHelpText", {
21
- bubbles: !0,
22
- detail: { isOpen: p }
23
- })
24
- );
25
- };
26
- return s`${this.helptext || this.helptextDropdown ? s`<div>
27
- ${this.helptext ? s`<div class="pkt-inputwrapper__helptext" id="${this.forId}-helptext">
28
- ${u(this.helptext)}
29
- </div>` : a}
30
- ${this.helptextDropdown ? s`<div class="pkt-inputwrapper__helptext-expandable">
31
- <button
32
- class="pkt-link pkt-link--icon-right pkt-btn pkt-btn--small pkt-btn--tertiary pkt-btn--icon-right"
33
- type="button"
34
- @click=${o}
35
- >
36
- <pkt-icon
37
- class="pkt-btn__icon"
38
- name="${this.isHelpTextOpen ? "chevron-thin-up" : "chevron-thin-down"}"
39
- ></pkt-icon>
40
- <span class="pkt-btn__text">${u(this.helptextDropdownButton)}</span>
41
- </button>
42
- <div
43
- class="${f({
44
- "pkt-inputwrapper__helptext": !0,
45
- "pkt-inputwrapper__helptext-expandable-open": this.isHelpTextOpen,
46
- "pkt-inputwrapper__helptext-expandable-closed": !this.isHelpTextOpen
47
- })}"
48
- >
49
- ${u(this.helptextDropdown)}
50
- </div>
51
- </div>` : a}
52
- </div>` : a}`;
53
- }
54
- };
55
- r([
56
- l({ type: String, reflect: !0 })
57
- ], e.prototype, "forId", 2);
58
- r([
59
- l({ type: String, reflect: !0 })
60
- ], e.prototype, "helptext", 2);
61
- r([
62
- l({ type: String, reflect: !0 })
63
- ], e.prototype, "helptextDropdown", 2);
64
- r([
65
- l({ type: String, reflect: !0 })
66
- ], e.prototype, "helptextDropdownButton", 2);
67
- r([
68
- _()
69
- ], e.prototype, "isHelpTextOpen", 2);
70
- e = r([
71
- c("pkt-helptext")
72
- ], e);
73
- export {
74
- e as P
75
- };
@@ -1,23 +0,0 @@
1
- "use strict";const t=require("./element-B0UgldHm.cjs"),h=require("./icon-PWn7rnfg.cjs"),x=require("./class-map-aeZWY44S.cjs"),u=require("./state-CG-binsl.cjs"),c=require("./stringutils-CkVRq4jP.cjs"),a=require("./input-wrapper-jPnKsfEC.cjs");var d=Object.defineProperty,k=Object.getOwnPropertyDescriptor,r=(i,n,s,e)=>{for(var p=e>1?void 0:e?k(n,s):n,l=i.length-1,o;l>=0;l--)(o=i[l])&&(p=(e?o(n,s,p):o(p))||p);return e&&p&&d(n,s,p),p};exports.PktHelptext=class extends t.PktElement{constructor(){super(),this.forId=c.uuidish(),this.helptext="",this.helptextDropdown="",this.helptextDropdownButton=a.specs.props.helptextDropdownButton.default,this.isHelpTextOpen=!1}render(){const n=()=>{const e=!this.isHelpTextOpen;this.isHelpTextOpen=e,this.dispatchEvent(new CustomEvent("toggleHelpText",{bubbles:!0,detail:{isOpen:e}}))},s=()=>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=${n}
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`${s()}`}};r([t.n({type:String,reflect:!0})],exports.PktHelptext.prototype,"forId",2);r([t.n({type:String,reflect:!0})],exports.PktHelptext.prototype,"helptext",2);r([t.n({type:String,reflect:!0})],exports.PktHelptext.prototype,"helptextDropdown",2);r([t.n({type:String,reflect:!0})],exports.PktHelptext.prototype,"helptextDropdownButton",2);r([u.r()],exports.PktHelptext.prototype,"isHelpTextOpen",2);exports.PktHelptext=r([t.t("pkt-helptext")],exports.PktHelptext);
@@ -1,160 +0,0 @@
1
- import { P as m, E as l, x as p, n as r, t as w } from "./element-BKrU5soj.js";
2
- import { P as k } from "./pkt-slot-controller-DhwCJd_0.js";
3
- import { e as v, n as T } from "./ref-D5qG7OFB.js";
4
- import { o as D } from "./icon-Bsb0MB2h.js";
5
- import { e as c } from "./class-map-CQzsZCwS.js";
6
- import { u as _ } from "./stringutils-DJjRa8dG.js";
7
- import { s } from "./input-wrapper-Bw9tARAD.js";
8
- import "./helptext-CNgXo34f.js";
9
- var E = Object.defineProperty, B = Object.getOwnPropertyDescriptor, e = (h, d, a, i) => {
10
- for (var o = i > 1 ? void 0 : i ? B(d, a) : d, n = h.length - 1, u; n >= 0; n--)
11
- (u = h[n]) && (o = (i ? u(d, a, o) : u(o)) || o);
12
- return i && o && E(d, a, o), o;
13
- };
14
- let t = class extends m {
15
- constructor() {
16
- super(), this.defaultSlot = v(), this.forId = _(), this.label = "", this.helptext = null, this.helptextDropdown = null, this.helptextDropdownButton = null, this.counter = s.props.counter.default, this.counterCurrent = 0, this.counterMaxLength = 0, this.optionalTag = s.props.optionalTag.default, this.optionalText = s.props.optionalText.default, this.requiredTag = s.props.requiredTag.default, this.requiredText = s.props.requiredText.default, this.hasError = s.props.hasError.default, this.errorMessage = "", this.disabled = s.props.disabled.default, this.inline = s.props.inline.default, this.ariaDescribedby = void 0, this.hasFieldset = s.props.hasFieldset.default, this.useWrapper = s.props.useWrapper.default, this.role = "group", this.slotController = new k(this, this.defaultSlot);
17
- }
18
- render() {
19
- const h = {
20
- "pkt-inputwrapper": !0,
21
- "pkt-inputwrapper--error": this.hasError,
22
- "pkt-inputwrapper--disabled": this.disabled,
23
- "pkt-inputwrapper--inline": this.inline
24
- }, d = {
25
- "pkt-tag": !0,
26
- "pkt-tag--small": !0,
27
- "pkt-tag--thin-text": !0,
28
- "pkt-tag--blue-light": this.optionalTag,
29
- "pkt-tag--beige": !this.optionalTag && this.requiredTag
30
- }, a = this.helptextDropdown !== "", i = {
31
- "pkt-inputwrapper__label": !0,
32
- "pkt-inputwrapper__fieldset": this.hasFieldset,
33
- "pkt-inputwrapper__legend": this.hasFieldset
34
- }, o = this.ariaDescribedby ? this.ariaDescribedby : this.helptext ? `${this.forId}-helptext` : l, n = () => this.optionalTag || this.requiredTag ? p`<span class=${c(d)}
35
- >${this.optionalTag ? this.optionalText : this.requiredTag ? this.requiredText : l}</span
36
- >` : l, u = () => this.useWrapper ? this.hasFieldset ? p`<legend class="pkt-inputwrapper__legend" id="${this.forId}-label">
37
- ${this.label} ${n()}
38
- </legend>` : a ? p`<h2>${this.label} ${n()}</h2>` : p`<span>${this.label} ${n()}</span>` : p`<label
39
- for="${this.forId}"
40
- class="pkt-sr-only"
41
- aria-describedby="${o}"
42
- id="${this.forId}-label"
43
- >
44
- ${this.label}
45
- </label>`, g = () => this.useWrapper && (this.helptext || this.helptextDropdown) ? p`
46
- <pkt-helptext
47
- .forId=${this.forId}
48
- .helptext=${this.helptext}
49
- .helptextDropdown=${this.helptextDropdown}
50
- .helptextDropdownButton=${this.helptextDropdownButton || s.props.helptextDropdownButton.default}
51
- @toggleHelpText=${(x) => {
52
- this.toggleDropdown(x);
53
- }}
54
- ></pkt-helptext>
55
- ` : l, y = () => this.counter ? p`<div class="pkt-input__counter" aria-live="polite" aria-atomic="true">
56
- ${this.counterCurrent || 0}
57
- ${this.counterMaxLength ? `/${this.counterMaxLength}` : l}
58
- </div>` : l, b = () => this.hasError && this.errorMessage ? p`<div
59
- role="alert"
60
- class="pkt-alert pkt-alert--error pkt-alert--compact"
61
- aria-live="assertive"
62
- aria-atomic="true"
63
- id="${this.forId}-error"
64
- >
65
- <pkt-icon name="alert-error" class="pkt-alert__icon"></pkt-icon>
66
- <div class="pkt-alert__text">${D(this.errorMessage)}</div>
67
- </div>` : l, f = () => p`
68
- ${u()} ${g()}
69
- ${a ? p`<label for="${this.forId}" class="pkt-sr-only" aria-describedby="${o}"
70
- >${this.label}</label
71
- >` : l}
72
- <div class="pkt-contents" ${T(this.defaultSlot)}></div>
73
- ${y()} ${b()}
74
- `, $ = () => this.hasFieldset ? p`<fieldset class=${c(i)} aria-describedby="${o}">
75
- ${f()}
76
- </fieldset>` : a ? p`<div class=${c(i)}>${f()}</div>` : p`<label
77
- class=${c(i)}
78
- for="${this.forId}"
79
- aria-describedby="${o}"
80
- id="${this.forId}-label"
81
- >
82
- ${f()}
83
- </label>`;
84
- return p`<div class=${c(h)}>${$()}</div> `;
85
- }
86
- toggleDropdown(h) {
87
- this.dispatchEvent(
88
- new CustomEvent("toggleHelpText", {
89
- bubbles: !1,
90
- detail: { isOpen: h.detail.isOpen }
91
- })
92
- );
93
- }
94
- };
95
- e([
96
- r({ type: String })
97
- ], t.prototype, "forId", 2);
98
- e([
99
- r({ type: String })
100
- ], t.prototype, "label", 2);
101
- e([
102
- r({ type: String })
103
- ], t.prototype, "helptext", 2);
104
- e([
105
- r({ type: String })
106
- ], t.prototype, "helptextDropdown", 2);
107
- e([
108
- r({ type: String })
109
- ], t.prototype, "helptextDropdownButton", 2);
110
- e([
111
- r({ type: Boolean })
112
- ], t.prototype, "counter", 2);
113
- e([
114
- r({ type: Number })
115
- ], t.prototype, "counterCurrent", 2);
116
- e([
117
- r({ type: Number })
118
- ], t.prototype, "counterMaxLength", 2);
119
- e([
120
- r({ type: Boolean })
121
- ], t.prototype, "optionalTag", 2);
122
- e([
123
- r({ type: String })
124
- ], t.prototype, "optionalText", 2);
125
- e([
126
- r({ type: Boolean })
127
- ], t.prototype, "requiredTag", 2);
128
- e([
129
- r({ type: String })
130
- ], t.prototype, "requiredText", 2);
131
- e([
132
- r({ type: Boolean })
133
- ], t.prototype, "hasError", 2);
134
- e([
135
- r({ type: String })
136
- ], t.prototype, "errorMessage", 2);
137
- e([
138
- r({ type: Boolean })
139
- ], t.prototype, "disabled", 2);
140
- e([
141
- r({ type: Boolean })
142
- ], t.prototype, "inline", 2);
143
- e([
144
- r({ type: String })
145
- ], t.prototype, "ariaDescribedby", 2);
146
- e([
147
- r({ type: Boolean })
148
- ], t.prototype, "hasFieldset", 2);
149
- e([
150
- r({ type: Boolean })
151
- ], t.prototype, "useWrapper", 2);
152
- e([
153
- r({ type: String, reflect: !0 })
154
- ], t.prototype, "role", 2);
155
- t = e([
156
- w("pkt-input-wrapper")
157
- ], t);
158
- export {
159
- t as P
160
- };
@@ -1,48 +0,0 @@
1
- "use strict";const t=require("./element-B0UgldHm.cjs"),f=require("./pkt-slot-controller-BEDVscvU.cjs"),d=require("./ref-DDYBJ4EB.cjs"),$=require("./icon-PWn7rnfg.cjs"),l=require("./class-map-aeZWY44S.cjs"),I=require("./stringutils-CkVRq4jP.cjs"),p=require("./input-wrapper-jPnKsfEC.cjs");require("./helptext-XPScYIkx.cjs");var P=Object.defineProperty,W=Object.getOwnPropertyDescriptor,e=(u,s,a,o)=>{for(var r=o>1?void 0:o?W(s,a):s,i=u.length-1,n;i>=0;i--)(n=u[i])&&(r=(o?n(s,a,r):n(r))||r);return o&&r&&P(s,a,r),r};exports.PktInputWrapper=class extends t.PktElement{constructor(){super(),this.defaultSlot=d.e(),this.forId=I.uuidish(),this.label="",this.helptext=null,this.helptextDropdown=null,this.helptextDropdownButton=null,this.counter=p.specs.props.counter.default,this.counterCurrent=0,this.counterMaxLength=0,this.optionalTag=p.specs.props.optionalTag.default,this.optionalText=p.specs.props.optionalText.default,this.requiredTag=p.specs.props.requiredTag.default,this.requiredText=p.specs.props.requiredText.default,this.hasError=p.specs.props.hasError.default,this.errorMessage="",this.disabled=p.specs.props.disabled.default,this.inline=p.specs.props.inline.default,this.ariaDescribedby=void 0,this.hasFieldset=p.specs.props.hasFieldset.default,this.useWrapper=p.specs.props.useWrapper.default,this.role="group",this.slotController=new f.PktSlotController(this,this.defaultSlot)}render(){const s={"pkt-inputwrapper":!0,"pkt-inputwrapper--error":this.hasError,"pkt-inputwrapper--disabled":this.disabled,"pkt-inputwrapper--inline":this.inline},a={"pkt-tag":!0,"pkt-tag--small":!0,"pkt-tag--thin-text":!0,"pkt-tag--blue-light":this.optionalTag,"pkt-tag--beige":!this.optionalTag&&this.requiredTag},o=this.helptextDropdown!=="",r={"pkt-inputwrapper__label":!0,"pkt-inputwrapper__fieldset":this.hasFieldset,"pkt-inputwrapper__legend":this.hasFieldset},i=this.ariaDescribedby?this.ariaDescribedby:this.helptext?`${this.forId}-helptext`:t.E,n=()=>this.optionalTag||this.requiredTag?t.x`<span class=${l.e(a)}
2
- >${this.optionalTag?this.optionalText:this.requiredTag?this.requiredText:t.E}</span
3
- >`:t.E,c=()=>this.useWrapper?this.hasFieldset?t.x`<legend class="pkt-inputwrapper__legend" id="${this.forId}-label">
4
- ${this.label} ${n()}
5
- </legend>`:o?t.x`<h2>${this.label} ${n()}</h2>`:t.x`<span>${this.label} ${n()}</span>`:t.x`<label
6
- for="${this.forId}"
7
- class="pkt-sr-only"
8
- aria-describedby="${i}"
9
- id="${this.forId}-label"
10
- >
11
- ${this.label}
12
- </label>`,g=()=>this.useWrapper&&(this.helptext||this.helptextDropdown)?t.x`
13
- <pkt-helptext
14
- .forId=${this.forId}
15
- .helptext=${this.helptext}
16
- .helptextDropdown=${this.helptextDropdown}
17
- .helptextDropdownButton=${this.helptextDropdownButton||p.specs.props.helptextDropdownButton.default}
18
- @toggleHelpText=${k=>{this.toggleDropdown(k)}}
19
- ></pkt-helptext>
20
- `:t.E,x=()=>this.counter?t.x`<div class="pkt-input__counter" aria-live="polite" aria-atomic="true">
21
- ${this.counterCurrent||0}
22
- ${this.counterMaxLength?`/${this.counterMaxLength}`:t.E}
23
- </div>`:t.E,y=()=>this.hasError&&this.errorMessage?t.x`<div
24
- role="alert"
25
- class="pkt-alert pkt-alert--error pkt-alert--compact"
26
- aria-live="assertive"
27
- aria-atomic="true"
28
- id="${this.forId}-error"
29
- >
30
- <pkt-icon name="alert-error" class="pkt-alert__icon"></pkt-icon>
31
- <div class="pkt-alert__text">${$.o(this.errorMessage)}</div>
32
- </div>`:t.E,h=()=>t.x`
33
- ${c()} ${g()}
34
- ${o?t.x`<label for="${this.forId}" class="pkt-sr-only" aria-describedby="${i}"
35
- >${this.label}</label
36
- >`:t.E}
37
- <div class="pkt-contents" ${d.n(this.defaultSlot)}></div>
38
- ${x()} ${y()}
39
- `,b=()=>this.hasFieldset?t.x`<fieldset class=${l.e(r)} aria-describedby="${i}">
40
- ${h()}
41
- </fieldset>`:o?t.x`<div class=${l.e(r)}>${h()}</div>`:t.x`<label
42
- class=${l.e(r)}
43
- for="${this.forId}"
44
- aria-describedby="${i}"
45
- id="${this.forId}-label"
46
- >
47
- ${h()}
48
- </label>`;return t.x`<div class=${l.e(s)}>${b()}</div> `}toggleDropdown(s){this.dispatchEvent(new CustomEvent("toggleHelpText",{bubbles:!1,detail:{isOpen:s.detail.isOpen}}))}};e([t.n({type:String})],exports.PktInputWrapper.prototype,"forId",2);e([t.n({type:String})],exports.PktInputWrapper.prototype,"label",2);e([t.n({type:String})],exports.PktInputWrapper.prototype,"helptext",2);e([t.n({type:String})],exports.PktInputWrapper.prototype,"helptextDropdown",2);e([t.n({type:String})],exports.PktInputWrapper.prototype,"helptextDropdownButton",2);e([t.n({type:Boolean})],exports.PktInputWrapper.prototype,"counter",2);e([t.n({type:Number})],exports.PktInputWrapper.prototype,"counterCurrent",2);e([t.n({type:Number})],exports.PktInputWrapper.prototype,"counterMaxLength",2);e([t.n({type:Boolean})],exports.PktInputWrapper.prototype,"optionalTag",2);e([t.n({type:String})],exports.PktInputWrapper.prototype,"optionalText",2);e([t.n({type:Boolean})],exports.PktInputWrapper.prototype,"requiredTag",2);e([t.n({type:String})],exports.PktInputWrapper.prototype,"requiredText",2);e([t.n({type:Boolean})],exports.PktInputWrapper.prototype,"hasError",2);e([t.n({type:String})],exports.PktInputWrapper.prototype,"errorMessage",2);e([t.n({type:Boolean})],exports.PktInputWrapper.prototype,"disabled",2);e([t.n({type:Boolean})],exports.PktInputWrapper.prototype,"inline",2);e([t.n({type:String})],exports.PktInputWrapper.prototype,"ariaDescribedby",2);e([t.n({type:Boolean})],exports.PktInputWrapper.prototype,"hasFieldset",2);e([t.n({type:Boolean})],exports.PktInputWrapper.prototype,"useWrapper",2);e([t.n({type:String,reflect:!0})],exports.PktInputWrapper.prototype,"role",2);exports.PktInputWrapper=e([t.t("pkt-input-wrapper")],exports.PktInputWrapper);
@@ -1 +0,0 @@
1
- "use strict";class h{constructor(t,...e){this.nodes=[],this.host=t,this.host.addController(this),this.slots=e,this.nodes=[],this.observer=new MutationObserver(o=>this.handleMutations(o))}hostConnected(){this.updateNodes(),this.observer.observe(this.host,{childList:!0})}hostDisconnected(){this.observer.disconnect()}hostUpdated(){this.updateSlots()}updateNodes(){this.nodes=[],Array.from(this.host.childNodes).forEach(e=>{var o;if(e.nodeType===Node.TEXT_NODE&&((o=e.nodeValue)!=null&&o.trim())){const s=document==null?void 0:document.createElement("template");s.content.appendChild(e),this.nodes.push(s)}else this.isSlotElement(e)||this.nodes.push(e)})}updateSlots(){this.slots.forEach(t=>{if(!t.value)return;const e=t.value.getAttribute("name"),s=this.nodes.flatMap(i=>i.getAttribute&&i.getAttribute("slot")==e?this.nodeFromElement(i,t):[]).filter(i=>t.value&&!t.value.contains(i)&&!i.contains(t.value));if(s.length>0)if(typeof t.value.replaceChildren!="function"){for(;t.value.firstChild;)t.value.removeChild(t.value.firstChild);t.value.append(...s)}else t.value.replaceChildren(...s)})}handleMutations(t){let e=!1;t.forEach(o=>{o.type==="childList"&&(o.addedNodes.forEach(s=>{var l;const i=s.nodeType===Node.ELEMENT_NODE&&!this.isSlotElement(s),d=s.nodeType===Node.TEXT_NODE&&((l=s.nodeValue)==null?void 0:l.trim());if(i)this.nodes.push(s),e=!0;else if(d){const n=document==null?void 0:document.createElement("template");n.content.appendChild(s),this.nodes.push(n),e=!0}}),o.removedNodes.forEach(s=>{this.nodes=this.nodes.filter(i=>i!==s),e=!0}))}),e&&this.updateSlots()}isSlotElement(t){return this.slots.some(e=>e.value===t)}nodeFromElement(t,e){var o;return t===((o=e.value)==null?void 0:o.parentNode)?[]:t instanceof HTMLTemplateElement?Array.from(t.content.childNodes):[t]}}exports.PktSlotController=h;
@@ -1,67 +0,0 @@
1
- class a {
2
- constructor(t, ...e) {
3
- this.nodes = [], this.host = t, this.host.addController(this), this.slots = e, this.nodes = [], this.observer = new MutationObserver((o) => this.handleMutations(o));
4
- }
5
- hostConnected() {
6
- this.updateNodes(), this.observer.observe(this.host, { childList: !0 });
7
- }
8
- hostDisconnected() {
9
- this.observer.disconnect();
10
- }
11
- hostUpdated() {
12
- this.updateSlots();
13
- }
14
- updateNodes() {
15
- this.nodes = [], Array.from(this.host.childNodes).forEach((e) => {
16
- var o;
17
- if (e.nodeType === Node.TEXT_NODE && ((o = e.nodeValue) != null && o.trim())) {
18
- const s = document == null ? void 0 : document.createElement("template");
19
- s.content.appendChild(e), this.nodes.push(s);
20
- } else this.isSlotElement(e) || this.nodes.push(e);
21
- });
22
- }
23
- updateSlots() {
24
- this.slots.forEach((t) => {
25
- if (!t.value) return;
26
- const e = t.value.getAttribute("name"), s = this.nodes.flatMap(
27
- (i) => i.getAttribute && i.getAttribute("slot") == e ? this.nodeFromElement(i, t) : []
28
- ).filter(
29
- (i) => t.value && !t.value.contains(i) && !i.contains(t.value)
30
- );
31
- if (s.length > 0)
32
- if (typeof t.value.replaceChildren != "function") {
33
- for (; t.value.firstChild; )
34
- t.value.removeChild(t.value.firstChild);
35
- t.value.append(...s);
36
- } else
37
- t.value.replaceChildren(...s);
38
- });
39
- }
40
- handleMutations(t) {
41
- let e = !1;
42
- t.forEach((o) => {
43
- o.type === "childList" && (o.addedNodes.forEach((s) => {
44
- var l;
45
- const i = s.nodeType === Node.ELEMENT_NODE && !this.isSlotElement(s), d = s.nodeType === Node.TEXT_NODE && ((l = s.nodeValue) == null ? void 0 : l.trim());
46
- if (i)
47
- this.nodes.push(s), e = !0;
48
- else if (d) {
49
- const n = document == null ? void 0 : document.createElement("template");
50
- n.content.appendChild(s), this.nodes.push(n), e = !0;
51
- }
52
- }), o.removedNodes.forEach((s) => {
53
- this.nodes = this.nodes.filter((i) => i !== s), e = !0;
54
- }));
55
- }), e && this.updateSlots();
56
- }
57
- isSlotElement(t) {
58
- return this.slots.some((e) => e.value === t);
59
- }
60
- nodeFromElement(t, e) {
61
- var o;
62
- return t === ((o = e.value) == null ? void 0 : o.parentNode) ? [] : t instanceof HTMLTemplateElement ? Array.from(t.content.childNodes) : [t];
63
- }
64
- }
65
- export {
66
- a as P
67
- };
@@ -1,44 +0,0 @@
1
- "use strict";const l=require("./element-B0UgldHm.cjs"),d=require("./state-CG-binsl.cjs"),a=require("./ref-DDYBJ4EB.cjs"),o=require("./if-defined-Br3lDE5v.cjs"),u=require("./input-element-Dnda8hac.cjs");require("./input-wrapper-nvacN4EY.cjs");class c{constructor(t){this.nodes=[],this.options=[],this.host=t,this.host.addController(this),this.nodes=[],this.options=[],this.observer=new MutationObserver(e=>this.handleMutations(e))}hostConnected(){Array.from(this.host.childNodes).forEach(t=>{(t.nodeName==="OPTION"||t.nodeName==="DATA")&&this.addNode(t)}),this.observer.observe(this.host,{childList:!0})}hostDisconnected(){this.observer.disconnect()}addNode(t){(t.nodeName==="OPTION"||t.nodeName==="DATA")&&(t.setAttribute("class","pkt-hide"),this.nodes.push(t))}createOptions(){this.options=this.nodes.map(t=>({value:t.getAttribute("value")||t.textContent||"",label:t.textContent||t.getAttribute("value")||"",selected:!!t.getAttribute("selected"),disabled:!!t.getAttribute("disabled")})),this.host.setAttribute("options",JSON.stringify(this.options))}handleMutations(t){let e=!1;t.forEach(s=>{s.addedNodes.forEach(i=>{(i.nodeName==="OPTION"||i.nodeName==="DATA")&&(this.addNode(i),e=!0)}),s.removedNodes.forEach(i=>{(i.nodeName==="OPTION"||i.nodeName==="DATA")&&(this.nodes=this.nodes.filter(r=>r!==i),e=!0)})}),e&&this.createOptions()}}var b=Object.defineProperty,f=Object.getOwnPropertyDescriptor,h=(n,t,e,s)=>{for(var i=s>1?void 0:s?f(t,e):t,r=n.length-1,p;r>=0;r--)(p=n[r])&&(i=(s?p(t,e,i):p(i))||i);return s&&i&&b(t,e,i),i};exports.PktSelect=class extends u.PktInputElement{constructor(){super(),this.selectRef=a.e(),this.defaultSlot=a.e(),this.options=[],this.value="",this._options=[],this.optionsController=new c(this)}connectedCallback(){super.connectedCallback();const t=this.options.length>0,e=this.optionsController.nodes.length&&this.optionsController.nodes.length>0;!t&&e?this.optionsController.nodes.forEach(s=>{const i={value:s.getAttribute("value")||s.textContent||"",label:s.textContent||s.getAttribute("value")||"",disabled:!!s.getAttribute("disabled")};s.getAttribute("selected")&&!this.value&&(this.value=i.value),this._options.push(i)}):this._options=this.options}attributeChangedCallback(t,e,s){t==="options"&&(this._options=s?JSON.parse(s):[]),super.attributeChangedCallback(t,e,s)}firstUpdated(t){super.firstUpdated(t),this.options.length&&(this._options=this.options)}render(){const t=`pkt-input ${this.fullwidth?"pkt-input--fullwidth":""}`;return l.x`
2
- <pkt-input-wrapper
3
- ?counter=${this.counter}
4
- ?disabled=${this.disabled}
5
- ?hasError=${this.hasError}
6
- ?inline=${this.inline}
7
- ?optionalTag=${this.optionalTag}
8
- ?requiredTag=${this.requiredTag}
9
- ?useWrapper=${this.useWrapper}
10
- ariaDescribedBy=${o.o(this.ariaDescribedBy)}
11
- .counterCurrent=${this.counterCurrent}
12
- .counterMaxLength=${this.counterMaxLength}
13
- class="pkt-select"
14
- errorMessage=${o.o(this.errorMessage)}
15
- forId=${this.id}
16
- helptext=${o.o(this.helptext)}
17
- helptextDropdown=${o.o(this.helptextDropdown)}
18
- helptextDropdownButton=${o.o(this.helptextDropdownButton)}
19
- label=${o.o(this.label)}
20
- optionalText=${o.o(this.optionalText)}
21
- requiredText=${o.o(this.requiredText)}
22
- >
23
- <select
24
- class=${t}
25
- aria-invalid=${this.hasError}
26
- aria-errormessage=${`${this.id}-error`}
27
- aria-labelledby=${o.o(this.ariaLabelledby)}
28
- ?disabled=${this.disabled}
29
- id=${this.id}
30
- name=${this.name||this.id}
31
- value=${this.value}
32
- ${a.n(this.selectRef)}
33
- ${a.n(this.defaultSlot)}
34
- >
35
- ${this._options.length>0&&this._options.map(e=>l.x`<option
36
- value=${e.value}
37
- ?selected=${this.value==e.value}
38
- ?disabled=${e.disabled}
39
- >
40
- ${e.label}
41
- </option>`)}
42
- </select>
43
- </pkt-input-wrapper>
44
- `}};h([l.n({type:Array})],exports.PktSelect.prototype,"options",2);h([l.n({type:String})],exports.PktSelect.prototype,"value",2);h([d.r()],exports.PktSelect.prototype,"_options",2);exports.PktSelect=h([l.t("pkt-select")],exports.PktSelect);