@nectary/components 5.53.3 → 5.54.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/bundle.js +36 -2
- package/input/index.d.ts +2 -0
- package/input/index.js +6 -0
- package/package.json +1 -1
- package/select-menu/index.js +11 -1
- package/textarea/index.d.ts +2 -0
- package/textarea/index.js +19 -1
- package/textarea/types.d.ts +2 -0
- package/utils/dom.d.ts +5 -0
package/bundle.js
CHANGED
|
@@ -7325,6 +7325,12 @@ class Input extends NectaryElement {
|
|
|
7325
7325
|
get focusable() {
|
|
7326
7326
|
return true;
|
|
7327
7327
|
}
|
|
7328
|
+
get ariaActiveDescendantElement() {
|
|
7329
|
+
return this.#$input.ariaActiveDescendantElement;
|
|
7330
|
+
}
|
|
7331
|
+
set ariaActiveDescendantElement(element) {
|
|
7332
|
+
this.#$input.ariaActiveDescendantElement = element;
|
|
7333
|
+
}
|
|
7328
7334
|
focus(options) {
|
|
7329
7335
|
this.#$input.focus(options);
|
|
7330
7336
|
}
|
|
@@ -16084,10 +16090,11 @@ class SelectMenuOption extends NectaryElement {
|
|
|
16084
16090
|
}
|
|
16085
16091
|
defineCustomElement("sinch-select-menu-option", SelectMenuOption);
|
|
16086
16092
|
const isSelectMenuOption = (el) => el.localName === "sinch-select-menu-option";
|
|
16087
|
-
const templateHTML$h = '<style>:host{display:block;outline:0}#listbox{overflow-y:auto;max-height:var(--sinch-comp-select-menu-font-max-height)}#search{display:none;margin:10px}#search.active{display:block}#search-clear:not(.active){display:none}#no-results{display:flex;align-items:center;justify-content:center;width:100%;height:30px;margin-bottom:10px;pointer-events:none;user-select:none;--sinch-comp-text-font:var(--sinch-comp-select-menu-font-not-found-text);--sinch-global-color-text:var(--sinch-comp-select-menu-color-default-not-found-text-initial)}#no-results:not(.active){display:none}::slotted(.hidden){display:none}::slotted(sinch-title){padding:8px 16px;--sinch-global-color-text:var(--sinch-comp-select-menu-color-default-title-initial)}</style><sinch-input id="search" size="s" placeholder="Search" aria-label="Search"><sinch-icon icons-version="2" name="magnifying-glass" id="icon-search" slot="icon"></sinch-icon><sinch-button id="search-clear" slot="right"><sinch-icon icons-version="2" name="fa-xmark" slot="icon"></sinch-icon></sinch-button></sinch-input><div id="no-results"><sinch-text id="no-results-text" type="m"></sinch-text></div><div id="listbox" role="listbox" tabindex="-1"><slot></slot></div>';
|
|
16093
|
+
const templateHTML$h = '<style>:host{display:block;outline:0}#listbox{overflow-y:auto;max-height:var(--sinch-comp-select-menu-font-max-height)}#search{display:none;margin:10px}#search.active{display:block}#search-clear:not(.active){display:none}#no-results{display:flex;align-items:center;justify-content:center;width:100%;height:30px;margin-bottom:10px;pointer-events:none;user-select:none;--sinch-comp-text-font:var(--sinch-comp-select-menu-font-not-found-text);--sinch-global-color-text:var(--sinch-comp-select-menu-color-default-not-found-text-initial)}#announcer{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}#no-results:not(.active){display:none}::slotted(.hidden){display:none}::slotted(sinch-title){padding:8px 16px;--sinch-global-color-text:var(--sinch-comp-select-menu-color-default-title-initial)}</style><sinch-input id="search" size="s" placeholder="Search" aria-label="Search"><sinch-icon icons-version="2" name="magnifying-glass" id="icon-search" slot="icon"></sinch-icon><sinch-button id="search-clear" slot="right"><sinch-icon icons-version="2" name="fa-xmark" slot="icon"></sinch-icon></sinch-button></sinch-input><div id="no-results"><sinch-text id="no-results-text" type="m"></sinch-text></div><div id="announcer" role="status" aria-live="polite" aria-atomic="true"></div><div id="listbox" role="listbox" tabindex="-1"><slot></slot></div>';
|
|
16088
16094
|
const ITEM_HEIGHT = 40;
|
|
16089
16095
|
const DEFAULT_SEARCH_LABEL = "Search";
|
|
16090
16096
|
const DEFAULT_NO_RESULTS_TEXT = "No results";
|
|
16097
|
+
const SUPPORTS_ACTIVE_DESCENDANT_ELEMENT = "ariaActiveDescendantElement" in Element.prototype;
|
|
16091
16098
|
const template$h = document.createElement("template");
|
|
16092
16099
|
template$h.innerHTML = templateHTML$h;
|
|
16093
16100
|
class SelectMenu extends NectaryElement {
|
|
@@ -16097,6 +16104,7 @@ class SelectMenu extends NectaryElement {
|
|
|
16097
16104
|
#$searchClear;
|
|
16098
16105
|
#$noResults;
|
|
16099
16106
|
#$noResultsText;
|
|
16107
|
+
#$announcer;
|
|
16100
16108
|
#controller = null;
|
|
16101
16109
|
#searchDebounce;
|
|
16102
16110
|
#internals;
|
|
@@ -16113,6 +16121,7 @@ class SelectMenu extends NectaryElement {
|
|
|
16113
16121
|
this.#$searchClear = shadowRoot.querySelector("#search-clear");
|
|
16114
16122
|
this.#$noResults = shadowRoot.querySelector("#no-results");
|
|
16115
16123
|
this.#$noResultsText = shadowRoot.querySelector("#no-results-text");
|
|
16124
|
+
this.#$announcer = shadowRoot.querySelector("#announcer");
|
|
16116
16125
|
this.#searchDebounce = debounceTimeout(200)(this.#updateSearchValue);
|
|
16117
16126
|
}
|
|
16118
16127
|
connectedCallback() {
|
|
@@ -16575,6 +16584,13 @@ class SelectMenu extends NectaryElement {
|
|
|
16575
16584
|
$op.scrollIntoView?.({ block: "nearest" });
|
|
16576
16585
|
}
|
|
16577
16586
|
}
|
|
16587
|
+
if (SUPPORTS_ACTIVE_DESCENDANT_ELEMENT) {
|
|
16588
|
+
const isSearchActive = hasClass(this.#$search, "active");
|
|
16589
|
+
this.#$search.ariaActiveDescendantElement = isSearchActive ? $option : null;
|
|
16590
|
+
this.ariaActiveDescendantElement = isSearchActive ? null : $option;
|
|
16591
|
+
} else {
|
|
16592
|
+
this.#$announcer.textContent = $option?.text ?? "";
|
|
16593
|
+
}
|
|
16578
16594
|
}
|
|
16579
16595
|
#getOptionElements() {
|
|
16580
16596
|
const assignedElements = this.#$optionSlot.assignedElements();
|
|
@@ -17447,7 +17463,7 @@ class Tag extends NectaryElement {
|
|
|
17447
17463
|
}
|
|
17448
17464
|
}
|
|
17449
17465
|
defineCustomElement("sinch-tag", Tag);
|
|
17450
|
-
const templateHTML$4 = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;position:relative;width:100%;box-sizing:border-box;background-color:var(--sinch-comp-textarea-color-default-background-initial);border-radius:var(--sinch-local-shape-radius);padding-right:2px;overflow:hidden;--sinch-local-shape-radius:var(--sinch-comp-textarea-shape-radius)}#input{all:initial;display:block;font:var(--sinch-comp-textarea-font-input);color:var(--sinch-comp-textarea-color-default-text-initial);resize:none;white-space:pre-wrap;overflow-wrap:break-word;padding:8px 10px 8px 12px;border:none;box-sizing:border-box}#input::placeholder{color:var(--sinch-comp-textarea-color-default-text-placeholder);opacity:1}#input:disabled{color:var(--sinch-comp-textarea-color-disabled-text-initial);-webkit-text-fill-color:var(--sinch-comp-textarea-color-disabled-text-initial)}#border{position:absolute;border:1px solid var(--sinch-comp-textarea-color-default-border-initial);border-radius:var(--sinch-local-shape-radius);inset:0;pointer-events:none}:host([invalid]) #border{border-color:var(--sinch-comp-textarea-color-invalid-border-initial)}#input:focus+#border{border-color:var(--sinch-comp-textarea-color-default-border-focus);border-width:2px}#input:disabled+#border{border-color:var(--sinch-comp-textarea-color-disabled-border-initial)}#bottom{display:flex;flex-direction:row;align-items:center;gap:8px;padding:12px 4px 4px}#bottom.empty{display:none}:host([resizable]) #bottom{padding-right:calc(var(--sinch-comp-textarea-size-resize-handle) + 4px)}#resize-handle{display:none;position:absolute;width:var(--sinch-comp-textarea-size-resize-handle);height:var(--sinch-comp-textarea-size-resize-handle);bottom:0;right:0;cursor:ns-resize}:host([resizable]) #resize-handle{display:block}#resize-icon{display:block;pointer-events:none;fill:var(--sinch-comp-textarea-color-default-border-initial)}</style><div id="wrapper"><textarea id="input"></textarea><div id="border"></div><div id="bottom"><slot name="bottom"></slot><div id="resize-handle"><svg id="resize-icon" width="16" height="16"><path d="m14.833 4.724-9.61 9.61-.942-.944 9.61-9.609.942.943ZM15.443 10 10.5 14.943 9.557 14 14.5 9.057l.943.943Z"/></svg></div></div></div>';
|
|
17466
|
+
const templateHTML$4 = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;position:relative;width:100%;box-sizing:border-box;background-color:var(--sinch-comp-textarea-color-default-background-initial);border-radius:var(--sinch-local-shape-radius);padding-right:2px;overflow:hidden;--sinch-local-shape-radius:var(--sinch-comp-textarea-shape-radius)}#input{all:initial;display:block;font:var(--sinch-comp-textarea-font-input);color:var(--sinch-comp-textarea-color-default-text-initial);resize:none;white-space:pre-wrap;overflow-wrap:break-word;padding:8px 10px 8px 12px;border:none;box-sizing:border-box}#input::placeholder{color:var(--sinch-comp-textarea-color-default-text-placeholder);opacity:1}#input:disabled{color:var(--sinch-comp-textarea-color-disabled-text-initial);-webkit-text-fill-color:var(--sinch-comp-textarea-color-disabled-text-initial)}:host([readonly]) #input{cursor:default}#border{position:absolute;border:1px solid var(--sinch-comp-textarea-color-default-border-initial);border-radius:var(--sinch-local-shape-radius);inset:0;pointer-events:none}:host([invalid]) #border{border-color:var(--sinch-comp-textarea-color-invalid-border-initial)}#input:focus+#border{border-color:var(--sinch-comp-textarea-color-default-border-focus);border-width:2px}#input:disabled+#border{border-color:var(--sinch-comp-textarea-color-disabled-border-initial)}#bottom{display:flex;flex-direction:row;align-items:center;gap:8px;padding:12px 4px 4px}#bottom.empty{display:none}:host([resizable]) #bottom{padding-right:calc(var(--sinch-comp-textarea-size-resize-handle) + 4px)}#resize-handle{display:none;position:absolute;width:var(--sinch-comp-textarea-size-resize-handle);height:var(--sinch-comp-textarea-size-resize-handle);bottom:0;right:0;cursor:ns-resize}:host([resizable]) #resize-handle{display:block}#resize-icon{display:block;pointer-events:none;fill:var(--sinch-comp-textarea-color-default-border-initial)}</style><div id="wrapper"><textarea id="input"></textarea><div id="border"></div><div id="bottom"><slot name="bottom"></slot><div id="resize-handle"><svg id="resize-icon" width="16" height="16"><path d="m14.833 4.724-9.61 9.61-.942-.944 9.61-9.609.942.943ZM15.443 10 10.5 14.943 9.557 14 14.5 9.057l.943.943Z"/></svg></div></div></div>';
|
|
17451
17467
|
const template$4 = document.createElement("template");
|
|
17452
17468
|
template$4.innerHTML = templateHTML$4;
|
|
17453
17469
|
class Textarea extends NectaryElement {
|
|
@@ -17545,6 +17561,7 @@ class Textarea extends NectaryElement {
|
|
|
17545
17561
|
"placeholder",
|
|
17546
17562
|
"invalid",
|
|
17547
17563
|
"disabled",
|
|
17564
|
+
"readonly",
|
|
17548
17565
|
"rows",
|
|
17549
17566
|
"minrows",
|
|
17550
17567
|
"resizable"
|
|
@@ -17600,6 +17617,17 @@ class Textarea extends NectaryElement {
|
|
|
17600
17617
|
updateBooleanAttribute(this, "disabled", isDisabled);
|
|
17601
17618
|
break;
|
|
17602
17619
|
}
|
|
17620
|
+
case "readonly": {
|
|
17621
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
17622
|
+
break;
|
|
17623
|
+
}
|
|
17624
|
+
const isReadonly = isAttrTrue(newVal);
|
|
17625
|
+
this.#$input.readOnly = isReadonly;
|
|
17626
|
+
this.ariaReadOnly = isReadonly.toString();
|
|
17627
|
+
this.#internals.ariaReadOnly = isReadonly.toString();
|
|
17628
|
+
updateBooleanAttribute(this, "readonly", isReadonly);
|
|
17629
|
+
break;
|
|
17630
|
+
}
|
|
17603
17631
|
case "rows": {
|
|
17604
17632
|
updateAttribute(this.#$input, "rows", newVal);
|
|
17605
17633
|
break;
|
|
@@ -17655,6 +17683,12 @@ class Textarea extends NectaryElement {
|
|
|
17655
17683
|
get disabled() {
|
|
17656
17684
|
return getBooleanAttribute(this, "disabled");
|
|
17657
17685
|
}
|
|
17686
|
+
set readonly(isReadonly) {
|
|
17687
|
+
updateBooleanAttribute(this, "readonly", isReadonly);
|
|
17688
|
+
}
|
|
17689
|
+
get readonly() {
|
|
17690
|
+
return getBooleanAttribute(this, "readonly");
|
|
17691
|
+
}
|
|
17658
17692
|
set resizable(isResizable) {
|
|
17659
17693
|
updateBooleanAttribute(this, "resizable", isResizable);
|
|
17660
17694
|
}
|
package/input/index.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export declare class Input extends NectaryElement {
|
|
|
41
41
|
set selectionDirection(value: HTMLInputElement['selectionDirection']);
|
|
42
42
|
setSelectionRange(selectionStart: number, selectionEnd: number): void;
|
|
43
43
|
get focusable(): boolean;
|
|
44
|
+
get ariaActiveDescendantElement(): Element | null;
|
|
45
|
+
set ariaActiveDescendantElement(element: Element | null);
|
|
44
46
|
focus(options?: FocusOptions): void;
|
|
45
47
|
blur(): void;
|
|
46
48
|
}
|
package/input/index.js
CHANGED
|
@@ -390,6 +390,12 @@ class Input extends NectaryElement {
|
|
|
390
390
|
get focusable() {
|
|
391
391
|
return true;
|
|
392
392
|
}
|
|
393
|
+
get ariaActiveDescendantElement() {
|
|
394
|
+
return this.#$input.ariaActiveDescendantElement;
|
|
395
|
+
}
|
|
396
|
+
set ariaActiveDescendantElement(element) {
|
|
397
|
+
this.#$input.ariaActiveDescendantElement = element;
|
|
398
|
+
}
|
|
393
399
|
focus(options) {
|
|
394
400
|
this.#$input.focus(options);
|
|
395
401
|
}
|
package/package.json
CHANGED
package/select-menu/index.js
CHANGED
|
@@ -10,10 +10,11 @@ import { debounceTimeout } from "../utils/debounce.js";
|
|
|
10
10
|
import { getReactEventHandler } from "../utils/get-react-event-handler.js";
|
|
11
11
|
import { isTargetEqual } from "../utils/event-target.js";
|
|
12
12
|
import { setFormValue, CSVToFormData } from "../utils/form.js";
|
|
13
|
-
const templateHTML = '<style>:host{display:block;outline:0}#listbox{overflow-y:auto;max-height:var(--sinch-comp-select-menu-font-max-height)}#search{display:none;margin:10px}#search.active{display:block}#search-clear:not(.active){display:none}#no-results{display:flex;align-items:center;justify-content:center;width:100%;height:30px;margin-bottom:10px;pointer-events:none;user-select:none;--sinch-comp-text-font:var(--sinch-comp-select-menu-font-not-found-text);--sinch-global-color-text:var(--sinch-comp-select-menu-color-default-not-found-text-initial)}#no-results:not(.active){display:none}::slotted(.hidden){display:none}::slotted(sinch-title){padding:8px 16px;--sinch-global-color-text:var(--sinch-comp-select-menu-color-default-title-initial)}</style><sinch-input id="search" size="s" placeholder="Search" aria-label="Search"><sinch-icon icons-version="2" name="magnifying-glass" id="icon-search" slot="icon"></sinch-icon><sinch-button id="search-clear" slot="right"><sinch-icon icons-version="2" name="fa-xmark" slot="icon"></sinch-icon></sinch-button></sinch-input><div id="no-results"><sinch-text id="no-results-text" type="m"></sinch-text></div><div id="listbox" role="listbox" tabindex="-1"><slot></slot></div>';
|
|
13
|
+
const templateHTML = '<style>:host{display:block;outline:0}#listbox{overflow-y:auto;max-height:var(--sinch-comp-select-menu-font-max-height)}#search{display:none;margin:10px}#search.active{display:block}#search-clear:not(.active){display:none}#no-results{display:flex;align-items:center;justify-content:center;width:100%;height:30px;margin-bottom:10px;pointer-events:none;user-select:none;--sinch-comp-text-font:var(--sinch-comp-select-menu-font-not-found-text);--sinch-global-color-text:var(--sinch-comp-select-menu-color-default-not-found-text-initial)}#announcer{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}#no-results:not(.active){display:none}::slotted(.hidden){display:none}::slotted(sinch-title){padding:8px 16px;--sinch-global-color-text:var(--sinch-comp-select-menu-color-default-title-initial)}</style><sinch-input id="search" size="s" placeholder="Search" aria-label="Search"><sinch-icon icons-version="2" name="magnifying-glass" id="icon-search" slot="icon"></sinch-icon><sinch-button id="search-clear" slot="right"><sinch-icon icons-version="2" name="fa-xmark" slot="icon"></sinch-icon></sinch-button></sinch-input><div id="no-results"><sinch-text id="no-results-text" type="m"></sinch-text></div><div id="announcer" role="status" aria-live="polite" aria-atomic="true"></div><div id="listbox" role="listbox" tabindex="-1"><slot></slot></div>';
|
|
14
14
|
const ITEM_HEIGHT = 40;
|
|
15
15
|
const DEFAULT_SEARCH_LABEL = "Search";
|
|
16
16
|
const DEFAULT_NO_RESULTS_TEXT = "No results";
|
|
17
|
+
const SUPPORTS_ACTIVE_DESCENDANT_ELEMENT = "ariaActiveDescendantElement" in Element.prototype;
|
|
17
18
|
const template = document.createElement("template");
|
|
18
19
|
template.innerHTML = templateHTML;
|
|
19
20
|
class SelectMenu extends NectaryElement {
|
|
@@ -23,6 +24,7 @@ class SelectMenu extends NectaryElement {
|
|
|
23
24
|
#$searchClear;
|
|
24
25
|
#$noResults;
|
|
25
26
|
#$noResultsText;
|
|
27
|
+
#$announcer;
|
|
26
28
|
#controller = null;
|
|
27
29
|
#searchDebounce;
|
|
28
30
|
#internals;
|
|
@@ -39,6 +41,7 @@ class SelectMenu extends NectaryElement {
|
|
|
39
41
|
this.#$searchClear = shadowRoot.querySelector("#search-clear");
|
|
40
42
|
this.#$noResults = shadowRoot.querySelector("#no-results");
|
|
41
43
|
this.#$noResultsText = shadowRoot.querySelector("#no-results-text");
|
|
44
|
+
this.#$announcer = shadowRoot.querySelector("#announcer");
|
|
42
45
|
this.#searchDebounce = debounceTimeout(200)(this.#updateSearchValue);
|
|
43
46
|
}
|
|
44
47
|
connectedCallback() {
|
|
@@ -501,6 +504,13 @@ class SelectMenu extends NectaryElement {
|
|
|
501
504
|
$op.scrollIntoView?.({ block: "nearest" });
|
|
502
505
|
}
|
|
503
506
|
}
|
|
507
|
+
if (SUPPORTS_ACTIVE_DESCENDANT_ELEMENT) {
|
|
508
|
+
const isSearchActive = hasClass(this.#$search, "active");
|
|
509
|
+
this.#$search.ariaActiveDescendantElement = isSearchActive ? $option : null;
|
|
510
|
+
this.ariaActiveDescendantElement = isSearchActive ? null : $option;
|
|
511
|
+
} else {
|
|
512
|
+
this.#$announcer.textContent = $option?.text ?? "";
|
|
513
|
+
}
|
|
504
514
|
}
|
|
505
515
|
#getOptionElements() {
|
|
506
516
|
const assignedElements = this.#$optionSlot.assignedElements();
|
package/textarea/index.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export declare class Textarea extends NectaryElement {
|
|
|
21
21
|
get invalid(): boolean;
|
|
22
22
|
set disabled(isDisabled: boolean);
|
|
23
23
|
get disabled(): boolean;
|
|
24
|
+
set readonly(isReadonly: boolean);
|
|
25
|
+
get readonly(): boolean;
|
|
24
26
|
set resizable(isResizable: boolean);
|
|
25
27
|
get resizable(): boolean;
|
|
26
28
|
set rows(value: HTMLTextAreaElement['rows']);
|
package/textarea/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { getRect } from "../utils/rect.js";
|
|
|
5
5
|
import { getReactEventHandler } from "../utils/get-react-event-handler.js";
|
|
6
6
|
import { setFormValue } from "../utils/form.js";
|
|
7
7
|
import { DEFAULT_SIZE } from "../utils/size.js";
|
|
8
|
-
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;position:relative;width:100%;box-sizing:border-box;background-color:var(--sinch-comp-textarea-color-default-background-initial);border-radius:var(--sinch-local-shape-radius);padding-right:2px;overflow:hidden;--sinch-local-shape-radius:var(--sinch-comp-textarea-shape-radius)}#input{all:initial;display:block;font:var(--sinch-comp-textarea-font-input);color:var(--sinch-comp-textarea-color-default-text-initial);resize:none;white-space:pre-wrap;overflow-wrap:break-word;padding:8px 10px 8px 12px;border:none;box-sizing:border-box}#input::placeholder{color:var(--sinch-comp-textarea-color-default-text-placeholder);opacity:1}#input:disabled{color:var(--sinch-comp-textarea-color-disabled-text-initial);-webkit-text-fill-color:var(--sinch-comp-textarea-color-disabled-text-initial)}#border{position:absolute;border:1px solid var(--sinch-comp-textarea-color-default-border-initial);border-radius:var(--sinch-local-shape-radius);inset:0;pointer-events:none}:host([invalid]) #border{border-color:var(--sinch-comp-textarea-color-invalid-border-initial)}#input:focus+#border{border-color:var(--sinch-comp-textarea-color-default-border-focus);border-width:2px}#input:disabled+#border{border-color:var(--sinch-comp-textarea-color-disabled-border-initial)}#bottom{display:flex;flex-direction:row;align-items:center;gap:8px;padding:12px 4px 4px}#bottom.empty{display:none}:host([resizable]) #bottom{padding-right:calc(var(--sinch-comp-textarea-size-resize-handle) + 4px)}#resize-handle{display:none;position:absolute;width:var(--sinch-comp-textarea-size-resize-handle);height:var(--sinch-comp-textarea-size-resize-handle);bottom:0;right:0;cursor:ns-resize}:host([resizable]) #resize-handle{display:block}#resize-icon{display:block;pointer-events:none;fill:var(--sinch-comp-textarea-color-default-border-initial)}</style><div id="wrapper"><textarea id="input"></textarea><div id="border"></div><div id="bottom"><slot name="bottom"></slot><div id="resize-handle"><svg id="resize-icon" width="16" height="16"><path d="m14.833 4.724-9.61 9.61-.942-.944 9.61-9.609.942.943ZM15.443 10 10.5 14.943 9.557 14 14.5 9.057l.943.943Z"/></svg></div></div></div>';
|
|
8
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;position:relative;width:100%;box-sizing:border-box;background-color:var(--sinch-comp-textarea-color-default-background-initial);border-radius:var(--sinch-local-shape-radius);padding-right:2px;overflow:hidden;--sinch-local-shape-radius:var(--sinch-comp-textarea-shape-radius)}#input{all:initial;display:block;font:var(--sinch-comp-textarea-font-input);color:var(--sinch-comp-textarea-color-default-text-initial);resize:none;white-space:pre-wrap;overflow-wrap:break-word;padding:8px 10px 8px 12px;border:none;box-sizing:border-box}#input::placeholder{color:var(--sinch-comp-textarea-color-default-text-placeholder);opacity:1}#input:disabled{color:var(--sinch-comp-textarea-color-disabled-text-initial);-webkit-text-fill-color:var(--sinch-comp-textarea-color-disabled-text-initial)}:host([readonly]) #input{cursor:default}#border{position:absolute;border:1px solid var(--sinch-comp-textarea-color-default-border-initial);border-radius:var(--sinch-local-shape-radius);inset:0;pointer-events:none}:host([invalid]) #border{border-color:var(--sinch-comp-textarea-color-invalid-border-initial)}#input:focus+#border{border-color:var(--sinch-comp-textarea-color-default-border-focus);border-width:2px}#input:disabled+#border{border-color:var(--sinch-comp-textarea-color-disabled-border-initial)}#bottom{display:flex;flex-direction:row;align-items:center;gap:8px;padding:12px 4px 4px}#bottom.empty{display:none}:host([resizable]) #bottom{padding-right:calc(var(--sinch-comp-textarea-size-resize-handle) + 4px)}#resize-handle{display:none;position:absolute;width:var(--sinch-comp-textarea-size-resize-handle);height:var(--sinch-comp-textarea-size-resize-handle);bottom:0;right:0;cursor:ns-resize}:host([resizable]) #resize-handle{display:block}#resize-icon{display:block;pointer-events:none;fill:var(--sinch-comp-textarea-color-default-border-initial)}</style><div id="wrapper"><textarea id="input"></textarea><div id="border"></div><div id="bottom"><slot name="bottom"></slot><div id="resize-handle"><svg id="resize-icon" width="16" height="16"><path d="m14.833 4.724-9.61 9.61-.942-.944 9.61-9.609.942.943ZM15.443 10 10.5 14.943 9.557 14 14.5 9.057l.943.943Z"/></svg></div></div></div>';
|
|
9
9
|
const template = document.createElement("template");
|
|
10
10
|
template.innerHTML = templateHTML;
|
|
11
11
|
class Textarea extends NectaryElement {
|
|
@@ -103,6 +103,7 @@ class Textarea extends NectaryElement {
|
|
|
103
103
|
"placeholder",
|
|
104
104
|
"invalid",
|
|
105
105
|
"disabled",
|
|
106
|
+
"readonly",
|
|
106
107
|
"rows",
|
|
107
108
|
"minrows",
|
|
108
109
|
"resizable"
|
|
@@ -158,6 +159,17 @@ class Textarea extends NectaryElement {
|
|
|
158
159
|
updateBooleanAttribute(this, "disabled", isDisabled);
|
|
159
160
|
break;
|
|
160
161
|
}
|
|
162
|
+
case "readonly": {
|
|
163
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
const isReadonly = isAttrTrue(newVal);
|
|
167
|
+
this.#$input.readOnly = isReadonly;
|
|
168
|
+
this.ariaReadOnly = isReadonly.toString();
|
|
169
|
+
this.#internals.ariaReadOnly = isReadonly.toString();
|
|
170
|
+
updateBooleanAttribute(this, "readonly", isReadonly);
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
161
173
|
case "rows": {
|
|
162
174
|
updateAttribute(this.#$input, "rows", newVal);
|
|
163
175
|
break;
|
|
@@ -213,6 +225,12 @@ class Textarea extends NectaryElement {
|
|
|
213
225
|
get disabled() {
|
|
214
226
|
return getBooleanAttribute(this, "disabled");
|
|
215
227
|
}
|
|
228
|
+
set readonly(isReadonly) {
|
|
229
|
+
updateBooleanAttribute(this, "readonly", isReadonly);
|
|
230
|
+
}
|
|
231
|
+
get readonly() {
|
|
232
|
+
return getBooleanAttribute(this, "readonly");
|
|
233
|
+
}
|
|
216
234
|
set resizable(isResizable) {
|
|
217
235
|
updateBooleanAttribute(this, "resizable", isResizable);
|
|
218
236
|
}
|
package/textarea/types.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export type TSinchTextareaProps = {
|
|
|
8
8
|
placeholder?: string;
|
|
9
9
|
/** Disabled */
|
|
10
10
|
disabled?: boolean;
|
|
11
|
+
/** Whether the textarea is read-only. The value stays focusable and is included in form submission */
|
|
12
|
+
readonly?: boolean;
|
|
11
13
|
/** Invalid state */
|
|
12
14
|
invalid?: boolean;
|
|
13
15
|
'aria-label': string;
|
package/utils/dom.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface ARIAMixin {
|
|
3
|
+
ariaActiveDescendantElement: Element | null;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
1
6
|
export declare const updateExplicitBooleanAttribute: ($element: Element, attrName: string, attrValue: boolean | null | undefined) => void;
|
|
2
7
|
export declare const isAttrTrue: (attrValue: string | null) => boolean;
|
|
3
8
|
export declare const getBooleanAttribute: ($element: Element, attrName: string) => boolean;
|