@oslokommune/punkt-elements 13.6.12 → 13.6.15

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/index.d.ts CHANGED
@@ -682,7 +682,6 @@ export declare class PktDatepicker extends PktInputElement<Props_4> {
682
682
  calendarOpen: boolean;
683
683
  timezone: string;
684
684
  inputClasses: {};
685
- buttonClasses: {};
686
685
  /**
687
686
  * Computed properties
688
687
  */
@@ -700,12 +699,18 @@ export declare class PktDatepicker extends PktInputElement<Props_4> {
700
699
  /**
701
700
  * Element references
702
701
  */
703
- inputRef: Ref<HTMLInputElement>;
704
- inputRefTo: Ref<HTMLInputElement>;
705
- btnRef: Ref<HTMLButtonElement>;
702
+ get inputRef(): Ref<HTMLInputElement>;
703
+ get inputRefTo(): Ref<HTMLInputElement>;
706
704
  calRef: Ref<PktCalendar>;
707
705
  popupRef: Ref<HTMLDivElement>;
708
706
  helptextSlot: Ref<HTMLElement>;
707
+ singleInputRef: Ref<PktDatepickerSingle>;
708
+ rangeInputRef: Ref<PktDatepickerRange>;
709
+ multipleInputRef: Ref<PktDatepickerMultiple>;
710
+ get currentInputElement(): HTMLInputElement | undefined;
711
+ get currentInputElementTo(): HTMLInputElement | undefined;
712
+ get currentButtonElement(): HTMLButtonElement | undefined;
713
+ get btnRef(): Ref<HTMLButtonElement>;
709
714
  /**
710
715
  * Rendering
711
716
  */
@@ -725,6 +730,35 @@ export declare class PktDatepicker extends PktInputElement<Props_4> {
725
730
  clearInputValue(): void;
726
731
  }
727
732
 
733
+ declare class PktDatepickerMultiple extends PktElement {
734
+ value: string[];
735
+ inputType: string;
736
+ id: string;
737
+ min?: string;
738
+ max?: string;
739
+ placeholder?: string;
740
+ readonly: boolean;
741
+ disabled: boolean;
742
+ maxlength?: number;
743
+ inputClasses: Record<string, boolean>;
744
+ internals?: any;
745
+ strings: any;
746
+ inputRef: Ref<HTMLInputElement>;
747
+ btnRef: Ref<HTMLButtonElement>;
748
+ get inputElement(): HTMLInputElement | undefined;
749
+ get buttonElement(): HTMLButtonElement | undefined;
750
+ get isInputReadonly(): boolean;
751
+ get isInputDisabled(): boolean;
752
+ private dispatchToggleCalendar;
753
+ private dispatchInput;
754
+ private dispatchFocus;
755
+ private dispatchBlur;
756
+ private dispatchChange;
757
+ private dispatchAddToSelected;
758
+ createRenderRoot(): this;
759
+ render(): TemplateResult<1>;
760
+ }
761
+
728
762
  declare class PktDatepickerPopup extends PktElement {
729
763
  open: boolean;
730
764
  multiple: boolean;
@@ -754,6 +788,63 @@ declare class PktDatepickerPopup extends PktElement {
754
788
  render(): TemplateResult<1>;
755
789
  }
756
790
 
791
+ declare class PktDatepickerRange extends PktElement {
792
+ value: string[];
793
+ inputType: string;
794
+ id: string;
795
+ min?: string;
796
+ max?: string;
797
+ placeholder?: string;
798
+ readonly: boolean;
799
+ disabled: boolean;
800
+ showRangeLabels: boolean;
801
+ inputClasses: Record<string, boolean>;
802
+ internals?: any;
803
+ strings: any;
804
+ inputRef: Ref<HTMLInputElement>;
805
+ inputRefTo: Ref<HTMLInputElement>;
806
+ btnRef: Ref<HTMLButtonElement>;
807
+ get inputElement(): HTMLInputElement | undefined;
808
+ get inputElementTo(): HTMLInputElement | undefined;
809
+ get buttonElement(): HTMLButtonElement | undefined;
810
+ get isInputReadonly(): boolean;
811
+ private dispatchToggleCalendar;
812
+ private dispatchInput;
813
+ private dispatchFocus;
814
+ private dispatchBlur;
815
+ private dispatchChange;
816
+ private dispatchManageValidity;
817
+ createRenderRoot(): this;
818
+ render(): TemplateResult<1>;
819
+ }
820
+
821
+ declare class PktDatepickerSingle extends PktElement {
822
+ value: string;
823
+ inputType: string;
824
+ id: string;
825
+ min?: string;
826
+ max?: string;
827
+ placeholder?: string;
828
+ readonly: boolean;
829
+ disabled: boolean;
830
+ inputClasses: Record<string, boolean>;
831
+ internals?: any;
832
+ strings: any;
833
+ inputRef: Ref<HTMLInputElement>;
834
+ btnRef: Ref<HTMLButtonElement>;
835
+ get inputElement(): HTMLInputElement | undefined;
836
+ get buttonElement(): HTMLButtonElement | undefined;
837
+ get isInputReadonly(): boolean;
838
+ private dispatchToggleCalendar;
839
+ private dispatchInput;
840
+ private dispatchFocus;
841
+ private dispatchBlur;
842
+ private dispatchChange;
843
+ private dispatchManageValidity;
844
+ createRenderRoot(): this;
845
+ render(): TemplateResult<1>;
846
+ }
847
+
757
848
  /**
758
849
  * OBS! `dateformat` er standard formatteringsstreng for visning av datoer.
759
850
  * Denne brukes for å sette "menneskeleselig" format på datoene i tags.
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./datepicker-C244h82t.cjs"),t=e.PktDatepicker;Object.defineProperty(exports,"PktDatepicker",{enumerable:!0,get:()=>e.PktDatepicker});exports.default=t;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./datepicker-BR1imflE.cjs"),t=e.PktDatepicker;Object.defineProperty(exports,"PktDatepicker",{enumerable:!0,get:()=>e.PktDatepicker});Object.defineProperty(exports,"PktDatepickerMultiple",{enumerable:!0,get:()=>e.PktDatepickerMultiple});Object.defineProperty(exports,"PktDatepickerRange",{enumerable:!0,get:()=>e.PktDatepickerRange});Object.defineProperty(exports,"PktDatepickerSingle",{enumerable:!0,get:()=>e.PktDatepickerSingle});exports.default=t;
@@ -1,6 +1,10 @@
1
- import { a as t } from "./datepicker-DwOkktaP.js";
2
- const e = t;
1
+ import { a as e } from "./datepicker-CbVSKaOY.js";
2
+ import { d as p, c as i, b as c } from "./datepicker-CbVSKaOY.js";
3
+ const a = e;
3
4
  export {
4
- t as PktDatepicker,
5
- e as default
5
+ e as PktDatepicker,
6
+ p as PktDatepickerMultiple,
7
+ i as PktDatepickerRange,
8
+ c as PktDatepickerSingle,
9
+ a as default
6
10
  };
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./alert-ZP5-fqlt.cjs"),l=require("./accordionitem-BOmnm80g.cjs"),b=require("./backlink-BT7DO6rV.cjs"),m=require("./button-BfqxLnMT.cjs"),P=require("./calendar-DH-fCGyW.cjs"),g=require("./card-B9RPShvV.cjs"),h=require("./combobox-BFOjlFIj.cjs"),f=require("./consent-DFrsiYGQ.cjs"),y=require("./checkbox-CH8xeK-0.cjs"),t=require("./element-D62wHiNU.cjs"),O=require("./pkt-slot-controller-BzddBp7z.cjs"),s=require("./ref-BfgcOXko.cjs"),j=require("./class-map-CG3vIaNm.cjs"),k=require("./datepicker-C244h82t.cjs"),q=require("./helptext-D1fkGmfT.cjs"),x=require("./heading-H_FWjo2k.cjs"),C=require("./icon-__Hjt2XZ.cjs"),v=require("./input-wrapper-DVjNwf8-.cjs"),S=require("./link-CyiVlb-7.cjs"),$=require("./linkcard-fH9uydjS.cjs"),L=require("./loader-C-3l7kb9.cjs"),T=require("./messagebox---xPIAwR.cjs"),_=require("./modal-IjDRQfX1.cjs"),A=require("./progressbar-DJzEC7cx.cjs"),p=require("./radiobutton-DEboKECm.cjs"),B=require("./tag-BKq07hGI.cjs"),I=require("./textarea-BS1tgktz.cjs"),D=require("./textinput-CCK8ti2y.cjs"),M=require("./select-DynzsPo0.cjs");var R=Object.defineProperty,H=Object.getOwnPropertyDescriptor,o=(a,e,r,i)=>{for(var n=i>1?void 0:i?H(e,r):e,u=a.length-1,c;u>=0;u--)(c=a[u])&&(n=(i?c(e,r,n):c(n))||n);return i&&n&&R(e,r,n),n};exports.PktComponent=class extends t.PktElement{constructor(){super(),this.string="",this.strings=[],this.darkmode=!1,this._list=[],this.defaultSlot=s.e(),this.namedSlot=s.e(),this.slotController=new O.PktSlotController(this,this.defaultSlot,this.namedSlot)}connectedCallback(){this.strings.length&&this.strings.forEach(e=>{this._list.push(e.toUpperCase())}),super.connectedCallback()}render(){const e={"pkt-component":!0,"pkt-component--has-list":this.strings.length>0,"pkt-darkmode":this.darkmode};return t.x`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./alert-ZP5-fqlt.cjs"),l=require("./accordionitem-BOmnm80g.cjs"),b=require("./backlink-BT7DO6rV.cjs"),m=require("./button-BfqxLnMT.cjs"),P=require("./calendar-DH-fCGyW.cjs"),g=require("./card-B9RPShvV.cjs"),h=require("./combobox-BFOjlFIj.cjs"),f=require("./consent-DFrsiYGQ.cjs"),y=require("./checkbox-CH8xeK-0.cjs"),t=require("./element-D62wHiNU.cjs"),O=require("./pkt-slot-controller-BzddBp7z.cjs"),s=require("./ref-BfgcOXko.cjs"),j=require("./class-map-CG3vIaNm.cjs"),k=require("./datepicker-BR1imflE.cjs"),q=require("./helptext-D1fkGmfT.cjs"),x=require("./heading-H_FWjo2k.cjs"),C=require("./icon-__Hjt2XZ.cjs"),v=require("./input-wrapper-DVjNwf8-.cjs"),S=require("./link-CyiVlb-7.cjs"),$=require("./linkcard-fH9uydjS.cjs"),L=require("./loader-C-3l7kb9.cjs"),T=require("./messagebox---xPIAwR.cjs"),_=require("./modal-IjDRQfX1.cjs"),A=require("./progressbar-DJzEC7cx.cjs"),p=require("./radiobutton-DEboKECm.cjs"),B=require("./tag-BKq07hGI.cjs"),I=require("./textarea-BS1tgktz.cjs"),D=require("./textinput-CCK8ti2y.cjs"),M=require("./select-DynzsPo0.cjs");var R=Object.defineProperty,H=Object.getOwnPropertyDescriptor,o=(a,e,r,i)=>{for(var n=i>1?void 0:i?H(e,r):e,u=a.length-1,c;u>=0;u--)(c=a[u])&&(n=(i?c(e,r,n):c(n))||n);return i&&n&&R(e,r,n),n};exports.PktComponent=class extends t.PktElement{constructor(){super(),this.string="",this.strings=[],this.darkmode=!1,this._list=[],this.defaultSlot=s.e(),this.namedSlot=s.e(),this.slotController=new O.PktSlotController(this,this.defaultSlot,this.namedSlot)}connectedCallback(){this.strings.length&&this.strings.forEach(e=>{this._list.push(e.toUpperCase())}),super.connectedCallback()}render(){const e={"pkt-component":!0,"pkt-component--has-list":this.strings.length>0,"pkt-darkmode":this.darkmode};return t.x`
2
2
  <div class="${j.e(e)}">
3
3
  <h1 class="pkt-txt-28">${this.string}</h1>
4
4
 
package/dist/pkt-index.js CHANGED
@@ -12,7 +12,7 @@ import { P as f, t as h, x as P, n, a as c } from "./element-DJZPsA_J.js";
12
12
  import { P as x } from "./pkt-slot-controller-BPGj-LC5.js";
13
13
  import { e as m, n as k } from "./ref-BCGCor-j.js";
14
14
  import { e as u } from "./class-map-Dw6Wrxwi.js";
15
- import { P as F, a as J } from "./datepicker-DwOkktaP.js";
15
+ import { P as F, a as J } from "./datepicker-CbVSKaOY.js";
16
16
  import { P as V } from "./helptext-8ykxyegi.js";
17
17
  import { P as Y } from "./heading-DQ0R34j4.js";
18
18
  import { P as tt } from "./icon-B1-mkmwB.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-elements",
3
- "version": "13.6.12",
3
+ "version": "13.6.15",
4
4
  "description": "Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo",
5
5
  "homepage": "https://punkt.oslo.kommune.no",
6
6
  "author": "Team Designsystem, Oslo Origo",
@@ -40,7 +40,7 @@
40
40
  "@babel/preset-env": "^7.28.3",
41
41
  "@babel/preset-typescript": "^7.25.9",
42
42
  "@oslokommune/punkt-assets": "^13.6.3",
43
- "@oslokommune/punkt-css": "^13.6.10",
43
+ "@oslokommune/punkt-css": "^13.6.15",
44
44
  "@testing-library/jest-dom": "^6.6.3",
45
45
  "@vitest/ui": "^1.0.0",
46
46
  "jest-axe": "^9.0.0",
@@ -72,5 +72,5 @@
72
72
  "url": "https://github.com/oslokommune/punkt/issues"
73
73
  },
74
74
  "license": "MIT",
75
- "gitHead": "0a373416dbf5e0b210cf078b3a29587bba6b6975"
75
+ "gitHead": "4798e1ff1529f3e32cd4c4173fab3ec3586319da"
76
76
  }
@@ -0,0 +1,202 @@
1
+ import { html } from 'lit'
2
+ import { customElement, property } from 'lit/decorators.js'
3
+ import { classMap } from 'lit/directives/class-map.js'
4
+ import { ifDefined } from 'lit/directives/if-defined.js'
5
+ import { Ref, createRef, ref } from 'lit/directives/ref.js'
6
+ import { PktElement } from '@/base-elements/element'
7
+ import { keyboardUtils, formUtils, deviceDetection, cssUtils } from './datepicker-utils'
8
+ import '@/components/icon'
9
+
10
+ @customElement('pkt-datepicker-multiple')
11
+ export class PktDatepickerMultiple extends PktElement {
12
+ @property({ type: Array })
13
+ value: string[] = []
14
+
15
+ @property({ type: String })
16
+ inputType: string = 'date'
17
+
18
+ @property({ type: String })
19
+ id: string = ''
20
+
21
+ @property({ type: String })
22
+ min?: string
23
+
24
+ @property({ type: String })
25
+ max?: string
26
+
27
+ @property({ type: String })
28
+ placeholder?: string
29
+
30
+ @property({ type: Boolean })
31
+ readonly: boolean = false
32
+
33
+ @property({ type: Boolean })
34
+ disabled: boolean = false
35
+
36
+ @property({ type: Number })
37
+ maxlength?: number
38
+
39
+ @property({ type: Object })
40
+ inputClasses: Record<string, boolean> = {}
41
+
42
+ @property({ type: Object })
43
+ internals?: any
44
+
45
+ @property({ type: Object })
46
+ strings: any = { calendar: { buttonAltText: 'Åpne kalender' } }
47
+
48
+ inputRef: Ref<HTMLInputElement> = createRef()
49
+ btnRef: Ref<HTMLButtonElement> = createRef()
50
+
51
+ get inputElement(): HTMLInputElement | undefined {
52
+ return this.inputRef.value
53
+ }
54
+
55
+ get buttonElement(): HTMLButtonElement | undefined {
56
+ return this.btnRef.value
57
+ }
58
+
59
+ get isInputReadonly(): boolean {
60
+ return this.readonly || this.inputType === 'text'
61
+ }
62
+
63
+ get isInputDisabled(): boolean {
64
+ return (
65
+ this.disabled ||
66
+ (this.maxlength !== undefined &&
67
+ this.maxlength !== null &&
68
+ this.value.length >= this.maxlength)
69
+ )
70
+ }
71
+
72
+ private dispatchToggleCalendar(e: Event) {
73
+ if (this.readonly) return
74
+
75
+ this.dispatchEvent(
76
+ new CustomEvent('toggle-calendar', {
77
+ detail: e,
78
+ bubbles: true,
79
+ composed: true,
80
+ }),
81
+ )
82
+ }
83
+
84
+ private dispatchInput(e: Event) {
85
+ this.dispatchEvent(
86
+ new CustomEvent('input-change', {
87
+ detail: e,
88
+ bubbles: true,
89
+ composed: true,
90
+ }),
91
+ )
92
+ }
93
+
94
+ private dispatchFocus() {
95
+ this.dispatchEvent(
96
+ new CustomEvent('input-focus', {
97
+ bubbles: true,
98
+ composed: true,
99
+ }),
100
+ )
101
+ }
102
+
103
+ private dispatchBlur(e: FocusEvent) {
104
+ this.dispatchEvent(
105
+ new CustomEvent('input-blur', {
106
+ detail: e,
107
+ bubbles: true,
108
+ composed: true,
109
+ }),
110
+ )
111
+ }
112
+
113
+ private dispatchChange(e: Event) {
114
+ this.dispatchEvent(
115
+ new CustomEvent('input-changed', {
116
+ detail: e,
117
+ bubbles: true,
118
+ composed: true,
119
+ }),
120
+ )
121
+ }
122
+
123
+ private dispatchAddToSelected(e: Event | KeyboardEvent) {
124
+ this.dispatchEvent(
125
+ new CustomEvent('add-to-selected', {
126
+ detail: e,
127
+ bubbles: true,
128
+ composed: true,
129
+ }),
130
+ )
131
+ }
132
+
133
+ createRenderRoot() {
134
+ return this
135
+ }
136
+
137
+ render() {
138
+ return html`
139
+ <div class="pkt-input__container">
140
+ <input
141
+ class=${classMap(this.inputClasses)}
142
+ .type=${this.inputType}
143
+ id="${this.id}-input"
144
+ min=${ifDefined(this.min)}
145
+ max=${ifDefined(this.max)}
146
+ placeholder=${ifDefined(this.placeholder)}
147
+ ?readonly=${this.isInputReadonly}
148
+ ?disabled=${this.isInputDisabled}
149
+ @click=${(e: MouseEvent) => {
150
+ e.preventDefault()
151
+ this.dispatchToggleCalendar(e)
152
+ }}
153
+ @touchend=${(e: TouchEvent) => {
154
+ e.preventDefault()
155
+ this.dispatchToggleCalendar(e)
156
+ }}
157
+ @blur=${(e: FocusEvent) => {
158
+ this.dispatchBlur(e)
159
+ this.dispatchAddToSelected(e)
160
+ }}
161
+ @input=${(e: Event) => {
162
+ this.dispatchInput(e)
163
+ e.stopImmediatePropagation()
164
+ }}
165
+ @focus=${() => {
166
+ this.dispatchFocus()
167
+ if (deviceDetection.isIOS()) {
168
+ this.dispatchToggleCalendar(new Event('focus'))
169
+ }
170
+ }}
171
+ @keydown=${(e: KeyboardEvent) =>
172
+ keyboardUtils.handleInputKeydown(
173
+ e,
174
+ (event) => this.dispatchToggleCalendar(event),
175
+ () =>
176
+ formUtils.submitFormOrFallback(this.internals, () => this.inputRef.value?.blur()),
177
+ undefined,
178
+ undefined,
179
+ (event) => this.dispatchAddToSelected(event),
180
+ )}
181
+ @change=${(e: Event) => {
182
+ this.dispatchChange(e)
183
+ e.stopImmediatePropagation()
184
+ }}
185
+ ${ref(this.inputRef)}
186
+ />
187
+ <button
188
+ class="${classMap(cssUtils.getButtonClasses())}"
189
+ type="button"
190
+ @click=${(e: Event) => this.dispatchToggleCalendar(e)}
191
+ @keydown=${(e: KeyboardEvent) =>
192
+ keyboardUtils.handleButtonKeydown(e, (event) => this.dispatchToggleCalendar(event))}
193
+ ?disabled=${this.disabled}
194
+ ${ref(this.btnRef)}
195
+ >
196
+ <pkt-icon name="calendar"></pkt-icon>
197
+ <span class="pkt-btn__text">${this.strings.calendar.buttonAltText}</span>
198
+ </button>
199
+ </div>
200
+ `
201
+ }
202
+ }
@@ -0,0 +1,281 @@
1
+ import { html, nothing } from 'lit'
2
+ import { customElement, property } from 'lit/decorators.js'
3
+ import { classMap } from 'lit/directives/class-map.js'
4
+ import { ifDefined } from 'lit/directives/if-defined.js'
5
+ import { Ref, createRef, ref } from 'lit/directives/ref.js'
6
+ import { PktElement } from '@/base-elements/element'
7
+ import { keyboardUtils, formUtils, deviceDetection, cssUtils } from './datepicker-utils'
8
+ import '@/components/icon'
9
+
10
+ @customElement('pkt-datepicker-range')
11
+ export class PktDatepickerRange extends PktElement {
12
+ @property({ type: Array })
13
+ value: string[] = []
14
+
15
+ @property({ type: String })
16
+ inputType: string = 'date'
17
+
18
+ @property({ type: String })
19
+ id: string = ''
20
+
21
+ @property({ type: String })
22
+ min?: string
23
+
24
+ @property({ type: String })
25
+ max?: string
26
+
27
+ @property({ type: String })
28
+ placeholder?: string
29
+
30
+ @property({ type: Boolean })
31
+ readonly: boolean = false
32
+
33
+ @property({ type: Boolean })
34
+ disabled: boolean = false
35
+
36
+ @property({ type: Boolean })
37
+ showRangeLabels: boolean = false
38
+
39
+ @property({ type: Object })
40
+ inputClasses: Record<string, boolean> = {}
41
+
42
+ @property({ type: Object })
43
+ internals?: any
44
+
45
+ @property({ type: Object })
46
+ strings: any = { generic: { from: 'Fra', to: 'Til' } }
47
+
48
+ inputRef: Ref<HTMLInputElement> = createRef()
49
+ inputRefTo: Ref<HTMLInputElement> = createRef()
50
+ btnRef: Ref<HTMLButtonElement> = createRef()
51
+
52
+ get inputElement(): HTMLInputElement | undefined {
53
+ return this.inputRef.value
54
+ }
55
+
56
+ get inputElementTo(): HTMLInputElement | undefined {
57
+ return this.inputRefTo.value
58
+ }
59
+
60
+ get buttonElement(): HTMLButtonElement | undefined {
61
+ return this.btnRef.value
62
+ }
63
+
64
+ get isInputReadonly(): boolean {
65
+ return this.readonly || this.inputType === 'text'
66
+ }
67
+
68
+ private dispatchToggleCalendar(e: Event) {
69
+ if (this.readonly) return
70
+
71
+ this.dispatchEvent(
72
+ new CustomEvent('toggle-calendar', {
73
+ detail: e,
74
+ bubbles: true,
75
+ composed: true,
76
+ }),
77
+ )
78
+ }
79
+
80
+ private dispatchInput(e: Event) {
81
+ this.dispatchEvent(
82
+ new CustomEvent('input-change', {
83
+ detail: e,
84
+ bubbles: true,
85
+ composed: true,
86
+ }),
87
+ )
88
+ }
89
+
90
+ private dispatchFocus() {
91
+ this.dispatchEvent(
92
+ new CustomEvent('input-focus', {
93
+ bubbles: true,
94
+ composed: true,
95
+ }),
96
+ )
97
+ }
98
+
99
+ private dispatchBlur(e: FocusEvent) {
100
+ this.dispatchEvent(
101
+ new CustomEvent('input-blur', {
102
+ detail: e,
103
+ bubbles: true,
104
+ composed: true,
105
+ }),
106
+ )
107
+ }
108
+
109
+ private dispatchChange(e: Event) {
110
+ this.dispatchEvent(
111
+ new CustomEvent('input-changed', {
112
+ detail: e,
113
+ bubbles: true,
114
+ composed: true,
115
+ }),
116
+ )
117
+ }
118
+
119
+ private dispatchManageValidity(input: HTMLInputElement) {
120
+ this.dispatchEvent(
121
+ new CustomEvent('manage-validity', {
122
+ detail: input,
123
+ bubbles: true,
124
+ composed: true,
125
+ }),
126
+ )
127
+ }
128
+
129
+ createRenderRoot() {
130
+ return this
131
+ }
132
+
133
+ render() {
134
+ const rangeLabelClasses = cssUtils.getRangeLabelClasses(this.showRangeLabels)
135
+
136
+ return html`
137
+ <div class="pkt-input__container">
138
+ ${this.showRangeLabels
139
+ ? html` <div class="pkt-input-prefix">${this.strings.generic.from}</div> `
140
+ : nothing}
141
+ <input
142
+ class=${classMap(this.inputClasses)}
143
+ .type=${this.inputType}
144
+ id="${this.id}-input"
145
+ .value=${this.value[0] ?? ''}
146
+ min=${ifDefined(this.min)}
147
+ max=${ifDefined(this.max)}
148
+ placeholder=${ifDefined(this.placeholder)}
149
+ ?readonly=${this.isInputReadonly}
150
+ ?disabled=${this.disabled}
151
+ @click=${(e: MouseEvent) => {
152
+ e.preventDefault()
153
+ this.dispatchToggleCalendar(e)
154
+ }}
155
+ @touchend=${(e: TouchEvent) => {
156
+ e.preventDefault()
157
+ this.dispatchToggleCalendar(e)
158
+ }}
159
+ @keydown=${(e: KeyboardEvent) =>
160
+ keyboardUtils.handleInputKeydown(
161
+ e,
162
+ (event) => this.dispatchToggleCalendar(event),
163
+ () =>
164
+ formUtils.submitFormOrFallback(this.internals, () =>
165
+ this.inputRefTo.value?.focus(),
166
+ ),
167
+ () => this.inputRefTo.value?.focus(),
168
+ () => this.inputRef.value?.blur(),
169
+ )}
170
+ @input=${(e: Event) => {
171
+ this.dispatchInput(e)
172
+ e.stopImmediatePropagation()
173
+ }}
174
+ @focus=${() => {
175
+ this.dispatchFocus()
176
+ if (deviceDetection.isIOS()) {
177
+ this.dispatchToggleCalendar(new Event('focus'))
178
+ }
179
+ }}
180
+ @blur=${(e: Event) => {
181
+ this.dispatchEvent(
182
+ new CustomEvent('range-blur', {
183
+ detail: {
184
+ event: e,
185
+ values: this.value,
186
+ inputType: 'from',
187
+ },
188
+ bubbles: true,
189
+ composed: true,
190
+ }),
191
+ )
192
+ }}
193
+ @change=${(e: Event) => {
194
+ e.stopImmediatePropagation()
195
+ }}
196
+ ${ref(this.inputRef)}
197
+ />
198
+ <div class="${classMap(rangeLabelClasses)}" id="${this.id}-to-label">
199
+ ${this.strings.generic.to}
200
+ </div>
201
+ ${!this.showRangeLabels ? html` <div class="pkt-input-separator">–</div> ` : nothing}
202
+ <input
203
+ class=${classMap(this.inputClasses)}
204
+ .type=${this.inputType}
205
+ id="${this.id}-to"
206
+ aria-labelledby="${this.id}-to-label"
207
+ .value=${this.value[1] ?? ''}
208
+ min=${ifDefined(this.min)}
209
+ max=${ifDefined(this.max)}
210
+ placeholder=${ifDefined(this.placeholder)}
211
+ ?readonly=${this.isInputReadonly}
212
+ ?disabled=${this.disabled}
213
+ @click=${(e: MouseEvent) => {
214
+ e.preventDefault()
215
+ this.dispatchToggleCalendar(e)
216
+ }}
217
+ @touchend=${(e: TouchEvent) => {
218
+ e.preventDefault()
219
+ this.dispatchToggleCalendar(e)
220
+ }}
221
+ @keydown=${(e: KeyboardEvent) =>
222
+ keyboardUtils.handleInputKeydown(
223
+ e,
224
+ (event) => this.dispatchToggleCalendar(event),
225
+ () =>
226
+ formUtils.submitFormOrFallback(this.internals, () => this.inputRefTo.value?.blur()),
227
+ undefined,
228
+ () => this.inputRefTo.value?.blur(),
229
+ )}
230
+ @input=${(e: Event) => {
231
+ this.dispatchInput(e)
232
+ e.stopImmediatePropagation()
233
+ }}
234
+ @focus=${() => {
235
+ this.dispatchFocus()
236
+ if (deviceDetection.isIOS()) {
237
+ this.dispatchToggleCalendar(new Event('focus'))
238
+ }
239
+ }}
240
+ @blur=${(e: FocusEvent) => {
241
+ this.dispatchBlur(e)
242
+ if ((e.target as HTMLInputElement).value) {
243
+ this.dispatchManageValidity(e.target as HTMLInputElement)
244
+ this.dispatchEvent(
245
+ new CustomEvent('validate-date-input', {
246
+ detail: e.target as HTMLInputElement,
247
+ bubbles: true,
248
+ composed: true,
249
+ }),
250
+ )
251
+ this.dispatchEvent(
252
+ new CustomEvent('handle-date-select', {
253
+ detail: (e.target as HTMLInputElement).value,
254
+ bubbles: true,
255
+ composed: true,
256
+ }),
257
+ )
258
+ }
259
+ }}
260
+ @change=${(e: Event) => {
261
+ this.dispatchChange(e)
262
+ e.stopImmediatePropagation()
263
+ }}
264
+ ${ref(this.inputRefTo)}
265
+ />
266
+ <button
267
+ class="${classMap(cssUtils.getButtonClasses())}"
268
+ type="button"
269
+ @click=${(e: Event) => this.dispatchToggleCalendar(e)}
270
+ @keydown=${(e: KeyboardEvent) =>
271
+ keyboardUtils.handleButtonKeydown(e, (event) => this.dispatchToggleCalendar(event))}
272
+ ?disabled=${this.disabled}
273
+ ${ref(this.btnRef)}
274
+ >
275
+ <pkt-icon name="calendar"></pkt-icon>
276
+ <span class="pkt-btn__text">${this.strings.calendar.buttonAltText}</span>
277
+ </button>
278
+ </div>
279
+ `
280
+ }
281
+ }