@sebgroup/green-core 1.2.3 → 1.2.4

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
@@ -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 = "-b059fe";
142
+ var VER_SUFFIX = "-001f73";
143
143
  var elementLookupTable = /* @__PURE__ */ new Map();
144
144
  var gdsCustomElement = (tagName) => {
145
145
  if (globalThis.GDS_DISABLE_VERSIONED_ELEMENTS) {
@@ -585,6 +585,7 @@ GdsOption = __decorateClass([
585
585
  // libs/core/src/primitives/popover/popover.ts
586
586
  import { LitElement as LitElement3, html as html3, unsafeCSS } from "lit";
587
587
  import { property as property3, state } from "lit/decorators.js";
588
+ import { classMap as classMap2 } from "lit/directives/class-map.js";
588
589
  import { msg } from "@lit/localize";
589
590
  import { createRef as createRef2, ref as ref2 } from "lit/directives/ref.js";
590
591
  import {
@@ -763,7 +764,7 @@ var style3 = css3`
763
764
  var popover_styles_default = style3;
764
765
 
765
766
  // libs/core/src/primitives/popover/popover.ts
766
- var _dialogElementRef, _handleCloseButton, _registerTriggerEvents, registerTriggerEvents_fn, _unregisterTriggerEvents, unregisterTriggerEvents_fn, _autoPositionCleanup, _registerAutoPositioning, registerAutoPositioning_fn, _triggerKeyDownListener, _focusFirstSlottedChild, _clickOutsideListener;
767
+ var _dialogElementRef, _autoPositionCleanupFn, _isMobileViewport, _handleCloseButton, _registerTriggerEvents, registerTriggerEvents_fn, _unregisterTriggerEvents, unregisterTriggerEvents_fn, _registerAutoPositioning, registerAutoPositioning_fn, _triggerKeyDownListener, _focusFirstSlottedChild, _clickOutsideListener;
767
768
  var GdsPopover = class extends LitElement3 {
768
769
  constructor() {
769
770
  super(...arguments);
@@ -775,14 +776,18 @@ var GdsPopover = class extends LitElement3 {
775
776
  this.label = void 0;
776
777
  this.placement = "bottom-start";
777
778
  this._trigger = void 0;
779
+ this._isVirtKbVisible = false;
780
+ // A reference to the dialog element used to make the popover modal
778
781
  __privateAdd(this, _dialogElementRef, createRef2());
782
+ // A function that removes the Floating UI auto positioning. This gets called when we switch to mobile view layout.
783
+ __privateAdd(this, _autoPositionCleanupFn, void 0);
784
+ __privateAdd(this, _isMobileViewport, false);
779
785
  __privateAdd(this, _handleCloseButton, (e) => {
780
786
  e.stopPropagation();
781
787
  e.preventDefault();
782
788
  this.open = false;
783
789
  setTimeout(() => this._trigger?.focus(), 250);
784
790
  });
785
- __privateAdd(this, _autoPositionCleanup, void 0);
786
791
  /**
787
792
  * ArrowDown on the trigger element will trigger the popover by default, and escape will close it.
788
793
  */
@@ -836,13 +841,27 @@ var GdsPopover = class extends LitElement3 {
836
841
  e.stopImmediatePropagation();
837
842
  }
838
843
  });
844
+ this.addEventListener("focusin", (e) => {
845
+ const t = e.target;
846
+ if (t.tagName === "INPUT" || t.tagName === "TEXTAREA") {
847
+ this._isVirtKbVisible = true;
848
+ } else {
849
+ this._isVirtKbVisible = false;
850
+ }
851
+ });
852
+ this.addEventListener("blurin", (_) => {
853
+ this._isVirtKbVisible = false;
854
+ });
839
855
  }
840
856
  disconnectedCallback() {
841
857
  super.disconnectedCallback();
842
858
  __privateMethod(this, _unregisterTriggerEvents, unregisterTriggerEvents_fn).call(this);
843
859
  }
844
860
  render() {
845
- return html3`<dialog ${ref2(__privateGet(this, _dialogElementRef))}>
861
+ return html3`<dialog
862
+ class="${classMap2({ "v-kb-visible": this._isVirtKbVisible })}"
863
+ ${ref2(__privateGet(this, _dialogElementRef))}
864
+ >
846
865
  <header>
847
866
  <h2>${this.label}</h2>
848
867
  <button
@@ -888,10 +907,12 @@ var GdsPopover = class extends LitElement3 {
888
907
  }
889
908
  _handleMobileLayout(matches) {
890
909
  var _a;
910
+ __privateSet(this, _isMobileViewport, matches);
891
911
  if (matches) {
892
- (_a = __privateGet(this, _autoPositionCleanup)) == null ? void 0 : _a.call(this);
912
+ (_a = __privateGet(this, _autoPositionCleanupFn)) == null ? void 0 : _a.call(this);
893
913
  __privateGet(this, _dialogElementRef).value?.style.removeProperty("left");
894
914
  __privateGet(this, _dialogElementRef).value?.style.removeProperty("top");
915
+ __privateGet(this, _dialogElementRef).value?.style.removeProperty("minWidth");
895
916
  this.updateComplete.then(() => {
896
917
  if (this.open)
897
918
  __privateGet(this, _dialogElementRef).value?.showModal();
@@ -904,6 +925,8 @@ var GdsPopover = class extends LitElement3 {
904
925
  }
905
926
  };
906
927
  _dialogElementRef = new WeakMap();
928
+ _autoPositionCleanupFn = new WeakMap();
929
+ _isMobileViewport = new WeakMap();
907
930
  _handleCloseButton = new WeakMap();
908
931
  _registerTriggerEvents = new WeakSet();
909
932
  registerTriggerEvents_fn = function() {
@@ -913,16 +936,18 @@ _unregisterTriggerEvents = new WeakSet();
913
936
  unregisterTriggerEvents_fn = function() {
914
937
  var _a;
915
938
  this._trigger?.removeEventListener("keydown", __privateGet(this, _triggerKeyDownListener));
916
- (_a = __privateGet(this, _autoPositionCleanup)) == null ? void 0 : _a.call(this);
939
+ (_a = __privateGet(this, _autoPositionCleanupFn)) == null ? void 0 : _a.call(this);
917
940
  };
918
- _autoPositionCleanup = new WeakMap();
919
941
  _registerAutoPositioning = new WeakSet();
920
942
  registerAutoPositioning_fn = function() {
921
943
  const referenceEl = this._trigger;
922
944
  const floatingEl = __privateGet(this, _dialogElementRef).value;
923
- if (!referenceEl || !floatingEl)
945
+ if (!referenceEl || !floatingEl || __privateGet(this, _isMobileViewport))
924
946
  return;
925
- __privateSet(this, _autoPositionCleanup, autoUpdate(referenceEl, floatingEl, () => {
947
+ if (__privateGet(this, _autoPositionCleanupFn)) {
948
+ __privateGet(this, _autoPositionCleanupFn).call(this);
949
+ }
950
+ __privateSet(this, _autoPositionCleanupFn, autoUpdate(referenceEl, floatingEl, () => {
926
951
  computePosition(referenceEl, floatingEl, {
927
952
  placement: this.placement,
928
953
  middleware: [offset(8), flip(), topLayerOverTransforms()],
@@ -955,6 +980,9 @@ __decorateClass([
955
980
  __decorateClass([
956
981
  state()
957
982
  ], GdsPopover.prototype, "_trigger", 2);
983
+ __decorateClass([
984
+ state()
985
+ ], GdsPopover.prototype, "_isVirtKbVisible", 2);
958
986
  __decorateClass([
959
987
  watch("triggerRef")
960
988
  ], GdsPopover.prototype, "_handleTriggerRefChanged", 1);
@@ -1396,7 +1424,7 @@ GdsDropdown = __decorateClass([
1396
1424
  // libs/core/src/components/context-menu/context-menu.ts
1397
1425
  import { LitElement as LitElement6 } from "lit";
1398
1426
  import { msg as msg3 } from "@lit/localize";
1399
- import { classMap as classMap2 } from "lit-html/directives/class-map.js";
1427
+ import { classMap as classMap3 } from "lit-html/directives/class-map.js";
1400
1428
  import { property as property6, queryAsync as queryAsync2 } from "lit/decorators.js";
1401
1429
 
1402
1430
  // libs/core/src/primitives/menu/menu.ts
@@ -1462,7 +1490,7 @@ var GdsContextMenu = class extends LitElement6 {
1462
1490
  render() {
1463
1491
  return html`<button
1464
1492
  id="trigger"
1465
- class="ghost border-0 small ${classMap2({ highlighted: this.open })}"
1493
+ class="ghost border-0 small ${classMap3({ highlighted: this.open })}"
1466
1494
  aria-label="${this.buttonLabel}"
1467
1495
  aria-haspopup="menu"
1468
1496
  aria-controls="menu"
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.2.3",
4
+ "version": "1.2.4",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
7
7
  "type": "module",
@@ -34,6 +34,7 @@ export declare class GdsPopover extends LitElement {
34
34
  */
35
35
  placement: Placement;
36
36
  private _trigger;
37
+ private _isVirtKbVisible;
37
38
  private _handleTriggerRefChanged;
38
39
  private _handleTriggerChanged;
39
40
  connectedCallback(): void;
@@ -3808,13 +3808,16 @@ a.button.tertiary.danger:focus-visible {
3808
3808
  header {
3809
3809
  border-bottom: 1px solid var(--border-color);
3810
3810
  display: flex;
3811
- padding: 0.5rem 0.75rem;
3811
+ padding: 0.25rem 0.75rem;
3812
3812
  }
3813
3813
  @media (min-width: 36em) {
3814
3814
  header {
3815
3815
  display: none;
3816
3816
  }
3817
3817
  }
3818
+ header button.close {
3819
+ margin: -0.25rem;
3820
+ }
3818
3821
 
3819
3822
  header h2 {
3820
3823
  flex-grow: 1;
@@ -3885,7 +3888,13 @@ dialog .close {
3885
3888
  }
3886
3889
  @media (max-width: 35.98em) {
3887
3890
  dialog {
3888
- border-radius: 1rem;
3891
+ border-radius: 0.5rem;
3892
+ max-height: 80svh;
3893
+ }
3894
+ dialog.v-kb-visible {
3895
+ inset-block-end: auto;
3896
+ max-height: 50svh;
3897
+ top: 1rem;
3889
3898
  }
3890
3899
  }
3891
3900
  @media (min-width: 36em) {
@@ -6347,7 +6356,7 @@ function register4() {
6347
6356
  // libs/core/src/utils/helpers/custom-element-scoping.ts
6348
6357
  import { html as litHtml } from "lit";
6349
6358
  import { customElement } from "lit/decorators.js";
6350
- var VER_SUFFIX = "-b059fe";
6359
+ var VER_SUFFIX = "-001f73";
6351
6360
  var elementLookupTable = /* @__PURE__ */ new Map();
6352
6361
  var templateCache = /* @__PURE__ */ new WeakMap();
6353
6362
  function applyElementScoping(strings, ...values) {