@nectary/components 0.37.0 → 0.39.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 (83) hide show
  1. package/accordion/types.d.ts +1 -0
  2. package/alert/index.js +1 -1
  3. package/card/index.d.ts +2 -0
  4. package/card/index.js +6 -31
  5. package/date-picker/index.js +42 -2
  6. package/date-picker/types.d.ts +25 -1
  7. package/dialog/index.d.ts +1 -0
  8. package/dialog/index.js +3 -2
  9. package/dropdown/types.d.ts +2 -0
  10. package/file-drop/index.d.ts +13 -0
  11. package/file-drop/index.js +320 -0
  12. package/file-drop/types.d.ts +50 -0
  13. package/file-drop/utils.d.ts +2 -0
  14. package/file-drop/utils.js +37 -0
  15. package/file-picker/index.d.ts +12 -0
  16. package/file-picker/index.js +170 -0
  17. package/file-picker/types.d.ts +32 -0
  18. package/file-picker/utils.d.ts +1 -0
  19. package/file-picker/utils.js +9 -0
  20. package/file-status/index.d.ts +17 -0
  21. package/file-status/index.js +100 -0
  22. package/file-status/types.d.ts +18 -0
  23. package/file-status/utils.d.ts +5 -0
  24. package/file-status/utils.js +6 -0
  25. package/icons-branded/easytouse/index.d.ts +11 -0
  26. package/icons-branded/easytouse/index.js +4 -0
  27. package/inline-alert/index.js +1 -1
  28. package/inline-alert/types.d.ts +2 -2
  29. package/package.json +1 -1
  30. package/pagination/types.d.ts +1 -0
  31. package/progress/index.d.ts +17 -0
  32. package/progress/index.js +87 -0
  33. package/progress/types.d.ts +12 -0
  34. package/radio/types.d.ts +1 -0
  35. package/segment/index.js +1 -1
  36. package/segment-collapse/types.d.ts +1 -0
  37. package/segmented-control/types.d.ts +1 -0
  38. package/segmented-icon-control/types.d.ts +1 -0
  39. package/select/types.d.ts +1 -1
  40. package/spinner/index.js +1 -1
  41. package/tabs/types.d.ts +1 -0
  42. package/tag/index.d.ts +1 -0
  43. package/tag/index.js +10 -3
  44. package/tag/utils.d.ts +3 -0
  45. package/tag/utils.js +6 -1
  46. package/tag-close/index.js +5 -1
  47. package/tag-close/types.d.ts +3 -1
  48. package/text/index.js +9 -1
  49. package/text/types.d.ts +3 -0
  50. package/time-picker/index.js +9 -1
  51. package/time-picker/types.d.ts +5 -1
  52. package/title/index.js +10 -2
  53. package/title/types.d.ts +3 -0
  54. package/toast/index.d.ts +17 -0
  55. package/toast/index.js +153 -0
  56. package/toast/types.d.ts +28 -0
  57. package/toast/types.js +1 -0
  58. package/toast/utils.d.ts +5 -0
  59. package/toast/utils.js +6 -0
  60. package/toast-manager/index.d.ts +17 -0
  61. package/toast-manager/index.js +271 -0
  62. package/toast-manager/types.d.ts +7 -0
  63. package/toast-manager/types.js +1 -0
  64. package/toggle/index.js +3 -4
  65. package/toggle/types.d.ts +1 -0
  66. package/utils.d.ts +2 -0
  67. package/utils.js +40 -1
  68. package/card-button/index.d.ts +0 -11
  69. package/card-button/index.js +0 -77
  70. package/card-button/types.d.ts +0 -12
  71. package/card-link/index.d.ts +0 -12
  72. package/card-link/index.js +0 -115
  73. package/card-link/types.d.ts +0 -14
  74. package/search/index.d.ts +0 -14
  75. package/search/index.js +0 -523
  76. package/search/types.d.ts +0 -25
  77. package/search-option/index.d.ts +0 -11
  78. package/search-option/index.js +0 -55
  79. package/search-option/types.d.ts +0 -9
  80. /package/{card-button → file-drop}/types.js +0 -0
  81. /package/{card-link → file-picker}/types.js +0 -0
  82. /package/{search-option → file-status}/types.js +0 -0
  83. /package/{search → progress}/types.js +0 -0
