@sebgroup/green-core 1.2.4 → 1.3.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.
@@ -67,6 +67,15 @@ export declare class GdsDropdown<ValueT = any> extends GdsFormControlElement<Val
67
67
  * ```
68
68
  */
69
69
  searchFilter: (q: string, o: GdsOption) => boolean;
70
+ /**
71
+ * Whether the popover should sync its width to the trigger button. When this is
72
+ * set to `true`, the popover will always have the same width as the trigger button.
73
+ *
74
+ * By default, line-breaks will be applied to the option content if it is wider than
75
+ * the popover width. If you use this option, make sure to verify that your options
76
+ * are still readable and apply appropriate custom layout or truncation if neccecary.
77
+ */
78
+ syncPopoverWidth: boolean;
70
79
  private elTriggerBtn;
71
80
  private elTriggerBtnAsync;
72
81
  private elListbox;
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 = "-001f73";
142
+ var VER_SUFFIX = "-f38327";
143
143
  var elementLookupTable = /* @__PURE__ */ new Map();
144
144
  var gdsCustomElement = (tagName) => {
145
145
  if (globalThis.GDS_DISABLE_VERSIONED_ELEMENTS) {
@@ -530,7 +530,7 @@ var GdsOption = class extends Focusable(LitElement2) {
530
530
  }
531
531
  }
532
532
  render() {
533
- const isMultiple = this.parentElement.multiple;
533
+ const isMultiple = this.parentElement?.multiple;
534
534
  const checkbox = html2`<span
535
535
  class="checkbox ${classMap({ checked: this.selected })}"
536
536
  ></span>`;
@@ -755,10 +755,20 @@ function isHTMLElement(value) {
755
755
  // libs/core/src/primitives/popover/popover.styles.ts
756
756
  import { css as css3 } from "lit";
757
757
  var style3 = css3`
758
- :host {
759
- position: absolute;
760
- background-color: white;
761
- box-shadow: 0 1rem 1rem 1rem rgba(0, 0, 0, 0.1);
758
+ :host([open]) dialog {
759
+ opacity: 1;
760
+ transform: translate3d(0, 0, 0);
761
+ visibility: visible;
762
+ }
763
+
764
+ dialog {
765
+ inset: auto;
766
+ position: fixed;
767
+ overflow: hidden;
768
+ padding: 0px;
769
+ box-sizing: border-box;
770
+ border-width: 0;
771
+ right: 0;
762
772
  }
763
773
  `;
764
774
  var popover_styles_default = style3;
@@ -775,6 +785,7 @@ var GdsPopover = class extends LitElement3 {
775
785
  this.triggerRef = Promise.resolve(void 0);
776
786
  this.label = void 0;
777
787
  this.placement = "bottom-start";
788
+ this.calcMaxWidth = (_referenceEl) => `auto`;
778
789
  this._trigger = void 0;
779
790
  this._isVirtKbVisible = false;
780
791
  // A reference to the dialog element used to make the popover modal
@@ -956,7 +967,8 @@ registerAutoPositioning_fn = function() {
956
967
  ({ x, y }) => Object.assign(floatingEl.style, {
957
968
  left: `${x}px`,
958
969
  top: `${y}px`,
959
- minWidth: `${referenceEl.offsetWidth}px`
970
+ minWidth: `${referenceEl.offsetWidth}px`,
971
+ maxWidth: `${this.calcMaxWidth(referenceEl)}`
960
972
  })
961
973
  );
962
974
  }));
@@ -977,6 +989,9 @@ __decorateClass([
977
989
  __decorateClass([
978
990
  property3()
979
991
  ], GdsPopover.prototype, "placement", 2);
992
+ __decorateClass([
993
+ property3()
994
+ ], GdsPopover.prototype, "calcMaxWidth", 2);
980
995
  __decorateClass([
981
996
  state()
982
997
  ], GdsPopover.prototype, "_trigger", 2);
@@ -1106,6 +1121,7 @@ var style4 = css4`
1106
1121
  color: white;
1107
1122
  padding: 0.7rem 2rem;
1108
1123
  margin: 0.5rem 0;
1124
+ box-sizing: border-box;
1109
1125
  }
1110
1126
  `;
1111
1127
  var dropdown_styles_default = style4;
@@ -1129,6 +1145,7 @@ var GdsDropdown = class extends GdsFormControlElement {
1129
1145
  this.multiple = false;
1130
1146
  this.compareWith = (a, b) => a === b;
1131
1147
  this.searchFilter = (q, o) => o.innerHTML.toLowerCase().includes(q.toLowerCase());
1148
+ this.syncPopoverWidth = false;
1132
1149
  // Private members
1133
1150
  __privateAdd(this, _optionElements, void 0);
1134
1151
  /**
@@ -1265,6 +1282,7 @@ var GdsDropdown = class extends GdsFormControlElement {
1265
1282
  .label=${this.label}
1266
1283
  .open=${this.open}
1267
1284
  .triggerRef=${this.elTriggerBtnAsync}
1285
+ .calcMaxWidth=${(trigger) => this.syncPopoverWidth ? `${trigger.offsetWidth}px` : `auto`}
1268
1286
  @gds-ui-state=${(e) => this.open = e.detail.open}
1269
1287
  >
1270
1288
  ${when2(
@@ -1396,6 +1414,9 @@ __decorateClass([
1396
1414
  __decorateClass([
1397
1415
  property5()
1398
1416
  ], GdsDropdown.prototype, "searchFilter", 2);
1417
+ __decorateClass([
1418
+ property5({ type: Boolean })
1419
+ ], GdsDropdown.prototype, "syncPopoverWidth", 2);
1399
1420
  __decorateClass([
1400
1421
  query("#trigger")
1401
1422
  ], GdsDropdown.prototype, "elTriggerBtn", 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.2.4",
4
+ "version": "1.3.0",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
7
7
  "type": "module",
@@ -33,6 +33,11 @@ export declare class GdsPopover extends LitElement {
33
33
  * Accepts any of the placements supported by Floating UI.
34
34
  */
35
35
  placement: Placement;
36
+ /**
37
+ * A callback that returns the maximum width of the popover.
38
+ * By default, the popover maxWidth will be set to `auto` and will grow as needed.
39
+ */
40
+ calcMaxWidth: (_referenceEl: HTMLElement) => string;
36
41
  private _trigger;
37
42
  private _isVirtKbVisible;
38
43
  private _handleTriggerRefChanged;
@@ -3800,6 +3800,7 @@ a.button.tertiary.danger:focus-visible {
3800
3800
  }
3801
3801
 
3802
3802
  :host([open]) dialog {
3803
+ box-sizing: border-box;
3803
3804
  opacity: 1;
3804
3805
  transform: translate3d(0, 0, 0);
3805
3806
  visibility: visible;
@@ -6356,7 +6357,7 @@ function register4() {
6356
6357
  // libs/core/src/utils/helpers/custom-element-scoping.ts
6357
6358
  import { html as litHtml } from "lit";
6358
6359
  import { customElement } from "lit/decorators.js";
6359
- var VER_SUFFIX = "-001f73";
6360
+ var VER_SUFFIX = "-f38327";
6360
6361
  var elementLookupTable = /* @__PURE__ */ new Map();
6361
6362
  var templateCache = /* @__PURE__ */ new WeakMap();
6362
6363
  function applyElementScoping(strings, ...values) {