@sebgroup/green-core 1.4.4 → 1.4.6
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.
|
@@ -77,13 +77,6 @@ export declare class GdsDropdown<ValueT = any> extends GdsFormControlElement<Val
|
|
|
77
77
|
* are still readable and apply appropriate custom layout or truncation if neccecary.
|
|
78
78
|
*/
|
|
79
79
|
syncPopoverWidth: boolean;
|
|
80
|
-
private _tStyles?;
|
|
81
|
-
private elTriggerBtn;
|
|
82
|
-
private elTriggerBtnAsync;
|
|
83
|
-
private elListbox;
|
|
84
|
-
private elSearchInput;
|
|
85
|
-
constructor();
|
|
86
|
-
connectedCallback(): void;
|
|
87
80
|
/**
|
|
88
81
|
* Get the options of the dropdown.
|
|
89
82
|
*/
|
|
@@ -98,6 +91,13 @@ export declare class GdsDropdown<ValueT = any> extends GdsFormControlElement<Val
|
|
|
98
91
|
* If the dropdown is in multiple mode, this will be a comma separated list of the selected values.
|
|
99
92
|
*/
|
|
100
93
|
get displayValue(): string;
|
|
94
|
+
private _tStyles?;
|
|
95
|
+
private _elTriggerBtn;
|
|
96
|
+
private _elTriggerBtnAsync;
|
|
97
|
+
private _elListbox;
|
|
98
|
+
private _elSearchInput;
|
|
99
|
+
constructor();
|
|
100
|
+
connectedCallback(): void;
|
|
101
101
|
render(): any;
|
|
102
102
|
/**
|
|
103
103
|
* Update value assignment and request update when the light DOM changes.
|
package/index.js
CHANGED
|
@@ -94,9 +94,13 @@ function watch(propertyName, options) {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
// libs/core/src/utils/decorators/observe-light-dom.ts
|
|
97
|
-
function observeLightDOM(
|
|
97
|
+
function observeLightDOM(observerConfig = {
|
|
98
|
+
attributes: true,
|
|
99
|
+
childList: true,
|
|
100
|
+
subtree: false,
|
|
101
|
+
characterData: true
|
|
102
|
+
}) {
|
|
98
103
|
return (proto, _propertyKey, descriptor) => {
|
|
99
|
-
const observerConfig = { attributes: true, childList: true, subtree: false };
|
|
100
104
|
let observer;
|
|
101
105
|
const connectedCallback = proto.connectedCallback;
|
|
102
106
|
const disconnectedCallback = proto.disconnectedCallback;
|
|
@@ -139,7 +143,7 @@ function watchMediaQuery(q) {
|
|
|
139
143
|
// libs/core/src/utils/helpers/custom-element-scoping.ts
|
|
140
144
|
import { html as litHtml } from "lit";
|
|
141
145
|
import { customElement } from "lit/decorators.js";
|
|
142
|
-
var VER_SUFFIX = "-
|
|
146
|
+
var VER_SUFFIX = "-a568b5";
|
|
143
147
|
var elementLookupTable = /* @__PURE__ */ new Map();
|
|
144
148
|
var gdsCustomElement = (tagName) => {
|
|
145
149
|
if (globalThis.GDS_DISABLE_VERSIONED_ELEMENTS) {
|
|
@@ -1285,7 +1289,7 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
1285
1289
|
* @param e The keyboard event.
|
|
1286
1290
|
*/
|
|
1287
1291
|
__privateAdd(this, _handleSearchFieldKeyUp, (e) => {
|
|
1288
|
-
const input = this.
|
|
1292
|
+
const input = this._elSearchInput;
|
|
1289
1293
|
const options = Array.from(__privateGet(this, _optionElements));
|
|
1290
1294
|
options.forEach((o) => o.hidden = false);
|
|
1291
1295
|
if (!input.value)
|
|
@@ -1300,11 +1304,13 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
1300
1304
|
* If found, focus should be moved to the listbox.
|
|
1301
1305
|
*/
|
|
1302
1306
|
__privateAdd(this, _handleSearchFieldKeyDown, (e) => {
|
|
1303
|
-
|
|
1304
|
-
e.
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1307
|
+
this._elListbox?.then((listbox) => {
|
|
1308
|
+
if (e.key === "ArrowDown" || e.key === "Tab") {
|
|
1309
|
+
e.preventDefault();
|
|
1310
|
+
listbox.focus();
|
|
1311
|
+
return;
|
|
1312
|
+
}
|
|
1313
|
+
});
|
|
1308
1314
|
});
|
|
1309
1315
|
/**
|
|
1310
1316
|
* Check for Tab in the listbox.
|
|
@@ -1313,12 +1319,12 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
1313
1319
|
__privateAdd(this, _handleListboxKeyDown, (e) => {
|
|
1314
1320
|
if (e.key === "Tab" && this.searchable) {
|
|
1315
1321
|
e.preventDefault();
|
|
1316
|
-
this.
|
|
1322
|
+
this._elSearchInput?.focus();
|
|
1317
1323
|
return;
|
|
1318
1324
|
}
|
|
1319
1325
|
});
|
|
1320
1326
|
__privateAdd(this, _handleOptionFocusChange, (e) => {
|
|
1321
|
-
const triggerButton = this.
|
|
1327
|
+
const triggerButton = this._elTriggerBtn;
|
|
1322
1328
|
if (triggerButton)
|
|
1323
1329
|
triggerButton.ariaActiveDescendantElement = e.target;
|
|
1324
1330
|
});
|
|
@@ -1334,7 +1340,7 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
1334
1340
|
if (e.key === "Tab" && !this.searchable) {
|
|
1335
1341
|
e.preventDefault();
|
|
1336
1342
|
this.open = false;
|
|
1337
|
-
this.
|
|
1343
|
+
this._elTriggerBtn?.focus();
|
|
1338
1344
|
}
|
|
1339
1345
|
});
|
|
1340
1346
|
constrainSlots(this);
|
|
@@ -1343,14 +1349,6 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
1343
1349
|
getScopedTagName("gds-option")
|
|
1344
1350
|
));
|
|
1345
1351
|
}
|
|
1346
|
-
connectedCallback() {
|
|
1347
|
-
super.connectedCallback();
|
|
1348
|
-
TransitionalStyles.instance.apply(this, "gds-dropdown");
|
|
1349
|
-
this.updateComplete.then(() => {
|
|
1350
|
-
this._handleLightDOMChange();
|
|
1351
|
-
this._handleValueChange();
|
|
1352
|
-
});
|
|
1353
|
-
}
|
|
1354
1352
|
/**
|
|
1355
1353
|
* Get the options of the dropdown.
|
|
1356
1354
|
*/
|
|
@@ -1384,6 +1382,14 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
1384
1382
|
}
|
|
1385
1383
|
return displayValue || this.placeholder?.innerHTML || "";
|
|
1386
1384
|
}
|
|
1385
|
+
connectedCallback() {
|
|
1386
|
+
super.connectedCallback();
|
|
1387
|
+
TransitionalStyles.instance.apply(this, "gds-dropdown");
|
|
1388
|
+
this.updateComplete.then(() => {
|
|
1389
|
+
this._handleLightDOMChange();
|
|
1390
|
+
this._handleValueChange();
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1387
1393
|
render() {
|
|
1388
1394
|
return html`
|
|
1389
1395
|
${this._tStyles}
|
|
@@ -1413,7 +1419,7 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
1413
1419
|
<gds-popover
|
|
1414
1420
|
.label=${this.label}
|
|
1415
1421
|
.open=${this.open}
|
|
1416
|
-
.triggerRef=${this.
|
|
1422
|
+
.triggerRef=${this._elTriggerBtnAsync}
|
|
1417
1423
|
.calcMaxWidth=${(trigger) => this.syncPopoverWidth ? `${trigger.offsetWidth}px` : `auto`}
|
|
1418
1424
|
@gds-ui-state=${(e) => this.open = e.detail.open}
|
|
1419
1425
|
>
|
|
@@ -1444,27 +1450,31 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
1444
1450
|
}
|
|
1445
1451
|
_handleLightDOMChange() {
|
|
1446
1452
|
this.requestUpdate();
|
|
1447
|
-
this.
|
|
1448
|
-
|
|
1453
|
+
if (this.multiple) {
|
|
1454
|
+
this._handleValueChange();
|
|
1449
1455
|
return;
|
|
1456
|
+
}
|
|
1450
1457
|
if (!this.value) {
|
|
1451
1458
|
if (this.placeholder)
|
|
1452
1459
|
this.value = this.placeholder.value;
|
|
1453
1460
|
else
|
|
1454
1461
|
this.value = this.options[0]?.value;
|
|
1455
|
-
} else if (!this.placeholder && this.options.find(
|
|
1462
|
+
} else if (!this.placeholder && this.options.find(
|
|
1463
|
+
(o) => this.compareWith(o.value, this.value)
|
|
1464
|
+
) === void 0) {
|
|
1456
1465
|
this.options[0] && (this.options[0].selected = true);
|
|
1457
1466
|
this.value = this.options[0]?.value;
|
|
1458
1467
|
}
|
|
1459
1468
|
}
|
|
1460
1469
|
_handleValueChange() {
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1470
|
+
this._elListbox.then((listbox) => {
|
|
1471
|
+
if (listbox) {
|
|
1472
|
+
if (Array.isArray(this.value))
|
|
1473
|
+
listbox.selection = this.value;
|
|
1474
|
+
else
|
|
1475
|
+
listbox.selection = [this.value];
|
|
1476
|
+
}
|
|
1477
|
+
});
|
|
1468
1478
|
}
|
|
1469
1479
|
_onOpenChange() {
|
|
1470
1480
|
const open = this.open;
|
|
@@ -1473,7 +1483,7 @@ var GdsDropdown = class extends GdsFormControlElement {
|
|
|
1473
1483
|
__privateMethod(this, _registerAutoCloseListener, registerAutoCloseListener_fn).call(this);
|
|
1474
1484
|
else {
|
|
1475
1485
|
__privateMethod(this, _unregisterAutoCloseListener, unregisterAutoCloseListener_fn).call(this);
|
|
1476
|
-
this.
|
|
1486
|
+
this._elSearchInput && (this._elSearchInput.value = "");
|
|
1477
1487
|
}
|
|
1478
1488
|
this.dispatchEvent(
|
|
1479
1489
|
new CustomEvent("gds-ui-state", {
|
|
@@ -1491,23 +1501,22 @@ _handleListboxKeyDown = new WeakMap();
|
|
|
1491
1501
|
_handleOptionFocusChange = new WeakMap();
|
|
1492
1502
|
_handleSelectionChange = new WeakSet();
|
|
1493
1503
|
handleSelectionChange_fn = function() {
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
);
|
|
1504
|
+
this._elListbox.then((listbox) => {
|
|
1505
|
+
if (this.multiple)
|
|
1506
|
+
this.value = listbox.selection.map((s) => s.value);
|
|
1507
|
+
else {
|
|
1508
|
+
this.value = listbox.selection[0]?.value;
|
|
1509
|
+
this.open = false;
|
|
1510
|
+
setTimeout(() => this._elTriggerBtn?.focus(), 0);
|
|
1511
|
+
}
|
|
1512
|
+
this.dispatchEvent(
|
|
1513
|
+
new CustomEvent("change", {
|
|
1514
|
+
detail: { value: this.value },
|
|
1515
|
+
bubbles: true,
|
|
1516
|
+
composed: true
|
|
1517
|
+
})
|
|
1518
|
+
);
|
|
1519
|
+
});
|
|
1511
1520
|
};
|
|
1512
1521
|
_registerAutoCloseListener = new WeakSet();
|
|
1513
1522
|
registerAutoCloseListener_fn = function() {
|
|
@@ -1554,18 +1563,23 @@ __decorateClass([
|
|
|
1554
1563
|
], GdsDropdown.prototype, "_tStyles", 2);
|
|
1555
1564
|
__decorateClass([
|
|
1556
1565
|
query("#trigger")
|
|
1557
|
-
], GdsDropdown.prototype, "
|
|
1566
|
+
], GdsDropdown.prototype, "_elTriggerBtn", 2);
|
|
1558
1567
|
__decorateClass([
|
|
1559
1568
|
queryAsync("#trigger")
|
|
1560
|
-
], GdsDropdown.prototype, "
|
|
1569
|
+
], GdsDropdown.prototype, "_elTriggerBtnAsync", 2);
|
|
1561
1570
|
__decorateClass([
|
|
1562
|
-
|
|
1563
|
-
], GdsDropdown.prototype, "
|
|
1571
|
+
queryAsync("#listbox")
|
|
1572
|
+
], GdsDropdown.prototype, "_elListbox", 2);
|
|
1564
1573
|
__decorateClass([
|
|
1565
1574
|
query("#searchinput")
|
|
1566
|
-
], GdsDropdown.prototype, "
|
|
1575
|
+
], GdsDropdown.prototype, "_elSearchInput", 2);
|
|
1567
1576
|
__decorateClass([
|
|
1568
|
-
observeLightDOM(
|
|
1577
|
+
observeLightDOM({
|
|
1578
|
+
attributes: true,
|
|
1579
|
+
childList: true,
|
|
1580
|
+
subtree: true,
|
|
1581
|
+
characterData: true
|
|
1582
|
+
})
|
|
1569
1583
|
], GdsDropdown.prototype, "_handleLightDOMChange", 1);
|
|
1570
1584
|
__decorateClass([
|
|
1571
1585
|
watch("value")
|
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.
|
|
4
|
+
"version": "1.4.6",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
7
7
|
"type": "module",
|
|
@@ -18,13 +18,15 @@
|
|
|
18
18
|
},
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"registry": "https://registry.npmjs.org/",
|
|
21
|
-
"access": "public"
|
|
21
|
+
"access": "public",
|
|
22
|
+
"directory": "../../dist/libs/core/src"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
25
|
"@floating-ui/dom": "^1.5.4",
|
|
25
26
|
"@lit/localize": "0.11.4",
|
|
26
27
|
"lit": "^2.8.0",
|
|
27
|
-
"reflect-metadata": "^0.1.13"
|
|
28
|
+
"reflect-metadata": "^0.1.13",
|
|
29
|
+
"date-fns": "^2.28.0"
|
|
28
30
|
},
|
|
29
31
|
"exports": {
|
|
30
32
|
".": {
|
package/transitional-styles.js
CHANGED
|
@@ -3212,7 +3212,7 @@ function register6() {
|
|
|
3212
3212
|
// libs/core/src/utils/helpers/custom-element-scoping.ts
|
|
3213
3213
|
import { html as litHtml } from "lit";
|
|
3214
3214
|
import { customElement } from "lit/decorators.js";
|
|
3215
|
-
var VER_SUFFIX = "-
|
|
3215
|
+
var VER_SUFFIX = "-a568b5";
|
|
3216
3216
|
var elementLookupTable = /* @__PURE__ */ new Map();
|
|
3217
3217
|
var templateCache = /* @__PURE__ */ new WeakMap();
|
|
3218
3218
|
function applyElementScoping(strings, ...values) {
|
|
@@ -3,5 +3,5 @@ declare type Handler = () => void;
|
|
|
3
3
|
/**
|
|
4
4
|
* Runs when the light DOM children of the component changes.
|
|
5
5
|
*/
|
|
6
|
-
export declare function observeLightDOM(): <ElemClass extends LitElement>(proto: ElemClass, _propertyKey: string, descriptor: TypedPropertyDescriptor<Handler>) => void;
|
|
6
|
+
export declare function observeLightDOM(observerConfig?: MutationObserverInit): <ElemClass extends LitElement>(proto: ElemClass, _propertyKey: string, descriptor: TypedPropertyDescriptor<Handler>) => void;
|
|
7
7
|
export {};
|