@sebgroup/green-core 1.4.6 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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;
package/index.js CHANGED
@@ -143,7 +143,7 @@ function watchMediaQuery(q) {
143
143
  // libs/core/src/utils/helpers/custom-element-scoping.ts
144
144
  import { html as litHtml } from "lit";
145
145
  import { customElement } from "lit/decorators.js";
146
- var VER_SUFFIX = "-a568b5";
146
+ var VER_SUFFIX = "-ea801b";
147
147
  var elementLookupTable = /* @__PURE__ */ new Map();
148
148
  var gdsCustomElement = (tagName) => {
149
149
  if (globalThis.GDS_DISABLE_VERSIONED_ELEMENTS) {
@@ -674,163 +674,6 @@ import {
674
674
  flip
675
675
  } from "@floating-ui/dom";
676
676
 
677
- // libs/core/src/primitives/popover/topLayerOverTransforms.middleware.ts
678
- var topLayerOverTransforms = () => ({
679
- name: "topLayer",
680
- async fn(middlewareArguments) {
681
- const {
682
- x,
683
- y,
684
- elements: { reference, floating }
685
- } = middlewareArguments;
686
- let onTopLayer = false;
687
- let topLayerIsFloating = false;
688
- const diffCoords = {
689
- x: 0,
690
- y: 0
691
- };
692
- try {
693
- onTopLayer = onTopLayer || floating.matches(":open");
694
- } catch (e) {
695
- }
696
- try {
697
- onTopLayer = onTopLayer || floating.matches(":modal");
698
- } catch (e) {
699
- }
700
- topLayerIsFloating = onTopLayer;
701
- if (!onTopLayer) {
702
- const dialogAncestorQueryEvent = new Event("floating-ui-dialog-test", {
703
- composed: true,
704
- bubbles: true
705
- });
706
- floating.addEventListener(
707
- "floating-ui-dialog-test",
708
- (event) => {
709
- event.composedPath().forEach((el) => {
710
- if (el === floating || el.localName !== "dialog")
711
- return;
712
- try {
713
- onTopLayer = onTopLayer || el.matches(":modal");
714
- if (onTopLayer) {
715
- }
716
- } catch (e) {
717
- }
718
- });
719
- },
720
- { once: true }
721
- );
722
- floating.dispatchEvent(dialogAncestorQueryEvent);
723
- }
724
- let overTransforms = false;
725
- const containingBlock = getContainingBlock(reference);
726
- if (containingBlock !== null && !isWindow(containingBlock)) {
727
- overTransforms = true;
728
- }
729
- if (onTopLayer && overTransforms) {
730
- const rect = containingBlock.getBoundingClientRect();
731
- diffCoords.x = rect.x;
732
- diffCoords.y = rect.y;
733
- }
734
- if (onTopLayer && topLayerIsFloating) {
735
- return {
736
- x: x + diffCoords.x,
737
- y: y + diffCoords.y,
738
- data: diffCoords
739
- };
740
- }
741
- if (onTopLayer) {
742
- return {
743
- x,
744
- y,
745
- data: diffCoords
746
- };
747
- }
748
- return {
749
- x: x - diffCoords.x,
750
- y: y - diffCoords.y,
751
- data: diffCoords
752
- };
753
- }
754
- });
755
- function getContainingBlock(element) {
756
- let currentNode = getParentNode(element);
757
- if (isShadowRoot(currentNode)) {
758
- currentNode = currentNode.host;
759
- }
760
- while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
761
- if (isContainingBlock(currentNode)) {
762
- return currentNode;
763
- } else {
764
- const parent = currentNode.assignedSlot ? currentNode.assignedSlot : currentNode.parentNode;
765
- currentNode = isShadowRoot(parent) ? parent.host : parent;
766
- }
767
- }
768
- return null;
769
- }
770
- function isLastTraversableNode(node) {
771
- return ["html", "body", "#document"].includes(getNodeName(node));
772
- }
773
- function isContainingBlock(element) {
774
- const isFirefox = /firefox/i.test(getUAString());
775
- if (element.tagName === "dialog") {
776
- return true;
777
- }
778
- const css7 = getComputedStyle(element);
779
- return css7.transform !== "none" || css7.perspective !== "none" || css7.contain === "paint" || ["transform", "perspective"].includes(css7.willChange) || isFirefox && css7.willChange === "filter" || isFirefox && (css7.filter ? css7.filter !== "none" : false);
780
- }
781
- function getUAString() {
782
- const uaData = navigator.userAgentData;
783
- if (uaData?.brands) {
784
- return uaData.brands.map((item) => `${item.brand}/${item.version}`).join(" ");
785
- }
786
- return navigator.userAgent;
787
- }
788
- function getParentNode(node) {
789
- if (getNodeName(node) === "html") {
790
- return node;
791
- }
792
- return (
793
- // this is a quicker (but less type safe) way to save quite some bytes from the bundle
794
- node.assignedSlot || // step into the shadow DOM of the parent of a slotted node
795
- node.parentNode || // DOM Element detected
796
- (isShadowRoot(node) ? node.host : null) || // ShadowRoot detected
797
- getDocumentElement(node)
798
- );
799
- }
800
- function getNodeName(node) {
801
- return isWindow(node) ? "" : node ? (node.nodeName || "").toLowerCase() : "";
802
- }
803
- function getDocumentElement(node) {
804
- return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
805
- }
806
- function isNode(value) {
807
- return value instanceof getWindow(value).Node;
808
- }
809
- function isWindow(value) {
810
- return value && value.document && value.location && value.alert && value.setInterval;
811
- }
812
- function getWindow(node) {
813
- if (node == null) {
814
- return window;
815
- }
816
- if (!isWindow(node)) {
817
- const ownerDocument = node.ownerDocument;
818
- return ownerDocument ? ownerDocument.defaultView || window : window;
819
- }
820
- return node;
821
- }
822
- function isShadowRoot(node) {
823
- if (typeof ShadowRoot === "undefined") {
824
- return false;
825
- }
826
- const OwnElement = getWindow(node).ShadowRoot;
827
- const testNode = node;
828
- return node instanceof OwnElement || testNode instanceof ShadowRoot;
829
- }
830
- function isHTMLElement(value) {
831
- return value instanceof getWindow(value).HTMLElement;
832
- }
833
-
834
677
  // libs/core/src/primitives/popover/popover.styles.ts
835
678
  import { css as css3 } from "lit";
836
679
  var style3 = css3`
@@ -877,10 +720,10 @@ var GdsPopover = class extends GdsElement {
877
720
  // A function that removes the Floating UI auto positioning. This gets called when we switch to mobile view layout.
878
721
  __privateAdd(this, _autoPositionCleanupFn, void 0);
879
722
  __privateAdd(this, _isMobileViewport, false);
880
- __privateAdd(this, _dispatchUiStateEvent, () => {
723
+ __privateAdd(this, _dispatchUiStateEvent, (reason) => {
881
724
  this.dispatchEvent(
882
725
  new CustomEvent("gds-ui-state", {
883
- detail: { open: this.open },
726
+ detail: { open: this.open, reason },
884
727
  bubbles: false,
885
728
  composed: false
886
729
  })
@@ -890,7 +733,7 @@ var GdsPopover = class extends GdsElement {
890
733
  e.stopPropagation();
891
734
  e.preventDefault();
892
735
  this.open = false;
893
- __privateGet(this, _dispatchUiStateEvent).call(this);
736
+ __privateGet(this, _dispatchUiStateEvent).call(this, "close");
894
737
  setTimeout(() => this._trigger?.focus(), 250);
895
738
  });
896
739
  /**
@@ -900,11 +743,11 @@ var GdsPopover = class extends GdsElement {
900
743
  if (e.key === "ArrowDown") {
901
744
  e.preventDefault();
902
745
  this.open = true;
903
- __privateGet(this, _dispatchUiStateEvent).call(this);
746
+ __privateGet(this, _dispatchUiStateEvent).call(this, "show");
904
747
  }
905
748
  if (e.key === "Escape") {
906
749
  this.open = false;
907
- __privateGet(this, _dispatchUiStateEvent).call(this);
750
+ __privateGet(this, _dispatchUiStateEvent).call(this, "cancel");
908
751
  }
909
752
  });
910
753
  /**
@@ -926,7 +769,7 @@ var GdsPopover = class extends GdsElement {
926
769
  if (!isInDialog) {
927
770
  e.stopPropagation();
928
771
  this.open = false;
929
- __privateGet(this, _dispatchUiStateEvent).call(this);
772
+ __privateGet(this, _dispatchUiStateEvent).call(this, "close");
930
773
  }
931
774
  }
932
775
  });
@@ -949,7 +792,7 @@ var GdsPopover = class extends GdsElement {
949
792
  this.addEventListener("keydown", (e) => {
950
793
  if (e.key === "Escape") {
951
794
  this.open = false;
952
- __privateGet(this, _dispatchUiStateEvent).call(this);
795
+ __privateGet(this, _dispatchUiStateEvent).call(this, "cancel");
953
796
  e.stopPropagation();
954
797
  e.preventDefault();
955
798
  }
@@ -1058,7 +901,7 @@ registerAutoPositioning_fn = function() {
1058
901
  __privateSet(this, _autoPositionCleanupFn, autoUpdate(referenceEl, floatingEl, () => {
1059
902
  computePosition(referenceEl, floatingEl, {
1060
903
  placement: this.placement,
1061
- middleware: [offset(8), flip(), topLayerOverTransforms()],
904
+ middleware: [offset(8), flip()],
1062
905
  strategy: "fixed"
1063
906
  }).then(
1064
907
  ({ x, y }) => Object.assign(floatingEl.style, {
@@ -1592,6 +1435,7 @@ GdsDropdown = __decorateClass([
1592
1435
  ], GdsDropdown);
1593
1436
 
1594
1437
  // libs/core/src/components/context-menu/context-menu.ts
1438
+ import { nothing } from "lit";
1595
1439
  import { msg as msg3 } from "@lit/localize";
1596
1440
  import { classMap as classMap3 } from "lit-html/directives/class-map.js";
1597
1441
  import { property as property6, queryAsync as queryAsync2, state as state6 } from "lit/decorators.js";
@@ -1643,6 +1487,7 @@ var GdsContextMenu = class extends GdsElement {
1643
1487
  __privateAdd(this, _handleItemClick);
1644
1488
  this.open = false;
1645
1489
  this.buttonLabel = msg3("Open context menu");
1490
+ this.showLabel = false;
1646
1491
  this.label = "";
1647
1492
  this.placement = "bottom-start";
1648
1493
  constrainSlots(this);
@@ -1662,14 +1507,15 @@ var GdsContextMenu = class extends GdsElement {
1662
1507
  return html`${this._tStyles}
1663
1508
  <button
1664
1509
  id="trigger"
1665
- class="ghost border-0 small ${classMap3({ highlighted: this.open })}"
1666
- aria-label="${this.buttonLabel}"
1510
+ class="icon border-0 small ${classMap3({ highlighted: this.open })}"
1511
+ aria-label=${this.buttonLabel ?? this.label}
1667
1512
  aria-haspopup="menu"
1668
1513
  aria-controls="menu"
1669
1514
  aria-expanded=${this.open}
1670
1515
  @click=${() => this.open = !this.open}
1671
1516
  >
1672
1517
  <slot name="trigger">
1518
+ ${this.showLabel ? this.buttonLabel ?? this.label : nothing}
1673
1519
  <i class="sg-icon sg-icon-ellipsis"></i>
1674
1520
  </slot>
1675
1521
  </button>
@@ -1682,7 +1528,7 @@ var GdsContextMenu = class extends GdsElement {
1682
1528
  @gds-ui-state=${(e) => this.open = e.detail.open}
1683
1529
  >
1684
1530
  <gds-menu
1685
- aria-label=${this.label}
1531
+ aria-label=${this.label ?? this.buttonLabel}
1686
1532
  @gds-menu-item-click=${__privateMethod(this, _handleItemClick, handleItemClick_fn)}
1687
1533
  >
1688
1534
  <slot allow="gds-menu-item"></slot>
@@ -1702,8 +1548,15 @@ __decorateClass([
1702
1548
  property6({ type: Boolean, reflect: true })
1703
1549
  ], GdsContextMenu.prototype, "open", 2);
1704
1550
  __decorateClass([
1705
- property6()
1551
+ property6({
1552
+ attribute: "button-label"
1553
+ })
1706
1554
  ], GdsContextMenu.prototype, "buttonLabel", 2);
1555
+ __decorateClass([
1556
+ property6({
1557
+ attribute: "show-label"
1558
+ })
1559
+ ], GdsContextMenu.prototype, "showLabel", 2);
1707
1560
  __decorateClass([
1708
1561
  property6()
1709
1562
  ], GdsContextMenu.prototype, "label", 2);
@@ -1759,13 +1612,13 @@ GdsMenuItem = __decorateClass([
1759
1612
  ], GdsMenuItem);
1760
1613
 
1761
1614
  // libs/core/src/components/datepicker/datepicker.ts
1762
- import { property as property9, queryAll, queryAsync as queryAsync3, state as state10 } from "lit/decorators.js";
1615
+ import { property as property9, query as query3, queryAll, queryAsync as queryAsync3, state as state10 } from "lit/decorators.js";
1763
1616
  import { join } from "lit/directives/join.js";
1764
1617
  import { when as when4 } from "lit/directives/when.js";
1765
1618
  import { until } from "lit/directives/until.js";
1766
1619
  import { map } from "lit/directives/map.js";
1767
1620
  import { repeat } from "lit/directives/repeat.js";
1768
- import { nothing } from "lit";
1621
+ import { nothing as nothing2 } from "lit";
1769
1622
  import { msg as msg5 } from "@lit/localize";
1770
1623
 
1771
1624
  // libs/core/src/primitives/calendar/calendar.ts
@@ -1922,6 +1775,8 @@ var GdsCalendar = class extends GdsElement {
1922
1775
  </table>`;
1923
1776
  }
1924
1777
  _valueChanged() {
1778
+ if (!this.value)
1779
+ return;
1925
1780
  this.focusedDate = this.value;
1926
1781
  }
1927
1782
  };
@@ -2028,10 +1883,10 @@ GdsCalendar = __decorateClass([
2028
1883
  ], GdsCalendar);
2029
1884
 
2030
1885
  // libs/core/src/components/datepicker/date-part-spinner.ts
2031
- import { LitElement as LitElement6 } from "lit";
1886
+ import { LitElement as LitElement7 } from "lit";
2032
1887
  import { property as property8, state as state9 } from "lit/decorators.js";
2033
1888
  var _inputBuffer, _increment, _decrement, _handleClick, _handleFocus, _handleBlur, _handleWheel, _handleKeyDown2, _focusNextSpinner, focusNextSpinner_fn, _dispatchChangeEvent, dispatchChangeEvent_fn, _formatNumber, formatNumber_fn, _clamp, clamp_fn, _clearInputBuffer, clearInputBuffer_fn;
2034
- var GdsDatePartSpinner = class extends LitElement6 {
1889
+ var GdsDatePartSpinner = class extends LitElement7 {
2035
1890
  constructor() {
2036
1891
  super(...arguments);
2037
1892
  __privateAdd(this, _focusNextSpinner);
@@ -2223,7 +2078,7 @@ var dateConverter = {
2223
2078
  return value.toISOString();
2224
2079
  }
2225
2080
  };
2226
- 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;
2081
+ var _valueOnOpen, _renderBackToValidRangeButton, renderBackToValidRangeButton_fn, _focusDate, focusDate_fn, _getSpinnerLabel, getSpinnerLabel_fn, _getMinSpinnerValue, getMinSpinnerValue_fn, _getMaxSpinnerValue, getMaxSpinnerValue_fn, _dispatchChangeEvent2, dispatchChangeEvent_fn2, _dispatchInputEvent, dispatchInputEvent_fn, _handleClipboardCopy, _handleClipboardPaste, _handleFieldClick, _handleCalendarChange, _handleMonthChange, _handleYearChange, _handleIncrementFocusedMonth, _handleDecrementFocusedMonth, _handleCalendarFocusChange, _handlePopoverStateChange, _handleSpinnerKeydown, _parseDateFormat, parseDateFormat_fn, _handleSpinnerChange, _spinnerState, _years, years_get, _isValueOutsideRange, isValueOutsideRange_get;
2227
2082
  var GdsDatepicker = class extends GdsFormControlElement {
2228
2083
  constructor() {
2229
2084
  super(...arguments);
@@ -2233,6 +2088,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
2233
2088
  __privateAdd(this, _getMinSpinnerValue);
2234
2089
  __privateAdd(this, _getMaxSpinnerValue);
2235
2090
  __privateAdd(this, _dispatchChangeEvent2);
2091
+ __privateAdd(this, _dispatchInputEvent);
2236
2092
  /**
2237
2093
  * Takes a dateformat string from the dateformat attribute and turnes it to a DateFormatLayout object used in rendering the template.
2238
2094
  */
@@ -2250,8 +2106,25 @@ var GdsDatepicker = class extends GdsFormControlElement {
2250
2106
  this._focusedMonth = (/* @__PURE__ */ new Date()).getMonth();
2251
2107
  this._focusedYear = (/* @__PURE__ */ new Date()).getFullYear();
2252
2108
  this._dateFormatLayout = __privateMethod(this, _parseDateFormat, parseDateFormat_fn).call(this, "y-m-d");
2109
+ __privateAdd(this, _valueOnOpen, void 0);
2110
+ __privateAdd(this, _handleClipboardCopy, (e) => {
2111
+ e.preventDefault();
2112
+ e.clipboardData?.setData("text/plain", this.displayValue);
2113
+ });
2114
+ __privateAdd(this, _handleClipboardPaste, (e) => {
2115
+ e.preventDefault();
2116
+ const pasted = e.clipboardData?.getData("text/plain");
2117
+ if (!pasted)
2118
+ return;
2119
+ const pastedDate = new Date(pasted);
2120
+ if (pastedDate.toString() === "Invalid Date")
2121
+ return;
2122
+ this.value = pastedDate;
2123
+ __privateMethod(this, _dispatchChangeEvent2, dispatchChangeEvent_fn2).call(this);
2124
+ });
2253
2125
  __privateAdd(this, _handleFieldClick, (e) => {
2254
2126
  this._elSpinners[0].focus();
2127
+ window.getSelection()?.selectAllChildren(this._elSpinners[0]);
2255
2128
  });
2256
2129
  __privateAdd(this, _handleCalendarChange, (e) => {
2257
2130
  e.stopPropagation();
@@ -2281,15 +2154,24 @@ var GdsDatepicker = class extends GdsFormControlElement {
2281
2154
  this._focusedYear--;
2282
2155
  }
2283
2156
  });
2284
- __privateAdd(this, _handleFocusChange, async () => {
2157
+ __privateAdd(this, _handleCalendarFocusChange, async () => {
2285
2158
  this._focusedMonth = (await this._elCalendar).focusedMonth;
2286
2159
  this._focusedYear = (await this._elCalendar).focusedYear;
2160
+ this.value = (await this._elCalendar).focusedDate;
2287
2161
  this.requestUpdate();
2162
+ __privateMethod(this, _dispatchInputEvent, dispatchInputEvent_fn).call(this);
2288
2163
  });
2289
- __privateAdd(this, _handlePopoverStateChange, (e) => {
2164
+ __privateAdd(this, _handlePopoverStateChange, async (e) => {
2290
2165
  if (e.target !== e.currentTarget)
2291
2166
  return;
2292
2167
  this.open = e.detail.open;
2168
+ if (e.detail.reason === "close") {
2169
+ this.value = (await this._elCalendar).focusedDate;
2170
+ __privateMethod(this, _dispatchChangeEvent2, dispatchChangeEvent_fn2).call(this);
2171
+ }
2172
+ if (e.detail.reason === "cancel") {
2173
+ this.value = __privateGet(this, _valueOnOpen);
2174
+ }
2293
2175
  });
2294
2176
  __privateAdd(this, _handleSpinnerKeydown, (e) => {
2295
2177
  const index = Array.from(this._elSpinners).findIndex(
@@ -2342,6 +2224,12 @@ var GdsDatepicker = class extends GdsFormControlElement {
2342
2224
  else
2343
2225
  return void 0;
2344
2226
  }
2227
+ /**
2228
+ * Get a string representation of the currently displayed value in the input field. The formatting will match the dateformat attribute.
2229
+ */
2230
+ get displayValue() {
2231
+ return this._elInput.innerText;
2232
+ }
2345
2233
  /**
2346
2234
  * A reference to a date cell element (<td>) inside the shadow root of the calendar primitive.
2347
2235
  * Inteded for use in integration tests.
@@ -2359,7 +2247,13 @@ var GdsDatepicker = class extends GdsFormControlElement {
2359
2247
 
2360
2248
  <div class="form-info"><slot name="sub-label"></slot></div>
2361
2249
 
2362
- <div class="field" id="trigger" @click=${__privateGet(this, _handleFieldClick)}>
2250
+ <div
2251
+ class="field"
2252
+ id="trigger"
2253
+ @click=${__privateGet(this, _handleFieldClick)}
2254
+ @copy=${__privateGet(this, _handleClipboardCopy)}
2255
+ @paste=${__privateGet(this, _handleClipboardPaste)}
2256
+ >
2363
2257
  <div class="input">
2364
2258
  ${join(
2365
2259
  map(
@@ -2457,7 +2351,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
2457
2351
  <gds-calendar
2458
2352
  id="calendar"
2459
2353
  @change=${__privateGet(this, _handleCalendarChange)}
2460
- @gds-date-focused=${__privateGet(this, _handleFocusChange)}
2354
+ @gds-date-focused=${__privateGet(this, _handleCalendarFocusChange)}
2461
2355
  .focusedMonth=${this._focusedMonth}
2462
2356
  .focusedYear=${this._focusedYear}
2463
2357
  .value=${this.value}
@@ -2476,7 +2370,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
2476
2370
  >
2477
2371
  ${msg5("Clear")}
2478
2372
  </button>
2479
- ${until(__privateMethod(this, _renderBackToValidRangeButton, renderBackToValidRangeButton_fn).call(this), nothing)}
2373
+ ${until(__privateMethod(this, _renderBackToValidRangeButton, renderBackToValidRangeButton_fn).call(this), nothing2)}
2480
2374
  <button
2481
2375
  class="tertiary today"
2482
2376
  @click=${() => {
@@ -2507,10 +2401,13 @@ var GdsDatepicker = class extends GdsFormControlElement {
2507
2401
  __privateSet(this, _spinnerState, { year, month, day });
2508
2402
  }
2509
2403
  _handleOpenChange() {
2510
- if (this.open)
2404
+ if (this.open) {
2405
+ __privateSet(this, _valueOnOpen, this.value);
2511
2406
  this._elCalendar.then((el) => el.focus());
2407
+ }
2512
2408
  }
2513
2409
  };
2410
+ _valueOnOpen = new WeakMap();
2514
2411
  _renderBackToValidRangeButton = new WeakSet();
2515
2412
  renderBackToValidRangeButton_fn = async function() {
2516
2413
  const focusedDate = await this.getFocusedDate();
@@ -2528,13 +2425,13 @@ renderBackToValidRangeButton_fn = async function() {
2528
2425
  () => html`<button class="tertiary back-to-range" @click=${buttonAction}>
2529
2426
  ${buttonTxt}
2530
2427
  </button>`,
2531
- () => nothing
2428
+ () => nothing2
2532
2429
  )}`;
2533
2430
  };
2534
2431
  _focusDate = new WeakSet();
2535
2432
  focusDate_fn = function(d) {
2536
2433
  const firstValidDate = new Date(d);
2537
- this._elCalendar.then((el) => el.focusedDate = firstValidDate).then(__privateGet(this, _handleFocusChange));
2434
+ this._elCalendar.then((el) => el.focusedDate = firstValidDate).then(__privateGet(this, _handleCalendarFocusChange));
2538
2435
  };
2539
2436
  _getSpinnerLabel = new WeakSet();
2540
2437
  getSpinnerLabel_fn = function(name) {
@@ -2571,13 +2468,23 @@ dispatchChangeEvent_fn2 = function() {
2571
2468
  })
2572
2469
  );
2573
2470
  };
2471
+ _dispatchInputEvent = new WeakSet();
2472
+ dispatchInputEvent_fn = function() {
2473
+ this.dispatchEvent(
2474
+ new CustomEvent("input", {
2475
+ detail: { value: this.value }
2476
+ })
2477
+ );
2478
+ };
2479
+ _handleClipboardCopy = new WeakMap();
2480
+ _handleClipboardPaste = new WeakMap();
2574
2481
  _handleFieldClick = new WeakMap();
2575
2482
  _handleCalendarChange = new WeakMap();
2576
2483
  _handleMonthChange = new WeakMap();
2577
2484
  _handleYearChange = new WeakMap();
2578
2485
  _handleIncrementFocusedMonth = new WeakMap();
2579
2486
  _handleDecrementFocusedMonth = new WeakMap();
2580
- _handleFocusChange = new WeakMap();
2487
+ _handleCalendarFocusChange = new WeakMap();
2581
2488
  _handlePopoverStateChange = new WeakMap();
2582
2489
  _handleSpinnerKeydown = new WeakMap();
2583
2490
  _parseDateFormat = new WeakSet();
@@ -2666,6 +2573,9 @@ __decorateClass([
2666
2573
  __decorateClass([
2667
2574
  queryAll(getScopedTagName("gds-date-part-spinner"))
2668
2575
  ], GdsDatepicker.prototype, "_elSpinners", 2);
2576
+ __decorateClass([
2577
+ query3(".input")
2578
+ ], GdsDatepicker.prototype, "_elInput", 2);
2669
2579
  __decorateClass([
2670
2580
  state10()
2671
2581
  ], 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.6",
4
+ "version": "1.5.1",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
7
7
  "type": "module",
@@ -22,11 +22,11 @@
22
22
  "directory": "../../dist/libs/core/src"
23
23
  },
24
24
  "dependencies": {
25
- "@floating-ui/dom": "^1.5.4",
25
+ "@floating-ui/dom": "^1.6.1",
26
26
  "@lit/localize": "0.11.4",
27
+ "date-fns": "^2.28.0",
27
28
  "lit": "^2.8.0",
28
- "reflect-metadata": "^0.1.13",
29
- "date-fns": "^2.28.0"
29
+ "reflect-metadata": "^0.1.13"
30
30
  },
31
31
  "exports": {
32
32
  ".": {
@@ -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 = "-a568b5";
3218
+ var VER_SUFFIX = "-ea801b";
3216
3219
  var elementLookupTable = /* @__PURE__ */ new Map();
3217
3220
  var templateCache = /* @__PURE__ */ new WeakMap();
3218
3221
  function applyElementScoping(strings, ...values) {
@@ -1,28 +0,0 @@
1
- /**
2
- * Temporary implemenation of topLayerOverTransforms middleware snagged from here: https://github.com/floating-ui/floating-ui/issues/1842
3
- *
4
- * This solved positioning issues when a popover is opened from a parent element that is using transforms.
5
- *
6
- * As soon as this is merged in FloatingUI we can remove this and use the official version.
7
- */
8
- export declare const topLayerOverTransforms: () => {
9
- name: string;
10
- fn(middlewareArguments: any): Promise<{
11
- x: any;
12
- y: any;
13
- data: {
14
- x: number;
15
- y: number;
16
- };
17
- }>;
18
- };
19
- export declare function isLastTraversableNode(node: any): boolean;
20
- export declare function getUAString(): any;
21
- export declare function getParentNode(node: any): any;
22
- export declare function getNodeName(node: any): any;
23
- export declare function getDocumentElement(node: any): any;
24
- export declare function isNode(value: any): boolean;
25
- export declare function isWindow(value: any): any;
26
- export declare function getWindow(node: any): any;
27
- export declare function isShadowRoot(node: any): boolean;
28
- export declare function isHTMLElement(value: any): boolean;