@nectary/components 5.55.0 → 5.57.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 +113 -21
- package/field-v2/index.d.ts +2 -0
- package/field-v2/index.js +42 -4
- package/field-v2/types.d.ts +2 -0
- 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/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);
|
|
@@ -8864,13 +8864,15 @@ class Field extends NectaryElement {
|
|
|
8864
8864
|
};
|
|
8865
8865
|
}
|
|
8866
8866
|
defineCustomElement("sinch-field", Field);
|
|
8867
|
-
const templateHTML$N = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;width:100%}#top{display:flex;align-items:baseline;height:24px;margin-bottom:2px}#bottom{display:flex;flex-direction:column;align-items:baseline;width:100%}#top.empty{display:none}#label{display:flex;align-items:baseline;min-width:0;font:var(--sinch-comp-field-font-label);color:var(--sinch-comp-field-color-default-label-initial)}#label-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}#asterisk{display:none;flex-shrink:0;color:var(--sinch-comp-field-color-default-asterisk-initial);margin-left:2px}:host([required]:not([disabled])) #asterisk{display:block}#optional{flex:1;font:var(--sinch-comp-field-font-optional);color:var(--sinch-comp-field-color-default-optional-initial);text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#additional{flex:1;text-align:left;line-height:20px;margin-top:2px;white-space:normal;overflow:visible;--sinch-comp-rich-text-font:var(--sinch-comp-field-font-additional);--sinch-global-color-text:var(--sinch-comp-field-color-default-additional-initial);--sinch-comp-link-color-default-text-initial:var(--sinch-comp-field-color-default-additional-initial);--sinch-comp-link-color-default-text-hover:var(--sinch-comp-field-color-default-additional-initial)}#additional:is([text=""],:not([text])){display:none}#invalid{font:var(--sinch-comp-field-font-invalid);color:var(--sinch-comp-field-color-invalid-text-initial);line-height:20px;margin-top:2px;white-space:normal;overflow:visible;--sinch-comp-rich-text-font:var(--sinch-comp-field-font-invalid);--sinch-global-color-text:var(--sinch-comp-field-color-invalid-text-initial);--sinch-comp-link-color-default-text-initial:var(--sinch-comp-field-color-invalid-text-initial);--sinch-comp-link-color-default-text-hover:var(--sinch-comp-field-color-invalid-text-initial)}#invalid:is([text=""],:not([text])){display:none}#tooltip{align-self:center;margin:0 8px;display:flex}#tooltip.empty{display:none}:host([disabled]) #label{color:var(--sinch-comp-field-color-disabled-label-initial)}:host([disabled]) #additional{--sinch-global-color-text:var(--sinch-comp-field-color-disabled-additional-initial);--sinch-comp-link-color-default-text-initial:var(--sinch-comp-field-color-disabled-additional-initial);--sinch-comp-link-color-default-text-hover:var(--sinch-comp-field-color-disabled-additional-initial)}:host([disabled]) #optional{color:var(--sinch-comp-field-color-disabled-optional-initial)}</style><div id="wrapper"><div id="top"><label id="label" for="input"><span id="label-text"></span><span id="asterisk" aria-hidden="true">*</span
|
|
8867
|
+
const templateHTML$N = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;width:100%}#top{display:flex;align-items:baseline;height:24px;margin-bottom:2px}#bottom{display:flex;flex-direction:column;align-items:baseline;width:100%}#top.empty{display:none}#label{display:flex;align-items:baseline;min-width:0;font:var(--sinch-comp-field-font-label);color:var(--sinch-comp-field-color-default-label-initial)}#label-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}#label-end{display:inline-flex;align-items:center;align-self:center;flex-shrink:0}#label-tail{display:inline-flex;align-items:center;flex-shrink:0;white-space:nowrap;vertical-align:baseline}#asterisk{display:none;flex-shrink:0;color:var(--sinch-comp-field-color-default-asterisk-initial);margin-left:2px}:host([required]:not([disabled])) #asterisk{display:block}#optional{flex:1;font:var(--sinch-comp-field-font-optional);color:var(--sinch-comp-field-color-default-optional-initial);text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#additional{flex:1;text-align:left;line-height:20px;margin-top:2px;white-space:normal;overflow:visible;--sinch-comp-rich-text-font:var(--sinch-comp-field-font-additional);--sinch-global-color-text:var(--sinch-comp-field-color-default-additional-initial);--sinch-comp-link-color-default-text-initial:var(--sinch-comp-field-color-default-additional-initial);--sinch-comp-link-color-default-text-hover:var(--sinch-comp-field-color-default-additional-initial)}#additional:is([text=""],:not([text])){display:none}#invalid{font:var(--sinch-comp-field-font-invalid);color:var(--sinch-comp-field-color-invalid-text-initial);line-height:20px;margin-top:2px;white-space:normal;overflow:visible;--sinch-comp-rich-text-font:var(--sinch-comp-field-font-invalid);--sinch-global-color-text:var(--sinch-comp-field-color-invalid-text-initial);--sinch-comp-link-color-default-text-initial:var(--sinch-comp-field-color-invalid-text-initial);--sinch-comp-link-color-default-text-hover:var(--sinch-comp-field-color-invalid-text-initial)}#invalid:is([text=""],:not([text])){display:none}#tooltip{align-self:center;margin:0 8px;display:flex}#tooltip.empty{display:none}:host([disabled]) #label{color:var(--sinch-comp-field-color-disabled-label-initial)}:host([disabled]) #additional{--sinch-global-color-text:var(--sinch-comp-field-color-disabled-additional-initial);--sinch-comp-link-color-default-text-initial:var(--sinch-comp-field-color-disabled-additional-initial);--sinch-comp-link-color-default-text-hover:var(--sinch-comp-field-color-disabled-additional-initial)}:host([disabled]) #optional{color:var(--sinch-comp-field-color-disabled-optional-initial)}:host([multiline]) #top{height:auto;min-height:24px;align-items:flex-start}:host([multiline]) #label{display:block;flex:1;min-width:0}:host([multiline]) #label-text{overflow:visible;text-overflow:unset;white-space:normal;overflow-wrap:break-word}:host([multiline]) #label-end{display:inline-block;width:max-content;max-width:100%;vertical-align:baseline;white-space:normal}:host([multiline]) #label-last{white-space:normal;overflow-wrap:break-word}:host([multiline]) #tooltip{flex-shrink:0}:host([multiline]) #optional:empty{display:none}</style><div id="wrapper"><div id="top"><label id="label" for="input"><span id="label-text"></span><span id="label-end"><span id="label-last"></span><span id="label-tail"><span id="label-tail-text"></span><span id="asterisk" aria-hidden="true">*</span><span id="tooltip"><slot name="tooltip"></slot></span></span></span></label> <span id="optional"></span></div><slot name="input"></slot><div id="bottom"><sinch-rich-text id="additional"></sinch-rich-text><sinch-rich-text id="invalid"></sinch-rich-text></div></div>';
|
|
8868
8868
|
const template$N = document.createElement("template");
|
|
8869
8869
|
template$N.innerHTML = templateHTML$N;
|
|
8870
8870
|
class FieldV2 extends NectaryElement {
|
|
8871
8871
|
#topSection;
|
|
8872
8872
|
#$label;
|
|
8873
8873
|
#$labelText;
|
|
8874
|
+
#$labelLast;
|
|
8875
|
+
#$labelTailText;
|
|
8874
8876
|
#$optionalText;
|
|
8875
8877
|
#$additionalText;
|
|
8876
8878
|
#$invalidText;
|
|
@@ -8885,6 +8887,8 @@ class FieldV2 extends NectaryElement {
|
|
|
8885
8887
|
this.#topSection = shadowRoot.querySelector("#top");
|
|
8886
8888
|
this.#$label = shadowRoot.querySelector("#label");
|
|
8887
8889
|
this.#$labelText = shadowRoot.querySelector("#label-text");
|
|
8890
|
+
this.#$labelLast = shadowRoot.querySelector("#label-last");
|
|
8891
|
+
this.#$labelTailText = shadowRoot.querySelector("#label-tail-text");
|
|
8888
8892
|
this.#$optionalText = shadowRoot.querySelector("#optional");
|
|
8889
8893
|
this.#$additionalText = shadowRoot.querySelector("#additional");
|
|
8890
8894
|
this.#$invalidText = shadowRoot.querySelector("#invalid");
|
|
@@ -8915,7 +8919,8 @@ class FieldV2 extends NectaryElement {
|
|
|
8915
8919
|
"additionaltext",
|
|
8916
8920
|
"invalidtext",
|
|
8917
8921
|
"disabled",
|
|
8918
|
-
"required"
|
|
8922
|
+
"required",
|
|
8923
|
+
"multiline"
|
|
8919
8924
|
];
|
|
8920
8925
|
}
|
|
8921
8926
|
#shouldShowTopSection() {
|
|
@@ -8926,7 +8931,7 @@ class FieldV2 extends NectaryElement {
|
|
|
8926
8931
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
8927
8932
|
switch (name) {
|
|
8928
8933
|
case "label": {
|
|
8929
|
-
this
|
|
8934
|
+
this.#syncLabelText();
|
|
8930
8935
|
this.#syncInputAriaLabel(newVal);
|
|
8931
8936
|
break;
|
|
8932
8937
|
}
|
|
@@ -8950,6 +8955,14 @@ class FieldV2 extends NectaryElement {
|
|
|
8950
8955
|
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
8951
8956
|
break;
|
|
8952
8957
|
}
|
|
8958
|
+
case "multiline": {
|
|
8959
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
8960
|
+
break;
|
|
8961
|
+
}
|
|
8962
|
+
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
8963
|
+
this.#syncLabelText();
|
|
8964
|
+
break;
|
|
8965
|
+
}
|
|
8953
8966
|
}
|
|
8954
8967
|
this.#shouldShowTopSection();
|
|
8955
8968
|
}
|
|
@@ -8989,6 +9002,12 @@ class FieldV2 extends NectaryElement {
|
|
|
8989
9002
|
get required() {
|
|
8990
9003
|
return getBooleanAttribute(this, "required");
|
|
8991
9004
|
}
|
|
9005
|
+
set multiline(isMultiline) {
|
|
9006
|
+
updateBooleanAttribute(this, "multiline", isMultiline);
|
|
9007
|
+
}
|
|
9008
|
+
get multiline() {
|
|
9009
|
+
return getBooleanAttribute(this, "multiline");
|
|
9010
|
+
}
|
|
8992
9011
|
#onRichTextElementClick = (e) => {
|
|
8993
9012
|
if (this.disabled) {
|
|
8994
9013
|
return;
|
|
@@ -9003,12 +9022,31 @@ class FieldV2 extends NectaryElement {
|
|
|
9003
9022
|
getReactEventHandler(this, "on-element-click")?.(e);
|
|
9004
9023
|
getReactEventHandler(this, "onElementClick")?.(e);
|
|
9005
9024
|
};
|
|
9006
|
-
#onLabelClick = () => {
|
|
9025
|
+
#onLabelClick = (e) => {
|
|
9026
|
+
if (e.composedPath().includes(this.#$tooltipWrapper)) {
|
|
9027
|
+
return;
|
|
9028
|
+
}
|
|
9007
9029
|
getFirstSlotElement(this.#$inputSlot)?.focus?.();
|
|
9008
9030
|
};
|
|
9009
9031
|
#onTooltipSlotChange = () => {
|
|
9010
9032
|
setClass(this.#$tooltipWrapper, "empty", this.#$tooltipSlot.assignedElements().length === 0);
|
|
9011
9033
|
};
|
|
9034
|
+
#syncLabelText() {
|
|
9035
|
+
const label = getAttribute(this, "label") ?? "";
|
|
9036
|
+
if (!this.multiline) {
|
|
9037
|
+
this.#$labelText.textContent = label;
|
|
9038
|
+
this.#$labelLast.textContent = "";
|
|
9039
|
+
this.#$labelTailText.textContent = "";
|
|
9040
|
+
return;
|
|
9041
|
+
}
|
|
9042
|
+
const match = /^(.*\s)(\S+)\s*$/.exec(label);
|
|
9043
|
+
const word = match == null ? label : match[2];
|
|
9044
|
+
const chars = Array.from(word);
|
|
9045
|
+
const tail = chars.pop() ?? "";
|
|
9046
|
+
this.#$labelText.textContent = match == null ? "" : match[1];
|
|
9047
|
+
this.#$labelLast.textContent = chars.join("");
|
|
9048
|
+
this.#$labelTailText.textContent = tail;
|
|
9049
|
+
}
|
|
9012
9050
|
#syncInputAriaLabel(labelText) {
|
|
9013
9051
|
const inputElement = getFirstSlotElement(this.#$inputSlot);
|
|
9014
9052
|
if (inputElement === null) {
|
|
@@ -9430,10 +9468,10 @@ class Spinner extends NectaryElement {
|
|
|
9430
9468
|
}
|
|
9431
9469
|
}
|
|
9432
9470
|
set size(size) {
|
|
9433
|
-
updateLiteralAttribute(this, sizeValues$
|
|
9471
|
+
updateLiteralAttribute(this, sizeValues$2, "size", size);
|
|
9434
9472
|
}
|
|
9435
9473
|
get size() {
|
|
9436
|
-
return getLiteralAttribute(this, sizeValues$
|
|
9474
|
+
return getLiteralAttribute(this, sizeValues$2, "size", DEFAULT_SIZE);
|
|
9437
9475
|
}
|
|
9438
9476
|
#onContextSize = (e) => {
|
|
9439
9477
|
if (this.hasAttribute("size") === true) {
|
|
@@ -9453,12 +9491,42 @@ class Spinner extends NectaryElement {
|
|
|
9453
9491
|
}
|
|
9454
9492
|
defineCustomElement("sinch-spinner", Spinner);
|
|
9455
9493
|
const typeValues$2 = ["pending", "loading", "progress", "success", "error"];
|
|
9456
|
-
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>';
|
|
9457
9524
|
const template$J = document.createElement("template");
|
|
9458
9525
|
template$J.innerHTML = templateHTML$J;
|
|
9459
9526
|
class FileStatus extends NectaryElement {
|
|
9460
9527
|
#$filename;
|
|
9461
9528
|
#$contentSlot;
|
|
9529
|
+
#$icons;
|
|
9462
9530
|
#controller = null;
|
|
9463
9531
|
constructor() {
|
|
9464
9532
|
super();
|
|
@@ -9466,6 +9534,8 @@ class FileStatus extends NectaryElement {
|
|
|
9466
9534
|
shadowRoot.appendChild(template$J.content.cloneNode(true));
|
|
9467
9535
|
this.#$filename = shadowRoot.querySelector("#filename");
|
|
9468
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);
|
|
9469
9539
|
}
|
|
9470
9540
|
connectedCallback() {
|
|
9471
9541
|
super.connectedCallback();
|
|
@@ -9497,8 +9567,20 @@ class FileStatus extends NectaryElement {
|
|
|
9497
9567
|
set filename(value) {
|
|
9498
9568
|
updateAttribute(this, "filename", value);
|
|
9499
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
|
+
}
|
|
9500
9582
|
static get observedAttributes() {
|
|
9501
|
-
return ["filename"];
|
|
9583
|
+
return ["filename", "icons"];
|
|
9502
9584
|
}
|
|
9503
9585
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
9504
9586
|
switch (name) {
|
|
@@ -9506,6 +9588,16 @@ class FileStatus extends NectaryElement {
|
|
|
9506
9588
|
this.#$filename.textContent = newVal;
|
|
9507
9589
|
break;
|
|
9508
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]);
|
|
9509
9601
|
}
|
|
9510
9602
|
}
|
|
9511
9603
|
#onContentSlotChange = () => {
|
|
@@ -15938,10 +16030,10 @@ class SelectButton extends NectaryElement {
|
|
|
15938
16030
|
return getBooleanAttribute(this, "disabled");
|
|
15939
16031
|
}
|
|
15940
16032
|
set size(size) {
|
|
15941
|
-
updateLiteralAttribute(this, sizeValues$
|
|
16033
|
+
updateLiteralAttribute(this, sizeValues$2, "size", size);
|
|
15942
16034
|
}
|
|
15943
16035
|
get size() {
|
|
15944
|
-
return getLiteralAttribute(this, sizeValues$
|
|
16036
|
+
return getLiteralAttribute(this, sizeValues$2, "size", DEFAULT_SIZE);
|
|
15945
16037
|
}
|
|
15946
16038
|
get focusable() {
|
|
15947
16039
|
return true;
|
package/field-v2/index.d.ts
CHANGED
package/field-v2/index.js
CHANGED
|
@@ -3,13 +3,15 @@ import { getAttribute, setClass, isAttrEqual, updateBooleanAttribute, isAttrTrue
|
|
|
3
3
|
import { defineCustomElement, NectaryElement } from "../utils/element.js";
|
|
4
4
|
import { getFirstSlotElement } from "../utils/slot.js";
|
|
5
5
|
import { getReactEventHandler } from "../utils/get-react-event-handler.js";
|
|
6
|
-
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;width:100%}#top{display:flex;align-items:baseline;height:24px;margin-bottom:2px}#bottom{display:flex;flex-direction:column;align-items:baseline;width:100%}#top.empty{display:none}#label{display:flex;align-items:baseline;min-width:0;font:var(--sinch-comp-field-font-label);color:var(--sinch-comp-field-color-default-label-initial)}#label-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}#asterisk{display:none;flex-shrink:0;color:var(--sinch-comp-field-color-default-asterisk-initial);margin-left:2px}:host([required]:not([disabled])) #asterisk{display:block}#optional{flex:1;font:var(--sinch-comp-field-font-optional);color:var(--sinch-comp-field-color-default-optional-initial);text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#additional{flex:1;text-align:left;line-height:20px;margin-top:2px;white-space:normal;overflow:visible;--sinch-comp-rich-text-font:var(--sinch-comp-field-font-additional);--sinch-global-color-text:var(--sinch-comp-field-color-default-additional-initial);--sinch-comp-link-color-default-text-initial:var(--sinch-comp-field-color-default-additional-initial);--sinch-comp-link-color-default-text-hover:var(--sinch-comp-field-color-default-additional-initial)}#additional:is([text=""],:not([text])){display:none}#invalid{font:var(--sinch-comp-field-font-invalid);color:var(--sinch-comp-field-color-invalid-text-initial);line-height:20px;margin-top:2px;white-space:normal;overflow:visible;--sinch-comp-rich-text-font:var(--sinch-comp-field-font-invalid);--sinch-global-color-text:var(--sinch-comp-field-color-invalid-text-initial);--sinch-comp-link-color-default-text-initial:var(--sinch-comp-field-color-invalid-text-initial);--sinch-comp-link-color-default-text-hover:var(--sinch-comp-field-color-invalid-text-initial)}#invalid:is([text=""],:not([text])){display:none}#tooltip{align-self:center;margin:0 8px;display:flex}#tooltip.empty{display:none}:host([disabled]) #label{color:var(--sinch-comp-field-color-disabled-label-initial)}:host([disabled]) #additional{--sinch-global-color-text:var(--sinch-comp-field-color-disabled-additional-initial);--sinch-comp-link-color-default-text-initial:var(--sinch-comp-field-color-disabled-additional-initial);--sinch-comp-link-color-default-text-hover:var(--sinch-comp-field-color-disabled-additional-initial)}:host([disabled]) #optional{color:var(--sinch-comp-field-color-disabled-optional-initial)}</style><div id="wrapper"><div id="top"><label id="label" for="input"><span id="label-text"></span><span id="asterisk" aria-hidden="true">*</span
|
|
6
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;width:100%}#top{display:flex;align-items:baseline;height:24px;margin-bottom:2px}#bottom{display:flex;flex-direction:column;align-items:baseline;width:100%}#top.empty{display:none}#label{display:flex;align-items:baseline;min-width:0;font:var(--sinch-comp-field-font-label);color:var(--sinch-comp-field-color-default-label-initial)}#label-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}#label-end{display:inline-flex;align-items:center;align-self:center;flex-shrink:0}#label-tail{display:inline-flex;align-items:center;flex-shrink:0;white-space:nowrap;vertical-align:baseline}#asterisk{display:none;flex-shrink:0;color:var(--sinch-comp-field-color-default-asterisk-initial);margin-left:2px}:host([required]:not([disabled])) #asterisk{display:block}#optional{flex:1;font:var(--sinch-comp-field-font-optional);color:var(--sinch-comp-field-color-default-optional-initial);text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#additional{flex:1;text-align:left;line-height:20px;margin-top:2px;white-space:normal;overflow:visible;--sinch-comp-rich-text-font:var(--sinch-comp-field-font-additional);--sinch-global-color-text:var(--sinch-comp-field-color-default-additional-initial);--sinch-comp-link-color-default-text-initial:var(--sinch-comp-field-color-default-additional-initial);--sinch-comp-link-color-default-text-hover:var(--sinch-comp-field-color-default-additional-initial)}#additional:is([text=""],:not([text])){display:none}#invalid{font:var(--sinch-comp-field-font-invalid);color:var(--sinch-comp-field-color-invalid-text-initial);line-height:20px;margin-top:2px;white-space:normal;overflow:visible;--sinch-comp-rich-text-font:var(--sinch-comp-field-font-invalid);--sinch-global-color-text:var(--sinch-comp-field-color-invalid-text-initial);--sinch-comp-link-color-default-text-initial:var(--sinch-comp-field-color-invalid-text-initial);--sinch-comp-link-color-default-text-hover:var(--sinch-comp-field-color-invalid-text-initial)}#invalid:is([text=""],:not([text])){display:none}#tooltip{align-self:center;margin:0 8px;display:flex}#tooltip.empty{display:none}:host([disabled]) #label{color:var(--sinch-comp-field-color-disabled-label-initial)}:host([disabled]) #additional{--sinch-global-color-text:var(--sinch-comp-field-color-disabled-additional-initial);--sinch-comp-link-color-default-text-initial:var(--sinch-comp-field-color-disabled-additional-initial);--sinch-comp-link-color-default-text-hover:var(--sinch-comp-field-color-disabled-additional-initial)}:host([disabled]) #optional{color:var(--sinch-comp-field-color-disabled-optional-initial)}:host([multiline]) #top{height:auto;min-height:24px;align-items:flex-start}:host([multiline]) #label{display:block;flex:1;min-width:0}:host([multiline]) #label-text{overflow:visible;text-overflow:unset;white-space:normal;overflow-wrap:break-word}:host([multiline]) #label-end{display:inline-block;width:max-content;max-width:100%;vertical-align:baseline;white-space:normal}:host([multiline]) #label-last{white-space:normal;overflow-wrap:break-word}:host([multiline]) #tooltip{flex-shrink:0}:host([multiline]) #optional:empty{display:none}</style><div id="wrapper"><div id="top"><label id="label" for="input"><span id="label-text"></span><span id="label-end"><span id="label-last"></span><span id="label-tail"><span id="label-tail-text"></span><span id="asterisk" aria-hidden="true">*</span><span id="tooltip"><slot name="tooltip"></slot></span></span></span></label> <span id="optional"></span></div><slot name="input"></slot><div id="bottom"><sinch-rich-text id="additional"></sinch-rich-text><sinch-rich-text id="invalid"></sinch-rich-text></div></div>';
|
|
7
7
|
const template = document.createElement("template");
|
|
8
8
|
template.innerHTML = templateHTML;
|
|
9
9
|
class FieldV2 extends NectaryElement {
|
|
10
10
|
#topSection;
|
|
11
11
|
#$label;
|
|
12
12
|
#$labelText;
|
|
13
|
+
#$labelLast;
|
|
14
|
+
#$labelTailText;
|
|
13
15
|
#$optionalText;
|
|
14
16
|
#$additionalText;
|
|
15
17
|
#$invalidText;
|
|
@@ -24,6 +26,8 @@ class FieldV2 extends NectaryElement {
|
|
|
24
26
|
this.#topSection = shadowRoot.querySelector("#top");
|
|
25
27
|
this.#$label = shadowRoot.querySelector("#label");
|
|
26
28
|
this.#$labelText = shadowRoot.querySelector("#label-text");
|
|
29
|
+
this.#$labelLast = shadowRoot.querySelector("#label-last");
|
|
30
|
+
this.#$labelTailText = shadowRoot.querySelector("#label-tail-text");
|
|
27
31
|
this.#$optionalText = shadowRoot.querySelector("#optional");
|
|
28
32
|
this.#$additionalText = shadowRoot.querySelector("#additional");
|
|
29
33
|
this.#$invalidText = shadowRoot.querySelector("#invalid");
|
|
@@ -54,7 +58,8 @@ class FieldV2 extends NectaryElement {
|
|
|
54
58
|
"additionaltext",
|
|
55
59
|
"invalidtext",
|
|
56
60
|
"disabled",
|
|
57
|
-
"required"
|
|
61
|
+
"required",
|
|
62
|
+
"multiline"
|
|
58
63
|
];
|
|
59
64
|
}
|
|
60
65
|
#shouldShowTopSection() {
|
|
@@ -65,7 +70,7 @@ class FieldV2 extends NectaryElement {
|
|
|
65
70
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
66
71
|
switch (name) {
|
|
67
72
|
case "label": {
|
|
68
|
-
this
|
|
73
|
+
this.#syncLabelText();
|
|
69
74
|
this.#syncInputAriaLabel(newVal);
|
|
70
75
|
break;
|
|
71
76
|
}
|
|
@@ -89,6 +94,14 @@ class FieldV2 extends NectaryElement {
|
|
|
89
94
|
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
90
95
|
break;
|
|
91
96
|
}
|
|
97
|
+
case "multiline": {
|
|
98
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
102
|
+
this.#syncLabelText();
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
92
105
|
}
|
|
93
106
|
this.#shouldShowTopSection();
|
|
94
107
|
}
|
|
@@ -128,6 +141,12 @@ class FieldV2 extends NectaryElement {
|
|
|
128
141
|
get required() {
|
|
129
142
|
return getBooleanAttribute(this, "required");
|
|
130
143
|
}
|
|
144
|
+
set multiline(isMultiline) {
|
|
145
|
+
updateBooleanAttribute(this, "multiline", isMultiline);
|
|
146
|
+
}
|
|
147
|
+
get multiline() {
|
|
148
|
+
return getBooleanAttribute(this, "multiline");
|
|
149
|
+
}
|
|
131
150
|
#onRichTextElementClick = (e) => {
|
|
132
151
|
if (this.disabled) {
|
|
133
152
|
return;
|
|
@@ -142,12 +161,31 @@ class FieldV2 extends NectaryElement {
|
|
|
142
161
|
getReactEventHandler(this, "on-element-click")?.(e);
|
|
143
162
|
getReactEventHandler(this, "onElementClick")?.(e);
|
|
144
163
|
};
|
|
145
|
-
#onLabelClick = () => {
|
|
164
|
+
#onLabelClick = (e) => {
|
|
165
|
+
if (e.composedPath().includes(this.#$tooltipWrapper)) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
146
168
|
getFirstSlotElement(this.#$inputSlot)?.focus?.();
|
|
147
169
|
};
|
|
148
170
|
#onTooltipSlotChange = () => {
|
|
149
171
|
setClass(this.#$tooltipWrapper, "empty", this.#$tooltipSlot.assignedElements().length === 0);
|
|
150
172
|
};
|
|
173
|
+
#syncLabelText() {
|
|
174
|
+
const label = getAttribute(this, "label") ?? "";
|
|
175
|
+
if (!this.multiline) {
|
|
176
|
+
this.#$labelText.textContent = label;
|
|
177
|
+
this.#$labelLast.textContent = "";
|
|
178
|
+
this.#$labelTailText.textContent = "";
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const match = /^(.*\s)(\S+)\s*$/.exec(label);
|
|
182
|
+
const word = match == null ? label : match[2];
|
|
183
|
+
const chars = Array.from(word);
|
|
184
|
+
const tail = chars.pop() ?? "";
|
|
185
|
+
this.#$labelText.textContent = match == null ? "" : match[1];
|
|
186
|
+
this.#$labelLast.textContent = chars.join("");
|
|
187
|
+
this.#$labelTailText.textContent = tail;
|
|
188
|
+
}
|
|
151
189
|
#syncInputAriaLabel(labelText) {
|
|
152
190
|
const inputElement = getFirstSlotElement(this.#$inputSlot);
|
|
153
191
|
if (inputElement === null) {
|
package/field-v2/types.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export type TSinchFieldV2Props = {
|
|
|
17
17
|
disabled?: boolean;
|
|
18
18
|
/** Decorative required indicator. Renders an asterisk next to the label; hidden when disabled. Does not set validation or accessibility state on the inner control. */
|
|
19
19
|
required?: boolean;
|
|
20
|
+
/** Wraps the label onto multiple lines */
|
|
21
|
+
multiline?: boolean;
|
|
20
22
|
};
|
|
21
23
|
export type TSinchFieldV2Style = {
|
|
22
24
|
'--sinch-comp-field-font-label'?: string;
|
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
|
};
|