@nectary/components 0.48.1 → 0.49.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/accordion/types.d.ts +2 -2
- package/accordion-item/types.d.ts +3 -3
- package/action-menu/index.js +0 -1
- package/action-menu/types.d.ts +2 -2
- package/action-menu-option/index.js +1 -1
- package/action-menu-option/types.d.ts +2 -2
- package/alert/index.d.ts +2 -1
- package/alert/index.js +4 -3
- package/alert/types.d.ts +3 -3
- package/alert/utils.d.ts +1 -1
- package/avatar/types.d.ts +3 -3
- package/avatar/utils.d.ts +1 -1
- package/badge/types.d.ts +3 -3
- package/badge/utils.d.ts +1 -1
- package/button/types.d.ts +3 -3
- package/button/utils.d.ts +1 -1
- package/card/types.d.ts +2 -2
- package/card-container/types.d.ts +2 -2
- package/chat/types.d.ts +2 -2
- package/chat-block/types.d.ts +3 -3
- package/chat-bubble/types.d.ts +4 -4
- package/checkbox/types.d.ts +2 -2
- package/chip/types.d.ts +2 -2
- package/code-tag/index.d.ts +13 -0
- package/code-tag/index.js +36 -0
- package/code-tag/types.d.ts +11 -0
- package/code-tag/types.js +1 -0
- package/color-menu/index.js +0 -3
- package/color-menu/types.d.ts +2 -2
- package/color-swatch/types.d.ts +2 -2
- package/date-picker/index.js +0 -6
- package/date-picker/types.d.ts +2 -2
- package/date-picker/utils.d.ts +6 -6
- package/dialog/index.js +0 -1
- package/dialog/types.d.ts +2 -2
- package/emoji/types.d.ts +2 -2
- package/emoji/utils.js +0 -4
- package/emoji-picker/index.js +1 -3
- package/emoji-picker/types.d.ts +4 -4
- package/field/types.d.ts +2 -2
- package/file-drop/types.d.ts +3 -3
- package/file-picker/index.js +0 -1
- package/file-picker/types.d.ts +3 -3
- package/file-status/types.d.ts +3 -3
- package/file-status/utils.d.ts +1 -1
- package/flag/types.d.ts +2 -2
- package/flag/utils.js +0 -2
- package/grid/types.d.ts +2 -2
- package/grid-item/types.d.ts +2 -2
- package/help-tooltip/types.d.ts +2 -2
- package/horizontal-stepper/types.d.ts +2 -2
- package/horizontal-stepper-item/types.d.ts +3 -3
- package/icon/types.d.ts +2 -2
- package/icon-button/types.d.ts +3 -3
- package/icon-button/utils.d.ts +1 -1
- package/icons/types.d.ts +2 -2
- package/icons-branded/types.d.ts +2 -2
- package/icons-channel/types.d.ts +2 -2
- package/illustrations/types.d.ts +4 -4
- package/inline-alert/index.d.ts +4 -3
- package/inline-alert/index.js +6 -5
- package/inline-alert/types.d.ts +3 -3
- package/inline-alert/utils.d.ts +1 -1
- package/input/index.js +17 -3
- package/input/types.d.ts +9 -3
- package/input/utils.d.ts +3 -0
- package/input/utils.js +6 -1
- package/link/types.d.ts +2 -2
- package/list/types.d.ts +2 -2
- package/list-item/types.d.ts +2 -2
- package/logo/types.d.ts +2 -2
- package/package.json +10 -9
- package/pagination/index.js +0 -6
- package/pagination/types.d.ts +2 -2
- package/pop/index.js +0 -16
- package/pop/types.d.ts +3 -3
- package/pop/utils.d.ts +1 -1
- package/popover/types.d.ts +3 -3
- package/popover/utils.d.ts +2 -2
- package/progress/types.d.ts +2 -2
- package/radio/types.d.ts +2 -2
- package/radio-option/types.d.ts +2 -2
- package/rich-text/index.d.ts +12 -0
- package/rich-text/index.js +56 -0
- package/rich-text/types.d.ts +12 -0
- package/rich-text/types.js +1 -0
- package/rich-text/utils.d.ts +5 -0
- package/rich-text/utils.js +6 -0
- package/segment/types.d.ts +2 -2
- package/segment-collapse/types.d.ts +2 -2
- package/segmented-control/types.d.ts +2 -2
- package/segmented-control-option/types.d.ts +2 -2
- package/segmented-icon-control/types.d.ts +2 -2
- package/segmented-icon-control-option/types.d.ts +2 -2
- package/select-button/index.js +1 -1
- package/select-button/types.d.ts +2 -2
- package/select-menu/index.js +0 -1
- package/select-menu/types.d.ts +2 -2
- package/select-menu-option/index.js +1 -1
- package/select-menu-option/types.d.ts +2 -2
- package/spinner/types.d.ts +2 -2
- package/table/types.d.ts +2 -2
- package/table-body/types.d.ts +2 -2
- package/table-cell/types.d.ts +3 -3
- package/table-head/types.d.ts +2 -2
- package/table-head-cell/types.d.ts +2 -2
- package/table-row/types.d.ts +2 -2
- package/tabs/types.d.ts +2 -2
- package/tabs-icon-option/index.js +1 -1
- package/tabs-icon-option/types.d.ts +2 -2
- package/tabs-option/index.js +1 -1
- package/tabs-option/types.d.ts +2 -2
- package/tag/types.d.ts +2 -2
- package/text/index.js +1 -3
- package/text/types.d.ts +3 -3
- package/text/utils.d.ts +1 -1
- package/text/utils.js +1 -1
- package/textarea/index.js +1 -1
- package/textarea/types.d.ts +2 -2
- package/theme/fonts.css +33 -0
- package/theme/fonts.json +33 -0
- package/tile-control/types.d.ts +2 -2
- package/tile-control-option/types.d.ts +2 -2
- package/time-picker/index.js +0 -4
- package/time-picker/types.d.ts +2 -2
- package/title/index.js +0 -2
- package/title/types.d.ts +4 -4
- package/title/utils.d.ts +3 -2
- package/title/utils.js +17 -0
- package/toast/types.d.ts +3 -3
- package/toast/utils.d.ts +1 -1
- package/toast-manager/index.js +0 -1
- package/toast-manager/types.d.ts +2 -2
- package/toggle/types.d.ts +2 -2
- package/tooltip/tooltip-state.d.ts +1 -1
- package/tooltip/types.d.ts +3 -3
- package/tooltip/utils.d.ts +2 -2
- package/utils/context.d.ts +5 -5
- package/utils/context.js +0 -1
- package/utils/countries.d.ts +1 -1
- package/utils/dom.d.ts +1 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +2 -1
- package/utils/markdown.d.ts +1 -0
- package/utils/markdown.js +128 -0
- package/utils/rect.js +0 -1
- package/utils/size.d.ts +4 -4
- package/vertical-stepper/types.d.ts +2 -2
- package/vertical-stepper-item/types.d.ts +3 -3
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { filterXSS } from 'xss';
|
|
2
|
+
const contextTags = {
|
|
3
|
+
em1: ['<span class="em1">', '</span>'],
|
|
4
|
+
em2: ['<span class="em2">', '</span>'],
|
|
5
|
+
em3: ['<span class="em3">', '</span>'],
|
|
6
|
+
s: ['<span class="strikethrough">', '</span>'],
|
|
7
|
+
p: ['<p class="paragraph">', '</p>']
|
|
8
|
+
};
|
|
9
|
+
const getContextTags = token => {
|
|
10
|
+
switch (token) {
|
|
11
|
+
case '_':
|
|
12
|
+
case '*':
|
|
13
|
+
return contextTags.em1;
|
|
14
|
+
case '__':
|
|
15
|
+
case '**':
|
|
16
|
+
return contextTags.em2;
|
|
17
|
+
case '___':
|
|
18
|
+
case '***':
|
|
19
|
+
return contextTags.em3;
|
|
20
|
+
case '~~':
|
|
21
|
+
return contextTags.s;
|
|
22
|
+
case 'p':
|
|
23
|
+
return contextTags.p;
|
|
24
|
+
default:
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const encodeAttr = str => {
|
|
29
|
+
return `${str}`.replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
|
|
30
|
+
};
|
|
31
|
+
const tokenizer = /(?<em>___|\*\*\*|__|\*\*|[_*]|~~)|(?:!?\[(?<linktext>[^\]]*?)\]\((?<linkhref>[^)]+?)\))|(?:`(?<code>[^`].*?)`)|(?<paragraph>\n{2,})|(?<newline>\n)/gm;
|
|
32
|
+
export const parseMarkdown = md => {
|
|
33
|
+
const context = [];
|
|
34
|
+
let out = '';
|
|
35
|
+
let lastIndex = 0;
|
|
36
|
+
const isContextEnd = token => {
|
|
37
|
+
return context.length > 0 && context.at(-1).token === token;
|
|
38
|
+
};
|
|
39
|
+
const pushContext = token => {
|
|
40
|
+
const desc = getContextTags(token);
|
|
41
|
+
if (desc === null) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
context.push({
|
|
45
|
+
token,
|
|
46
|
+
out: ''
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const popContext = (token, prev) => {
|
|
50
|
+
const desc = getContextTags(token);
|
|
51
|
+
if (desc === null) {
|
|
52
|
+
return token;
|
|
53
|
+
}
|
|
54
|
+
const ctx = context.pop();
|
|
55
|
+
return `${desc[0]}${ctx.out}${prev}${desc[1]}`;
|
|
56
|
+
};
|
|
57
|
+
const flushContext = prev => {
|
|
58
|
+
let str = '';
|
|
59
|
+
while (context.length > 1) {
|
|
60
|
+
const ctx = context.pop();
|
|
61
|
+
str = `${ctx.token}${ctx.out}${str}`;
|
|
62
|
+
}
|
|
63
|
+
if (context.length === 0) {
|
|
64
|
+
pushContext('p');
|
|
65
|
+
}
|
|
66
|
+
return popContext(context.at(-1).token, str + prev);
|
|
67
|
+
};
|
|
68
|
+
md = md.trim();
|
|
69
|
+
while (true) {
|
|
70
|
+
const tokens = tokenizer.exec(md);
|
|
71
|
+
if (tokens === null) {
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
let prev = md.substring(lastIndex, tokens.index);
|
|
75
|
+
let chunk = tokens[0];
|
|
76
|
+
const groups = tokens.groups;
|
|
77
|
+
lastIndex = tokenizer.lastIndex;
|
|
78
|
+
if (context.length === 0) {
|
|
79
|
+
pushContext('p');
|
|
80
|
+
}
|
|
81
|
+
if (prev.match(/[^\\](\\\\)*\\$/) != null) {
|
|
82
|
+
prev = prev.substring(0, prev.length - 1);
|
|
83
|
+
context.at(-1).out += prev + chunk;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (groups.em != null) {
|
|
87
|
+
const isCloseTag = isContextEnd(groups.em);
|
|
88
|
+
if (isCloseTag) {
|
|
89
|
+
chunk = popContext(groups.em, prev);
|
|
90
|
+
context.at(-1).out += chunk;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
context.at(-1).out += prev;
|
|
94
|
+
pushContext(groups.em);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (groups.linkhref != null) {
|
|
98
|
+
const href = groups.linkhref;
|
|
99
|
+
const text = groups.linktext.length > 0 ? groups.linktext : href;
|
|
100
|
+
chunk = `<a class="link" target="_blank" href="${encodeAttr(href)}">${encodeAttr(text)}</a>`;
|
|
101
|
+
context.at(-1).out += prev + chunk;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (groups.code != null) {
|
|
105
|
+
chunk = `<span class="code">${encodeAttr(groups.code)}</span>`;
|
|
106
|
+
context.at(-1).out += prev + chunk;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (groups.newline != null) {
|
|
110
|
+
chunk = '<br/>';
|
|
111
|
+
context.at(-1).out += prev + chunk;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (groups.paragraph != null) {
|
|
115
|
+
out += flushContext(prev);
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
out = (out + flushContext(md.substring(lastIndex))).trim();
|
|
120
|
+
return filterXSS(out, {
|
|
121
|
+
whiteList: {
|
|
122
|
+
p: ['class'],
|
|
123
|
+
span: ['class'],
|
|
124
|
+
a: ['href', 'class', 'target'],
|
|
125
|
+
br: []
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
};
|
package/utils/rect.js
CHANGED
|
@@ -16,7 +16,6 @@ export const getRect = el => {
|
|
|
16
16
|
export const rectOverlap = (targetRect, contentRect) => {
|
|
17
17
|
return targetRect.x < contentRect.x + contentRect.width && targetRect.x + targetRect.width > contentRect.x && targetRect.y < contentRect.y + contentRect.height && targetRect.y + targetRect.height > contentRect.y;
|
|
18
18
|
};
|
|
19
|
-
|
|
20
19
|
export const getTargetRect = slot => {
|
|
21
20
|
const item = getFirstSlotElement(slot, true);
|
|
22
21
|
if (item === null) {
|
package/utils/size.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type TSinchSize = 'l' | 'm' | 's';
|
|
2
|
+
export type TSinchSizeEx = TSinchSize | 'xs';
|
|
3
3
|
export declare const DEFAULT_SIZE: TSinchSize;
|
|
4
4
|
export declare const sizeValues: readonly TSinchSize[];
|
|
5
5
|
export declare const sizeExValues: readonly TSinchSizeEx[];
|
|
6
|
-
|
|
6
|
+
type TAssertSize = (value: string | null, name: string) => asserts value is TSinchSize;
|
|
7
7
|
export declare const assertSize: TAssertSize;
|
|
8
|
-
|
|
8
|
+
type TAssertSizeEx = (value: string | null, name: string) => asserts value is TSinchSizeEx;
|
|
9
9
|
export declare const assertSizeEx: TAssertSizeEx;
|
|
10
10
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export
|
|
2
|
+
export type TSinchVerticalStepperElement = HTMLElement & {
|
|
3
3
|
/** Current item index, starting from 1 */
|
|
4
4
|
index: string;
|
|
5
5
|
/** Current item index, starting from 1 */
|
|
6
6
|
setAttribute(name: 'index', value: string): void;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type TSinchVerticalStepperReact = TSinchElementReact<TSinchVerticalStepperElement> & {
|
|
9
9
|
/** Current item index, starting from 1 */
|
|
10
10
|
index: string;
|
|
11
11
|
/** Label that is used for a11y */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type TSinchVerticalStepperStatusType = 'error' | 'skip';
|
|
3
|
+
export type TSinchVerticalStepperItemElement = HTMLElement & {
|
|
4
4
|
/** Label */
|
|
5
5
|
label: string;
|
|
6
6
|
/** Description */
|
|
@@ -14,7 +14,7 @@ export declare type TSinchVerticalStepperItemElement = HTMLElement & {
|
|
|
14
14
|
/** Status */
|
|
15
15
|
setAttribute(name: 'status', value: TSinchVerticalStepperStatusType): void;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type TSinchVerticalStepperItemReact = TSinchElementReact<TSinchVerticalStepperItemElement> & {
|
|
18
18
|
/** Label */
|
|
19
19
|
label: string;
|
|
20
20
|
/** Description */
|