@sebgroup/green-core 1.0.0-beta.14 → 1.0.0-beta.15
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 +158 -52
- package/package.json +1 -1
- package/primitives/popover/popover.d.ts +6 -1
- package/transitional-styles.js +133 -11
- package/utils/decorators/index.d.ts +1 -0
- package/utils/decorators/watch-media-query.d.ts +31 -0
package/index.js
CHANGED
|
@@ -37,7 +37,7 @@ import { property as property5 } from "lit/decorators.js";
|
|
|
37
37
|
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
38
38
|
import { when as when2 } from "lit/directives/when.js";
|
|
39
39
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
40
|
-
import { createRef as
|
|
40
|
+
import { createRef as createRef3, ref as ref3 } from "lit/directives/ref.js";
|
|
41
41
|
import { msg, str, updateWhenLocaleChanges } from "@lit/localize";
|
|
42
42
|
import "reflect-metadata";
|
|
43
43
|
|
|
@@ -119,10 +119,31 @@ function observeLightDOM() {
|
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
// libs/core/src/utils/decorators/watch-media-query.ts
|
|
123
|
+
function watchMediaQuery(q) {
|
|
124
|
+
return (proto, _propertyKey, descriptor) => {
|
|
125
|
+
const mediaQuery = window.matchMedia(q);
|
|
126
|
+
const connectedCallback = proto.connectedCallback;
|
|
127
|
+
const disconnectedCallback = proto.disconnectedCallback;
|
|
128
|
+
proto.connectedCallback = function() {
|
|
129
|
+
connectedCallback?.call(this);
|
|
130
|
+
const listener = (e) => {
|
|
131
|
+
descriptor.value?.call(this, e.matches);
|
|
132
|
+
};
|
|
133
|
+
mediaQuery.addEventListener("change", listener);
|
|
134
|
+
this.disconnectedCallback = function() {
|
|
135
|
+
disconnectedCallback?.call(this);
|
|
136
|
+
mediaQuery.removeEventListener("change", listener);
|
|
137
|
+
};
|
|
138
|
+
descriptor.value?.call(this, mediaQuery.matches);
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
122
143
|
// libs/core/src/utils/helpers/custom-element-scoping.ts
|
|
123
144
|
import { html as litHtml } from "lit";
|
|
124
145
|
import { customElement } from "lit/decorators.js";
|
|
125
|
-
var VER_SUFFIX = "-
|
|
146
|
+
var VER_SUFFIX = "-700e99";
|
|
126
147
|
var elementLookupTable = /* @__PURE__ */ new Map();
|
|
127
148
|
var gdsCustomElement = (tagName) => {
|
|
128
149
|
if (globalThis.GDS_DISABLE_VERSIONED_ELEMENTS) {
|
|
@@ -530,6 +551,7 @@ GdsListbox = __decorateClass([
|
|
|
530
551
|
// libs/core/src/primitives/popover/popover.ts
|
|
531
552
|
import { LitElement as LitElement3, html as html3, unsafeCSS as unsafeCSS3 } from "lit";
|
|
532
553
|
import { property as property3 } from "lit/decorators.js";
|
|
554
|
+
import { createRef as createRef2, ref as ref2 } from "lit/directives/ref.js";
|
|
533
555
|
import { computePosition, autoUpdate, offset, flip } from "@floating-ui/dom";
|
|
534
556
|
|
|
535
557
|
// libs/core/src/primitives/popover/popover.styles.ts
|
|
@@ -540,19 +562,31 @@ var style3 = css3`
|
|
|
540
562
|
background-color: white;
|
|
541
563
|
box-shadow: 0 1rem 1rem 1rem rgba(0, 0, 0, 0.1);
|
|
542
564
|
}
|
|
565
|
+
|
|
566
|
+
dialog::backdrop {
|
|
567
|
+
pointer-events: none;
|
|
568
|
+
}
|
|
543
569
|
`;
|
|
544
570
|
var popover_styles_default = style3;
|
|
545
571
|
|
|
546
572
|
// libs/core/src/primitives/popover/popover.ts
|
|
547
|
-
var
|
|
573
|
+
var _dialogElementRef, _handleCloseButton, _registerTriggerEvents, registerTriggerEvents_fn, _unregisterTriggerEvents, unregisterTriggerEvents_fn, _autoPositionCleanup, _registerAutoPositioning, registerAutoPositioning_fn, _triggerKeyDownListener, _focusFirstSlottedChild;
|
|
548
574
|
var GdsPopover = class extends LitElement3 {
|
|
549
575
|
constructor() {
|
|
550
576
|
super(...arguments);
|
|
551
577
|
__privateAdd(this, _registerTriggerEvents);
|
|
552
578
|
__privateAdd(this, _unregisterTriggerEvents);
|
|
553
|
-
__privateAdd(this,
|
|
579
|
+
__privateAdd(this, _registerAutoPositioning);
|
|
554
580
|
this.open = false;
|
|
555
581
|
this.trigger = void 0;
|
|
582
|
+
this.label = void 0;
|
|
583
|
+
__privateAdd(this, _dialogElementRef, createRef2());
|
|
584
|
+
__privateAdd(this, _handleCloseButton, (e) => {
|
|
585
|
+
e.stopPropagation();
|
|
586
|
+
e.preventDefault();
|
|
587
|
+
this.open = false;
|
|
588
|
+
setTimeout(() => this.trigger?.focus(), 250);
|
|
589
|
+
});
|
|
556
590
|
__privateAdd(this, _autoPositionCleanup, void 0);
|
|
557
591
|
/**
|
|
558
592
|
* ArrowDown on the trigger element will trigger the popover by default, and escape will close it.
|
|
@@ -560,16 +594,21 @@ var GdsPopover = class extends LitElement3 {
|
|
|
560
594
|
__privateAdd(this, _triggerKeyDownListener, (e) => {
|
|
561
595
|
if (e.key === "ArrowDown") {
|
|
562
596
|
e.preventDefault();
|
|
563
|
-
|
|
564
|
-
const firstSlottedChild = this.shadowRoot?.querySelector("slot")?.assignedElements()[0];
|
|
565
|
-
this.updateComplete.then(() => {
|
|
566
|
-
firstSlottedChild?.focus();
|
|
567
|
-
});
|
|
597
|
+
this.open = true;
|
|
568
598
|
}
|
|
569
599
|
if (e.key === "Escape") {
|
|
570
|
-
|
|
600
|
+
this.open = false;
|
|
571
601
|
}
|
|
572
602
|
});
|
|
603
|
+
/**
|
|
604
|
+
* Move focus to the first slotted child.
|
|
605
|
+
*/
|
|
606
|
+
__privateAdd(this, _focusFirstSlottedChild, () => {
|
|
607
|
+
const firstSlottedChild = this.shadowRoot?.querySelector("slot")?.assignedElements()[0];
|
|
608
|
+
this.updateComplete.then(() => {
|
|
609
|
+
firstSlottedChild?.focus();
|
|
610
|
+
});
|
|
611
|
+
});
|
|
573
612
|
}
|
|
574
613
|
_handleTriggerChanged() {
|
|
575
614
|
__privateMethod(this, _registerTriggerEvents, registerTriggerEvents_fn).call(this);
|
|
@@ -578,10 +617,10 @@ var GdsPopover = class extends LitElement3 {
|
|
|
578
617
|
super.connectedCallback();
|
|
579
618
|
TransitionalStyles.instance.apply(this, "gds-popover");
|
|
580
619
|
__privateMethod(this, _registerTriggerEvents, registerTriggerEvents_fn).call(this);
|
|
581
|
-
this.
|
|
620
|
+
this._handleOpenChange();
|
|
582
621
|
this.addEventListener("keydown", (e) => {
|
|
583
622
|
if (e.key === "Escape") {
|
|
584
|
-
|
|
623
|
+
this.open = false;
|
|
585
624
|
}
|
|
586
625
|
});
|
|
587
626
|
}
|
|
@@ -590,50 +629,86 @@ var GdsPopover = class extends LitElement3 {
|
|
|
590
629
|
__privateMethod(this, _unregisterTriggerEvents, unregisterTriggerEvents_fn).call(this);
|
|
591
630
|
}
|
|
592
631
|
render() {
|
|
593
|
-
return html3
|
|
632
|
+
return html3`<dialog ${ref2(__privateGet(this, _dialogElementRef))}>
|
|
633
|
+
<header>
|
|
634
|
+
<h2>${this.label}</h2>
|
|
635
|
+
<button class="close" @click=${__privateGet(this, _handleCloseButton)}>
|
|
636
|
+
<i></i>
|
|
637
|
+
</button>
|
|
638
|
+
</header>
|
|
639
|
+
<slot></slot>
|
|
640
|
+
</dialog>`;
|
|
594
641
|
}
|
|
595
|
-
|
|
642
|
+
_handleOpenChange() {
|
|
596
643
|
this.setAttribute("aria-hidden", String(!this.open));
|
|
597
644
|
this.hidden = !this.open;
|
|
645
|
+
this.updateComplete.then(() => {
|
|
646
|
+
if (this.open) {
|
|
647
|
+
__privateGet(this, _dialogElementRef).value?.showModal();
|
|
648
|
+
__privateGet(this, _focusFirstSlottedChild).call(this);
|
|
649
|
+
} else {
|
|
650
|
+
__privateGet(this, _dialogElementRef).value?.close();
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
this.dispatchEvent(
|
|
654
|
+
new CustomEvent("gds-ui-state", {
|
|
655
|
+
detail: { open: this.open },
|
|
656
|
+
bubbles: true,
|
|
657
|
+
composed: false
|
|
658
|
+
})
|
|
659
|
+
);
|
|
660
|
+
}
|
|
661
|
+
_handleMobileLayout(matches) {
|
|
662
|
+
var _a;
|
|
663
|
+
if (matches) {
|
|
664
|
+
(_a = __privateGet(this, _autoPositionCleanup)) == null ? void 0 : _a.call(this);
|
|
665
|
+
__privateGet(this, _dialogElementRef).value?.style.removeProperty("left");
|
|
666
|
+
__privateGet(this, _dialogElementRef).value?.style.removeProperty("top");
|
|
667
|
+
this.updateComplete.then(() => {
|
|
668
|
+
if (this.open)
|
|
669
|
+
__privateGet(this, _dialogElementRef).value?.showModal();
|
|
670
|
+
});
|
|
671
|
+
} else {
|
|
672
|
+
this.updateComplete.then(() => {
|
|
673
|
+
__privateMethod(this, _registerAutoPositioning, registerAutoPositioning_fn).call(this);
|
|
674
|
+
});
|
|
675
|
+
}
|
|
598
676
|
}
|
|
599
677
|
};
|
|
600
|
-
|
|
678
|
+
_dialogElementRef = new WeakMap();
|
|
679
|
+
_handleCloseButton = new WeakMap();
|
|
601
680
|
_registerTriggerEvents = new WeakSet();
|
|
602
681
|
registerTriggerEvents_fn = function() {
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
682
|
+
this.trigger?.addEventListener("keydown", __privateGet(this, _triggerKeyDownListener));
|
|
683
|
+
};
|
|
684
|
+
_unregisterTriggerEvents = new WeakSet();
|
|
685
|
+
unregisterTriggerEvents_fn = function() {
|
|
686
|
+
var _a;
|
|
687
|
+
this.trigger?.removeEventListener("keydown", __privateGet(this, _triggerKeyDownListener));
|
|
688
|
+
(_a = __privateGet(this, _autoPositionCleanup)) == null ? void 0 : _a.call(this);
|
|
689
|
+
};
|
|
690
|
+
_autoPositionCleanup = new WeakMap();
|
|
691
|
+
_registerAutoPositioning = new WeakSet();
|
|
692
|
+
registerAutoPositioning_fn = function() {
|
|
606
693
|
const referenceEl = this.trigger;
|
|
607
|
-
|
|
608
|
-
|
|
694
|
+
const floatingEl = __privateGet(this, _dialogElementRef).value;
|
|
695
|
+
if (!referenceEl || !floatingEl)
|
|
696
|
+
return;
|
|
697
|
+
__privateSet(this, _autoPositionCleanup, autoUpdate(referenceEl, floatingEl, () => {
|
|
698
|
+
computePosition(referenceEl, floatingEl, {
|
|
609
699
|
placement: "bottom-start",
|
|
610
700
|
middleware: [offset(8), flip()]
|
|
611
701
|
}).then(({ x, y }) => {
|
|
612
|
-
Object.assign(
|
|
702
|
+
Object.assign(floatingEl.style, {
|
|
613
703
|
left: `${x}px`,
|
|
614
|
-
top: `${y}px
|
|
704
|
+
top: `${y}px`,
|
|
705
|
+
minWidth: `${referenceEl.offsetWidth}px`
|
|
615
706
|
});
|
|
616
707
|
});
|
|
617
708
|
}));
|
|
618
709
|
};
|
|
619
|
-
_unregisterTriggerEvents = new WeakSet();
|
|
620
|
-
unregisterTriggerEvents_fn = function() {
|
|
621
|
-
var _a;
|
|
622
|
-
this.trigger?.removeEventListener("keydown", __privateGet(this, _triggerKeyDownListener));
|
|
623
|
-
(_a = __privateGet(this, _autoPositionCleanup)) == null ? void 0 : _a.call(this);
|
|
624
|
-
};
|
|
625
710
|
_triggerKeyDownListener = new WeakMap();
|
|
626
|
-
|
|
627
|
-
setOpen_fn = function(open) {
|
|
628
|
-
this.open = open;
|
|
629
|
-
this.dispatchEvent(
|
|
630
|
-
new CustomEvent("gds-ui-state", {
|
|
631
|
-
detail: { open },
|
|
632
|
-
bubbles: true,
|
|
633
|
-
composed: false
|
|
634
|
-
})
|
|
635
|
-
);
|
|
636
|
-
};
|
|
711
|
+
_focusFirstSlottedChild = new WeakMap();
|
|
637
712
|
GdsPopover.styles = unsafeCSS3(popover_styles_default);
|
|
638
713
|
__decorateClass([
|
|
639
714
|
property3({ type: Boolean, reflect: true })
|
|
@@ -641,12 +716,18 @@ __decorateClass([
|
|
|
641
716
|
__decorateClass([
|
|
642
717
|
property3()
|
|
643
718
|
], GdsPopover.prototype, "trigger", 2);
|
|
719
|
+
__decorateClass([
|
|
720
|
+
property3()
|
|
721
|
+
], GdsPopover.prototype, "label", 2);
|
|
644
722
|
__decorateClass([
|
|
645
723
|
watch("trigger")
|
|
646
724
|
], GdsPopover.prototype, "_handleTriggerChanged", 1);
|
|
647
725
|
__decorateClass([
|
|
648
726
|
watch("open")
|
|
649
|
-
], GdsPopover.prototype, "
|
|
727
|
+
], GdsPopover.prototype, "_handleOpenChange", 1);
|
|
728
|
+
__decorateClass([
|
|
729
|
+
watchMediaQuery("(max-width: 576px)")
|
|
730
|
+
], GdsPopover.prototype, "_handleMobileLayout", 1);
|
|
650
731
|
GdsPopover = __decorateClass([
|
|
651
732
|
gdsCustomElement("gds-popover")
|
|
652
733
|
], GdsPopover);
|
|
@@ -763,7 +844,7 @@ var style4 = css4`
|
|
|
763
844
|
var dropdown_styles_default = style4;
|
|
764
845
|
|
|
765
846
|
// libs/core/src/components/dropdown/dropdown.ts
|
|
766
|
-
var _listboxRef, _triggerRef, _searchInputRef, _optionElements, _listboxId, _triggerId, _handleSearchFieldKeyUp, _handleSearchFieldKeyDown, _handleOptionFocusChange, _registerPopoverTrigger, registerPopoverTrigger_fn, _handleSelectionChange, handleSelectionChange_fn, _registerAutoCloseListener, registerAutoCloseListener_fn, _unregisterAutoCloseListener, unregisterAutoCloseListener_fn, _autoCloseListener;
|
|
847
|
+
var _listboxRef, _triggerRef, _searchInputRef, _optionElements, _listboxId, _triggerId, _handleSearchFieldKeyUp, _handleSearchFieldKeyDown, _handleListboxKeyDown, _handleOptionFocusChange, _registerPopoverTrigger, registerPopoverTrigger_fn, _handleSelectionChange, handleSelectionChange_fn, _registerAutoCloseListener, registerAutoCloseListener_fn, _unregisterAutoCloseListener, unregisterAutoCloseListener_fn, _autoCloseListener, _tabCloseListener;
|
|
767
848
|
var GdsDropdown = class extends GdsFormControlElement {
|
|
768
849
|
constructor() {
|
|
769
850
|
super();
|
|
@@ -786,9 +867,9 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
786
867
|
this.searchable = false;
|
|
787
868
|
this.multiple = false;
|
|
788
869
|
// Private members
|
|
789
|
-
__privateAdd(this, _listboxRef,
|
|
790
|
-
__privateAdd(this, _triggerRef,
|
|
791
|
-
__privateAdd(this, _searchInputRef,
|
|
870
|
+
__privateAdd(this, _listboxRef, createRef3());
|
|
871
|
+
__privateAdd(this, _triggerRef, createRef3());
|
|
872
|
+
__privateAdd(this, _searchInputRef, createRef3());
|
|
792
873
|
__privateAdd(this, _optionElements, void 0);
|
|
793
874
|
__privateAdd(this, _listboxId, randomId());
|
|
794
875
|
__privateAdd(this, _triggerId, randomId());
|
|
@@ -798,7 +879,7 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
798
879
|
* @param e The keyboard event.
|
|
799
880
|
*/
|
|
800
881
|
__privateAdd(this, _handleSearchFieldKeyUp, (e) => {
|
|
801
|
-
const input =
|
|
882
|
+
const input = __privateGet(this, _searchInputRef).value;
|
|
802
883
|
const options = Array.from(__privateGet(this, _optionElements));
|
|
803
884
|
options.forEach((o) => o.hidden = false);
|
|
804
885
|
if (!input.value)
|
|
@@ -809,15 +890,27 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
809
890
|
filteredOptions.forEach((o) => o.hidden = true);
|
|
810
891
|
});
|
|
811
892
|
/**
|
|
812
|
-
* Check for ArrowDown in the search field.
|
|
893
|
+
* Check for ArrowDown or Tab in the search field.
|
|
813
894
|
* If found, focus should be moved to the listbox.
|
|
814
895
|
*/
|
|
815
896
|
__privateAdd(this, _handleSearchFieldKeyDown, (e) => {
|
|
816
|
-
if (e.key === "ArrowDown") {
|
|
897
|
+
if (e.key === "ArrowDown" || e.key === "Tab") {
|
|
898
|
+
e.preventDefault();
|
|
817
899
|
__privateGet(this, _listboxRef).value?.focus();
|
|
818
900
|
return;
|
|
819
901
|
}
|
|
820
902
|
});
|
|
903
|
+
/**
|
|
904
|
+
* Check for Tab in the listbox.
|
|
905
|
+
* If found, focus should be moved to the search field.
|
|
906
|
+
*/
|
|
907
|
+
__privateAdd(this, _handleListboxKeyDown, (e) => {
|
|
908
|
+
if (e.key === "Tab" && this.searchable) {
|
|
909
|
+
e.preventDefault();
|
|
910
|
+
__privateGet(this, _searchInputRef).value?.focus();
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
});
|
|
821
914
|
__privateAdd(this, _handleOptionFocusChange, (e) => {
|
|
822
915
|
const triggerButton = __privateGet(this, _triggerRef).value;
|
|
823
916
|
if (triggerButton)
|
|
@@ -833,6 +926,13 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
833
926
|
if (isClickOutside || isFocusOutside)
|
|
834
927
|
this.open = false;
|
|
835
928
|
});
|
|
929
|
+
__privateAdd(this, _tabCloseListener, (e) => {
|
|
930
|
+
if (e.key === "Tab" && !this.searchable) {
|
|
931
|
+
e.preventDefault();
|
|
932
|
+
this.open = false;
|
|
933
|
+
__privateGet(this, _triggerRef).value?.focus();
|
|
934
|
+
}
|
|
935
|
+
});
|
|
836
936
|
constrainSlots(this);
|
|
837
937
|
updateWhenLocaleChanges(this);
|
|
838
938
|
__privateSet(this, _optionElements, this.getElementsByTagName(
|
|
@@ -897,7 +997,7 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
897
997
|
aria-owns="${__privateGet(this, _listboxId)}"
|
|
898
998
|
aria-controls="${__privateGet(this, _listboxId)}"
|
|
899
999
|
aria-expanded="${this.open}"
|
|
900
|
-
${
|
|
1000
|
+
${ref3(__privateGet(this, _triggerRef))}
|
|
901
1001
|
>
|
|
902
1002
|
<slot name="trigger">
|
|
903
1003
|
<span>${unsafeHTML(this.displayValue)}</span>
|
|
@@ -907,9 +1007,10 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
907
1007
|
<span class="form-info"><slot name="message"></slot></span>
|
|
908
1008
|
|
|
909
1009
|
<gds-popover
|
|
1010
|
+
.label=${this.label}
|
|
910
1011
|
.open=${this.open}
|
|
911
1012
|
@gds-ui-state=${(e) => this.open = e.detail.open}
|
|
912
|
-
${
|
|
1013
|
+
${ref3(__privateMethod(this, _registerPopoverTrigger, registerPopoverTrigger_fn))}
|
|
913
1014
|
>
|
|
914
1015
|
${when2(
|
|
915
1016
|
this.searchable,
|
|
@@ -917,7 +1018,7 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
917
1018
|
type="text"
|
|
918
1019
|
aria-label="${msg("Filter available options")}"
|
|
919
1020
|
placeholder="${msg("Search")}"
|
|
920
|
-
${
|
|
1021
|
+
${ref3(__privateGet(this, _searchInputRef))}
|
|
921
1022
|
@keydown=${__privateGet(this, _handleSearchFieldKeyDown)}
|
|
922
1023
|
@keyup=${__privateGet(this, _handleSearchFieldKeyUp)}
|
|
923
1024
|
/>`
|
|
@@ -926,9 +1027,10 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
926
1027
|
<gds-listbox
|
|
927
1028
|
id="${__privateGet(this, _listboxId)}"
|
|
928
1029
|
.multiple="${ifDefined(this.multiple)}"
|
|
929
|
-
${
|
|
1030
|
+
${ref3(__privateGet(this, _listboxRef))}
|
|
930
1031
|
@change="${__privateMethod(this, _handleSelectionChange, handleSelectionChange_fn)}"
|
|
931
1032
|
@gds-focus="${__privateGet(this, _handleOptionFocusChange)}"
|
|
1033
|
+
@keydown=${__privateGet(this, _handleListboxKeyDown)}
|
|
932
1034
|
>
|
|
933
1035
|
<slot gds-allow="gds-option"></slot>
|
|
934
1036
|
</gds-listbox>
|
|
@@ -960,12 +1062,12 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
960
1062
|
}
|
|
961
1063
|
_onOpenChange() {
|
|
962
1064
|
const open = this.open;
|
|
1065
|
+
Array.from(__privateGet(this, _optionElements)).forEach((o) => o.hidden = !open);
|
|
963
1066
|
if (open)
|
|
964
1067
|
__privateMethod(this, _registerAutoCloseListener, registerAutoCloseListener_fn).call(this);
|
|
965
1068
|
else {
|
|
966
1069
|
__privateMethod(this, _unregisterAutoCloseListener, unregisterAutoCloseListener_fn).call(this);
|
|
967
1070
|
__privateGet(this, _searchInputRef).value && (__privateGet(this, _searchInputRef).value.value = "");
|
|
968
|
-
Array.from(__privateGet(this, _optionElements)).forEach((o) => o.hidden = false);
|
|
969
1071
|
}
|
|
970
1072
|
this.dispatchEvent(
|
|
971
1073
|
new CustomEvent("gds-ui-state", {
|
|
@@ -984,6 +1086,7 @@ _listboxId = new WeakMap();
|
|
|
984
1086
|
_triggerId = new WeakMap();
|
|
985
1087
|
_handleSearchFieldKeyUp = new WeakMap();
|
|
986
1088
|
_handleSearchFieldKeyDown = new WeakMap();
|
|
1089
|
+
_handleListboxKeyDown = new WeakMap();
|
|
987
1090
|
_handleOptionFocusChange = new WeakMap();
|
|
988
1091
|
_registerPopoverTrigger = new WeakSet();
|
|
989
1092
|
registerPopoverTrigger_fn = function(el) {
|
|
@@ -1017,14 +1120,17 @@ registerAutoCloseListener_fn = function() {
|
|
|
1017
1120
|
window.addEventListener("click", __privateGet(this, _autoCloseListener));
|
|
1018
1121
|
this.addEventListener("blur", __privateGet(this, _autoCloseListener));
|
|
1019
1122
|
this.addEventListener("gds-blur", __privateGet(this, _autoCloseListener));
|
|
1123
|
+
this.addEventListener("keydown", __privateGet(this, _tabCloseListener));
|
|
1020
1124
|
};
|
|
1021
1125
|
_unregisterAutoCloseListener = new WeakSet();
|
|
1022
1126
|
unregisterAutoCloseListener_fn = function() {
|
|
1023
1127
|
window.removeEventListener("click", __privateGet(this, _autoCloseListener));
|
|
1024
1128
|
this.removeEventListener("blur", __privateGet(this, _autoCloseListener));
|
|
1025
1129
|
this.removeEventListener("gds-blur", __privateGet(this, _autoCloseListener));
|
|
1130
|
+
this.removeEventListener("keydown", __privateGet(this, _tabCloseListener));
|
|
1026
1131
|
};
|
|
1027
1132
|
_autoCloseListener = new WeakMap();
|
|
1133
|
+
_tabCloseListener = new WeakMap();
|
|
1028
1134
|
GdsDropdown.styles = dropdown_styles_default;
|
|
1029
1135
|
GdsDropdown.shadowRootOptions = {
|
|
1030
1136
|
mode: "open",
|
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.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.15",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
7
7
|
"type": "module",
|
|
@@ -23,9 +23,14 @@ export declare class GdsPopover extends LitElement {
|
|
|
23
23
|
* Optional trigger element for the popover.
|
|
24
24
|
*/
|
|
25
25
|
trigger: HTMLElement | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Optional trigger element for the popover.
|
|
28
|
+
*/
|
|
29
|
+
label: string | undefined;
|
|
26
30
|
private _handleTriggerChanged;
|
|
27
31
|
connectedCallback(): void;
|
|
28
32
|
disconnectedCallback(): void;
|
|
29
33
|
render(): import("lit-html").TemplateResult<1>;
|
|
30
|
-
private
|
|
34
|
+
private _handleOpenChange;
|
|
35
|
+
private _handleMobileLayout;
|
|
31
36
|
}
|
package/transitional-styles.js
CHANGED
|
@@ -21,6 +21,7 @@ var listbox_trans_styles_default = `
|
|
|
21
21
|
display: flex;
|
|
22
22
|
flex-direction: column;
|
|
23
23
|
list-style: none;
|
|
24
|
+
overflow-y: auto;
|
|
24
25
|
}
|
|
25
26
|
:host > li {
|
|
26
27
|
padding-bottom: 0.5rem;
|
|
@@ -1723,6 +1724,7 @@ a.button.tertiary.danger:focus {
|
|
|
1723
1724
|
cursor: pointer;
|
|
1724
1725
|
display: flex;
|
|
1725
1726
|
gap: 0.75rem;
|
|
1727
|
+
user-select: none;
|
|
1726
1728
|
}
|
|
1727
1729
|
:host:not(:disabled, .disabled, [aria-disabled]):hover {
|
|
1728
1730
|
background-color: #199be3;
|
|
@@ -3471,7 +3473,106 @@ a.button.tertiary.danger:focus {
|
|
|
3471
3473
|
outline-style: solid;
|
|
3472
3474
|
}
|
|
3473
3475
|
|
|
3474
|
-
|
|
3476
|
+
.close {
|
|
3477
|
+
/* smartphones, touchscreens */
|
|
3478
|
+
outline: none;
|
|
3479
|
+
font-size: 0;
|
|
3480
|
+
background: hsla(var(--background-hsl), 0);
|
|
3481
|
+
border: 0;
|
|
3482
|
+
border-radius: 50%;
|
|
3483
|
+
content: "";
|
|
3484
|
+
cursor: pointer;
|
|
3485
|
+
display: flex;
|
|
3486
|
+
font-family: inherit;
|
|
3487
|
+
height: 2rem;
|
|
3488
|
+
position: relative;
|
|
3489
|
+
width: 2rem;
|
|
3490
|
+
}
|
|
3491
|
+
@media (hover: none) and (pointer: coarse) {
|
|
3492
|
+
.close:not(:disabled):not(.disabled) {
|
|
3493
|
+
padding: 0.375rem;
|
|
3494
|
+
height: 2.75rem;
|
|
3495
|
+
width: 2.75rem;
|
|
3496
|
+
}
|
|
3497
|
+
.close:not(:disabled):not(.disabled) > i {
|
|
3498
|
+
background: var(--gds-ref-pallet-base200);
|
|
3499
|
+
height: 2rem;
|
|
3500
|
+
width: 2rem;
|
|
3501
|
+
border-radius: 50%;
|
|
3502
|
+
position: relative;
|
|
3503
|
+
}
|
|
3504
|
+
.close:not(:disabled):not(.disabled) > div::after, .close:not(:disabled):not(.disabled) > div::before {
|
|
3505
|
+
height: 0.789375rem;
|
|
3506
|
+
width: 0.130625rem;
|
|
3507
|
+
top: 0.625rem;
|
|
3508
|
+
}
|
|
3509
|
+
}
|
|
3510
|
+
.close:focus-visible > i {
|
|
3511
|
+
border-color: var(--gds-sys-color-blue-dark-2);
|
|
3512
|
+
box-shadow: 0 0 0.0625rem 0 var(--gds-sys-color-blue-dark-2), 0 0 0.25rem 0.0625rem var(--gds-sys-color-blue-dark-2);
|
|
3513
|
+
outline-color: transparent;
|
|
3514
|
+
outline-style: solid;
|
|
3515
|
+
}
|
|
3516
|
+
.close > i {
|
|
3517
|
+
border-radius: var(--gds-sys-shape-corner-round);
|
|
3518
|
+
display: block;
|
|
3519
|
+
width: 100%;
|
|
3520
|
+
height: 100%;
|
|
3521
|
+
}
|
|
3522
|
+
.close > i::after, .close > i::before {
|
|
3523
|
+
background: var(--gds-sys-color-font);
|
|
3524
|
+
content: "";
|
|
3525
|
+
display: block;
|
|
3526
|
+
height: 0.789375rem;
|
|
3527
|
+
width: 0.130625rem;
|
|
3528
|
+
border-radius: 0.5px;
|
|
3529
|
+
left: calc(50% - 0.0625rem);
|
|
3530
|
+
position: absolute;
|
|
3531
|
+
top: 0.625rem;
|
|
3532
|
+
}
|
|
3533
|
+
.close > i::after {
|
|
3534
|
+
transform: rotateZ(45deg);
|
|
3535
|
+
}
|
|
3536
|
+
.close > i::before {
|
|
3537
|
+
transform: rotateZ(-45deg);
|
|
3538
|
+
}
|
|
3539
|
+
.close > svg path {
|
|
3540
|
+
fill: var(--gds-sys-color-font);
|
|
3541
|
+
}
|
|
3542
|
+
@media (min-width: 768px) {
|
|
3543
|
+
.close:not(:disabled, .disabled):hover > i {
|
|
3544
|
+
background: var(--gds-ref-pallet-base200);
|
|
3545
|
+
}
|
|
3546
|
+
.close:not(:disabled, .disabled):hover:active > i {
|
|
3547
|
+
background: var(--gds-ref-pallet-base500);
|
|
3548
|
+
}
|
|
3549
|
+
}
|
|
3550
|
+
|
|
3551
|
+
:host([open]) dialog {
|
|
3552
|
+
opacity: 1;
|
|
3553
|
+
transform: translate3d(0, 0, 0);
|
|
3554
|
+
visibility: visible;
|
|
3555
|
+
}
|
|
3556
|
+
|
|
3557
|
+
header {
|
|
3558
|
+
border-bottom: 1px solid var(--border-color);
|
|
3559
|
+
display: flex;
|
|
3560
|
+
padding: 0.5rem 0.75rem;
|
|
3561
|
+
}
|
|
3562
|
+
@media (min-width: 576px) {
|
|
3563
|
+
header {
|
|
3564
|
+
display: none;
|
|
3565
|
+
}
|
|
3566
|
+
}
|
|
3567
|
+
|
|
3568
|
+
header h2 {
|
|
3569
|
+
flex-grow: 1;
|
|
3570
|
+
font-weight: 500;
|
|
3571
|
+
line-height: 1.5;
|
|
3572
|
+
margin: 0;
|
|
3573
|
+
}
|
|
3574
|
+
|
|
3575
|
+
dialog {
|
|
3475
3576
|
--z-index: var(--sg-z-index-popover);
|
|
3476
3577
|
max-height: calc(100% - 1rem);
|
|
3477
3578
|
background-color: var(--sg-popover-background);
|
|
@@ -3482,10 +3583,13 @@ a.button.tertiary.danger:focus {
|
|
|
3482
3583
|
position: fixed;
|
|
3483
3584
|
visibility: hidden;
|
|
3484
3585
|
z-index: var(--z-index);
|
|
3586
|
+
border-width: 0;
|
|
3485
3587
|
overflow: hidden;
|
|
3588
|
+
padding: 0;
|
|
3589
|
+
right: 0;
|
|
3486
3590
|
}
|
|
3487
3591
|
@media (max-width: 575.98px) {
|
|
3488
|
-
|
|
3592
|
+
dialog {
|
|
3489
3593
|
border-top: solid var(--sg-border-width) var(--sg-border-color);
|
|
3490
3594
|
--border-color: var(--sg-border-color);
|
|
3491
3595
|
padding-bottom: 0.5rem;
|
|
@@ -3499,7 +3603,7 @@ a.button.tertiary.danger:focus {
|
|
|
3499
3603
|
}
|
|
3500
3604
|
}
|
|
3501
3605
|
@media (min-width: 576px) {
|
|
3502
|
-
|
|
3606
|
+
dialog {
|
|
3503
3607
|
padding-bottom: 0;
|
|
3504
3608
|
border: solid var(--sg-border-width) var(--sg-border-color);
|
|
3505
3609
|
--border-color: var(--sg-popover-border-color);
|
|
@@ -3511,30 +3615,47 @@ a.button.tertiary.danger:focus {
|
|
|
3511
3615
|
position: absolute;
|
|
3512
3616
|
}
|
|
3513
3617
|
}
|
|
3514
|
-
|
|
3618
|
+
dialog > [role=listbox] {
|
|
3515
3619
|
width: 100%;
|
|
3516
3620
|
overflow-y: auto;
|
|
3517
3621
|
}
|
|
3518
|
-
|
|
3622
|
+
dialog.active {
|
|
3519
3623
|
opacity: 1;
|
|
3520
3624
|
transform: translate3d(0, 0, 0);
|
|
3521
3625
|
visibility: visible;
|
|
3522
3626
|
}
|
|
3523
|
-
|
|
3627
|
+
dialog .close {
|
|
3524
3628
|
margin: 0.25rem;
|
|
3525
3629
|
flex-shrink: 0;
|
|
3526
3630
|
align-self: flex-end;
|
|
3527
3631
|
}
|
|
3528
3632
|
@media (min-width: 576px) {
|
|
3529
|
-
|
|
3633
|
+
dialog .close {
|
|
3530
3634
|
display: none;
|
|
3531
3635
|
}
|
|
3532
3636
|
}
|
|
3637
|
+
@media (max-width: 575.98px) {
|
|
3638
|
+
dialog {
|
|
3639
|
+
border-radius: 1rem;
|
|
3640
|
+
}
|
|
3641
|
+
}
|
|
3642
|
+
@media (min-width: 576px) {
|
|
3643
|
+
dialog {
|
|
3644
|
+
inset: auto;
|
|
3645
|
+
position: absolute;
|
|
3646
|
+
}
|
|
3647
|
+
}
|
|
3533
3648
|
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3649
|
+
dialog::backdrop {
|
|
3650
|
+
background-color: rgba(0, 0, 0, 0.2);
|
|
3651
|
+
display: block;
|
|
3652
|
+
pointer-events: none;
|
|
3653
|
+
position: fixed;
|
|
3654
|
+
}
|
|
3655
|
+
@media (min-width: 576px) {
|
|
3656
|
+
dialog::backdrop {
|
|
3657
|
+
display: none;
|
|
3658
|
+
}
|
|
3538
3659
|
}`;
|
|
3539
3660
|
|
|
3540
3661
|
// libs/core/src/primitives/popover/popover.trans.styles.ts
|
|
@@ -5472,6 +5593,7 @@ input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner
|
|
|
5472
5593
|
|
|
5473
5594
|
input[type=text] {
|
|
5474
5595
|
border-radius: 0;
|
|
5596
|
+
font-size: 1rem;
|
|
5475
5597
|
line-height: 1;
|
|
5476
5598
|
margin: -1px;
|
|
5477
5599
|
min-height: auto;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { LitElement } from 'lit';
|
|
2
|
+
declare type Handler = (matches: boolean) => void;
|
|
3
|
+
/**
|
|
4
|
+
* Media queries expressing standard breakpoints.
|
|
5
|
+
* TODO: These should probably be imported from somehere, so that they are always in sync with CSS.
|
|
6
|
+
*/
|
|
7
|
+
export declare const standardBreakpoints: {
|
|
8
|
+
sm: string;
|
|
9
|
+
md: string;
|
|
10
|
+
lg: string;
|
|
11
|
+
xl: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Runs when the match state of the specified media query changes.
|
|
15
|
+
*
|
|
16
|
+
* @param q The media query to watch.
|
|
17
|
+
*
|
|
18
|
+
* Usage:
|
|
19
|
+
* ```javascript
|
|
20
|
+
* \@watchMediaQuery('(max-width: 576px)')
|
|
21
|
+
* handleMobileLayout(matches) {
|
|
22
|
+
* if (matches) {
|
|
23
|
+
* // Do something when the media query matches
|
|
24
|
+
* } else
|
|
25
|
+
* // Do something when the media query no longer matches
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function watchMediaQuery(q: string): <ElemClass extends LitElement>(proto: ElemClass, _propertyKey: string, descriptor: TypedPropertyDescriptor<Handler>) => void;
|
|
31
|
+
export {};
|