@nectary/components 0.40.0 → 0.41.1

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.
Files changed (74) hide show
  1. package/accordion-item/index.js +4 -0
  2. package/action-menu/index.js +11 -13
  3. package/action-menu-option/index.js +2 -1
  4. package/button/index.js +5 -1
  5. package/button/types.d.ts +1 -1
  6. package/checkbox/index.js +4 -0
  7. package/chip/index.js +18 -15
  8. package/chip/types.d.ts +3 -4
  9. package/color-menu/index.d.ts +1 -0
  10. package/color-menu/index.js +37 -51
  11. package/color-menu/types.d.ts +5 -6
  12. package/color-menu/utils.d.ts +1 -0
  13. package/color-menu/utils.js +15 -0
  14. package/color-swatch/index.js +8 -7
  15. package/color-swatch/types.d.ts +3 -4
  16. package/colors.json +14 -10
  17. package/date-picker/index.js +1 -1
  18. package/field/index.js +22 -5
  19. package/file-drop/index.js +1 -1
  20. package/file-picker/index.js +1 -1
  21. package/help-tooltip/index.js +10 -27
  22. package/icon-button/index.d.ts +1 -0
  23. package/icon-button/index.js +26 -15
  24. package/icon-button/types.d.ts +16 -2
  25. package/input/index.js +4 -0
  26. package/link/index.js +5 -1
  27. package/package.json +1 -1
  28. package/pagination/index.js +4 -0
  29. package/pop/index.d.ts +11 -0
  30. package/pop/index.js +429 -0
  31. package/pop/types.d.ts +35 -0
  32. package/pop/utils.d.ts +7 -0
  33. package/pop/utils.js +18 -0
  34. package/popover/index.d.ts +1 -0
  35. package/popover/index.js +91 -230
  36. package/popover/types.d.ts +8 -1
  37. package/popover/utils.d.ts +5 -0
  38. package/popover/utils.js +17 -1
  39. package/radio-option/index.js +4 -0
  40. package/segment-collapse/index.js +4 -0
  41. package/segmented-control-option/index.js +5 -1
  42. package/segmented-icon-control-option/index.js +5 -1
  43. package/select-button/index.js +6 -1
  44. package/select-menu/index.js +12 -13
  45. package/tabs-option/index.js +4 -0
  46. package/tag/index.js +13 -15
  47. package/tag/types.d.ts +3 -4
  48. package/textarea/index.js +4 -0
  49. package/theme.css +76 -10
  50. package/tile-control-option/index.js +5 -1
  51. package/time-picker/index.js +1 -1
  52. package/toggle/index.js +5 -1
  53. package/tooltip/index.d.ts +2 -0
  54. package/tooltip/index.js +160 -17
  55. package/tooltip/types.d.ts +13 -0
  56. package/tooltip/utils.d.ts +5 -0
  57. package/tooltip/utils.js +25 -1
  58. package/types.d.ts +0 -7
  59. package/utils/animation.d.ts +17 -0
  60. package/utils/animation.js +142 -0
  61. package/utils/colors.d.ts +4 -9
  62. package/utils/colors.js +4 -120
  63. package/utils/context.d.ts +15 -0
  64. package/utils/context.js +57 -0
  65. package/utils/index.d.ts +5 -9
  66. package/utils/index.js +49 -50
  67. package/dropdown-checkbox-option/index.d.ts +0 -11
  68. package/dropdown-checkbox-option/index.js +0 -74
  69. package/dropdown-checkbox-option/types.d.ts +0 -15
  70. package/dropdown-radio-option/index.d.ts +0 -11
  71. package/dropdown-radio-option/index.js +0 -74
  72. package/dropdown-radio-option/types.d.ts +0 -15
  73. package/dropdown-radio-option/types.js +0 -1
  74. /package/{dropdown-checkbox-option → pop}/types.js +0 -0
