@sebgroup/green-core 1.4.5 → 1.5.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.
@@ -25,6 +25,10 @@ export declare class GdsContextMenu extends GdsElement {
25
25
  * The label for the trigger button.
26
26
  */
27
27
  buttonLabel: string;
28
+ /**
29
+ * The label for the trigger button.
30
+ */
31
+ showLabel: boolean;
28
32
  /**
29
33
  * The label for the popover and menu. Should describe the context of the menu.
30
34
  */
@@ -58,6 +58,10 @@ export declare class GdsDatepicker extends GdsFormControlElement<Date> {
58
58
  * is closed, the value will be undefined.
59
59
  */
60
60
  getFocusedDate(): Promise<Date | undefined>;
61
+ /**
62
+ * Get a string representation of the currently displayed value in the input field. The formatting will match the dateformat attribute.
63
+ */
64
+ get displayValue(): string;
61
65
  /**
62
66
  * A reference to the calendar button element inside the shadow root.
63
67
  * Inteded for use in integration tests.
@@ -74,6 +78,7 @@ export declare class GdsDatepicker extends GdsFormControlElement<Date> {
74
78
  private _elCalendar;
75
79
  private _elTrigger;
76
80
  private _elSpinners;
81
+ private _elInput;
77
82
  private _tStyles?;
78
83
  connectedCallback(): void;
79
84
  render(): any;
@@ -77,13 +77,6 @@ export declare class GdsDropdown<ValueT = any> extends GdsFormControlElement<Val
77
77
  * are still readable and apply appropriate custom layout or truncation if neccecary.
78
78
  */
79
79
  syncPopoverWidth: boolean;
80
- private _tStyles?;
81
- private elTriggerBtn;
82
- private elTriggerBtnAsync;
83
- private elListbox;
84
- private elSearchInput;
85
- constructor();
86
- connectedCallback(): void;
87
80
  /**
88
81
  * Get the options of the dropdown.
89
82
  */
@@ -98,6 +91,13 @@ export declare class GdsDropdown<ValueT = any> extends GdsFormControlElement<Val
98
91
  * If the dropdown is in multiple mode, this will be a comma separated list of the selected values.
99
92
  */
100
93
  get displayValue(): string;
94
+ private _tStyles?;
95
+ private _elTriggerBtn;
96
+ private _elTriggerBtnAsync;
97
+ private _elListbox;
98
+ private _elSearchInput;
99
+ constructor();
100
+ connectedCallback(): void;
101
101
  render(): any;
102
102
  /**
103
103
  * Update value assignment and request update when the light DOM changes.
package/index.js CHANGED
@@ -94,9 +94,13 @@ function watch(propertyName, options) {
94
94
  }
95
95
 
96
96
  // libs/core/src/utils/decorators/observe-light-dom.ts
97
- function observeLightDOM() {
97
+ function observeLightDOM(observerConfig = {
98
+ attributes: true,
99
+ childList: true,
100
+ subtree: false,
101
+ characterData: true
102
+ }) {
98
103
  return (proto, _propertyKey, descriptor) => {
99
- const observerConfig = { attributes: true, childList: true, subtree: false };
100
104
  let observer;
101
105
  const connectedCallback = proto.connectedCallback;
102
106
  const disconnectedCallback = proto.disconnectedCallback;
@@ -139,7 +143,7 @@ function watchMediaQuery(q) {
139
143
  // libs/core/src/utils/helpers/custom-element-scoping.ts
140
144
  import { html as litHtml } from "lit";
141
145
  import { customElement } from "lit/decorators.js";
142
- var VER_SUFFIX = "-6cf221";
146
+ var VER_SUFFIX = "-eaa4d5";
143
147
  var elementLookupTable = /* @__PURE__ */ new Map();
144
148
  var gdsCustomElement = (tagName) => {
145
149
  if (globalThis.GDS_DISABLE_VERSIONED_ELEMENTS) {
@@ -873,10 +877,10 @@ var GdsPopover = class extends GdsElement {
873
877
  // A function that removes the Floating UI auto positioning. This gets called when we switch to mobile view layout.
874
878
  __privateAdd(this, _autoPositionCleanupFn, void 0);
875
879
  __privateAdd(this, _isMobileViewport, false);
876
- __privateAdd(this, _dispatchUiStateEvent, () => {
880
+ __privateAdd(this, _dispatchUiStateEvent, (reason) => {
877
881
  this.dispatchEvent(
878
882
  new CustomEvent("gds-ui-state", {
879
- detail: { open: this.open },
883
+ detail: { open: this.open, reason },
880
884
  bubbles: false,
881
885
  composed: false
882
886
  })
@@ -886,7 +890,7 @@ var GdsPopover = class extends GdsElement {
886
890
  e.stopPropagation();
887
891
  e.preventDefault();
888
892
  this.open = false;
889
- __privateGet(this, _dispatchUiStateEvent).call(this);
893
+ __privateGet(this, _dispatchUiStateEvent).call(this, "close");
890
894
  setTimeout(() => this._trigger?.focus(), 250);
891
895
  });
892
896
  /**
@@ -896,11 +900,11 @@ var GdsPopover = class extends GdsElement {
896
900
  if (e.key === "ArrowDown") {
897
901
  e.preventDefault();
898
902
  this.open = true;
899
- __privateGet(this, _dispatchUiStateEvent).call(this);
903
+ __privateGet(this, _dispatchUiStateEvent).call(this, "show");
900
904
  }
901
905
  if (e.key === "Escape") {
902
906
  this.open = false;
903
- __privateGet(this, _dispatchUiStateEvent).call(this);
907
+ __privateGet(this, _dispatchUiStateEvent).call(this, "cancel");
904
908
  }
905
909
  });
906
910
  /**
@@ -922,7 +926,7 @@ var GdsPopover = class extends GdsElement {
922
926
  if (!isInDialog) {
923
927
  e.stopPropagation();
924
928
  this.open = false;
925
- __privateGet(this, _dispatchUiStateEvent).call(this);
929
+ __privateGet(this, _dispatchUiStateEvent).call(this, "close");
926
930
  }
927
931
  }
928
932
  });
@@ -945,7 +949,7 @@ var GdsPopover = class extends GdsElement {
945
949
  this.addEventListener("keydown", (e) => {
946
950
  if (e.key === "Escape") {
947
951
  this.open = false;
948
- __privateGet(this, _dispatchUiStateEvent).call(this);
952
+ __privateGet(this, _dispatchUiStateEvent).call(this, "cancel");
949
953
  e.stopPropagation();
950
954
  e.preventDefault();
951
955
  }
@@ -1285,7 +1289,7 @@ var GdsDropdown = class extends GdsFormControlElement {
1285
1289
  * @param e The keyboard event.
1286
1290
  */
1287
1291
  __privateAdd(this, _handleSearchFieldKeyUp, (e) => {
1288
- const input = this.elSearchInput;
1292
+ const input = this._elSearchInput;
1289
1293
  const options = Array.from(__privateGet(this, _optionElements));
1290
1294
  options.forEach((o) => o.hidden = false);
1291
1295
  if (!input.value)
@@ -1300,11 +1304,13 @@ var GdsDropdown = class extends GdsFormControlElement {
1300
1304
  * If found, focus should be moved to the listbox.
1301
1305
  */
1302
1306
  __privateAdd(this, _handleSearchFieldKeyDown, (e) => {
1303
- if (e.key === "ArrowDown" || e.key === "Tab") {
1304
- e.preventDefault();
1305
- this.elListbox?.focus();
1306
- return;
1307
- }
1307
+ this._elListbox?.then((listbox) => {
1308
+ if (e.key === "ArrowDown" || e.key === "Tab") {
1309
+ e.preventDefault();
1310
+ listbox.focus();
1311
+ return;
1312
+ }
1313
+ });
1308
1314
  });
1309
1315
  /**
1310
1316
  * Check for Tab in the listbox.
@@ -1313,12 +1319,12 @@ var GdsDropdown = class extends GdsFormControlElement {
1313
1319
  __privateAdd(this, _handleListboxKeyDown, (e) => {
1314
1320
  if (e.key === "Tab" && this.searchable) {
1315
1321
  e.preventDefault();
1316
- this.elSearchInput?.focus();
1322
+ this._elSearchInput?.focus();
1317
1323
  return;
1318
1324
  }
1319
1325
  });
1320
1326
  __privateAdd(this, _handleOptionFocusChange, (e) => {
1321
- const triggerButton = this.elTriggerBtn;
1327
+ const triggerButton = this._elTriggerBtn;
1322
1328
  if (triggerButton)
1323
1329
  triggerButton.ariaActiveDescendantElement = e.target;
1324
1330
  });
@@ -1334,7 +1340,7 @@ var GdsDropdown = class extends GdsFormControlElement {
1334
1340
  if (e.key === "Tab" && !this.searchable) {
1335
1341
  e.preventDefault();
1336
1342
  this.open = false;
1337
- this.elTriggerBtn?.focus();
1343
+ this._elTriggerBtn?.focus();
1338
1344
  }
1339
1345
  });
1340
1346
  constrainSlots(this);
@@ -1343,14 +1349,6 @@ var GdsDropdown = class extends GdsFormControlElement {
1343
1349
  getScopedTagName("gds-option")
1344
1350
  ));
1345
1351
  }
1346
- connectedCallback() {
1347
- super.connectedCallback();
1348
- TransitionalStyles.instance.apply(this, "gds-dropdown");
1349
- this.updateComplete.then(() => {
1350
- this._handleLightDOMChange();
1351
- this._handleValueChange();
1352
- });
1353
- }
1354
1352
  /**
1355
1353
  * Get the options of the dropdown.
1356
1354
  */
@@ -1384,6 +1382,14 @@ var GdsDropdown = class extends GdsFormControlElement {
1384
1382
  }
1385
1383
  return displayValue || this.placeholder?.innerHTML || "";
1386
1384
  }
1385
+ connectedCallback() {
1386
+ super.connectedCallback();
1387
+ TransitionalStyles.instance.apply(this, "gds-dropdown");
1388
+ this.updateComplete.then(() => {
1389
+ this._handleLightDOMChange();
1390
+ this._handleValueChange();
1391
+ });
1392
+ }
1387
1393
  render() {
1388
1394
  return html`
1389
1395
  ${this._tStyles}
@@ -1413,7 +1419,7 @@ var GdsDropdown = class extends GdsFormControlElement {
1413
1419
  <gds-popover
1414
1420
  .label=${this.label}
1415
1421
  .open=${this.open}
1416
- .triggerRef=${this.elTriggerBtnAsync}
1422
+ .triggerRef=${this._elTriggerBtnAsync}
1417
1423
  .calcMaxWidth=${(trigger) => this.syncPopoverWidth ? `${trigger.offsetWidth}px` : `auto`}
1418
1424
  @gds-ui-state=${(e) => this.open = e.detail.open}
1419
1425
  >
@@ -1444,27 +1450,31 @@ var GdsDropdown = class extends GdsFormControlElement {
1444
1450
  }
1445
1451
  _handleLightDOMChange() {
1446
1452
  this.requestUpdate();
1447
- this._handleValueChange();
1448
- if (this.multiple)
1453
+ if (this.multiple) {
1454
+ this._handleValueChange();
1449
1455
  return;
1456
+ }
1450
1457
  if (!this.value) {
1451
1458
  if (this.placeholder)
1452
1459
  this.value = this.placeholder.value;
1453
1460
  else
1454
1461
  this.value = this.options[0]?.value;
1455
- } else if (!this.placeholder && this.options.find((o) => o.value === this.value) === void 0) {
1462
+ } else if (!this.placeholder && this.options.find(
1463
+ (o) => this.compareWith(o.value, this.value)
1464
+ ) === void 0) {
1456
1465
  this.options[0] && (this.options[0].selected = true);
1457
1466
  this.value = this.options[0]?.value;
1458
1467
  }
1459
1468
  }
1460
1469
  _handleValueChange() {
1461
- const listbox = this.elListbox;
1462
- if (listbox) {
1463
- if (Array.isArray(this.value))
1464
- listbox.selection = this.value;
1465
- else
1466
- listbox.selection = [this.value];
1467
- }
1470
+ this._elListbox.then((listbox) => {
1471
+ if (listbox) {
1472
+ if (Array.isArray(this.value))
1473
+ listbox.selection = this.value;
1474
+ else
1475
+ listbox.selection = [this.value];
1476
+ }
1477
+ });
1468
1478
  }
1469
1479
  _onOpenChange() {
1470
1480
  const open = this.open;
@@ -1473,7 +1483,7 @@ var GdsDropdown = class extends GdsFormControlElement {
1473
1483
  __privateMethod(this, _registerAutoCloseListener, registerAutoCloseListener_fn).call(this);
1474
1484
  else {
1475
1485
  __privateMethod(this, _unregisterAutoCloseListener, unregisterAutoCloseListener_fn).call(this);
1476
- this.elSearchInput && (this.elSearchInput.value = "");
1486
+ this._elSearchInput && (this._elSearchInput.value = "");
1477
1487
  }
1478
1488
  this.dispatchEvent(
1479
1489
  new CustomEvent("gds-ui-state", {
@@ -1491,23 +1501,22 @@ _handleListboxKeyDown = new WeakMap();
1491
1501
  _handleOptionFocusChange = new WeakMap();
1492
1502
  _handleSelectionChange = new WeakSet();
1493
1503
  handleSelectionChange_fn = function() {
1494
- const listbox = this.elListbox;
1495
- if (!listbox)
1496
- return;
1497
- if (this.multiple)
1498
- this.value = listbox.selection.map((s) => s.value);
1499
- else {
1500
- this.value = listbox.selection[0]?.value;
1501
- this.open = false;
1502
- setTimeout(() => this.elTriggerBtn?.focus(), 0);
1503
- }
1504
- this.dispatchEvent(
1505
- new CustomEvent("change", {
1506
- detail: { value: this.value },
1507
- bubbles: true,
1508
- composed: true
1509
- })
1510
- );
1504
+ this._elListbox.then((listbox) => {
1505
+ if (this.multiple)
1506
+ this.value = listbox.selection.map((s) => s.value);
1507
+ else {
1508
+ this.value = listbox.selection[0]?.value;
1509
+ this.open = false;
1510
+ setTimeout(() => this._elTriggerBtn?.focus(), 0);
1511
+ }
1512
+ this.dispatchEvent(
1513
+ new CustomEvent("change", {
1514
+ detail: { value: this.value },
1515
+ bubbles: true,
1516
+ composed: true
1517
+ })
1518
+ );
1519
+ });
1511
1520
  };
1512
1521
  _registerAutoCloseListener = new WeakSet();
1513
1522
  registerAutoCloseListener_fn = function() {
@@ -1554,18 +1563,23 @@ __decorateClass([
1554
1563
  ], GdsDropdown.prototype, "_tStyles", 2);
1555
1564
  __decorateClass([
1556
1565
  query("#trigger")
1557
- ], GdsDropdown.prototype, "elTriggerBtn", 2);
1566
+ ], GdsDropdown.prototype, "_elTriggerBtn", 2);
1558
1567
  __decorateClass([
1559
1568
  queryAsync("#trigger")
1560
- ], GdsDropdown.prototype, "elTriggerBtnAsync", 2);
1569
+ ], GdsDropdown.prototype, "_elTriggerBtnAsync", 2);
1561
1570
  __decorateClass([
1562
- query("#listbox")
1563
- ], GdsDropdown.prototype, "elListbox", 2);
1571
+ queryAsync("#listbox")
1572
+ ], GdsDropdown.prototype, "_elListbox", 2);
1564
1573
  __decorateClass([
1565
1574
  query("#searchinput")
1566
- ], GdsDropdown.prototype, "elSearchInput", 2);
1575
+ ], GdsDropdown.prototype, "_elSearchInput", 2);
1567
1576
  __decorateClass([
1568
- observeLightDOM()
1577
+ observeLightDOM({
1578
+ attributes: true,
1579
+ childList: true,
1580
+ subtree: true,
1581
+ characterData: true
1582
+ })
1569
1583
  ], GdsDropdown.prototype, "_handleLightDOMChange", 1);
1570
1584
  __decorateClass([
1571
1585
  watch("value")
@@ -1578,6 +1592,7 @@ GdsDropdown = __decorateClass([
1578
1592
  ], GdsDropdown);
1579
1593
 
1580
1594
  // libs/core/src/components/context-menu/context-menu.ts
1595
+ import { nothing } from "lit";
1581
1596
  import { msg as msg3 } from "@lit/localize";
1582
1597
  import { classMap as classMap3 } from "lit-html/directives/class-map.js";
1583
1598
  import { property as property6, queryAsync as queryAsync2, state as state6 } from "lit/decorators.js";
@@ -1629,6 +1644,7 @@ var GdsContextMenu = class extends GdsElement {
1629
1644
  __privateAdd(this, _handleItemClick);
1630
1645
  this.open = false;
1631
1646
  this.buttonLabel = msg3("Open context menu");
1647
+ this.showLabel = false;
1632
1648
  this.label = "";
1633
1649
  this.placement = "bottom-start";
1634
1650
  constrainSlots(this);
@@ -1648,14 +1664,15 @@ var GdsContextMenu = class extends GdsElement {
1648
1664
  return html`${this._tStyles}
1649
1665
  <button
1650
1666
  id="trigger"
1651
- class="ghost border-0 small ${classMap3({ highlighted: this.open })}"
1652
- aria-label="${this.buttonLabel}"
1667
+ class="icon border-0 small ${classMap3({ highlighted: this.open })}"
1668
+ aria-label=${this.buttonLabel ?? this.label}
1653
1669
  aria-haspopup="menu"
1654
1670
  aria-controls="menu"
1655
1671
  aria-expanded=${this.open}
1656
1672
  @click=${() => this.open = !this.open}
1657
1673
  >
1658
1674
  <slot name="trigger">
1675
+ ${this.showLabel ? this.buttonLabel ?? this.label : nothing}
1659
1676
  <i class="sg-icon sg-icon-ellipsis"></i>
1660
1677
  </slot>
1661
1678
  </button>
@@ -1668,7 +1685,7 @@ var GdsContextMenu = class extends GdsElement {
1668
1685
  @gds-ui-state=${(e) => this.open = e.detail.open}
1669
1686
  >
1670
1687
  <gds-menu
1671
- aria-label=${this.label}
1688
+ aria-label=${this.label ?? this.buttonLabel}
1672
1689
  @gds-menu-item-click=${__privateMethod(this, _handleItemClick, handleItemClick_fn)}
1673
1690
  >
1674
1691
  <slot allow="gds-menu-item"></slot>
@@ -1688,8 +1705,15 @@ __decorateClass([
1688
1705
  property6({ type: Boolean, reflect: true })
1689
1706
  ], GdsContextMenu.prototype, "open", 2);
1690
1707
  __decorateClass([
1691
- property6()
1708
+ property6({
1709
+ attribute: "button-label"
1710
+ })
1692
1711
  ], GdsContextMenu.prototype, "buttonLabel", 2);
1712
+ __decorateClass([
1713
+ property6({
1714
+ attribute: "show-label"
1715
+ })
1716
+ ], GdsContextMenu.prototype, "showLabel", 2);
1693
1717
  __decorateClass([
1694
1718
  property6()
1695
1719
  ], GdsContextMenu.prototype, "label", 2);
@@ -1745,13 +1769,13 @@ GdsMenuItem = __decorateClass([
1745
1769
  ], GdsMenuItem);
1746
1770
 
1747
1771
  // libs/core/src/components/datepicker/datepicker.ts
1748
- import { property as property9, queryAll, queryAsync as queryAsync3, state as state10 } from "lit/decorators.js";
1772
+ import { property as property9, query as query3, queryAll, queryAsync as queryAsync3, state as state10 } from "lit/decorators.js";
1749
1773
  import { join } from "lit/directives/join.js";
1750
1774
  import { when as when4 } from "lit/directives/when.js";
1751
1775
  import { until } from "lit/directives/until.js";
1752
1776
  import { map } from "lit/directives/map.js";
1753
1777
  import { repeat } from "lit/directives/repeat.js";
1754
- import { nothing } from "lit";
1778
+ import { nothing as nothing2 } from "lit";
1755
1779
  import { msg as msg5 } from "@lit/localize";
1756
1780
 
1757
1781
  // libs/core/src/primitives/calendar/calendar.ts
@@ -1908,6 +1932,8 @@ var GdsCalendar = class extends GdsElement {
1908
1932
  </table>`;
1909
1933
  }
1910
1934
  _valueChanged() {
1935
+ if (!this.value)
1936
+ return;
1911
1937
  this.focusedDate = this.value;
1912
1938
  }
1913
1939
  };
@@ -2014,10 +2040,10 @@ GdsCalendar = __decorateClass([
2014
2040
  ], GdsCalendar);
2015
2041
 
2016
2042
  // libs/core/src/components/datepicker/date-part-spinner.ts
2017
- import { LitElement as LitElement6 } from "lit";
2043
+ import { LitElement as LitElement7 } from "lit";
2018
2044
  import { property as property8, state as state9 } from "lit/decorators.js";
2019
2045
  var _inputBuffer, _increment, _decrement, _handleClick, _handleFocus, _handleBlur, _handleWheel, _handleKeyDown2, _focusNextSpinner, focusNextSpinner_fn, _dispatchChangeEvent, dispatchChangeEvent_fn, _formatNumber, formatNumber_fn, _clamp, clamp_fn, _clearInputBuffer, clearInputBuffer_fn;
2020
- var GdsDatePartSpinner = class extends LitElement6 {
2046
+ var GdsDatePartSpinner = class extends LitElement7 {
2021
2047
  constructor() {
2022
2048
  super(...arguments);
2023
2049
  __privateAdd(this, _focusNextSpinner);
@@ -2209,7 +2235,7 @@ var dateConverter = {
2209
2235
  return value.toISOString();
2210
2236
  }
2211
2237
  };
2212
- var _renderBackToValidRangeButton, renderBackToValidRangeButton_fn, _focusDate, focusDate_fn, _getSpinnerLabel, getSpinnerLabel_fn, _getMinSpinnerValue, getMinSpinnerValue_fn, _getMaxSpinnerValue, getMaxSpinnerValue_fn, _dispatchChangeEvent2, dispatchChangeEvent_fn2, _handleFieldClick, _handleCalendarChange, _handleMonthChange, _handleYearChange, _handleIncrementFocusedMonth, _handleDecrementFocusedMonth, _handleFocusChange, _handlePopoverStateChange, _handleSpinnerKeydown, _parseDateFormat, parseDateFormat_fn, _handleSpinnerChange, _spinnerState, _years, years_get, _isValueOutsideRange, isValueOutsideRange_get;
2238
+ var _valueOnOpen, _renderBackToValidRangeButton, renderBackToValidRangeButton_fn, _focusDate, focusDate_fn, _getSpinnerLabel, getSpinnerLabel_fn, _getMinSpinnerValue, getMinSpinnerValue_fn, _getMaxSpinnerValue, getMaxSpinnerValue_fn, _dispatchChangeEvent2, dispatchChangeEvent_fn2, _handleClipboardCopy, _handleClipboardPaste, _handleFieldClick, _handleCalendarChange, _handleMonthChange, _handleYearChange, _handleIncrementFocusedMonth, _handleDecrementFocusedMonth, _handleCalendarFocusChange, _handlePopoverStateChange, _handleSpinnerKeydown, _parseDateFormat, parseDateFormat_fn, _handleSpinnerChange, _spinnerState, _years, years_get, _isValueOutsideRange, isValueOutsideRange_get;
2213
2239
  var GdsDatepicker = class extends GdsFormControlElement {
2214
2240
  constructor() {
2215
2241
  super(...arguments);
@@ -2236,8 +2262,25 @@ var GdsDatepicker = class extends GdsFormControlElement {
2236
2262
  this._focusedMonth = (/* @__PURE__ */ new Date()).getMonth();
2237
2263
  this._focusedYear = (/* @__PURE__ */ new Date()).getFullYear();
2238
2264
  this._dateFormatLayout = __privateMethod(this, _parseDateFormat, parseDateFormat_fn).call(this, "y-m-d");
2265
+ __privateAdd(this, _valueOnOpen, void 0);
2266
+ __privateAdd(this, _handleClipboardCopy, (e) => {
2267
+ e.preventDefault();
2268
+ e.clipboardData?.setData("text/plain", this.displayValue);
2269
+ });
2270
+ __privateAdd(this, _handleClipboardPaste, (e) => {
2271
+ e.preventDefault();
2272
+ const pasted = e.clipboardData?.getData("text/plain");
2273
+ if (!pasted)
2274
+ return;
2275
+ const pastedDate = new Date(pasted);
2276
+ if (pastedDate.toString() === "Invalid Date")
2277
+ return;
2278
+ this.value = pastedDate;
2279
+ __privateMethod(this, _dispatchChangeEvent2, dispatchChangeEvent_fn2).call(this);
2280
+ });
2239
2281
  __privateAdd(this, _handleFieldClick, (e) => {
2240
2282
  this._elSpinners[0].focus();
2283
+ window.getSelection()?.selectAllChildren(this._elSpinners[0]);
2241
2284
  });
2242
2285
  __privateAdd(this, _handleCalendarChange, (e) => {
2243
2286
  e.stopPropagation();
@@ -2267,15 +2310,21 @@ var GdsDatepicker = class extends GdsFormControlElement {
2267
2310
  this._focusedYear--;
2268
2311
  }
2269
2312
  });
2270
- __privateAdd(this, _handleFocusChange, async () => {
2313
+ __privateAdd(this, _handleCalendarFocusChange, async () => {
2271
2314
  this._focusedMonth = (await this._elCalendar).focusedMonth;
2272
2315
  this._focusedYear = (await this._elCalendar).focusedYear;
2316
+ this.value = (await this._elCalendar).focusedDate;
2273
2317
  this.requestUpdate();
2318
+ __privateMethod(this, _dispatchChangeEvent2, dispatchChangeEvent_fn2).call(this);
2274
2319
  });
2275
2320
  __privateAdd(this, _handlePopoverStateChange, (e) => {
2276
2321
  if (e.target !== e.currentTarget)
2277
2322
  return;
2278
2323
  this.open = e.detail.open;
2324
+ if (e.detail.reason === "cancel") {
2325
+ this.value = __privateGet(this, _valueOnOpen);
2326
+ __privateMethod(this, _dispatchChangeEvent2, dispatchChangeEvent_fn2).call(this);
2327
+ }
2279
2328
  });
2280
2329
  __privateAdd(this, _handleSpinnerKeydown, (e) => {
2281
2330
  const index = Array.from(this._elSpinners).findIndex(
@@ -2328,6 +2377,12 @@ var GdsDatepicker = class extends GdsFormControlElement {
2328
2377
  else
2329
2378
  return void 0;
2330
2379
  }
2380
+ /**
2381
+ * Get a string representation of the currently displayed value in the input field. The formatting will match the dateformat attribute.
2382
+ */
2383
+ get displayValue() {
2384
+ return this._elInput.innerText;
2385
+ }
2331
2386
  /**
2332
2387
  * A reference to a date cell element (<td>) inside the shadow root of the calendar primitive.
2333
2388
  * Inteded for use in integration tests.
@@ -2345,7 +2400,13 @@ var GdsDatepicker = class extends GdsFormControlElement {
2345
2400
 
2346
2401
  <div class="form-info"><slot name="sub-label"></slot></div>
2347
2402
 
2348
- <div class="field" id="trigger" @click=${__privateGet(this, _handleFieldClick)}>
2403
+ <div
2404
+ class="field"
2405
+ id="trigger"
2406
+ @click=${__privateGet(this, _handleFieldClick)}
2407
+ @copy=${__privateGet(this, _handleClipboardCopy)}
2408
+ @paste=${__privateGet(this, _handleClipboardPaste)}
2409
+ >
2349
2410
  <div class="input">
2350
2411
  ${join(
2351
2412
  map(
@@ -2443,7 +2504,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
2443
2504
  <gds-calendar
2444
2505
  id="calendar"
2445
2506
  @change=${__privateGet(this, _handleCalendarChange)}
2446
- @gds-date-focused=${__privateGet(this, _handleFocusChange)}
2507
+ @gds-date-focused=${__privateGet(this, _handleCalendarFocusChange)}
2447
2508
  .focusedMonth=${this._focusedMonth}
2448
2509
  .focusedYear=${this._focusedYear}
2449
2510
  .value=${this.value}
@@ -2462,7 +2523,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
2462
2523
  >
2463
2524
  ${msg5("Clear")}
2464
2525
  </button>
2465
- ${until(__privateMethod(this, _renderBackToValidRangeButton, renderBackToValidRangeButton_fn).call(this), nothing)}
2526
+ ${until(__privateMethod(this, _renderBackToValidRangeButton, renderBackToValidRangeButton_fn).call(this), nothing2)}
2466
2527
  <button
2467
2528
  class="tertiary today"
2468
2529
  @click=${() => {
@@ -2493,10 +2554,13 @@ var GdsDatepicker = class extends GdsFormControlElement {
2493
2554
  __privateSet(this, _spinnerState, { year, month, day });
2494
2555
  }
2495
2556
  _handleOpenChange() {
2496
- if (this.open)
2557
+ if (this.open) {
2558
+ __privateSet(this, _valueOnOpen, this.value);
2497
2559
  this._elCalendar.then((el) => el.focus());
2560
+ }
2498
2561
  }
2499
2562
  };
2563
+ _valueOnOpen = new WeakMap();
2500
2564
  _renderBackToValidRangeButton = new WeakSet();
2501
2565
  renderBackToValidRangeButton_fn = async function() {
2502
2566
  const focusedDate = await this.getFocusedDate();
@@ -2514,13 +2578,13 @@ renderBackToValidRangeButton_fn = async function() {
2514
2578
  () => html`<button class="tertiary back-to-range" @click=${buttonAction}>
2515
2579
  ${buttonTxt}
2516
2580
  </button>`,
2517
- () => nothing
2581
+ () => nothing2
2518
2582
  )}`;
2519
2583
  };
2520
2584
  _focusDate = new WeakSet();
2521
2585
  focusDate_fn = function(d) {
2522
2586
  const firstValidDate = new Date(d);
2523
- this._elCalendar.then((el) => el.focusedDate = firstValidDate).then(__privateGet(this, _handleFocusChange));
2587
+ this._elCalendar.then((el) => el.focusedDate = firstValidDate).then(__privateGet(this, _handleCalendarFocusChange));
2524
2588
  };
2525
2589
  _getSpinnerLabel = new WeakSet();
2526
2590
  getSpinnerLabel_fn = function(name) {
@@ -2557,13 +2621,15 @@ dispatchChangeEvent_fn2 = function() {
2557
2621
  })
2558
2622
  );
2559
2623
  };
2624
+ _handleClipboardCopy = new WeakMap();
2625
+ _handleClipboardPaste = new WeakMap();
2560
2626
  _handleFieldClick = new WeakMap();
2561
2627
  _handleCalendarChange = new WeakMap();
2562
2628
  _handleMonthChange = new WeakMap();
2563
2629
  _handleYearChange = new WeakMap();
2564
2630
  _handleIncrementFocusedMonth = new WeakMap();
2565
2631
  _handleDecrementFocusedMonth = new WeakMap();
2566
- _handleFocusChange = new WeakMap();
2632
+ _handleCalendarFocusChange = new WeakMap();
2567
2633
  _handlePopoverStateChange = new WeakMap();
2568
2634
  _handleSpinnerKeydown = new WeakMap();
2569
2635
  _parseDateFormat = new WeakSet();
@@ -2652,6 +2718,9 @@ __decorateClass([
2652
2718
  __decorateClass([
2653
2719
  queryAll(getScopedTagName("gds-date-part-spinner"))
2654
2720
  ], GdsDatepicker.prototype, "_elSpinners", 2);
2721
+ __decorateClass([
2722
+ query3(".input")
2723
+ ], GdsDatepicker.prototype, "_elInput", 2);
2655
2724
  __decorateClass([
2656
2725
  state10()
2657
2726
  ], GdsDatepicker.prototype, "_tStyles", 2);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sebgroup/green-core",
3
3
  "description": "A carefully crafted set of Web Components, laying the foundation of the Green Design System.",
4
- "version": "1.4.5",
4
+ "version": "1.5.0",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
7
7
  "type": "module",
@@ -18,7 +18,8 @@
18
18
  },
19
19
  "publishConfig": {
20
20
  "registry": "https://registry.npmjs.org/",
21
- "access": "public"
21
+ "access": "public",
22
+ "directory": "../../dist/libs/core/src"
22
23
  },
23
24
  "dependencies": {
24
25
  "@floating-ui/dom": "^1.5.4",
@@ -102,6 +102,9 @@ var option_trans_styles_default = `/**
102
102
  }
103
103
  :host(:hover),
104
104
  :host(:focus-visible) {
105
+ background-color: var(--gds-ref-pallet-base200);
106
+ }
107
+ :host(:active) {
105
108
  background-color: var(--gds-ref-pallet-base300);
106
109
  }
107
110
  :host(:focus) {
@@ -1301,6 +1304,7 @@ button.icon,
1301
1304
  height: 2.75rem;
1302
1305
  width: 2.75rem;
1303
1306
  min-width: auto;
1307
+ --color: var(--gds-ref-pallet-base800);
1304
1308
  }
1305
1309
  .form-group button.icon,
1306
1310
  .form-group .button.icon {
@@ -1336,27 +1340,17 @@ button.icon text,
1336
1340
  stroke: var(--gds-ref-pallet-base800);
1337
1341
  transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
1338
1342
  }
1339
- button.icon:hover,
1340
- .button.icon:hover {
1341
- background-color: var(--gds-ref-pallet-base800);
1342
- border-color: var(--gds-ref-pallet-base800);
1343
- }
1344
- button.icon:hover path,
1345
- button.icon:hover line,
1346
- button.icon:hover circle,
1347
- button.icon:hover rect,
1348
- button.icon:hover ellipse,
1349
- button.icon:hover polyline,
1350
- button.icon:hover text,
1351
- .button.icon:hover path,
1352
- .button.icon:hover line,
1353
- .button.icon:hover circle,
1354
- .button.icon:hover rect,
1355
- .button.icon:hover ellipse,
1356
- .button.icon:hover polyline,
1357
- .button.icon:hover text {
1358
- fill: var(--gds-ref-pallet-base000);
1359
- stroke: var(--gds-ref-pallet-base000);
1343
+ button.icon:hover, button.icon.highlighted,
1344
+ .button.icon:hover,
1345
+ .button.icon.highlighted {
1346
+ background-color: rgba(0, 0, 0, 0.1);
1347
+ border-color: transparent;
1348
+ }
1349
+ button.icon:active, button.icon.highlighted:hover,
1350
+ .button.icon:active,
1351
+ .button.icon.highlighted:hover {
1352
+ background-color: rgba(0, 0, 0, 0.2);
1353
+ border-color: transparent;
1360
1354
  }
1361
1355
 
1362
1356
  button.primary.danger,
@@ -2708,10 +2702,13 @@ i.sg-icon.sg-icon-ellipsis::before {
2708
2702
  align-items: center;
2709
2703
  display: inline-flex;
2710
2704
  justify-content: center;
2711
- transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1), outline-offset 0s, outline-width 0s;
2712
- border-color: rgb(51, 51, 51);
2713
- color: rgb(51, 51, 51);
2714
- --color: rgb(51, 51, 51);
2705
+ background-color: transparent;
2706
+ border: 0.0625rem solid transparent;
2707
+ padding: 0.625rem;
2708
+ height: 2.75rem;
2709
+ width: 2.75rem;
2710
+ min-width: auto;
2711
+ --color: var(--gds-ref-pallet-base800);
2715
2712
  }
2716
2713
  button:focus:not(:focus-visible) {
2717
2714
  box-shadow: none;
@@ -2744,47 +2741,48 @@ i.sg-icon.sg-icon-ellipsis::before {
2744
2741
  font-size: 1.5rem;
2745
2742
  line-height: 2rem;
2746
2743
  }
2747
- button:not(:disabled, .disabled, [aria-disabled]):hover {
2748
- background-color: rgb(51, 51, 51);
2749
- color: rgb(255, 255, 255);
2750
- --background: rgb(51, 51, 51);
2751
- --color: rgb(255, 255, 255);
2752
- border-color: rgb(51, 51, 51);
2753
- }
2754
- button[aria-selected], button:active, button.active, button.active:hover, button:active:hover {
2755
- background-color: rgb(51, 51, 51);
2756
- color: rgb(255, 255, 255);
2757
- --background: rgb(51, 51, 51);
2758
- --color: rgb(255, 255, 255);
2759
- border-color: rgb(51, 51, 51);
2744
+ .form-group button {
2745
+ margin-top: -0.625rem;
2760
2746
  }
2761
- button[aria-selected]:hover, button.active:hover, button:active:hover {
2762
- opacity: 0.9;
2747
+ button.small {
2748
+ height: 2rem;
2749
+ width: 2rem;
2750
+ padding: 0.4375rem;
2751
+ line-height: 1.125rem;
2763
2752
  }
2764
- button:focus-visible {
2765
- background-color: rgb(51, 51, 51);
2766
- color: rgb(255, 255, 255);
2767
- --background: rgb(51, 51, 51);
2768
- --color: rgb(255, 255, 255);
2769
- border-color: rgb(51, 51, 51) !important;
2753
+ button svg {
2754
+ height: 1rem;
2755
+ width: 1rem;
2770
2756
  }
2771
- button:disabled, button.disabled, button[aria-disabled=true] {
2772
- color: var(--text-disabled-color) !important;
2773
- border-color: var(--border-disabled-color) !important;
2774
- cursor: not-allowed;
2757
+ button path,
2758
+ button line,
2759
+ button circle,
2760
+ button rect,
2761
+ button ellipse,
2762
+ button polyline,
2763
+ button text {
2764
+ fill: var(--gds-ref-pallet-base800);
2765
+ stroke: var(--gds-ref-pallet-base800);
2766
+ transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
2775
2767
  }
2776
- button:disabled::-moz-placeholder, button.disabled::-moz-placeholder, button[aria-disabled=true]::-moz-placeholder {
2777
- color: var(--text-disabled-color);
2768
+ button:hover, button.highlighted {
2769
+ background-color: rgba(0, 0, 0, 0.1);
2770
+ border-color: transparent;
2778
2771
  }
2779
- button:disabled::placeholder, button.disabled::placeholder, button[aria-disabled=true]::placeholder {
2780
- color: var(--text-disabled-color);
2772
+ button:active, button.highlighted:hover {
2773
+ background-color: rgba(0, 0, 0, 0.2);
2774
+ border-color: transparent;
2781
2775
  }
2782
2776
  }
2783
2777
  @layer _overrides {
2784
2778
  button {
2785
2779
  border-color: transparent;
2780
+ color: var(--gds-ref-pallet-base800);
2781
+ display: flex;
2782
+ gap: 0.5rem;
2786
2783
  line-height: 0.75;
2787
2784
  padding-inline: 0.4375rem;
2785
+ width: auto;
2788
2786
  }
2789
2787
  button.highlighted {
2790
2788
  background-color: var(--gds-ref-pallet-base300);
@@ -2871,14 +2869,14 @@ var calendar_trans_styles_default = `/* stylelint-disable max-nesting-depth */
2871
2869
  :host table tbody tr td.today {
2872
2870
  background: transparent;
2873
2871
  border-radius: 4px;
2874
- color: hsl(var(--sg-hsl-blue-2));
2875
- text-decoration: underline;
2872
+ color: var(--gds-ref-pallet-base800);
2873
+ box-shadow: inset 0 0 0 2px var(--gds-ref-pallet-base800);
2876
2874
  }
2877
2875
  :host table tbody tr td:hover:not(.disabled) {
2878
- background: hsl(var(--sg-hsl-blue-0));
2876
+ background: var(--gds-ref-pallet-base300);
2879
2877
  border: solid 1px var(--sg-bg-level-2);
2880
2878
  border-radius: 4px;
2881
- color: hsl(var(--sg-hsl-white));
2879
+ color: var(--gds-sys-color-font);
2882
2880
  cursor: pointer;
2883
2881
  }
2884
2882
  :host table tbody tr td:focus-visible:not(.disabled) {
@@ -2899,17 +2897,16 @@ var calendar_trans_styles_default = `/* stylelint-disable max-nesting-depth */
2899
2897
  outline-offset: 0.125rem;
2900
2898
  }
2901
2899
  :host table tbody tr td[aria-selected=true] {
2902
- background: hsl(var(--sg-hsl-blue-2));
2900
+ background: var(--gds-ref-pallet-base800);
2903
2901
  border: solid 1px var(--sg-bg-level-2);
2904
2902
  border-radius: 4px;
2905
2903
  color: hsl(var(--sg-hsl-white));
2906
2904
  }
2907
2905
  :host table tbody tr td[tabindex="0"] {
2908
2906
  border-radius: 4px;
2909
- box-shadow: inset 0 0 0 2px hsl(var(--sg-hsl-blue-2));
2910
2907
  }
2911
2908
  :host table tbody tr td:hover:active:not(.disabled) {
2912
- background: hsl(var(--sg-hsl-blue-2));
2909
+ background: var(--gds-ref-pallet-base800);
2913
2910
  border: solid 1px var(--sg-bg-level-2);
2914
2911
  border-radius: 4px;
2915
2912
  color: hsl(var(--sg-hsl-white));
@@ -3085,6 +3082,12 @@ i.sg-icon.sg-icon-ellipsis::before {
3085
3082
  background: color-mix(in srgb, var(--gds-sys-color-blue) 50%, transparent);
3086
3083
  outline: none;
3087
3084
  }
3085
+ .field [role=spinbutton]::-moz-selection {
3086
+ background: transparent;
3087
+ }
3088
+ .field [role=spinbutton]::selection {
3089
+ background: transparent;
3090
+ }
3088
3091
  .field button {
3089
3092
  -webkit-appearance: none;
3090
3093
  -moz-appearance: none;
@@ -3212,7 +3215,7 @@ function register6() {
3212
3215
  // libs/core/src/utils/helpers/custom-element-scoping.ts
3213
3216
  import { html as litHtml } from "lit";
3214
3217
  import { customElement } from "lit/decorators.js";
3215
- var VER_SUFFIX = "-6cf221";
3218
+ var VER_SUFFIX = "-eaa4d5";
3216
3219
  var elementLookupTable = /* @__PURE__ */ new Map();
3217
3220
  var templateCache = /* @__PURE__ */ new WeakMap();
3218
3221
  function applyElementScoping(strings, ...values) {
@@ -3,5 +3,5 @@ declare type Handler = () => void;
3
3
  /**
4
4
  * Runs when the light DOM children of the component changes.
5
5
  */
6
- export declare function observeLightDOM(): <ElemClass extends LitElement>(proto: ElemClass, _propertyKey: string, descriptor: TypedPropertyDescriptor<Handler>) => void;
6
+ export declare function observeLightDOM(observerConfig?: MutationObserverInit): <ElemClass extends LitElement>(proto: ElemClass, _propertyKey: string, descriptor: TypedPropertyDescriptor<Handler>) => void;
7
7
  export {};