@@ -0,0 +1,12 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ export declare type TSinchProgressElement = HTMLElement & {
3
+ value: number;
4
+ detailed: boolean;
5
+ setAttribute(name: 'value', value: string): void;
6
+ setAttribute(name: 'detailed', value: ''): void;
7
+ };
8
+ export declare type TSinchProgressReact = TSinchElementReact<TSinchProgressElement> & {
9
+ value: number;
10
+ detailed?: boolean;
11
+ 'aria-label': string;
12
+ };
package/radio/types.d.ts CHANGED
@@ -9,6 +9,7 @@ export declare type TSinchRadioElement = HTMLElement & {
9
9
  export declare type TSinchRadioReact = TSinchElementReact<TSinchRadioElement> & {
10
10
  value: string;
11
11
  'aria-label': string;
12
+ /** @deprecated */
12
13
  onChange?: (event: SyntheticEvent<TSinchRadioElement, CustomEvent<boolean>>) => void;
13
14
  'on-change'?: (e: CustomEvent<string>) => void;
14
15
  };
package/segment/index.js CHANGED
@@ -10,7 +10,7 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
10
10
  import '../title';
11
11
  import { getTitleLevelFromType } from '../title/utils';
12
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}#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}#info.empty+#collapse{margin-left:auto}#collapse.empty{display:none}#preview:not(.empty)+#info.empty+#collapse:not(.empty),#preview:not(.empty)+#info:not(.empty){margin-left:24px}#content-wrapper{flex:1;min-height:0;overflow-y:auto}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px}#action.empty{display:none}: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>';
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}#header{display:flex;flex-direction:row;align-items:center;height:48px;gap:8px;--sinch-size-icon:32px}#caption{color:var(--sinch-color-text-default);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}#info.empty+#collapse{margin-left:auto}#collapse.empty{display:none}#preview:not(.empty)+#info.empty+#collapse:not(.empty),#preview:not(.empty)+#info:not(.empty){margin-left:24px}#content-wrapper{flex:1;min-height:0;overflow-y:auto}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px}#action.empty{display:none}: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" ellipsis></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
14
  import { assertSize, sizeValues } from './utils';
15
15
  const template = document.createElement('template');
16
16
  template.innerHTML = templateHTML;
