@nectary/components 2.7.0 → 2.8.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/link/index.js +19 -1
- package/link/types.d.ts +4 -0
- package/package.json +1 -1
- package/radio-option/types.d.ts +1 -0
- package/readme.md +0 -6
- package/rich-text/utils.js +12 -1
- package/tile-control/index.js +1 -1
- package/tile-control/types.d.ts +7 -5
- package/utils/markdown.d.ts +1 -1
- package/utils/markdown.js +9 -9
package/link/index.js
CHANGED
|
@@ -31,7 +31,7 @@ defineCustomElement('sinch-link', class extends NectaryElement {
|
|
|
31
31
|
this.removeEventListener('-blur', this.#onBlurReactHandler);
|
|
32
32
|
}
|
|
33
33
|
static get observedAttributes() {
|
|
34
|
-
return ['text', 'href', 'external', 'standalone', 'disabled'];
|
|
34
|
+
return ['text', 'href', 'use-history', 'external', 'standalone', 'disabled'];
|
|
35
35
|
}
|
|
36
36
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
37
37
|
if (isAttrEqual(oldVal, newVal)) {
|
|
@@ -48,6 +48,15 @@ defineCustomElement('sinch-link', class extends NectaryElement {
|
|
|
48
48
|
updateAttribute(this.#$anchor, 'href', newVal);
|
|
49
49
|
break;
|
|
50
50
|
}
|
|
51
|
+
case 'use-history':
|
|
52
|
+
{
|
|
53
|
+
const shouldUseHistory = isAttrTrue(newVal);
|
|
54
|
+
if (shouldUseHistory) {
|
|
55
|
+
updateBooleanAttribute(this, 'preventdefault', true);
|
|
56
|
+
}
|
|
57
|
+
updateBooleanAttribute(this, name, shouldUseHistory);
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
51
60
|
case 'standalone':
|
|
52
61
|
case 'disabled':
|
|
53
62
|
{
|
|
@@ -75,6 +84,12 @@ defineCustomElement('sinch-link', class extends NectaryElement {
|
|
|
75
84
|
set href(value) {
|
|
76
85
|
updateAttribute(this, 'href', value);
|
|
77
86
|
}
|
|
87
|
+
set 'use-history'(value) {
|
|
88
|
+
updateBooleanAttribute(this, 'use-history', value);
|
|
89
|
+
}
|
|
90
|
+
get 'use-history'() {
|
|
91
|
+
return getBooleanAttribute(this, 'use-history');
|
|
92
|
+
}
|
|
78
93
|
set disabled(isDisabled) {
|
|
79
94
|
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
80
95
|
}
|
|
@@ -111,6 +126,9 @@ defineCustomElement('sinch-link', class extends NectaryElement {
|
|
|
111
126
|
#onAnchorClick = e => {
|
|
112
127
|
if (this.preventDefault) {
|
|
113
128
|
e.preventDefault();
|
|
129
|
+
if (this['use-history']) {
|
|
130
|
+
history.pushState({}, '', this.href);
|
|
131
|
+
}
|
|
114
132
|
}
|
|
115
133
|
this.dispatchEvent(new CustomEvent('-click'));
|
|
116
134
|
};
|
package/link/types.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export type TSinchLinkElement = HTMLElement & {
|
|
|
6
6
|
href: string;
|
|
7
7
|
/** Disabled */
|
|
8
8
|
disabled: boolean;
|
|
9
|
+
/** Replaces the anchor tag behaviour to use history instead */
|
|
10
|
+
'use-history': boolean;
|
|
9
11
|
/** Sets `target="_blank" and a special external icon on the left side */
|
|
10
12
|
external: boolean;
|
|
11
13
|
/** Special standalone (`display: block`) mode with an arrow icon on the right side */
|
|
@@ -36,6 +38,8 @@ export type TSinchLinkReact = TSinchElementReact<TSinchLinkElement> & {
|
|
|
36
38
|
text: string;
|
|
37
39
|
/** URL that hyperlink point to */
|
|
38
40
|
href: string;
|
|
41
|
+
/** Replaces the anchor tag behaviour to use history instead */
|
|
42
|
+
'use-history'?: boolean;
|
|
39
43
|
/** Disabled */
|
|
40
44
|
disabled?: boolean;
|
|
41
45
|
/** Sets `target="_blank" and a special external icon on the left side */
|
package/package.json
CHANGED
package/radio-option/types.d.ts
CHANGED
package/readme.md
CHANGED
|
@@ -8,12 +8,6 @@ Design System's framework-agnostic Component Library implementation.
|
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
|
-
Add the following line to `.npmrc` in the project root:
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
//registry.npmjs.org/:_authToken=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
|
|
15
|
-
```
|
|
16
|
-
|
|
17
11
|
Add the component library dependency to `package.json`:
|
|
18
12
|
|
|
19
13
|
```
|
package/rich-text/utils.js
CHANGED
|
@@ -47,10 +47,21 @@ export const createParseVisitor = doc => {
|
|
|
47
47
|
const $br = doc.createElement('br');
|
|
48
48
|
$p.appendChild($br);
|
|
49
49
|
},
|
|
50
|
-
link(text, href) {
|
|
50
|
+
link(text, href, attributes) {
|
|
51
51
|
const $link = doc.createElement('sinch-link');
|
|
52
52
|
$link.text = text;
|
|
53
53
|
$link.href = href;
|
|
54
|
+
if (attributes != null) {
|
|
55
|
+
attributes.forEach(attr => {
|
|
56
|
+
switch (attr) {
|
|
57
|
+
case 'use-history':
|
|
58
|
+
$link['use-history'] = true;
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
54
65
|
$p.appendChild($link);
|
|
55
66
|
},
|
|
56
67
|
list(isOrdered) {
|
package/tile-control/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCustomElement, getAttribute, getBooleanAttribute, unpackCsv, getFirstCsvValue, getIntegerAttribute, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv, updateIntegerAttribute, isAttrTrue, isAttrEqual } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:block;outline:0;--sinch-grid-num-columns:1}#wrapper{display:grid;grid-template-columns:repeat(var(--sinch-grid-num-columns),auto);gap:16px;width:fit-content}:host([small]) #wrapper{gap:8px}:host([cols="2"]){--sinch-grid-num-columns:2}:host([cols="3"]){--sinch-grid-num-columns:3}:host([cols="4"]){--sinch-grid-num-columns:4}:host([cols="5"]){--sinch-grid-num-columns:5}:host([cols="6"]){--sinch-grid-num-columns:6}:host([cols="7"]){--sinch-grid-num-columns:7}:host([cols="8"]){--sinch-grid-num-columns:8}</style><div id="wrapper"><slot></slot></div>';
|
|
2
|
+
const templateHTML = '<style>:host{display:block;outline:0;--sinch-grid-num-columns:1}#wrapper{display:grid;grid-template-columns:repeat(var(--sinch-grid-num-columns),auto);gap:16px;width:fit-content}:host([small]) #wrapper{gap:8px}:host([cols="2"]){--sinch-grid-num-columns:2}:host([cols="3"]){--sinch-grid-num-columns:3}:host([cols="4"]){--sinch-grid-num-columns:4}:host([cols="5"]){--sinch-grid-num-columns:5}:host([cols="6"]){--sinch-grid-num-columns:6}:host([cols="7"]){--sinch-grid-num-columns:7}:host([cols="8"]){--sinch-grid-num-columns:8}:host([cols="9"]){--sinch-grid-num-columns:9}:host([cols="10"]){--sinch-grid-num-columns:10}</style><div id="wrapper"><slot></slot></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-tile-control', class extends NectaryElement {
|
package/tile-control/types.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
+
/** Number of coumns from 1 to 10 */
|
|
3
|
+
export type TSinchTileControlColumns = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | number;
|
|
2
4
|
export type TSinchTileControlElement = HTMLElement & {
|
|
3
5
|
/** Value */
|
|
4
6
|
value: string;
|
|
@@ -6,8 +8,8 @@ export type TSinchTileControlElement = HTMLElement & {
|
|
|
6
8
|
small: boolean;
|
|
7
9
|
/** Multiple */
|
|
8
10
|
multiple: boolean;
|
|
9
|
-
/** Number of columns from 1 to
|
|
10
|
-
cols:
|
|
11
|
+
/** Number of columns from 1 to 10 */
|
|
12
|
+
cols: TSinchTileControlColumns;
|
|
11
13
|
/** Change value event */
|
|
12
14
|
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
13
15
|
/** Value */
|
|
@@ -16,7 +18,7 @@ export type TSinchTileControlElement = HTMLElement & {
|
|
|
16
18
|
setAttribute(name: 'small', value: ''): void;
|
|
17
19
|
/** Multiple */
|
|
18
20
|
setAttribute(name: 'multiple', value: ''): void;
|
|
19
|
-
/** Number of columns from 1 to
|
|
21
|
+
/** Number of columns from 1 to 10 */
|
|
20
22
|
setAttribute(name: 'cols', value: string): void;
|
|
21
23
|
};
|
|
22
24
|
export type TSinchTileControlReact = TSinchElementReact<TSinchTileControlElement> & {
|
|
@@ -26,8 +28,8 @@ export type TSinchTileControlReact = TSinchElementReact<TSinchTileControlElement
|
|
|
26
28
|
multiple?: boolean;
|
|
27
29
|
/** Small */
|
|
28
30
|
small?: boolean;
|
|
29
|
-
/** Number of columns from 1 to
|
|
30
|
-
cols:
|
|
31
|
+
/** Number of columns from 1 to 10 */
|
|
32
|
+
cols: TSinchTileControlColumns;
|
|
31
33
|
/** Label that is used for a11y */
|
|
32
34
|
'aria-label': string;
|
|
33
35
|
/** Change value handler */
|
package/utils/markdown.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type TMarkdownInlineParams = {
|
|
|
4
4
|
isStrikethrough?: boolean;
|
|
5
5
|
};
|
|
6
6
|
export type TMarkdownParseVisitor = {
|
|
7
|
-
link(text: string, href: string): void;
|
|
7
|
+
link(text: string, href: string, attributes?: string[]): void;
|
|
8
8
|
emoji(emojiChar: string): void;
|
|
9
9
|
codetag(text: string): void;
|
|
10
10
|
inline(text: string, params: TMarkdownInlineParams): void;
|
package/utils/markdown.js
CHANGED
|
@@ -8,7 +8,7 @@ const regEm2Underscore = /__(?<em2>.+?)__/;
|
|
|
8
8
|
const regEm1Underscore = /_(?<em1>.+?)_/;
|
|
9
9
|
const regCodeTag = /`(?<code>.+?)`/;
|
|
10
10
|
const regStrikethrough = /~~(?<strike>.+?)~~/;
|
|
11
|
-
const regLink = /!?\[(?<linktext>[^\]]*?)\]\((?<linkhref>[^)]+?)\)
|
|
11
|
+
const regLink = /!?\[(?<linktext>[^\]]*?)\]\((?<linkhref>[^)]+?)\)(\{(?<linkattrs>[^)]+?)\})?/;
|
|
12
12
|
const regEmoji = /(?<emoji>(?![0-9*#])\p{Emoji})/u;
|
|
13
13
|
const regUList = /^(?<indent>[\t ]*?)[*+-][\t ]+(?<ultext>.*?)[\t ]*?$/;
|
|
14
14
|
const regOList = /^(?<indent>[\t ]*?)\d+\.[\t ]+(?<oltext>.*?)[\t ]*?$/;
|
|
@@ -47,35 +47,35 @@ const createLineParser = visitor => function parseLine(regs, md) {
|
|
|
47
47
|
visitor.inline(line.substring(0, match.index), context);
|
|
48
48
|
}
|
|
49
49
|
line = line.substring(match.index + matchedStr.length);
|
|
50
|
-
if (groups
|
|
51
|
-
visitor.link(groups.linktext, groups.linkhref);
|
|
50
|
+
if (groups?.linkhref != null) {
|
|
51
|
+
visitor.link(groups.linktext, groups.linkhref, groups.linkattrs?.split(' '));
|
|
52
52
|
}
|
|
53
|
-
if (groups
|
|
53
|
+
if (groups?.code != null) {
|
|
54
54
|
visitor.codetag(groups.code);
|
|
55
55
|
}
|
|
56
|
-
if (groups
|
|
56
|
+
if (groups?.emoji != null) {
|
|
57
57
|
visitor.emoji(groups.emoji);
|
|
58
58
|
}
|
|
59
|
-
if (groups
|
|
59
|
+
if (groups?.em1 != null) {
|
|
60
60
|
parseLine(excludeRegs(regs, regEm1Star, regEm1Underscore), groups.em1, {
|
|
61
61
|
...context,
|
|
62
62
|
isItalic: true
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
if (groups
|
|
65
|
+
if (groups?.em2 != null) {
|
|
66
66
|
parseLine(excludeRegs(regs, regEm2Star, regEm2Underscore), groups.em2, {
|
|
67
67
|
...context,
|
|
68
68
|
isBold: true
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
if (groups
|
|
71
|
+
if (groups?.em3 != null) {
|
|
72
72
|
parseLine(excludeRegs(regs, regEm3Star, regEm3Underscore, regEm2Star, regEm2Underscore, regEm1Star, regEm1Underscore), groups.em3, {
|
|
73
73
|
...context,
|
|
74
74
|
isBold: true,
|
|
75
75
|
isItalic: true
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
if (groups
|
|
78
|
+
if (groups?.strike != null) {
|
|
79
79
|
parseLine(excludeRegs(regs, regStrikethrough), groups.strike, {
|
|
80
80
|
...context,
|
|
81
81
|
isStrikethrough: true
|