@nectary/components 0.9.0 → 0.11.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 (106) hide show
  1. package/accordion/index.js +5 -1
  2. package/accordion-item/index.js +7 -7
  3. package/alert/index.js +2 -2
  4. package/alert-button/index.js +1 -1
  5. package/alert-close/index.js +2 -2
  6. package/button/index.d.ts +2 -1
  7. package/button/index.js +7 -3
  8. package/card/index.d.ts +23 -0
  9. package/card/index.js +164 -0
  10. package/card-button/index.d.ts +27 -0
  11. package/card-button/index.js +83 -0
  12. package/card-link/index.d.ts +29 -0
  13. package/card-link/index.js +121 -0
  14. package/checkbox/index.d.ts +3 -0
  15. package/checkbox/index.js +27 -18
  16. package/dialog/index.d.ts +23 -0
  17. package/dialog/index.js +181 -0
  18. package/dropdown/index.d.ts +34 -0
  19. package/dropdown/index.js +451 -0
  20. package/dropdown-option/index.d.ts +44 -0
  21. package/dropdown-option/index.js +116 -0
  22. package/help-tooltip/index.js +5 -1
  23. package/icon/arrow-back/index.d.ts +11 -0
  24. package/icon/arrow-back/index.js +4 -0
  25. package/icon/arrow-downward/index.d.ts +11 -0
  26. package/icon/arrow-downward/index.js +4 -0
  27. package/icon/arrow-forward/index.d.ts +11 -0
  28. package/icon/arrow-forward/index.js +4 -0
  29. package/icon/arrow-upward/index.d.ts +11 -0
  30. package/icon/arrow-upward/index.js +4 -0
  31. package/icon/cancel/index.js +1 -1
  32. package/icon/close/index.js +1 -1
  33. package/icon/create-icon-class.js +1 -1
  34. package/icon/east/index.js +1 -1
  35. package/icon/help-outline/index.js +1 -1
  36. package/icon/more-horiz/index.js +1 -1
  37. package/icon/more-vert/index.js +1 -1
  38. package/icon/north/index.js +1 -1
  39. package/icon/north-east/index.js +1 -1
  40. package/icon/north-west/index.js +1 -1
  41. package/icon/open-in-new/index.js +1 -1
  42. package/icon/south/index.js +1 -1
  43. package/icon/south-east/index.js +1 -1
  44. package/icon/south-west/index.js +1 -1
  45. package/icon/west/index.js +1 -1
  46. package/icon-branded/barchart-down/index.js +1 -1
  47. package/icon-branded/barchart-up/index.js +1 -1
  48. package/icon-branded/campaigns/index.js +1 -1
  49. package/icon-branded/chatbot/index.js +1 -1
  50. package/icon-branded/contact/index.js +1 -1
  51. package/icon-branded/create-icon-class.js +1 -1
  52. package/icon-branded/home/index.js +1 -1
  53. package/icon-branded/multiple-channels/index.js +1 -1
  54. package/icon-branded/rocket/index.js +1 -1
  55. package/icon-branded/settings/index.js +1 -1
  56. package/icon-branded/user/index.js +1 -1
  57. package/icon-branded/users/index.js +1 -1
  58. package/illustration/create-illustration-class.d.ts +308 -0
  59. package/illustration/create-illustration-class.js +53 -0
  60. package/illustration/phone-and-cat/index.d.ts +11 -0
  61. package/illustration/phone-and-cat/index.js +4 -0
  62. package/illustration/types.d.ts +7 -0
  63. package/illustration/types.js +1 -0
  64. package/index.d.ts +11 -0
  65. package/index.js +12 -1
  66. package/input/index.d.ts +3 -1
  67. package/input/index.js +59 -11
  68. package/link/index.js +2 -2
  69. package/logo/create-logo-class.js +1 -1
  70. package/logo/sinch-icon/index.js +1 -1
  71. package/logo/sinch-icon-wordmark/index.js +1 -1
  72. package/package.json +1 -1
  73. package/pagination/index.js +1 -6
  74. package/radio/index.d.ts +1 -0
  75. package/radio/index.js +97 -71
  76. package/radio-option/index.d.ts +1 -0
  77. package/radio-option/index.js +4 -1
  78. package/select/index.d.ts +4 -1
  79. package/select/index.js +72 -265
  80. package/select-option/index.d.ts +3 -17
  81. package/select-option/index.js +4 -103
  82. package/spinner/index.js +1 -1
  83. package/table/index.js +1 -1
  84. package/table-body/index.js +1 -1
  85. package/table-cell/index.js +1 -1
  86. package/table-head/index.js +1 -1
  87. package/table-head-cell/index.js +3 -2
  88. package/table-head-sort/index.d.ts +1 -0
  89. package/table-head-sort/index.js +3 -1
  90. package/table-row/index.js +1 -1
  91. package/tabs/index.d.ts +1 -0
  92. package/tabs/index.js +96 -66
  93. package/tabs-option/index.d.ts +1 -0
  94. package/tabs-option/index.js +4 -2
  95. package/tag/index.js +1 -1
  96. package/tag-close/index.js +2 -2
  97. package/textarea/index.d.ts +3 -1
  98. package/textarea/index.js +58 -11
  99. package/theme.css +6 -2
  100. package/toggle/index.d.ts +1 -0
  101. package/toggle/index.js +4 -5
  102. package/tooltip/index.d.ts +2 -1
  103. package/tooltip/index.js +7 -3
  104. package/types.d.ts +7 -0
  105. package/utils.d.ts +3 -0
  106. package/utils.js +17 -0
@@ -50,7 +50,7 @@ defineCustomElement('sinch-accordion', (_$slot = new WeakMap(), _onSlotChange =
50
50
  });
51
51
 
52
52
  const shadowRoot = this.attachShadow({
53
- mode: 'production' === 'development' ? 'open' : 'closed',
53
+ mode: 'closed',
54
54
  delegatesFocus: true
55
55
  });
56
56
  shadowRoot.appendChild(template.content.cloneNode(true));
