@nectary/components 5.14.6 → 5.15.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 +2840 -2487
- package/package.json +1 -1
- package/rich-text/index.d.ts +8 -1
- package/rich-text/index.js +36 -2
- package/rich-text/types.d.ts +11 -0
- package/rich-text/utils.d.ts +4 -0
- package/rich-text/utils.js +25 -3
- package/rich-textarea/index.d.ts +10 -1
- package/rich-textarea/index.js +123 -9
- package/rich-textarea/types.d.ts +16 -0
- package/rich-textarea/utils.d.ts +9 -2
- package/rich-textarea/utils.js +90 -21
- package/rich-textarea-chip/index.d.ts +20 -0
- package/rich-textarea-chip/index.js +116 -0
- package/rich-textarea-chip/types.d.ts +56 -0
- package/rich-textarea-chip/types.js +1 -0
- package/utils/component-names.d.ts +2 -2
- package/utils/component-names.js +1 -0
- package/utils/element.d.ts +1 -0
- package/utils/markdown.js +4 -4
package/rich-textarea/utils.js
CHANGED
|
@@ -22,6 +22,9 @@ const isTextBlock = ($n) => isParagraph($n) || isListItem($n);
|
|
|
22
22
|
const isEmoji = ($n) => {
|
|
23
23
|
return $n !== null && $n.nodeName === "IMG";
|
|
24
24
|
};
|
|
25
|
+
const isChip = ($n) => {
|
|
26
|
+
return $n !== null && $n.nodeName === "SINCH-RICH-TEXTAREA-CHIP";
|
|
27
|
+
};
|
|
25
28
|
const isInline = ($n) => $n !== null && $n.nodeName === "SPAN";
|
|
26
29
|
const isRoot = ($n) => $n !== null && $n.nodeName === "DIV";
|
|
27
30
|
const assertNonNull = ($n) => {
|
|
@@ -89,7 +92,7 @@ const assertInline = ($n) => {
|
|
|
89
92
|
}
|
|
90
93
|
};
|
|
91
94
|
const isTextContent = ($n) => {
|
|
92
|
-
return $n !== null && $n.nodeType === Node.ELEMENT_NODE && (isInline($n) || isEmoji($n));
|
|
95
|
+
return $n !== null && $n.nodeType === Node.ELEMENT_NODE && (isInline($n) || isEmoji($n) || isChip($n));
|
|
93
96
|
};
|
|
94
97
|
const assertTextContent = ($n) => {
|
|
95
98
|
assertNonNull($n);
|
|
@@ -138,7 +141,6 @@ const isFormatItalic = ($n) => isFormatName($n, "i");
|
|
|
138
141
|
const isFormatStrikethrough = ($n) => isFormatName($n, "s");
|
|
139
142
|
const isFormatCodetag = ($n) => isFormatName($n, "c");
|
|
140
143
|
const isFormatLink = ($n) => isFormatName($n, "l");
|
|
141
|
-
const isFormatTag = ($n) => isFormatName($n, "m");
|
|
142
144
|
const isAllInsideFormatName = ($a, $b, formatName) => {
|
|
143
145
|
const aBlock = getParentTextBlock($a);
|
|
144
146
|
const bBlock = getParentTextBlock($b);
|
|
@@ -185,9 +187,6 @@ const setInlineFormat = ($n, formatName, shouldEnable) => {
|
|
|
185
187
|
$n.className = "";
|
|
186
188
|
$n.removeAttribute(LINK_HREF_ATTR_NAME);
|
|
187
189
|
}
|
|
188
|
-
if (formatName === "m" || isFormatName($n, "m")) {
|
|
189
|
-
$n.className = "";
|
|
190
|
-
}
|
|
191
190
|
$n.classList.add(formatName);
|
|
192
191
|
} else {
|
|
193
192
|
if (formatName === "l") {
|
|
@@ -252,10 +251,41 @@ const createLink = (text, href, doc) => {
|
|
|
252
251
|
$link.setAttribute(LINK_HREF_ATTR_NAME, href);
|
|
253
252
|
return $link;
|
|
254
253
|
};
|
|
255
|
-
const createTag = (text, doc) => {
|
|
256
|
-
const $
|
|
257
|
-
|
|
258
|
-
|
|
254
|
+
const createTag = (text, doc, color, icon) => {
|
|
255
|
+
const $chip = doc.createElement("sinch-rich-textarea-chip");
|
|
256
|
+
$chip.text = text;
|
|
257
|
+
$chip.contentEditable = "false";
|
|
258
|
+
if (color !== void 0 && color !== null && color !== "") {
|
|
259
|
+
$chip.setAttribute("color", color);
|
|
260
|
+
}
|
|
261
|
+
if (icon !== void 0 && icon !== null && icon !== "") {
|
|
262
|
+
$chip.setAttribute("icon", icon);
|
|
263
|
+
}
|
|
264
|
+
return $chip;
|
|
265
|
+
};
|
|
266
|
+
const removeChip = ($chip, $root) => {
|
|
267
|
+
if (!isChip($chip)) {
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
const $parent = $chip.parentNode;
|
|
271
|
+
if ($parent === null) {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
const $next = $chip.nextSibling;
|
|
275
|
+
const $prev = $chip.previousSibling;
|
|
276
|
+
$parent.removeChild($chip);
|
|
277
|
+
if ($next !== null && isTextContent($next)) {
|
|
278
|
+
return createCollapsedRange(createBeginCursorFromTextContent($next));
|
|
279
|
+
}
|
|
280
|
+
if ($prev !== null && isTextContent($prev)) {
|
|
281
|
+
return createCollapsedRange(createEndCursorFromTextContent($prev));
|
|
282
|
+
}
|
|
283
|
+
if (isTextBlock($parent)) {
|
|
284
|
+
const $empty = createEmptyInline($parent.ownerDocument);
|
|
285
|
+
$parent.appendChild($empty);
|
|
286
|
+
return createCollapsedRange(createBeginCursorFromTextContent($empty));
|
|
287
|
+
}
|
|
288
|
+
return getBeginRange($root);
|
|
259
289
|
};
|
|
260
290
|
const EMOJI_CHAR_ATTR_NAME = "data-char";
|
|
261
291
|
const createEmoji = (emojiChar, baseUrl, doc) => {
|
|
@@ -893,6 +923,13 @@ const createIncomingCursorFromNodeWithOffset = (node, offset) => {
|
|
|
893
923
|
offset: 0
|
|
894
924
|
};
|
|
895
925
|
}
|
|
926
|
+
if (isChip(node)) {
|
|
927
|
+
return {
|
|
928
|
+
$text: null,
|
|
929
|
+
$inline: node,
|
|
930
|
+
offset: 0
|
|
931
|
+
};
|
|
932
|
+
}
|
|
896
933
|
if (isTextBlock(node)) {
|
|
897
934
|
if (isAfterLastChildIndex(node, offset)) {
|
|
898
935
|
return createEndCursorFromTextContent(
|
|
@@ -1075,10 +1112,10 @@ const insertLink = ($root, text, href, range) => {
|
|
|
1075
1112
|
)
|
|
1076
1113
|
};
|
|
1077
1114
|
};
|
|
1078
|
-
const
|
|
1115
|
+
const insertChip = ($root, text, range, options) => {
|
|
1079
1116
|
const cursor = removeContentInRange(range);
|
|
1080
1117
|
const { $text, $inline, offset, isAfterInline: isAfterLastChild } = cursor;
|
|
1081
|
-
const $tag = createTag(text, $root.ownerDocument);
|
|
1118
|
+
const $tag = createTag(text, $root.ownerDocument, options?.color, options?.icon);
|
|
1082
1119
|
if (isTextNode($text)) {
|
|
1083
1120
|
if (isEmptyText($text.nodeValue)) {
|
|
1084
1121
|
getParentTextBlock($inline).replaceChild($tag, $inline);
|
|
@@ -1174,7 +1211,7 @@ const insertText = ($root, data, range) => {
|
|
|
1174
1211
|
isTextNode(range.startContainer) && !isEmptyText(range.startContainer.nodeValue)
|
|
1175
1212
|
) {
|
|
1176
1213
|
const $inline2 = getParentInline(range.startContainer);
|
|
1177
|
-
const isHotTextWhitespace = range.startOffset === range.startContainer.length && data === TEXT_WHITESPACE && (isFormatCodetag($inline2) || isFormatLink($inline2)
|
|
1214
|
+
const isHotTextWhitespace = range.startOffset === range.startContainer.length && data === TEXT_WHITESPACE && (isFormatCodetag($inline2) || isFormatLink($inline2));
|
|
1178
1215
|
if (!isHotTextWhitespace) {
|
|
1179
1216
|
return DEFAULT_ACTION_RESULT;
|
|
1180
1217
|
}
|
|
@@ -1213,7 +1250,7 @@ const insertText = ($root, data, range) => {
|
|
|
1213
1250
|
};
|
|
1214
1251
|
}
|
|
1215
1252
|
if (offset === $text.length && data === TEXT_WHITESPACE) {
|
|
1216
|
-
if (isFormatLink($inline) || isFormatCodetag($inline)
|
|
1253
|
+
if (isFormatLink($inline) || isFormatCodetag($inline)) {
|
|
1217
1254
|
const $newinline = createInlineWithText(data, $root.ownerDocument);
|
|
1218
1255
|
$inline.after($newinline);
|
|
1219
1256
|
return {
|
|
@@ -1370,6 +1407,18 @@ const getSelectionInfo = (range) => {
|
|
|
1370
1407
|
const bCursor = createIncomingCursorFromNodeWithOffset(range.endContainer, range.endOffset);
|
|
1371
1408
|
if (aCursor.$inline === bCursor.$inline) {
|
|
1372
1409
|
const { $text, $inline } = aCursor;
|
|
1410
|
+
if (isChip($inline)) {
|
|
1411
|
+
return {
|
|
1412
|
+
bold: false,
|
|
1413
|
+
italic: false,
|
|
1414
|
+
strikethrough: false,
|
|
1415
|
+
codetag: false,
|
|
1416
|
+
tag: true,
|
|
1417
|
+
link: false,
|
|
1418
|
+
olist: isInsideList(true, $inline),
|
|
1419
|
+
ulist: isInsideList(false, $inline)
|
|
1420
|
+
};
|
|
1421
|
+
}
|
|
1373
1422
|
if ($text !== null || isInline($inline)) {
|
|
1374
1423
|
assertInline($inline);
|
|
1375
1424
|
return {
|
|
@@ -1377,7 +1426,7 @@ const getSelectionInfo = (range) => {
|
|
|
1377
1426
|
italic: isFormatItalic($inline),
|
|
1378
1427
|
strikethrough: isFormatStrikethrough($inline),
|
|
1379
1428
|
codetag: isFormatCodetag($inline),
|
|
1380
|
-
tag:
|
|
1429
|
+
tag: false,
|
|
1381
1430
|
link: isFormatLink($inline),
|
|
1382
1431
|
olist: isInsideList(true, $inline),
|
|
1383
1432
|
ulist: isInsideList(false, $inline)
|
|
@@ -1415,7 +1464,10 @@ const isEmptyTextBlock = ($block) => {
|
|
|
1415
1464
|
return false;
|
|
1416
1465
|
}
|
|
1417
1466
|
const $inline = blockChildren[0];
|
|
1418
|
-
|
|
1467
|
+
if (isChip($inline)) {
|
|
1468
|
+
return false;
|
|
1469
|
+
}
|
|
1470
|
+
const isEmptyText2 = isInline($inline) && !isFormatCodetag($inline) && isEmptyTextNode(getChildText($inline));
|
|
1419
1471
|
return isEmptyText2;
|
|
1420
1472
|
};
|
|
1421
1473
|
const isEditorEmpty = ($root) => {
|
|
@@ -1435,6 +1487,13 @@ const serializeDescriptorReducer = (range) => (state, $n) => {
|
|
|
1435
1487
|
}
|
|
1436
1488
|
return state;
|
|
1437
1489
|
}
|
|
1490
|
+
if (isChip($n)) {
|
|
1491
|
+
const text2 = $n.text ?? "";
|
|
1492
|
+
if (text2.length > 0) {
|
|
1493
|
+
state.push({ isTag: true, text: `{{${text2}}}` });
|
|
1494
|
+
}
|
|
1495
|
+
return state;
|
|
1496
|
+
}
|
|
1438
1497
|
let text = getTextValue(getChildText($n));
|
|
1439
1498
|
let trailingSpaces = "";
|
|
1440
1499
|
if (range !== null) {
|
|
@@ -1456,10 +1515,6 @@ const serializeDescriptorReducer = (range) => (state, $n) => {
|
|
|
1456
1515
|
state.push({ isCodetag: true, text });
|
|
1457
1516
|
return state;
|
|
1458
1517
|
}
|
|
1459
|
-
if (isFormatTag($n)) {
|
|
1460
|
-
state.push({ isTag: true, text: `{{${text}}}` });
|
|
1461
|
-
return state;
|
|
1462
|
-
}
|
|
1463
1518
|
if (isFormatLink($n)) {
|
|
1464
1519
|
const href = $n.getAttribute(LINK_HREF_ATTR_NAME) ?? "#";
|
|
1465
1520
|
state.push({ isLink: true, text, href });
|
|
@@ -1664,10 +1719,22 @@ const serializeMarkdown = ($root, range) => {
|
|
|
1664
1719
|
};
|
|
1665
1720
|
const createParseVisitor = (doc) => {
|
|
1666
1721
|
let emojiBaseUrl = null;
|
|
1722
|
+
let chipColor = null;
|
|
1723
|
+
let chipIcon = null;
|
|
1724
|
+
let chipResolver = null;
|
|
1667
1725
|
return {
|
|
1668
1726
|
updateEmojiBaseUrl(url) {
|
|
1669
1727
|
emojiBaseUrl = url;
|
|
1670
1728
|
},
|
|
1729
|
+
updateChipColor(color) {
|
|
1730
|
+
chipColor = color;
|
|
1731
|
+
},
|
|
1732
|
+
updateChipIcon(icon) {
|
|
1733
|
+
chipIcon = icon;
|
|
1734
|
+
},
|
|
1735
|
+
updateChipResolver(resolver) {
|
|
1736
|
+
chipResolver = resolver;
|
|
1737
|
+
},
|
|
1671
1738
|
createVisitor() {
|
|
1672
1739
|
const $root = doc.createDocumentFragment();
|
|
1673
1740
|
let $currentBlock = null;
|
|
@@ -1693,7 +1760,8 @@ const createParseVisitor = (doc) => {
|
|
|
1693
1760
|
$currentBlock.appendChild($inline);
|
|
1694
1761
|
},
|
|
1695
1762
|
tag(text) {
|
|
1696
|
-
const
|
|
1763
|
+
const resolved = chipResolver?.(text);
|
|
1764
|
+
const $tag = createTag(text, doc, resolved?.color ?? chipColor, resolved?.icon ?? chipIcon);
|
|
1697
1765
|
$currentBlock.appendChild($tag);
|
|
1698
1766
|
},
|
|
1699
1767
|
inline(text, { isBold, isItalic, isStrikethrough }) {
|
|
@@ -1777,13 +1845,14 @@ export {
|
|
|
1777
1845
|
getEndRange,
|
|
1778
1846
|
getSelectionInfo,
|
|
1779
1847
|
handleEmojiMousedown,
|
|
1848
|
+
insertChip,
|
|
1780
1849
|
insertFromPaste,
|
|
1781
1850
|
insertLineBreak,
|
|
1782
1851
|
insertLink,
|
|
1783
|
-
insertTag,
|
|
1784
1852
|
insertText,
|
|
1785
1853
|
isEditorEmpty,
|
|
1786
1854
|
isSelectionEqual,
|
|
1855
|
+
removeChip,
|
|
1787
1856
|
serializeMarkdown,
|
|
1788
1857
|
setBrowserCaret
|
|
1789
1858
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import '../icon';
|
|
2
|
+
import '../text';
|
|
3
|
+
import { NectaryElement } from '../utils';
|
|
4
|
+
export * from './types';
|
|
5
|
+
export declare class RichTextareaChip extends NectaryElement {
|
|
6
|
+
#private;
|
|
7
|
+
constructor();
|
|
8
|
+
connectedCallback(): void;
|
|
9
|
+
disconnectedCallback(): void;
|
|
10
|
+
static get observedAttributes(): string[];
|
|
11
|
+
attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null): void;
|
|
12
|
+
get text(): string;
|
|
13
|
+
set text(value: string);
|
|
14
|
+
get readonly(): boolean;
|
|
15
|
+
set readonly(isReadonly: boolean);
|
|
16
|
+
get color(): string;
|
|
17
|
+
set color(value: string);
|
|
18
|
+
get icon(): string;
|
|
19
|
+
set icon(value: string);
|
|
20
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import "../icon/index.js";
|
|
2
|
+
import "../text/index.js";
|
|
3
|
+
import { getTagColorBg, getTagColorFg } from "../tag/utils.js";
|
|
4
|
+
import { isAttrEqual, updateBooleanAttribute, isAttrTrue, updateAttribute, getAttribute, getBooleanAttribute } from "../utils/dom.js";
|
|
5
|
+
import { defineCustomElement, NectaryElement } from "../utils/element.js";
|
|
6
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#button{all:initial;position:relative;display:flex;flex-direction:row;align-items:center;gap:4px;width:100%;height:var(--sinch-comp-chip-size-container-m);padding:0 5px 0 9px;border-radius:var(--sinch-comp-chip-shape-radius);background-color:var(--sinch-comp-chip-color-neutral-default-background-initial);box-sizing:border-box;--sinch-global-color-text:var(--sinch-comp-chip-color-neutral-default-foreground-initial);--sinch-global-color-icon:var(--sinch-comp-chip-color-neutral-default-foreground-initial);--sinch-global-size-icon:var(--sinch-comp-chip-size-icon-m)}:host(:not([icon])) #icon-start{display:none}#text{flex:1;--sinch-comp-text-font:var(--sinch-comp-chip-font-size-m-label)}:host([readonly]) #button{padding-right:9px}#icon-close{cursor:pointer}:host([readonly]) #icon-close{display:none}</style><div id="button"><sinch-icon icons-version="2" id="icon-start"></sinch-icon><sinch-text id="text" type="xs" ellipsis></sinch-text><sinch-icon icons-version="2" name="circle-cross" id="icon-close"></sinch-icon></div>';
|
|
7
|
+
const template = document.createElement("template");
|
|
8
|
+
template.innerHTML = templateHTML;
|
|
9
|
+
class RichTextareaChip extends NectaryElement {
|
|
10
|
+
#$text;
|
|
11
|
+
#$button;
|
|
12
|
+
#$iconStart;
|
|
13
|
+
#$iconClose;
|
|
14
|
+
#controller = null;
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
const shadowRoot = this.attachShadow();
|
|
18
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
19
|
+
this.#$text = shadowRoot.querySelector("#text");
|
|
20
|
+
this.#$button = shadowRoot.querySelector("#button");
|
|
21
|
+
this.#$iconStart = shadowRoot.querySelector("#icon-start");
|
|
22
|
+
this.#$iconClose = shadowRoot.querySelector("#icon-close");
|
|
23
|
+
}
|
|
24
|
+
connectedCallback() {
|
|
25
|
+
super.connectedCallback();
|
|
26
|
+
this.#controller = new AbortController();
|
|
27
|
+
const { signal } = this.#controller;
|
|
28
|
+
this.#$iconClose.addEventListener("click", this.#onRightIconClick, { signal });
|
|
29
|
+
this.addEventListener("click", this.#onClick, { signal });
|
|
30
|
+
}
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
super.disconnectedCallback();
|
|
33
|
+
this.#controller.abort();
|
|
34
|
+
this.#controller = null;
|
|
35
|
+
}
|
|
36
|
+
static get observedAttributes() {
|
|
37
|
+
return ["text", "color", "icon", "readonly"];
|
|
38
|
+
}
|
|
39
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
40
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
switch (name) {
|
|
44
|
+
case "text": {
|
|
45
|
+
this.#$text.textContent = newVal;
|
|
46
|
+
updateAttribute(this, "aria-label", newVal);
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
case "readonly": {
|
|
50
|
+
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
case "color": {
|
|
54
|
+
this.#updateColor(newVal);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case "icon": {
|
|
58
|
+
this.#$iconStart.setAttribute("name", newVal ?? "");
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
get text() {
|
|
64
|
+
return getAttribute(this, "text", "");
|
|
65
|
+
}
|
|
66
|
+
set text(value) {
|
|
67
|
+
updateAttribute(this, "text", value);
|
|
68
|
+
}
|
|
69
|
+
get readonly() {
|
|
70
|
+
return getBooleanAttribute(this, "readonly");
|
|
71
|
+
}
|
|
72
|
+
set readonly(isReadonly) {
|
|
73
|
+
updateBooleanAttribute(this, "readonly", isReadonly);
|
|
74
|
+
}
|
|
75
|
+
get color() {
|
|
76
|
+
return getAttribute(this, "color", "");
|
|
77
|
+
}
|
|
78
|
+
set color(value) {
|
|
79
|
+
updateAttribute(this, "color", value);
|
|
80
|
+
}
|
|
81
|
+
get icon() {
|
|
82
|
+
return getAttribute(this, "icon", "");
|
|
83
|
+
}
|
|
84
|
+
set icon(value) {
|
|
85
|
+
updateAttribute(this, "icon", value);
|
|
86
|
+
}
|
|
87
|
+
#updateColor(color) {
|
|
88
|
+
if (color !== null && color !== "") {
|
|
89
|
+
this.#$button.style.setProperty("background-color", getTagColorBg(color));
|
|
90
|
+
this.#$button.style.setProperty("--sinch-global-color-text", getTagColorFg(color));
|
|
91
|
+
this.#$button.style.setProperty("--sinch-global-color-icon", getTagColorFg(color));
|
|
92
|
+
} else {
|
|
93
|
+
this.#$button.style.removeProperty("background-color");
|
|
94
|
+
this.#$button.style.removeProperty("--sinch-global-color-text");
|
|
95
|
+
this.#$button.style.removeProperty("--sinch-global-color-icon");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
#onClick = (e) => {
|
|
99
|
+
if (e.target === this.#$iconClose || this.#$iconClose.contains(e.target)) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
this.dispatchEvent(
|
|
103
|
+
new CustomEvent("-click", { bubbles: true, composed: true })
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
#onRightIconClick = (e) => {
|
|
107
|
+
e.stopPropagation();
|
|
108
|
+
this.dispatchEvent(
|
|
109
|
+
new CustomEvent("-right-icon-click", { bubbles: true, composed: true })
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
defineCustomElement("sinch-rich-textarea-chip", RichTextareaChip);
|
|
114
|
+
export {
|
|
115
|
+
RichTextareaChip
|
|
116
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { TSinchTagColor } from '../tag/colors';
|
|
2
|
+
import type { NectaryComponentReactByType, NectaryComponentVanillaByType, NectaryComponentReact, NectaryComponentVanilla } from '../types';
|
|
3
|
+
export type TSinchRichTextareaChipProps = {
|
|
4
|
+
/** Text */
|
|
5
|
+
text: string;
|
|
6
|
+
/** Readonly - hides the close button */
|
|
7
|
+
readonly?: boolean;
|
|
8
|
+
/** Color using the tag color system */
|
|
9
|
+
color?: TSinchTagColor;
|
|
10
|
+
/** Icon name */
|
|
11
|
+
icon?: string;
|
|
12
|
+
};
|
|
13
|
+
export type TSinchRichTextareaChipEvents = {
|
|
14
|
+
/** Click event handler */
|
|
15
|
+
'-click'?: (e: CustomEvent<void>) => void;
|
|
16
|
+
};
|
|
17
|
+
export type TSinchRichTextareaChipStyle = {
|
|
18
|
+
'--sinch-comp-chip-size-container-m'?: string;
|
|
19
|
+
'--sinch-comp-chip-size-icon-m'?: string;
|
|
20
|
+
'--sinch-comp-chip-font-size-m-label'?: string;
|
|
21
|
+
'--sinch-comp-chip-color-neutral-default-background-initial'?: string;
|
|
22
|
+
'--sinch-comp-chip-color-neutral-default-foreground-initial'?: string;
|
|
23
|
+
'--sinch-comp-chip-color-outiline-focus'?: string;
|
|
24
|
+
'--sinch-comp-chip-shape-radius'?: string;
|
|
25
|
+
'--sinch-global-color-text'?: string;
|
|
26
|
+
'--sinch-global-color-icon'?: string;
|
|
27
|
+
'--sinch-global-size-icon'?: string;
|
|
28
|
+
'--sinch-comp-text-font'?: string;
|
|
29
|
+
};
|
|
30
|
+
export type TSinchRichTextareaChip = {
|
|
31
|
+
props: TSinchRichTextareaChipProps;
|
|
32
|
+
events: TSinchRichTextareaChipEvents;
|
|
33
|
+
style: TSinchRichTextareaChipStyle;
|
|
34
|
+
};
|
|
35
|
+
export type TSinchRichTextareaChipElement = NectaryComponentVanillaByType<TSinchRichTextareaChip>;
|
|
36
|
+
export type TSinchRichTextareaChipReact = NectaryComponentReactByType<TSinchRichTextareaChip>;
|
|
37
|
+
declare global {
|
|
38
|
+
interface NectaryComponentMap {
|
|
39
|
+
'sinch-rich-textarea-chip': TSinchRichTextareaChip;
|
|
40
|
+
}
|
|
41
|
+
interface HTMLElementTagNameMap {
|
|
42
|
+
'sinch-rich-textarea-chip': NectaryComponentVanilla<'sinch-rich-textarea-chip'>;
|
|
43
|
+
}
|
|
44
|
+
namespace JSX {
|
|
45
|
+
interface IntrinsicElements {
|
|
46
|
+
'sinch-rich-textarea-chip': NectaryComponentReact<'sinch-rich-textarea-chip'>;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
declare module 'react' {
|
|
51
|
+
namespace JSX {
|
|
52
|
+
interface IntrinsicElements extends globalThis.JSX.IntrinsicElements {
|
|
53
|
+
'sinch-rich-textarea-chip': NectaryComponentReact<'sinch-rich-textarea-chip'>;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const BASE_COMPONENT_NAMES_LIST: readonly ["accordion-item", "accordion", "action-menu-option", "action-menu", "alert", "avatar", "badge", "button-group-item", "button-group", "button", "card-container", "card-v2-title", "card-v2", "checkbox", "chip", "code-tag", "color-menu-option", "color-menu", "color-swatch", "date-picker", "dialog", "emoji-picker", "emoji", "field", "file-drop", "file-picker", "file-status", "flag", "grid-item", "grid", "help-tooltip", "icon", "inline-alert", "input", "link", "list-item", "list", "pagination", "persistent-overlay", "pop", "popover", "progress-stepper-item", "progress-stepper", "progress", "radio-option", "radio", "rich-text", "rich-textarea", "segment-collapse", "segmented-control-option", "segmented-control", "segmented-icon-control-option", "segmented-icon-control", "select-button", "select-menu-option", "select-menu", "skeleton-item", "skeleton", "spinner", "stop-events", "table-body", "table-cell", "table-head-cell", "table-head", "table-row", "table", "tabs-icon-option", "tabs-option", "tabs", "tag", "text", "textarea", "time-picker", "title", "toast-manager", "toast", "toggle", "tooltip"];
|
|
2
|
-
export declare const BASE_COMPONENT_NAMES: Set<"pop" | "button" | "dialog" | "input" | "link" | "progress" | "table" | "textarea" | "title" | "accordion-item" | "accordion" | "action-menu-option" | "action-menu" | "alert" | "avatar" | "badge" | "button-group-item" | "button-group" | "card-container" | "card-v2-title" | "card-v2" | "checkbox" | "chip" | "code-tag" | "color-menu-option" | "color-menu" | "color-swatch" | "date-picker" | "emoji-picker" | "emoji" | "field" | "file-drop" | "file-picker" | "file-status" | "flag" | "grid-item" | "grid" | "help-tooltip" | "icon" | "inline-alert" | "list-item" | "list" | "pagination" | "persistent-overlay" | "popover" | "progress-stepper-item" | "progress-stepper" | "radio-option" | "radio" | "rich-text" | "rich-textarea" | "segment-collapse" | "segmented-control-option" | "segmented-control" | "segmented-icon-control-option" | "segmented-icon-control" | "select-button" | "select-menu-option" | "select-menu" | "skeleton-item" | "skeleton" | "spinner" | "stop-events" | "table-body" | "table-cell" | "table-head-cell" | "table-head" | "table-row" | "tabs-icon-option" | "tabs-option" | "tabs" | "tag" | "text" | "time-picker" | "toast-manager" | "toast" | "toggle" | "tooltip">;
|
|
1
|
+
export declare const BASE_COMPONENT_NAMES_LIST: readonly ["accordion-item", "accordion", "action-menu-option", "action-menu", "alert", "avatar", "badge", "button-group-item", "button-group", "button", "card-container", "card-v2-title", "card-v2", "checkbox", "chip", "code-tag", "color-menu-option", "color-menu", "color-swatch", "date-picker", "dialog", "emoji-picker", "emoji", "field", "file-drop", "file-picker", "file-status", "flag", "grid-item", "grid", "help-tooltip", "icon", "inline-alert", "input", "link", "list-item", "list", "pagination", "persistent-overlay", "pop", "popover", "progress-stepper-item", "progress-stepper", "progress", "radio-option", "radio", "rich-text", "rich-textarea", "rich-textarea-chip", "segment-collapse", "segmented-control-option", "segmented-control", "segmented-icon-control-option", "segmented-icon-control", "select-button", "select-menu-option", "select-menu", "skeleton-item", "skeleton", "spinner", "stop-events", "table-body", "table-cell", "table-head-cell", "table-head", "table-row", "table", "tabs-icon-option", "tabs-option", "tabs", "tag", "text", "textarea", "time-picker", "title", "toast-manager", "toast", "toggle", "tooltip"];
|
|
2
|
+
export declare const BASE_COMPONENT_NAMES: Set<"pop" | "button" | "dialog" | "input" | "link" | "progress" | "table" | "textarea" | "title" | "accordion-item" | "accordion" | "action-menu-option" | "action-menu" | "alert" | "avatar" | "badge" | "button-group-item" | "button-group" | "card-container" | "card-v2-title" | "card-v2" | "checkbox" | "chip" | "code-tag" | "color-menu-option" | "color-menu" | "color-swatch" | "date-picker" | "emoji-picker" | "emoji" | "field" | "file-drop" | "file-picker" | "file-status" | "flag" | "grid-item" | "grid" | "help-tooltip" | "icon" | "inline-alert" | "list-item" | "list" | "pagination" | "persistent-overlay" | "popover" | "progress-stepper-item" | "progress-stepper" | "radio-option" | "radio" | "rich-text" | "rich-textarea" | "rich-textarea-chip" | "segment-collapse" | "segmented-control-option" | "segmented-control" | "segmented-icon-control-option" | "segmented-icon-control" | "select-button" | "select-menu-option" | "select-menu" | "skeleton-item" | "skeleton" | "spinner" | "stop-events" | "table-body" | "table-cell" | "table-head-cell" | "table-head" | "table-row" | "tabs-icon-option" | "tabs-option" | "tabs" | "tag" | "text" | "time-picker" | "toast-manager" | "toast" | "toggle" | "tooltip">;
|
|
3
3
|
export type ComponentName = `sinch-${typeof BASE_COMPONENT_NAMES_LIST[number]}`;
|
package/utils/component-names.js
CHANGED
package/utils/element.d.ts
CHANGED
package/utils/markdown.js
CHANGED
|
@@ -9,7 +9,7 @@ const regEm1Underscore = new RegExp("(?<!\\\\)_(?<em1>.+?)(?<!\\\\)_");
|
|
|
9
9
|
const regCodeTag = new RegExp("(?<!\\\\)`(?<code>.+?)(?<!\\\\)`");
|
|
10
10
|
const regStrikethrough = new RegExp("(?<!\\\\)~~(?<strike>.+?)(?<!\\\\)~~");
|
|
11
11
|
const regLink = new RegExp("(?<!\\\\)!?\\[(?<linktext>[^\\]]*?)\\]\\((?<linkhref>[^)]+?)\\)(\\{(?<linkattrs>[^)]+?)\\})?");
|
|
12
|
-
const
|
|
12
|
+
const regChip = new RegExp("(?<!\\\\)\\{\\{(?<chip>[a-zA-Z0-9_-]+)\\}\\}");
|
|
13
13
|
const regEmoji = new RegExp("(?<emoji>(?![0-9*#])\\p{Emoji})", "u");
|
|
14
14
|
const regUList = /^(?<indent>[\t ]*?)[*+-][\t ]+(?<ultext>.*?)[\t ]*?$/;
|
|
15
15
|
const regOList = /^(?<indent>[\t ]*?)\d+\.[\t ]+(?<oltext>.*?)[\t ]*?$/;
|
|
@@ -18,7 +18,7 @@ const allRegs = [
|
|
|
18
18
|
regEscapedChars,
|
|
19
19
|
regCodeTag,
|
|
20
20
|
regLink,
|
|
21
|
-
|
|
21
|
+
regChip,
|
|
22
22
|
regEm3Star,
|
|
23
23
|
regEm2Star,
|
|
24
24
|
regEm1Star,
|
|
@@ -66,8 +66,8 @@ const createLineParser = (visitor) => function parseLine(regs, md, context = INI
|
|
|
66
66
|
if (groups?.code != null) {
|
|
67
67
|
visitor.codetag(groups.code);
|
|
68
68
|
}
|
|
69
|
-
if (groups?.
|
|
70
|
-
visitor.tag(groups.
|
|
69
|
+
if (groups?.chip != null) {
|
|
70
|
+
visitor.tag(groups.chip);
|
|
71
71
|
}
|
|
72
72
|
if (groups?.emoji != null) {
|
|
73
73
|
visitor.emoji(groups.emoji);
|