@@ -0,0 +1,142 @@
1
+ export class TooltipState {
2
+ #timerId = null;
3
+ #state = 'initial';
4
+ #options;
5
+
6
+ constructor(options) {
7
+ this.#options = options;
8
+ }
9
+
10
+ show() {
11
+ switch (this.#state) {
12
+ case 'initial':
13
+ {
14
+ this.#delayShow();
15
+ break;
16
+ }
17
+
18
+ case 'hide-delay':
19
+ {
20
+ this.#cancelStateChange('show');
21
+ break;
22
+ }
23
+
24
+ case 'hide':
25
+ {
26
+ this.#cancelStateChange();
27
+ this.#onShow();
28
+ break;
29
+ }
30
+ }
31
+ }
32
+
33
+ hide() {
34
+ switch (this.#state) {
35
+ case 'show-delay':
36
+ {
37
+ this.#cancelStateChange('initial');
38
+ break;
39
+ }
40
+
41
+ case 'show':
42
+ {
43
+ this.#delayHide();
44
+ break;
45
+ }
46
+ }
47
+ }
48
+
49
+ interrupt() {
50
+ switch (this.#state) {
51
+ case 'show-delay':
52
+ {
53
+ this.#cancelStateChange('initial');
54
+ break;
55
+ }
56
+
57
+ case 'show':
58
+ {
59
+ this.#onHideStart();
60
+ break;
61
+ }
62
+
63
+ case 'hide-delay':
64
+ {
65
+ this.#cancelStateChange();
66
+ this.#onHideStart();
67
+ break;
68
+ }
69
+ }
70
+ }
71
+
72
+ destroy() {
73
+ switch (this.#state) {
74
+ case 'show-delay':
75
+ {
76
+ this.#cancelStateChange('initial');
77
+ break;
78
+ }
79
+
80
+ case 'show':
81
+ {
82
+ this.#onHideStart(true);
83
+ break;
84
+ }
85
+
86
+ case 'hide-delay':
87
+ {
88
+ this.#cancelStateChange();
89
+ this.#onHideStart(true);
90
+ break;
91
+ }
92
+
93
+ case 'hide':
94
+ {
95
+ this.#cancelStateChange();
96
+ this.#onHideEnd();
97
+ break;
98
+ }
99
+ }
100
+ }
101
+
102
+ #delayShow() {
103
+ this.#state = 'show-delay';
104
+ this.#timerId = window.setTimeout(this.#onShow, this.#options.showDelay);
105
+ }
106
+
107
+ #delayHide() {
108
+ this.#state = 'hide-delay';
109
+ this.#timerId = window.setTimeout(this.#onHideStart, this.#options.hideDelay);
110
+ }
111
+
112
+ #onShow = () => {
113
+ this.#state = 'show';
114
+ this.#options.onShow();
115
+ };
116
+ #onHideStart = isImmediate => {
117
+ this.#state = 'hide';
118
+ this.#options.onHideStart();
119
+
120
+ if (isImmediate === true || this.#options.hideAnimationDuration === 0) {
121
+ this.#onHideEnd();
122
+ } else {
123
+ this.#timerId = window.setTimeout(this.#onHideEnd, this.#options.hideAnimationDuration);
124
+ }
125
+ };
126
+ #onHideEnd = () => {
127
+ this.#state = 'initial';
128
+ this.#options.onHideEnd();
129
+ };
130
+
131
+ #cancelStateChange(nextState) {
132
+ if (nextState != null) {
133
+ this.#state = nextState;
134
+ }
135
+
136
+ if (this.#timerId !== null) {
137
+ clearTimeout(this.#timerId);
138
+ this.#timerId = null;
139
+ }
140
+ }
141
+
142
+ }
package/utils/colors.d.ts CHANGED
@@ -1,10 +1,5 @@
1
1
  export declare const NO_COLOR: "";
