@nectary/components 0.29.1 → 0.30.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.
Files changed (113) hide show
  1. package/accordion-item/types.d.ts +1 -2
  2. package/accordion-item/utils.d.ts +2 -1
  3. package/alert/index.js +1 -1
  4. package/alert/types.d.ts +1 -2
  5. package/alert/utils.d.ts +2 -1
  6. package/alert-button/index.js +1 -1
  7. package/avatar/types.d.ts +2 -3
  8. package/avatar/utils.d.ts +3 -2
  9. package/avatar-status/index.js +1 -3
  10. package/avatar-status/types.d.ts +1 -2
  11. package/avatar-status/utils.d.ts +1 -1
  12. package/button/index.js +1 -1
  13. package/button/types.d.ts +1 -2
  14. package/button/utils.d.ts +2 -1
  15. package/card/index.js +1 -1
  16. package/card-container/index.js +1 -1
  17. package/chat-bubble/types.d.ts +2 -3
  18. package/chat-bubble/utils.d.ts +3 -2
  19. package/checkbox/index.js +1 -1
  20. package/colors.json +6 -1
  21. package/date-picker/index.d.ts +19 -0
  22. package/date-picker/index.js +419 -0
  23. package/date-picker/types.d.ts +26 -0
  24. package/date-picker/types.js +1 -0
  25. package/date-picker/utils.d.ts +32 -0
  26. package/date-picker/utils.js +142 -0
  27. package/dialog/index.js +23 -5
  28. package/dropdown-checkbox-option/index.js +1 -1
  29. package/icon-button/index.js +1 -1
  30. package/icons/create-icon-class.d.ts +1 -307
  31. package/icons/keyboard-double-arrow-left/index.d.ts +11 -0
  32. package/icons/keyboard-double-arrow-left/index.js +4 -0
  33. package/icons/keyboard-double-arrow-right/index.d.ts +11 -0
  34. package/icons/keyboard-double-arrow-right/index.js +4 -0
  35. package/icons-branded/chat/index.d.ts +11 -0
  36. package/icons-branded/chat/index.js +4 -0
  37. package/icons-branded/create-icon-class.d.ts +1 -311
  38. package/icons-branded/mms/index.d.ts +11 -0
  39. package/icons-branded/mms/index.js +4 -0
  40. package/icons-branded/push/index.d.ts +11 -0
  41. package/icons-branded/push/index.js +4 -0
  42. package/icons-branded/rcs/index.d.ts +11 -0
  43. package/icons-branded/rcs/index.js +4 -0
  44. package/icons-branded/sms/index.d.ts +11 -0
  45. package/icons-branded/sms/index.js +4 -0
  46. package/icons-channel/apple-business-chat-square/index.d.ts +11 -0
  47. package/icons-channel/apple-business-chat-square/index.js +4 -0
  48. package/icons-channel/create-icon-class.d.ts +1 -310
  49. package/icons-channel/create-icon-class.js +1 -1
  50. package/icons-channel/facebook-messenger-square/index.d.ts +11 -0
  51. package/icons-channel/facebook-messenger-square/index.js +4 -0
  52. package/icons-channel/instagram-square/index.d.ts +11 -0
  53. package/icons-channel/instagram-square/index.js +4 -0
  54. package/icons-channel/line-square/index.d.ts +11 -0
  55. package/icons-channel/line-square/index.js +4 -0
  56. package/icons-channel/talk-square/index.d.ts +11 -0
  57. package/icons-channel/talk-square/index.js +4 -0
  58. package/icons-channel/telegram-square/index.d.ts +11 -0
  59. package/icons-channel/telegram-square/index.js +4 -0
  60. package/icons-channel/twitter-square/index.d.ts +11 -0
  61. package/icons-channel/twitter-square/index.js +4 -0
  62. package/icons-channel/viber-square/index.d.ts +11 -0
  63. package/icons-channel/viber-square/index.js +4 -0
  64. package/icons-channel/wechat-square/index.d.ts +11 -0
  65. package/icons-channel/wechat-square/index.js +4 -0
  66. package/icons-channel/whatsapp-square/index.d.ts +11 -0
  67. package/icons-channel/whatsapp-square/index.js +4 -0
  68. package/illustration/create-illustration-class.d.ts +1 -310
  69. package/illustration/create-illustration-class.js +20 -3
  70. package/illustration/phone-and-cat/index.js +1 -1
  71. package/illustration/types.d.ts +8 -0
  72. package/illustration/utils.d.ts +3 -0
  73. package/illustration/utils.js +2 -0
  74. package/input/index.js +1 -1
  75. package/input/types.d.ts +4 -5
  76. package/input/utils.d.ts +2 -1
  77. package/link/index.js +18 -4
  78. package/link/types.d.ts +0 -2
  79. package/logo/create-logo-class.d.ts +1 -311
  80. package/package.json +1 -1
  81. package/popover/index.js +76 -47
  82. package/popover/types.d.ts +1 -2
  83. package/popover/utils.d.ts +2 -1
  84. package/search/index.js +1 -1
  85. package/segment/index.d.ts +1 -0
  86. package/segment/index.js +109 -6
  87. package/segment/types.d.ts +4 -0
  88. package/segment/utils.d.ts +5 -0
  89. package/segment/utils.js +6 -0
  90. package/select/index.js +1 -1
  91. package/spinner/types.d.ts +1 -2
  92. package/spinner/utils.d.ts +2 -1
  93. package/table-cell/types.d.ts +4 -5
  94. package/table-cell/utils.d.ts +2 -1
  95. package/table-head-cell/types.d.ts +4 -4
  96. package/tag/index.js +1 -1
  97. package/tag/types.d.ts +1 -2
  98. package/tag/utils.d.ts +2 -1
  99. package/text/index.js +0 -1
  100. package/text/types.d.ts +1 -2
  101. package/text/utils.d.ts +1 -1
  102. package/textarea/index.js +1 -1
  103. package/theme.css +17 -0
  104. package/title/index.js +0 -2
  105. package/title/types.d.ts +2 -3
  106. package/title/utils.d.ts +4 -3
  107. package/title/utils.js +21 -0
  108. package/toggle/index.js +1 -1
  109. package/tooltip/index.js +1 -1
  110. package/tooltip/types.d.ts +1 -2
  111. package/tooltip/utils.d.ts +2 -1
  112. package/utils.d.ts +4 -0
  113. package/utils.js +35 -4
