@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
package/pagination/index.js
CHANGED
|
@@ -95,11 +95,9 @@ defineCustomElement('sinch-pagination', class extends NectaryElement {
|
|
|
95
95
|
e.stopPropagation();
|
|
96
96
|
const value = getIntegerAttribute(this, 'value', 0) - 1;
|
|
97
97
|
const max = Math.max(0, getIntegerAttribute(this, 'max', 0));
|
|
98
|
-
|
|
99
98
|
if (e.target === this.#$left) {
|
|
100
99
|
return this.#dispatchChangeEvent(value - 1);
|
|
101
100
|
}
|
|
102
|
-
|
|
103
101
|
if (e.target === this.#$right) {
|
|
104
102
|
return this.#dispatchChangeEvent(value + 1);
|
|
105
103
|
}
|
|
@@ -108,19 +106,15 @@ defineCustomElement('sinch-pagination', class extends NectaryElement {
|
|
|
108
106
|
if (btnIndex === FIRST_BTN_INDEX) {
|
|
109
107
|
return this.#dispatchChangeEvent(0);
|
|
110
108
|
}
|
|
111
|
-
|
|
112
109
|
if (btnIndex === this.#$buttons.length - 1) {
|
|
113
110
|
return this.#dispatchChangeEvent(max - 1);
|
|
114
111
|
}
|
|
115
|
-
|
|
116
112
|
if (btnIndex === DOTS_LEFT_INDEX && max > NUM_BUTTONS && value > MIDDLE_BTN_INDEX) {
|
|
117
113
|
return this.#dispatchChangeEvent(Math.floor(value / 2));
|
|
118
114
|
}
|
|
119
|
-
|
|
120
115
|
if (btnIndex === DOTS_RIGHT_INDEX && max > NUM_BUTTONS && value <= max - DOTS_RIGHT_INDEX) {
|
|
121
116
|
return this.#dispatchChangeEvent(Math.floor((max - value) / 2 + value));
|
|
122
117
|
}
|
|
123
|
-
|
|
124
118
|
return this.#dispatchChangeEvent(btnIndex + Math.min(Math.max(0, value - MIDDLE_BTN_INDEX), Math.max(0, max - NUM_BUTTONS)));
|
|
125
119
|
}
|
|
126
120
|
};
|
package/pagination/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TRect, TSinchElementReact } from '../types';
|
|
2
2
|
import type { SyntheticEvent } from 'react';
|
|
3
|
-
export
|
|
3
|
+
export type TSinchPaginationElement = HTMLElement & {
|
|
4
4
|
value: number;
|
|
5
5
|
max: number;
|
|
6
6
|
readonly prevButtonRect: TRect;
|
|
@@ -11,7 +11,7 @@ export declare type TSinchPaginationElement = HTMLElement & {
|
|
|
11
11
|
setAttribute(name: 'value', value: string): void;
|
|
12
12
|
setAttribute(name: 'max', value: string): void;
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type TSinchPaginationReact = TSinchElementReact<TSinchPaginationElement> & {
|
|
15
15
|
value: number;
|
|
16
16
|
max: number;
|
|
17
17
|
/** @deprecated */
|
package/pop/index.js
CHANGED
|
@@ -146,7 +146,6 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
|
|
|
146
146
|
if (!this.isConnected || this.#isOpen()) {
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
|
-
|
|
150
149
|
this.#$targetSlot.addEventListener('blur', this.#stopEventPropagation, true);
|
|
151
150
|
this.#$focus.style.setProperty('display', 'block');
|
|
152
151
|
this.#$focus.addEventListener('focus', this.#captureRelatedActiveElement);
|
|
@@ -154,7 +153,6 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
|
|
|
154
153
|
this.#$focus.removeEventListener('focus', this.#captureRelatedActiveElement);
|
|
155
154
|
this.#$focus.style.removeProperty('display');
|
|
156
155
|
this.#$targetSlot.removeEventListener('blur', this.#stopEventPropagation, true);
|
|
157
|
-
|
|
158
156
|
this.#$dialog.showModal();
|
|
159
157
|
this.#$target.setAttribute('aria-expanded', 'true');
|
|
160
158
|
this.#updateOrientation();
|
|
@@ -180,15 +178,12 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
|
|
|
180
178
|
const matrix = new DOMMatrixReadOnly(targetElComputedStyle.transform);
|
|
181
179
|
$targetEl.style.setProperty('transform', matrix.translate(-matrix.e, -matrix.f).toString());
|
|
182
180
|
}
|
|
183
|
-
|
|
184
181
|
getFirstSlotElement(this.#$targetSlot)?.setAttribute('slot', 'target-open');
|
|
185
|
-
|
|
186
182
|
this.#$targetOpenSlot.addEventListener('keydown', this.#onTargetKeydown);
|
|
187
183
|
if (this.#targetActiveElement !== null) {
|
|
188
184
|
this.#$targetOpenSlot.addEventListener('focus', this.#stopEventPropagation, true);
|
|
189
185
|
this.#targetActiveElement.focus();
|
|
190
186
|
this.#$targetOpenSlot.removeEventListener('focus', this.#stopEventPropagation, true);
|
|
191
|
-
|
|
192
187
|
if (!isElementFocused(this.#targetActiveElement)) {
|
|
193
188
|
requestAnimationFrame(() => {
|
|
194
189
|
this.#$targetOpenSlot.addEventListener('focus', this.#stopEventPropagation, true);
|
|
@@ -198,10 +193,8 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
|
|
|
198
193
|
}
|
|
199
194
|
}
|
|
200
195
|
}
|
|
201
|
-
|
|
202
196
|
disableScroll();
|
|
203
197
|
window.addEventListener('resize', this.#onResize);
|
|
204
|
-
|
|
205
198
|
this.#dispatchContentVisibility(true);
|
|
206
199
|
}
|
|
207
200
|
#onCollapse() {
|
|
@@ -209,23 +202,17 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
|
|
|
209
202
|
return;
|
|
210
203
|
}
|
|
211
204
|
const isNonModal = !this.modal;
|
|
212
|
-
|
|
213
205
|
this.#dispatchContentVisibility(false);
|
|
214
|
-
|
|
215
206
|
this.#$targetOpenSlot.removeEventListener('keydown', this.#onTargetKeydown);
|
|
216
|
-
|
|
217
207
|
if (isNonModal) {
|
|
218
208
|
this.#targetActiveElement = null;
|
|
219
209
|
this.#$targetOpenSlot.addEventListener('blur', this.#captureActiveElement, true);
|
|
220
210
|
}
|
|
221
|
-
|
|
222
211
|
this.#$dialog.close();
|
|
223
212
|
this.#$target.setAttribute('aria-expanded', 'false');
|
|
224
|
-
|
|
225
213
|
if (isNonModal) {
|
|
226
214
|
this.#$targetOpenSlot.removeEventListener('blur', this.#captureActiveElement, true);
|
|
227
215
|
}
|
|
228
|
-
|
|
229
216
|
const targetEl = this.#getFirstTargetElement(this.#$targetOpenSlot);
|
|
230
217
|
targetEl.style.removeProperty('margin');
|
|
231
218
|
targetEl.style.removeProperty('position');
|
|
@@ -238,13 +225,11 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
|
|
|
238
225
|
this.#$target.style.removeProperty('display');
|
|
239
226
|
this.#$target.style.removeProperty('width');
|
|
240
227
|
this.#$target.style.removeProperty('height');
|
|
241
|
-
|
|
242
228
|
if (this.#targetActiveElement !== null) {
|
|
243
229
|
if (!isElementFocused(this.#targetActiveElement)) {
|
|
244
230
|
this.#$targetSlot.addEventListener('focus', this.#stopEventPropagation, true);
|
|
245
231
|
this.#targetActiveElement.focus();
|
|
246
232
|
this.#$targetSlot.removeEventListener('focus', this.#stopEventPropagation, true);
|
|
247
|
-
|
|
248
233
|
if (!isElementFocused(this.#targetActiveElement)) {
|
|
249
234
|
const $targetEl = this.#targetActiveElement;
|
|
250
235
|
requestAnimationFrame(() => {
|
|
@@ -256,7 +241,6 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
|
|
|
256
241
|
this.#targetActiveElement = null;
|
|
257
242
|
}
|
|
258
243
|
}
|
|
259
|
-
|
|
260
244
|
enableScroll();
|
|
261
245
|
this.#resizeThrottle.cancel();
|
|
262
246
|
window.removeEventListener('resize', this.#onResize);
|
package/pop/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TRect, TSinchElementReact } from '../types';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type TSinchPopOrientation = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'bottom-center' | 'bottom-stretch' | 'top-center' | 'top-stretch' | 'center-right' | 'center-left';
|
|
3
|
+
export type TSinchPopElement = HTMLElement & {
|
|
4
4
|
/** Open/close state */
|
|
5
5
|
open: boolean;
|
|
6
6
|
/** Orientation, where it *points to* from origin */
|
|
@@ -20,7 +20,7 @@ export declare type TSinchPopElement = HTMLElement & {
|
|
|
20
20
|
setAttribute(name: 'modal', value: boolean): void;
|
|
21
21
|
setAttribute(name: 'inset', value: string): void;
|
|
22
22
|
};
|
|
23
|
-
export
|
|
23
|
+
export type TSinchPopReact = TSinchElementReact<TSinchPopElement> & {
|
|
24
24
|
/** Open/close state */
|
|
25
25
|
open: boolean;
|
|
26
26
|
/** Orientation, where it *points to* from origin */
|
package/pop/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TSinchPopOrientation } from './types';
|
|
2
2
|
export declare const orientationValues: readonly TSinchPopOrientation[];
|
|
3
|
-
|
|
3
|
+
type TAssertOrientation = (value: string | null) => asserts value is TSinchPopOrientation;
|
|
4
4
|
export declare const assertOrientation: TAssertOrientation;
|
|
5
5
|
export declare const disableScroll: () => void;
|
|
6
6
|
export declare const enableScroll: () => void;
|
package/popover/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TRect, TSinchElementReact } from '../types';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type TSinchPopoverOrientation = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'bottom' | 'top';
|
|
3
|
+
export type TSinchPopoverElement = HTMLElement & {
|
|
4
4
|
/** Open/close state */
|
|
5
5
|
open: boolean;
|
|
6
6
|
/** Orientation, where it *points to* from origin */
|
|
@@ -22,7 +22,7 @@ export declare type TSinchPopoverElement = HTMLElement & {
|
|
|
22
22
|
/** Show tip */
|
|
23
23
|
setAttribute(name: 'tip', value: ''): void;
|
|
24
24
|
};
|
|
25
|
-
export
|
|
25
|
+
export type TSinchPopoverReact = TSinchElementReact<TSinchPopoverElement> & {
|
|
26
26
|
/** Open/close state */
|
|
27
27
|
open: boolean;
|
|
28
28
|
/** Orientation, where it *points to* from origin */
|
package/popover/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { TSinchPopOrientation } from '../pop/types';
|
|
2
1
|
import type { TSinchPopoverOrientation } from './types';
|
|
2
|
+
import type { TSinchPopOrientation } from '../pop/types';
|
|
3
3
|
export declare const orientationValues: readonly TSinchPopoverOrientation[];
|
|
4
4
|
export declare const getPopOrientation: (orientation: TSinchPopoverOrientation) => TSinchPopOrientation;
|
|
5
|
-
|
|
5
|
+
type TAssertOrientation = (value: string | null) => asserts value is TSinchPopoverOrientation;
|
|
6
6
|
export declare const assertOrientation: TAssertOrientation;
|
|
7
7
|
export {};
|
package/progress/types.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export
|
|
2
|
+
export type TSinchProgressElement = HTMLElement & {
|
|
3
3
|
value: number;
|
|
4
4
|
detailed: boolean;
|
|
5
5
|
setAttribute(name: 'value', value: string): void;
|
|
6
6
|
setAttribute(name: 'detailed', value: ''): void;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type TSinchProgressReact = TSinchElementReact<TSinchProgressElement> & {
|
|
9
9
|
value: number;
|
|
10
10
|
detailed?: boolean;
|
|
11
11
|
'aria-label': string;
|
package/radio/types.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
2
|
import type { SyntheticEvent } from 'react';
|
|
3
|
-
export
|
|
3
|
+
export type TSinchRadioElement = HTMLElement & {
|
|
4
4
|
value: string;
|
|
5
5
|
addEventListener(type: 'change', listener: (e: CustomEvent<boolean>) => void): void;
|
|
6
6
|
addEventListener(type: '-change', listener: (e: CustomEvent<boolean>) => void): void;
|
|
7
7
|
setAttribute(name: 'value', value: string): void;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type TSinchRadioReact = TSinchElementReact<TSinchRadioElement> & {
|
|
10
10
|
value: string;
|
|
11
11
|
'aria-label': string;
|
|
12
12
|
/** @deprecated */
|
package/radio-option/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export
|
|
2
|
+
export type TSinchRadioOptionElement = HTMLElement & {
|
|
3
3
|
value: string;
|
|
4
4
|
checked: boolean;
|
|
5
5
|
disabled: boolean;
|
|
@@ -9,7 +9,7 @@ export declare type TSinchRadioOptionElement = HTMLElement & {
|
|
|
9
9
|
setAttribute(name: 'disabled', value: ''): void;
|
|
10
10
|
setAttribute(name: 'text', value: string): void;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type TSinchRadioOptionReact = TSinchElementReact<TSinchRadioOptionElement> & {
|
|
13
13
|
value: string;
|
|
14
14
|
disabled?: boolean;
|
|
15
15
|
text: string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import '../icons/cancel';
|
|
2
|
+
import type { TSinchRichTextElement, TSinchRichTextReact } from './types';
|
|
3
|
+
declare global {
|
|
4
|
+
namespace JSX {
|
|
5
|
+
interface IntrinsicElements {
|
|
6
|
+
'sinch-rich-text': TSinchRichTextReact;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
interface HTMLElementTagNameMap {
|
|
10
|
+
'sinch-rich-text': TSinchRichTextElement;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import '../icons/cancel';
|
|
2
|
+
import { defineCustomElement, NectaryElement, getLiteralAttribute, updateLiteralAttribute, getAttribute, updateAttribute, parseMarkdown } from '../utils';
|
|
3
|
+
const templateHTML = '<style>:host{display:block;font:var(--sinch-font-text-m)}:host([size="s"]){font:var(--sinch-font-text-s)}:host([size=xs]){font:var(--sinch-font-text-xs)}:host([size=xxs]){font:var(--sinch-font-text-xxs)}.em1{font-style:italic}.em2{font-weight:700}.em3{font-style:italic;font-weight:700}.strikethrough{text-decoration:line-through}.link{color:var(--sinch-color-tropical-500)}.code{border:1px solid var(--sinch-color-border-light);background-color:var(--sinch-color-bg-primary-contrast);padding:0 .25em;border-radius:var(--sinch-shape-radius-xs)}.paragraph{margin:0}.paragraph+.paragraph{margin-top:12px}</style><div id="wrapper"></div>';
|
|
4
|
+
import { assertSize, sizeValues } from './utils';
|
|
5
|
+
const template = document.createElement('template');
|
|
6
|
+
template.innerHTML = templateHTML;
|
|
7
|
+
defineCustomElement('sinch-rich-text', class extends NectaryElement {
|
|
8
|
+
#wrapper;
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
const shadowRoot = this.attachShadow();
|
|
12
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
13
|
+
this.#wrapper = shadowRoot.querySelector('#wrapper');
|
|
14
|
+
}
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
this.setAttribute('role', 'paragraph');
|
|
17
|
+
}
|
|
18
|
+
get size() {
|
|
19
|
+
return getLiteralAttribute(this, sizeValues, 'size', 'm');
|
|
20
|
+
}
|
|
21
|
+
set size(value) {
|
|
22
|
+
updateLiteralAttribute(this, sizeValues, 'size', value);
|
|
23
|
+
}
|
|
24
|
+
get text() {
|
|
25
|
+
return getAttribute(this, 'text', '');
|
|
26
|
+
}
|
|
27
|
+
set text(value) {
|
|
28
|
+
updateAttribute(this, 'text', value);
|
|
29
|
+
}
|
|
30
|
+
static get observedAttributes() {
|
|
31
|
+
return ['size', 'text'];
|
|
32
|
+
}
|
|
33
|
+
attributeChangedCallback(name, _, newVal) {
|
|
34
|
+
switch (name) {
|
|
35
|
+
case 'size':
|
|
36
|
+
{
|
|
37
|
+
if ('production' !== 'production') {
|
|
38
|
+
assertSize(newVal);
|
|
39
|
+
}
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
case 'text':
|
|
43
|
+
{
|
|
44
|
+
this.#updateText(newVal);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
#updateText(text) {
|
|
50
|
+
if (text === null) {
|
|
51
|
+
this.#wrapper.innerHTML = '';
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
this.#wrapper.innerHTML = parseMarkdown(text);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TSinchTextType } from '../text/types';
|
|
2
|
+
import type { TSinchElementReact } from '../types';
|
|
3
|
+
export type TSinchRichTextElement = HTMLElement & {
|
|
4
|
+
size: TSinchTextType;
|
|
5
|
+
text: string;
|
|
6
|
+
setAttribute(name: 'size', value: TSinchTextType): void;
|
|
7
|
+
setAttribute(name: 'text', value: string): void;
|
|
8
|
+
};
|
|
9
|
+
export type TSinchRichTextReact = TSinchElementReact<TSinchRichTextElement> & {
|
|
10
|
+
size?: TSinchTextType;
|
|
11
|
+
text: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/segment/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TRect, TSinchElementReact } from '../types';
|
|
2
2
|
import type { TSinchSize } from '../utils/size';
|
|
3
|
-
export
|
|
3
|
+
export type TSinchSegmentElement = HTMLElement & {
|
|
4
4
|
caption: string;
|
|
5
5
|
collapsed: boolean;
|
|
6
6
|
size: TSinchSize;
|
|
@@ -9,7 +9,7 @@ export declare type TSinchSegmentElement = HTMLElement & {
|
|
|
9
9
|
setAttribute(name: 'collapsed', value: ''): void;
|
|
10
10
|
setAttribute(name: 'size', value: TSinchSize): void;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type TSinchSegmentReact = TSinchElementReact<TSinchSegmentElement> & {
|
|
13
13
|
caption: string;
|
|
14
14
|
collapsed?: boolean;
|
|
15
15
|
size?: TSinchSize;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
2
|
import type { SyntheticEvent } from 'react';
|
|
3
|
-
export
|
|
3
|
+
export type TSinchSegmentExpandElement = HTMLElement & {
|
|
4
4
|
value: boolean;
|
|
5
5
|
addEventListener(type: 'change', listener: (e: CustomEvent<boolean>) => void): void;
|
|
6
6
|
addEventListener(type: '-change', listener: (e: CustomEvent<boolean>) => void): void;
|
|
7
7
|
setAttribute(name: 'value', value: string): void;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type TSinchSegmentExpandReact = TSinchElementReact<TSinchSegmentExpandElement> & {
|
|
10
10
|
value: boolean;
|
|
11
11
|
'aria-label': string;
|
|
12
12
|
/** @deprecated */
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
2
|
import type { SyntheticEvent } from 'react';
|
|
3
|
-
export
|
|
3
|
+
export type TSinchSegmentedControlElement = HTMLElement & {
|
|
4
4
|
value: string;
|
|
5
5
|
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
6
6
|
setAttribute(name: 'value', value: string): void;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type TSinchSegmentedControlReact = TSinchElementReact<TSinchSegmentedControlElement> & {
|
|
9
9
|
value: string;
|
|
10
10
|
'aria-label': string;
|
|
11
11
|
/** @deprecated */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export
|
|
2
|
+
export type TSinchSegmentedControlOptionElement = HTMLElement & {
|
|
3
3
|
value: string;
|
|
4
4
|
disabled: boolean;
|
|
5
5
|
text: string;
|
|
@@ -9,7 +9,7 @@ export declare type TSinchSegmentedControlOptionElement = HTMLElement & {
|
|
|
9
9
|
setAttribute(name: 'text', value: string): void;
|
|
10
10
|
setAttribute(name: 'disabled', value: ''): void;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type TSinchSegmentedControlOptionReact = TSinchElementReact<TSinchSegmentedControlOptionElement> & {
|
|
13
13
|
value: string;
|
|
14
14
|
text: string;
|
|
15
15
|
disabled?: boolean;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
2
|
import type { SyntheticEvent } from 'react';
|
|
3
|
-
export
|
|
3
|
+
export type TSinchSegmentedIconControlElement = HTMLElement & {
|
|
4
4
|
value: string;
|
|
5
5
|
multiple: boolean;
|
|
6
6
|
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
7
7
|
setAttribute(name: 'value', value: string): void;
|
|
8
8
|
setAttribute(name: 'multiple', value: ''): void;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type TSinchSegmentedIconControlReact = TSinchElementReact<TSinchSegmentedIconControlElement> & {
|
|
11
11
|
value: string;
|
|
12
12
|
multiple?: boolean;
|
|
13
13
|
'aria-label': string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export
|
|
2
|
+
export type TSinchSegmentedIconControlOptionElement = HTMLElement & {
|
|
3
3
|
value: string;
|
|
4
4
|
disabled: boolean;
|
|
5
5
|
addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
|
|
@@ -7,7 +7,7 @@ export declare type TSinchSegmentedIconControlOptionElement = HTMLElement & {
|
|
|
7
7
|
setAttribute(name: 'value', value: string): void;
|
|
8
8
|
setAttribute(name: 'disabled', value: ''): void;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type TSinchSegmentedIconControlOptionReact = TSinchElementReact<TSinchSegmentedIconControlOptionElement> & {
|
|
11
11
|
value: string;
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
'aria-label': string;
|
package/select-button/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import '../text';
|
|
|
2
2
|
import '../icons/keyboard-arrow-down';
|
|
3
3
|
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getReactEventHandler, isAttrTrue, NectaryElement, setClass, subscribeContext, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute, Context } from '../utils';
|
|
4
4
|
import { assertSize, DEFAULT_SIZE, sizeValues } from '../utils/size';
|
|
5
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-size:var(--sinch-size-m);--sinch-size-icon:var(--sinch-select-button-icon-size-m);--sinch-shape-radius:var(--sinch-shape-radius-m)}:host([data-size="l"]){--sinch-size:var(--sinch-size-l);--sinch-size-icon:var(--sinch-select-button-icon-size-l);--sinch-shape-radius:var(--sinch-shape-radius-l)}:host([data-size="m"]){--sinch-size:var(--sinch-size-m);--sinch-size-icon:var(--sinch-select-button-icon-size-m);--sinch-shape-radius:var(--sinch-shape-radius-m)}:host([data-size="s"]){--sinch-size:var(--sinch-size-s);--sinch-size-icon:var(--sinch-select-button-icon-size-s);--sinch-shape-radius:var(--sinch-shape-radius-s)}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:var(--sinch-size);padding:0 8px 0 12px;background-color:var(--sinch-color-bg-primary-light);border-radius:var(--sinch-shape-radius);--sinch-color-icon:var(--sinch-color-stormy-500)}:host([
|
|
5
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-size:var(--sinch-size-m);--sinch-size-icon:var(--sinch-select-button-icon-size-m);--sinch-shape-radius:var(--sinch-shape-radius-m)}:host([data-size="l"]){--sinch-size:var(--sinch-size-l);--sinch-size-icon:var(--sinch-select-button-icon-size-l);--sinch-shape-radius:var(--sinch-shape-radius-l)}:host([data-size="m"]){--sinch-size:var(--sinch-size-m);--sinch-size-icon:var(--sinch-select-button-icon-size-m);--sinch-shape-radius:var(--sinch-shape-radius-m)}:host([data-size="s"]){--sinch-size:var(--sinch-size-s);--sinch-size-icon:var(--sinch-select-button-icon-size-s);--sinch-shape-radius:var(--sinch-shape-radius-s)}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:var(--sinch-size);padding:0 8px 0 12px;background-color:var(--sinch-color-bg-primary-light);border-radius:var(--sinch-shape-radius);--sinch-color-icon:var(--sinch-color-stormy-500)}:host([data-size="l"]) #wrapper{padding:0 12px}:host([data-size="m"]) #wrapper{padding:0 8px 0 12px}:host([data-size="s"]) #wrapper{padding:0 4px 0 12px}:host([disabled]:not([disabled=false])) #wrapper{--sinch-color-icon:var(--sinch-color-text-disabled)}#button{all:initial;cursor:pointer;position:absolute;left:0;top:0;width:100%;height:100%;z-index:1}#border{position:absolute;border:1px solid var(--sinch-color-border-dark);border-radius:var(--sinch-shape-radius);inset:0;pointer-events:none}#text{flex:1;min-width:0;color:var(--sinch-color-text-muted)}:host([text]:not([text=""])) #text{color:var(--sinch-color-text-default)}#button:disabled{cursor:initial}#button:disabled+#border{border-color:var(--sinch-color-border-disabled)}#button:focus-visible+#border{border-color:var(--sinch-color-border-focus);border-width:2px}:host([invalid]) #button:enabled+#border{border-color:var(--sinch-color-text-invalid)}#button:disabled~#text{color:var(--sinch-color-text-disabled)}#left{display:flex;flex-direction:row;align-self:stretch;align-items:center;gap:4px;margin-left:-4px}#left.empty{display:none}#dropdown-icon{margin-left:-4px}</style><div id="wrapper"><button id="button"></button><div id="border"></div><div id="left"><slot name="left"></slot></div><slot name="icon"></slot><sinch-text id="text" type="m" ellipsis></sinch-text><sinch-icon-keyboard-arrow-down id="dropdown-icon"></sinch-icon-keyboard-arrow-down></div>';
|
|
6
6
|
const template = document.createElement('template');
|
|
7
7
|
template.innerHTML = templateHTML;
|
|
8
8
|
defineCustomElement('sinch-select-button', class extends NectaryElement {
|
package/select-button/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
2
|
import type { TSinchSize } from '../utils/size';
|
|
3
|
-
export
|
|
3
|
+
export type TSinchSelectButtonElement = HTMLElement & {
|
|
4
4
|
/** Text */
|
|
5
5
|
text: string;
|
|
6
6
|
/** Text that appears in the text field when it has no text set */
|
|
@@ -28,7 +28,7 @@ export declare type TSinchSelectButtonElement = HTMLElement & {
|
|
|
28
28
|
/** Size, `m` by default */
|
|
29
29
|
setAttribute(name: 'size', value: TSinchSize): void;
|
|
30
30
|
};
|
|
31
|
-
export
|
|
31
|
+
export type TSinchSelectButtonReact = TSinchElementReact<TSinchSelectButtonElement> & {
|
|
32
32
|
/** Text */
|
|
33
33
|
text: string;
|
|
34
34
|
/** Label that is used for a11y` */
|
package/select-menu/index.js
CHANGED
|
@@ -251,7 +251,6 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
251
251
|
const hasRows = this.hasAttribute('rows');
|
|
252
252
|
for (const $op of this.#getOptionElements()) {
|
|
253
253
|
const isSelected = $op === $option;
|
|
254
|
-
|
|
255
254
|
updateBooleanAttribute($op, 'data-selected', isSelected);
|
|
256
255
|
if (isSelected && hasRows) {
|
|
257
256
|
$op.scrollIntoView?.({
|
package/select-menu/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export
|
|
2
|
+
export type TSinchSelectMenuElement = HTMLElement & {
|
|
3
3
|
/** Selected value, CSV when multiple */
|
|
4
4
|
value: string;
|
|
5
5
|
/** How many rows to show and scroll the rest */
|
|
@@ -15,7 +15,7 @@ export declare type TSinchSelectMenuElement = HTMLElement & {
|
|
|
15
15
|
/** Allows multiple selection */
|
|
16
16
|
setAttribute(name: 'multiple', value: ''): void;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
18
|
+
export type TSinchSelectMenuReact = TSinchElementReact<TSinchSelectMenuElement> & {
|
|
19
19
|
/** Selected value, CSV when multiple */
|
|
20
20
|
value: string;
|
|
21
21
|
/** How many rows to show and scroll the rest */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '../icons/check';
|
|
2
2
|
import '../text';
|
|
3
3
|
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
4
|
-
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;position:relative;box-sizing:border-box;height:40px;padding:8px 16px;align-items:center;gap:10px;user-select:none;cursor:pointer;color:var(--sinch-color-text-default);--sinch-color-icon:var(--sinch-color-stormy-500);--sinch-size-icon:24px}#content{flex:1}
|
|
4
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;position:relative;box-sizing:border-box;height:40px;padding:8px 16px;align-items:center;gap:10px;user-select:none;cursor:pointer;color:var(--sinch-color-text-default);--sinch-color-icon:var(--sinch-color-stormy-500);--sinch-size-icon:24px}#content{flex:1}#check{display:none;margin-right:-6px}:host([data-checked]) #check{display:block}:host([disabled])>#wrapper{cursor:initial;color:var(--sinch-color-text-disabled);--sinch-color-icon:var(--sinch-color-stormy-100)}:host(:hover:not([disabled]))>#wrapper,:host([data-selected])>#wrapper{background-color:var(--sinch-color-snow-400)}::slotted(*){margin-left:-6px}</style><div id="wrapper"><slot name="icon"></slot><sinch-text id="content" type="m" ellipsis></sinch-text><sinch-icon-check id="check"></sinch-icon-check></div>';
|
|
5
5
|
const template = document.createElement('template');
|
|
6
6
|
template.innerHTML = templateHTML;
|
|
7
7
|
export class SelectMenuOption extends NectaryElement {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export
|
|
2
|
+
export type TSinchSelectMenuOptionElement = HTMLElement & {
|
|
3
3
|
/** Value */
|
|
4
4
|
value: string;
|
|
5
5
|
/** Display text */
|
|
@@ -14,7 +14,7 @@ export declare type TSinchSelectMenuOptionElement = HTMLElement & {
|
|
|
14
14
|
/** Disabled state */
|
|
15
15
|
setAttribute(name: 'disabled', value: ''): void;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type TSinchSelectMenuOptionReact = TSinchElementReact<TSinchSelectMenuOptionElement> & {
|
|
18
18
|
/** Value */
|
|
19
19
|
value: string;
|
|
20
20
|
/** Display text */
|
package/spinner/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
2
|
import type { TSinchSize } from '../utils/size';
|
|
3
|
-
export
|
|
3
|
+
export type TSinchSpinnerElement = HTMLElement & {
|
|
4
4
|
size: TSinchSize;
|
|
5
5
|
setAttribute(name: 'size', value: TSinchSize): void;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type TSinchSpinnerReact = TSinchElementReact<TSinchSpinnerElement> & {
|
|
8
8
|
size?: TSinchSize;
|
|
9
9
|
};
|
package/table/types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type TSinchTableElement = HTMLElement;
|
|
3
|
+
export type TSinchTableReact = TSinchElementReact<TSinchTableElement>;
|
package/table-body/types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type TSinchTableBodyElement = HTMLElement;
|
|
3
|
+
export type TSinchTableBodyReact = TSinchElementReact<TSinchTableBodyElement>;
|
package/table-cell/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type TSinchTableAlignType = 'start' | 'center' | 'end';
|
|
3
|
+
export type TSinchTableCellElement = HTMLElement & {
|
|
4
4
|
align: TSinchTableAlignType;
|
|
5
5
|
setAttribute(name: 'align', value: TSinchTableAlignType): void;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type TSinchTableCellReact = TSinchElementReact<TSinchTableCellElement> & {
|
|
8
8
|
align?: TSinchTableAlignType;
|
|
9
9
|
};
|
package/table-head/types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type TSinchTableHeadElement = HTMLElement;
|
|
3
|
+
export type TSinchTableHeadReact = TSinchElementReact<TSinchTableHeadElement>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TSinchTableAlignType } from '../table-cell/types';
|
|
2
2
|
import type { TSinchElementReact } from '../types';
|
|
3
|
-
export
|
|
3
|
+
export type TSinchTableHeaderCellElement = HTMLElement & {
|
|
4
4
|
text: string | null;
|
|
5
5
|
align: TSinchTableAlignType;
|
|
6
6
|
fit: boolean;
|
|
@@ -8,7 +8,7 @@ export declare type TSinchTableHeaderCellElement = HTMLElement & {
|
|
|
8
8
|
setAttribute(name: 'align', value: TSinchTableAlignType): void;
|
|
9
9
|
setAttribute(name: 'fit', value: ''): void;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type TSinchTableHeaderCellReact = TSinchElementReact<TSinchTableHeaderCellElement> & {
|
|
12
12
|
text?: string;
|
|
13
13
|
fit?: boolean;
|
|
14
14
|
align?: TSinchTableAlignType;
|
package/table-row/types.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export
|
|
2
|
+
export type TSinchTableRowElement = HTMLElement & {
|
|
3
3
|
sticky: boolean;
|
|
4
4
|
selected: boolean;
|
|
5
5
|
setAttribute(name: 'sticky', value: ''): void;
|
|
6
6
|
setAttribute(name: 'selected', value: ''): void;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type TSinchTableRowReact = TSinchElementReact<TSinchTableRowElement> & {
|
|
9
9
|
sticky?: boolean;
|
|
10
10
|
selected?: boolean;
|
|
11
11
|
};
|