2
- export declare type TSinchColorName = typeof NO_COLOR | 'Blue 10' | 'Blue 20' | 'Blue 30' | 'Blue 40' | 'Blue 50' | 'Green 10' | 'Green 20' | 'Green 30' | 'Yellow 20' | 'Yellow 10' | 'Orange 10' | 'Orange 30' | 'Orange 20' | 'Coral 10' | 'Pink 10' | 'Pink 20' | 'Brown 10' | 'Brown 20' | 'Gray 10' | 'Gray 20' | 'Red 10' | 'Skin tone 0' | 'Skin tone 10' | 'Skin tone 20' | 'Skin tone 30' | 'Skin tone 40' | 'Skin tone 50';
3
- export declare const colorNameValues: readonly TSinchColorName[];
4
- declare type TAssertColorName = (value: string | null) => asserts value is TSinchColorName;
5
- export declare const assertColorNameValue: TAssertColorName;
6
- export declare const colorMap: Record<TSinchColorName, {
7
- value: string;
8
- isInverted: boolean;
9
- }>;
10
- export {};
2
+ export declare const lightColorNames: string;
3
+ export declare const darkColorNames: string;
4
+ export declare const vibrantColorNames: string;
5
+ export declare const skinToneColorNames: string;
package/utils/colors.js CHANGED
@@ -1,121 +1,5 @@
1
1
  export const NO_COLOR = '';
