@nectary/components 5.56.0 → 5.57.1
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 +72 -18
- package/file-status/index.d.ts +5 -1
- package/file-status/index.js +28 -3
- package/file-status/types.d.ts +7 -0
- package/file-status/utils.d.ts +6 -1
- package/file-status/utils.js +32 -0
- package/input/index.js +1 -1
- package/package.json +1 -1
package/bundle.js
CHANGED
|
@@ -1229,8 +1229,8 @@ class CodeTag extends NectaryElement {
|
|
|
1229
1229
|
}
|
|
1230
1230
|
defineCustomElement("sinch-code-tag", CodeTag);
|
|
1231
1231
|
const DEFAULT_SIZE = "m";
|
|
1232
|
-
const sizeValues$
|
|
1233
|
-
const sizeExValues = [...sizeValues$
|
|
1232
|
+
const sizeValues$2 = ["l", "m", "s"];
|
|
1233
|
+
const sizeExValues = [...sizeValues$2, "xs"];
|
|
1234
1234
|
const linkTypeValues = [
|
|
1235
1235
|
"primary",
|
|
1236
1236
|
"secondary",
|
|
@@ -1840,7 +1840,7 @@ const parseMarkdown = (md, visitor, chipReg = regChip, escapeReg = regEscapedCha
|
|
|
1840
1840
|
}
|
|
1841
1841
|
return visitor.end();
|
|
1842
1842
|
};
|
|
1843
|
-
const sizeValues = ["m", "s", "xs", "xxs"];
|
|
1843
|
+
const sizeValues$1 = ["m", "s", "xs", "xxs"];
|
|
1844
1844
|
const createParseVisitor$1 = (doc) => {
|
|
1845
1845
|
let emojiBaseUrl = null;
|
|
1846
1846
|
let chipColor = null;
|
|
@@ -2071,10 +2071,10 @@ class RichText extends NectaryElement {
|
|
|
2071
2071
|
}
|
|
2072
2072
|
}
|
|
2073
2073
|
get size() {
|
|
2074
|
-
return getLiteralAttribute(this, sizeValues, "size", "m");
|
|
2074
|
+
return getLiteralAttribute(this, sizeValues$1, "size", "m");
|
|
2075
2075
|
}
|
|
2076
2076
|
set size(value) {
|
|
2077
|
-
updateLiteralAttribute(this, sizeValues, "size", value);
|
|
2077
|
+
updateLiteralAttribute(this, sizeValues$1, "size", value);
|
|
2078
2078
|
}
|
|
2079
2079
|
get text() {
|
|
2080
2080
|
return getAttribute(this, "text", "");
|
|
@@ -2276,10 +2276,10 @@ class Avatar extends NectaryElement {
|
|
|
2276
2276
|
updateAttribute(this, "color", value);
|
|
2277
2277
|
}
|
|
2278
2278
|
get size() {
|
|
2279
|
-
return getLiteralAttribute(this, sizeValues$
|
|
2279
|
+
return getLiteralAttribute(this, sizeValues$2, "size", DEFAULT_SIZE);
|
|
2280
2280
|
}
|
|
2281
2281
|
set size(value) {
|
|
2282
|
-
updateLiteralAttribute(this, sizeValues$
|
|
2282
|
+
updateLiteralAttribute(this, sizeValues$2, "size", value);
|
|
2283
2283
|
}
|
|
2284
2284
|
get status() {
|
|
2285
2285
|
return getLiteralAttribute(this, statusValues, "status", null);
|
|
@@ -2414,10 +2414,10 @@ class Badge extends NectaryElement {
|
|
|
2414
2414
|
updateAttribute(this, "text", value);
|
|
2415
2415
|
}
|
|
2416
2416
|
get size() {
|
|
2417
|
-
return getLiteralAttribute(this, sizeValues$
|
|
2417
|
+
return getLiteralAttribute(this, sizeValues$2, "size", DEFAULT_SIZE);
|
|
2418
2418
|
}
|
|
2419
2419
|
set size(value) {
|
|
2420
|
-
updateLiteralAttribute(this, sizeValues$
|
|
2420
|
+
updateLiteralAttribute(this, sizeValues$2, "size", value);
|
|
2421
2421
|
}
|
|
2422
2422
|
get mode() {
|
|
2423
2423
|
return getLiteralAttribute(this, modeValues, "mode", "square");
|
|
@@ -7290,10 +7290,10 @@ class Input extends NectaryElement {
|
|
|
7290
7290
|
return getBooleanAttribute(this, "autofocus");
|
|
7291
7291
|
}
|
|
7292
7292
|
set size(size) {
|
|
7293
|
-
updateLiteralAttribute(this, sizeValues$
|
|
7293
|
+
updateLiteralAttribute(this, sizeValues$2, "size", size);
|
|
7294
7294
|
}
|
|
7295
7295
|
get size() {
|
|
7296
|
-
return getLiteralAttribute(this, sizeValues$
|
|
7296
|
+
return getLiteralAttribute(this, sizeValues$2, "size", DEFAULT_SIZE);
|
|
7297
7297
|
}
|
|
7298
7298
|
set autocomplete(value) {
|
|
7299
7299
|
updateAttribute(this, "autocomplete", value);
|
|
@@ -7675,9 +7675,9 @@ class Input extends NectaryElement {
|
|
|
7675
7675
|
const size = this.getAttribute("data-size") ?? DEFAULT_SIZE;
|
|
7676
7676
|
this.#sizeContext.dispatch(size);
|
|
7677
7677
|
}
|
|
7678
|
+
// No `onKeyDown` lookup: the native keydown is composed, so React already calls `onKeyDown` itself
|
|
7678
7679
|
#onKeyDownReactHandler = (e) => {
|
|
7679
7680
|
getReactEventHandler(this, "on-key-down")?.(e);
|
|
7680
|
-
getReactEventHandler(this, "onKeyDown")?.(e);
|
|
7681
7681
|
};
|
|
7682
7682
|
#onChangeReactHandler = (e) => {
|
|
7683
7683
|
getReactEventHandler(this, "on-change")?.(e);
|
|
@@ -9468,10 +9468,10 @@ class Spinner extends NectaryElement {
|
|
|
9468
9468
|
}
|
|
9469
9469
|
}
|
|
9470
9470
|
set size(size) {
|
|
9471
|
-
updateLiteralAttribute(this, sizeValues$
|
|
9471
|
+
updateLiteralAttribute(this, sizeValues$2, "size", size);
|
|
9472
9472
|
}
|
|
9473
9473
|
get size() {
|
|
9474
|
-
return getLiteralAttribute(this, sizeValues$
|
|
9474
|
+
return getLiteralAttribute(this, sizeValues$2, "size", DEFAULT_SIZE);
|
|
9475
9475
|
}
|
|
9476
9476
|
#onContextSize = (e) => {
|
|
9477
9477
|
if (this.hasAttribute("size") === true) {
|
|
@@ -9491,12 +9491,42 @@ class Spinner extends NectaryElement {
|
|
|
9491
9491
|
}
|
|
9492
9492
|
defineCustomElement("sinch-spinner", Spinner);
|
|
9493
9493
|
const typeValues$2 = ["pending", "loading", "progress", "success", "error"];
|
|
9494
|
-
const
|
|
9494
|
+
const sizeValues = ["s", "m"];
|
|
9495
|
+
const defaultIcons = {
|
|
9496
|
+
pending: "fa-clipboard-question",
|
|
9497
|
+
progress: "fa-file-lines",
|
|
9498
|
+
success: "circle-check",
|
|
9499
|
+
error: "octagon-exclamation"
|
|
9500
|
+
};
|
|
9501
|
+
const parseIcons = (json) => {
|
|
9502
|
+
const icons = {};
|
|
9503
|
+
if (json === null) {
|
|
9504
|
+
return icons;
|
|
9505
|
+
}
|
|
9506
|
+
let parsed;
|
|
9507
|
+
try {
|
|
9508
|
+
parsed = JSON.parse(json);
|
|
9509
|
+
} catch {
|
|
9510
|
+
return icons;
|
|
9511
|
+
}
|
|
9512
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
9513
|
+
return icons;
|
|
9514
|
+
}
|
|
9515
|
+
for (const type of typeValues$2) {
|
|
9516
|
+
const name = parsed[type];
|
|
9517
|
+
if (typeof name === "string" && name !== "") {
|
|
9518
|
+
icons[type] = name;
|
|
9519
|
+
}
|
|
9520
|
+
}
|
|
9521
|
+
return icons;
|
|
9522
|
+
};
|
|
9523
|
+
const templateHTML$J = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;align-items:flex-start;padding:12px 16px;box-sizing:border-box;min-height:48px;min-width:148px;border-radius:var(--sinch-comp-file-status-shape-radius)}:host([type=error]) #wrapper{background-color:var(--sinch-comp-file-status-color-error-background)}:host([type=success]) #wrapper{background-color:var(--sinch-comp-file-status-color-success-background)}:host([type=pending]) #wrapper{background-color:var(--sinch-comp-file-status-color-pending-background)}:host([type=progress]) #wrapper{background-color:var(--sinch-comp-file-status-color-progress-background)}:host([type=loading]) #wrapper{background-color:var(--sinch-comp-file-status-color-loading-background)}:host([size="s"]) #wrapper{padding:6px;min-height:36px}#content-wrapper{display:flex;flex-direction:column;gap:8px;flex:1;min-width:0;min-height:24px;margin-left:16px}:host([size="s"]) #content-wrapper{margin-left:6px}:host([type=error]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-error-text)}:host([type=success]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-success-text)}:host([type=pending]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-pending-text)}:host([type=progress]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-progress-text)}:host([type=loading]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-loading-text)}#action{display:flex;gap:4px;height:32px;margin-top:-4px;margin-bottom:-4px}#icon-error,#icon-loading,#icon-pending,#icon-progress,#icon-success,#spinner{display:none}#icon-pending{--sinch-global-color-icon:var(--sinch-comp-file-status-color-pending-icon)}#icon-success{--sinch-global-color-icon:var(--sinch-comp-file-status-color-success-icon)}#icon-progress{--sinch-global-color-icon:var(--sinch-comp-file-status-color-progress-icon)}#icon-error{--sinch-global-color-icon:var(--sinch-comp-file-status-color-error-icon)}#icon-loading,#spinner{--sinch-global-color-icon:var(--sinch-comp-file-status-color-loading-icon)}:host([type=error]) #icon-error,:host([type=loading]) #icon-loading[name],:host([type=loading]) #spinner,:host([type=pending]) #icon-pending,:host([type=progress]) #icon-progress,:host([type=success]) #icon-success{display:block}#icon-loading[name]+#spinner{display:none}</style><div id="wrapper"><sinch-icon icons-version="2" id="icon-loading"></sinch-icon><sinch-spinner id="spinner" size="m"></sinch-spinner><sinch-icon icons-version="2" id="icon-pending"></sinch-icon><sinch-icon icons-version="2" id="icon-success"></sinch-icon><sinch-icon icons-version="2" id="icon-progress"></sinch-icon><sinch-icon icons-version="2" id="icon-error"></sinch-icon><div id="content-wrapper"><sinch-text id="filename" type="m" ellipsis></sinch-text><slot name="content"></slot></div><div id="action"><slot name="action"></slot></div></div>';
|
|
9495
9524
|
const template$J = document.createElement("template");
|
|
9496
9525
|
template$J.innerHTML = templateHTML$J;
|
|
9497
9526
|
class FileStatus extends NectaryElement {
|
|
9498
9527
|
#$filename;
|
|
9499
9528
|
#$contentSlot;
|
|
9529
|
+
#$icons;
|
|
9500
9530
|
#controller = null;
|
|
9501
9531
|
constructor() {
|
|
9502
9532
|
super();
|
|
@@ -9504,6 +9534,8 @@ class FileStatus extends NectaryElement {
|
|
|
9504
9534
|
shadowRoot.appendChild(template$J.content.cloneNode(true));
|
|
9505
9535
|
this.#$filename = shadowRoot.querySelector("#filename");
|
|
9506
9536
|
this.#$contentSlot = shadowRoot.querySelector('slot[name="content"]');
|
|
9537
|
+
this.#$icons = new Map(typeValues$2.map((type) => [type, shadowRoot.querySelector(`#icon-${type}`)]));
|
|
9538
|
+
this.#updateIcons(null);
|
|
9507
9539
|
}
|
|
9508
9540
|
connectedCallback() {
|
|
9509
9541
|
super.connectedCallback();
|
|
@@ -9535,8 +9567,20 @@ class FileStatus extends NectaryElement {
|
|
|
9535
9567
|
set filename(value) {
|
|
9536
9568
|
updateAttribute(this, "filename", value);
|
|
9537
9569
|
}
|
|
9570
|
+
get size() {
|
|
9571
|
+
return getLiteralAttribute(this, sizeValues, "size", "m");
|
|
9572
|
+
}
|
|
9573
|
+
set size(value) {
|
|
9574
|
+
updateLiteralAttribute(this, sizeValues, "size", value);
|
|
9575
|
+
}
|
|
9576
|
+
get icons() {
|
|
9577
|
+
return getAttribute(this, "icons");
|
|
9578
|
+
}
|
|
9579
|
+
set icons(value) {
|
|
9580
|
+
updateAttribute(this, "icons", value);
|
|
9581
|
+
}
|
|
9538
9582
|
static get observedAttributes() {
|
|
9539
|
-
return ["filename"];
|
|
9583
|
+
return ["filename", "icons"];
|
|
9540
9584
|
}
|
|
9541
9585
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
9542
9586
|
switch (name) {
|
|
@@ -9544,6 +9588,16 @@ class FileStatus extends NectaryElement {
|
|
|
9544
9588
|
this.#$filename.textContent = newVal;
|
|
9545
9589
|
break;
|
|
9546
9590
|
}
|
|
9591
|
+
case "icons": {
|
|
9592
|
+
this.#updateIcons(newVal);
|
|
9593
|
+
break;
|
|
9594
|
+
}
|
|
9595
|
+
}
|
|
9596
|
+
}
|
|
9597
|
+
#updateIcons(json) {
|
|
9598
|
+
const icons = parseIcons(json);
|
|
9599
|
+
for (const [type, $icon] of this.#$icons) {
|
|
9600
|
+
updateAttribute($icon, "name", icons[type] ?? defaultIcons[type]);
|
|
9547
9601
|
}
|
|
9548
9602
|
}
|
|
9549
9603
|
#onContentSlotChange = () => {
|
|
@@ -15976,10 +16030,10 @@ class SelectButton extends NectaryElement {
|
|
|
15976
16030
|
return getBooleanAttribute(this, "disabled");
|
|
15977
16031
|
}
|
|
15978
16032
|
set size(size) {
|
|
15979
|
-
updateLiteralAttribute(this, sizeValues$
|
|
16033
|
+
updateLiteralAttribute(this, sizeValues$2, "size", size);
|
|
15980
16034
|
}
|
|
15981
16035
|
get size() {
|
|
15982
|
-
return getLiteralAttribute(this, sizeValues$
|
|
16036
|
+
return getLiteralAttribute(this, sizeValues$2, "size", DEFAULT_SIZE);
|
|
15983
16037
|
}
|
|
15984
16038
|
get focusable() {
|
|
15985
16039
|
return true;
|
package/file-status/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import '../spinner';
|
|
|
2
2
|
import '../icon';
|
|
3
3
|
import '../text';
|
|
4
4
|
import { NectaryElement } from '../utils';
|
|
5
|
-
import type { TSinchFileStatusType } from './types';
|
|
5
|
+
import type { TSinchFileStatusSize, TSinchFileStatusType } from './types';
|
|
6
6
|
export * from './types';
|
|
7
7
|
export declare class FileStatus extends NectaryElement {
|
|
8
8
|
#private;
|
|
@@ -13,6 +13,10 @@ export declare class FileStatus extends NectaryElement {
|
|
|
13
13
|
set type(value: TSinchFileStatusType);
|
|
14
14
|
get filename(): string;
|
|
15
15
|
set filename(value: string);
|
|
16
|
+
get size(): TSinchFileStatusSize;
|
|
17
|
+
set size(value: TSinchFileStatusSize);
|
|
18
|
+
get icons(): string | null;
|
|
19
|
+
set icons(value: string | null);
|
|
16
20
|
static get observedAttributes(): string[];
|
|
17
21
|
attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null): void;
|
|
18
22
|
}
|
package/file-status/index.js
CHANGED
|
@@ -3,13 +3,14 @@ import "../icon/index.js";
|
|
|
3
3
|
import "../text/index.js";
|
|
4
4
|
import { getLiteralAttribute, updateLiteralAttribute, getAttribute, updateAttribute, updateBooleanAttribute } from "../utils/dom.js";
|
|
5
5
|
import { defineCustomElement, NectaryElement } from "../utils/element.js";
|
|
6
|
-
import { typeValues } from "./utils.js";
|
|
7
|
-
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;align-items:flex-start;padding:12px 16px;box-sizing:border-box;min-height:48px;min-width:148px;border-radius:var(--sinch-comp-file-status-shape-radius)}:host([type=error]) #wrapper{background-color:var(--sinch-comp-file-status-color-error-background)}:host([type=success]) #wrapper{background-color:var(--sinch-comp-file-status-color-success-background)}:host([type=pending]) #wrapper{background-color:var(--sinch-comp-file-status-color-pending-background)}:host([type=progress]) #wrapper{background-color:var(--sinch-comp-file-status-color-progress-background)}:host([type=loading]) #wrapper{background-color:var(--sinch-comp-file-status-color-loading-background)}#content-wrapper{display:flex;flex-direction:column;gap:8px;flex:1;min-width:0;min-height:24px;margin-left:16px}:host([type=error]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-error-text)}:host([type=success]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-success-text)}:host([type=pending]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-pending-text)}:host([type=progress]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-progress-text)}:host([type=loading]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-loading-text)}#action{display:flex;gap:4px;height:32px;margin-top:-4px;margin-bottom:-4px}#icon-error,#icon-loading,#icon-pending,#icon-progress,#icon-success{display:none}#icon-pending{--sinch-global-color-icon:var(--sinch-comp-file-status-color-pending-icon)}#icon-success{--sinch-global-color-icon:var(--sinch-comp-file-status-color-success-icon)}#icon-progress{--sinch-global-color-icon:var(--sinch-comp-file-status-color-progress-icon)}#icon-error{--sinch-global-color-icon:var(--sinch-comp-file-status-color-error-icon)}#icon-loading{--sinch-global-color-icon:var(--sinch-comp-file-status-color-loading-icon)}:host([type=error]) #icon-error,:host([type=loading]) #icon-loading,:host([type=pending]) #icon-pending,:host([type=progress]) #icon-progress,:host([type=success]) #icon-success{display:block}</style><div id="wrapper"><sinch-
|
|
6
|
+
import { typeValues, sizeValues, parseIcons, defaultIcons } from "./utils.js";
|
|
7
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;align-items:flex-start;padding:12px 16px;box-sizing:border-box;min-height:48px;min-width:148px;border-radius:var(--sinch-comp-file-status-shape-radius)}:host([type=error]) #wrapper{background-color:var(--sinch-comp-file-status-color-error-background)}:host([type=success]) #wrapper{background-color:var(--sinch-comp-file-status-color-success-background)}:host([type=pending]) #wrapper{background-color:var(--sinch-comp-file-status-color-pending-background)}:host([type=progress]) #wrapper{background-color:var(--sinch-comp-file-status-color-progress-background)}:host([type=loading]) #wrapper{background-color:var(--sinch-comp-file-status-color-loading-background)}:host([size="s"]) #wrapper{padding:6px;min-height:36px}#content-wrapper{display:flex;flex-direction:column;gap:8px;flex:1;min-width:0;min-height:24px;margin-left:16px}:host([size="s"]) #content-wrapper{margin-left:6px}:host([type=error]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-error-text)}:host([type=success]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-success-text)}:host([type=pending]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-pending-text)}:host([type=progress]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-progress-text)}:host([type=loading]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-loading-text)}#action{display:flex;gap:4px;height:32px;margin-top:-4px;margin-bottom:-4px}#icon-error,#icon-loading,#icon-pending,#icon-progress,#icon-success,#spinner{display:none}#icon-pending{--sinch-global-color-icon:var(--sinch-comp-file-status-color-pending-icon)}#icon-success{--sinch-global-color-icon:var(--sinch-comp-file-status-color-success-icon)}#icon-progress{--sinch-global-color-icon:var(--sinch-comp-file-status-color-progress-icon)}#icon-error{--sinch-global-color-icon:var(--sinch-comp-file-status-color-error-icon)}#icon-loading,#spinner{--sinch-global-color-icon:var(--sinch-comp-file-status-color-loading-icon)}:host([type=error]) #icon-error,:host([type=loading]) #icon-loading[name],:host([type=loading]) #spinner,:host([type=pending]) #icon-pending,:host([type=progress]) #icon-progress,:host([type=success]) #icon-success{display:block}#icon-loading[name]+#spinner{display:none}</style><div id="wrapper"><sinch-icon icons-version="2" id="icon-loading"></sinch-icon><sinch-spinner id="spinner" size="m"></sinch-spinner><sinch-icon icons-version="2" id="icon-pending"></sinch-icon><sinch-icon icons-version="2" id="icon-success"></sinch-icon><sinch-icon icons-version="2" id="icon-progress"></sinch-icon><sinch-icon icons-version="2" id="icon-error"></sinch-icon><div id="content-wrapper"><sinch-text id="filename" type="m" ellipsis></sinch-text><slot name="content"></slot></div><div id="action"><slot name="action"></slot></div></div>';
|
|
8
8
|
const template = document.createElement("template");
|
|
9
9
|
template.innerHTML = templateHTML;
|
|
10
10
|
class FileStatus extends NectaryElement {
|
|
11
11
|
#$filename;
|
|
12
12
|
#$contentSlot;
|
|
13
|
+
#$icons;
|
|
13
14
|
#controller = null;
|
|
14
15
|
constructor() {
|
|
15
16
|
super();
|
|
@@ -17,6 +18,8 @@ class FileStatus extends NectaryElement {
|
|
|
17
18
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
18
19
|
this.#$filename = shadowRoot.querySelector("#filename");
|
|
19
20
|
this.#$contentSlot = shadowRoot.querySelector('slot[name="content"]');
|
|
21
|
+
this.#$icons = new Map(typeValues.map((type) => [type, shadowRoot.querySelector(`#icon-${type}`)]));
|
|
22
|
+
this.#updateIcons(null);
|
|
20
23
|
}
|
|
21
24
|
connectedCallback() {
|
|
22
25
|
super.connectedCallback();
|
|
@@ -48,8 +51,20 @@ class FileStatus extends NectaryElement {
|
|
|
48
51
|
set filename(value) {
|
|
49
52
|
updateAttribute(this, "filename", value);
|
|
50
53
|
}
|
|
54
|
+
get size() {
|
|
55
|
+
return getLiteralAttribute(this, sizeValues, "size", "m");
|
|
56
|
+
}
|
|
57
|
+
set size(value) {
|
|
58
|
+
updateLiteralAttribute(this, sizeValues, "size", value);
|
|
59
|
+
}
|
|
60
|
+
get icons() {
|
|
61
|
+
return getAttribute(this, "icons");
|
|
62
|
+
}
|
|
63
|
+
set icons(value) {
|
|
64
|
+
updateAttribute(this, "icons", value);
|
|
65
|
+
}
|
|
51
66
|
static get observedAttributes() {
|
|
52
|
-
return ["filename"];
|
|
67
|
+
return ["filename", "icons"];
|
|
53
68
|
}
|
|
54
69
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
55
70
|
switch (name) {
|
|
@@ -57,6 +72,16 @@ class FileStatus extends NectaryElement {
|
|
|
57
72
|
this.#$filename.textContent = newVal;
|
|
58
73
|
break;
|
|
59
74
|
}
|
|
75
|
+
case "icons": {
|
|
76
|
+
this.#updateIcons(newVal);
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
#updateIcons(json) {
|
|
82
|
+
const icons = parseIcons(json);
|
|
83
|
+
for (const [type, $icon] of this.#$icons) {
|
|
84
|
+
updateAttribute($icon, "name", icons[type] ?? defaultIcons[type]);
|
|
60
85
|
}
|
|
61
86
|
}
|
|
62
87
|
#onContentSlotChange = () => {
|
package/file-status/types.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import type { NectaryComponentReactByType, NectaryComponentVanillaByType, NectaryComponentReact, NectaryComponentVanilla } from '../types';
|
|
2
2
|
export type TSinchFileStatusType = 'pending' | 'loading' | 'progress' | 'success' | 'error';
|
|
3
|
+
export type TSinchFileStatusSize = 's' | 'm';
|
|
4
|
+
/** Icon name per type; types left out keep their default icon */
|
|
5
|
+
export type TSinchFileStatusIcons = Partial<Record<TSinchFileStatusType, string>>;
|
|
3
6
|
export type TSinchFileStatusProps = {
|
|
4
7
|
/** File status type */
|
|
5
8
|
type: TSinchFileStatusType;
|
|
6
9
|
/** File name */
|
|
7
10
|
filename: string;
|
|
11
|
+
/** Size, `m` by default */
|
|
12
|
+
size?: TSinchFileStatusSize;
|
|
13
|
+
/** JSON string of `TSinchFileStatusIcons` overriding the icon per type, e.g. `{"success":"fa-check"}`. A `loading` icon replaces the spinner */
|
|
14
|
+
icons?: string;
|
|
8
15
|
};
|
|
9
16
|
export type TSinchFileStatusStyle = {
|
|
10
17
|
'--sinch-comp-file-status-shape-radius'?: string;
|
package/file-status/utils.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import type { TSinchFileStatusType } from './types';
|
|
1
|
+
import type { TSinchFileStatusIcons, TSinchFileStatusSize, TSinchFileStatusType } from './types';
|
|
2
2
|
export declare const typeValues: readonly TSinchFileStatusType[];
|
|
3
|
+
export declare const sizeValues: readonly TSinchFileStatusSize[];
|
|
4
|
+
/** `loading` has no default icon: it renders a spinner unless overridden */
|
|
5
|
+
export declare const defaultIcons: TSinchFileStatusIcons;
|
|
6
|
+
/** Parses the `icons` attribute, keeping only known types with non-empty string names */
|
|
7
|
+
export declare const parseIcons: (json: string | null) => TSinchFileStatusIcons;
|
package/file-status/utils.js
CHANGED
|
@@ -1,4 +1,36 @@
|
|
|
1
1
|
const typeValues = ["pending", "loading", "progress", "success", "error"];
|
|
2
|
+
const sizeValues = ["s", "m"];
|
|
3
|
+
const defaultIcons = {
|
|
4
|
+
pending: "fa-clipboard-question",
|
|
5
|
+
progress: "fa-file-lines",
|
|
6
|
+
success: "circle-check",
|
|
7
|
+
error: "octagon-exclamation"
|
|
8
|
+
};
|
|
9
|
+
const parseIcons = (json) => {
|
|
10
|
+
const icons = {};
|
|
11
|
+
if (json === null) {
|
|
12
|
+
return icons;
|
|
13
|
+
}
|
|
14
|
+
let parsed;
|
|
15
|
+
try {
|
|
16
|
+
parsed = JSON.parse(json);
|
|
17
|
+
} catch {
|
|
18
|
+
return icons;
|
|
19
|
+
}
|
|
20
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
21
|
+
return icons;
|
|
22
|
+
}
|
|
23
|
+
for (const type of typeValues) {
|
|
24
|
+
const name = parsed[type];
|
|
25
|
+
if (typeof name === "string" && name !== "") {
|
|
26
|
+
icons[type] = name;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return icons;
|
|
30
|
+
};
|
|
2
31
|
export {
|
|
32
|
+
defaultIcons,
|
|
33
|
+
parseIcons,
|
|
34
|
+
sizeValues,
|
|
3
35
|
typeValues
|
|
4
36
|
};
|
package/input/index.js
CHANGED
|
@@ -740,9 +740,9 @@ class Input extends NectaryElement {
|
|
|
740
740
|
const size = this.getAttribute("data-size") ?? DEFAULT_SIZE;
|
|
741
741
|
this.#sizeContext.dispatch(size);
|
|
742
742
|
}
|
|
743
|
+
// No `onKeyDown` lookup: the native keydown is composed, so React already calls `onKeyDown` itself
|
|
743
744
|
#onKeyDownReactHandler = (e) => {
|
|
744
745
|
getReactEventHandler(this, "on-key-down")?.(e);
|
|
745
|
-
getReactEventHandler(this, "onKeyDown")?.(e);
|
|
746
746
|
};
|
|
747
747
|
#onChangeReactHandler = (e) => {
|
|
748
748
|
getReactEventHandler(this, "on-change")?.(e);
|