@sebgroup/green-core 1.5.0 → 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.
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 = "-eaa4d5";
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`
@@ -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, {
@@ -2235,7 +2078,7 @@ var dateConverter = {
2235
2078
  return value.toISOString();
2236
2079
  }
2237
2080
  };
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;
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;
2239
2082
  var GdsDatepicker = class extends GdsFormControlElement {
2240
2083
  constructor() {
2241
2084
  super(...arguments);
@@ -2245,6 +2088,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
2245
2088
  __privateAdd(this, _getMinSpinnerValue);
2246
2089
  __privateAdd(this, _getMaxSpinnerValue);
2247
2090
  __privateAdd(this, _dispatchChangeEvent2);
2091
+ __privateAdd(this, _dispatchInputEvent);
2248
2092
  /**
2249
2093
  * Takes a dateformat string from the dateformat attribute and turnes it to a DateFormatLayout object used in rendering the template.
2250
2094
  */
@@ -2315,15 +2159,18 @@ var GdsDatepicker = class extends GdsFormControlElement {
2315
2159
  this._focusedYear = (await this._elCalendar).focusedYear;
2316
2160
  this.value = (await this._elCalendar).focusedDate;
2317
2161
  this.requestUpdate();
2318
- __privateMethod(this, _dispatchChangeEvent2, dispatchChangeEvent_fn2).call(this);
2162
+ __privateMethod(this, _dispatchInputEvent, dispatchInputEvent_fn).call(this);
2319
2163
  });
2320
- __privateAdd(this, _handlePopoverStateChange, (e) => {
2164
+ __privateAdd(this, _handlePopoverStateChange, async (e) => {
2321
2165
  if (e.target !== e.currentTarget)
2322
2166
  return;
2323
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
+ }
2324
2172
  if (e.detail.reason === "cancel") {
2325
2173
  this.value = __privateGet(this, _valueOnOpen);
2326
- __privateMethod(this, _dispatchChangeEvent2, dispatchChangeEvent_fn2).call(this);
2327
2174
  }
2328
2175
  });
2329
2176
  __privateAdd(this, _handleSpinnerKeydown, (e) => {
@@ -2621,6 +2468,14 @@ dispatchChangeEvent_fn2 = function() {
2621
2468
  })
2622
2469
  );
2623
2470
  };
2471
+ _dispatchInputEvent = new WeakSet();
2472
+ dispatchInputEvent_fn = function() {
2473
+ this.dispatchEvent(
2474
+ new CustomEvent("input", {
2475
+ detail: { value: this.value }
2476
+ })
2477
+ );
2478
+ };
2624
2479
  _handleClipboardCopy = new WeakMap();
2625
2480
  _handleClipboardPaste = new WeakMap();
2626
2481
  _handleFieldClick = new WeakMap();
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.5.0",
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
  ".": {
@@ -3215,7 +3215,7 @@ function register6() {
3215
3215
  // libs/core/src/utils/helpers/custom-element-scoping.ts
3216
3216
  import { html as litHtml } from "lit";
3217
3217
  import { customElement } from "lit/decorators.js";
3218
- var VER_SUFFIX = "-eaa4d5";
3218
+ var VER_SUFFIX = "-ea801b";
3219
3219
  var elementLookupTable = /* @__PURE__ */ new Map();
3220
3220
  var templateCache = /* @__PURE__ */ new WeakMap();
3221
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;