2
- export const colorNameValues = [NO_COLOR, 'Blue 10', 'Blue 20', 'Blue 30', 'Blue 40', 'Blue 50', 'Green 10', 'Green 20', 'Green 30', 'Yellow 10', 'Yellow 20', 'Orange 10', 'Orange 20', 'Orange 30', 'Pink 10', 'Pink 20', 'Brown 10', 'Brown 20', 'Gray 10', 'Gray 20', 'Coral 10', 'Red 10', 'Skin tone 0', 'Skin tone 10', 'Skin tone 20', 'Skin tone 30', 'Skin tone 40', 'Skin tone 50'];
3
- export const assertColorNameValue = value => {
4
- if (value === null || !colorNameValues.includes(value)) {
5
- throw new Error(`Invalid color name: "${value}"`);
6
- }
7
- };
8
- export const colorMap = {
9
- [NO_COLOR]: {
10
- value: NO_COLOR,
11
- isInverted: false
12
- },
13
- 'Blue 50': {
14
- value: 'night-400',
15
- isInverted: true
16
- },
17
- 'Blue 40': {
18
- value: 'aqua-400',
19
- isInverted: false
20
- },
21
- 'Blue 30': {
22
- value: 'aqua-200',
23
- isInverted: false
24
- },
25
- 'Blue 20': {
26
- value: 'night-200',
27
- isInverted: false
28
- },
29
- 'Blue 10': {
30
- value: 'informative-200',
31
- isInverted: false
32
- },
33
- 'Green 30': {
34
- value: 'grass-400',
35
- isInverted: false
36
- },
37
- 'Green 20': {
38
- value: 'grass-200',
39
- isInverted: false
40
- },
41
- 'Green 10': {
42
- value: 'success-200',
43
- isInverted: false
44
- },
45
- 'Yellow 20': {
46
- value: 'bolt-400',
47
- isInverted: false
48
- },
49
- 'Yellow 10': {
50
- value: 'bolt-200',
51
- isInverted: false
52
- },
53
- 'Orange 30': {
54
- value: 'orange-400',
55
- isInverted: false
56
- },
57
- 'Orange 20': {
58
- value: 'orange-200',
59
- isInverted: false
60
- },
61
- 'Orange 10': {
62
- value: 'warning-200',
63
- isInverted: false
64
- },
65
- 'Pink 20': {
66
- value: 'candy-400',
67
- isInverted: false
68
- },
69
- 'Pink 10': {
70
- value: 'candy-200',
71
- isInverted: false
72
- },
73
- 'Brown 20': {
74
- value: 'mud-400',
75
- isInverted: true
76
- },
77
- 'Brown 10': {
78
- value: 'mud-200',
79
- isInverted: false
80
- },
81
- 'Gray 20': {
82
- value: 'dirt-400',
83
- isInverted: false
84
- },
85
- 'Gray 10': {
86
- value: 'dirt-200',
87
- isInverted: false
88
- },
89
- 'Coral 10': {
90
- value: 'berry-200',
91
- isInverted: false
92
- },
93
- 'Red 10': {
94
- value: 'error-200',
95
- isInverted: false
96
- },
97
- 'Skin tone 0': {
98
- value: 'skin-tone-10',
99
- isInverted: false
100
- },
101
- 'Skin tone 10': {
102
- value: 'skin-tone-20',
103
- isInverted: false
104
- },
105
- 'Skin tone 20': {
106
- value: 'skin-tone-30',
107
- isInverted: false
108
- },
109
- 'Skin tone 30': {
110
- value: 'skin-tone-40',
111
- isInverted: false
112
- },
113
- 'Skin tone 40': {
114
- value: 'skin-tone-50',
115
- isInverted: false
116
- },
117
- 'Skin tone 50': {
118
- value: 'skin-tone-60',
119
- isInverted: true
120
- }
121
- };
2
+ export const lightColorNames = ['light-violet', 'light-blue', 'light-green', 'light-yellow', 'light-orange', 'light-pink', 'light-brown', 'light-gray'].join(',');
3
+ export const darkColorNames = ['dark-violet', 'dark-blue', 'dark-green', 'dark-yellow', 'dark-orange', 'dark-pink', 'dark-brown', 'dark-gray'].join(',');
4
+ export const vibrantColorNames = ['violet', 'blue', 'green', 'yellow', 'orange', 'pink', 'brown', 'gray'].join(',');
5
+ export const skinToneColorNames = ['skin-tone-0', 'skin-tone-10', 'skin-tone-20', 'skin-tone-30', 'skin-tone-40', 'skin-tone-50'].join(',');
@@ -0,0 +1,15 @@
1
+ export declare type TContextName = 'visibility' | 'keydown';
2
+ export declare type TContextKeyboard = {
3
+ code: string;
4
+ preventDefault: () => void;
5
+ };
6
+ export declare type TContextVisibility = boolean;
7
+ export declare class Context {
8
+ #private;
9
+ constructor($element: Element, name: TContextName);
10
+ get elements(): Iterable<Element>;
11
+ subscribe(): void;
12
+ unsubscribe(): void;
13
+ }
14
+ export declare const dispatchContextConnectEvent: (el: Element, name: TContextName) => void;
15
+ export declare const dispatchContextDisconnectEvent: (el: Element, name: TContextName) => void;
@@ -0,0 +1,57 @@
1
+ export class Context {
2
+ #$root;
3
+ #listeners = new Set();
4
+ #name;
5
+ #isSubscribed = false;
6
+
7
+ constructor($element, name) {
8
+ this.#$root = $element;
9
+ this.#name = name;
10
+ }
11
+
12
+ get elements() {
13
+ return this.#listeners;
14
+ }
15
+
16
+ subscribe() {
17
+ if (this.#isSubscribed) {
18
+ return;
19
+ }
20
+
21
+ this.#$root.addEventListener(`-context-connect-${this.#name}`, this.#onConnect);
22
+ this.#$root.addEventListener(`-context-disconnect-${this.#name}`, this.#onDisconnect);
23
+ this.#isSubscribed = true;
24
+ }
25
+
26
+ unsubscribe() {
27
+ this.#listeners.clear();
28
+ this.#$root.removeEventListener(`-context-connect-${this.#name}`, this.#onConnect);
29
+ this.#$root.removeEventListener(`-context-disconnect-${this.#name}`, this.#onDisconnect);
30
+ this.#isSubscribed = false;
31
+ }
32
+
33
+ #onConnect = e => {
34
+ e.stopPropagation();
35
+ this.#listeners.add(e.detail);
36
+ };
37
+ #onDisconnect = e => {
38
+ e.stopPropagation();
39
+ this.#listeners.delete(e.detail);
40
+ };
41
+ }
42
+ export const dispatchContextConnectEvent = (el, name) => {
43
+ requestAnimationFrame(() => {
44
+ el.dispatchEvent(new CustomEvent(`-context-connect-${name}`, {
45
+ bubbles: true,
46
+ composed: true,
47
+ detail: el
48
+ }));
49
+ });
50
+ };
51
+ export const dispatchContextDisconnectEvent = (el, name) => {
52
+ el.dispatchEvent(new CustomEvent(`-context-disconnect-${name}`, {
53
+ bubbles: true,
54
+ composed: true,
55
+ detail: el
56
+ }));
57
+ };
package/utils/index.d.ts CHANGED
@@ -8,7 +8,8 @@ declare global {
8
8
  }