@@ -65,6 +65,10 @@ defineCustomElement('sinch-accordion', (_$slot = new WeakMap(), _onSlotChange =
65
65
  return ['value'];
66
66
  }
67
67
 
68
+ connectedCallback() {
69
+ this.setAttribute('aria-label', 'accordion');
70
+ }
71
+
68
72
  get nodeName() {
69
73
  return 'select';
70
74
  }
@@ -1,21 +1,21 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$button, _$labelContent, _onButtonClick;
4
+ var _$button, _$buttonContent, _onButtonClick;
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
10
  import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
11
- const templateHTML = '<style>:host{display:block;outline:0;min-height:48px}#wrapper{display:flex;flex-direction:column;position:relative;width:100%;height:100%;box-sizing:border-box;overflow:hidden;border-bottom:1px solid var(--sinch-color-stormy-200)}#button{all:initial;cursor:pointer;display:flex;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:48px;padding:12px 8px;font:var(--sinch-font-title-4);color:var(--sinch-color-text-default);fill:var(--sinch-color-stormy-500)}#button>*{pointer-events:none}#button:disabled{cursor:initial;color:var(--sinch-color-stormy-100);fill:var(--sinch-color-stormy-100)}#button::before{width:8px;height:8px;border-radius:50%;margin-left:2px;margin-right:8px}:host([status=success]) #button::before{content:"";background-color:var(--sinch-color-success-500)}:host([status=warn]) #button::before{content:"";background-color:var(--sinch-color-warning-500)}:host([status=error]) #button::before{content:"";background-color:var(--sinch-color-error-500)}:host([status=info]) #button::before{content:"";background-color:var(--sinch-color-informative-500)}#content{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#box{display:none;overflow-y:auto;flex-shrink:1;min-height:0;padding:0 8px 18px;font:var(--sinch-font-body);color:var(--sinch-color-text-default)}#button[aria-expanded=true]>#dropdown-icon{transform:rotate(180deg)}#button[aria-expanded=true]+#box{display:block}</style><div id="wrapper"><button id="button" aria-haspopup="box" aria-expanded="false" aria-labelledby="button"><slot name="icon"></slot><span id="content"></span> <svg id="dropdown-icon" width="12" height="8"><path d="M1.41.59 6 5.17 10.59.59 12 2 6 8 0 2 1.41.59Z"/></svg></button><div id="box"><slot name="content"></slot></div></div>';
11
+ const templateHTML = '<style>:host{display:block;outline:0;min-height:48px}#wrapper{display:flex;flex-direction:column;position:relative;width:100%;height:100%;box-sizing:border-box;overflow:hidden;border-bottom:1px solid var(--sinch-color-stormy-200)}#button{all:initial;cursor:pointer;display:flex;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:48px;padding:12px 8px;font:var(--sinch-font-title-4);color:var(--sinch-color-text-default);fill:var(--sinch-color-stormy-500)}#button>*{pointer-events:none}#button:disabled{cursor:initial;color:var(--sinch-color-stormy-100);fill:var(--sinch-color-stormy-100)}#button::before{width:8px;height:8px;border-radius:50%;margin-left:2px;margin-right:8px}:host([status=success]) #button::before{content:"";background-color:var(--sinch-color-success-500)}:host([status=warn]) #button::before{content:"";background-color:var(--sinch-color-warning-500)}:host([status=error]) #button::before{content:"";background-color:var(--sinch-color-error-500)}:host([status=info]) #button::before{content:"";background-color:var(--sinch-color-informative-500)}#title{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#content{display:none;overflow-y:auto;flex-shrink:1;min-height:0;padding:0 8px 18px;font:var(--sinch-font-body);color:var(--sinch-color-text-default)}#button[aria-expanded=true]>#dropdown-icon{transform:rotate(180deg)}#button[aria-expanded=true]+#content{display:block}</style><div id="wrapper"><button id="button" aria-controls="content" aria-expanded="false"><slot name="icon"></slot><span id="title"></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><div id="content" role="region" aria-labelledby="button"><slot name="content"></slot></div></div>';
12
12
  export const isAccordionItemElement = element => {
13
13
  return element instanceof Element && element.tagName === 'SINCH-ACCORDION-ITEM';
14
14
  };
15
15
  const statusValues = ['info', 'success', 'warn', 'error'];
16
16
  const template = document.createElement('template');
17
17
  template.innerHTML = templateHTML;
18
- defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$labelContent = new WeakMap(), _onButtonClick = new WeakMap(), class extends HTMLElement {
18
+ defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$buttonContent = new WeakMap(), _onButtonClick = new WeakMap(), class extends HTMLElement {
19
19
  constructor() {
20
20
  super();
21
21
 
@@ -24,7 +24,7 @@ defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$labelCo
24
24
  value: void 0
25
25
  });
26
26
 
27
- _classPrivateFieldInitSpec(this, _$labelContent, {
27
+ _classPrivateFieldInitSpec(this, _$buttonContent, {
28
28
  writable: true,
29
29
  value: void 0
30
30
  });
@@ -44,14 +44,14 @@ defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$labelCo
44
44
  });
45
45
 
46
46
  const shadowRoot = this.attachShadow({
47
- mode: 'production' === 'development' ? 'open' : 'closed',
47
+ mode: 'closed',
48
48
  delegatesFocus: true
49
49
  });
50
50
  shadowRoot.appendChild(template.content.cloneNode(true));
51
51
 
52
52
  _classPrivateFieldSet(this, _$button, shadowRoot.querySelector('#button'));
53
53
 
54
- _classPrivateFieldSet(this, _$labelContent, shadowRoot.querySelector('#content'));
54
+ _classPrivateFieldSet(this, _$buttonContent, shadowRoot.querySelector('#title'));
55
55
  }
56
56
 
57
57
  connectedCallback() {
@@ -110,7 +110,7 @@ defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$labelCo
110
110
  switch (name) {
111
111
  case 'label':
112
112
  {
113
- _classPrivateFieldGet(this, _$labelContent).textContent = newVal;
113
+ _classPrivateFieldGet(this, _$buttonContent).textContent = newVal;
114
114
  break;
115
115
  }
116
116
 
package/alert/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, getBooleanAttribute, getAttribute, getLiteralAttribute, updateBooleanAttribute, updateAttribute, updateLiteralAttribute } from '../utils';
11
- const templateHTML = '<style>:host{--sinch-color-alert-info-background:#D5E5F8;--sinch-color-alert-success-background:#D7F1D8;--sinch-color-alert-warn-background:#FFE8D6;--sinch-color-alert-error-background:#FCD7D4;display:block}#wrapper{display:flex;flex-direction:row;column-gap:12px;align-items:center;position:relative;padding:12px 18px;border-radius:4px;font:var(--sinch-font-body);color:var(--sinch-color-stormy-600);background-color:var(--sinch-color-alert-info-background);box-sizing:border-box;width:100%;min-height:56px}#body-wrapper{display:flex;flex-direction:row;align-items:center;column-gap:12px;flex:1;min-width:0}#title{display:none;font:var(--sinch-font-title-4);margin:0;margin-bottom:4px}#text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0;flex:1;min-width:0}:is(#icon-info,#icon-success,#icon-warn,#icon-error){display:none}:host([type=success]) #wrapper{background-color:var(--sinch-color-alert-success-background)}:host([type=warn]) #wrapper{background-color:var(--sinch-color-alert-warn-background)}:host([type=error]) #wrapper{background-color:var(--sinch-color-alert-error-background)}:host([type=info]) #wrapper{background-color:var(--sinch-color-alert-info-background)}:host([type=success]) #icon-success{display:block}:host([type=warn]) #icon-warn{display:block}:host([type=error]) #icon-error{display:block}:host(:is([type=info],:not([type]))) #icon-info{display:block}:host([multiline]:not([multiline=false])) #wrapper{align-items:flex-start;padding:16px 18px}:host([multiline]:not([multiline=false])) #body-wrapper{flex-direction:column;align-items:flex-start}:host([multiline]:not([multiline=false])) #title{display:block}:host([multiline]:not([multiline=false])) :is(#icon-info,#icon-success,#icon-warn,#icon-error){margin-top:2px}:host([multiline]:not([multiline=false])) #text{overflow:unset;text-overflow:unset;white-space:unset}:host([multiline]:not([multiline=false])) ::slotted(sinch-alert-button){margin-top:10px}</style><div id="wrapper"><svg id="icon-info" width="20" height="20" viewBox="0 0 20 20"><path d="M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0Zm0 15c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1s1 .45 1 1v4c0 .55-.45 1-1 1Zm1-8H9V5h2v2Z" fill="#2071CE"/></svg> <svg id="icon-success" width="20" height="20" viewBox="0 0 20 20"><path d="M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0ZM7.29 14.29 3.7 10.7a.996.996 0 1 1 1.41-1.41L8 12.17l6.88-6.88a.996.996 0 1 1 1.41 1.41L8.7 14.29a.996.996 0 0 1-1.41 0Z" fill="#2E8540"/></svg> <svg id="icon-warn" width="20" height="20" viewBox="0 0 20 20"><path d="M2.47 18h15.06c1.54 0 2.5-1.67 1.73-3L11.73 1.99c-.77-1.33-2.69-1.33-3.46 0L.74 15c-.77 1.33.19 3 1.73 3ZM10 11c-.55 0-1-.45-1-1V8c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1Zm1 4H9v-2h2v2Z" fill="#FF8C34"/></svg> <svg id="icon-error" width="20" height="20" viewBox="0 0 18 18"><path d="M12.32 0H5.68c-.26 0-.52.11-.7.29L.29 4.98c-.18.18-.29.44-.29.7v6.63c0 .27.11.52.29.71l4.68 4.68c.19.19.45.3.71.3h6.63c.27 0 .52-.11.71-.29l4.68-4.68a.99.99 0 0 0 .29-.71V5.68c0-.27-.11-.52-.29-.71L13.02.29c-.18-.18-.44-.29-.7-.29ZM9 14.3c-.72 0-1.3-.58-1.3-1.3 0-.72.58-1.3 1.3-1.3.72 0 1.3.58 1.3 1.3 0 .72-.58 1.3-1.3 1.3ZM9 10c-.55 0-1-.45-1-1V5c0-.55.45-1 1-1s1 .45 1 1v4c0 .55-.45 1-1 1Z" fill="#E31C3D"/></svg><div id="body-wrapper"><p id="title"></p><p id="text"></p><slot name="button"></slot></div><slot name="close"></slot></div>';
11
+ const templateHTML = '<style>:host{--sinch-color-alert-info-background:#D5E5F8;--sinch-color-alert-success-background:#D7F1D8;--sinch-color-alert-warn-background:#FFE8D6;--sinch-color-alert-error-background:#FCD7D4;display:block}#wrapper{display:flex;flex-direction:row;column-gap:12px;align-items:center;position:relative;padding:12px 18px;border-radius:4px;font:var(--sinch-font-body);color:var(--sinch-color-stormy-600);background-color:var(--sinch-color-alert-info-background);box-sizing:border-box;width:100%;min-height:56px}#body-wrapper{display:flex;flex-direction:row;align-items:center;column-gap:12px;flex:1;min-width:0}#title{display:none;font:var(--sinch-font-title-4);margin:0;margin-bottom:4px}#text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0;flex:1;min-width:0}:is(#icon-info,#icon-success,#icon-warn,#icon-error){display:none}:host([type=success]) #wrapper{background-color:var(--sinch-color-alert-success-background)}:host([type=warn]) #wrapper{background-color:var(--sinch-color-alert-warn-background)}:host([type=error]) #wrapper{background-color:var(--sinch-color-alert-error-background)}:host([type=info]) #wrapper{background-color:var(--sinch-color-alert-info-background)}:host([type=success]) #icon-success{display:block}:host([type=warn]) #icon-warn{display:block}:host([type=error]) #icon-error{display:block}:host(:is([type=info],:not([type]))) #icon-info{display:block}:host([multiline]:not([multiline=false])) #wrapper{align-items:flex-start;padding:16px 18px}:host([multiline]:not([multiline=false])) #body-wrapper{flex-direction:column;align-items:flex-start}:host([multiline]:not([multiline=false])) #title{display:block}:host([multiline]:not([multiline=false])) :is(#icon-info,#icon-success,#icon-warn,#icon-error){margin-top:2px}:host([multiline]:not([multiline=false])) #text{overflow:unset;text-overflow:unset;white-space:unset}:host([multiline]:not([multiline=false])) ::slotted(sinch-alert-button){margin-top:10px}</style><div id="wrapper"><svg id="icon-info" width="20" height="20" viewBox="0 0 20 20" aria-hidden="true"><path d="M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0Zm0 15c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1s1 .45 1 1v4c0 .55-.45 1-1 1Zm1-8H9V5h2v2Z" fill="#2071CE"/></svg> <svg id="icon-success" width="20" height="20" viewBox="0 0 20 20" aria-hidden="true"><path d="M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0ZM7.29 14.29 3.7 10.7a.996.996 0 1 1 1.41-1.41L8 12.17l6.88-6.88a.996.996 0 1 1 1.41 1.41L8.7 14.29a.996.996 0 0 1-1.41 0Z" fill="#2E8540"/></svg> <svg id="icon-warn" width="20" height="20" viewBox="0 0 20 20" aria-hidden="true"><path d="M2.47 18h15.06c1.54 0 2.5-1.67 1.73-3L11.73 1.99c-.77-1.33-2.69-1.33-3.46 0L.74 15c-.77 1.33.19 3 1.73 3ZM10 11c-.55 0-1-.45-1-1V8c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1Zm1 4H9v-2h2v2Z" fill="#FF8C34"/></svg> <svg id="icon-error" width="20" height="20" viewBox="0 0 18 18" aria-hidden="true"><path d="M12.32 0H5.68c-.26 0-.52.11-.7.29L.29 4.98c-.18.18-.29.44-.29.7v6.63c0 .27.11.52.29.71l4.68 4.68c.19.19.45.3.71.3h6.63c.27 0 .52-.11.71-.29l4.68-4.68a.99.99 0 0 0 .29-.71V5.68c0-.27-.11-.52-.29-.71L13.02.29c-.18-.18-.44-.29-.7-.29ZM9 14.3c-.72 0-1.3-.58-1.3-1.3 0-.72.58-1.3 1.3-1.3.72 0 1.3.58 1.3 1.3 0 .72-.58 1.3-1.3 1.3ZM9 10c-.55 0-1-.45-1-1V5c0-.55.45-1 1-1s1 .45 1 1v4c0 .55-.45 1-1 1Z" fill="#E31C3D"/></svg><div id="body-wrapper"><p id="title"></p><p id="text"></p><slot name="button"></slot></div><slot name="close"></slot></div>';
12
12
  const typeValues = ['info', 'success', 'warn', 'error'];
13
13
  const template = document.createElement('template');
14
14
  template.innerHTML = templateHTML;
@@ -27,7 +27,7 @@ defineCustomElement('sinch-alert', (_$text = new WeakMap(), _$title = new WeakMa
27
27
  });
28
28
 
29
29
  const shadowRoot = this.attachShadow({
30
- mode: 'production' === 'development' ? 'open' : 'closed'
30
+ mode: 'closed'
31
31
  });
32
32
  shadowRoot.appendChild(template.content.cloneNode(true));
33
33
 
@@ -21,7 +21,7 @@ defineCustomElement('sinch-alert-button', (_$button = new WeakMap(), class exten
21
21
  });
22
22
 
23
23
  const shadowRoot = this.attachShadow({
24
- mode: 'production' === 'development' ? 'open' : 'closed',
24
+ mode: 'closed',
25
25
  delegatesFocus: true
26
26
  });
27
27
  shadowRoot.appendChild(template.content.cloneNode(true));
@@ -9,7 +9,7 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
9
9
 
10
10
  import '../icon/close';
11
11
  import { defineCustomElement } from '../utils';
12
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}button{all:initial;display:block;width:24px;height:24px;box-sizing:border-box;cursor:pointer}sinch-icon-close{display:block;pointer-events:none}</style><button><sinch-icon-close size="24"></sinch-icon-close></button>';
12
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}button{all:initial;display:block;width:24px;height:24px;box-sizing:border-box;cursor:pointer}sinch-icon-close{display:block;pointer-events:none}</style><button aria-label="close"><sinch-icon-close size="24"></sinch-icon-close></button>';
13
13
  const template = document.createElement('template');
