@sebgroup/green-core 1.8.0 → 1.9.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.
- package/README.md +1 -1
- package/components/datepicker/datepicker.d.ts +8 -0
- package/components/dropdown/dropdown.d.ts +4 -0
- package/index.js +47 -4
- package/package.json +1 -1
- package/primitives/calendar/calendar.d.ts +8 -0
- package/primitives/popover/popover.d.ts +10 -0
- package/transitional-styles.js +1 -1
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/
|
|
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 = "-
|
|
147
|
+
var VER_SUFFIX = "-af766e";
|
|
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,6 +1754,7 @@ 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() {
|
|
@@ -1798,11 +1814,13 @@ var GdsCalendar = class extends GdsElement {
|
|
|
1798
1814
|
</td>`
|
|
1799
1815
|
)}
|
|
1800
1816
|
${week.days.map((day) => {
|
|
1801
|
-
const
|
|
1817
|
+
const isOutsideCurrentMonth = !isSameMonth(this.focusedDate, day) || day < this.min || day > this.max;
|
|
1818
|
+
const isWeekend = day.getDay() === 0 || day.getDay() === 6;
|
|
1819
|
+
const isDisabled = isOutsideCurrentMonth || this.disabledWeekends && isWeekend || this.disabledDates && this.disabledDates.some((d) => isSameDay(d, day));
|
|
1802
1820
|
return html7`
|
|
1803
1821
|
<td
|
|
1804
1822
|
class="${classMap5({
|
|
1805
|
-
disabled: isDisabled,
|
|
1823
|
+
disabled: Boolean(isDisabled),
|
|
1806
1824
|
today: isSameDay(currentDate, day)
|
|
1807
1825
|
})}"
|
|
1808
1826
|
?disabled=${isDisabled}
|
|
@@ -1910,6 +1928,12 @@ __decorateClass([
|
|
|
1910
1928
|
__decorateClass([
|
|
1911
1929
|
property7()
|
|
1912
1930
|
], GdsCalendar.prototype, "focusedDate", 2);
|
|
1931
|
+
__decorateClass([
|
|
1932
|
+
property7({ type: Boolean, attribute: "disabled-weekends" })
|
|
1933
|
+
], GdsCalendar.prototype, "disabledWeekends", 2);
|
|
1934
|
+
__decorateClass([
|
|
1935
|
+
property7({ type: Array, attribute: "disabled-dates" })
|
|
1936
|
+
], GdsCalendar.prototype, "disabledDates", 2);
|
|
1913
1937
|
__decorateClass([
|
|
1914
1938
|
property7({ type: Number })
|
|
1915
1939
|
], GdsCalendar.prototype, "focusedMonth", 1);
|
|
@@ -2127,6 +2151,14 @@ var dateConverter = {
|
|
|
2127
2151
|
return value.toISOString();
|
|
2128
2152
|
}
|
|
2129
2153
|
};
|
|
2154
|
+
var dateArrayConverter = {
|
|
2155
|
+
fromAttribute(value) {
|
|
2156
|
+
return value.split(",").map((d) => new Date(d.trim()));
|
|
2157
|
+
},
|
|
2158
|
+
toAttribute(value) {
|
|
2159
|
+
return JSON.stringify(value.map((d) => d.toISOString()));
|
|
2160
|
+
}
|
|
2161
|
+
};
|
|
2130
2162
|
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
2163
|
var GdsDatepicker = class extends GdsFormControlElement {
|
|
2132
2164
|
constructor() {
|
|
@@ -2154,6 +2186,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
|
|
|
2154
2186
|
this.showWeekNumbers = false;
|
|
2155
2187
|
this.size = "medium";
|
|
2156
2188
|
this.hideLabel = false;
|
|
2189
|
+
this.disabledWeekends = false;
|
|
2157
2190
|
this._focusedMonth = (/* @__PURE__ */ new Date()).getMonth();
|
|
2158
2191
|
this._focusedYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
2159
2192
|
this._dateFormatLayout = __privateMethod(this, _parseDateFormat, parseDateFormat_fn).call(this, "y-m-d");
|
|
@@ -2404,6 +2437,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
|
|
|
2404
2437
|
<gds-dropdown
|
|
2405
2438
|
.value=${this._focusedMonth.toString()}
|
|
2406
2439
|
@change=${__privateGet(this, _handleMonthChange)}
|
|
2440
|
+
.maxHeight=${300}
|
|
2407
2441
|
label="${msg5("Month")}"
|
|
2408
2442
|
style="width:120px"
|
|
2409
2443
|
size="small"
|
|
@@ -2425,6 +2459,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
|
|
|
2425
2459
|
<gds-dropdown
|
|
2426
2460
|
.value=${this._focusedYear.toString()}
|
|
2427
2461
|
@change=${__privateGet(this, _handleYearChange)}
|
|
2462
|
+
.maxHeight=${300}
|
|
2428
2463
|
label="${msg5("Year")}"
|
|
2429
2464
|
size="small"
|
|
2430
2465
|
hide-label
|
|
@@ -2453,6 +2488,8 @@ var GdsDatepicker = class extends GdsFormControlElement {
|
|
|
2453
2488
|
.min=${this.min}
|
|
2454
2489
|
.max=${this.max}
|
|
2455
2490
|
.showWeekNumbers=${this.showWeekNumbers}
|
|
2491
|
+
.disabledWeekends=${this.disabledWeekends}
|
|
2492
|
+
.disabledDates=${this.disabledDates}
|
|
2456
2493
|
></gds-calendar>
|
|
2457
2494
|
|
|
2458
2495
|
<div class="footer">
|
|
@@ -2655,6 +2692,12 @@ __decorateClass([
|
|
|
2655
2692
|
__decorateClass([
|
|
2656
2693
|
property9()
|
|
2657
2694
|
], GdsDatepicker.prototype, "dateformat", 1);
|
|
2695
|
+
__decorateClass([
|
|
2696
|
+
property9({ type: Boolean, attribute: "disabled-weekends" })
|
|
2697
|
+
], GdsDatepicker.prototype, "disabledWeekends", 2);
|
|
2698
|
+
__decorateClass([
|
|
2699
|
+
property9({ converter: dateArrayConverter, attribute: "disabled-dates" })
|
|
2700
|
+
], GdsDatepicker.prototype, "disabledDates", 2);
|
|
2658
2701
|
__decorateClass([
|
|
2659
2702
|
queryAsync3("#calendar-button")
|
|
2660
2703
|
], GdsDatepicker.prototype, "test_calendarButton", 2);
|
package/package.json
CHANGED
|
@@ -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;
|
package/transitional-styles.js
CHANGED
|
@@ -3353,7 +3353,7 @@ function register7() {
|
|
|
3353
3353
|
// libs/core/src/utils/helpers/custom-element-scoping.ts
|
|
3354
3354
|
import { html as litHtml } from "lit";
|
|
3355
3355
|
import { customElement } from "lit/decorators.js";
|
|
3356
|
-
var VER_SUFFIX = "-
|
|
3356
|
+
var VER_SUFFIX = "-af766e";
|
|
3357
3357
|
var elementLookupTable = /* @__PURE__ */ new Map();
|
|
3358
3358
|
var templateCache = /* @__PURE__ */ new WeakMap();
|
|
3359
3359
|
function applyElementScoping(strings, ...values) {
|