@sebgroup/green-core 1.5.0 → 1.6.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/components/dropdown/dropdown.d.ts +1 -1
- package/components/index.d.ts +1 -0
- package/index.js +118 -197
- package/package.json +4 -4
- package/primitives/listbox/option.d.ts +1 -2
- package/primitives/menu/menu-heading.d.ts +6 -0
- package/primitives/menu/menu-heading.styles.d.ts +2 -0
- package/transitional-styles.js +33 -4
- package/primitives/popover/topLayerOverTransforms.middleware.d.ts +0 -28
|
@@ -10,7 +10,7 @@ import { CSSResult } from 'lit';
|
|
|
10
10
|
*
|
|
11
11
|
* @status beta
|
|
12
12
|
*
|
|
13
|
-
* @slot - Options for the dropdown. Accepts `gds-option` elements.
|
|
13
|
+
* @slot - Options for the dropdown. Accepts `gds-option` and `gds-menu-heading` elements.
|
|
14
14
|
* @slot button - The trigger button for the dropdown. Custom content for the button can be assigned through this slot.
|
|
15
15
|
* @slot sub-label - Renders between the label and the trigger button.
|
|
16
16
|
* @slot message - Renders below the trigger button. Will be red if there is a validation error.
|
package/components/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './dropdown/dropdown';
|
|
2
2
|
export * from '../primitives/listbox/option';
|
|
3
|
+
export * from '../primitives/menu/menu-heading';
|
|
3
4
|
export * from './context-menu/context-menu';
|
|
4
5
|
export * from '../primitives/menu/menu-item';
|
|
5
6
|
export * from './datepicker/datepicker';
|
package/index.js
CHANGED
|
@@ -143,10 +143,11 @@ function watchMediaQuery(q) {
|
|
|
143
143
|
// libs/core/src/utils/helpers/custom-element-scoping.ts
|
|
144
144
|
import { html as litHtml } from "lit";
|
|
145
145
|
import { customElement } from "lit/decorators.js";
|
|
146
|
-
var VER_SUFFIX = "-
|
|
146
|
+
var VER_SUFFIX = "-f9a04d";
|
|
147
147
|
var elementLookupTable = /* @__PURE__ */ new Map();
|
|
148
148
|
var gdsCustomElement = (tagName) => {
|
|
149
149
|
if (globalThis.GDS_DISABLE_VERSIONED_ELEMENTS) {
|
|
150
|
+
elementLookupTable.set(tagName, tagName);
|
|
150
151
|
return customElement(tagName);
|
|
151
152
|
}
|
|
152
153
|
const versionedTagName = tagName + VER_SUFFIX;
|
|
@@ -419,7 +420,7 @@ var GdsListbox = class extends GdsElement {
|
|
|
419
420
|
if (!__privateGet(this, _slotRef).value)
|
|
420
421
|
return [];
|
|
421
422
|
return unwrap(__privateGet(this, _slotRef).value).assignedElements().filter(
|
|
422
|
-
(o) => !o.hasAttribute("isplaceholder")
|
|
423
|
+
(o) => !o.hasAttribute("isplaceholder") && o.gdsElementName === "gds-option"
|
|
423
424
|
) || [];
|
|
424
425
|
}
|
|
425
426
|
/**
|
|
@@ -674,163 +675,6 @@ import {
|
|
|
674
675
|
flip
|
|
675
676
|
} from "@floating-ui/dom";
|
|
676
677
|
|
|
677
|
-
// libs/core/src/primitives/popover/topLayerOverTransforms.middleware.ts
|
|
678
|
-
var topLayerOverTransforms = () => ({
|
|
679
|
-
name: "topLayer",
|
|
680
|
-
async fn(middlewareArguments) {
|
|
681
|
-
const {
|
|
682
|
-
x,
|
|
683
|
-
y,
|
|
684
|
-
elements: { reference, floating }
|
|
685
|
-
} = middlewareArguments;
|
|
686
|
-
let onTopLayer = false;
|
|
687
|
-
let topLayerIsFloating = false;
|
|
688
|
-
const diffCoords = {
|
|
689
|
-
x: 0,
|
|
690
|
-
y: 0
|
|
691
|
-
};
|
|
692
|
-
try {
|
|
693
|
-
onTopLayer = onTopLayer || floating.matches(":open");
|
|
694
|
-
} catch (e) {
|
|
695
|
-
}
|
|
696
|
-
try {
|
|
697
|
-
onTopLayer = onTopLayer || floating.matches(":modal");
|
|
698
|
-
} catch (e) {
|
|
699
|
-
}
|
|
700
|
-
topLayerIsFloating = onTopLayer;
|
|
701
|
-
if (!onTopLayer) {
|
|
702
|
-
const dialogAncestorQueryEvent = new Event("floating-ui-dialog-test", {
|
|
703
|
-
composed: true,
|
|
704
|
-
bubbles: true
|
|
705
|
-
});
|
|
706
|
-
floating.addEventListener(
|
|
707
|
-
"floating-ui-dialog-test",
|
|
708
|
-
(event) => {
|
|
709
|
-
event.composedPath().forEach((el) => {
|
|
710
|
-
if (el === floating || el.localName !== "dialog")
|
|
711
|
-
return;
|
|
712
|
-
try {
|
|
713
|
-
onTopLayer = onTopLayer || el.matches(":modal");
|
|
714
|
-
if (onTopLayer) {
|
|
715
|
-
}
|
|
716
|
-
} catch (e) {
|
|
717
|
-
}
|
|
718
|
-
});
|
|
719
|
-
},
|
|
720
|
-
{ once: true }
|
|
721
|
-
);
|
|
722
|
-
floating.dispatchEvent(dialogAncestorQueryEvent);
|
|
723
|
-
}
|
|
724
|
-
let overTransforms = false;
|
|
725
|
-
const containingBlock = getContainingBlock(reference);
|
|
726
|
-
if (containingBlock !== null && !isWindow(containingBlock)) {
|
|
727
|
-
overTransforms = true;
|
|
728
|
-
}
|
|
729
|
-
if (onTopLayer && overTransforms) {
|
|
730
|
-
const rect = containingBlock.getBoundingClientRect();
|
|
731
|
-
diffCoords.x = rect.x;
|
|
732
|
-
diffCoords.y = rect.y;
|
|
733
|
-
}
|
|
734
|
-
if (onTopLayer && topLayerIsFloating) {
|
|
735
|
-
return {
|
|
736
|
-
x: x + diffCoords.x,
|
|
737
|
-
y: y + diffCoords.y,
|
|
738
|
-
data: diffCoords
|
|
739
|
-
};
|
|
740
|
-
}
|
|
741
|
-
if (onTopLayer) {
|
|
742
|
-
return {
|
|
743
|
-
x,
|
|
744
|
-
y,
|
|
745
|
-
data: diffCoords
|
|
746
|
-
};
|
|
747
|
-
}
|
|
748
|
-
return {
|
|
749
|
-
x: x - diffCoords.x,
|
|
750
|
-
y: y - diffCoords.y,
|
|
751
|
-
data: diffCoords
|
|
752
|
-
};
|
|
753
|
-
}
|
|
754
|
-
});
|
|
755
|
-
function getContainingBlock(element) {
|
|
756
|
-
let currentNode = getParentNode(element);
|
|
757
|
-
if (isShadowRoot(currentNode)) {
|
|
758
|
-
currentNode = currentNode.host;
|
|
759
|
-
}
|
|
760
|
-
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
761
|
-
if (isContainingBlock(currentNode)) {
|
|
762
|
-
return currentNode;
|
|
763
|
-
} else {
|
|
764
|
-
const parent = currentNode.assignedSlot ? currentNode.assignedSlot : currentNode.parentNode;
|
|
765
|
-
currentNode = isShadowRoot(parent) ? parent.host : parent;
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
return null;
|
|
769
|
-
}
|
|
770
|
-
function isLastTraversableNode(node) {
|
|
771
|
-
return ["html", "body", "#document"].includes(getNodeName(node));
|
|
772
|
-
}
|
|
773
|
-
function isContainingBlock(element) {
|
|
774
|
-
const isFirefox = /firefox/i.test(getUAString());
|
|
775
|
-
if (element.tagName === "dialog") {
|
|
776
|
-
return true;
|
|
777
|
-
}
|
|
778
|
-
const css7 = getComputedStyle(element);
|
|
779
|
-
return css7.transform !== "none" || css7.perspective !== "none" || css7.contain === "paint" || ["transform", "perspective"].includes(css7.willChange) || isFirefox && css7.willChange === "filter" || isFirefox && (css7.filter ? css7.filter !== "none" : false);
|
|
780
|
-
}
|
|
781
|
-
function getUAString() {
|
|
782
|
-
const uaData = navigator.userAgentData;
|
|
783
|
-
if (uaData?.brands) {
|
|
784
|
-
return uaData.brands.map((item) => `${item.brand}/${item.version}`).join(" ");
|
|
785
|
-
}
|
|
786
|
-
return navigator.userAgent;
|
|
787
|
-
}
|
|
788
|
-
function getParentNode(node) {
|
|
789
|
-
if (getNodeName(node) === "html") {
|
|
790
|
-
return node;
|
|
791
|
-
}
|
|
792
|
-
return (
|
|
793
|
-
// this is a quicker (but less type safe) way to save quite some bytes from the bundle
|
|
794
|
-
node.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
|
795
|
-
node.parentNode || // DOM Element detected
|
|
796
|
-
(isShadowRoot(node) ? node.host : null) || // ShadowRoot detected
|
|
797
|
-
getDocumentElement(node)
|
|
798
|
-
);
|
|
799
|
-
}
|
|
800
|
-
function getNodeName(node) {
|
|
801
|
-
return isWindow(node) ? "" : node ? (node.nodeName || "").toLowerCase() : "";
|
|
802
|
-
}
|
|
803
|
-
function getDocumentElement(node) {
|
|
804
|
-
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
|
805
|
-
}
|
|
806
|
-
function isNode(value) {
|
|
807
|
-
return value instanceof getWindow(value).Node;
|
|
808
|
-
}
|
|
809
|
-
function isWindow(value) {
|
|
810
|
-
return value && value.document && value.location && value.alert && value.setInterval;
|
|
811
|
-
}
|
|
812
|
-
function getWindow(node) {
|
|
813
|
-
if (node == null) {
|
|
814
|
-
return window;
|
|
815
|
-
}
|
|
816
|
-
if (!isWindow(node)) {
|
|
817
|
-
const ownerDocument = node.ownerDocument;
|
|
818
|
-
return ownerDocument ? ownerDocument.defaultView || window : window;
|
|
819
|
-
}
|
|
820
|
-
return node;
|
|
821
|
-
}
|
|
822
|
-
function isShadowRoot(node) {
|
|
823
|
-
if (typeof ShadowRoot === "undefined") {
|
|
824
|
-
return false;
|
|
825
|
-
}
|
|
826
|
-
const OwnElement = getWindow(node).ShadowRoot;
|
|
827
|
-
const testNode = node;
|
|
828
|
-
return node instanceof OwnElement || testNode instanceof ShadowRoot;
|
|
829
|
-
}
|
|
830
|
-
function isHTMLElement(value) {
|
|
831
|
-
return value instanceof getWindow(value).HTMLElement;
|
|
832
|
-
}
|
|
833
|
-
|
|
834
678
|
// libs/core/src/primitives/popover/popover.styles.ts
|
|
835
679
|
import { css as css3 } from "lit";
|
|
836
680
|
var style3 = css3`
|
|
@@ -1058,7 +902,7 @@ registerAutoPositioning_fn = function() {
|
|
|
1058
902
|
__privateSet(this, _autoPositionCleanupFn, autoUpdate(referenceEl, floatingEl, () => {
|
|
1059
903
|
computePosition(referenceEl, floatingEl, {
|
|
1060
904
|
placement: this.placement,
|
|
1061
|
-
middleware: [offset(8), flip()
|
|
905
|
+
middleware: [offset(8), flip()],
|
|
1062
906
|
strategy: "fixed"
|
|
1063
907
|
}).then(
|
|
1064
908
|
({ x, y }) => Object.assign(floatingEl.style, {
|
|
@@ -1443,7 +1287,7 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
1443
1287
|
@gds-focus="${__privateGet(this, _handleOptionFocusChange)}"
|
|
1444
1288
|
@keydown=${__privateGet(this, _handleListboxKeyDown)}
|
|
1445
1289
|
>
|
|
1446
|
-
<slot gds-allow="gds-option"></slot>
|
|
1290
|
+
<slot gds-allow="gds-option gds-menu-heading"></slot>
|
|
1447
1291
|
</gds-listbox>
|
|
1448
1292
|
</gds-popover>
|
|
1449
1293
|
`;
|
|
@@ -1591,6 +1435,44 @@ GdsDropdown = __decorateClass([
|
|
|
1591
1435
|
gdsCustomElement("gds-dropdown")
|
|
1592
1436
|
], GdsDropdown);
|
|
1593
1437
|
|
|
1438
|
+
// libs/core/src/primitives/menu/menu-heading.ts
|
|
1439
|
+
import { html as html5 } from "lit";
|
|
1440
|
+
|
|
1441
|
+
// libs/core/src/primitives/menu/menu-heading.styles.ts
|
|
1442
|
+
import { css as css5 } from "lit";
|
|
1443
|
+
var style5 = css5`
|
|
1444
|
+
@layer base, reset, transitional-styles;
|
|
1445
|
+
@layer base {
|
|
1446
|
+
:host {
|
|
1447
|
+
padding: 0.5 1rem;
|
|
1448
|
+
cursor: pointer;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
:host(:hover) {
|
|
1452
|
+
background-color: grey;
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
`;
|
|
1456
|
+
var menu_heading_styles_default = style5;
|
|
1457
|
+
|
|
1458
|
+
// libs/core/src/primitives/menu/menu-heading.ts
|
|
1459
|
+
var GdsMenuHeading = class extends GdsElement {
|
|
1460
|
+
connectedCallback() {
|
|
1461
|
+
super.connectedCallback();
|
|
1462
|
+
this.setAttribute("inert", "true");
|
|
1463
|
+
this.updateComplete.then(
|
|
1464
|
+
() => TransitionalStyles.instance.apply(this, "gds-menu-heading")
|
|
1465
|
+
);
|
|
1466
|
+
}
|
|
1467
|
+
render() {
|
|
1468
|
+
return html5`<slot></slot>`;
|
|
1469
|
+
}
|
|
1470
|
+
};
|
|
1471
|
+
GdsMenuHeading.styles = menu_heading_styles_default;
|
|
1472
|
+
GdsMenuHeading = __decorateClass([
|
|
1473
|
+
gdsCustomElement("gds-menu-heading")
|
|
1474
|
+
], GdsMenuHeading);
|
|
1475
|
+
|
|
1594
1476
|
// libs/core/src/components/context-menu/context-menu.ts
|
|
1595
1477
|
import { nothing } from "lit";
|
|
1596
1478
|
import { msg as msg3 } from "@lit/localize";
|
|
@@ -1616,7 +1498,7 @@ var GdsMenu = class extends GdsElement {
|
|
|
1616
1498
|
if (!this.#slotRef.value)
|
|
1617
1499
|
return [];
|
|
1618
1500
|
return unwrap(this.#slotRef.value).assignedElements().filter(
|
|
1619
|
-
(o) => !o.hasAttribute("isplaceholder")
|
|
1501
|
+
(o) => !o.hasAttribute("isplaceholder") && o.gdsElementName === "gds-menu-item"
|
|
1620
1502
|
) || [];
|
|
1621
1503
|
}
|
|
1622
1504
|
/**
|
|
@@ -1688,7 +1570,7 @@ var GdsContextMenu = class extends GdsElement {
|
|
|
1688
1570
|
aria-label=${this.label ?? this.buttonLabel}
|
|
1689
1571
|
@gds-menu-item-click=${__privateMethod(this, _handleItemClick, handleItemClick_fn)}
|
|
1690
1572
|
>
|
|
1691
|
-
<slot allow="gds-menu-item"></slot>
|
|
1573
|
+
<slot allow="gds-menu-item gds-menu-heading"></slot>
|
|
1692
1574
|
</gds-menu>
|
|
1693
1575
|
</gds-popover>`;
|
|
1694
1576
|
}
|
|
@@ -1779,7 +1661,7 @@ import { nothing as nothing2 } from "lit";
|
|
|
1779
1661
|
import { msg as msg5 } from "@lit/localize";
|
|
1780
1662
|
|
|
1781
1663
|
// libs/core/src/primitives/calendar/calendar.ts
|
|
1782
|
-
import { html as
|
|
1664
|
+
import { html as html7 } from "lit";
|
|
1783
1665
|
import { classMap as classMap4 } from "lit/directives/class-map.js";
|
|
1784
1666
|
import { when as when3 } from "lit/directives/when.js";
|
|
1785
1667
|
import { property as property7, query as query2, state as state8 } from "lit/decorators.js";
|
|
@@ -1801,7 +1683,7 @@ import {
|
|
|
1801
1683
|
eachWeekOfInterval,
|
|
1802
1684
|
eachDayOfInterval
|
|
1803
1685
|
} from "date-fns";
|
|
1804
|
-
import { html as
|
|
1686
|
+
import { html as html6 } from "lit-html";
|
|
1805
1687
|
function renderMonthGridView(date, template) {
|
|
1806
1688
|
const monthStart = startOfMonth(date);
|
|
1807
1689
|
const monthEnd = endOfMonth(date);
|
|
@@ -1809,7 +1691,7 @@ function renderMonthGridView(date, template) {
|
|
|
1809
1691
|
{ start: monthStart, end: monthEnd },
|
|
1810
1692
|
{ weekStartsOn: 1 }
|
|
1811
1693
|
);
|
|
1812
|
-
return
|
|
1694
|
+
return html6`${template(
|
|
1813
1695
|
weeks.map((weekStartDay) => ({
|
|
1814
1696
|
days: eachDayOfInterval({
|
|
1815
1697
|
start: weekStartDay,
|
|
@@ -1820,8 +1702,8 @@ function renderMonthGridView(date, template) {
|
|
|
1820
1702
|
}
|
|
1821
1703
|
|
|
1822
1704
|
// libs/core/src/primitives/calendar/calendar.styles.ts
|
|
1823
|
-
import { css as
|
|
1824
|
-
var
|
|
1705
|
+
import { css as css6 } from "lit";
|
|
1706
|
+
var style6 = css6`
|
|
1825
1707
|
@layer base, reset, transitional-styles;
|
|
1826
1708
|
@layer base {
|
|
1827
1709
|
td.disabled {
|
|
@@ -1833,7 +1715,7 @@ var style5 = css5`
|
|
|
1833
1715
|
}
|
|
1834
1716
|
}
|
|
1835
1717
|
`;
|
|
1836
|
-
var calendar_styles_default =
|
|
1718
|
+
var calendar_styles_default = style6;
|
|
1837
1719
|
|
|
1838
1720
|
// libs/core/src/primitives/calendar/calendar.ts
|
|
1839
1721
|
var _setSelectedDate, setSelectedDate_fn, _handleKeyDown, handleKeyDown_fn;
|
|
@@ -1877,11 +1759,11 @@ var GdsCalendar = class extends GdsElement {
|
|
|
1877
1759
|
}
|
|
1878
1760
|
render() {
|
|
1879
1761
|
const currentDate = /* @__PURE__ */ new Date();
|
|
1880
|
-
return
|
|
1762
|
+
return html7`${this._tStyles}
|
|
1881
1763
|
<table>
|
|
1882
1764
|
<thead>
|
|
1883
1765
|
<tr>
|
|
1884
|
-
${when3(this.showWeekNumbers, () =>
|
|
1766
|
+
${when3(this.showWeekNumbers, () => html7`<th></th>`)}
|
|
1885
1767
|
<th>${msg4("Mon")}</th>
|
|
1886
1768
|
<th>${msg4("Tue")}</th>
|
|
1887
1769
|
<th>${msg4("Wed")}</th>
|
|
@@ -1894,19 +1776,19 @@ var GdsCalendar = class extends GdsElement {
|
|
|
1894
1776
|
<tbody>
|
|
1895
1777
|
${renderMonthGridView(
|
|
1896
1778
|
this.focusedDate,
|
|
1897
|
-
(weeks) =>
|
|
1779
|
+
(weeks) => html7`
|
|
1898
1780
|
${weeks.map(
|
|
1899
|
-
(week) =>
|
|
1781
|
+
(week) => html7`
|
|
1900
1782
|
<tr>
|
|
1901
1783
|
${when3(
|
|
1902
1784
|
this.showWeekNumbers,
|
|
1903
|
-
() =>
|
|
1785
|
+
() => html7`<td class="week-number">
|
|
1904
1786
|
${getWeek(week.days[0])}
|
|
1905
1787
|
</td>`
|
|
1906
1788
|
)}
|
|
1907
1789
|
${week.days.map((day) => {
|
|
1908
1790
|
const isDisabled = !isSameMonth(this.focusedDate, day) || day < this.min || day > this.max;
|
|
1909
|
-
return
|
|
1791
|
+
return html7`
|
|
1910
1792
|
<td
|
|
1911
1793
|
class="${classMap4({
|
|
1912
1794
|
disabled: isDisabled,
|
|
@@ -2040,10 +1922,10 @@ GdsCalendar = __decorateClass([
|
|
|
2040
1922
|
], GdsCalendar);
|
|
2041
1923
|
|
|
2042
1924
|
// libs/core/src/components/datepicker/date-part-spinner.ts
|
|
2043
|
-
import { LitElement as
|
|
1925
|
+
import { LitElement as LitElement6 } from "lit";
|
|
2044
1926
|
import { property as property8, state as state9 } from "lit/decorators.js";
|
|
2045
1927
|
var _inputBuffer, _increment, _decrement, _handleClick, _handleFocus, _handleBlur, _handleWheel, _handleKeyDown2, _focusNextSpinner, focusNextSpinner_fn, _dispatchChangeEvent, dispatchChangeEvent_fn, _formatNumber, formatNumber_fn, _clamp, clamp_fn, _clearInputBuffer, clearInputBuffer_fn;
|
|
2046
|
-
var GdsDatePartSpinner = class extends
|
|
1928
|
+
var GdsDatePartSpinner = class extends LitElement6 {
|
|
2047
1929
|
constructor() {
|
|
2048
1930
|
super(...arguments);
|
|
2049
1931
|
__privateAdd(this, _focusNextSpinner);
|
|
@@ -2085,7 +1967,6 @@ var GdsDatePartSpinner = class extends LitElement7 {
|
|
|
2085
1967
|
__privateMethod(this, _clearInputBuffer, clearInputBuffer_fn).call(this);
|
|
2086
1968
|
this.value = __privateMethod(this, _clamp, clamp_fn).call(this, parseInt(this.value.toString()));
|
|
2087
1969
|
__privateMethod(this, _dispatchChangeEvent, dispatchChangeEvent_fn).call(this);
|
|
2088
|
-
document.getSelection()?.removeAllRanges();
|
|
2089
1970
|
});
|
|
2090
1971
|
__privateAdd(this, _handleWheel, (e) => {
|
|
2091
1972
|
e.stopPropagation();
|
|
@@ -2216,8 +2097,8 @@ GdsDatePartSpinner = __decorateClass([
|
|
|
2216
2097
|
], GdsDatePartSpinner);
|
|
2217
2098
|
|
|
2218
2099
|
// libs/core/src/components/datepicker/datepicker.styles.ts
|
|
2219
|
-
import { css as
|
|
2220
|
-
var styles =
|
|
2100
|
+
import { css as css7 } from "lit";
|
|
2101
|
+
var styles = css7`
|
|
2221
2102
|
@layer base, reset, transitional-styles;
|
|
2222
2103
|
@layer base {
|
|
2223
2104
|
label {
|
|
@@ -2235,7 +2116,7 @@ var dateConverter = {
|
|
|
2235
2116
|
return value.toISOString();
|
|
2236
2117
|
}
|
|
2237
2118
|
};
|
|
2238
|
-
var _valueOnOpen, _renderBackToValidRangeButton, renderBackToValidRangeButton_fn, _focusDate, focusDate_fn, _getSpinnerLabel, getSpinnerLabel_fn, _getMinSpinnerValue, getMinSpinnerValue_fn, _getMaxSpinnerValue, getMaxSpinnerValue_fn, _dispatchChangeEvent2, dispatchChangeEvent_fn2, _handleClipboardCopy, _handleClipboardPaste, _handleFieldClick, _handleCalendarChange, _handleMonthChange, _handleYearChange, _handleIncrementFocusedMonth, _handleDecrementFocusedMonth, _handleCalendarFocusChange, _handlePopoverStateChange, _handleSpinnerKeydown, _parseDateFormat, parseDateFormat_fn, _handleSpinnerChange, _spinnerState, _years, years_get, _isValueOutsideRange, isValueOutsideRange_get;
|
|
2119
|
+
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;
|
|
2239
2120
|
var GdsDatepicker = class extends GdsFormControlElement {
|
|
2240
2121
|
constructor() {
|
|
2241
2122
|
super(...arguments);
|
|
@@ -2245,6 +2126,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
|
|
|
2245
2126
|
__privateAdd(this, _getMinSpinnerValue);
|
|
2246
2127
|
__privateAdd(this, _getMaxSpinnerValue);
|
|
2247
2128
|
__privateAdd(this, _dispatchChangeEvent2);
|
|
2129
|
+
__privateAdd(this, _dispatchInputEvent);
|
|
2248
2130
|
/**
|
|
2249
2131
|
* Takes a dateformat string from the dateformat attribute and turnes it to a DateFormatLayout object used in rendering the template.
|
|
2250
2132
|
*/
|
|
@@ -2263,24 +2145,48 @@ var GdsDatepicker = class extends GdsFormControlElement {
|
|
|
2263
2145
|
this._focusedYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
2264
2146
|
this._dateFormatLayout = __privateMethod(this, _parseDateFormat, parseDateFormat_fn).call(this, "y-m-d");
|
|
2265
2147
|
__privateAdd(this, _valueOnOpen, void 0);
|
|
2148
|
+
__privateAdd(this, _handleFieldFocusOut, (e) => {
|
|
2149
|
+
this._elTrigger.then((_) => {
|
|
2150
|
+
const parent = e.relatedTarget?.parentElement;
|
|
2151
|
+
if (parent === e.target)
|
|
2152
|
+
return;
|
|
2153
|
+
document.getSelection()?.removeAllRanges();
|
|
2154
|
+
});
|
|
2155
|
+
});
|
|
2156
|
+
__privateAdd(this, _handleSpinnerFocus, (e) => {
|
|
2157
|
+
this._elTrigger.then((field) => {
|
|
2158
|
+
document.getSelection()?.removeAllRanges();
|
|
2159
|
+
const range = new Range();
|
|
2160
|
+
range.setStart(field.firstChild, 0);
|
|
2161
|
+
range.setEnd(field.lastChild, 4);
|
|
2162
|
+
document.getSelection()?.addRange(range);
|
|
2163
|
+
});
|
|
2164
|
+
});
|
|
2266
2165
|
__privateAdd(this, _handleClipboardCopy, (e) => {
|
|
2267
|
-
|
|
2268
|
-
|
|
2166
|
+
this._elTrigger.then((field) => {
|
|
2167
|
+
if (e.currentTarget !== field)
|
|
2168
|
+
return;
|
|
2169
|
+
e.preventDefault();
|
|
2170
|
+
e.clipboardData?.setData("text/plain", this.displayValue);
|
|
2171
|
+
});
|
|
2269
2172
|
});
|
|
2270
2173
|
__privateAdd(this, _handleClipboardPaste, (e) => {
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2174
|
+
this._elTrigger.then((field) => {
|
|
2175
|
+
if (e.currentTarget !== field)
|
|
2176
|
+
return;
|
|
2177
|
+
e.preventDefault();
|
|
2178
|
+
const pasted = e.clipboardData?.getData("text/plain");
|
|
2179
|
+
if (!pasted)
|
|
2180
|
+
return;
|
|
2181
|
+
const pastedDate = new Date(pasted);
|
|
2182
|
+
if (pastedDate.toString() === "Invalid Date")
|
|
2183
|
+
return;
|
|
2184
|
+
this.value = pastedDate;
|
|
2185
|
+
__privateMethod(this, _dispatchChangeEvent2, dispatchChangeEvent_fn2).call(this);
|
|
2186
|
+
});
|
|
2280
2187
|
});
|
|
2281
2188
|
__privateAdd(this, _handleFieldClick, (e) => {
|
|
2282
2189
|
this._elSpinners[0].focus();
|
|
2283
|
-
window.getSelection()?.selectAllChildren(this._elSpinners[0]);
|
|
2284
2190
|
});
|
|
2285
2191
|
__privateAdd(this, _handleCalendarChange, (e) => {
|
|
2286
2192
|
e.stopPropagation();
|
|
@@ -2315,15 +2221,18 @@ var GdsDatepicker = class extends GdsFormControlElement {
|
|
|
2315
2221
|
this._focusedYear = (await this._elCalendar).focusedYear;
|
|
2316
2222
|
this.value = (await this._elCalendar).focusedDate;
|
|
2317
2223
|
this.requestUpdate();
|
|
2318
|
-
__privateMethod(this,
|
|
2224
|
+
__privateMethod(this, _dispatchInputEvent, dispatchInputEvent_fn).call(this);
|
|
2319
2225
|
});
|
|
2320
|
-
__privateAdd(this, _handlePopoverStateChange, (e) => {
|
|
2226
|
+
__privateAdd(this, _handlePopoverStateChange, async (e) => {
|
|
2321
2227
|
if (e.target !== e.currentTarget)
|
|
2322
2228
|
return;
|
|
2323
2229
|
this.open = e.detail.open;
|
|
2230
|
+
if (e.detail.reason === "close") {
|
|
2231
|
+
this.value = (await this._elCalendar).focusedDate;
|
|
2232
|
+
__privateMethod(this, _dispatchChangeEvent2, dispatchChangeEvent_fn2).call(this);
|
|
2233
|
+
}
|
|
2324
2234
|
if (e.detail.reason === "cancel") {
|
|
2325
2235
|
this.value = __privateGet(this, _valueOnOpen);
|
|
2326
|
-
__privateMethod(this, _dispatchChangeEvent2, dispatchChangeEvent_fn2).call(this);
|
|
2327
2236
|
}
|
|
2328
2237
|
});
|
|
2329
2238
|
__privateAdd(this, _handleSpinnerKeydown, (e) => {
|
|
@@ -2407,7 +2316,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
|
|
|
2407
2316
|
@copy=${__privateGet(this, _handleClipboardCopy)}
|
|
2408
2317
|
@paste=${__privateGet(this, _handleClipboardPaste)}
|
|
2409
2318
|
>
|
|
2410
|
-
<div class="input">
|
|
2319
|
+
<div class="input" @focusout=${__privateGet(this, _handleFieldFocusOut)}>
|
|
2411
2320
|
${join(
|
|
2412
2321
|
map(
|
|
2413
2322
|
this._dateFormatLayout.layout,
|
|
@@ -2421,6 +2330,7 @@ var GdsDatepicker = class extends GdsFormControlElement {
|
|
|
2421
2330
|
aria-describedby="label"
|
|
2422
2331
|
@keydown=${__privateGet(this, _handleSpinnerKeydown)}
|
|
2423
2332
|
@change=${(e) => __privateGet(this, _handleSpinnerChange).call(this, e.detail.value, f.name)}
|
|
2333
|
+
@focus=${__privateGet(this, _handleSpinnerFocus)}
|
|
2424
2334
|
></gds-date-part-spinner>`
|
|
2425
2335
|
),
|
|
2426
2336
|
html`<span>${this._dateFormatLayout.delimiter}</span>`
|
|
@@ -2621,6 +2531,16 @@ dispatchChangeEvent_fn2 = function() {
|
|
|
2621
2531
|
})
|
|
2622
2532
|
);
|
|
2623
2533
|
};
|
|
2534
|
+
_dispatchInputEvent = new WeakSet();
|
|
2535
|
+
dispatchInputEvent_fn = function() {
|
|
2536
|
+
this.dispatchEvent(
|
|
2537
|
+
new CustomEvent("input", {
|
|
2538
|
+
detail: { value: this.value }
|
|
2539
|
+
})
|
|
2540
|
+
);
|
|
2541
|
+
};
|
|
2542
|
+
_handleFieldFocusOut = new WeakMap();
|
|
2543
|
+
_handleSpinnerFocus = new WeakMap();
|
|
2624
2544
|
_handleClipboardCopy = new WeakMap();
|
|
2625
2545
|
_handleClipboardPaste = new WeakMap();
|
|
2626
2546
|
_handleFieldClick = new WeakMap();
|
|
@@ -2737,6 +2657,7 @@ export {
|
|
|
2737
2657
|
GdsContextMenu,
|
|
2738
2658
|
GdsDatepicker,
|
|
2739
2659
|
GdsDropdown,
|
|
2660
|
+
GdsMenuHeading,
|
|
2740
2661
|
GdsMenuItem,
|
|
2741
2662
|
GdsOption,
|
|
2742
2663
|
VER_SUFFIX,
|
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
|
+
"version": "1.6.0",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
7
7
|
"type": "module",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"directory": "../../dist/libs/core/src"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@floating-ui/dom": "^1.
|
|
25
|
+
"@floating-ui/dom": "^1.6.1",
|
|
26
26
|
"@lit/localize": "0.11.4",
|
|
27
|
+
"date-fns": "^2.28.0",
|
|
27
28
|
"lit": "^2.8.0",
|
|
28
|
-
"reflect-metadata": "^0.1.13"
|
|
29
|
-
"date-fns": "^2.28.0"
|
|
29
|
+
"reflect-metadata": "^0.1.13"
|
|
30
30
|
},
|
|
31
31
|
"exports": {
|
|
32
32
|
".": {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
1
|
import { GdsElement } from '../../gds-element';
|
|
3
2
|
import 'reflect-metadata';
|
|
4
3
|
export interface OptionsContainer extends HTMLElement {
|
|
5
4
|
options: GdsOption[];
|
|
6
5
|
multiple: boolean;
|
|
7
6
|
}
|
|
8
|
-
declare const GdsOption_base: (new (...args: any[]) => LitElement) & typeof GdsElement;
|
|
7
|
+
declare const GdsOption_base: (new (...args: any[]) => import("lit").LitElement) & typeof GdsElement;
|
|
9
8
|
/**
|
|
10
9
|
* @element gds-option
|
|
11
10
|
* @internal
|
package/transitional-styles.js
CHANGED
|
@@ -146,10 +146,32 @@ var option_trans_styles_default = `/**
|
|
|
146
146
|
}
|
|
147
147
|
}`;
|
|
148
148
|
|
|
149
|
+
// libs/core/src/primitives/menu/menu-heading.trans.styles.scss
|
|
150
|
+
var menu_heading_trans_styles_default = `@layer base, reset, transitional-styles;
|
|
151
|
+
@layer transitional-styles {
|
|
152
|
+
:host {
|
|
153
|
+
padding: 0.5rem 1rem;
|
|
154
|
+
background-color: var(--gds-ref-pallet-base100);
|
|
155
|
+
color: var(--gds-ref-pallet-base800);
|
|
156
|
+
display: flex;
|
|
157
|
+
-webkit-user-select: none;
|
|
158
|
+
-moz-user-select: none;
|
|
159
|
+
user-select: none;
|
|
160
|
+
font-size: 0.875rem;
|
|
161
|
+
}
|
|
162
|
+
:host([aria-hidden=true]) {
|
|
163
|
+
display: none;
|
|
164
|
+
}
|
|
165
|
+
}`;
|
|
166
|
+
|
|
149
167
|
// libs/core/src/primitives/listbox/listbox.trans.styles.ts
|
|
150
168
|
function register() {
|
|
151
169
|
TransitionalStyles.instance.register("gds-listbox", listbox_trans_styles_default.toString());
|
|
152
170
|
TransitionalStyles.instance.register("gds-option", option_trans_styles_default.toString());
|
|
171
|
+
TransitionalStyles.instance.register(
|
|
172
|
+
"gds-menu-heading",
|
|
173
|
+
menu_heading_trans_styles_default.toString()
|
|
174
|
+
);
|
|
153
175
|
}
|
|
154
176
|
|
|
155
177
|
// libs/core/src/primitives/popover/popover.trans.styles.scss
|
|
@@ -1967,6 +1989,7 @@ a.button.tertiary.danger:focus-visible {
|
|
|
1967
1989
|
width: 2rem;
|
|
1968
1990
|
border-radius: 50%;
|
|
1969
1991
|
position: relative;
|
|
1992
|
+
--color: var(--gds-sys-color-base);
|
|
1970
1993
|
}
|
|
1971
1994
|
.close:not(:disabled):not(.disabled) > div::after, .close:not(:disabled):not(.disabled) > div::before {
|
|
1972
1995
|
height: 0.789375rem;
|
|
@@ -3071,16 +3094,22 @@ i.sg-icon.sg-icon-ellipsis::before {
|
|
|
3071
3094
|
outline-width: 0.125rem;
|
|
3072
3095
|
outline-offset: 0.125rem;
|
|
3073
3096
|
}
|
|
3097
|
+
.field .input::-moz-selection {
|
|
3098
|
+
background: transparent;
|
|
3099
|
+
}
|
|
3100
|
+
.field .input::selection {
|
|
3101
|
+
background: transparent;
|
|
3102
|
+
}
|
|
3074
3103
|
.field span {
|
|
3075
|
-
cursor:
|
|
3104
|
+
cursor: text;
|
|
3076
3105
|
}
|
|
3077
3106
|
.field [role=spinbutton] {
|
|
3078
|
-
cursor:
|
|
3107
|
+
cursor: text;
|
|
3079
3108
|
display: inline-block;
|
|
3080
3109
|
}
|
|
3081
3110
|
.field [role=spinbutton]:focus {
|
|
3082
|
-
background: color-mix(in srgb, var(--gds-sys-color-blue) 50%, transparent);
|
|
3083
3111
|
outline: none;
|
|
3112
|
+
background: color-mix(in srgb, var(--gds-sys-color-blue) 50%, transparent);
|
|
3084
3113
|
}
|
|
3085
3114
|
.field [role=spinbutton]::-moz-selection {
|
|
3086
3115
|
background: transparent;
|
|
@@ -3215,7 +3244,7 @@ function register6() {
|
|
|
3215
3244
|
// libs/core/src/utils/helpers/custom-element-scoping.ts
|
|
3216
3245
|
import { html as litHtml } from "lit";
|
|
3217
3246
|
import { customElement } from "lit/decorators.js";
|
|
3218
|
-
var VER_SUFFIX = "-
|
|
3247
|
+
var VER_SUFFIX = "-f9a04d";
|
|
3219
3248
|
var elementLookupTable = /* @__PURE__ */ new Map();
|
|
3220
3249
|
var templateCache = /* @__PURE__ */ new WeakMap();
|
|
3221
3250
|
function applyElementScoping(strings, ...values) {
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Temporary implemenation of topLayerOverTransforms middleware snagged from here: https://github.com/floating-ui/floating-ui/issues/1842
|
|
3
|
-
*
|
|
4
|
-
* This solved positioning issues when a popover is opened from a parent element that is using transforms.
|
|
5
|
-
*
|
|
6
|
-
* As soon as this is merged in FloatingUI we can remove this and use the official version.
|
|
7
|
-
*/
|
|
8
|
-
export declare const topLayerOverTransforms: () => {
|
|
9
|
-
name: string;
|
|
10
|
-
fn(middlewareArguments: any): Promise<{
|
|
11
|
-
x: any;
|
|
12
|
-
y: any;
|
|
13
|
-
data: {
|
|
14
|
-
x: number;
|
|
15
|
-
y: number;
|
|
16
|
-
};
|
|
17
|
-
}>;
|
|
18
|
-
};
|
|
19
|
-
export declare function isLastTraversableNode(node: any): boolean;
|
|
20
|
-
export declare function getUAString(): any;
|
|
21
|
-
export declare function getParentNode(node: any): any;
|
|
22
|
-
export declare function getNodeName(node: any): any;
|
|
23
|
-
export declare function getDocumentElement(node: any): any;
|
|
24
|
-
export declare function isNode(value: any): boolean;
|
|
25
|
-
export declare function isWindow(value: any): any;
|
|
26
|
-
export declare function getWindow(node: any): any;
|
|
27
|
-
export declare function isShadowRoot(node: any): boolean;
|
|
28
|
-
export declare function isHTMLElement(value: any): boolean;
|