@sebgroup/green-core 1.4.2 → 1.4.3

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 = "-3bff35";
142
+ var VER_SUFFIX = "-ebe3ca";
143
143
  var elementLookupTable = /* @__PURE__ */ new Map();
144
144
  var gdsCustomElement = (tagName) => {
145
145
  if (globalThis.GDS_DISABLE_VERSIONED_ELEMENTS) {
@@ -193,12 +193,20 @@ import { createRef, ref } from "lit/directives/ref.js";
193
193
  // libs/core/src/utils/helpers/transitional-styles.ts
194
194
  import { html as html2 } from "lit";
195
195
  import { unsafeHTML } from "lit/directives/unsafe-html.js";
196
+ function supportsConstructedStylesheets() {
197
+ try {
198
+ new CSSStyleSheet();
199
+ return true;
200
+ } catch {
201
+ return false;
202
+ }
203
+ }
196
204
  var TransitionalStyles = class {
197
205
  constructor() {
198
206
  this.sheets = /* @__PURE__ */ new Map();
199
207
  this.elements = /* @__PURE__ */ new Map();
200
208
  this.sheetsLegacy = /* @__PURE__ */ new Map();
201
- this.useLegacyStylesheets = true;
209
+ this.useLegacyStylesheets = !supportsConstructedStylesheets();
202
210
  }
203
211
  static get instance() {
204
212
  if (!globalThis.__gdsTransitionalStyles?.[VER_SUFFIX])
@@ -208,7 +216,6 @@ var TransitionalStyles = class {
208
216
  };
209
217
  return globalThis.__gdsTransitionalStyles[VER_SUFFIX];
210
218
  }
211
- //!supportsConstructedStylesheets()
212
219
  apply(element, styleKey) {
213
220
  if (!element.shadowRoot)
214
221
  return;
@@ -1746,7 +1753,6 @@ import { map } from "lit/directives/map.js";
1746
1753
  import { repeat } from "lit/directives/repeat.js";
1747
1754
  import { nothing } from "lit";
1748
1755
  import { msg as msg5 } from "@lit/localize";
1749
- import { eachYearOfInterval } from "date-fns";
1750
1756
 
1751
1757
  // libs/core/src/primitives/calendar/calendar.ts
1752
1758
  import { html as html6 } from "lit";
@@ -2069,9 +2075,13 @@ var GdsDatePartSpinner = class extends LitElement6 {
2069
2075
  } else {
2070
2076
  const key = parseInt(e.key);
2071
2077
  if (!isNaN(key)) {
2072
- __privateSet(this, _inputBuffer, __privateGet(this, _inputBuffer) + key.toString());
2073
- this.value = parseInt(__privateGet(this, _inputBuffer));
2074
- if (__privateGet(this, _inputBuffer).length == this.length) {
2078
+ if (__privateGet(this, _inputBuffer).length < this.length) {
2079
+ __privateSet(this, _inputBuffer, __privateGet(this, _inputBuffer) + key.toString());
2080
+ this.value = parseInt(__privateGet(this, _inputBuffer));
2081
+ }
2082
+ if (__privateGet(this, _inputBuffer).length === this.length) {
2083
+ this.value = __privateMethod(this, _clamp, clamp_fn).call(this, this.value);
2084
+ __privateMethod(this, _clearInputBuffer, clearInputBuffer_fn).call(this);
2075
2085
  __privateMethod(this, _focusNextSpinner, focusNextSpinner_fn).call(this);
2076
2086
  __privateMethod(this, _dispatchChangeEvent, dispatchChangeEvent_fn).call(this);
2077
2087
  }
@@ -2193,7 +2203,7 @@ var dateConverter = {
2193
2203
  return value.toISOString();
2194
2204
  }
2195
2205
  };
2196
- var _renderBackToValidRangeButton, renderBackToValidRangeButton_fn, _focusDate, focusDate_fn, _getSpinnerLabel, getSpinnerLabel_fn, _getMinSpinnerValue, getMinSpinnerValue_fn, _getMaxSpinnerValue, getMaxSpinnerValue_fn, _dispatchChangeEvent2, dispatchChangeEvent_fn2, _handleCalendarChange, _handleMonthChange, _handleYearChange, _handleIncrementFocusedMonth, _handleDecrementFocusedMonth, _handleFocusChange, _handlePopoverStateChange, _handleSpinnerKeydown, _parseDateFormat, parseDateFormat_fn, _handleSpinnerChange, _spinnerState, _years, years_get;
2206
+ var _renderBackToValidRangeButton, renderBackToValidRangeButton_fn, _focusDate, focusDate_fn, _getSpinnerLabel, getSpinnerLabel_fn, _getMinSpinnerValue, getMinSpinnerValue_fn, _getMaxSpinnerValue, getMaxSpinnerValue_fn, _dispatchChangeEvent2, dispatchChangeEvent_fn2, _handleCalendarChange, _handleMonthChange, _handleYearChange, _handleIncrementFocusedMonth, _handleDecrementFocusedMonth, _handleFocusChange, _handlePopoverStateChange, _handleSpinnerKeydown, _parseDateFormat, parseDateFormat_fn, _handleSpinnerChange, _spinnerState, _years, years_get, _isValueOutsideRange, isValueOutsideRange_get;
2197
2207
  var GdsDatepicker = class extends GdsFormControlElement {
2198
2208
  constructor() {
2199
2209
  super(...arguments);
@@ -2208,10 +2218,10 @@ var GdsDatepicker = class extends GdsFormControlElement {
2208
2218
  */
2209
2219
  __privateAdd(this, _parseDateFormat);
2210
2220
  /**
2211
- * Returns an array of years between the min and max dates for use in the year dropdown.
2212
- * If the value is set to a year outside the range, it will be added to the array until the value is changed.
2221
+ * Returns a year iterator between the min and max dates for use in the year dropdown.
2213
2222
  */
2214
2223
  __privateAdd(this, _years);
2224
+ __privateAdd(this, _isValueOutsideRange);
2215
2225
  this.min = new Date((/* @__PURE__ */ new Date()).getFullYear() - 10, 0, 1);
2216
2226
  this.max = new Date((/* @__PURE__ */ new Date()).getFullYear() + 10, 0, 1);
2217
2227
  this.open = false;
@@ -2511,7 +2521,7 @@ getSpinnerLabel_fn = function(name) {
2511
2521
  _getMinSpinnerValue = new WeakSet();
2512
2522
  getMinSpinnerValue_fn = function(name) {
2513
2523
  const min = {
2514
- year: this.min.getFullYear(),
2524
+ year: 1900,
2515
2525
  month: 1,
2516
2526
  day: 1
2517
2527
  };
@@ -2520,7 +2530,7 @@ getMinSpinnerValue_fn = function(name) {
2520
2530
  _getMaxSpinnerValue = new WeakSet();
2521
2531
  getMaxSpinnerValue_fn = function(name) {
2522
2532
  const max = {
2523
- year: this.max.getFullYear(),
2533
+ year: 9999,
2524
2534
  month: 12,
2525
2535
  day: 31
2526
2536
  };
@@ -2562,19 +2572,24 @@ _handleSpinnerChange = new WeakMap();
2562
2572
  _spinnerState = new WeakMap();
2563
2573
  _years = new WeakSet();
2564
2574
  years_get = function() {
2565
- const years = eachYearOfInterval({
2566
- start: this.min,
2567
- end: this.max
2568
- }).map((date) => date.getFullYear());
2575
+ const minYear = this.min.getFullYear();
2576
+ const maxYear = this.max.getFullYear();
2577
+ const isOutsideRange = __privateGet(this, _isValueOutsideRange, isValueOutsideRange_get);
2578
+ const valueYear = this.value?.getFullYear();
2579
+ return {
2580
+ *[Symbol.iterator]() {
2581
+ if (isOutsideRange)
2582
+ yield valueYear;
2583
+ for (let i = minYear; i <= maxYear; i++)
2584
+ yield i;
2585
+ }
2586
+ };
2587
+ };
2588
+ _isValueOutsideRange = new WeakSet();
2589
+ isValueOutsideRange_get = function() {
2569
2590
  if (!this.value)
2570
- return years;
2571
- const selectedYear = this.value.getFullYear();
2572
- const valueIsInrage = years[0] <= selectedYear && years[years.length - 1] >= selectedYear;
2573
- if (!valueIsInrage) {
2574
- years.push(selectedYear);
2575
- years.sort((a, b) => a - b);
2576
- }
2577
- return years;
2591
+ return false;
2592
+ return this.value.getFullYear() < this.min.getFullYear() || this.value.getFullYear() > this.max.getFullYear();
2578
2593
  };
2579
2594
  GdsDatepicker.styles = [styles];
2580
2595
  GdsDatepicker.shadowRootOptions = {
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.2",
4
+ "version": "1.4.3",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
7
7
  "type": "module",
@@ -3216,7 +3216,7 @@ function register6() {
3216
3216
  // libs/core/src/utils/helpers/custom-element-scoping.ts
3217
3217
  import { html as litHtml } from "lit";
3218
3218
  import { customElement } from "lit/decorators.js";
3219
- var VER_SUFFIX = "-3bff35";
3219
+ var VER_SUFFIX = "-ebe3ca";
3220
3220
  var elementLookupTable = /* @__PURE__ */ new Map();
3221
3221
  var templateCache = /* @__PURE__ */ new WeakMap();
3222
3222
  function applyElementScoping(strings, ...values) {
@@ -3254,12 +3254,20 @@ var registerTransitionalStyles = () => {
3254
3254
  register5();
3255
3255
  register6();
3256
3256
  };
3257
+ function supportsConstructedStylesheets() {
3258
+ try {
3259
+ new CSSStyleSheet();
3260
+ return true;
3261
+ } catch {
3262
+ return false;
3263
+ }
3264
+ }
3257
3265
  var TransitionalStyles = class {
3258
3266
  constructor() {
3259
3267
  this.sheets = /* @__PURE__ */ new Map();
3260
3268
  this.elements = /* @__PURE__ */ new Map();
3261
3269
  this.sheetsLegacy = /* @__PURE__ */ new Map();
3262
- this.useLegacyStylesheets = true;
3270
+ this.useLegacyStylesheets = !supportsConstructedStylesheets();
3263
3271
  }
3264
3272
  static get instance() {
3265
3273
  if (!globalThis.__gdsTransitionalStyles?.[VER_SUFFIX])
@@ -3269,7 +3277,6 @@ var TransitionalStyles = class {
3269
3277
  };
3270
3278
  return globalThis.__gdsTransitionalStyles[VER_SUFFIX];
3271
3279
  }
3272
- //!supportsConstructedStylesheets()
3273
3280
  apply(element, styleKey) {
3274
3281
  if (!element.shadowRoot)
3275
3282
  return;