14
14
  template.innerHTML = templateHTML;
15
15
  defineCustomElement('sinch-alert-close', (_$button = new WeakMap(), class extends HTMLElement {
@@ -22,7 +22,7 @@ defineCustomElement('sinch-alert-close', (_$button = new WeakMap(), class extend
22
22
  });
23
23
 
24
24
  const shadowRoot = this.attachShadow({
25
- mode: 'production' === 'development' ? 'open' : 'closed',
25
+ mode: 'closed',
26
26
  delegatesFocus: true
27
27
  });
28
28
  shadowRoot.appendChild(template.content.cloneNode(true));
package/button/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { TSinchElementReact } from '../types';
2
2
  import type { FocusEvent, MouseEvent } from 'react';
3
- declare const buttonTypes: readonly ["primary", "secondary", "cta", "destructive"];
3
+ declare const buttonTypes: readonly ["primary", "secondary", "cta-primary", "cta-secondary", "destructive"];
4
4
  export declare type TSinchButtonType = typeof buttonTypes[number];
5
5
  export declare type TSinchButtonElement = HTMLElement & {
6
6
  type: TSinchButtonType;
@@ -13,6 +13,7 @@ export declare type TSinchButtonElement = HTMLElement & {
13
13
  export declare type TSinchButtonReact = TSinchElementReact<TSinchButtonElement> & {
14
14
  type: TSinchButtonType;
15
15
  text: string;
16
+ 'aria-label': string;
16
17
  disabled?: boolean;
17
18
  small?: boolean;
18
19
  onClick: (e: MouseEvent<TSinchButtonElement>) => void;
package/button/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 { defineCustomElement, getBooleanAttribute, getAttribute, getLiteralAttribute, isAttrTrue, updateBooleanAttribute, updateAttribute, updateLiteralAttribute } from '../utils';
11
- const templateHTML = '<style>:host{--sinch-color-button-background:var(--sinch-color-tropical-500);--sinch-color-button-background-hover:var(--sinch-color-tropical-400);--sinch-color-button-background-focus:var(--sinch-color-tropical-500);--sinch-color-button-background-active:var(--sinch-color-tropical-600);--sinch-color-button-background-disabled:var(--sinch-color-tropical-100);--sinch-color-button-text:var(--sinch-color-text-inverted);--sinch-color-button-text-disabled:var(--sinch-color-text-inverted);--sinch-color-button-border:var(--sinch-color-transparent);--sinch-color-button-border-hover:var(--sinch-color-transparent);--sinch-color-button-border-focus:var(--sinch-color-tropical-700);--sinch-color-button-border-active:var(--sinch-color-transparent);--sinch-color-button-border-disabled:var(--sinch-color-transparent);--sinch-color-spinner-bg:var(--sinch-color-tropical-300);--sinch-color-spinner-fg:var(--sinch-color-snow-100);--sinch-color-icon:var(--sinch-color-text-inverted);display:inline-block;vertical-align:middle;outline:0}:host([type=secondary]){--sinch-color-button-background:var(--sinch-color-snow-100);--sinch-color-button-background-hover:var(--sinch-color-tropical-100);--sinch-color-button-background-focus:var(--sinch-color-snow-100);--sinch-color-button-background-active:var(--sinch-color-tropical-100);--sinch-color-button-background-disabled:var(--sinch-color-snow-100);--sinch-color-button-text:var(--sinch-color-tropical-500);--sinch-color-button-text-disabled:var(--sinch-color-tropical-100);--sinch-color-button-border:var(--sinch-color-tropical-500);--sinch-color-button-border-hover:var(--sinch-color-tropical-500);--sinch-color-button-border-focus:var(--sinch-color-tropical-700);--sinch-color-button-border-active:var(--sinch-color-tropical-500);--sinch-color-button-border-disabled:var(--sinch-color-tropical-100);--sinch-color-spinner-bg:var(--sinch-color-tropical-100);--sinch-color-spinner-fg:var(--sinch-color-tropical-500);--sinch-color-icon:var(--sinch-color-tropical-500)}:host([type=secondary]) button:is(:hover,:active){--sinch-color-spinner-bg:var(--sinch-color-tropical-300);--sinch-color-spinner-fg:var(--sinch-color-snow-100)}:host([type=secondary]) button:disabled{--sinch-color-spinner-bg:var(--sinch-color-tropical-200);--sinch-color-spinner-fg:var(--sinch-color-tropical-400)}:host([type=cta]){--sinch-color-button-background:var(--sinch-color-honey-500);--sinch-color-button-background-hover:var(--sinch-color-honey-400);--sinch-color-button-background-focus:var(--sinch-color-honey-500);--sinch-color-button-background-active:var(--sinch-color-honey-600);--sinch-color-button-background-disabled:var(--sinch-color-honey-100);--sinch-color-button-text:var(--sinch-color-text-default);--sinch-color-button-text-disabled:var(--sinch-color-stormy-300);--sinch-color-button-border:var(--sinch-color-transparent);--sinch-color-button-border-hover:var(--sinch-color-transparent);--sinch-color-button-border-focus:var(--sinch-color-text-default);--sinch-color-button-border-active:var(--sinch-color-transparent);--sinch-color-button-border-disabled:var(--sinch-color-transparent);--sinch-color-spinner-bg:var(--sinch-color-honey-700);--sinch-color-spinner-fg:var(--sinch-color-stormy-600);--sinch-color-icon:var(--sinch-color-text-default)}:host([type=cta]) button:disabled{--sinch-color-spinner-bg:var(--sinch-color-snow-100);--sinch-color-spinner-fg:var(--sinch-color-stormy-300)}:host([type=destructive]){--sinch-color-button-background:var(--sinch-color-snow-100);--sinch-color-button-background-hover:var(--sinch-color-error-200);--sinch-color-button-background-focus:var(--sinch-color-snow-100);--sinch-color-button-background-active:var(--sinch-color-error-200);--sinch-color-button-background-disabled:var(--sinch-color-snow-100);--sinch-color-button-text:var(--sinch-color-text-invalid);--sinch-color-button-text-disabled:var(--sinch-color-error-200);--sinch-color-button-border:var(--sinch-color-error-500);--sinch-color-button-border-hover:var(--sinch-color-error-500);--sinch-color-button-border-focus:var(--sinch-color-error-800);--sinch-color-button-border-active:var(--sinch-color-error-500);--sinch-color-button-border-disabled:var(--sinch-color-error-200);--sinch-color-spinner-bg:var(--sinch-color-raspberry-100);--sinch-color-spinner-fg:var(--sinch-color-raspberry-500);--sinch-color-icon:var(--sinch-color-text-invalid)}:host([type=destructive]) button:is(:hover,:active){--sinch-color-spinner-bg:var(--sinch-color-raspberry-200);--sinch-color-spinner-fg:var(--sinch-color-raspberry-500)}:host([type=destructive]) button:disabled{--sinch-color-spinner-bg:var(--sinch-color-raspberry-100);--sinch-color-spinner-fg:var(--sinch-color-raspberry-500)}button{all:initial;display:flex;align-items:center;justify-content:center;gap:15px;box-sizing:border-box;width:100%;height:48px;padding:12px 24px;border-radius:4px;font:var(--sinch-font-title-4);color:var(--sinch-color-button-text);background-color:var(--sinch-color-button-background);box-shadow:0 0 0 1px var(--sinch-color-button-border) inset;cursor:pointer}button:focus{background-color:var(--sinch-color-button-background-focus);box-shadow:0 0 0 2px var(--sinch-color-button-border-focus) inset}button:hover{background-color:var(--sinch-color-button-background-hover);box-shadow:0 0 0 1px var(--sinch-color-button-border-hover) inset}button:active{background-color:var(--sinch-color-button-background-active);box-shadow:0 0 0 2px var(--sinch-color-button-border-active) inset}button:disabled{color:var(--sinch-color-button-text-disabled);background-color:var(--sinch-color-button-background-disabled);box-shadow:0 0 0 1px var(--sinch-color-button-border-disabled) inset;cursor:initial;--sinch-color-spinner-bg:var(--sinch-color-snow-100);--sinch-color-spinner-fg:var(--sinch-color-tropical-200);--sinch-color-icon:var(--sinch-color-button-text-disabled)}button>*{pointer-events:none}#text{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host([small]:not([small=false]))>button{height:32px;padding:8px 16px;line-height:16px;font-size:14px;gap:8px}</style><button><slot name="icon"></slot><span id="text"></span></button>';
12
- const buttonTypes = ['primary', 'secondary', 'cta', 'destructive'];
11
+ const templateHTML = '<style>:host{--sinch-color-button-background:var(--sinch-color-tropical-500);--sinch-color-button-background-hover:var(--sinch-color-tropical-400);--sinch-color-button-background-focus:var(--sinch-color-tropical-500);--sinch-color-button-background-active:var(--sinch-color-tropical-600);--sinch-color-button-background-disabled:var(--sinch-color-tropical-100);--sinch-color-button-text:var(--sinch-color-text-inverted);--sinch-color-button-text-disabled:var(--sinch-color-text-inverted);--sinch-color-button-border:var(--sinch-color-transparent);--sinch-color-button-border-hover:var(--sinch-color-transparent);--sinch-color-button-border-focus:var(--sinch-color-tropical-700);--sinch-color-button-border-active:var(--sinch-color-transparent);--sinch-color-button-border-disabled:var(--sinch-color-transparent);--sinch-color-spinner-bg:var(--sinch-color-tropical-300);--sinch-color-spinner-fg:var(--sinch-color-snow-100);--sinch-color-icon:var(--sinch-color-text-inverted);display:inline-block;vertical-align:middle;outline:0}:host([type=secondary]){--sinch-color-button-background:var(--sinch-color-snow-100);--sinch-color-button-background-hover:var(--sinch-color-tropical-100);--sinch-color-button-background-focus:var(--sinch-color-snow-100);--sinch-color-button-background-active:var(--sinch-color-tropical-100);--sinch-color-button-background-disabled:var(--sinch-color-snow-100);--sinch-color-button-text:var(--sinch-color-tropical-500);--sinch-color-button-text-disabled:var(--sinch-color-tropical-100);--sinch-color-button-border:var(--sinch-color-tropical-500);--sinch-color-button-border-hover:var(--sinch-color-tropical-500);--sinch-color-button-border-focus:var(--sinch-color-tropical-700);--sinch-color-button-border-active:var(--sinch-color-tropical-500);--sinch-color-button-border-disabled:var(--sinch-color-tropical-100);--sinch-color-spinner-bg:var(--sinch-color-tropical-100);--sinch-color-spinner-fg:var(--sinch-color-tropical-500);--sinch-color-icon:var(--sinch-color-tropical-500)}:host([type=secondary]) button:is(:hover,:active){--sinch-color-spinner-bg:var(--sinch-color-tropical-300);--sinch-color-spinner-fg:var(--sinch-color-snow-100)}:host([type=secondary]) button:disabled{--sinch-color-spinner-bg:var(--sinch-color-tropical-200);--sinch-color-spinner-fg:var(--sinch-color-tropical-400)}:host([type=cta-primary]){--sinch-color-button-background:var(--sinch-color-honey-500);--sinch-color-button-background-hover:var(--sinch-color-honey-400);--sinch-color-button-background-focus:var(--sinch-color-honey-500);--sinch-color-button-background-active:var(--sinch-color-honey-600);--sinch-color-button-background-disabled:var(--sinch-color-honey-100);--sinch-color-button-text:var(--sinch-color-text-default);--sinch-color-button-text-disabled:var(--sinch-color-stormy-300);--sinch-color-button-border:var(--sinch-color-transparent);--sinch-color-button-border-hover:var(--sinch-color-transparent);--sinch-color-button-border-focus:var(--sinch-color-text-default);--sinch-color-button-border-active:var(--sinch-color-transparent);--sinch-color-button-border-disabled:var(--sinch-color-transparent);--sinch-color-spinner-bg:var(--sinch-color-honey-700);--sinch-color-spinner-fg:var(--sinch-color-stormy-600);--sinch-color-icon:var(--sinch-color-text-default)}:host([type=cta-primary]) button:disabled{--sinch-color-spinner-bg:var(--sinch-color-snow-100);--sinch-color-spinner-fg:var(--sinch-color-stormy-300)}:host([type=cta-secondary]){--sinch-color-button-background:var(--sinch-color-snow-100);--sinch-color-button-background-hover:var(--sinch-color-snow-500);--sinch-color-button-background-focus:var(--sinch-color-snow-100);--sinch-color-button-background-active:var(--sinch-color-snow-500);--sinch-color-button-background-disabled:var(--sinch-color-snow-100);--sinch-color-button-text:var(--sinch-color-stormy-500);--sinch-color-button-text-disabled:var(--sinch-color-stormy-200);--sinch-color-button-border:var(--sinch-color-stormy-500);--sinch-color-button-border-hover:var(--sinch-color-stormy-500);--sinch-color-button-border-focus:var(--sinch-color-stormy-500);--sinch-color-button-border-active:var(--sinch-color-stormy-500);--sinch-color-button-border-disabled:var(--sinch-color-stormy-200);--sinch-color-spinner-bg:var(--sinch-color-snow-800);--sinch-color-spinner-fg:var(--sinch-color-stormy-600);--sinch-color-icon:var(--sinch-color-stormy-500)}:host([type=cta-secondary]) button:disabled{--sinch-color-spinner-bg:var(--sinch-color-snow-600);--sinch-color-spinner-fg:var(--sinch-color-stormy-200);--sinch-color-icon:var(--sinch-color-stormy-200)}:host([type=destructive]){--sinch-color-button-background:var(--sinch-color-snow-100);--sinch-color-button-background-hover:var(--sinch-color-error-200);--sinch-color-button-background-focus:var(--sinch-color-snow-100);--sinch-color-button-background-active:var(--sinch-color-error-200);--sinch-color-button-background-disabled:var(--sinch-color-snow-100);--sinch-color-button-text:var(--sinch-color-text-invalid);--sinch-color-button-text-disabled:var(--sinch-color-error-200);--sinch-color-button-border:var(--sinch-color-error-500);--sinch-color-button-border-hover:var(--sinch-color-error-500);--sinch-color-button-border-focus:var(--sinch-color-error-800);--sinch-color-button-border-active:var(--sinch-color-error-500);--sinch-color-button-border-disabled:var(--sinch-color-error-200);--sinch-color-spinner-bg:var(--sinch-color-raspberry-100);--sinch-color-spinner-fg:var(--sinch-color-raspberry-500);--sinch-color-icon:var(--sinch-color-text-invalid)}:host([type=destructive]) button:is(:hover,:active){--sinch-color-spinner-bg:var(--sinch-color-raspberry-200);--sinch-color-spinner-fg:var(--sinch-color-raspberry-500)}:host([type=destructive]) button:disabled{--sinch-color-spinner-bg:var(--sinch-color-raspberry-100);--sinch-color-spinner-fg:var(--sinch-color-raspberry-500)}button{all:initial;display:flex;align-items:center;justify-content:center;gap:15px;box-sizing:border-box;width:100%;height:48px;padding:12px;border-radius:4px;font:var(--sinch-font-title-4);color:var(--sinch-color-button-text);background-color:var(--sinch-color-button-background);box-shadow:0 0 0 1px var(--sinch-color-button-border) inset;cursor:pointer}button:focus{background-color:var(--sinch-color-button-background-focus);box-shadow:0 0 0 2px var(--sinch-color-button-border-focus) inset}button:hover{background-color:var(--sinch-color-button-background-hover);box-shadow:0 0 0 1px var(--sinch-color-button-border-hover) inset}button:active{background-color:var(--sinch-color-button-background-active);box-shadow:0 0 0 2px var(--sinch-color-button-border-active) inset}button:disabled{color:var(--sinch-color-button-text-disabled);background-color:var(--sinch-color-button-background-disabled);box-shadow:0 0 0 1px var(--sinch-color-button-border-disabled) inset;cursor:initial;--sinch-color-spinner-bg:var(--sinch-color-snow-100);--sinch-color-spinner-fg:var(--sinch-color-tropical-200);--sinch-color-icon:var(--sinch-color-button-text-disabled)}button>*{pointer-events:none}#text{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;display:none}:host([text]:not([text=""])) #text{display:initial}:host([text]:not([text=""])) button{padding:12px 24px}:host([small]:not([small=false]))>button{height:32px;padding:8px;line-height:16px;font-size:14px;gap:8px}:host([text]:not([text=""])[small]:not([small=false])) button{padding:8px 16px}</style><button><slot name="icon"></slot><span id="text"></span></button>';
12
+ const buttonTypes = ['primary', 'secondary', 'cta-primary', 'cta-secondary', 'destructive'];
13
13
  const template = document.createElement('template');
14
14
  template.innerHTML = templateHTML;
15
15
  defineCustomElement('sinch-button', (_$button = new WeakMap(), _$text = new WeakMap(), class extends HTMLElement {
@@ -27,7 +27,7 @@ defineCustomElement('sinch-button', (_$button = new WeakMap(), _$text = new Weak
27
27
  });
28
28
 
29
29
  const shadowRoot = this.attachShadow({
30
- mode: 'production' === 'development' ? 'open' : 'closed',
30
+ mode: 'closed',
31
31
  delegatesFocus: true
32
32
  });
33
33
  shadowRoot.appendChild(template.content.cloneNode(true));
@@ -37,6 +37,10 @@ defineCustomElement('sinch-button', (_$button = new WeakMap(), _$text = new Weak
37
37
  _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
38
38
  }
39
39
 
40
+ connectedCallback() {
41
+ this.setAttribute('role', 'button');
42
+ }
43
+
40
44
  static get observedAttributes() {
41
45
  return ['text', 'disabled'];
42
46
  }
@@ -0,0 +1,23 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ export declare type TSinchCardElement = HTMLElement & {
3
+ text: string;
4
+ label: string;
5
+ header: string;
6
+ disabled: boolean;
7
+ };
8
+ export declare type TSinchCardReact = TSinchElementReact<TSinchCardElement> & {
9
+ text: string;
10
+ label?: string;
11
+ header: string;
12
+ disabled?: boolean;
13
+ };
14
+ declare global {
15
+ namespace JSX {
16
+ interface IntrinsicElements {
17
+ 'sinch-card': TSinchCardReact;
18
+ }
19
+ }
20
+ interface HTMLElementTagNameMap {
21
+ 'sinch-card': TSinchCardElement;
22
+ }
23
+ }
package/card/index.js ADDED
@@ -0,0 +1,164 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
+
4
+ var _$text, _$label, _$title, _$illustrationSlot, _$actionSlot, _$illustrationSlotWrapper, _onIllustrationSlotChange, _updateDisabledAttributeInChildren;
5
+
6
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
+
8
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
+
10
+ import { isSinchCardButtonElement } from '../card-button';
11
+ import { isSinchCardLinkElement } from '../card-link';
12
+ import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute, setClass } from '../utils';
13
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative}#card-body{padding:24px;box-sizing:border-box;display:flex;flex-direction:column;gap:16px;background-color:var(--sinch-color-snow-100);border-radius:8px;border:1px solid var(--sinch-color-snow-700)}#illustration-wrapper{display:none;flex-direction:column;align-items:center;border-top-left-radius:8px;border-top-right-radius:8px;overflow:hidden;background-color:var(--sinch-color-stormy-500);max-height:222px}#illustration-wrapper.active{display:flex}#illustration-wrapper.active+#card-body{border-top-left-radius:0;border-top-right-radius:0;border-top:none}#label{margin:0;font:var(--sinch-font-title-5);color:var(--sinch-color-stormy-300);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#label:empty{display:none}#header{display:flex;flex-direction:row;align-items:center;gap:8px}#title{font:var(--sinch-font-title-3);color:var(--sinch-color-stormy-500);flex:1;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#description{margin:0;font:var(--sinch-font-body);color:var(--sinch-color-stormy-500);flex:1;min-height:0;max-height:120px;overflow-y:auto}#description:empty{display:none}:host([disabled]:not([disabled=false])) :is(#illustration-wrapper,#description,#header,#label){opacity:60%}::slotted(sinch-card-button),::slotted(sinch-card-link){margin-top:20px;align-self:flex-start;max-width:100%}</style><div id="wrapper"><div id="illustration-wrapper"><slot name="illustration"></slot></div><div id="card-body"><p id="label"></p><div id="header"><slot name="icon"></slot><span id="title"></span></div><p id="description"></p><slot name="action"></slot></div></div>';
14
+ const template = document.createElement('template');
15
+ template.innerHTML = templateHTML;
16
+ defineCustomElement('sinch-card', (_$text = new WeakMap(), _$label = new WeakMap(), _$title = new WeakMap(), _$illustrationSlot = new WeakMap(), _$actionSlot = new WeakMap(), _$illustrationSlotWrapper = new WeakMap(), _onIllustrationSlotChange = new WeakMap(), _updateDisabledAttributeInChildren = new WeakMap(), class extends HTMLElement {
17
+ constructor() {
18
+ super();
19
+
20
+ _classPrivateFieldInitSpec(this, _$text, {
21
+ writable: true,
22
+ value: void 0
23
+ });
24
+
25
+ _classPrivateFieldInitSpec(this, _$label, {
26
+ writable: true,
27
+ value: void 0
28
+ });
29
+
30
+ _classPrivateFieldInitSpec(this, _$title, {
31
+ writable: true,
32
+ value: void 0
33
+ });
34
+
35
+ _classPrivateFieldInitSpec(this, _$illustrationSlot, {
36
+ writable: true,
37
+ value: void 0
38
+ });
39
+
40
+ _classPrivateFieldInitSpec(this, _$actionSlot, {
41
+ writable: true,
42
+ value: void 0
43
+ });
44
+
45
+ _classPrivateFieldInitSpec(this, _$illustrationSlotWrapper, {
46
+ writable: true,
47
+ value: void 0
48
+ });
49
+
50
+ _classPrivateFieldInitSpec(this, _onIllustrationSlotChange, {
51
+ writable: true,
52
+ value: () => {
53
+ setClass(_classPrivateFieldGet(this, _$illustrationSlotWrapper), 'active', _classPrivateFieldGet(this, _$illustrationSlot).assignedElements().length > 0);
54
+ }
55
+ });
56
+
57
+ _classPrivateFieldInitSpec(this, _updateDisabledAttributeInChildren, {
58
+ writable: true,
59
+ value: () => {
60
+ _classPrivateFieldGet(this, _$actionSlot).assignedElements().forEach(el => {
61
+ if (isSinchCardButtonElement(el) || isSinchCardLinkElement(el)) {
62
+ updateAttribute(el, 'disabled', this.getAttribute('disabled'));
63
+ }
64
+ });
65
+ }
66
+ });
67
+
68
+ const shadowRoot = this.attachShadow({
69
+ mode: 'closed',
70
+ delegatesFocus: true
71
+ });
72
+ shadowRoot.appendChild(template.content.cloneNode(true));
73
+
74
+ _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#description'));
75
+
76
+ _classPrivateFieldSet(this, _$label, shadowRoot.querySelector('#label'));
77
+
78
+ _classPrivateFieldSet(this, _$title, shadowRoot.querySelector('#title'));
79
+
80
+ _classPrivateFieldSet(this, _$illustrationSlot, shadowRoot.querySelector('slot[name="illustration"]'));
81
+
82
+ _classPrivateFieldSet(this, _$actionSlot, shadowRoot.querySelector('slot[name="action"]'));
83
+
84
+ _classPrivateFieldSet(this, _$illustrationSlotWrapper, shadowRoot.querySelector('#illustration-wrapper'));
85
+ }
86
+
87
+ connectedCallback() {
88
+ _classPrivateFieldGet(this, _$illustrationSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onIllustrationSlotChange));
89
+
90
+ _classPrivateFieldGet(this, _$actionSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _updateDisabledAttributeInChildren));
91
+ }
92
+
93
+ disconnectedCallback() {
94
+ _classPrivateFieldGet(this, _$illustrationSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onIllustrationSlotChange));
95
+
96
+ _classPrivateFieldGet(this, _$actionSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _updateDisabledAttributeInChildren));
97
+ }
98
+
99
+ static get observedAttributes() {
100
+ return ['text', 'label', 'header', 'disabled'];
101
+ }
102
+
103
+ attributeChangedCallback(name, _, newVal) {
104
+ switch (name) {
105
+ case 'text':
106
+ {
107
+ _classPrivateFieldGet(this, _$text).textContent = newVal;
108
+ break;
109
+ }
110
+
111
+ case 'label':
112
+ {
113
+ _classPrivateFieldGet(this, _$label).textContent = newVal;
114
+ break;
115
+ }
116
+
117
+ case 'header':
118
+ {
119
+ _classPrivateFieldGet(this, _$title).textContent = newVal;
120
+ break;
121
+ }
122
+
123
+ case 'disabled':
124
+ {
125
+ _classPrivateFieldGet(this, _updateDisabledAttributeInChildren).call(this);
126
+
127
+ break;
128
+ }
129
+ }
130
+ }
131
+
132
+ set text(value) {
133
+ updateAttribute(this, 'text', value);
134
+ }
135
+
136
+ get text() {
137
+ return getAttribute(this, 'text', '');
138
+ }
139
+
140
+ set header(value) {
141
+ updateAttribute(this, 'header', value);
142
+ }
143
+
144
+ get header() {
145
+ return getAttribute(this, 'header', '');
146
+ }
147
+
148
+ set label(value) {
149
+ updateAttribute(this, 'label', value);
150
+ }
151
+
152
+ get label() {
153
+ return getAttribute(this, 'label', '');
154
+ }
155
+
156
+ set disabled(isDisabled) {
157
+ updateBooleanAttribute(this, 'disabled', isDisabled);
158
+ }
159
+
160
+ get disabled() {
161
+ return getBooleanAttribute(this, 'disabled');
162
+ }
163
+
164
+ }));
@@ -0,0 +1,27 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ import type { FocusEvent, MouseEvent } from 'react';
3
+ export declare const isSinchCardButtonElement: (el: Element) => el is TSinchCardButtonElement;
4
+ export declare type TSinchCardButtonElement = HTMLElement & {
5
+ text: string;
6
+ disabled: boolean;
7
+ focus(): void;
8
+ blur(): void;
9
+ };
10
+ export declare type TSinchCardButtonReact = TSinchElementReact<TSinchCardButtonElement> & {
11
+ text: string;
12
+ 'aria-label': string;
13
+ disabled?: boolean;
14
+ onClick: (e: MouseEvent<TSinchCardButtonElement>) => void;
15
+ onFocus?: (e: FocusEvent<TSinchCardButtonElement>) => void;
16
+ onBlur?: (e: FocusEvent<TSinchCardButtonElement>) => void;
17
+ };
18
+ declare global {
19
+ namespace JSX {
20
+ interface IntrinsicElements {
21
+ 'sinch-card-button': TSinchCardButtonReact;
22
+ }
23
+ }
24
+ interface HTMLElementTagNameMap {
25
+ 'sinch-card-button': TSinchCardButtonElement;
26
+ }
27
+ }
@@ -0,0 +1,83 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
+
4
+ var _$button;
5
+
6
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
+
8
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
+
10
+ import { defineCustomElement, getBooleanAttribute, getAttribute, updateAttribute } from '../utils';
11
+ const templateHTML = '<style>:host{display:inline-block;outline:0}sinch-button{display:block}</style><sinch-button type="primary" small></sinch-button>';
12
+ export const isSinchCardButtonElement = el => {
13
+ return el.tagName === 'SINCH-CARD-BUTTON';
14
+ };
15
+ const template = document.createElement('template');
16
+ template.innerHTML = templateHTML;
17
+ defineCustomElement('sinch-card-button', (_$button = new WeakMap(), class extends HTMLElement {
18
+ constructor() {
19
+ super();
20
+
21
+ _classPrivateFieldInitSpec(this, _$button, {
22
+ writable: true,
23
+ value: void 0
24
+ });
25
+
26
+ const shadowRoot = this.attachShadow({
27
+ mode: 'closed',
28
+ delegatesFocus: true
29
+ });
30
+ shadowRoot.appendChild(template.content.cloneNode(true));
31
+
32
+ _classPrivateFieldSet(this, _$button, shadowRoot.querySelector('sinch-button'));
33
+ }
34
+
35
+ connectedCallback() {
36
+ this.setAttribute('role', 'button');
37
+ }
38
+
39
+ static get observedAttributes() {
40
+ return ['text', 'disabled'];
41
+ }
42
+
43
+ attributeChangedCallback(name, _, newVal) {
44
+ switch (name) {
45
+ case 'text':
46
+ {
47
+ updateAttribute(_classPrivateFieldGet(this, _$button), 'text', newVal);
48
+ break;
49
+ }
50
+
51
+ case 'disabled':
52
+ {
53
+ updateAttribute(_classPrivateFieldGet(this, _$button), 'disabled', newVal);
54
+ break;
55
+ }
56
+ }
57
+ }
58
+
59
+ set text(value) {
60
+ updateAttribute(this, 'text', value);
61
+ }
62
+
63
+ get text() {
64
+ return getAttribute(this, 'text', '');
65
+ }
66
+
67
+ set disabled(isDisabled) {
68
+ updateAttribute(this, 'disabled', isDisabled);
69
+ }
70
+
71
+ get disabled() {
72
+ return getBooleanAttribute(this, 'disabled');
73
+ }
74
+
75
+ focus() {
76
+ _classPrivateFieldGet(this, _$button).focus();
77
+ }
78
+
79
+ blur() {
80
+ _classPrivateFieldGet(this, _$button).blur();
81
+ }
82
+
83
+ }));
@@ -0,0 +1,29 @@
1
+ import '../icon/cancel';
2
+ import type { TSinchElementReact } from '../types';
3
+ import type { FocusEvent, MouseEvent } from 'react';
4
+ export declare const isSinchCardLinkElement: (el: Element) => el is TSinchCardLinkElement;
5
+ export declare type TSinchCardLinkElement = HTMLElement & {
6
+ text: string;
7
+ href: string;
8
+ disabled: boolean;
9
+ focus(): void;
10
+ blur(): void;
11
+ };
12
+ export declare type TSinchCardLinkReact = TSinchElementReact<TSinchCardLinkElement> & {
13
+ text: string;
14
+ href: string;
15
+ disabled?: boolean;
16
+ onClick?: (e: MouseEvent<TSinchCardLinkElement>) => void;
17
+ onFocus?: (e: FocusEvent<TSinchCardLinkElement>) => void;
18
+ onBlur?: (e: FocusEvent<TSinchCardLinkElement>) => void;
19
+ };
20
+ declare global {
21
+ namespace JSX {
22
+ interface IntrinsicElements {
23
+ 'sinch-card-link': TSinchCardLinkReact;
24
+ }
25
+ }
26
+ interface HTMLElementTagNameMap {
27
+ 'sinch-card-link': TSinchCardLinkElement;
28
+ }
29
+ }