package/segment/index.js CHANGED
@@ -1,17 +1,20 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$caption, _$collapseSlot;
4
+ var _$caption, _$previewSlot, _$previewWrapper, _$infoSlot, _$infoWrapper, _$collapseSlot, _$collapseWrapper, _onPreviewSlotChange, _onInfoSlotChange, _onCollapseSlotChange;
5
5
 
6
6
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
7
 
8
8
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
9
 
10
- import { defineCustomElement, getAttribute, getBooleanAttribute, getRect, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
11
- const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;width:100%;height:100%;border-radius:4px;box-sizing:border-box;background-color:var(--sinch-color-snow-100);color:var(--sinch-color-text-default);font:var(--sinch-font-body);border:none;box-shadow:1px 2px 8px rgba(0,0,0,.1)}#header{position:relative;display:flex;flex-direction:row;align-items:center;gap:16px;height:32px;padding:24px 32px 16px;--sinch-size-icon:32px}#caption{font:var(--sinch-font-title-l);color:var(--sinch-color-text-default);flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#content-wrapper{padding:0 32px;flex:1;min-height:0;overflow:auto}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;padding:16px 32px 24px}#info{position:relative;display:flex;flex-direction:row;align-items:center;gap:16px;z-index:1}:host([collapsed]:not([collapsed=false])) :is(#content-wrapper,#action){display:none}:host([collapsed]:not([collapsed=false])) #header{padding-bottom:24px}</style><div id="wrapper"><div id="header"><slot name="icon"></slot><span id="caption"></span><div id="info"><slot name="info"></slot></div><slot name="collapse"></slot></div><div id="content-wrapper"><slot name="content"></slot></div><div id="action"><slot name="action"></slot></div></div>';
10
+ import '../title';
11
+ import { getTitleLevelFromType } from '../title/utils';
12
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getRect, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
13
+ const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;gap:16px;width:100%;height:100%;border:1px solid var(--sinch-color-snow-700);border-radius:var(--sinch-shape-radius-l);box-sizing:border-box;background-color:var(--sinch-color-snow-100);color:var(--sinch-color-text-default);font:var(--sinch-font-body);box-shadow:var(--sinch-elevation-level-2);padding:8px 24px 16px;overflow:hidden}#header{display:flex;flex-direction:row;align-items:center;height:48px;gap:8px;--sinch-size-icon:32px}#caption{font:var(--sinch-font-title-l);color:var(--sinch-color-text-default);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:1em}#info{display:flex;flex-direction:row;align-items:center;gap:8px;margin-left:auto;align-self:stretch}#info.empty{display:none}#preview{flex:1;flex-basis:auto;height:48px;min-width:0;overflow:hidden;margin-left:24px}#preview.empty{display:none}#preview:not(.empty)+#info.empty+#collapse:not(.empty),#preview:not(.empty)+#info:not(.empty){margin-left:24px}#collapse.empty{display:none}#content-wrapper{flex:1;min-height:0;overflow-y:auto}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px}:host([collapsed]:not([collapsed=false])) :is(#content-wrapper,#action){display:none}:host([collapsed]:not([collapsed=false])) #wrapper{padding-bottom:8px}::slotted([slot=icon]){margin-right:8px}</style><div id="wrapper"><div id="header"><slot name="icon"></slot><sinch-title id="caption" level="3" type="m"></sinch-title><div id="preview"><slot name="preview"></slot></div><div id="info"><slot name="info"></slot></div><div id="collapse"><slot name="collapse"></slot></div></div><div id="content-wrapper"><slot name="content"></slot></div><div id="action"><slot name="action"></slot></div></div>';
14
+ import { assertSize, sizeValues } from './utils';
12
15
  const template = document.createElement('template');
13
16
  template.innerHTML = templateHTML;
14
- defineCustomElement('sinch-segment', (_$caption = new WeakMap(), _$collapseSlot = new WeakMap(), class extends NectaryElement {
17
+ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), _$previewSlot = new WeakMap(), _$previewWrapper = new WeakMap(), _$infoSlot = new WeakMap(), _$infoWrapper = new WeakMap(), _$collapseSlot = new WeakMap(), _$collapseWrapper = new WeakMap(), _onPreviewSlotChange = new WeakMap(), _onInfoSlotChange = new WeakMap(), _onCollapseSlotChange = new WeakMap(), class extends NectaryElement {
15
18
  constructor() {
16
19
  super();
17
20
 
@@ -20,28 +23,120 @@ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), _$collapseSlot
20
23
  value: void 0
21
24
  });
22
25
 
26
+ _classPrivateFieldInitSpec(this, _$previewSlot, {
27
+ writable: true,
28
+ value: void 0
29
+ });
30
+
31
+ _classPrivateFieldInitSpec(this, _$previewWrapper, {
32
+ writable: true,
33
+ value: void 0
34
+ });
35
+
36
+ _classPrivateFieldInitSpec(this, _$infoSlot, {
37
+ writable: true,
38
+ value: void 0
39
+ });
40
+
41
+ _classPrivateFieldInitSpec(this, _$infoWrapper, {
42
+ writable: true,
43
+ value: void 0
44
+ });
45
+
23
46
  _classPrivateFieldInitSpec(this, _$collapseSlot, {
24
47
  writable: true,
25
48
  value: void 0
26
49
  });
27
50
 
51
+ _classPrivateFieldInitSpec(this, _$collapseWrapper, {
52
+ writable: true,
53
+ value: void 0
54
+ });
55
+
56
+ _classPrivateFieldInitSpec(this, _onPreviewSlotChange, {
57
+ writable: true,
58
+ value: () => {
59
+ setClass(_classPrivateFieldGet(this, _$previewWrapper), 'empty', _classPrivateFieldGet(this, _$previewSlot).assignedElements().length === 0);
60
+ }
61
+ });
62
+
63
+ _classPrivateFieldInitSpec(this, _onInfoSlotChange, {
64
+ writable: true,
65
+ value: () => {
66
+ setClass(_classPrivateFieldGet(this, _$infoWrapper), 'empty', _classPrivateFieldGet(this, _$infoSlot).assignedElements().length === 0);
67
+ }
68
+ });
69
+
70
+ _classPrivateFieldInitSpec(this, _onCollapseSlotChange, {
71
+ writable: true,
72
+ value: () => {
73
+ setClass(_classPrivateFieldGet(this, _$collapseWrapper), 'empty', _classPrivateFieldGet(this, _$collapseSlot).assignedElements().length === 0);
74
+ }
75
+ });
76
+
28
77
  const shadowRoot = this.attachShadow();
29
78
  shadowRoot.appendChild(template.content.cloneNode(true));
30
79
 
31
80
  _classPrivateFieldSet(this, _$caption, shadowRoot.querySelector('#caption'));
32
81
 
82
+ _classPrivateFieldSet(this, _$previewSlot, shadowRoot.querySelector('slot[name="preview"]'));
83
+
84
+ _classPrivateFieldSet(this, _$infoSlot, shadowRoot.querySelector('slot[name="info"]'));
85
+
33
86
  _classPrivateFieldSet(this, _$collapseSlot, shadowRoot.querySelector('slot[name="collapse"]'));
87
+
88
+ _classPrivateFieldSet(this, _$previewWrapper, shadowRoot.querySelector('#preview'));
89
+
90
+ _classPrivateFieldSet(this, _$infoWrapper, shadowRoot.querySelector('#info'));
91
+
92
+ _classPrivateFieldSet(this, _$collapseWrapper, shadowRoot.querySelector('#collapse'));
93
+ }
94
+
95
+ connectedCallback() {
96
+ _classPrivateFieldGet(this, _$previewSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onPreviewSlotChange));
97
+
98
+ _classPrivateFieldGet(this, _$infoSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onInfoSlotChange));
99
+
100
+ _classPrivateFieldGet(this, _$collapseSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onCollapseSlotChange));
101
+
102
+ _classPrivateFieldGet(this, _onPreviewSlotChange).call(this);
103
+
104
+ _classPrivateFieldGet(this, _onInfoSlotChange).call(this);
105
+
106
+ _classPrivateFieldGet(this, _onCollapseSlotChange).call(this);
107
+ }
108
+
109
+ disconnectedCallback() {
110
+ _classPrivateFieldGet(this, _$previewSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onPreviewSlotChange));
111
+
112
+ _classPrivateFieldGet(this, _$infoSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onInfoSlotChange));
113
+
114
+ _classPrivateFieldGet(this, _$collapseSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onCollapseSlotChange));
34
115
  }
