@sebgroup/green-core 1.8.0 → 1.9.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/README.md CHANGED
@@ -17,7 +17,7 @@ If you are new to Green, checkout [@sebgroup/green-core](https://github.com/sebg
17
17
  We also provide components for the following technologies:
18
18
 
19
19
  - [React](https://github.com/sebgroup/green/tree/main/libs/react)
20
- - [Angular](https://github.com/sebgroup/green/tree/main/libs/react)
20
+ - [Angular](https://github.com/sebgroup/green/tree/main/libs/angular)
21
21
 
22
22
  If you're trying to find something specific, here's a full list of packages that we support!
23
23
 
@@ -61,6 +61,14 @@ export declare class GdsDatepicker extends GdsFormControlElement<Date> {
61
61
  */
62
62
  get dateformat(): string;
63
63
  set dateformat(dateformat: string);
64
+ /**
65
+ * Whether to disable weekends in the calendar.
66
+ */
67
+ disabledWeekends: boolean;
68
+ /**
69
+ * An array of dates that should be disabled in the calendar.
70
+ */
71
+ disabledDates?: Date[];
64
72
  /**
65
73
  * Get the currently focused date in the calendar popover. If no date is focused, or the calendar popover
66
74
  * is closed, the value will be undefined.
@@ -76,6 +76,10 @@ export declare class GdsDropdown<ValueT = any> extends GdsFormControlElement<Val
76
76
  * are still readable and apply appropriate custom layout or truncation if neccecary.
77
77
  */
78
78
  syncPopoverWidth: boolean;
79
+ /**
80
+ * Maximum height of the dropdown list.
81
+ */
82
+ maxHeight: number;
79
83
  /**
80
84
  * Size of the dropdown. Supports `medium` and `small`. There is no `large` size for dropdowns.
81
85
  * `medium` is the default size.
package/index.js CHANGED
@@ -144,7 +144,7 @@ function watchMediaQuery(q) {
144
144
  // libs/core/src/utils/helpers/custom-element-scoping.ts
145
145
  import { html as litHtml } from "lit";
146
146
  import { customElement } from "lit/decorators.js";
147
- var VER_SUFFIX = "-3d880b";
147
+ var VER_SUFFIX = "-260c87";
148
148
  var elementLookupTable = /* @__PURE__ */ new Map();
149
149
  var gdsCustomElement = (tagName) => {
150
150
  if (globalThis.GDS_DISABLE_VERSIONED_ELEMENTS) {
@@ -715,6 +715,8 @@ var GdsPopover = class extends GdsElement {
715
715
  this.placement = "bottom-start";
716
716
  this.calcMinWidth = (referenceEl) => `${referenceEl.offsetWidth}px`;
717
717
  this.calcMaxWidth = (_referenceEl) => `auto`;
718
+ this.calcMinHeight = (referenceEl) => `auto`;
719
+ this.calcMaxHeight = (_referenceEl) => `500px`;
718
720
  this._trigger = void 0;
719
721
  this._isVirtKbVisible = false;
720
722
  // A reference to the dialog element used to make the popover modal
@@ -910,7 +912,9 @@ registerAutoPositioning_fn = function() {
910
912
  left: `${x}px`,
911
913
  top: `${y}px`,
912
914
  minWidth: this.calcMinWidth(referenceEl),
913
- maxWidth: this.calcMaxWidth(referenceEl)
915
+ maxWidth: this.calcMaxWidth(referenceEl),
916
+ minHeight: this.calcMinHeight(referenceEl),
917
+ maxHeight: this.calcMaxHeight(referenceEl)
914
918
  })
915
919
  );
916
920
  }));
@@ -937,6 +941,12 @@ __decorateClass([
937
941
  __decorateClass([
938
942
  property3()
939
943
  ], GdsPopover.prototype, "calcMaxWidth", 2);
944
+ __decorateClass([
945
+ property3()
946
+ ], GdsPopover.prototype, "calcMinHeight", 2);
947
+ __decorateClass([
948
+ property3()
949
+ ], GdsPopover.prototype, "calcMaxHeight", 2);
940
950
  __decorateClass([
941
951
  state3()
942
952
  ], GdsPopover.prototype, "_trigger", 2);
@@ -1127,6 +1137,7 @@ var GdsDropdown = class extends GdsFormControlElement {
1127
1137
  this.compareWith = (a, b) => a === b;
1128
1138
  this.searchFilter = (q, o) => o.innerHTML.toLowerCase().includes(q.toLowerCase());
1129
1139
  this.syncPopoverWidth = false;
1140
+ this.maxHeight = 500;
1130
1141
  this.size = "medium";
1131
1142
  this.hideLabel = false;
1132
1143
  __privateAdd(this, _optionElements, void 0);
@@ -1270,6 +1281,7 @@ var GdsDropdown = class extends GdsFormControlElement {
1270
1281
  .open=${this.open}
1271
1282
  .triggerRef=${this._elTriggerBtnAsync}
1272
1283
  .calcMaxWidth=${(trigger) => this.syncPopoverWidth ? `${trigger.offsetWidth}px` : `auto`}
1284
+ .calcMaxHeight=${(_trigger) => `${this.maxHeight}px`}
1273
1285
  @gds-ui-state=${(e) => this.open = e.detail.open}
1274
1286
  >
1275
1287
  ${when2(
@@ -1407,6 +1419,9 @@ __decorateClass([
1407
1419
  __decorateClass([
1408
1420
  property5({ type: Boolean, attribute: "sync-popover-width" })
1409
1421
  ], GdsDropdown.prototype, "syncPopoverWidth", 2);
1422
+ __decorateClass([
1423
+ property5({ type: Number, attribute: "max-height" })
1424
+ ], GdsDropdown.prototype, "maxHeight", 2);
1410
1425
  __decorateClass([
1411
1426
  property5()
1412
1427
  ], GdsDropdown.prototype, "size", 2);
@@ -1739,13 +1754,17 @@ var GdsCalendar = class extends GdsElement {
1739
1754
  this.min = new Date((/* @__PURE__ */ new Date()).getFullYear() - 10, 0, 1);
1740
1755
  this.max = new Date((/* @__PURE__ */ new Date()).getFullYear() + 10, 0, 1);
1741
1756
  this.focusedDate = /* @__PURE__ */ new Date();
1757
+ this.disabledWeekends = false;
1742
1758
  this.showWeekNumbers = false;
1743
1759
  }
1744
1760
  get focusedMonth() {
1745
1761
  return this.focusedDate.getMonth();
1746
1762
  }
1747
1763
  set focusedMonth(month) {
1748
- this.focusedDate = new Date(this.focusedDate.setMonth(month));
1764
+ const newDate = new Date(this.focusedDate);
1765
+ newDate.setMonth(month);
1766
+ newDate.setHours(0, 0, 0, 0);
1767
+ this.focusedDate = newDate;
1749
1768
  }
1750
1769
  get focusedYear() {
1751
1770
  return this.focusedDate.getFullYear();
@@ -1798,11 +1817,13 @@ var GdsCalendar = class extends GdsElement {
1798
1817
  </td>`
1799
1818
  )}
1800
1819
  ${week.days.map((day) => {
1801
- const isDisabled = !isSameMonth(this.focusedDate, day) || day < this.min || day > this.max;
1820
+ const isOutsideCurrentMonth = !isSameMonth(this.focusedDate, day) || day < this.min || day > this.max;
1821
+ const isWeekend = day.getDay() === 0 || day.getDay() === 6;
1822
+ const isDisabled = isOutsideCurrentMonth || this.disabledWeekends && isWeekend || this.disabledDates && this.disabledDates.some((d) => isSameDay(d, day));
1802
1823
  return html7`
1803
1824
  <td
1804
1825
  class="${classMap5({
1805
- disabled: isDisabled,
1826
+ disabled: Boolean(isDisabled),
1806
1827
  today: isSameDay(currentDate, day)
1807
1828
  })}"
1808
1829
  ?disabled=${isDisabled}
@@ -1910,6 +1931,12 @@ __decorateClass([
1910
1931
  __decorateClass([
1911
1932
  property7()
1912
1933
  ], GdsCalendar.prototype, "focusedDate", 2);
1934
+ __decorateClass([
1935
+ property7({ type: Boolean, attribute: "disabled-weekends" })
1936
+ ], GdsCalendar.prototype, "disabledWeekends", 2);
1937
+ __decorateClass([
1938
+ property7({ type: Array, attribute: "disabled-dates" })
1939
+ ], GdsCalendar.prototype, "disabledDates", 2);
1913
1940
  __decorateClass([
1914
1941
  property7({ type: Number })
1915
1942
  ], GdsCalendar.prototype, "focusedMonth", 1);
@@ -2127,6 +2154,14 @@ var dateConverter = {
2127
2154
  return value.toISOString();
2128
2155
  }
2129
2156
  };
2157
+ var dateArrayConverter = {
2158
+ fromAttribute(value) {
2159
+ return value.split(",").map((d) => new Date(d.trim()));
2160
+ },
2161
+ toAttribute(value) {
2162
+ return JSON.stringify(value.map((d) => d.toISOString()));
2163
+ }
2164
+ };
2130
2165
  var _valueOnOpen, _renderBackToValidRangeButton, renderBackToValidRangeButton_fn, _focusDate, focusDate_fn, _getSpinnerLabel, getSpinnerLabel_fn, _getMinSpinnerValue, getMinSpinnerValue_fn, _getMaxSpinnerValue, getMaxSpinnerValue_fn, _dispatchChangeEvent2, dispatchChangeEvent_fn2, _dispatchInputEvent, dispatchInputEvent_fn, _handleFieldFocusOut, _handleSpinnerFocus, _handleClipboardCopy, _handleClipboardPaste, _handleFieldClick, _handleCalendarChange, _handleMonthChange, _handleYearChange, _handleIncrementFocusedMonth, _handleDecrementFocusedMonth, _handleCalendarFocusChange, _handlePopoverStateChange, _handleSpinnerKeydown, _parseDateFormat, parseDateFormat_fn, _handleSpinnerChange, _spinnerState, _years, years_get, _isValueOutsideRange, isValueOutsideRange_get;
2131
2166
  var GdsDatepicker = class extends GdsFormControlElement {
2132
2167
  constructor() {
@@ -2154,6 +2189,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
2154
2189
  this.showWeekNumbers = false;
2155
2190
  this.size = "medium";
2156
2191
  this.hideLabel = false;
2192
+ this.disabledWeekends = false;
2157
2193
  this._focusedMonth = (/* @__PURE__ */ new Date()).getMonth();
2158
2194
  this._focusedYear = (/* @__PURE__ */ new Date()).getFullYear();
2159
2195
  this._dateFormatLayout = __privateMethod(this, _parseDateFormat, parseDateFormat_fn).call(this, "y-m-d");
@@ -2242,6 +2278,10 @@ var GdsDatepicker = class extends GdsFormControlElement {
2242
2278
  this.open = e.detail.open;
2243
2279
  if (e.detail.reason === "close") {
2244
2280
  this.value = (await this._elCalendar).value;
2281
+ if (this.value) {
2282
+ this._focusedMonth = this.value.getMonth();
2283
+ this._focusedYear = this.value.getFullYear();
2284
+ }
2245
2285
  __privateMethod(this, _dispatchChangeEvent2, dispatchChangeEvent_fn2).call(this);
2246
2286
  }
2247
2287
  if (e.detail.reason === "cancel") {
@@ -2404,6 +2444,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
2404
2444
  <gds-dropdown
2405
2445
  .value=${this._focusedMonth.toString()}
2406
2446
  @change=${__privateGet(this, _handleMonthChange)}
2447
+ .maxHeight=${300}
2407
2448
  label="${msg5("Month")}"
2408
2449
  style="width:120px"
2409
2450
  size="small"
@@ -2425,6 +2466,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
2425
2466
  <gds-dropdown
2426
2467
  .value=${this._focusedYear.toString()}
2427
2468
  @change=${__privateGet(this, _handleYearChange)}
2469
+ .maxHeight=${300}
2428
2470
  label="${msg5("Year")}"
2429
2471
  size="small"
2430
2472
  hide-label
@@ -2453,6 +2495,8 @@ var GdsDatepicker = class extends GdsFormControlElement {
2453
2495
  .min=${this.min}
2454
2496
  .max=${this.max}
2455
2497
  .showWeekNumbers=${this.showWeekNumbers}
2498
+ .disabledWeekends=${this.disabledWeekends}
2499
+ .disabledDates=${this.disabledDates}
2456
2500
  ></gds-calendar>
2457
2501
 
2458
2502
  <div class="footer">
@@ -2655,6 +2699,12 @@ __decorateClass([
2655
2699
  __decorateClass([
2656
2700
  property9()
2657
2701
  ], GdsDatepicker.prototype, "dateformat", 1);
2702
+ __decorateClass([
2703
+ property9({ type: Boolean, attribute: "disabled-weekends" })
2704
+ ], GdsDatepicker.prototype, "disabledWeekends", 2);
2705
+ __decorateClass([
2706
+ property9({ converter: dateArrayConverter, attribute: "disabled-dates" })
2707
+ ], GdsDatepicker.prototype, "disabledDates", 2);
2658
2708
  __decorateClass([
2659
2709
  queryAsync3("#calendar-button")
2660
2710
  ], GdsDatepicker.prototype, "test_calendarButton", 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.8.0",
4
+ "version": "1.9.1",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
7
7
  "type": "module",
@@ -28,6 +28,14 @@ export declare class GdsCalendar extends GdsElement {
28
28
  * The date that is currently focused.
29
29
  */
30
30
  focusedDate: Date;
31
+ /**
32
+ * Whether to disable weekends or not.
33
+ */
34
+ disabledWeekends: boolean;
35
+ /**
36
+ * An array of dates that should be disabled in the calendar.
37
+ */
38
+ disabledDates?: Date[];
31
39
  /**
32
40
  * The month that is currently focused.
33
41
  */
@@ -43,6 +43,16 @@ export declare class GdsPopover extends GdsElement {
43
43
  * By default, the popover maxWidth will be set to `auto` and will grow as needed.
44
44
  */
45
45
  calcMaxWidth: (_referenceEl: HTMLElement) => string;
46
+ /**
47
+ * A callback that returns the minimum height of the popover.
48
+ * By default, the popover minHeight will be set to `auto`
49
+ */
50
+ calcMinHeight: (referenceEl: HTMLElement) => string;
51
+ /**
52
+ * A callback that returns the maximum height of the popover.
53
+ * By default, the popover maxHeight will be set to a hard coded pixel value (check source).
54
+ */
55
+ calcMaxHeight: (_referenceEl: HTMLElement) => string;
46
56
  private _trigger;
47
57
  private _isVirtKbVisible;
48
58
  private _handleTriggerRefChanged;
@@ -89,25 +89,25 @@ var option_trans_styles_default = `/**
89
89
  user-select: none;
90
90
  }
91
91
  :host:hover, :host:focus-visible {
92
- background-color: var(--gds-ref-pallet-base200);
92
+ background-color: var(--grey-400);
93
93
  }
94
94
  :host:active {
95
- background-color: var(--gds-ref-pallet-base300);
95
+ background-color: var(--grey-400);
96
96
  }
97
97
  :host:focus {
98
98
  outline-color: #000;
99
99
  outline-offset: -0.25rem;
100
100
  }
101
101
  :host.active.sg-highlighted, :host[aria-selected=true] {
102
- background: var(--gds-ref-pallet-base800);
102
+ background: var(--grey-1000);
103
103
  color: #fff;
104
104
  }
105
105
  :host(:hover),
106
106
  :host(:focus-visible) {
107
- background-color: var(--gds-ref-pallet-base200);
107
+ background-color: var(--grey-400);
108
108
  }
109
109
  :host(:active) {
110
- background-color: var(--gds-ref-pallet-base300);
110
+ background-color: var(--grey-500);
111
111
  }
112
112
  :host(:focus) {
113
113
  outline-color: #000;
@@ -117,7 +117,7 @@ var option_trans_styles_default = `/**
117
117
  display: none;
118
118
  }
119
119
  :host([highlighted]) {
120
- background: var(--gds-ref-pallet-base800);
120
+ background: var(--grey-1000);
121
121
  color: #fff;
122
122
  }
123
123
  .checkbox {
@@ -2086,6 +2086,7 @@ a.button.tertiary.danger:focus-visible {
2086
2086
  overflow: hidden;
2087
2087
  padding: 0;
2088
2088
  right: 0;
2089
+ color: var(--text-primary-color);
2089
2090
  }
2090
2091
  @media (max-width: 35.98em) {
2091
2092
  dialog {
@@ -2104,8 +2105,8 @@ a.button.tertiary.danger:focus-visible {
2104
2105
  dialog {
2105
2106
  padding-bottom: 0;
2106
2107
  border: solid var(--sg-border-width) var(--sg-border-color);
2107
- --border-color: var(--gds-ref-pallet-base800);
2108
- --sg-border-color: var(--gds-ref-pallet-base800);
2108
+ --border-color: var(--text-primary-color);
2109
+ --sg-border-color: var(--text-primary-color);
2109
2110
  border-radius: var(--sg-border-radius);
2110
2111
  max-height: 500px;
2111
2112
  box-shadow: var(--sg-popover-box-shadow);
@@ -2503,8 +2504,8 @@ var dropdown_trans_styles_default = `/**
2503
2504
  padding-top: 0.75rem;
2504
2505
  border-radius: var(--sg-border-radius);
2505
2506
  border: solid var(--sg-border-width) var(--sg-border-color);
2506
- --border-color: var(--gds-ref-pallet-base600);
2507
- --sg-border-color: var(--gds-ref-pallet-base600);
2507
+ --border-color: var(--grey-800);
2508
+ --sg-border-color: var(--grey-800);
2508
2509
  background: var(--sg-form-control-bg);
2509
2510
  color: var(--text-primary-color);
2510
2511
  min-height: 2.75rem;
@@ -2598,11 +2599,11 @@ var dropdown_trans_styles_default = `/**
2598
2599
  }
2599
2600
  }
2600
2601
  button:not(:disabled, .disabled, [aria-disabled]):hover {
2601
- --background: var(--gds-ref-pallet-base200);
2602
- --color: var(--gds-ref-pallet-base800);
2603
- background-color: var(--gds-ref-pallet-base200);
2604
- color: var(--gds-ref-pallet-base800);
2605
- border-color: var(--gds-ref-pallet-base800);
2602
+ --background: var(--grey-400);
2603
+ --color: var(--grey-1000);
2604
+ background-color: var(--grey-400);
2605
+ color: var(--grey-1000);
2606
+ border-color: var(--grey-1000);
2606
2607
  }
2607
2608
  button > span {
2608
2609
  white-space: nowrap;
@@ -2612,8 +2613,8 @@ var dropdown_trans_styles_default = `/**
2612
2613
  button::after {
2613
2614
  margin-left: 0.5rem;
2614
2615
  margin-right: 0.5rem;
2615
- border-bottom: solid 2px var(--gds-ref-pallet-base800);
2616
- border-left: solid 2px var(--gds-ref-pallet-base800);
2616
+ border-bottom: solid 2px var(--text-primary-color);
2617
+ border-left: solid 2px var(--text-primary-color);
2617
2618
  content: "";
2618
2619
  display: block;
2619
2620
  height: 0.5rem;
@@ -2634,7 +2635,7 @@ var dropdown_trans_styles_default = `/**
2634
2635
  font-size: 0.875rem;
2635
2636
  }
2636
2637
  button:hover {
2637
- background: var(--gds-ref-pallet-base300);
2638
+ background: var(--grey-400);
2638
2639
  }
2639
2640
  label {
2640
2641
  display: block;
@@ -2913,11 +2914,11 @@ var calendar_trans_styles_default = `/* stylelint-disable max-nesting-depth */
2913
2914
  :host table tbody tr td.today {
2914
2915
  background: transparent;
2915
2916
  border-radius: 4px;
2916
- color: var(--gds-ref-pallet-base800);
2917
- box-shadow: inset 0 0 0 2px var(--gds-ref-pallet-base800);
2917
+ color: var(--grey-1000);
2918
+ box-shadow: inset 0 0 0 2px var(--grey-1000);
2918
2919
  }
2919
2920
  :host table tbody tr td:hover:not(.disabled) {
2920
- background: var(--gds-ref-pallet-base300);
2921
+ background: var(--grey-500);
2921
2922
  border: solid 1px var(--sg-bg-level-2);
2922
2923
  border-radius: 4px;
2923
2924
  color: var(--gds-sys-color-font);
@@ -2941,7 +2942,7 @@ var calendar_trans_styles_default = `/* stylelint-disable max-nesting-depth */
2941
2942
  z-index: 0;
2942
2943
  }
2943
2944
  :host table tbody tr td[aria-selected=true] {
2944
- background: var(--gds-ref-pallet-base800);
2945
+ background: var(--grey-1000);
2945
2946
  border: solid 1px var(--sg-bg-level-2);
2946
2947
  border-radius: 4px;
2947
2948
  color: hsl(var(--sg-hsl-white));
@@ -2950,7 +2951,7 @@ var calendar_trans_styles_default = `/* stylelint-disable max-nesting-depth */
2950
2951
  border-radius: 4px;
2951
2952
  }
2952
2953
  :host table tbody tr td:hover:active:not(.disabled) {
2953
- background: var(--gds-ref-pallet-base800);
2954
+ background: var(--grey-1000);
2954
2955
  border: solid 1px var(--sg-bg-level-2);
2955
2956
  border-radius: 4px;
2956
2957
  color: hsl(var(--sg-hsl-white));
@@ -3098,7 +3099,7 @@ i.sg-icon.sg-icon-ellipsis::before {
3098
3099
  cursor: text;
3099
3100
  }
3100
3101
  .field:hover {
3101
- background-color: var(--gds-ref-pallet-base100);
3102
+ background-color: var(--grey-200);
3102
3103
  }
3103
3104
  .field .input {
3104
3105
  padding-left: 1rem;
@@ -3154,6 +3155,7 @@ i.sg-icon.sg-icon-ellipsis::before {
3154
3155
  cursor: pointer;
3155
3156
  width: 2.75rem;
3156
3157
  background: transparent;
3158
+ color: var(--text-primary-color);
3157
3159
  }
3158
3160
  .field button:focus:not(:focus-visible) {
3159
3161
  box-shadow: none;
@@ -3166,7 +3168,7 @@ i.sg-icon.sg-icon-ellipsis::before {
3166
3168
  outline-offset: 0.125rem;
3167
3169
  }
3168
3170
  .field button:hover {
3169
- background: var(--gds-ref-pallet-base300);
3171
+ background: var(--grey-500);
3170
3172
  }
3171
3173
  .field button svg {
3172
3174
  width: 1rem;
@@ -3248,15 +3250,15 @@ i.sg-icon.sg-icon-ellipsis::before {
3248
3250
  outline-offset: 0.125rem;
3249
3251
  }
3250
3252
  .header button:hover {
3251
- background: var(--gds-ref-pallet-base300);
3253
+ background: var(--grey-400);
3252
3254
  }
3253
3255
  .header button:focus-visible {
3254
3256
  outline-offset: 0;
3255
3257
  }
3256
3258
  .header button .icon::before {
3257
3259
  background: none;
3258
- border-bottom: 2px solid;
3259
- border-left: 2px solid;
3260
+ border-bottom: 2px solid var(--grey-1000);
3261
+ border-left: 2px solid var(--grey-1000);
3260
3262
  content: "";
3261
3263
  display: block;
3262
3264
  height: 8px;
@@ -3353,7 +3355,7 @@ function register7() {
3353
3355
  // libs/core/src/utils/helpers/custom-element-scoping.ts
3354
3356
  import { html as litHtml } from "lit";
3355
3357
  import { customElement } from "lit/decorators.js";
3356
- var VER_SUFFIX = "-3d880b";
3358
+ var VER_SUFFIX = "-260c87";
3357
3359
  var elementLookupTable = /* @__PURE__ */ new Map();
3358
3360
  var templateCache = /* @__PURE__ */ new WeakMap();
3359
3361
  function applyElementScoping(strings, ...values) {