9
9
  export declare class NectaryElement extends HTMLElement {
10
10
  attachShadow(options?: Partial<ShadowRootInit>): ShadowRoot;
11
- __version: string;
11
+ version: string;
12
+ get focusable(): boolean;
12
13
  }
13
14
  export declare const getReactEventHandler: ($element: HTMLElement, handlerName: string) => ((arg?: any) => void) | null;
14
15
  export declare const updateExplicitBooleanAttribute: ($element: Element, attrName: string, attrValue: boolean | null | undefined) => void;
@@ -47,14 +48,9 @@ export declare const throttleAnimationFrame: (cb: (...args: any[]) => void) => {
47
48
  fn: (...args: any[]) => void;
48
49
  cancel: () => void;
49
50
  };
50
- export declare const getFirstSlotElement: (root: HTMLSlotElement) => HTMLElement | null;
51
+ export declare const getFirstSlotElement: (root: HTMLSlotElement, isDeep?: boolean) => HTMLElement | null;
52
+ export declare const getFirstFocusableElement: (root: Element) => NectaryElement | null;
51
53
  export declare const cloneNode: (el: Element, deep: boolean) => Element;
52
54
  export declare const isElementFocused: ($el: Element | null) => boolean;
53
- export declare class Context {
54
- #private;
55
- constructor($element: Element, name: string);
56
- get elements(): Iterable<Element>;
57
- subscribe(): void;
58
- unsubscribe(): void;
59
- }
55
+ export declare const rectOverlap: (targetRect: TRect, contentRect: TRect) => boolean;
60
56
  export {};
package/utils/index.js CHANGED
@@ -37,7 +37,12 @@ export class NectaryElement extends HTMLElement {
37
37
  });
38
38
  }
39
39
 
40
- __version = pkg.version;
40
+ version = pkg.version;
41
+
42
+ get focusable() {
43
+ return false;
44
+ }
45
+
41
46
  }