35
116
 
36
117
  static get observedAttributes() {
37
- return ['caption'];
118
+ return ['caption', 'collapsed', 'size'];
38
119
  }
39
120
 
40
121
  attributeChangedCallback(name, _, newVal) {
41
122
  switch (name) {
42
123
  case 'caption':
43
124
  {
44
- _classPrivateFieldGet(this, _$caption).textContent = newVal;
125
+ updateAttribute(_classPrivateFieldGet(this, _$caption), 'text', newVal);
126
+ break;
127
+ }
128
+
129
+ case 'collapsed':
130
+ {
131
+ updateBooleanAttribute(this, 'collapsed', isAttrTrue(newVal));
132
+ break;
133
+ }
134
+
135
+ case 'size':
136
+ {
137
+ assertSize(newVal);
138
+ updateAttribute(_classPrivateFieldGet(this, _$caption), 'type', newVal);
139
+ updateAttribute(_classPrivateFieldGet(this, _$caption), 'level', getTitleLevelFromType(newVal));
45
140
  break;
46
141
  }
47
142
  }
@@ -63,6 +158,14 @@ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), _$collapseSlot
63
158
  return getBooleanAttribute(this, 'collapsed');
64
159
  }
65
160
 
161
+ get size() {
162
+ return getLiteralAttribute(this, sizeValues, 'size', 'm');
163
+ }
164
+
165
+ set size(value) {
166
+ updateLiteralAttribute(this, sizeValues, 'size', value);
167
+ }
168
+
66
169
  get collapseButtonRect() {
67
170
  const $collapseButton = _classPrivateFieldGet(this, _$collapseSlot).assignedElements()[0];
68
171
 
@@ -1,12 +1,16 @@
1
1
  import type { TRect, TSinchElementReact } from '../types';
2
+ export declare type TSinchSegmentSize = 'l' | 'm' | 's';
2
3
  export declare type TSinchSegmentElement = HTMLElement & {
3
4
  caption: string;
4
5
  collapsed: boolean;
6
+ size: TSinchSegmentSize;
5
7
  readonly collapseButtonRect: TRect | null;
6
8
  setAttribute(name: 'caption', value: string): void;
7
9
  setAttribute(name: 'collapsed', value: ''): void;
10
+ setAttribute(name: 'size', value: TSinchSegmentSize): void;
8
11
  };
9
12
  export declare type TSinchSegmentReact = TSinchElementReact<TSinchSegmentElement> & {
10
13
  caption: string;
11
14
  collapsed?: boolean;
15
+ size?: TSinchSegmentSize;
12
16
  };
@@ -0,0 +1,5 @@
1
+ import type { TSinchSegmentSize } from './types';
2
+ export declare const sizeValues: readonly TSinchSegmentSize[];
3
+ declare type TAssertSize = (value: string | null) => asserts value is TSinchSegmentSize;
4
+ export declare const assertSize: TAssertSize;
5
+ export {};
@@ -0,0 +1,6 @@
1
+ export const sizeValues = ['l', 'm', 's'];
2
+ export const assertSize = value => {
3
+ if (value === null || !sizeValues.includes(value)) {
4
+ throw new Error(`sinch-segment: invalid size attribute: ${value}`);
5
+ }
6
+ };
package/select/index.js CHANGED
@@ -13,7 +13,7 @@ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(
13
13
 
14
14
  import '../dropdown';
15
15
  import { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateIntegerAttribute } from '../utils';
16
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{position:relative;--sinch-popover-expand-width:1}sinch-dropdown{display:block}#button{all:initial;display:flex;align-items:center;gap:8px;border:1px solid var(--sinch-color-stormy-200);border-radius:4px;box-sizing:border-box;width:100%;height:48px;margin:2px 0;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);cursor:pointer}#button:focus{border-color:var(--sinch-color-stormy-600)}#dropdown-icon{fill:var(--sinch-color-stormy-500)}#button>*{pointer-events:none}#button[data-unselected]{color:var(--sinch-color-text-muted)}#button:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100);cursor:initial}#button:disabled #dropdown-icon{fill:var(--sinch-color-stormy-100)}:host([invalidtext]:not([invalidtext=""])) #button:not(:disabled){border-color:var(--sinch-color-text-invalid)}#content{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#bottom,#top{display:flex;align-items:baseline}#top{height:24px}#bottom{height:20px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted)}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid)}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])){--sinch-color-icon:var(--sinch-color-stormy-100)}#listbox{position:absolute;left:0;top:0;padding-top:74px;width:100%;display:none;list-style:none;outline:0;z-index:1}#listbox-body{font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);border:1px solid var(--sinch-color-stormy-500);border-top-width:0;border-bottom-left-radius:2px;border-bottom-right-radius:2px;width:100%;box-sizing:border-box;box-shadow:1px 2px 4px rgba(0,0,0,.15);overflow-y:auto}#button[aria-expanded=true]~#listbox{display:block}</style><div id="wrapper"><div id="top"><label id="label" for="dropdown"></label><slot name="tooltip"></slot><span id="optional"></span></div><sinch-dropdown id="dropdown"><button slot="target" id="button"><span id="content"></span> <svg id="dropdown-icon" width="12" height="8" aria-hidden="true"><path d="M1.41.59 6 5.17 10.59.59 12 2 6 8 0 2 1.41.59Z"/></svg></button><slot name="option" slot="option"></slot></sinch-dropdown><div id="bottom"><span id="invalid"></span> <span id="additional"></span></div></div>';
16
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{position:relative;--sinch-popover-expand-width:1}sinch-dropdown{display:block}#button{all:initial;display:flex;align-items:center;gap:8px;border:1px solid var(--sinch-color-stormy-200);border-radius:var(--sinch-shape-radius-s);box-sizing:border-box;width:100%;height:48px;margin:2px 0;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);cursor:pointer}#button:focus{border-color:var(--sinch-color-stormy-600)}#dropdown-icon{fill:var(--sinch-color-stormy-500)}#button>*{pointer-events:none}#button[data-unselected]{color:var(--sinch-color-text-muted)}#button:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100);cursor:initial}#button:disabled #dropdown-icon{fill:var(--sinch-color-stormy-100)}:host([invalidtext]:not([invalidtext=""])) #button:not(:disabled){border-color:var(--sinch-color-text-invalid)}#content{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#bottom,#top{display:flex;align-items:baseline}#top{height:24px}#bottom{height:20px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted)}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid)}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])){--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="dropdown"></label><slot name="tooltip"></slot><span id="optional"></span></div><sinch-dropdown id="dropdown"><button slot="target" id="button"><span id="content"></span> <svg id="dropdown-icon" width="12" height="8" aria-hidden="true"><path d="M1.41.59 6 5.17 10.59.59 12 2 6 8 0 2 1.41.59Z"/></svg></button><slot name="option" slot="option"></slot></sinch-dropdown><div id="bottom"><span id="invalid"></span> <span id="additional"></span></div></div>';
17
17
  const template = document.createElement('template');
18
18
  template.innerHTML = templateHTML;
19
19
  defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _$dropdown = new WeakMap(), _$optionSlot = new WeakMap(), _$sh = new WeakMap(), _createElement = new WeakSet(), _updateButtonContent = new WeakSet(), _onValueChange = new WeakMap(), _getOptionWithValue = new WeakSet(), _onLabelClick = new WeakMap(), _onDropdownClick = new WeakMap(), _onDropdownClose = new WeakMap(), class extends NectaryElement {
@@ -1,6 +1,5 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- import type { spinnerTypes } from './utils';
3
- export declare type TSinchSpinnerType = typeof spinnerTypes[number];
2
+ export declare type TSinchSpinnerType = 'large' | 'medium' | 'small';
4
3
  export declare type TSinchSpinnerElement = HTMLElement & {
5
4
  type: TSinchSpinnerType;
6
5
  setAttribute(name: 'type', value: TSinchSpinnerType): void;
@@ -1 +1,2 @@
1
- export declare const spinnerTypes: readonly ["large", "medium", "small"];
1
+ import type { TSinchSpinnerType } from './types';
2
+ export declare const spinnerTypes: readonly TSinchSpinnerType[];
@@ -1,10 +1,9 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- import type { alignValues } from './utils';
3
- export declare type TAlignType = typeof alignValues[number];
2
+ export declare type TSinchTableAlignType = 'start' | 'center' | 'end';
4
3
  export declare type TSinchTableCellElement = HTMLElement & {
5
- align: TAlignType;
6
- setAttribute(name: 'align', value: TAlignType): void;
4
+ align: TSinchTableAlignType;
5
+ setAttribute(name: 'align', value: TSinchTableAlignType): void;
7
6
  };
8
7
  export declare type TSinchTableCellReact = TSinchElementReact<TSinchTableCellElement> & {
9
- align?: TAlignType;
8
+ align?: TSinchTableAlignType;
10
9
  };
@@ -1 +1,2 @@
1
- export declare const alignValues: readonly ["start", "center", "end"];
1
+ import type { TSinchTableAlignType } from './types';
2
+ export declare const alignValues: readonly TSinchTableAlignType[];
@@ -1,15 +1,15 @@
1
- import type { TAlignType } from '../table-cell/types';
1
+ import type { TSinchTableAlignType } from '../table-cell/types';
2
2
  import type { TSinchElementReact } from '../types';
3
3
  export declare type TSinchTableHeaderCellElement = HTMLElement & {
4
4
  text: string | null;
5
- align: TAlignType;
5
+ align: TSinchTableAlignType;
6
6
  fit: boolean;
7
7
  setAttribute(name: 'text', value: string): void;
8
- setAttribute(name: 'align', value: TAlignType): void;
8
+ setAttribute(name: 'align', value: TSinchTableAlignType): void;
9
9
  setAttribute(name: 'fit', value: ''): void;
10
10
  };
11
11
  export declare type TSinchTableHeaderCellReact = TSinchElementReact<TSinchTableHeaderCellElement> & {
12
12
  text?: string;
13
13
  fit?: boolean;
14
- align?: TAlignType;
14
+ align?: TSinchTableAlignType;
15
15
  };
package/tag/index.js CHANGED
@@ -9,7 +9,7 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
9
9
 
10
10
  import '../icons/cancel';
11
11
  import { defineCustomElement, getBooleanAttribute, getAttribute, getLiteralAttribute, updateBooleanAttribute, updateAttribute, updateLiteralAttribute, NectaryElement } from '../utils';
12
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{display:flex;flex-direction:row;align-items:center;gap:4px;position:relative;padding:2px 8px;border-radius:12px;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-600);width:100%;height:24px;box-sizing:border-box;--sinch-color-icon:var(--sinch-color-stormy-400);--sinch-size-icon:16px}:host([category=candy])>#wrapper{background-color:var(--sinch-color-candy-200)}:host([category=bolt])>#wrapper{background-color:var(--sinch-color-bolt-200)}:host([category=aqua])>#wrapper{background-color:var(--sinch-color-aqua-200)}:host([category=grass])>#wrapper{background-color:var(--sinch-color-grass-200)}:host([category=berry])>#wrapper{background-color:var(--sinch-color-berry-200)}:host([category=orange])>#wrapper{background-color:var(--sinch-color-orange-200)}:host([category=night])>#wrapper{background-color:var(--sinch-color-night-200)}:host([category=mud])>#wrapper{background-color:var(--sinch-color-mud-200)}:host([category=dirt])>#wrapper{background-color:var(--sinch-color-dirt-200)}:host([inverted]:not([inverted=false]))>#wrapper{background-color:var(--sinch-color-stormy-500);color:var(--sinch-color-snow-100);--sinch-color-icon:var(--sinch-color-snow-100)}:host([small]:not([small=false])) #wrapper{height:20px;border-radius:10px;padding:0 8px;--sinch-size-icon:14px}#text{text-overflow:ellipsis;white-space:nowrap;overflow:auto;flex:1}</style><div id="wrapper"><slot name="icon"></slot><span id="text"></span><slot name="close"></slot></div>';
12
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;gap:4px;width:100%;height:24px;padding:2px 8px;border-radius:12px;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-600);box-sizing:border-box;--sinch-color-icon:var(--sinch-color-stormy-400);--sinch-size-icon:16px}:host([category=candy])>#wrapper{background-color:var(--sinch-color-candy-200)}:host([category=bolt])>#wrapper{background-color:var(--sinch-color-bolt-200)}:host([category=aqua])>#wrapper{background-color:var(--sinch-color-aqua-200)}:host([category=grass])>#wrapper{background-color:var(--sinch-color-grass-200)}:host([category=berry])>#wrapper{background-color:var(--sinch-color-berry-200)}:host([category=orange])>#wrapper{background-color:var(--sinch-color-orange-200)}:host([category=night])>#wrapper{background-color:var(--sinch-color-night-200)}:host([category=mud])>#wrapper{background-color:var(--sinch-color-mud-200)}:host([category=dirt])>#wrapper{background-color:var(--sinch-color-dirt-200)}:host([inverted]:not([inverted=false]))>#wrapper{background-color:var(--sinch-color-stormy-500);color:var(--sinch-color-snow-100);--sinch-color-icon:var(--sinch-color-snow-100)}:host([small]:not([small=false])) #wrapper{height:20px;border-radius:10px;padding:0 8px;--sinch-size-icon:14px}#text{text-overflow:ellipsis;white-space:nowrap;overflow:auto;flex:1}</style><div id="wrapper"><slot name="icon"></slot><span id="text"></span><slot name="close"></slot></div>';
13
13
  import { categoryValues } from './utils';
14
14
  const template = document.createElement('template');
15
15
  template.innerHTML = templateHTML;
package/tag/types.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- import type { categoryValues } from './utils';
3
- export declare type TSinchTagCategory = typeof categoryValues[number];
2
+ export declare type TSinchTagCategory = 'candy' | 'bolt' | 'aqua' | 'grass' | 'berry' | 'orange' | 'night' | 'mud' | 'dirt';
4
3
  export declare type TSinchTagElement = HTMLElement & {
5
4
  category: TSinchTagCategory | null;
6
5
  text: string;
package/tag/utils.d.ts CHANGED
@@ -1 +1,2 @@
1
- export declare const categoryValues: readonly ["candy", "bolt", "aqua", "grass", "berry", "orange", "night", "mud", "dirt"];
1
+ import type { TSinchTagCategory } from './types';
2
+ export declare const categoryValues: readonly TSinchTagCategory[];
package/text/index.js CHANGED
@@ -15,7 +15,6 @@ defineCustomElement('sinch-text', class extends NectaryElement {
15
15
 
16
16
  connectedCallback() {
17
17
  this.setAttribute('role', getBooleanAttribute(this, 'inline') ? 'text' : 'paragraph');
18
- assertType(this.getAttribute('type'));
19
18
  }
20
19
 
21
20
  get type() {
package/text/types.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- import type { typeValues } from './utils';
3
- export declare type TSinchTextType = typeof typeValues[number];
2
+ export declare type TSinchTextType = 'm' | 's' | 'xs' | 'xxs';
4
3
  export declare type TSinchTextElement = HTMLElement & {
5
4
  type: TSinchTextType;
6
5
  inline: boolean;
package/text/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { TSinchTextType } from './types';
2
- export declare const typeValues: readonly ["m", "s", "xs", "xxs"];
2
+ export declare const typeValues: readonly TSinchTextType[];
3
3
  declare type TAssertType = (value: string | null) => asserts value is TSinchTextType;
4
4
  export declare const assertType: TAssertType;
5
5
  export {};
package/textarea/index.js CHANGED
@@ -8,7 +8,7 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
8
8
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
9
 
10
10
  import { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
11
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{width:100%;box-sizing:border-box}#input{all:initial;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:4px;width:100%;margin:2px 0;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto);background-color:var(--sinch-color-snow-100);resize:none}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#input:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100)}#input:disabled::placeholder{color:var(--sinch-color-snow-500)}#input:focus{border-color:var(--sinch-color-stormy-600)}:host([resizable]:not([resizable=false])) #input{resize:vertical}:host([invalidtext]:not([invalidtext=""])) #input:not(:disabled){border-color:var(--sinch-color-text-invalid)}#bottom,#top{display:flex;align-items:baseline}#top{height:24px}#bottom{height:20px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted)}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid)}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])){--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><slot name="tooltip"></slot><span id="optional"></span></div><textarea id="input"></textarea><div id="bottom"><span id="invalid"></span> <span id="additional"></span></div></div>';
11
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{width:100%;box-sizing:border-box}#input{all:initial;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:var(--sinch-shape-radius-s);width:100%;margin:2px 0;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto);background-color:var(--sinch-color-snow-100);resize:none}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#input:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100)}#input:disabled::placeholder{color:var(--sinch-color-snow-500)}#input:focus{border-color:var(--sinch-color-stormy-600)}:host([resizable]:not([resizable=false])) #input{resize:vertical}:host([invalidtext]:not([invalidtext=""])) #input:not(:disabled){border-color:var(--sinch-color-text-invalid)}#bottom,#top{display:flex;align-items:baseline}#top{height:24px}#bottom{height:20px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted)}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid)}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])){--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><slot name="tooltip"></slot><span id="optional"></span></div><textarea id="input"></textarea><div id="bottom"><span id="invalid"></span> <span id="additional"></span></div></div>';
12
12
  const template = document.createElement('template');
13
13
  template.innerHTML = templateHTML;
14
14
  defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _selectionStart = new WeakMap(), _selectionEnd = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onInput = new WeakMap(), class extends NectaryElement {
package/theme.css CHANGED
@@ -72,6 +72,11 @@
72
72
  --sinch-color-orange-200: #FFD4B3;
73
73
  --sinch-color-bolt-400: #FFBE3C;
74
74
  --sinch-color-bolt-200: #FFE6B3;
75
+ --sinch-color-background-grey: #FAFAFA;
76
+ --sinch-color-background-green: #DCEDE1;
77
+ --sinch-color-background-blue: #DEF2FF;
78
+ --sinch-color-background-yellow: #FCECCB;
79
+ --sinch-color-background-white: #FFFFFF;
75
80
  --sinch-color-transparent: transparent;
76
81
 
77
82
  /* Typography */
@@ -87,6 +92,18 @@
87
92
  --sinch-font-text-xs: 400 12px/20px var(--sinch-font-family);
88
93
  --sinch-font-text-xxs: 400 10px/16px var(--sinch-font-family);
89
94
 
95
+ /* Shapes */
96
+ --sinch-shape-radius-xs: 2px;
97
+ --sinch-shape-radius-s: 4px;
98
+ --sinch-shape-radius-m: 8px;
99
+ --sinch-shape-radius-l: 12px;
100
+
101
+ /* Elevation */
102
+ --sinch-elevation-level-0: 0 0 0 0 rgba(10, 39, 61, 0.1);
103
+ --sinch-elevation-level-1: 1px 2px 6px rgba(10, 39, 61, 0.1);
104
+ --sinch-elevation-level-2: 1px 4px 8px rgba(10, 39, 61, 0.1);
105
+ --sinch-elevation-level-3: 1px 6px 12px rgba(10, 39, 61, 0.15);
106
+
90
107
  /* Deprecated */
91
108
  --sinch-font-hero: 700 56px/72px var(--sinch-font-family);
92
109
  --sinch-font-body: 400 16px/24px var(--sinch-font-family);
package/title/index.js CHANGED
@@ -30,8 +30,6 @@ defineCustomElement('sinch-title', (_$text = new WeakMap(), class extends Nectar
30
30
 
31
31
  connectedCallback() {
32
32
  this.setAttribute('role', 'heading');
33
- assertLevel(this.getAttribute('level'));
34
- assertType(this.getAttribute('type'));
35
33
  }
36
34
 
37
35
  get text() {
package/title/types.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- import type { levelValues, typeValues } from './utils';
3
- export declare type TSinchTitleType = typeof typeValues[number];
4
- export declare type TSinchTitleLevel = typeof levelValues[number];
2
+ export declare type TSinchTitleType = 'xl' | 'l' | 'm' | 's' | 'xs';
3
+ export declare type TSinchTitleLevel = '1' | '2' | '3' | '4' | '5' | '6';
5
4
  export declare type TSinchTitleElement = HTMLElement & {
6
5
  text: string;
7
6
  type: TSinchTitleType;
package/title/utils.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import type { TSinchTitleLevel, TSinchTitleType } from './types';
2
- export declare const typeValues: readonly ["xl", "l", "m", "s", "xs"];
3
- export declare const levelValues: readonly ["1", "2", "3", "4", "5", "6"];
2
+ export declare const typeValues: readonly TSinchTitleType[];
3
+ export declare const levelValues: readonly TSinchTitleLevel[];
4
4
  declare type TAssertLevel = (value: string | null) => asserts value is TSinchTitleLevel;
5
- declare type TAssertType = (value: string | null) => asserts value is TSinchTitleType;
6
5
  export declare const assertLevel: TAssertLevel;
6
+ declare type TAssertType = (value: string | null) => asserts value is TSinchTitleType;
7
7
  export declare const assertType: TAssertType;
8
+ export declare const getTitleLevelFromType: (type: TSinchTitleType) => TSinchTitleLevel;
8
9
  export {};
package/title/utils.js CHANGED
@@ -9,4 +9,25 @@ export const assertType = value => {
9
9
  if (value === null || !typeValues.includes(value)) {
10
10
  throw new Error(`sinch-title: invalid type attribute: ${value}`);
11
11
  }
12
+ };
13
+ export const getTitleLevelFromType = type => {
14
+ switch (type) {
15
+ case 'xl':
16
+ return '1';
17
+
18
+ case 'l':
19
+ return '2';
20
+
21
+ case 'm':
22
+ return '3';
23
+
24
+ case 's':
25
+ return '4';
26
+
27
+ case 'xs':
28
+ return '5';
29
+
30
+ default:
31
+ throw new Error(`sinch-title: invalid type value: ${type}`);
32
+ }
12
33
  };
package/toggle/index.js CHANGED
@@ -8,7 +8,7 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
8
8
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
9
 
10
10
  import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
11
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{display:flex;flex-direction:row;box-sizing:border-box;width:100%;height:32px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);text-align:initial}:host([small]:not([small=false])) #wrapper{font:var(--sinch-font-small-text)}#checkbox{all:initial;display:block;position:absolute;left:0;top:0;width:40px;height:20px;cursor:pointer;pointer-events:initial}#checkbox:disabled{cursor:initial}#knob-container{position:relative;box-sizing:border-box;align-self:center;width:40px;height:20px;border-radius:10px;pointer-events:none;padding:2px;background-color:var(--sinch-color-stormy-100);overflow:hidden}:host([checked]:not([checked=false])) #knob-container{background-color:var(--sinch-color-tropical-500)}:host([small]:not([small=false])) #knob-container{width:32px;height:16px;border-radius:8px}#knob{position:relative;box-sizing:border-box;width:16px;height:16px;border-radius:50%;background-color:var(--sinch-color-snow-100);transform:translateX(0);transition:transform .1s ease-in-out}:host([checked]:not([checked=false])) #knob{transform:translateX(20px)}:host([small]:not([small=false])) #knob{width:12px;height:12px}:host([small]:not([small=false])[checked]:not([checked=false])) #knob{transform:translateX(16px)}#knob::after,#knob::before{color:var(--sinch-color-snow-100);text-transform:uppercase;font-size:8px;line-height:16px;display:none;position:absolute;top:0;padding:0 3px}#knob::before{content:"on";right:100%}#knob::after{content:"off";left:100%}:host([labeled]:not([labeled=false]):is(:not([small]),[small=false])) #knob::after,:host([labeled]:not([labeled=false]):is(:not([small]),[small=false])) #knob::before{display:block}@media (prefers-reduced-motion){#knob{transition:none}}#label{display:none;flex:1;align-self:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;padding-left:8px}:host([text]:not([text=""])) #label{display:block}:host([disabled]:not([disabled=false])) #label{color:var(--sinch-color-stormy-200)}:host([disabled]:not([disabled=false])) #knob-container{background-color:var(--sinch-color-snow-700)}:host([checked]:not([checked=false])[disabled]:not([disabled=false])) #knob-container{background-color:var(--sinch-color-tropical-100)}</style><div id="wrapper"><div id="knob-container"><div id="knob"></div><input id="checkbox" type="checkbox"></div><label for="checkbox" id="label"></label></div>';
11
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{display:flex;flex-direction:row;box-sizing:border-box;width:100%;height:32px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);text-align:initial}:host([small]:not([small=false])) #wrapper{font:var(--sinch-font-small-text)}#checkbox{all:initial;display:block;position:absolute;left:0;top:0;width:40px;height:20px;cursor:pointer;pointer-events:initial}#checkbox:disabled{cursor:initial}#knob-container{position:relative;box-sizing:border-box;align-self:center;width:40px;height:20px;border-radius:10px;pointer-events:none;padding:2px;background-color:var(--sinch-color-stormy-100);box-shadow:var(--sinch-elevation-level-1);overflow:hidden}:host([checked]:not([checked=false])) #knob-container{background-color:var(--sinch-color-tropical-500)}:host([small]:not([small=false])) #knob-container{width:32px;height:16px;border-radius:8px}#knob{position:relative;box-sizing:border-box;width:16px;height:16px;border-radius:50%;background-color:var(--sinch-color-snow-100);transform:translateX(0);transition:transform .1s ease-in-out}:host([checked]:not([checked=false])) #knob{transform:translateX(20px)}:host([small]:not([small=false])) #knob{width:12px;height:12px}:host([small]:not([small=false])[checked]:not([checked=false])) #knob{transform:translateX(16px)}#knob::after,#knob::before{color:var(--sinch-color-snow-100);text-transform:uppercase;font-size:8px;line-height:16px;display:none;position:absolute;top:0;padding:0 3px}#knob::before{content:"on";right:100%}#knob::after{content:"off";left:100%}:host([labeled]:not([labeled=false]):is(:not([small]),[small=false])) #knob::after,:host([labeled]:not([labeled=false]):is(:not([small]),[small=false])) #knob::before{display:block}@media (prefers-reduced-motion){#knob{transition:none}}#label{display:none;flex:1;align-self:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;padding-left:8px}:host([text]:not([text=""])) #label{display:block}:host([disabled]:not([disabled=false])) #label{color:var(--sinch-color-stormy-200)}:host([disabled]:not([disabled=false])) #knob-container{background-color:var(--sinch-color-snow-700)}:host([checked]:not([checked=false])[disabled]:not([disabled=false])) #knob-container{background-color:var(--sinch-color-tropical-100)}</style><div id="wrapper"><div id="knob-container"><div id="knob"></div><input id="checkbox" type="checkbox"></div><label for="checkbox" id="label"></label></div>';
12
12
  const template = document.createElement('template');
13
13
  template.innerHTML = templateHTML;
14
14
  defineCustomElement('sinch-toggle', (_$input = new WeakMap(), _$label = new WeakMap(), _onInput = new WeakMap(), class extends NectaryElement {
package/tooltip/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { attrValueToPixels, defineCustomElement, getBooleanAttribute, getIntegerAttribute, getAttribute, getLiteralAttribute, updateBooleanAttribute, updateAttribute, updateLiteralAttribute, getRect, NectaryElement } from '../utils';
2
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#wrapper{position:relative;display:block}#tooltip{position:absolute;left:0;top:0;width:100%;height:100%;pointer-events:none;opacity:0;transition:opacity .2s linear .2s}@media (prefers-reduced-motion){#tooltip{transition:none}}:host(:hover) #tooltip{opacity:1}#text{position:absolute;padding:2px 6px;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-600);width:max-content;border-radius:2px;top:-8px;left:50%;transform:translateX(-50%) translateY(-100%)}#arrow{position:absolute;top:-8px;left:50%;transform:translateX(-50%);fill:var(--sinch-color-snow-600)}:host([orientation=top-left]) #text{transform:translateX(-80%) translateY(-100%)}:host([orientation=top-right]) #text{transform:translateX(-20%) translateY(-100%)}:host([orientation=bottom-right]) #text{top:calc(100% + 8px);transform:translateX(-20%)}:host([orientation=bottom-left]) #text{top:calc(100% + 8px);transform:translateX(-80%)}:host([orientation=bottom]) #text{top:calc(100% + 8px);transform:translateX(-50%)}:host([orientation^=bottom]) #arrow{top:calc(100% + 4px);transform:translateX(-50%) rotate(180deg)}:host([orientation=left]) #text{left:unset;right:calc(100% + 8px);top:50%;transform:translateY(-50%)}:host([orientation=left]) #arrow{left:-11px;top:50%;transform:translateY(-50%) rotate(270deg)}:host([orientation=right]) #text{left:calc(100% + 8px);top:50%;transform:translateY(-50%)}:host([orientation=right]) #arrow{top:50%;left:calc(100% + 2px);transform:translateY(-50%) rotate(90deg)}:host([inverted]:not([inverted=false])) #text{color:var(--sinch-color-text-inverted);background-color:var(--sinch-color-stormy-500)}:host([inverted]:not([inverted=false])) #arrow{fill:var(--sinch-color-stormy-500)}::slotted(*){display:block}</style><div id="wrapper"><slot></slot><div id="tooltip"><div id="text"></div><svg id="arrow" width="9" height="4" aria-hidden="true"><path d="m4.5 4 4-4h-8l4 4Z"/></svg></div></div>';
2
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#wrapper{position:relative;display:block}#tooltip{position:absolute;left:0;top:0;width:100%;height:100%;pointer-events:none;opacity:0;transition:opacity .2s linear .2s}@media (prefers-reduced-motion){#tooltip{transition:none}}:host(:hover) #tooltip{opacity:1}#text{position:absolute;padding:2px 6px;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-600);width:max-content;border-radius:var(--sinch-shape-radius-xs);top:-8px;left:50%;transform:translateX(-50%) translateY(-100%);word-break:break-word}#arrow{position:absolute;top:-8px;left:50%;transform:translateX(-50%);fill:var(--sinch-color-snow-600)}:host([orientation=top-left]) #text{transform:translateX(-80%) translateY(-100%)}:host([orientation=top-right]) #text{transform:translateX(-20%) translateY(-100%)}:host([orientation=bottom-right]) #text{top:calc(100% + 8px);transform:translateX(-20%)}:host([orientation=bottom-left]) #text{top:calc(100% + 8px);transform:translateX(-80%)}:host([orientation=bottom]) #text{top:calc(100% + 8px);transform:translateX(-50%)}:host([orientation^=bottom]) #arrow{top:calc(100% + 4px);transform:translateX(-50%) rotate(180deg)}:host([orientation=left]) #text{left:unset;right:calc(100% + 8px);top:50%;transform:translateY(-50%)}:host([orientation=left]) #arrow{left:-11px;top:50%;transform:translateY(-50%) rotate(270deg)}:host([orientation=right]) #text{left:calc(100% + 8px);top:50%;transform:translateY(-50%)}:host([orientation=right]) #arrow{top:50%;left:calc(100% + 2px);transform:translateY(-50%) rotate(90deg)}:host([inverted]:not([inverted=false])) #text{color:var(--sinch-color-text-inverted);background-color:var(--sinch-color-stormy-500)}:host([inverted]:not([inverted=false])) #arrow{fill:var(--sinch-color-stormy-500)}::slotted(*){display:block}</style><div id="wrapper"><slot></slot><div id="tooltip"><div id="text"></div><svg id="arrow" width="9" height="4" aria-hidden="true"><path d="m4.5 4 4-4h-8l4 4Z"/></svg></div></div>';
3
3
  import { orientationValues } from './utils';
4
4
  const template = document.createElement('template');
5
5
  template.innerHTML = templateHTML;
@@ -1,6 +1,5 @@
1
1
  import type { TRect, TSinchElementReact } from '../types';
2
- import type { orientationValues } from './utils';
3
- export declare type TSinchTooltipOrientation = typeof orientationValues[number];
2
+ export declare type TSinchTooltipOrientation = 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
4
3
  export declare type TSinchTooltipElement = HTMLElement & {
5
4
  text: string;
6
5
  width: number | null;
@@ -1 +1,2 @@
1
- export declare const orientationValues: readonly ["top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right"];
1
+ import type { TSinchTooltipOrientation } from './types';
2
+ export declare const orientationValues: readonly TSinchTooltipOrientation[];
package/utils.d.ts CHANGED
@@ -41,4 +41,8 @@ export declare const getFirstCsvValue: (acc: string) => string | null;
41
41
  export declare const getRect: (el: Element) => TRect;
42
42
  export declare const setClass: (elem: Element, name: string, isSet: boolean) => void;
43
43
  export declare const getCssVar: (element: Element, variableName: string) => string | null;
44
+ export declare const throttleAnimationFrame: (cb: (...args: any[]) => void) => {
45
+ fn: (...args: any[]) => void;
46
+ cancel: () => void;
47
+ };
44
48
  export {};
package/utils.js CHANGED
@@ -56,13 +56,13 @@ export const getBooleanAttribute = ($element, attrName) => {
56
56
  return isAttrTrue($element.getAttribute(attrName));
57
57
  };
58
58
  export const updateBooleanAttribute = ($element, attrName, attrValue) => {
59
- const isCurrentValueTrue = getBooleanAttribute($element, attrName);
59
+ const currentAttrValue = $element.getAttribute(attrName);
60
60
 
61
61
  if (attrValue === true) {
62
- if (!isCurrentValueTrue) {
62
+ if (!isAttrTrue(currentAttrValue)) {
63
63
  $element.setAttribute(attrName, '');
64
64
  }
65
- } else if (isCurrentValueTrue) {
65
+ } else if (currentAttrValue !== null) {
66
66
  $element.removeAttribute(attrName);
67
67
  }
68
68
  };
@@ -202,4 +202,35 @@ export const setClass = (elem, name, isSet) => {
202
202
  export const getCssVar = (element, variableName) => {
203
203
  const result = getComputedStyle(element).getPropertyValue(variableName);
204
204
  return result === '' ? null : result;
205
- };
205
+ };
206
+
207
+ const throttle = (delayFn, cancelFn) => cb => {
208
+ let id = null;
209
+ let fnArgs;
210
+
211
+ const delayCallback = () => {
212
+ id = null;
213
+ cb(fnArgs);
214
+ };
215
+
216
+ return {
217
+ fn: function () {
218
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
219
+ args[_key] = arguments[_key];
220
+ }
221
+
222
+ fnArgs = args;
223
+
224
+ if (id === null) {
225
+ id = delayFn(delayCallback);
226
+ }
227
+ },
228
+ cancel: () => {
229
+ if (id !== null) {
230
+ cancelFn(id);
231
+ }
232
+ }
233
+ };
234
+ };
235
+
236
+ export const throttleAnimationFrame = throttle(global.requestAnimationFrame, global.cancelAnimationFrame);