@@ -9,6 +9,7 @@ export declare type TSinchSegmentExpandElement = HTMLElement & {
9
9
  export declare type TSinchSegmentExpandReact = TSinchElementReact<TSinchSegmentExpandElement> & {
10
10
  value: boolean;
11
11
  'aria-label': string;
12
+ /** @deprecated */
12
13
  onChange?: (e: SyntheticEvent<TSinchSegmentExpandElement, CustomEvent<boolean>>) => void;
13
14
  'on-change'?: (e: CustomEvent<boolean>) => void;
14
15
  };
@@ -8,6 +8,7 @@ export declare type TSinchSegmentedControlElement = HTMLElement & {
8
8
  export declare type TSinchSegmentedControlReact = TSinchElementReact<TSinchSegmentedControlElement> & {
9
9
  value: string;
10
10
  'aria-label': string;
11
+ /** @deprecated */
11
12
  onChange?: (event: SyntheticEvent<TSinchSegmentedControlElement, CustomEvent<string>>) => void;
12
13
  'on-change'?: (e: CustomEvent<string>) => void;
13
14
  };
@@ -11,6 +11,7 @@ export declare type TSinchSegmentedIconControlReact = TSinchElementReact<TSinchS
11
11
  value: string;
12
12
  multiple?: boolean;
13
13
  'aria-label': string;
14
+ /** @deprecated */
14
15
  onChange?: (event: SyntheticEvent<TSinchSegmentedIconControlElement, CustomEvent<string>>) => void;
15
16
  'on-change'?: (e: CustomEvent<string>) => void;
16
17
  };
package/select/types.d.ts CHANGED
@@ -42,7 +42,7 @@ export declare type TSinchSelectReact = TSinchElementReact<TSinchSelectElement>
42
42
  disabled?: boolean;
43
43
  /** Number of visible at the same time options in the list */
44
44
  maxVisibleItems?: number;
45
- /** Change value handler */
45
+ /** @deprecated Change value handler */
46
46
  onChange?: (e: SyntheticEvent<TSinchSelectElement, CustomEvent<string>>) => void;
47
47
  /** Change value handler */
48
48
  'on-change'?: (e: CustomEvent<string>) => void;
package/spinner/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineCustomElement, getLiteralAttribute, NectaryElement, updateLiteralAttribute } from '../utils';
2
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}@keyframes spinner{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}div{animation:1.5s linear infinite spinner;animation-play-state:running;border:solid 3px var(--sinch-color-spinner-bg,#d4dadd);border-bottom-color:var(--sinch-color-spinner-fg,#0a273d);border-radius:50%;height:20px;width:20px;box-sizing:border-box;will-change:transform}:host([type=large]) div{height:46px;width:46px;border-width:4px}:host([type=small]) div{height:14px;width:14px;border-width:2px}:host([static]:not([static=false])) div{animation-play-state:paused}</style><div></div>';
2
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}@keyframes spinner{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}div{animation:1.5s linear infinite spinner;animation-play-state:running;border:solid 3px var(--sinch-color-spinner-bg,#d4dadd);border-bottom-color:var(--sinch-color-spinner-fg,#0a273d);border-radius:50%;height:20px;width:20px;box-sizing:border-box;will-change:transform;margin:2px}:host([type=large]) div{height:48px;width:48px;border-width:4px}:host([type=small]) div{height:14px;width:14px;border-width:2px;margin:1px}:host([static]:not([static=false])) div{animation-play-state:paused}</style><div></div>';
3
3
  import { spinnerTypes } from './utils';
4
4
  const template = document.createElement('template');
5
5
  template.innerHTML = templateHTML;
package/tabs/types.d.ts CHANGED
@@ -8,6 +8,7 @@ export declare type TSinchTabsElement = HTMLElement & {
8
8
  export declare type TSinchTabsReact = TSinchElementReact<TSinchTabsElement> & {
9
9
  value: string;
10
10
  'aria-label': string;
11
+ /** @deprecated */
11
12
  onChange?: (event: SyntheticEvent<TSinchTabsElement, CustomEvent<string>>) => void;
12
13
  'on-change'?: (e: CustomEvent<string>) => void;
13
14
  };
package/tag/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import '../icons/cancel';
2
+ import '../text';
2
3
  import type { TSinchTagElement, TSinchTagReact } from './types';
3
4
  declare global {
4
5
  namespace JSX {
package/tag/index.js CHANGED
@@ -8,9 +8,10 @@ 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 '../icons/cancel';
11
+ import '../text';
11
12
  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{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:hidden;flex:1}</style><div id="wrapper"><slot name="icon"></slot><span id="text"></span><slot name="close"></slot></div>';
13
- import { categoryValues } from './utils';
13
+ 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{flex:1}</style><div id="wrapper"><slot name="icon"></slot><sinch-text id="text" type="xs" ellipsis></sinch-text><slot name="close"></slot></div>';
14
+ import { assertCategoryValue, categoryValues } from './utils';
14
15
  const template = document.createElement('template');
15
16
  template.innerHTML = templateHTML;
16
17
  defineCustomElement('sinch-tag', (_$text = new WeakMap(), class extends NectaryElement {
@@ -61,11 +62,17 @@ defineCustomElement('sinch-tag', (_$text = new WeakMap(), class extends NectaryE
61
62
  }
62
63
 
63
64
  static get observedAttributes() {
64
- return ['text'];
65
+ return ['text', 'category'];
65
66
  }
66
67
 
67
68
  attributeChangedCallback(name, _, newVal) {
68
69
  switch (name) {
70
+ case 'category':
71
+ {
72
+ assertCategoryValue(newVal);
73
+ break;
74
+ }
75
+
69
76
  case 'text':
70
77
  {
71
78
  _classPrivateFieldGet(this, _$text).textContent = newVal;
package/tag/utils.d.ts CHANGED
@@ -1,2 +1,5 @@
1
1
  import type { TSinchTagCategory } from './types';
2
2
  export declare const categoryValues: readonly TSinchTagCategory[];
3
+ declare type TAssertCategory = (value: string | null) => asserts value is TSinchTagCategory;
4
+ export declare const assertCategoryValue: TAssertCategory;
5
+ export {};
package/tag/utils.js CHANGED
@@ -1 +1,6 @@
1
- export const categoryValues = ['candy', 'bolt', 'aqua', 'grass', 'berry', 'orange', 'night', 'mud', 'dirt'];
1
+ export const categoryValues = ['candy', 'bolt', 'aqua', 'grass', 'berry', 'orange', 'night', 'mud', 'dirt'];
2
+ export const assertCategoryValue = value => {
3
+ if (value === null || !categoryValues.includes(value)) {
4
+ throw new Error(`sinch-tag: invalid category attribute: ${value}`);
5
+ }
6
+ };
@@ -9,7 +9,7 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
9
9
 
10
10
  import '../icons/cancel';
11
11
  import { defineCustomElement, NectaryElement } from '../utils';
12
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:14px;height:14px}button{all:initial;position:absolute;display:flex;align-items:center;justify-content:center;width:24px;height:24px;box-sizing:border-box;left:50%;top:50%;transform:translateX(-50%) translateY(-50%);cursor:pointer}button>*{pointer-events:none}</style><div id="wrapper"><button aria-label="dismiss tag"><sinch-icon-cancel></sinch-icon-cancel></button></div>';
12
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:14px;height:14px}button{all:initial;position:absolute;display:flex;align-items:center;justify-content:center;width:24px;height:24px;box-sizing:border-box;left:50%;top:50%;transform:translateX(-50%) translateY(-50%);cursor:pointer}button>*{pointer-events:none}</style><div id="wrapper"><button><sinch-icon-cancel></sinch-icon-cancel></button></div>';
13
13
  const template = document.createElement('template');
14
14
  template.innerHTML = templateHTML;
15
15
  defineCustomElement('sinch-tag-close', (_$button = new WeakMap(), class extends NectaryElement {
@@ -27,6 +27,10 @@ defineCustomElement('sinch-tag-close', (_$button = new WeakMap(), class extends
27
27
  _classPrivateFieldSet(this, _$button, shadowRoot.querySelector('button'));
28
28
  }
29
29
 
30
+ connectedCallback() {
31
+ this.setAttribute('role', 'button');
32
+ }
33
+
30
34
  focus() {
31
35
  _classPrivateFieldGet(this, _$button).focus();
32
36
  }
@@ -1,3 +1,5 @@
1
1
  import type { TSinchElementReact } from '../types';
2
2
  export declare type TSinchTagCloseElement = HTMLElement;
3
- export declare type TSinchTagCloseReact = TSinchElementReact<TSinchTagCloseElement>;
3
+ export declare type TSinchTagCloseReact = TSinchElementReact<TSinchTagCloseElement> & {
4
+ 'aria-label': string;
5
+ };
package/text/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import '../icons/cancel';
2
2
  import { defineCustomElement, getBooleanAttribute, updateBooleanAttribute, NectaryElement, getLiteralAttribute, updateLiteralAttribute, isAttrTrue } from '../utils';
3
- const templateHTML = '<style>:host{display:block;font:var(--sinch-font-text-m)}:host([inline]:not([inline=false])){display:inline}:host([type="s"]){font:var(--sinch-font-text-s)}:host([type=xs]){font:var(--sinch-font-text-xs)}:host([type=xxs]){font:var(--sinch-font-text-xxs)}:host([emphasized]:not([emphasized=false])){font-weight:var(--sinch-font-weight-emphasized)}</style><slot></slot>';
3
+ const templateHTML = '<style>:host{display:block;font:var(--sinch-font-text-m)}:host([inline]:not([inline=false])){display:inline}:host([type="s"]){font:var(--sinch-font-text-s)}:host([type=xs]){font:var(--sinch-font-text-xs)}:host([type=xxs]){font:var(--sinch-font-text-xxs)}:host([emphasized]:not([emphasized=false])){font-weight:var(--sinch-font-weight-emphasized)}:host([ellipsis]:not([ellipsis=false])){overflow:hidden;text-overflow:ellipsis;white-space:nowrap}</style><slot></slot>';
4
4
  import { assertType, typeValues } from './utils';
5
5
  const template = document.createElement('template');
6
6
  template.innerHTML = templateHTML;
@@ -31,6 +31,14 @@ defineCustomElement('sinch-text', class extends NectaryElement {
31
31
  return getBooleanAttribute(this, 'inline');
32
32
  }
33
33
 
34
+ set ellipsis(isEllipsis) {
35
+ updateBooleanAttribute(this, 'ellipsis', isEllipsis);
36
+ }
37
+
38
+ get ellipsis() {
39
+ return getBooleanAttribute(this, 'ellipsis');
40
+ }
41
+
34
42
  set emphasized(isEmphasized) {
35
43
  updateBooleanAttribute(this, 'emphasized', isEmphasized);
36
44
  }
package/text/types.d.ts CHANGED
@@ -4,12 +4,15 @@ export declare type TSinchTextElement = HTMLElement & {
4
4
  type: TSinchTextType;
5
5
  inline: boolean;
6
6
  emphasized: boolean;
7
+ ellipsis: boolean;
7
8
  setAttribute(name: 'type', value: TSinchTextType): void;
8
9
  setAttribute(name: 'inline', value: ''): void;
9
10
  setAttribute(name: 'emphasized', value: ''): void;
11
+ setAttribute(name: 'ellipsis', value: ''): void;
10
12
  };
11
13
  export declare type TSinchTextReact = TSinchElementReact<TSinchTextElement> & {
12
14
  type: TSinchTextType;
13
15
  inline?: boolean;
14
16
  emphasized?: boolean;
17
+ ellipsis?: boolean;
15
18
  };
@@ -401,7 +401,7 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
401
401
 
402
402
  case 'submit-aria-label':
403
403
  {
404
- _classPrivateFieldGet(this, _$submitButton).ariaLabel = newVal;
404
+ updateAttribute(_classPrivateFieldGet(this, _$submitButton), 'aria-label', newVal);
405
405
  break;
406
406
  }
407
407
  }
@@ -427,6 +427,14 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
427
427
  return getBooleanAttribute(this, 'ampm');
428
428
  }
429
429
 
430
+ set submitAriaLabel(value) {
431
+ updateAttribute(this, 'submit-aria-label', value);
432
+ }
433
+
434
+ get submitAriaLabel() {
435
+ return getAttribute(this, 'submit-aria-label', '');
436
+ }
437
+
430
438
  get submitButtonRect() {
431
439
  return getRect(_classPrivateFieldGet(this, _$submitButton));
432
440
  }
@@ -5,6 +5,8 @@ export declare type TSinchTimePickerElement = HTMLElement & {
5
5
  value: string;
6
6
  /** AM/PM 12-hour clock system, `false` by default */
7
7
  ampm: boolean;
8
+ /** Submit button label that is used for a11y */
9
+ submitAriaLabel: string;
8
10
  readonly submitButtonRect: TRect;
9
11
  readonly amButtonRect: TRect | null;
10
12
  readonly pmButtonRect: TRect | null;
@@ -16,6 +18,8 @@ export declare type TSinchTimePickerElement = HTMLElement & {
16
18
  setAttribute(name: 'value', value: string): void;
17
19
  /** AM/PM 12-hour clock system, `false` by default */
18
20
  setAttribute(name: 'ampm', value: boolean): void;
21
+ /** Submit button label that is used for a11y */
22
+ setAttribute(name: 'submit-aria-label', value: string): void;
19
23
  };
20
24
  export declare type TSinchTimePickerReact = TSinchElementReact<TSinchTimePickerElement> & {
21
25
  /** Time value in ISO 8601 format */
@@ -26,7 +30,7 @@ export declare type TSinchTimePickerReact = TSinchElementReact<TSinchTimePickerE
26
30
  'aria-label': string;
27
31
  /** Submit button label that is used for a11y */
28
32
  'submit-aria-label': string;
29
- /** Change value handler, return time in ISO 8601 format */
33
+ /** @deprecated Change value handler, return time in ISO 8601 format */
30
34
  onChange?: (e: SyntheticEvent<TSinchTimePickerElement, CustomEvent<string>>) => void;
31
35
  /** Change value handler, return time in ISO 8601 format */
32
36
  'on-change'?: (e: CustomEvent<string>) => void;
package/title/index.js CHANGED
@@ -8,8 +8,8 @@ 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 '../icons/cancel';
11
- import { defineCustomElement, getAttribute, updateAttribute, updateLiteralAttribute, getLiteralAttribute, NectaryElement } from '../utils';
12
- const templateHTML = '<style>:host{display:block}:host([type=xl])>*{font:var(--sinch-font-title-xl)}:host([type="l"])>*{font:var(--sinch-font-title-l)}:host([type="m"])>*{font:var(--sinch-font-title-m)}:host([type="s"])>*{font:var(--sinch-font-title-s)}:host([type=xs])>*{font:var(--sinch-font-title-xs)}</style><span id="text"></span>';
11
+ import { defineCustomElement, getAttribute, updateAttribute, updateLiteralAttribute, getLiteralAttribute, NectaryElement, updateBooleanAttribute, getBooleanAttribute } from '../utils';
12
+ const templateHTML = '<style>:host{display:block}:host([type=xl]) #text{font:var(--sinch-font-title-xl)}:host([type="l"]) #text{font:var(--sinch-font-title-l)}:host([type="m"]) #text{font:var(--sinch-font-title-m)}:host([type="s"]) #text{font:var(--sinch-font-title-s)}:host([type=xs]) #text{font:var(--sinch-font-title-xs)}:host([ellipsis]:not([ellipsis=false])) #text{display:block;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}</style><span id="text"></span>';
13
13
  import { assertLevel, assertType, typeValues } from './utils';
14
14
  const template = document.createElement('template');
15
15
  template.innerHTML = templateHTML;
@@ -48,6 +48,14 @@ defineCustomElement('sinch-title', (_$text = new WeakMap(), class extends Nectar
48
48
  return getLiteralAttribute(this, typeValues, 'type');
49
49
  }
50
50
 
51
+ set ellipsis(isEllipsis) {
52
+ updateBooleanAttribute(this, 'ellipsis', isEllipsis);
53
+ }
54
+
55
+ get ellipsis() {
56
+ return getBooleanAttribute(this, 'ellipsis');
57
+ }
58
+
51
59
  static get observedAttributes() {
52
60
  return ['text', 'type', 'level'];
53
61
  }
package/title/types.d.ts CHANGED
@@ -5,12 +5,15 @@ export declare type TSinchTitleElement = HTMLElement & {
5
5
  text: string;
6
6
  type: TSinchTitleType;
7
7
  level: TSinchTitleLevel;
8
+ ellipsis: boolean;
8
9
  setAttribute(name: 'text', value: string): void;
9
10
  setAttribute(name: 'type', value: TSinchTitleType): void;
10
11
  setAttribute(name: 'level', value: TSinchTitleLevel): void;
12
+ setAttribute(name: 'ellipsis', value: ''): void;
11
13
  };
12
14
  export declare type TSinchTitleReact = TSinchElementReact<TSinchTitleElement> & {
13
15
  text: string;
14
16
  type: TSinchTitleType;
15
17
  level: TSinchTitleLevel;
18
+ ellipsis?: boolean;
16
19
  };
@@ -0,0 +1,17 @@
1
+ import '../icons/report-problem';
2
+ import '../icons/report';
3
+ import '../icons/check-circle';
4
+ import '../icons/info';
5
+ import '../title';
6
+ import '../text';
7
+ import type { TSinchToastElement, TSinchToastReact } from './types';
8
+ declare global {
9
+ namespace JSX {
10
+ interface IntrinsicElements {
11
+ 'sinch-toast': TSinchToastReact;
12
+ }
13
+ }
14
+ interface HTMLElementTagNameMap {
15
+ 'sinch-toast': TSinchToastElement;
16
+ }
17
+ }
package/toast/index.js ADDED
@@ -0,0 +1,153 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
+
4
+ var _$text, _tid, _updateTimeout, _onTimeout, _clearTimeout, _onTimeoutReactHandler;
5
+
6
+ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
+
8
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
9
+
10
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
11
+
12
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
13
+
14
+ import '../icons/report-problem';
15
+ import '../icons/report';
16
+ import '../icons/check-circle';
17
+ import '../icons/info';
18
+ import '../title';
19
+ import '../text';
20
+ import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, getReactEventHandler, getBooleanAttribute, updateBooleanAttribute } from '../utils';
21
+ const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;align-items:center;gap:8px;width:328px;padding:8px 16px;box-sizing:border-box;border-radius:var(--sinch-shape-radius-l);box-shadow:var(--sinch-elevation-level-3)}#text{color:var(--sinch-color-stormy-500);padding:4px 0 4px 4px;flex:1;min-width:0}#icon-error,#icon-info,#icon-success,#icon-warn{display:none;align-self:flex-start;margin:4px 0}:host([type=success]) #wrapper{background-color:var(--sinch-color-success-200)}:host([type=warn]) #wrapper{background-color:var(--sinch-color-warning-200)}:host([type=error]) #wrapper{background-color:var(--sinch-color-error-200)}:host([type=info]) #wrapper{background-color:var(--sinch-color-informative-200)}:host([type=success]) #icon-success{display:block;--sinch-color-icon:var(--sinch-color-success-500)}:host([type=warn]) #icon-warn{display:block;--sinch-color-icon:var(--sinch-color-warning-500)}:host([type=error]) #icon-error{display:block;--sinch-color-icon:var(--sinch-color-error-500)}:host([type=info]) #icon-info{display:block;--sinch-color-icon:var(--sinch-color-informative-500)}</style><div id="wrapper"><sinch-icon-info id="icon-info"></sinch-icon-info><sinch-icon-check-circle id="icon-success"></sinch-icon-check-circle><sinch-icon-report-problem id="icon-warn"></sinch-icon-report-problem><sinch-icon-report id="icon-error"></sinch-icon-report><sinch-text id="text" type="m"></sinch-text><slot name="action"></slot><slot name="close"></slot></div>';
22
+ import { assertType, typeValues } from './utils';
23
+ const TIMEOUT = 5000;
24
+ const template = document.createElement('template');
25
+ template.innerHTML = templateHTML;
26
+ defineCustomElement('sinch-toast', (_$text = new WeakMap(), _tid = new WeakMap(), _updateTimeout = new WeakSet(), _onTimeout = new WeakMap(), _clearTimeout = new WeakSet(), _onTimeoutReactHandler = new WeakMap(), class extends NectaryElement {
27
+ constructor() {
28
+ super();
29
+
30
+ _classPrivateMethodInitSpec(this, _clearTimeout);
31
+
32
+ _classPrivateMethodInitSpec(this, _updateTimeout);
33
+
34
+ _classPrivateFieldInitSpec(this, _$text, {
35
+ writable: true,
36
+ value: void 0
37
+ });
38
+
39
+ _classPrivateFieldInitSpec(this, _tid, {
40
+ writable: true,
41
+ value: null
42
+ });
43
+
44
+ _classPrivateFieldInitSpec(this, _onTimeout, {
45
+ writable: true,
46
+ value: () => {
47
+ this.dispatchEvent(new CustomEvent('-timeout'));
48
+ }
49
+ });
50
+
51
+ _classPrivateFieldInitSpec(this, _onTimeoutReactHandler, {
52
+ writable: true,
53
+ value: e => {
54
+ getReactEventHandler(this, 'on-timeout')?.(e);
55
+ }
56
+ });
57
+
58
+ const shadowRoot = this.attachShadow();
59
+ shadowRoot.appendChild(template.content.cloneNode(true));
60
+
61
+ _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
62
+ }
63
+
64
+ connectedCallback() {
65
+ this.setAttribute('aria-atomic', 'true');
66
+ this.setAttribute('aria-live', 'polite');
67
+ this.addEventListener('-timeout', _classPrivateFieldGet(this, _onTimeoutReactHandler));
68
+
69
+ _classPrivateMethodGet(this, _updateTimeout, _updateTimeout2).call(this);
70
+ }
71
+
72
+ disconnectedCallback() {
73
+ this.removeEventListener('-timeout', _classPrivateFieldGet(this, _onTimeoutReactHandler));
74
+
75
+ _classPrivateMethodGet(this, _clearTimeout, _clearTimeout2).call(this);
76
+ }
77
+
78
+ get type() {
79
+ return getLiteralAttribute(this, typeValues, 'type');
80
+ }
81
+
82
+ set type(value) {
83
+ updateLiteralAttribute(this, typeValues, 'type', value);
84
+ }
85
+
86
+ get text() {
87
+ return getAttribute(this, 'text', '');
88
+ }
89
+
90
+ set text(value) {
91
+ updateAttribute(this, 'text', value);
92
+ }
93
+
94
+ get persistent() {
95
+ return getBooleanAttribute(this, 'persistent');
96
+ }
97
+
98
+ set persistent(isPersistent) {
99
+ updateBooleanAttribute(this, 'persistent', isPersistent);
100
+ }
101
+
102
+ static get observedAttributes() {
103
+ return ['text', 'type', 'persistent'];
104
+ }
105
+
106
+ attributeChangedCallback(name, oldVal, newVal) {
107
+ if (oldVal === newVal) {
108
+ return;
109
+ }
110
+
111
+ switch (name) {
112
+ case 'type':
113
+ {
114
+ assertType(newVal);
115
+ break;
116
+ }
117
+
118
+ case 'text':
119
+ {
120
+ _classPrivateFieldGet(this, _$text).textContent = newVal;
121
+ break;
122
+ }
123
+
124
+ case 'persistent':
125
+ {
126
+ _classPrivateMethodGet(this, _updateTimeout, _updateTimeout2).call(this);
127
+
128
+ break;
129
+ }
130
+ }
131
+ }
132
+
133
+ }));
134
+
135
+ function _updateTimeout2() {
136
+ if (this.persistent) {
137
+ _classPrivateMethodGet(this, _clearTimeout, _clearTimeout2).call(this);
138
+
139
+ return;
140
+ }
141
+
142
+ if (_classPrivateFieldGet(this, _tid) === null) {
143
+ _classPrivateFieldSet(this, _tid, window.setTimeout(_classPrivateFieldGet(this, _onTimeout), TIMEOUT));
144
+ }
145
+ }
146
+
147
+ function _clearTimeout2() {
148
+ if (_classPrivateFieldGet(this, _tid) !== null) {
149
+ window.clearTimeout(_classPrivateFieldGet(this, _tid));
150
+
151
+ _classPrivateFieldSet(this, _tid, null);
152
+ }
153
+ }
@@ -0,0 +1,28 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ export declare type TSinchToastType = 'info' | 'warn' | 'error' | 'success';
3
+ export declare type TSinchToastElement = HTMLElement & {
4
+ /** Type */
5
+ type: TSinchToastType;
6
+ /** Text */
7
+ text: string;
8
+ /** Persistent, i.e. doesn't automatically dissapear after 5s */
9
+ persistent: boolean;
10
+ /** Timeout event */
11
+ addEventListener(type: '-timeout', listener: (e: CustomEvent<void>) => void): void;
12
+ /** Type */
13
+ setAttribute(name: 'type', value: TSinchToastType): void;
14
+ /** Text */
15
+ setAttribute(name: 'text', value: string): void;
16
+ /** Persistent, i.e. doesn't automatically dissapear after 5s */
17
+ setAttribute(name: 'persistent', value: ''): void;
18
+ };
19
+ export declare type TSinchToastReact = TSinchElementReact<TSinchToastElement> & {
20
+ /** Type */
21
+ type: TSinchToastType;
22
+ /** Text */
23
+ text: string;
24
+ /** Persistent, i.e. doesn't automatically dissapear after 5s */
25
+ persistent?: boolean;
26
+ /** Timeout handler */
27
+ 'on-timeout'?: (e: CustomEvent<void>) => void;
28
+ };
package/toast/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { TSinchToastType } from './types';
2
+ export declare const typeValues: readonly TSinchToastType[];
3
+ declare type TAssertType = (value: string | null) => asserts value is TSinchToastType;
4
+ export declare const assertType: TAssertType;
5
+ export {};
package/toast/utils.js ADDED
@@ -0,0 +1,6 @@
1
+ export const typeValues = ['info', 'success', 'warn', 'error'];
2
+ export const assertType = value => {
3
+ if (value === null || !typeValues.includes(value)) {
4
+ throw new Error(`sinch-toast: invalid type attribute: ${value}`);
5
+ }
6
+ };
@@ -0,0 +1,17 @@
1
+ import '../icons/report-problem';
2
+ import '../icons/report';
3
+ import '../icons/check-circle';
4
+ import '../icons/info';
5
+ import '../title';
6
+ import '../text';
7
+ import type { TSinchToastManagerElement, TSinchToastManagerReact } from './types';
8
+ declare global {
9
+ namespace JSX {
10
+ interface IntrinsicElements {
11
+ 'sinch-toast-manager': TSinchToastManagerReact;
12
+ }
13
+ }
14
+ interface HTMLElementTagNameMap {
15
+ 'sinch-toast-manager': TSinchToastManagerElement;
16
+ }
17
+ }