42
47
  export const getReactEventHandler = ($element, handlerName) => {
43
48
  for (const key in $element) {
@@ -260,22 +265,52 @@ const throttle = (delayFn, cancelFn) => cb => {
260
265
  };
261
266
 
262
267
  export const throttleAnimationFrame = throttle(global.requestAnimationFrame, global.cancelAnimationFrame);
263
- export const getFirstSlotElement = root => {
264
- let slot = root;
265
268
 
266
- while (true) {
267
- const el = slot.assignedElements()[0];
269
+ const isSlotElement = el => {
270
+ return el.tagName === 'SLOT';
271
+ };
268
272
 
269
- if (el == null) {
270
- return null;
271
- }
273
+ export const getFirstSlotElement = function (root) {
274
+ let isDeep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
275
+ const el = root.assignedElements()[0];
276
+
277
+ if (el == null) {
278
+ return null;
279
+ }
280
+
281
+ if (isDeep && isSlotElement(el)) {
282
+ return getFirstSlotElement(el, isDeep);
283
+ }
284
+
285
+ return el;
286
+ };
287
+
288
+ const getChildren = root => {
289
+ if (isSlotElement(root)) {
290
+ return root.assignedElements();
291
+ }
292
+
293
+ return Array.from(root.children);
294
+ };
295
+
296
+ const isFocusable = el => {
297
+ return el.focusable === true;
298
+ };
272
299
 
273
- if (el.tagName !== 'SLOT') {
274
- return el;
300
+ export const getFirstFocusableElement = root => {
301
+ for (const child of getChildren(root)) {
302
+ if (isFocusable(child)) {
303
+ return child;
275
304
  }
276
305
 
277
- slot = el;
306
+ const resultEl = getFirstFocusableElement(child);
307
+
308
+ if (resultEl !== null) {
309
+ return resultEl;
310
+ }
278
311
  }
312
+
313
+ return null;
279
314
  };
280
315
  export const cloneNode = (el, deep) => {
281
316
  const root = el.getRootNode();
@@ -302,42 +337,6 @@ export const cloneNode = (el, deep) => {
302
337
  export const isElementFocused = $el => {
303
338
  return $el !== null && $el === $el.getRootNode().activeElement;
304
339
  };
305
- export class Context {
306
- #$root;
307
- #listeners = new Set();
308
- #name;
309
- #isSubscribed = false;
310
-
311
- constructor($element, name) {
312
- this.#$root = $element;
313
- this.#name = name;
314
- }
315
-
316
- get elements() {
317
- return this.#listeners;
318
- }
319
-
320
- subscribe() {
321
- if (this.#isSubscribed) {
322
- return;
323
- }
324
-
325
- this.#$root.addEventListener(`-context-connect-${this.#name}`, this.#onConnect);
326
- this.#$root.addEventListener(`-context-disconnect-${this.#name}`, this.#onDisconnect);
327
- this.#isSubscribed = true;
328
- }
329
-
330
- unsubscribe() {
331
- this.#listeners.clear();
332
- this.#$root.removeEventListener(`-context-connect-${this.#name}`, this.#onConnect);
333
- this.#$root.removeEventListener(`-context-disconnect-${this.#name}`, this.#onDisconnect);
334
- this.#isSubscribed = false;
335
- }
336
-
337
- #onConnect = e => {
338
- this.#listeners.add(e.target);
339
- };
340
- #onDisconnect = e => {
341
- this.#listeners.delete(e.target);
342
- };
343
- }
340
+ export const rectOverlap = (targetRect, contentRect) => {
341
+ 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;
342
+ };
@@ -1,11 +0,0 @@
1
- import type { TSinchDropdownCheckboxOptionElement, TSinchDropdownCheckboxOptionReact } from './types';
2
- declare global {
3
- namespace JSX {
4
- interface IntrinsicElements {
5
- 'sinch-dropdown-checkbox-option': TSinchDropdownCheckboxOptionReact;
6
- }
7
- }
8
- interface HTMLElementTagNameMap {
9
- 'sinch-dropdown-checkbox-option': TSinchDropdownCheckboxOptionElement;
10
- }
11
- }
@@ -1,74 +0,0 @@
1
- import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
2
- const templateHTML = '<style>:host{display:block}#wrapper{display:flex;position:relative;box-sizing:border-box;height:40px;padding:4px 10px 4px 6px;align-items:center;gap:6px;user-select:none;cursor:pointer}#text{flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#icon-container{position:relative;width:32px;height:32px}#icon-container::before{content:"";position:absolute;top:7px;left:7px;width:18px;height:18px;border-radius:var(--sinch-shape-radius-xs);pointer-events:none;background-color:var(--sinch-color-snow-100);border:2px solid var(--sinch-color-stormy-300);transition:background-color .1s linear;box-sizing:border-box}#icon-checkmark{position:absolute;left:9px;top:10px;transition:opacity .1s linear;opacity:0;pointer-events:none;fill:var(--sinch-color-snow-100)}:host([data-checked]) #icon-container::before{background-color:var(--sinch-color-tropical-500);border-color:var(--sinch-color-tropical-500)}:host([data-checked]) #icon-checkmark{opacity:1}:host(:hover)>#wrapper,:host([data-selected])>#wrapper{background-color:var(--sinch-color-snow-500)}:host([disabled]:not([disabled=false]))>#wrapper{color:var(--sinch-color-stormy-100);cursor:initial}:host([disabled]:not([disabled=false])) #icon-container::before{border-color:var(--sinch-color-stormy-100)}@media (prefers-reduced-motion){#icon-checkmark,#icon-container::before{transition:none}}</style><div id="wrapper"><div id="icon-container"><svg id="icon-checkmark" width="14" height="11" aria-hidden="true"><path d="M14 1.99999L12.59 0.579987L4.98995 8.17L1.49997 4.5L0.0799694 5.91L4.98995 11L14 1.99999Z"/></svg></div><span id="text"></span></div>';
3
- const template = document.createElement('template');
4
- template.innerHTML = templateHTML;
5
- defineCustomElement('sinch-dropdown-checkbox-option', class extends NectaryElement {
6
- #$text;
7
-
8
- constructor() {
9
- super();
10
- const shadowRoot = this.attachShadow();
11
- shadowRoot.appendChild(template.content.cloneNode(true));
12
- this.#$text = shadowRoot.querySelector('#text');
13
- }
14
-
15
- connectedCallback() {
16
- this.setAttribute('role', 'option');
17
- }
18
-
19
- static get observedAttributes() {
20
- return ['text', 'checked'];
21
- }
22
-
23
- attributeChangedCallback(name, oldVal, newVal) {
24
- if (oldVal === newVal) {
25
- return;
26
- }
27
-
28
- switch (name) {
29
- case 'text':
30
- {
31
- this.#$text.textContent = newVal;
32
- break;
33
- }
34
-
35
- case 'checked':
36
- {
37
- updateExplicitBooleanAttribute(this, 'aria-selected', isAttrTrue(newVal));
38
- }
39
- }
40
- }
41
-
42
- set value(value) {
43
- updateAttribute(this, 'value', value);
44
- }
45
-
46
- get value() {
47
- return getAttribute(this, 'value', '');
48
- }
49
-
50
- set text(value) {
51
- updateAttribute(this, 'text', value);
52
- }
53
-
54
- get text() {
55
- return getAttribute(this, 'text', '');
56
- }
57
-
58
- set disabled(isDisabled) {
59
- updateBooleanAttribute(this, 'disabled', isDisabled);
60
- }
61
-
62
- get disabled() {
63
- return getBooleanAttribute(this, 'disabled');
64
- }
65
-
66
- set checked(isChecked) {
67
- updateBooleanAttribute(this, 'checked', isChecked);
68
- }
69
-
70
- get checked() {
71
- return getBooleanAttribute(this, 'checked');
72
- }
73
-
74
- });
@@ -1,15 +0,0 @@
1
- import type { TSinchElementReact } from '../types';
2
- export declare type TSinchDropdownCheckboxOptionElement = HTMLElement & {
3
- value: string;
4
- text: string;
5
- disabled: boolean;
6
- setAttribute(name: 'value', value: string): void;
7
- setAttribute(name: 'text', value: string): void;
8
- setAttribute(name: 'disabled', value: ''): void;
9
- };
10
- export declare type TSinchDropdownCheckboxOptionReact = TSinchElementReact<TSinchDropdownCheckboxOptionElement> & {
11
- value: string;
12
- text: string;
13
- disabled?: boolean;
14
- 'aria-label': string;
15
- };
@@ -1,11 +0,0 @@
1
- import type { TSinchDropdownRadioOptionElement, TSinchDropdownRadioOptionReact } from './types';
2
- declare global {
3
- namespace JSX {
4
- interface IntrinsicElements {
5
- 'sinch-dropdown-radio-option': TSinchDropdownRadioOptionReact;
6
- }
7
- }
8
- interface HTMLElementTagNameMap {
9
- 'sinch-dropdown-radio-option': TSinchDropdownRadioOptionElement;
10
- }
11
- }