@sebgroup/green-core 1.4.0 → 1.4.2

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/index.js CHANGED
@@ -33,8 +33,8 @@ var __privateMethod = (obj, member, method) => {
33
33
  };
34
34
 
35
35
  // libs/core/src/components/dropdown/dropdown.ts
36
- import { property as property5, query, queryAsync } from "lit/decorators.js";
37
- import { unsafeHTML } from "lit/directives/unsafe-html.js";
36
+ import { property as property5, query, queryAsync, state as state4 } from "lit/decorators.js";
37
+ import { unsafeHTML as unsafeHTML2 } from "lit/directives/unsafe-html.js";
38
38
  import { when as when2 } from "lit/directives/when.js";
39
39
  import { ifDefined } from "lit/directives/if-defined.js";
40
40
  import { msg as msg2, str, updateWhenLocaleChanges } from "@lit/localize";
@@ -139,7 +139,7 @@ function watchMediaQuery(q) {
139
139
  // libs/core/src/utils/helpers/custom-element-scoping.ts
140
140
  import { html as litHtml } from "lit";
141
141
  import { customElement } from "lit/decorators.js";
142
- var VER_SUFFIX = "-98c004";
142
+ var VER_SUFFIX = "-3bff35";
143
143
  var elementLookupTable = /* @__PURE__ */ new Map();
144
144
  var gdsCustomElement = (tagName) => {
145
145
  if (globalThis.GDS_DISABLE_VERSIONED_ELEMENTS) {
@@ -187,27 +187,38 @@ function getUnscopedTagName(tagName) {
187
187
  }
188
188
 
189
189
  // libs/core/src/primitives/listbox/listbox.ts
190
- import { LitElement } from "lit";
191
- import { property } from "lit/decorators.js";
190
+ import { property, state } from "lit/decorators.js";
192
191
  import { createRef, ref } from "lit/directives/ref.js";
193
192
 
194
193
  // libs/core/src/utils/helpers/transitional-styles.ts
195
- var TransitionalStyles = class _TransitionalStyles {
194
+ import { html as html2 } from "lit";
195
+ import { unsafeHTML } from "lit/directives/unsafe-html.js";
196
+ var TransitionalStyles = class {
196
197
  constructor() {
197
198
  this.sheets = /* @__PURE__ */ new Map();
198
199
  this.elements = /* @__PURE__ */ new Map();
200
+ this.sheetsLegacy = /* @__PURE__ */ new Map();
201
+ this.useLegacyStylesheets = true;
199
202
  }
200
203
  static get instance() {
201
204
  if (!globalThis.__gdsTransitionalStyles?.[VER_SUFFIX])
202
205
  globalThis.__gdsTransitionalStyles = {
203
206
  ...globalThis.__gdsTransitionalStyles,
204
- [VER_SUFFIX]: new _TransitionalStyles()
207
+ [VER_SUFFIX]: new TransitionalStyles()
205
208
  };
206
209
  return globalThis.__gdsTransitionalStyles[VER_SUFFIX];
207
210
  }
211
+ //!supportsConstructedStylesheets()
208
212
  apply(element, styleKey) {
213
+ if (!element.shadowRoot)
214
+ return;
215
+ if (this.useLegacyStylesheets) {
216
+ this.elements.set(styleKey, element);
217
+ this.applyToElementLegacy(styleKey);
218
+ return;
219
+ }
209
220
  const sheet = this.sheets.get(styleKey);
210
- if (!sheet || !element.shadowRoot)
221
+ if (!sheet)
211
222
  return;
212
223
  this.elements.set(styleKey, element);
213
224
  this.applyToElement(styleKey, sheet);
@@ -218,7 +229,39 @@ var TransitionalStyles = class _TransitionalStyles {
218
229
  return;
219
230
  element.shadowRoot.adoptedStyleSheets = [sheet];
220
231
  }
232
+ // This is a fallback for browsers that don't support constructed stylesheets.
233
+ // Primarily, this is here to support Safari/iOS 15.x
234
+ //
235
+ // To work around the lack of Constructed Stylesheets, we use a regular <style>
236
+ // element instead. The _tStyles property needs to be added to the render template
237
+ // of each component.
238
+ //
239
+ // Lit itself will also add a <style> element to the shadow root in these browsers,
240
+ // meaning that we have to override the base styles added from the static style
241
+ // property in this case. This is what the `all: revert` rule is for.
242
+ // We can use cascade layers to ensure that the revert rule ovverides the base styles
243
+ // but not the transitional styles.
244
+ // `@layer base, reset, transitional-styles;`
245
+ applyToElementLegacy(styleKey) {
246
+ const sheet = this.sheetsLegacy.get(styleKey);
247
+ const element = this.elements.get(styleKey);
248
+ if (!element)
249
+ return;
250
+ element._tStyles = html2`<style>
251
+ @layer reset {
252
+ *:not(style, [gds-element]) {
253
+ all: revert;
254
+ }
255
+ }
256
+ ${unsafeHTML(sheet)}
257
+ </style>`;
258
+ }
221
259
  register(name, styles2) {
260
+ if (this.useLegacyStylesheets) {
261
+ this.sheetsLegacy.set(name, styles2);
262
+ this.applyToElementLegacy(name);
263
+ return;
264
+ }
222
265
  const sheet = new CSSStyleSheet();
223
266
  sheet.replaceSync(styles2);
224
267
  this.sheets.set(name, sheet);
@@ -229,12 +272,32 @@ var TransitionalStyles = class _TransitionalStyles {
229
272
  // libs/core/src/primitives/listbox/listbox.ts
230
273
  import "reflect-metadata";
231
274
 
275
+ // libs/core/src/gds-element.ts
276
+ import { LitElement as LitElement2 } from "lit";
277
+ var GdsElement = class extends LitElement2 {
278
+ constructor() {
279
+ super(...arguments);
280
+ /**
281
+ * The unscoped name of this element.
282
+ */
283
+ this.gdsElementName = "";
284
+ }
285
+ connectedCallback() {
286
+ super.connectedCallback();
287
+ this.gdsElementName = getUnscopedTagName(this.tagName.toLowerCase()) || this.gdsElementName;
288
+ this.setAttribute("gds-element", this.gdsElementName);
289
+ }
290
+ };
291
+
232
292
  // libs/core/src/primitives/listbox/listbox.styles.ts
233
293
  import { css } from "lit";
234
294
  var style = css`
235
- :host {
236
- display: flex;
237
- flex-direction: column;
295
+ @layer base, reset, transitional-styles;
296
+ @layer base {
297
+ :host {
298
+ display: flex;
299
+ flex-direction: column;
300
+ }
238
301
  }
239
302
  `;
240
303
  var listbox_styles_default = style;
@@ -307,7 +370,7 @@ function unwrap(slotRef) {
307
370
 
308
371
  // libs/core/src/primitives/listbox/listbox.ts
309
372
  var _slotRef, _handleSelect;
310
- var GdsListbox = class extends LitElement {
373
+ var GdsListbox = class extends GdsElement {
311
374
  constructor() {
312
375
  super();
313
376
  this.multiple = false;
@@ -386,7 +449,7 @@ var GdsListbox = class extends LitElement {
386
449
  (this.visibleSelectedOptionElements[0] || this.visibleOptionElements[0])?.focus();
387
450
  }
388
451
  render() {
389
- return html`<slot ${ref(__privateGet(this, _slotRef))}></slot>`;
452
+ return html`${this._tStyles}<slot ${ref(__privateGet(this, _slotRef))}></slot>`;
390
453
  }
391
454
  _rerenderOptions() {
392
455
  this.options.forEach((el) => {
@@ -411,6 +474,9 @@ __decorateClass([
411
474
  __decorateClass([
412
475
  property()
413
476
  ], GdsListbox.prototype, "compareWith", 2);
477
+ __decorateClass([
478
+ state()
479
+ ], GdsListbox.prototype, "_tStyles", 2);
414
480
  __decorateClass([
415
481
  watch("multiple")
416
482
  ], GdsListbox.prototype, "_rerenderOptions", 1);
@@ -419,21 +485,24 @@ GdsListbox = __decorateClass([
419
485
  ], GdsListbox);
420
486
 
421
487
  // libs/core/src/primitives/listbox/option.ts
422
- import { LitElement as LitElement2, html as html2 } from "lit";
423
- import { property as property2 } from "lit/decorators.js";
488
+ import { html as html3 } from "lit";
489
+ import { property as property2, state as state2 } from "lit/decorators.js";
424
490
  import { when } from "lit/directives/when.js";
425
491
  import { classMap } from "lit/directives/class-map.js";
426
492
 
427
493
  // libs/core/src/primitives/listbox/option.styles.ts
428
494
  import { css as css2 } from "lit";
429
495
  var style2 = css2`
430
- :host {
431
- padding: 0.5 1rem;
432
- cursor: pointer;
433
- }
496
+ @layer base, reset, transitional-styles;
497
+ @layer base {
498
+ :host {
499
+ padding: 0.5 1rem;
500
+ cursor: pointer;
501
+ }
434
502
 
435
- :host(:hover) {
436
- background-color: grey;
503
+ :host(:hover) {
504
+ background-color: grey;
505
+ }
437
506
  }
438
507
  `;
439
508
  var option_styles_default = style2;
@@ -476,7 +545,7 @@ var Focusable = (superClass) => {
476
545
 
477
546
  // libs/core/src/primitives/listbox/option.ts
478
547
  var _hidden, _emitSelect, emitSelect_fn;
479
- var GdsOption = class extends Focusable(LitElement2) {
548
+ var GdsOption = class extends Focusable(GdsElement) {
480
549
  constructor() {
481
550
  super();
482
551
  __privateAdd(this, _emitSelect);
@@ -525,7 +594,7 @@ var GdsOption = class extends Focusable(LitElement2) {
525
594
  }
526
595
  render() {
527
596
  const isMultiple = this.parentElement?.multiple;
528
- const checkbox = html2`<span
597
+ const checkbox = html3` <span
529
598
  class="checkbox ${classMap({ checked: this.selected })}"
530
599
  ></span>`;
531
600
  if (!isMultiple) {
@@ -534,7 +603,8 @@ var GdsOption = class extends Focusable(LitElement2) {
534
603
  else
535
604
  this.removeAttribute("highlighted");
536
605
  }
537
- return html2`${when(isMultiple, () => checkbox)}<slot></slot>`;
606
+ return html3`${this._tStyles}${when(isMultiple, () => checkbox)}
607
+ <slot></slot>`;
538
608
  }
539
609
  };
540
610
  _hidden = new WeakMap();
@@ -570,6 +640,9 @@ __decorateClass([
570
640
  __decorateClass([
571
641
  property2({ type: Boolean, reflect: true })
572
642
  ], GdsOption.prototype, "isPlaceholder", 2);
643
+ __decorateClass([
644
+ state2()
645
+ ], GdsOption.prototype, "_tStyles", 2);
573
646
  __decorateClass([
574
647
  watch("isplaceholder")
575
648
  ], GdsOption.prototype, "_handlePlaceholderStatusChange", 1);
@@ -578,8 +651,8 @@ GdsOption = __decorateClass([
578
651
  ], GdsOption);
579
652
 
580
653
  // libs/core/src/primitives/popover/popover.ts
581
- import { LitElement as LitElement3, html as html3, unsafeCSS } from "lit";
582
- import { property as property3, state } from "lit/decorators.js";
654
+ import { html as html4, unsafeCSS } from "lit";
655
+ import { property as property3, state as state3 } from "lit/decorators.js";
583
656
  import { classMap as classMap2 } from "lit/directives/class-map.js";
584
657
  import { msg } from "@lit/localize";
585
658
  import { createRef as createRef2, ref as ref2 } from "lit/directives/ref.js";
@@ -750,27 +823,31 @@ function isHTMLElement(value) {
750
823
  // libs/core/src/primitives/popover/popover.styles.ts
751
824
  import { css as css3 } from "lit";
752
825
  var style3 = css3`
753
- :host([open]) dialog {
754
- opacity: 1;
755
- transform: translate3d(0, 0, 0);
756
- visibility: visible;
757
- }
826
+ @layer base, reset, transitional-styles;
827
+ @layer base {
828
+ :host([open]) dialog {
829
+ opacity: 1;
830
+ box-sizing: border-box;
831
+ transform: translate3d(0, 0, 0);
832
+ visibility: visible;
833
+ }
758
834
 
759
- dialog {
760
- inset: auto;
761
- position: fixed;
762
- overflow: hidden;
763
- padding: 0px;
764
- box-sizing: border-box;
765
- border-width: 0;
766
- right: 0;
835
+ dialog {
836
+ inset: auto;
837
+ position: fixed;
838
+ overflow: hidden;
839
+ padding: 0px;
840
+ box-sizing: border-box;
841
+ border-width: 0;
842
+ right: 0;
843
+ }
767
844
  }
768
845
  `;
769
846
  var popover_styles_default = style3;
770
847
 
771
848
  // libs/core/src/primitives/popover/popover.ts
772
849
  var _dialogElementRef, _autoPositionCleanupFn, _isMobileViewport, _dispatchUiStateEvent, _handleCloseButton, _registerTriggerEvents, registerTriggerEvents_fn, _unregisterTriggerEvents, unregisterTriggerEvents_fn, _registerAutoPositioning, registerAutoPositioning_fn, _triggerKeyDownListener, _focusFirstSlottedChild, _clickOutsideListener;
773
- var GdsPopover = class extends LitElement3 {
850
+ var GdsPopover = class extends GdsElement {
774
851
  constructor() {
775
852
  super(...arguments);
776
853
  __privateAdd(this, _registerTriggerEvents);
@@ -883,22 +960,23 @@ var GdsPopover = class extends LitElement3 {
883
960
  __privateMethod(this, _unregisterTriggerEvents, unregisterTriggerEvents_fn).call(this);
884
961
  }
885
962
  render() {
886
- return html3`<dialog
887
- class="${classMap2({ "v-kb-visible": this._isVirtKbVisible })}"
888
- ${ref2(__privateGet(this, _dialogElementRef))}
889
- >
890
- <header>
891
- <h2>${this.label}</h2>
892
- <button
893
- class="close"
894
- @click=${__privateGet(this, _handleCloseButton)}
895
- aria-label="${msg("Close")}"
896
- >
897
- <i></i>
898
- </button>
899
- </header>
900
- <slot></slot>
901
- </dialog>`;
963
+ return html4`${this._tStyles}
964
+ <dialog
965
+ class="${classMap2({ "v-kb-visible": this._isVirtKbVisible })}"
966
+ ${ref2(__privateGet(this, _dialogElementRef))}
967
+ >
968
+ <header>
969
+ <h2>${this.label}</h2>
970
+ <button
971
+ class="close"
972
+ @click=${__privateGet(this, _handleCloseButton)}
973
+ aria-label="${msg("Close")}"
974
+ >
975
+ <i></i>
976
+ </button>
977
+ </header>
978
+ <slot></slot>
979
+ </dialog>`;
902
980
  }
903
981
  _handleOpenChange() {
904
982
  this.setAttribute("aria-hidden", String(!this.open));
@@ -1004,10 +1082,10 @@ __decorateClass([
1004
1082
  property3()
1005
1083
  ], GdsPopover.prototype, "calcMaxWidth", 2);
1006
1084
  __decorateClass([
1007
- state()
1085
+ state3()
1008
1086
  ], GdsPopover.prototype, "_trigger", 2);
1009
1087
  __decorateClass([
1010
- state()
1088
+ state3()
1011
1089
  ], GdsPopover.prototype, "_isVirtKbVisible", 2);
1012
1090
  __decorateClass([
1013
1091
  watch("triggerRef")
@@ -1015,6 +1093,9 @@ __decorateClass([
1015
1093
  __decorateClass([
1016
1094
  watch("_trigger")
1017
1095
  ], GdsPopover.prototype, "_handleTriggerChanged", 1);
1096
+ __decorateClass([
1097
+ state3()
1098
+ ], GdsPopover.prototype, "_tStyles", 2);
1018
1099
  __decorateClass([
1019
1100
  watch("open")
1020
1101
  ], GdsPopover.prototype, "_handleOpenChange", 1);
@@ -1026,11 +1107,12 @@ GdsPopover = __decorateClass([
1026
1107
  ], GdsPopover);
1027
1108
 
1028
1109
  // libs/core/src/components/form-control.ts
1029
- import { LitElement as LitElement4 } from "lit";
1030
1110
  import { property as property4 } from "lit/decorators.js";
1031
- var GdsFormControlElement = class extends LitElement4 {
1111
+ var _internals;
1112
+ var GdsFormControlElement = class extends GdsElement {
1032
1113
  constructor() {
1033
1114
  super();
1115
+ __privateAdd(this, _internals, void 0);
1034
1116
  this.invalid = false;
1035
1117
  this.name = "";
1036
1118
  /**
@@ -1040,43 +1122,68 @@ var GdsFormControlElement = class extends LitElement4 {
1040
1122
  this._handleFormReset = () => {
1041
1123
  this.value = void 0;
1042
1124
  };
1043
- this.#internals = this.attachInternals();
1044
- }
1045
- #internals;
1046
- static {
1047
- this.formAssociated = true;
1125
+ try {
1126
+ __privateSet(this, _internals, this.attachInternals());
1127
+ } catch (e) {
1128
+ __privateSet(this, _internals, {
1129
+ form: this.closest("form"),
1130
+ setFormValue: (value) => {
1131
+ this.value = value;
1132
+ },
1133
+ setValidity: (validity, validationMessage) => {
1134
+ this.invalid = validity.customError;
1135
+ },
1136
+ validationMessage: "",
1137
+ validity: {
1138
+ badInput: false,
1139
+ customError: false,
1140
+ patternMismatch: false,
1141
+ rangeOverflow: false,
1142
+ rangeUnderflow: false,
1143
+ stepMismatch: false,
1144
+ tooLong: false,
1145
+ tooShort: false,
1146
+ typeMismatch: false,
1147
+ valueMissing: false,
1148
+ valid: true
1149
+ },
1150
+ willValidate: true,
1151
+ checkValidity: () => true,
1152
+ reportValidity: () => true
1153
+ });
1154
+ }
1048
1155
  }
1049
1156
  get form() {
1050
- return this.#internals.form;
1157
+ return __privateGet(this, _internals).form;
1051
1158
  }
1052
1159
  get type() {
1053
1160
  return getUnscopedTagName(this.localName) || "gds-form-control";
1054
1161
  }
1055
1162
  get validity() {
1056
- return this.#internals.validity;
1163
+ return __privateGet(this, _internals).validity;
1057
1164
  }
1058
1165
  get validationMessage() {
1059
- return this.#internals.validationMessage;
1166
+ return __privateGet(this, _internals).validationMessage;
1060
1167
  }
1061
1168
  get willValidate() {
1062
- return this.#internals.willValidate;
1169
+ return __privateGet(this, _internals).willValidate;
1063
1170
  }
1064
1171
  checkValidity() {
1065
- return this.#internals.checkValidity();
1172
+ return __privateGet(this, _internals).checkValidity();
1066
1173
  }
1067
1174
  reportValidity() {
1068
- return this.#internals.reportValidity();
1175
+ return __privateGet(this, _internals).reportValidity();
1069
1176
  }
1070
1177
  connectedCallback() {
1071
1178
  super.connectedCallback();
1072
- this.#internals.form?.addEventListener("reset", this._handleFormReset);
1179
+ __privateGet(this, _internals).form?.addEventListener("reset", this._handleFormReset);
1073
1180
  }
1074
1181
  disconnectedCallback() {
1075
1182
  super.disconnectedCallback();
1076
- this.#internals.form?.removeEventListener("reset", this._handleFormReset);
1183
+ __privateGet(this, _internals).form?.removeEventListener("reset", this._handleFormReset);
1077
1184
  }
1078
1185
  __handleValidityChange() {
1079
- this.#internals.setValidity(
1186
+ __privateGet(this, _internals).setValidity(
1080
1187
  {
1081
1188
  badInput: false,
1082
1189
  customError: this.invalid,
@@ -1087,15 +1194,18 @@ var GdsFormControlElement = class extends LitElement4 {
1087
1194
  tooLong: false,
1088
1195
  tooShort: false,
1089
1196
  typeMismatch: false,
1090
- valueMissing: false
1197
+ valueMissing: false,
1198
+ valid: !this.invalid
1091
1199
  },
1092
1200
  this.validationMessage || "Error message"
1093
1201
  );
1094
1202
  }
1095
1203
  __handleValueChange() {
1096
- this.#internals.setFormValue(this.value);
1204
+ __privateGet(this, _internals).setFormValue(this.value);
1097
1205
  }
1098
1206
  };
1207
+ _internals = new WeakMap();
1208
+ GdsFormControlElement.formAssociated = true;
1099
1209
  __decorateClass([
1100
1210
  property4({
1101
1211
  type: Boolean,
@@ -1123,16 +1233,20 @@ __decorateClass([
1123
1233
  // libs/core/src/components/dropdown/dropdown.styles.ts
1124
1234
  import { css as css4 } from "lit";
1125
1235
  var style4 = css4`
1126
- button {
1127
- appearance: none;
1128
- display: block;
1129
- background-color: black;
1130
- border-radius: 2rem;
1131
- border: none;
1132
- color: white;
1133
- padding: 0.7rem 2rem;
1134
- margin: 0.5rem 0;
1135
- box-sizing: border-box;
1236
+ @layer base, reset, transitional-styles;
1237
+
1238
+ @layer base {
1239
+ button {
1240
+ appearance: none;
1241
+ display: block;
1242
+ background-color: black;
1243
+ border-radius: 2rem;
1244
+ border: none;
1245
+ color: white;
1246
+ padding: 0.7rem 2rem;
1247
+ margin: 0.5rem 0;
1248
+ box-sizing: border-box;
1249
+ }
1136
1250
  }
1137
1251
  `;
1138
1252
  var dropdown_styles_default = style4;
@@ -1157,7 +1271,6 @@ var GdsDropdown = class extends GdsFormControlElement {
1157
1271
  this.compareWith = (a, b) => a === b;
1158
1272
  this.searchFilter = (q, o) => o.innerHTML.toLowerCase().includes(q.toLowerCase());
1159
1273
  this.syncPopoverWidth = false;
1160
- // Private members
1161
1274
  __privateAdd(this, _optionElements, void 0);
1162
1275
  /**
1163
1276
  * Event handler for filtering the options in the dropdown.
@@ -1266,6 +1379,7 @@ var GdsDropdown = class extends GdsFormControlElement {
1266
1379
  }
1267
1380
  render() {
1268
1381
  return html`
1382
+ ${this._tStyles}
1269
1383
  ${when2(
1270
1384
  this.label,
1271
1385
  () => html`<label for="trigger">${this.label}</label>`
@@ -1283,7 +1397,7 @@ var GdsDropdown = class extends GdsFormControlElement {
1283
1397
  aria-expanded="${this.open}"
1284
1398
  >
1285
1399
  <slot name="trigger">
1286
- <span>${unsafeHTML(this.displayValue)}</span>
1400
+ <span>${unsafeHTML2(this.displayValue)}</span>
1287
1401
  </slot>
1288
1402
  </button>
1289
1403
 
@@ -1428,6 +1542,9 @@ __decorateClass([
1428
1542
  __decorateClass([
1429
1543
  property5({ type: Boolean })
1430
1544
  ], GdsDropdown.prototype, "syncPopoverWidth", 2);
1545
+ __decorateClass([
1546
+ state4()
1547
+ ], GdsDropdown.prototype, "_tStyles", 2);
1431
1548
  __decorateClass([
1432
1549
  query("#trigger")
1433
1550
  ], GdsDropdown.prototype, "elTriggerBtn", 2);
@@ -1454,30 +1571,29 @@ GdsDropdown = __decorateClass([
1454
1571
  ], GdsDropdown);
1455
1572
 
1456
1573
  // libs/core/src/components/context-menu/context-menu.ts
1457
- import { LitElement as LitElement6 } from "lit";
1458
1574
  import { msg as msg3 } from "@lit/localize";
1459
1575
  import { classMap as classMap3 } from "lit-html/directives/class-map.js";
1460
- import { property as property6, queryAsync as queryAsync2 } from "lit/decorators.js";
1576
+ import { property as property6, queryAsync as queryAsync2, state as state6 } from "lit/decorators.js";
1461
1577
 
1462
1578
  // libs/core/src/primitives/menu/menu.ts
1463
- import { LitElement as LitElement5 } from "lit";
1464
1579
  import { createRef as createRef3, ref as ref3 } from "lit/directives/ref.js";
1465
- var _slotRef2;
1466
- var GdsMenu = class extends LitElement5 {
1580
+ import { state as state5 } from "lit/decorators.js";
1581
+ var GdsMenu = class extends GdsElement {
1467
1582
  constructor() {
1468
1583
  super();
1469
- __privateAdd(this, _slotRef2, createRef3());
1584
+ this.#slotRef = createRef3();
1470
1585
  new ListboxKbNavController(this);
1471
1586
  }
1587
+ #slotRef;
1472
1588
  connectedCallback() {
1473
1589
  super.connectedCallback();
1474
1590
  this.setAttribute("role", "menu");
1475
1591
  TransitionalStyles.instance.apply(this, "gds-listbox");
1476
1592
  }
1477
1593
  get navigableItems() {
1478
- if (!__privateGet(this, _slotRef2).value)
1594
+ if (!this.#slotRef.value)
1479
1595
  return [];
1480
- return unwrap(__privateGet(this, _slotRef2).value).assignedElements().filter(
1596
+ return unwrap(this.#slotRef.value).assignedElements().filter(
1481
1597
  (o) => !o.hasAttribute("isplaceholder")
1482
1598
  ) || [];
1483
1599
  }
@@ -1488,17 +1604,19 @@ var GdsMenu = class extends LitElement5 {
1488
1604
  this.navigableItems[0]?.focus();
1489
1605
  }
1490
1606
  render() {
1491
- return html`<slot ${ref3(__privateGet(this, _slotRef2))}></slot>`;
1607
+ return html`${this._tStyles}<slot ${ref3(this.#slotRef)}></slot>`;
1492
1608
  }
1493
1609
  };
1494
- _slotRef2 = new WeakMap();
1610
+ __decorateClass([
1611
+ state5()
1612
+ ], GdsMenu.prototype, "_tStyles", 2);
1495
1613
  GdsMenu = __decorateClass([
1496
1614
  gdsCustomElement("gds-menu")
1497
1615
  ], GdsMenu);
1498
1616
 
1499
1617
  // libs/core/src/components/context-menu/context-menu.ts
1500
1618
  var _handleItemClick, handleItemClick_fn;
1501
- var GdsContextMenu = class extends LitElement6 {
1619
+ var GdsContextMenu = class extends GdsElement {
1502
1620
  constructor() {
1503
1621
  super();
1504
1622
  __privateAdd(this, _handleItemClick);
@@ -1520,7 +1638,8 @@ var GdsContextMenu = class extends LitElement6 {
1520
1638
  });
1521
1639
  }
1522
1640
  render() {
1523
- return html`<button
1641
+ return html`${this._tStyles}
1642
+ <button
1524
1643
  id="trigger"
1525
1644
  class="ghost border-0 small ${classMap3({ highlighted: this.open })}"
1526
1645
  aria-label="${this.buttonLabel}"
@@ -1570,6 +1689,9 @@ __decorateClass([
1570
1689
  __decorateClass([
1571
1690
  property6()
1572
1691
  ], GdsContextMenu.prototype, "placement", 2);
1692
+ __decorateClass([
1693
+ state6()
1694
+ ], GdsContextMenu.prototype, "_tStyles", 2);
1573
1695
  __decorateClass([
1574
1696
  queryAsync2("#trigger")
1575
1697
  ], GdsContextMenu.prototype, "elTriggerBtn", 2);
@@ -1578,19 +1700,18 @@ GdsContextMenu = __decorateClass([
1578
1700
  ], GdsContextMenu);
1579
1701
 
1580
1702
  // libs/core/src/primitives/menu/menu-item.ts
1581
- import { LitElement as LitElement7 } from "lit";
1582
- var _handleOnClick;
1583
- var GdsMenuItem = class extends Focusable(LitElement7) {
1703
+ import { state as state7 } from "lit/decorators.js";
1704
+ var GdsMenuItem = class extends Focusable(GdsElement) {
1584
1705
  constructor() {
1585
1706
  super(...arguments);
1586
- __privateAdd(this, _handleOnClick, () => {
1707
+ this.#handleOnClick = () => {
1587
1708
  this.dispatchEvent(
1588
1709
  new CustomEvent("gds-menu-item-click", {
1589
1710
  bubbles: true,
1590
1711
  composed: true
1591
1712
  })
1592
1713
  );
1593
- });
1714
+ };
1594
1715
  }
1595
1716
  connectedCallback() {
1596
1717
  super.connectedCallback();
@@ -1601,33 +1722,37 @@ var GdsMenuItem = class extends Focusable(LitElement7) {
1601
1722
  e.preventDefault();
1602
1723
  this.click();
1603
1724
  });
1604
- this.addEventListener("click", __privateGet(this, _handleOnClick));
1725
+ this.addEventListener("click", this.#handleOnClick);
1605
1726
  TransitionalStyles.instance.apply(this, "gds-option");
1606
1727
  }
1728
+ #handleOnClick;
1607
1729
  render() {
1608
- return html`<slot></slot>`;
1730
+ return html`${this._tStyles}<slot></slot>`;
1609
1731
  }
1610
1732
  };
1611
- _handleOnClick = new WeakMap();
1733
+ __decorateClass([
1734
+ state7()
1735
+ ], GdsMenuItem.prototype, "_tStyles", 2);
1612
1736
  GdsMenuItem = __decorateClass([
1613
1737
  gdsCustomElement("gds-menu-item")
1614
1738
  ], GdsMenuItem);
1615
1739
 
1616
1740
  // libs/core/src/components/datepicker/datepicker.ts
1617
- import { property as property9, queryAll, queryAsync as queryAsync3, state as state3 } from "lit/decorators.js";
1741
+ import { property as property9, queryAll, queryAsync as queryAsync3, state as state10 } from "lit/decorators.js";
1618
1742
  import { join } from "lit/directives/join.js";
1619
1743
  import { when as when4 } from "lit/directives/when.js";
1620
1744
  import { until } from "lit/directives/until.js";
1621
1745
  import { map } from "lit/directives/map.js";
1622
1746
  import { repeat } from "lit/directives/repeat.js";
1747
+ import { nothing } from "lit";
1623
1748
  import { msg as msg5 } from "@lit/localize";
1624
1749
  import { eachYearOfInterval } from "date-fns";
1625
1750
 
1626
1751
  // libs/core/src/primitives/calendar/calendar.ts
1627
- import { LitElement as LitElement8, html as html5 } from "lit";
1752
+ import { html as html6 } from "lit";
1628
1753
  import { classMap as classMap4 } from "lit/directives/class-map.js";
1629
1754
  import { when as when3 } from "lit/directives/when.js";
1630
- import { property as property7, query as query2 } from "lit/decorators.js";
1755
+ import { property as property7, query as query2, state as state8 } from "lit/decorators.js";
1631
1756
  import { msg as msg4 } from "@lit/localize";
1632
1757
  import {
1633
1758
  addDays as addDays2,
@@ -1646,7 +1771,7 @@ import {
1646
1771
  eachWeekOfInterval,
1647
1772
  eachDayOfInterval
1648
1773
  } from "date-fns";
1649
- import { html as html4 } from "lit-html";
1774
+ import { html as html5 } from "lit-html";
1650
1775
  function renderMonthGridView(date, template) {
1651
1776
  const monthStart = startOfMonth(date);
1652
1777
  const monthEnd = endOfMonth(date);
@@ -1654,7 +1779,7 @@ function renderMonthGridView(date, template) {
1654
1779
  { start: monthStart, end: monthEnd },
1655
1780
  { weekStartsOn: 1 }
1656
1781
  );
1657
- return html4`${template(
1782
+ return html5`${template(
1658
1783
  weeks.map((weekStartDay) => ({
1659
1784
  days: eachDayOfInterval({
1660
1785
  start: weekStartDay,
@@ -1667,19 +1792,22 @@ function renderMonthGridView(date, template) {
1667
1792
  // libs/core/src/primitives/calendar/calendar.styles.ts
1668
1793
  import { css as css5 } from "lit";
1669
1794
  var style5 = css5`
1670
- td.disabled {
1671
- color: #999;
1672
- cursor: default;
1673
- }
1674
- td.today {
1675
- background-color: #eee;
1795
+ @layer base, reset, transitional-styles;
1796
+ @layer base {
1797
+ td.disabled {
1798
+ color: #999;
1799
+ cursor: default;
1800
+ }
1801
+ td.today {
1802
+ background-color: #eee;
1803
+ }
1676
1804
  }
1677
1805
  `;
1678
1806
  var calendar_styles_default = style5;
1679
1807
 
1680
1808
  // libs/core/src/primitives/calendar/calendar.ts
1681
1809
  var _setSelectedDate, setSelectedDate_fn, _handleKeyDown, handleKeyDown_fn;
1682
- var GdsCalendar = class extends LitElement8 {
1810
+ var GdsCalendar = class extends GdsElement {
1683
1811
  constructor() {
1684
1812
  super(...arguments);
1685
1813
  __privateAdd(this, _setSelectedDate);
@@ -1719,58 +1847,59 @@ var GdsCalendar = class extends LitElement8 {
1719
1847
  }
1720
1848
  render() {
1721
1849
  const currentDate = /* @__PURE__ */ new Date();
1722
- return html5`<table>
1723
- <thead>
1724
- <tr>
1725
- ${when3(this.showWeekNumbers, () => html5`<th></th>`)}
1726
- <th>${msg4("Mon")}</th>
1727
- <th>${msg4("Tue")}</th>
1728
- <th>${msg4("Wed")}</th>
1729
- <th>${msg4("Thu")}</th>
1730
- <th>${msg4("Fri")}</th>
1731
- <th>${msg4("Sat")}</th>
1732
- <th>${msg4("Sun")}</th>
1733
- </tr>
1734
- </thead>
1735
- <tbody>
1736
- ${renderMonthGridView(
1850
+ return html6`${this._tStyles}
1851
+ <table>
1852
+ <thead>
1853
+ <tr>
1854
+ ${when3(this.showWeekNumbers, () => html6`<th></th>`)}
1855
+ <th>${msg4("Mon")}</th>
1856
+ <th>${msg4("Tue")}</th>
1857
+ <th>${msg4("Wed")}</th>
1858
+ <th>${msg4("Thu")}</th>
1859
+ <th>${msg4("Fri")}</th>
1860
+ <th>${msg4("Sat")}</th>
1861
+ <th>${msg4("Sun")}</th>
1862
+ </tr>
1863
+ </thead>
1864
+ <tbody>
1865
+ ${renderMonthGridView(
1737
1866
  this.focusedDate,
1738
- (weeks) => html5`
1739
- ${weeks.map(
1740
- (week) => html5`
1741
- <tr>
1742
- ${when3(
1867
+ (weeks) => html6`
1868
+ ${weeks.map(
1869
+ (week) => html6`
1870
+ <tr>
1871
+ ${when3(
1743
1872
  this.showWeekNumbers,
1744
- () => html5`<td class="week-number">
1745
- ${getWeek(week.days[0])}
1746
- </td>`
1873
+ () => html6`<td class="week-number">
1874
+ ${getWeek(week.days[0])}
1875
+ </td>`
1747
1876
  )}
1748
- ${week.days.map((day) => {
1877
+ ${week.days.map((day) => {
1749
1878
  const isDisabled = !isSameMonth(this.focusedDate, day) || day < this.min || day > this.max;
1750
- return html5`
1751
- <td
1752
- class="${classMap4({
1879
+ return html6`
1880
+ <td
1881
+ class="${classMap4({
1753
1882
  disabled: isDisabled,
1754
1883
  today: isSameDay(currentDate, day)
1755
1884
  })}"
1756
- ?disabled=${isDisabled}
1757
- tabindex="${isSameDay(this.focusedDate, day) ? 0 : -1}"
1758
- aria-selected="${isSameDay(this.value, day)}"
1759
- aria-label="${day.toDateString()}"
1760
- @click=${() => isDisabled ? null : __privateMethod(this, _setSelectedDate, setSelectedDate_fn).call(this, day)}
1761
- id="dateCell-${day.getDate()}"
1762
- >
1763
- ${day.getDate()}
1764
- </td>
1765
- `;
1885
+ ?disabled=${isDisabled}
1886
+ tabindex="${isSameDay(this.focusedDate, day) ? 0 : -1}"
1887
+ aria-selected="${isSameDay(this.value, day)}"
1888
+ aria-label="${day.toDateString()}"
1889
+ @click=${() => isDisabled ? null : __privateMethod(this, _setSelectedDate, setSelectedDate_fn).call(this, day)}
1890
+ id="dateCell-${day.getDate()}"
1891
+ >
1892
+ ${day.getDate()}
1893
+ </td>
1894
+ `;
1766
1895
  })}
1767
- </tr>
1768
- `
1896
+ </tr>
1897
+ `
1769
1898
  )}
1770
- `
1899
+ `
1771
1900
  )}
1772
- </tbody>
1773
- </table>`;
1901
+ </tbody>
1902
+ </table>`;
1774
1903
  }
1775
1904
  };
1776
1905
  _setSelectedDate = new WeakSet();
@@ -1865,15 +1994,18 @@ __decorateClass([
1865
1994
  __decorateClass([
1866
1995
  query2('td[tabindex="0"]')
1867
1996
  ], GdsCalendar.prototype, "_elFocusedCell", 2);
1997
+ __decorateClass([
1998
+ state8()
1999
+ ], GdsCalendar.prototype, "_tStyles", 2);
1868
2000
  GdsCalendar = __decorateClass([
1869
2001
  gdsCustomElement("gds-calendar")
1870
2002
  ], GdsCalendar);
1871
2003
 
1872
2004
  // libs/core/src/components/datepicker/date-part-spinner.ts
1873
- import { LitElement as LitElement9 } from "lit";
1874
- import { property as property8, state as state2 } from "lit/decorators.js";
2005
+ import { LitElement as LitElement6 } from "lit";
2006
+ import { property as property8, state as state9 } from "lit/decorators.js";
1875
2007
  var _inputBuffer, _increment, _decrement, _handleClick, _handleFocus, _handleBlur, _handleWheel, _handleKeyDown2, _focusNextSpinner, focusNextSpinner_fn, _dispatchChangeEvent, dispatchChangeEvent_fn, _formatNumber, formatNumber_fn, _clamp, clamp_fn, _clearInputBuffer, clearInputBuffer_fn;
1876
- var GdsDatePartSpinner = class extends LitElement9 {
2008
+ var GdsDatePartSpinner = class extends LitElement6 {
1877
2009
  constructor() {
1878
2010
  super(...arguments);
1879
2011
  __privateAdd(this, _focusNextSpinner);
@@ -2032,7 +2164,7 @@ __decorateClass([
2032
2164
  property8({ type: Number, attribute: "aria-valuemax" })
2033
2165
  ], GdsDatePartSpinner.prototype, "max", 2);
2034
2166
  __decorateClass([
2035
- state2()
2167
+ state9()
2036
2168
  ], GdsDatePartSpinner.prototype, "displayValue", 2);
2037
2169
  __decorateClass([
2038
2170
  watch("value")
@@ -2044,13 +2176,15 @@ GdsDatePartSpinner = __decorateClass([
2044
2176
  // libs/core/src/components/datepicker/datepicker.styles.ts
2045
2177
  import { css as css6 } from "lit";
2046
2178
  var styles = css6`
2047
- label {
2048
- display: block;
2179
+ @layer base, reset, transitional-styles;
2180
+ @layer base {
2181
+ label {
2182
+ display: block;
2183
+ }
2049
2184
  }
2050
2185
  `;
2051
2186
 
2052
2187
  // libs/core/src/components/datepicker/datepicker.ts
2053
- import { nothing } from "lit";
2054
2188
  var dateConverter = {
2055
2189
  fromAttribute(value) {
2056
2190
  return new Date(value);
@@ -2059,7 +2193,7 @@ var dateConverter = {
2059
2193
  return value.toISOString();
2060
2194
  }
2061
2195
  };
2062
- var _renderBackToValidRangeButton, renderBackToValidRangeButton_fn, _focusDate, focusDate_fn, _getSpinnerLabel, getSpinnerLabel_fn, _getMinSpinnerValue, getMinSpinnerValue_fn, _getMaxSpinnerValue, getMaxSpinnerValue_fn, _dispatchChangeEvent2, dispatchChangeEvent_fn2, _handleIncrementFocusedMonth, _handleDecrementFocusedMonth, _handleFocusChange, _handlePopoverStateChange, _handleSpinnerKeydown, _parseDateFormat, parseDateFormat_fn, _handleSpinnerChange, _spinnerState, _years, years_get;
2196
+ var _renderBackToValidRangeButton, renderBackToValidRangeButton_fn, _focusDate, focusDate_fn, _getSpinnerLabel, getSpinnerLabel_fn, _getMinSpinnerValue, getMinSpinnerValue_fn, _getMaxSpinnerValue, getMaxSpinnerValue_fn, _dispatchChangeEvent2, dispatchChangeEvent_fn2, _handleCalendarChange, _handleMonthChange, _handleYearChange, _handleIncrementFocusedMonth, _handleDecrementFocusedMonth, _handleFocusChange, _handlePopoverStateChange, _handleSpinnerKeydown, _parseDateFormat, parseDateFormat_fn, _handleSpinnerChange, _spinnerState, _years, years_get;
2063
2197
  var GdsDatepicker = class extends GdsFormControlElement {
2064
2198
  constructor() {
2065
2199
  super(...arguments);
@@ -2086,6 +2220,20 @@ var GdsDatepicker = class extends GdsFormControlElement {
2086
2220
  this._focusedMonth = (/* @__PURE__ */ new Date()).getMonth();
2087
2221
  this._focusedYear = (/* @__PURE__ */ new Date()).getFullYear();
2088
2222
  this._dateFormatLayout = __privateMethod(this, _parseDateFormat, parseDateFormat_fn).call(this, "y-m-d");
2223
+ __privateAdd(this, _handleCalendarChange, (e) => {
2224
+ e.stopPropagation();
2225
+ this.value = e.detail;
2226
+ this.open = false;
2227
+ __privateMethod(this, _dispatchChangeEvent2, dispatchChangeEvent_fn2).call(this);
2228
+ });
2229
+ __privateAdd(this, _handleMonthChange, (e) => {
2230
+ e.stopPropagation();
2231
+ this._focusedMonth = e.target?.value;
2232
+ });
2233
+ __privateAdd(this, _handleYearChange, (e) => {
2234
+ e.stopPropagation();
2235
+ this._focusedYear = e.target?.value;
2236
+ });
2089
2237
  __privateAdd(this, _handleIncrementFocusedMonth, (_e) => {
2090
2238
  this._focusedMonth++;
2091
2239
  if (this._focusedMonth > 11) {
@@ -2173,7 +2321,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
2173
2321
  TransitionalStyles.instance.apply(this, "gds-datepicker");
2174
2322
  }
2175
2323
  render() {
2176
- return html`
2324
+ return html`${this._tStyles}
2177
2325
  <label for="spinner-0" id="label">${this.label}</label>
2178
2326
 
2179
2327
  <div class="form-info"><slot name="sub-label"></slot></div>
@@ -2241,7 +2389,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
2241
2389
  </button>
2242
2390
  <gds-dropdown
2243
2391
  .value=${this._focusedMonth.toString()}
2244
- @change=${(e) => this._focusedMonth = e.target?.value}
2392
+ @change=${__privateGet(this, _handleMonthChange)}
2245
2393
  aria-label="${msg5("Month")}"
2246
2394
  >
2247
2395
  <gds-option value="0">${msg5("January")}</gds-option>
@@ -2259,7 +2407,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
2259
2407
  </gds-dropdown>
2260
2408
  <gds-dropdown
2261
2409
  .value=${this._focusedYear.toString()}
2262
- @change=${(e) => this._focusedYear = e.target?.value}
2410
+ @change=${__privateGet(this, _handleYearChange)}
2263
2411
  aria-label="${msg5("Year")}"
2264
2412
  >
2265
2413
  ${repeat(
@@ -2275,12 +2423,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
2275
2423
 
2276
2424
  <gds-calendar
2277
2425
  id="calendar"
2278
- @change=${(e) => {
2279
- e.stopPropagation();
2280
- this.value = e.detail;
2281
- this.open = false;
2282
- __privateMethod(this, _dispatchChangeEvent2, dispatchChangeEvent_fn2).call(this);
2283
- }}
2426
+ @change=${__privateGet(this, _handleCalendarChange)}
2284
2427
  @gds-date-focused=${__privateGet(this, _handleFocusChange)}
2285
2428
  .focusedMonth=${this._focusedMonth}
2286
2429
  .focusedYear=${this._focusedYear}
@@ -2311,8 +2454,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
2311
2454
  ${msg5("Today")}
2312
2455
  </button>
2313
2456
  </div>
2314
- </gds-popover>
2315
- `;
2457
+ </gds-popover> `;
2316
2458
  }
2317
2459
  _handleValueChange() {
2318
2460
  if (!this.value) {
@@ -2392,6 +2534,9 @@ dispatchChangeEvent_fn2 = function() {
2392
2534
  })
2393
2535
  );
2394
2536
  };
2537
+ _handleCalendarChange = new WeakMap();
2538
+ _handleMonthChange = new WeakMap();
2539
+ _handleYearChange = new WeakMap();
2395
2540
  _handleIncrementFocusedMonth = new WeakMap();
2396
2541
  _handleDecrementFocusedMonth = new WeakMap();
2397
2542
  _handleFocusChange = new WeakMap();
@@ -2461,13 +2606,13 @@ __decorateClass([
2461
2606
  queryAsync3("#calendar-button")
2462
2607
  ], GdsDatepicker.prototype, "test_calendarButton", 2);
2463
2608
  __decorateClass([
2464
- state3()
2609
+ state10()
2465
2610
  ], GdsDatepicker.prototype, "_focusedMonth", 2);
2466
2611
  __decorateClass([
2467
- state3()
2612
+ state10()
2468
2613
  ], GdsDatepicker.prototype, "_focusedYear", 2);
2469
2614
  __decorateClass([
2470
- state3()
2615
+ state10()
2471
2616
  ], GdsDatepicker.prototype, "_dateFormatLayout", 2);
2472
2617
  __decorateClass([
2473
2618
  queryAsync3("#calendar")
@@ -2478,6 +2623,9 @@ __decorateClass([
2478
2623
  __decorateClass([
2479
2624
  queryAll(getScopedTagName("gds-date-part-spinner"))
2480
2625
  ], GdsDatepicker.prototype, "_elSpinners", 2);
2626
+ __decorateClass([
2627
+ state10()
2628
+ ], GdsDatepicker.prototype, "_tStyles", 2);
2481
2629
  __decorateClass([
2482
2630
  watch("value")
2483
2631
  ], GdsDatepicker.prototype, "_handleValueChange", 1);