@nectary/components 5.44.4 → 5.44.5
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/action-menu/index.js +10 -3
- package/action-menu-option/index.js +19 -2
- package/bundle.js +89 -25
- package/date-picker/index.js +1 -0
- package/package.json +1 -1
- package/pop/index.js +10 -2
- package/popover/index.js +35 -5
- package/select-button/index.js +6 -3
- package/tooltip/index.js +9 -11
package/action-menu/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isSinchActionMenuOption } from "../action-menu-option/utils.js";
|
|
2
2
|
import { subscribeContext } from "../utils/context.js";
|
|
3
|
-
import { attrValueToPixels, updateIntegerAttribute, getIntegerAttribute,
|
|
3
|
+
import { attrValueToPixels, updateIntegerAttribute, getIntegerAttribute, getBooleanAttribute, getDeepActiveElement, updateBooleanAttribute } from "../utils/dom.js";
|
|
4
4
|
import { defineCustomElement, NectaryElement } from "../utils/element.js";
|
|
5
5
|
const templateHTML = '<style>:host{display:block;outline:0}#listbox{overflow-y:auto}</style><div id="listbox" role="presentation"><slot></slot></div>';
|
|
6
6
|
const ITEM_HEIGHT = 40;
|
|
@@ -54,9 +54,16 @@ class ActionMenu extends NectaryElement {
|
|
|
54
54
|
};
|
|
55
55
|
#onListboxClick = (e) => {
|
|
56
56
|
this.focus();
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
const $option = e.composedPath().find(isSinchActionMenuOption);
|
|
58
|
+
if ($option === void 0) {
|
|
59
|
+
return;
|
|
59
60
|
}
|
|
61
|
+
if (getBooleanAttribute($option, "disabled")) {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
e.stopPropagation();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
this.#selectOption($option);
|
|
60
67
|
};
|
|
61
68
|
#onListboxKeyDown = (e) => {
|
|
62
69
|
this.#handleKeydown(e);
|
|
@@ -38,7 +38,13 @@ class ActionMenuOption extends NectaryElement {
|
|
|
38
38
|
break;
|
|
39
39
|
}
|
|
40
40
|
case "disabled": {
|
|
41
|
-
|
|
41
|
+
const isDisabled = isAttrTrue(newVal);
|
|
42
|
+
updateBooleanAttribute(this, name, isDisabled);
|
|
43
|
+
updateExplicitBooleanAttribute(
|
|
44
|
+
this,
|
|
45
|
+
"aria-selected",
|
|
46
|
+
getBooleanAttribute(this, "data-selected") && !isDisabled
|
|
47
|
+
);
|
|
42
48
|
break;
|
|
43
49
|
}
|
|
44
50
|
case "data-selected": {
|
|
@@ -61,12 +67,23 @@ class ActionMenuOption extends NectaryElement {
|
|
|
61
67
|
return getBooleanAttribute(this, "disabled");
|
|
62
68
|
}
|
|
63
69
|
click() {
|
|
70
|
+
if (this.disabled) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
64
73
|
this.#dispatchClickEvent();
|
|
65
74
|
}
|
|
66
|
-
#onMouseDown = () => {
|
|
75
|
+
#onMouseDown = (e) => {
|
|
76
|
+
if (this.disabled) {
|
|
77
|
+
e.stopPropagation();
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
67
81
|
this.#dispatchClickEvent();
|
|
68
82
|
};
|
|
69
83
|
#dispatchClickEvent() {
|
|
84
|
+
if (this.disabled) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
70
87
|
this.dispatchEvent(
|
|
71
88
|
new CustomEvent("-click")
|
|
72
89
|
);
|
package/bundle.js
CHANGED
|
@@ -760,7 +760,13 @@ class ActionMenuOption extends NectaryElement {
|
|
|
760
760
|
break;
|
|
761
761
|
}
|
|
762
762
|
case "disabled": {
|
|
763
|
-
|
|
763
|
+
const isDisabled = isAttrTrue(newVal);
|
|
764
|
+
updateBooleanAttribute(this, name, isDisabled);
|
|
765
|
+
updateExplicitBooleanAttribute(
|
|
766
|
+
this,
|
|
767
|
+
"aria-selected",
|
|
768
|
+
getBooleanAttribute(this, "data-selected") && !isDisabled
|
|
769
|
+
);
|
|
764
770
|
break;
|
|
765
771
|
}
|
|
766
772
|
case "data-selected": {
|
|
@@ -783,12 +789,23 @@ class ActionMenuOption extends NectaryElement {
|
|
|
783
789
|
return getBooleanAttribute(this, "disabled");
|
|
784
790
|
}
|
|
785
791
|
click() {
|
|
792
|
+
if (this.disabled) {
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
786
795
|
this.#dispatchClickEvent();
|
|
787
796
|
}
|
|
788
|
-
#onMouseDown = () => {
|
|
797
|
+
#onMouseDown = (e) => {
|
|
798
|
+
if (this.disabled) {
|
|
799
|
+
e.stopPropagation();
|
|
800
|
+
e.preventDefault();
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
789
803
|
this.#dispatchClickEvent();
|
|
790
804
|
};
|
|
791
805
|
#dispatchClickEvent() {
|
|
806
|
+
if (this.disabled) {
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
792
809
|
this.dispatchEvent(
|
|
793
810
|
new CustomEvent("-click")
|
|
794
811
|
);
|
|
@@ -923,9 +940,16 @@ class ActionMenu extends NectaryElement {
|
|
|
923
940
|
};
|
|
924
941
|
#onListboxClick = (e) => {
|
|
925
942
|
this.focus();
|
|
926
|
-
|
|
927
|
-
|
|
943
|
+
const $option = e.composedPath().find(isSinchActionMenuOption);
|
|
944
|
+
if ($option === void 0) {
|
|
945
|
+
return;
|
|
946
|
+
}
|
|
947
|
+
if (getBooleanAttribute($option, "disabled")) {
|
|
948
|
+
e.preventDefault();
|
|
949
|
+
e.stopPropagation();
|
|
950
|
+
return;
|
|
928
951
|
}
|
|
952
|
+
this.#selectOption($option);
|
|
929
953
|
};
|
|
930
954
|
#onListboxKeyDown = (e) => {
|
|
931
955
|
this.#handleKeydown(e);
|
|
@@ -3575,6 +3599,7 @@ class Pop extends NectaryElement {
|
|
|
3575
3599
|
targetStyleValue: null,
|
|
3576
3600
|
transformedAncestor: null
|
|
3577
3601
|
};
|
|
3602
|
+
#hasManagedHostRole = false;
|
|
3578
3603
|
static #dialogA11yAttrs = [
|
|
3579
3604
|
"aria-label",
|
|
3580
3605
|
"aria-labelledby",
|
|
@@ -3734,11 +3759,18 @@ class Pop extends NectaryElement {
|
|
|
3734
3759
|
}
|
|
3735
3760
|
#syncDialogSemantics(useDialogSemantics) {
|
|
3736
3761
|
if (useDialogSemantics) {
|
|
3737
|
-
this.setAttribute("role", "dialog");
|
|
3738
3762
|
this.#$dialog.setAttribute("aria-modal", "true");
|
|
3763
|
+
const hostRole = this.getAttribute("role");
|
|
3764
|
+
if (hostRole === null || this.#hasManagedHostRole) {
|
|
3765
|
+
this.setAttribute("role", "dialog");
|
|
3766
|
+
this.#hasManagedHostRole = true;
|
|
3767
|
+
}
|
|
3739
3768
|
return;
|
|
3740
3769
|
}
|
|
3741
|
-
this.
|
|
3770
|
+
if (this.#hasManagedHostRole && this.getAttribute("role") === "dialog") {
|
|
3771
|
+
this.removeAttribute("role");
|
|
3772
|
+
}
|
|
3773
|
+
this.#hasManagedHostRole = false;
|
|
3742
3774
|
this.#$dialog.removeAttribute("aria-modal");
|
|
3743
3775
|
}
|
|
3744
3776
|
#shouldUseModalSemantics(transformedAncestor = this.#openSession.transformedAncestor) {
|
|
@@ -4218,7 +4250,7 @@ const getPopOrientation$1 = (orientation) => {
|
|
|
4218
4250
|
}
|
|
4219
4251
|
return orientation;
|
|
4220
4252
|
};
|
|
4221
|
-
const templateHTML$Y = '<style>:host{display:contents}#content-wrapper{padding-bottom:8px;filter:drop-shadow(var(--sinch-comp-tooltip-shadow))}:host([orientation=left]) #content-wrapper{padding-bottom:0;padding-right:8px}:host([orientation=right]) #content-wrapper{padding-bottom:0;padding-left:8px}:host([orientation^=bottom]) #content-wrapper{padding-bottom:0;padding-top:8px}#content{position:relative;display:block;max-width:300px;padding:2px 6px;box-sizing:border-box;background-color:var(--sinch-local-color-background);border-radius:var(--sinch-comp-tooltip-shape-radius);pointer-events:none;opacity:0;--sinch-local-color-background:var(--sinch-comp-tooltip-color-background);--sinch-global-color-text:var(--sinch-comp-tooltip-color-text)}#text{word-break:break-word;pointer-events:none;--sinch-comp-text-font:var(--sinch-comp-tooltip-font-body)}#tip{position:absolute;left:50%;top:100%;transform:translateX(-50%) rotate(0);transform-origin:top center;fill:var(--sinch-local-color-background);pointer-events:none}#tip.hidden{display:none}:host([orientation=left]) #tip{transform:translateX(-50%) rotate(270deg);top:50%;left:100%}:host([orientation=right]) #tip{transform:translateX(-50%) rotate(90deg);top:50%;left:0}:host([orientation^=bottom]) #tip{transform:translateX(-50%) rotate(180deg);top:0}:host([text-align=right]) #text{--sinch-comp-text-align:right}:host([text-align=center]) #text{--sinch-comp-text-align:center}:host([text-align=left]) #text{--sinch-comp-text-align:left}</style><sinch-pop id="pop"><slot id="target" slot="target"></slot><div id="content-wrapper" slot="content"><div id="content"><sinch-text id="text" type="s"></sinch-text><svg id="tip" width="8" height="4" aria-hidden="true"><path d="m4 4 4-4h-8l4 4Z"/></svg></div></div></sinch-pop>';
|
|
4253
|
+
const templateHTML$Y = '<style>:host{display:contents}#content-wrapper{padding-bottom:8px;filter:drop-shadow(var(--sinch-comp-tooltip-shadow))}:host([orientation=left]) #content-wrapper{padding-bottom:0;padding-right:8px}:host([orientation=right]) #content-wrapper{padding-bottom:0;padding-left:8px}:host([orientation^=bottom]) #content-wrapper{padding-bottom:0;padding-top:8px}#content{position:relative;display:block;max-width:300px;padding:2px 6px;box-sizing:border-box;background-color:var(--sinch-local-color-background);border-radius:var(--sinch-comp-tooltip-shape-radius);pointer-events:none;opacity:0;--sinch-local-color-background:var(--sinch-comp-tooltip-color-background);--sinch-global-color-text:var(--sinch-comp-tooltip-color-text)}#text{word-break:break-word;pointer-events:none;--sinch-comp-text-font:var(--sinch-comp-tooltip-font-body)}#tip{position:absolute;left:50%;top:100%;transform:translateX(-50%) rotate(0);transform-origin:top center;fill:var(--sinch-local-color-background);pointer-events:none}#tip.hidden{display:none}:host([orientation=left]) #tip{transform:translateX(-50%) rotate(270deg);top:50%;left:100%}:host([orientation=right]) #tip{transform:translateX(-50%) rotate(90deg);top:50%;left:0}:host([orientation^=bottom]) #tip{transform:translateX(-50%) rotate(180deg);top:0}:host([text-align=right]) #text{--sinch-comp-text-align:right}:host([text-align=center]) #text{--sinch-comp-text-align:center}:host([text-align=left]) #text{--sinch-comp-text-align:left}</style><sinch-pop id="pop"><slot id="target" slot="target"></slot><div id="content-wrapper" slot="content"><div id="content" role="tooltip"><sinch-text id="text" type="s"></sinch-text><svg id="tip" width="8" height="4" aria-hidden="true"><path d="m4 4 4-4h-8l4 4Z"/></svg></div></div></sinch-pop>';
|
|
4222
4254
|
const TIP_SIZE$1 = 8;
|
|
4223
4255
|
const SHOW_DELAY_SLOW = 1e3;
|
|
4224
4256
|
const SHOW_DELAY_FAST = 250;
|
|
@@ -4287,7 +4319,6 @@ class Tooltip extends NectaryElement {
|
|
|
4287
4319
|
const options = {
|
|
4288
4320
|
signal: this.#controller.signal
|
|
4289
4321
|
};
|
|
4290
|
-
this.setAttribute("role", "tooltip");
|
|
4291
4322
|
this.#$pop.addEventListener("-close", this.#onPopClose, options);
|
|
4292
4323
|
this.#$target.addEventListener("slotchange", this.#onTargetSlotChange, options);
|
|
4293
4324
|
this.#assignTargetNodes();
|
|
@@ -4305,7 +4336,7 @@ class Tooltip extends NectaryElement {
|
|
|
4305
4336
|
updateAttribute(this.#$pop, "orientation", getPopOrientation$1(this.orientation));
|
|
4306
4337
|
updateBooleanAttribute(this.#$pop, "hide-outside-viewport", !this.showOutsideViewport);
|
|
4307
4338
|
updateBooleanAttribute(this.#$pop, "disable-focus-restore", true);
|
|
4308
|
-
this.#
|
|
4339
|
+
this.#updatePopA11yAttrs();
|
|
4309
4340
|
this.#updateText();
|
|
4310
4341
|
}
|
|
4311
4342
|
disconnectedCallback() {
|
|
@@ -4351,7 +4382,7 @@ class Tooltip extends NectaryElement {
|
|
|
4351
4382
|
switch (name) {
|
|
4352
4383
|
case "text": {
|
|
4353
4384
|
this.#updateText();
|
|
4354
|
-
this.#
|
|
4385
|
+
this.#updatePopA11yAttrs();
|
|
4355
4386
|
break;
|
|
4356
4387
|
}
|
|
4357
4388
|
case "orientation": {
|
|
@@ -4374,11 +4405,7 @@ class Tooltip extends NectaryElement {
|
|
|
4374
4405
|
}
|
|
4375
4406
|
case "aria-label":
|
|
4376
4407
|
case "aria-description": {
|
|
4377
|
-
|
|
4378
|
-
this.#updatePopAriaLabel();
|
|
4379
|
-
} else {
|
|
4380
|
-
updateAttribute(this.#$pop, name, newVal);
|
|
4381
|
-
}
|
|
4408
|
+
this.#updatePopA11yAttrs();
|
|
4382
4409
|
break;
|
|
4383
4410
|
}
|
|
4384
4411
|
case "show-outside-viewport": {
|
|
@@ -4954,12 +4981,15 @@ class Tooltip extends NectaryElement {
|
|
|
4954
4981
|
this.#subscribeMouseEnterEvent();
|
|
4955
4982
|
}
|
|
4956
4983
|
}
|
|
4957
|
-
#
|
|
4984
|
+
#updatePopA11yAttrs() {
|
|
4958
4985
|
const rawAriaLabel = getAttribute(this, "aria-label");
|
|
4959
4986
|
const explicitAriaLabel = rawAriaLabel !== null && rawAriaLabel.trim().length > 0 ? rawAriaLabel.trim() : null;
|
|
4960
4987
|
const fallbackAriaLabel = this.text ?? "";
|
|
4961
4988
|
const ariaLabel = explicitAriaLabel ?? (fallbackAriaLabel.length === 0 ? null : fallbackAriaLabel);
|
|
4962
|
-
updateAttribute(this.#$
|
|
4989
|
+
updateAttribute(this.#$content, "aria-label", ariaLabel);
|
|
4990
|
+
const rawAriaDescription = getAttribute(this, "aria-description");
|
|
4991
|
+
const ariaDescription = rawAriaDescription !== null && rawAriaDescription.trim().length > 0 ? rawAriaDescription.trim() : null;
|
|
4992
|
+
updateAttribute(this.#$content, "aria-description", ariaDescription);
|
|
4963
4993
|
}
|
|
4964
4994
|
#subscribeMouseEnterEvent() {
|
|
4965
4995
|
if (!this.isDomConnected || this.#isSubscribed) {
|
|
@@ -5636,6 +5666,7 @@ class DatePicker extends NectaryElement {
|
|
|
5636
5666
|
this.#$weekDayNames = Array.from(shadowRoot.querySelectorAll("#week-day-names > .week-day-name"));
|
|
5637
5667
|
}
|
|
5638
5668
|
connectedCallback() {
|
|
5669
|
+
this.setAttribute("role", "group");
|
|
5639
5670
|
this.#controller = new AbortController();
|
|
5640
5671
|
const options = {
|
|
5641
5672
|
signal: this.#controller.signal
|
|
@@ -7409,6 +7440,7 @@ class Popover extends NectaryElement {
|
|
|
7409
7440
|
if (slottedTarget != null) {
|
|
7410
7441
|
updateAttribute(slottedTarget, "aria-controls", popoverIdReference);
|
|
7411
7442
|
updateAttribute(slottedTarget, "aria-haspopup", true);
|
|
7443
|
+
this.#ensureInputHasComboboxRole(slottedTarget);
|
|
7412
7444
|
const isOpen = this.getAttribute("open") ?? false;
|
|
7413
7445
|
updateAttribute(slottedTarget, "aria-expanded", isOpen);
|
|
7414
7446
|
}
|
|
@@ -7434,7 +7466,8 @@ class Popover extends NectaryElement {
|
|
|
7434
7466
|
"focus-content-on-open",
|
|
7435
7467
|
"tip",
|
|
7436
7468
|
"aria-label",
|
|
7437
|
-
"aria-description"
|
|
7469
|
+
"aria-description",
|
|
7470
|
+
"role"
|
|
7438
7471
|
];
|
|
7439
7472
|
}
|
|
7440
7473
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
@@ -7470,14 +7503,16 @@ class Popover extends NectaryElement {
|
|
|
7470
7503
|
case "open": {
|
|
7471
7504
|
updateAttribute(this.#$pop, name, newVal);
|
|
7472
7505
|
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
7473
|
-
const
|
|
7474
|
-
if (
|
|
7475
|
-
|
|
7506
|
+
const slottedTarget = this.#getFirstAssignedElementInSlot(this.#$targetSlot);
|
|
7507
|
+
if (slottedTarget != null) {
|
|
7508
|
+
this.#ensureInputHasComboboxRole(slottedTarget);
|
|
7509
|
+
updateAttribute(slottedTarget, "aria-expanded", isAttrTrue(newVal));
|
|
7476
7510
|
}
|
|
7477
7511
|
break;
|
|
7478
7512
|
}
|
|
7479
7513
|
case "aria-label":
|
|
7480
|
-
case "aria-description":
|
|
7514
|
+
case "aria-description":
|
|
7515
|
+
case "role": {
|
|
7481
7516
|
updateAttribute(this.#$pop, name, newVal);
|
|
7482
7517
|
break;
|
|
7483
7518
|
}
|
|
@@ -7535,6 +7570,32 @@ class Popover extends NectaryElement {
|
|
|
7535
7570
|
}
|
|
7536
7571
|
return elements[0];
|
|
7537
7572
|
}
|
|
7573
|
+
#isTextLikeInputType(type) {
|
|
7574
|
+
const normalizedType = (type ?? "text").toLowerCase();
|
|
7575
|
+
return [
|
|
7576
|
+
"text",
|
|
7577
|
+
"search",
|
|
7578
|
+
"email",
|
|
7579
|
+
"url",
|
|
7580
|
+
"tel",
|
|
7581
|
+
"password"
|
|
7582
|
+
].includes(normalizedType);
|
|
7583
|
+
}
|
|
7584
|
+
#canUpgradeToComboboxRole(element) {
|
|
7585
|
+
if (!element.matches("input, sinch-input")) {
|
|
7586
|
+
return false;
|
|
7587
|
+
}
|
|
7588
|
+
return this.#isTextLikeInputType(element.getAttribute("type"));
|
|
7589
|
+
}
|
|
7590
|
+
#ensureInputHasComboboxRole(element) {
|
|
7591
|
+
if (!this.#canUpgradeToComboboxRole(element)) {
|
|
7592
|
+
return;
|
|
7593
|
+
}
|
|
7594
|
+
const currentRole = element.getAttribute("role");
|
|
7595
|
+
if (currentRole === null || currentRole === "textbox") {
|
|
7596
|
+
element.setAttribute("role", "combobox");
|
|
7597
|
+
}
|
|
7598
|
+
}
|
|
7538
7599
|
#focusSlottedContentOnOpen() {
|
|
7539
7600
|
const slottedContent = this.#getFirstAssignedElementInSlot(this.#$contentSlot);
|
|
7540
7601
|
if (isFocusableContent(slottedContent)) {
|
|
@@ -15383,10 +15444,13 @@ class SelectButton extends NectaryElement {
|
|
|
15383
15444
|
}
|
|
15384
15445
|
}
|
|
15385
15446
|
};
|
|
15386
|
-
#onButtonClick = () => {
|
|
15387
|
-
if (
|
|
15388
|
-
|
|
15447
|
+
#onButtonClick = (e) => {
|
|
15448
|
+
if (this.disabled) {
|
|
15449
|
+
e.stopPropagation();
|
|
15450
|
+
e.preventDefault();
|
|
15451
|
+
return;
|
|
15389
15452
|
}
|
|
15453
|
+
this.dispatchEvent(new CustomEvent("-click"));
|
|
15390
15454
|
};
|
|
15391
15455
|
#onClickReactHandler = (e) => {
|
|
15392
15456
|
getReactEventHandler(this, "on-click")?.(e);
|
package/date-picker/index.js
CHANGED
|
@@ -55,6 +55,7 @@ class DatePicker extends NectaryElement {
|
|
|
55
55
|
this.#$weekDayNames = Array.from(shadowRoot.querySelectorAll("#week-day-names > .week-day-name"));
|
|
56
56
|
}
|
|
57
57
|
connectedCallback() {
|
|
58
|
+
this.setAttribute("role", "group");
|
|
58
59
|
this.#controller = new AbortController();
|
|
59
60
|
const options = {
|
|
60
61
|
signal: this.#controller.signal
|
package/package.json
CHANGED
package/pop/index.js
CHANGED
|
@@ -35,6 +35,7 @@ class Pop extends NectaryElement {
|
|
|
35
35
|
targetStyleValue: null,
|
|
36
36
|
transformedAncestor: null
|
|
37
37
|
};
|
|
38
|
+
#hasManagedHostRole = false;
|
|
38
39
|
static #dialogA11yAttrs = [
|
|
39
40
|
"aria-label",
|
|
40
41
|
"aria-labelledby",
|
|
@@ -194,11 +195,18 @@ class Pop extends NectaryElement {
|
|
|
194
195
|
}
|
|
195
196
|
#syncDialogSemantics(useDialogSemantics) {
|
|
196
197
|
if (useDialogSemantics) {
|
|
197
|
-
this.setAttribute("role", "dialog");
|
|
198
198
|
this.#$dialog.setAttribute("aria-modal", "true");
|
|
199
|
+
const hostRole = this.getAttribute("role");
|
|
200
|
+
if (hostRole === null || this.#hasManagedHostRole) {
|
|
201
|
+
this.setAttribute("role", "dialog");
|
|
202
|
+
this.#hasManagedHostRole = true;
|
|
203
|
+
}
|
|
199
204
|
return;
|
|
200
205
|
}
|
|
201
|
-
this.
|
|
206
|
+
if (this.#hasManagedHostRole && this.getAttribute("role") === "dialog") {
|
|
207
|
+
this.removeAttribute("role");
|
|
208
|
+
}
|
|
209
|
+
this.#hasManagedHostRole = false;
|
|
202
210
|
this.#$dialog.removeAttribute("aria-modal");
|
|
203
211
|
}
|
|
204
212
|
#shouldUseModalSemantics(transformedAncestor = this.#openSession.transformedAncestor) {
|
package/popover/index.js
CHANGED
|
@@ -46,6 +46,7 @@ class Popover extends NectaryElement {
|
|
|
46
46
|
if (slottedTarget != null) {
|
|
47
47
|
updateAttribute(slottedTarget, "aria-controls", popoverIdReference);
|
|
48
48
|
updateAttribute(slottedTarget, "aria-haspopup", true);
|
|
49
|
+
this.#ensureInputHasComboboxRole(slottedTarget);
|
|
49
50
|
const isOpen = this.getAttribute("open") ?? false;
|
|
50
51
|
updateAttribute(slottedTarget, "aria-expanded", isOpen);
|
|
51
52
|
}
|
|
@@ -71,7 +72,8 @@ class Popover extends NectaryElement {
|
|
|
71
72
|
"focus-content-on-open",
|
|
72
73
|
"tip",
|
|
73
74
|
"aria-label",
|
|
74
|
-
"aria-description"
|
|
75
|
+
"aria-description",
|
|
76
|
+
"role"
|
|
75
77
|
];
|
|
76
78
|
}
|
|
77
79
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
@@ -107,14 +109,16 @@ class Popover extends NectaryElement {
|
|
|
107
109
|
case "open": {
|
|
108
110
|
updateAttribute(this.#$pop, name, newVal);
|
|
109
111
|
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
112
|
-
|
|
112
|
+
const slottedTarget = this.#getFirstAssignedElementInSlot(this.#$targetSlot);
|
|
113
|
+
if (slottedTarget != null) {
|
|
114
|
+
this.#ensureInputHasComboboxRole(slottedTarget);
|
|
115
|
+
updateAttribute(slottedTarget, "aria-expanded", isAttrTrue(newVal));
|
|
113
116
|
}
|
|
114
117
|
break;
|
|
115
118
|
}
|
|
116
119
|
case "aria-label":
|
|
117
|
-
case "aria-description":
|
|
120
|
+
case "aria-description":
|
|
121
|
+
case "role": {
|
|
118
122
|
updateAttribute(this.#$pop, name, newVal);
|
|
119
123
|
break;
|
|
120
124
|
}
|
|
@@ -172,6 +176,32 @@ class Popover extends NectaryElement {
|
|
|
172
176
|
}
|
|
173
177
|
return elements[0];
|
|
174
178
|
}
|
|
179
|
+
#isTextLikeInputType(type) {
|
|
180
|
+
const normalizedType = (type ?? "text").toLowerCase();
|
|
181
|
+
return [
|
|
182
|
+
"text",
|
|
183
|
+
"search",
|
|
184
|
+
"email",
|
|
185
|
+
"url",
|
|
186
|
+
"tel",
|
|
187
|
+
"password"
|
|
188
|
+
].includes(normalizedType);
|
|
189
|
+
}
|
|
190
|
+
#canUpgradeToComboboxRole(element) {
|
|
191
|
+
if (!element.matches("input, sinch-input")) {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
return this.#isTextLikeInputType(element.getAttribute("type"));
|
|
195
|
+
}
|
|
196
|
+
#ensureInputHasComboboxRole(element) {
|
|
197
|
+
if (!this.#canUpgradeToComboboxRole(element)) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const currentRole = element.getAttribute("role");
|
|
201
|
+
if (currentRole === null || currentRole === "textbox") {
|
|
202
|
+
element.setAttribute("role", "combobox");
|
|
203
|
+
}
|
|
204
|
+
}
|
|
175
205
|
#focusSlottedContentOnOpen() {
|
|
176
206
|
const slottedContent = this.#getFirstAssignedElementInSlot(this.#$contentSlot);
|
|
177
207
|
if (isFocusableContent(slottedContent)) {
|
package/select-button/index.js
CHANGED
|
@@ -174,10 +174,13 @@ class SelectButton extends NectaryElement {
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
};
|
|
177
|
-
#onButtonClick = () => {
|
|
178
|
-
if (
|
|
179
|
-
|
|
177
|
+
#onButtonClick = (e) => {
|
|
178
|
+
if (this.disabled) {
|
|
179
|
+
e.stopPropagation();
|
|
180
|
+
e.preventDefault();
|
|
181
|
+
return;
|
|
180
182
|
}
|
|
183
|
+
this.dispatchEvent(new CustomEvent("-click"));
|
|
181
184
|
};
|
|
182
185
|
#onClickReactHandler = (e) => {
|
|
183
186
|
getReactEventHandler(this, "on-click")?.(e);
|
package/tooltip/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { getReactEventHandler } from "../utils/get-react-event-handler.js";
|
|
|
7
7
|
import { getPlacementContext, toLocalRect } from "../utils/placement.js";
|
|
8
8
|
import { TooltipState } from "./tooltip-state.js";
|
|
9
9
|
import { getPopOrientation, orientationValues, textAlignValues, typeValues } from "./utils.js";
|
|
10
|
-
const templateHTML = '<style>:host{display:contents}#content-wrapper{padding-bottom:8px;filter:drop-shadow(var(--sinch-comp-tooltip-shadow))}:host([orientation=left]) #content-wrapper{padding-bottom:0;padding-right:8px}:host([orientation=right]) #content-wrapper{padding-bottom:0;padding-left:8px}:host([orientation^=bottom]) #content-wrapper{padding-bottom:0;padding-top:8px}#content{position:relative;display:block;max-width:300px;padding:2px 6px;box-sizing:border-box;background-color:var(--sinch-local-color-background);border-radius:var(--sinch-comp-tooltip-shape-radius);pointer-events:none;opacity:0;--sinch-local-color-background:var(--sinch-comp-tooltip-color-background);--sinch-global-color-text:var(--sinch-comp-tooltip-color-text)}#text{word-break:break-word;pointer-events:none;--sinch-comp-text-font:var(--sinch-comp-tooltip-font-body)}#tip{position:absolute;left:50%;top:100%;transform:translateX(-50%) rotate(0);transform-origin:top center;fill:var(--sinch-local-color-background);pointer-events:none}#tip.hidden{display:none}:host([orientation=left]) #tip{transform:translateX(-50%) rotate(270deg);top:50%;left:100%}:host([orientation=right]) #tip{transform:translateX(-50%) rotate(90deg);top:50%;left:0}:host([orientation^=bottom]) #tip{transform:translateX(-50%) rotate(180deg);top:0}:host([text-align=right]) #text{--sinch-comp-text-align:right}:host([text-align=center]) #text{--sinch-comp-text-align:center}:host([text-align=left]) #text{--sinch-comp-text-align:left}</style><sinch-pop id="pop"><slot id="target" slot="target"></slot><div id="content-wrapper" slot="content"><div id="content"><sinch-text id="text" type="s"></sinch-text><svg id="tip" width="8" height="4" aria-hidden="true"><path d="m4 4 4-4h-8l4 4Z"/></svg></div></div></sinch-pop>';
|
|
10
|
+
const templateHTML = '<style>:host{display:contents}#content-wrapper{padding-bottom:8px;filter:drop-shadow(var(--sinch-comp-tooltip-shadow))}:host([orientation=left]) #content-wrapper{padding-bottom:0;padding-right:8px}:host([orientation=right]) #content-wrapper{padding-bottom:0;padding-left:8px}:host([orientation^=bottom]) #content-wrapper{padding-bottom:0;padding-top:8px}#content{position:relative;display:block;max-width:300px;padding:2px 6px;box-sizing:border-box;background-color:var(--sinch-local-color-background);border-radius:var(--sinch-comp-tooltip-shape-radius);pointer-events:none;opacity:0;--sinch-local-color-background:var(--sinch-comp-tooltip-color-background);--sinch-global-color-text:var(--sinch-comp-tooltip-color-text)}#text{word-break:break-word;pointer-events:none;--sinch-comp-text-font:var(--sinch-comp-tooltip-font-body)}#tip{position:absolute;left:50%;top:100%;transform:translateX(-50%) rotate(0);transform-origin:top center;fill:var(--sinch-local-color-background);pointer-events:none}#tip.hidden{display:none}:host([orientation=left]) #tip{transform:translateX(-50%) rotate(270deg);top:50%;left:100%}:host([orientation=right]) #tip{transform:translateX(-50%) rotate(90deg);top:50%;left:0}:host([orientation^=bottom]) #tip{transform:translateX(-50%) rotate(180deg);top:0}:host([text-align=right]) #text{--sinch-comp-text-align:right}:host([text-align=center]) #text{--sinch-comp-text-align:center}:host([text-align=left]) #text{--sinch-comp-text-align:left}</style><sinch-pop id="pop"><slot id="target" slot="target"></slot><div id="content-wrapper" slot="content"><div id="content" role="tooltip"><sinch-text id="text" type="s"></sinch-text><svg id="tip" width="8" height="4" aria-hidden="true"><path d="m4 4 4-4h-8l4 4Z"/></svg></div></div></sinch-pop>';
|
|
11
11
|
const TIP_SIZE = 8;
|
|
12
12
|
const SHOW_DELAY_SLOW = 1e3;
|
|
13
13
|
const SHOW_DELAY_FAST = 250;
|
|
@@ -76,7 +76,6 @@ class Tooltip extends NectaryElement {
|
|
|
76
76
|
const options = {
|
|
77
77
|
signal: this.#controller.signal
|
|
78
78
|
};
|
|
79
|
-
this.setAttribute("role", "tooltip");
|
|
80
79
|
this.#$pop.addEventListener("-close", this.#onPopClose, options);
|
|
81
80
|
this.#$target.addEventListener("slotchange", this.#onTargetSlotChange, options);
|
|
82
81
|
this.#assignTargetNodes();
|
|
@@ -94,7 +93,7 @@ class Tooltip extends NectaryElement {
|
|
|
94
93
|
updateAttribute(this.#$pop, "orientation", getPopOrientation(this.orientation));
|
|
95
94
|
updateBooleanAttribute(this.#$pop, "hide-outside-viewport", !this.showOutsideViewport);
|
|
96
95
|
updateBooleanAttribute(this.#$pop, "disable-focus-restore", true);
|
|
97
|
-
this.#
|
|
96
|
+
this.#updatePopA11yAttrs();
|
|
98
97
|
this.#updateText();
|
|
99
98
|
}
|
|
100
99
|
disconnectedCallback() {
|
|
@@ -140,7 +139,7 @@ class Tooltip extends NectaryElement {
|
|
|
140
139
|
switch (name) {
|
|
141
140
|
case "text": {
|
|
142
141
|
this.#updateText();
|
|
143
|
-
this.#
|
|
142
|
+
this.#updatePopA11yAttrs();
|
|
144
143
|
break;
|
|
145
144
|
}
|
|
146
145
|
case "orientation": {
|
|
@@ -163,11 +162,7 @@ class Tooltip extends NectaryElement {
|
|
|
163
162
|
}
|
|
164
163
|
case "aria-label":
|
|
165
164
|
case "aria-description": {
|
|
166
|
-
|
|
167
|
-
this.#updatePopAriaLabel();
|
|
168
|
-
} else {
|
|
169
|
-
updateAttribute(this.#$pop, name, newVal);
|
|
170
|
-
}
|
|
165
|
+
this.#updatePopA11yAttrs();
|
|
171
166
|
break;
|
|
172
167
|
}
|
|
173
168
|
case "show-outside-viewport": {
|
|
@@ -743,12 +738,15 @@ class Tooltip extends NectaryElement {
|
|
|
743
738
|
this.#subscribeMouseEnterEvent();
|
|
744
739
|
}
|
|
745
740
|
}
|
|
746
|
-
#
|
|
741
|
+
#updatePopA11yAttrs() {
|
|
747
742
|
const rawAriaLabel = getAttribute(this, "aria-label");
|
|
748
743
|
const explicitAriaLabel = rawAriaLabel !== null && rawAriaLabel.trim().length > 0 ? rawAriaLabel.trim() : null;
|
|
749
744
|
const fallbackAriaLabel = this.text ?? "";
|
|
750
745
|
const ariaLabel = explicitAriaLabel ?? (fallbackAriaLabel.length === 0 ? null : fallbackAriaLabel);
|
|
751
|
-
updateAttribute(this.#$
|
|
746
|
+
updateAttribute(this.#$content, "aria-label", ariaLabel);
|
|
747
|
+
const rawAriaDescription = getAttribute(this, "aria-description");
|
|
748
|
+
const ariaDescription = rawAriaDescription !== null && rawAriaDescription.trim().length > 0 ? rawAriaDescription.trim() : null;
|
|
749
|
+
updateAttribute(this.#$content, "aria-description", ariaDescription);
|
|
752
750
|
}
|
|
753
751
|
#subscribeMouseEnterEvent() {
|
|
754
752
|
if (!this.isDomConnected || this.#isSubscribed) {
|