@nectary/components 0.12.0 → 0.14.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.
@@ -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, 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)}#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>';
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);--sinch-size-icon:16px}#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
  };
@@ -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 aria-label="close"><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-size-icon:24px}sinch-icon-close{display:block;pointer-events:none}</style><button aria-label="close"><sinch-icon-close></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 {
package/button/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, 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-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>';
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;--sinch-size-icon:24px}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;--sinch-size-icon:16px}:host([text]:not([text=""])[small]:not([small=false])) button{padding:8px 16px}</style><button><slot name="icon"></slot><span id="text"></span></button>';
12
12
  const buttonTypes = ['primary', 'secondary', 'cta-primary', 'cta-secondary', 'destructive'];
13
13
  const template = document.createElement('template');
14
14
  template.innerHTML = templateHTML;
package/card/index.js CHANGED
@@ -10,7 +10,7 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
10
10
  import { isSinchCardButtonElement } from '../card-button';
11
11
  import { isSinchCardLinkElement } from '../card-link';
12
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);height:240px}#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>';
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);height:240px}#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;--sinch-size-icon:48px}#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
14
  const template = document.createElement('template');
15
15
  template.innerHTML = templateHTML;
16
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 {
@@ -9,7 +9,7 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
9
9
 
10
10
  import '../icon/arrow-forward';
11
11
  import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute } from '../utils';
12
- const templateHTML = '<style>:host{display:inline;outline:0}a{display:flex;flex-direction:row;gap:8px;font:var(--sinch-font-emphasized-body);color:var(--sinch-color-tropical-500);text-decoration:none;outline:0;--sinch-color-icon:var(--sinch-color-tropical-500)}a:hover{color:var(--sinch-color-tropical-600);fill:var(--sinch-color-tropical-600)}:host([disabled]:not([disabled=false])) a{color:var(--sinch-color-tropical-300);pointer-events:none;cursor:initial;--sinch-color-icon:var(--sinch-color-tropical-300)}span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;flex-shrink:1}</style><a><span></span><sinch-icon-arrow-forward size="24"></sinch-icon-arrow-forward></a>';
12
+ const templateHTML = '<style>:host{display:inline;outline:0}a{display:flex;flex-direction:row;gap:8px;font:var(--sinch-font-emphasized-body);color:var(--sinch-color-tropical-500);text-decoration:none;outline:0;--sinch-color-icon:var(--sinch-color-tropical-500);--sinch-size-icon:24px}a:hover{color:var(--sinch-color-tropical-600);fill:var(--sinch-color-tropical-600)}:host([disabled]:not([disabled=false])) a{color:var(--sinch-color-tropical-300);pointer-events:none;cursor:initial;--sinch-color-icon:var(--sinch-color-tropical-300)}span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;flex-shrink:1}</style><a><span></span><sinch-icon-arrow-forward></sinch-icon-arrow-forward></a>';
13
13
  export const isSinchCardLinkElement = el => {
14
14
  return el.tagName === 'SINCH-CARD-LINK';
15
15
  };
package/dialog/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import '../icon/close';
1
2
  import type { TRect, TSinchElementReact } from '../types';
2
3
  import type { SyntheticEvent } from 'react';
3
4
  declare type TSinchDialogElement = HTMLElement & {
package/dialog/index.js CHANGED
@@ -8,7 +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, getAttribute, getRect, updateAttribute } from '../utils';
11
- const templateHTML = '<style>:host{outline:0}#wrapper{position:fixed;top:0;left:0;height:100vh;width:100vw;color:var(--sinch-color-text-default);font:var(--sinch-font-body);z-index:2147483647}#backdrop{background-color:#000;position:absolute;left:0;top:0;opacity:55%;width:100%;height:100%}#main{display:flex;flex-direction:column;position:relative;left:50%;top:50%;transform:translateX(-50%) translateY(-50%);padding:24px;width:100%;max-width:512px;border-radius:4px;box-sizing:border-box;background-color:var(--sinch-color-snow-100)}#header{display:flex;flex-direction:row;justify-content:space-between;align-content:center;margin-bottom:16px}#title{font:var(--sinch-font-title-3);color:var(--sinch-color-text-default)}#content-wrapper{max-height:50vh;overflow-y:auto;margin-top:16px}#close{all:initial;cursor:pointer}#buttons{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;margin-top:24px}</style><div id="wrapper"><div id="backdrop"></div><div id="main"><div id="header"><span id="title"></span> <button id="close"><sinch-icon-close size="24"></sinch-icon-close></button></div><div id="content-wrapper"><slot name="content"></slot></div><div id="buttons"><slot name="buttons"></slot></div></div></div>';
11
+ import '../icon/close';
12
+ const templateHTML = '<style>:host{outline:0}#wrapper{position:fixed;top:0;left:0;height:100vh;width:100vw;color:var(--sinch-color-text-default);font:var(--sinch-font-body);z-index:2147483647}#backdrop{background-color:#000;position:absolute;left:0;top:0;opacity:55%;width:100%;height:100%}#main{display:flex;flex-direction:column;position:relative;left:50%;top:50%;transform:translateX(-50%) translateY(-50%);padding:24px;width:100%;max-width:512px;border-radius:4px;box-sizing:border-box;background-color:var(--sinch-color-snow-100)}#header{display:flex;flex-direction:row;justify-content:space-between;align-content:center;margin-bottom:16px}#title{font:var(--sinch-font-title-3);color:var(--sinch-color-text-default)}#content-wrapper{max-height:50vh;overflow-y:auto;margin-top:16px}#close{all:initial;cursor:pointer;--sinch-size-icon:24px}#buttons{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;margin-top:24px}</style><div id="wrapper"><div id="backdrop"></div><div id="main"><div id="header"><span id="title"></span> <button id="close"><sinch-icon-close></sinch-icon-close></button></div><div id="content-wrapper"><slot name="content"></slot></div><div id="buttons"><slot name="buttons"></slot></div></div></div>';
12
13
  const template = document.createElement('template');
13
14
  template.innerHTML = templateHTML;
14
15
 
@@ -6,7 +6,7 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
6
6
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
7
7
 
8
8
  import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute } from '../utils';
9
- const templateHTML = '<style>:host{display:block}*{pointer-events:none}#wrapper{display:flex;position:relative;box-sizing:border-box;padding:6px 12px;width:100%;align-items:center;gap:12px}#content{flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host(:hover)>#wrapper,:host([data-selected])>#wrapper{background-color:var(--sinch-color-snow-500)}:host([checked])>#wrapper{padding-right:36px}:host([checked])>#wrapper::after{content:"";position:absolute;top:10px;right:11px;width:18px;height:14px;background-image:url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\'%3E%3Cpath d=\'M6 11.17 1.83 7 .41 8.41 6 14 18 2 16.59.59 6 11.17Z\' fill=\'%230A273D\'/%3E%3C/svg%3E");background-size:cover;background-repeat:no-repeat}:host([disabled]:not([disabled=false]))>#wrapper{color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><slot name="icon"></slot><span id="content"></span></div>';
9
+ const templateHTML = '<style>:host{display:block}*{pointer-events:none}#wrapper{display:flex;position:relative;box-sizing:border-box;height:40px;padding:6px 12px;width:100%;align-items:center;gap:12px;--sinch-size-icon:24px}#content{flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host(:hover)>#wrapper,:host([data-selected])>#wrapper{background-color:var(--sinch-color-snow-500)}:host([checked])>#wrapper{padding-right:36px}:host([checked])>#wrapper::after{content:"";position:absolute;top:10px;right:11px;width:18px;height:14px;background-image:url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\'%3E%3Cpath d=\'M6 11.17 1.83 7 .41 8.41 6 14 18 2 16.59.59 6 11.17Z\' fill=\'%230A273D\'/%3E%3C/svg%3E");background-size:cover;background-repeat:no-repeat}:host([disabled]:not([disabled=false]))>#wrapper{color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><slot name="icon"></slot><span id="content"></span></div>';
10
10
  const template = document.createElement('template');
11
11
  template.innerHTML = templateHTML;
12
12
 
@@ -1,7 +1,7 @@
1
1
  import '../tooltip';
2
2
  import '../icon/help-outline';
3
3
  import { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, updateAttribute, updateBooleanAttribute, updateIntegerAttribute } from '../utils';
4
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}sinch-tooltip{display:block}</style><sinch-tooltip><sinch-icon-help-outline size="18"></sinch-icon-help-outline></sinch-tooltip>';
4
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;--sinch-size-icon:18px}sinch-tooltip{display:block}</style><sinch-tooltip><sinch-icon-help-outline></sinch-icon-help-outline></sinch-tooltip>';
5
5
  const template = document.createElement('template');
6
6
  template.innerHTML = templateHTML;
7
7
  defineCustomElement('sinch-help-tooltip', class extends HTMLElement {
@@ -1,9 +1,7 @@
1
1
  export declare const createIconClass: (templateHTML: string) => {
2
2
  new (): {
3
3
  $svg: SVGElement;
4
- size: number;
5
4
  connectedCallback(): void;
6
- attributeChangedCallback(name: string, _: string | null, newVal: string | null): void;
7
5
  accessKey: string;
8
6
  readonly accessKeyLabel: string;
9
7
  autocapitalize: string;
@@ -304,5 +302,4 @@ export declare const createIconClass: (templateHTML: string) => {
304
302
  blur(): void;
305
303
  focus(options?: FocusOptions | undefined): void;
306
304
  };
307
- readonly observedAttributes: string[];
308
305
  };
@@ -1,8 +1,5 @@
1
- import { getIntegerAttribute, updateAttribute, updateIntegerAttribute } from '../utils';
2
- const iconStylesHtml = '<style>:host{display:inline-block;vertical-align:middle}svg{display:block;fill:var(--sinch-color-icon,--sinch-color-text-default)}</style>';
3
- const DEFAULT_SIZE = 24;
4
- const MIN_SIZE = 4;
5
- const MAX_SIZE = 256;
1
+ import { updateAttribute } from '../utils';
2
+ const iconStylesHtml = '<style>:host{display:inline-block;vertical-align:middle}svg{display:block;fill:var(--sinch-color-icon,--sinch-color-text-default);height:var(--sinch-size-icon,24px)}</style>';
6
3
  export const createIconClass = templateHTML => {
7
4
  const template = document.createElement('template');
8
5
  template.innerHTML = iconStylesHtml + templateHTML;
@@ -16,37 +13,8 @@ export const createIconClass = templateHTML => {
16
13
  this.$svg = shadowRoot.querySelector('svg');
17
14
  }
18
15
 
19
- static get observedAttributes() {
20
- return ['size'];
21
- }
22
-
23
- set size(value) {
24
- updateAttribute(this, 'size', value);
25
- }
26
-
27
- get size() {
28
- return getIntegerAttribute(this, 'size', DEFAULT_SIZE);
29
- }
30
-
31
16
  connectedCallback() {
32
17
  updateAttribute(this.$svg, 'preserveAspectRatio', 'xMinYMin meet');
33
-
34
- if (!this.hasAttribute('size')) {
35
- updateAttribute(this, 'size', DEFAULT_SIZE);
36
- }
37
- }
38
-
39
- attributeChangedCallback(name, _, newVal) {
40
- switch (name) {
41
- case 'size':
42
- {
43
- updateIntegerAttribute(this.$svg, 'height', newVal, {
44
- min: MIN_SIZE,
45
- max: MAX_SIZE
46
- });
47
- break;
48
- }
49
- }
50
18
  }
51
19
 
52
20
  };
@@ -0,0 +1,11 @@
1
+ import type { TSinchIconElement, TSinchIconReact } from '../types';
2
+ declare global {
3
+ namespace JSX {
4
+ interface IntrinsicElements {
5
+ 'sinch-icon-search': TSinchIconReact;
6
+ }
7
+ }
8
+ interface HTMLElementTagNameMap {
9
+ 'sinch-icon-search': TSinchIconElement;
10
+ }
11
+ }
@@ -0,0 +1,4 @@
1
+ import { defineCustomElement } from '../../utils';
2
+ import { createIconClass } from '../create-icon-class';
3
+ const templateHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 0 0 1.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 0 0-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 0 0 5.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14Zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14Z"/></svg>';
4
+ defineCustomElement('sinch-icon-search', createIconClass(templateHTML));
@@ -0,0 +1,24 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ import type { FocusEvent, MouseEvent } from 'react';
3
+ export declare type TSinchIconButtonElement = HTMLElement & {
4
+ disabled: boolean;
5
+ focus(): void;
6
+ blur(): void;
7
+ };
8
+ export declare type TSinchIconButtonReact = TSinchElementReact<TSinchIconButtonElement> & {
9
+ 'aria-label': string;
10
+ disabled?: boolean;
11
+ onClick: (e: MouseEvent<TSinchIconButtonElement>) => void;
12
+ onFocus?: (e: FocusEvent<TSinchIconButtonElement>) => void;
13
+ onBlur?: (e: FocusEvent<TSinchIconButtonElement>) => void;
14
+ };
15
+ declare global {
16
+ namespace JSX {
17
+ interface IntrinsicElements {
18
+ 'sinch-icon-button': TSinchIconButtonReact;
19
+ }
20
+ }
21
+ interface HTMLElementTagNameMap {
22
+ 'sinch-icon-button': TSinchIconButtonElement;
23
+ }
24
+ }
@@ -0,0 +1,66 @@
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, isAttrTrue, updateBooleanAttribute } from '../utils';
11
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}button{all:initial;display:flex;align-items:center;justify-content:center;box-sizing:border-box;width:48px;height:48px;border-radius:4px;background-color:transparent;box-shadow:0 0 0 1px transparent inset;cursor:pointer;--sinch-size-icon:24px;--sinch-color-icon:var(--sinch-color-stormy-500)}button:focus{box-shadow:0 0 0 1px var(--sinch-color-stormy-500) inset}button:hover{background-color:var(--sinch-color-snow-500)}button:active{background-color:var(--sinch-color-snow-600)}button:disabled{background-color:transparent;cursor:initial;--sinch-color-spinner-bg:var(--sinch-color-snow-200);--sinch-color-spinner-fg:var(--sinch-color-stormy-200);--sinch-color-icon:var(--sinch-color-stormy-100)}button>*{pointer-events:none}</style><button><slot name="icon"></slot></button>';
12
+ const template = document.createElement('template');
13
+ template.innerHTML = templateHTML;
14
+ defineCustomElement('sinch-icon-button', (_$button = new WeakMap(), class extends HTMLElement {
15
+ constructor() {
16
+ super();
17
+
18
+ _classPrivateFieldInitSpec(this, _$button, {
19
+ writable: true,
20
+ value: void 0
21
+ });
22
+
23
+ const shadowRoot = this.attachShadow({
24
+ mode: 'closed',
25
+ delegatesFocus: true
26
+ });
27
+ shadowRoot.appendChild(template.content.cloneNode(true));
28
+
29
+ _classPrivateFieldSet(this, _$button, shadowRoot.querySelector('button'));
30
+ }
31
+
32
+ connectedCallback() {
33
+ this.setAttribute('role', 'button');
34
+ }
35
+
36
+ static get observedAttributes() {
37
+ return ['disabled'];
38
+ }
39
+
40
+ attributeChangedCallback(name, _, newVal) {
41
+ switch (name) {
42
+ case 'disabled':
43
+ {
44
+ _classPrivateFieldGet(this, _$button).disabled = isAttrTrue(newVal);
45
+ break;
46
+ }
47
+ }
48
+ }
49
+
50
+ set disabled(isDisabled) {
51
+ updateBooleanAttribute(this, 'disabled', isDisabled);
52
+ }
53
+
54
+ get disabled() {
55
+ return getBooleanAttribute(this, 'disabled');
56
+ }
57
+
58
+ focus() {
59
+ _classPrivateFieldGet(this, _$button).focus();
60
+ }
61
+
62
+ blur() {
63
+ _classPrivateFieldGet(this, _$button).blur();
64
+ }
65
+
66
+ }));
package/index.d.ts CHANGED
@@ -48,6 +48,7 @@ import './icon/north';
48
48
  import './icon/north-east';
49
49
  import './icon/north-west';
50
50
  import './icon/open-in-new';
51
+ import './icon/search';
51
52
  import './icon/south';
52
53
  import './icon/south-east';
53
54
  import './icon/south-west';
@@ -78,3 +79,6 @@ import './icon-branded/users';
78
79
  import './dialog';
79
80
  import './grid';
80
81
  import './grid-item';
82
+ import './icon-button';
83
+ import './search';
84
+ import './search-option';
package/index.js CHANGED
@@ -48,6 +48,7 @@ import './icon/north';
48
48
  import './icon/north-east';
49
49
  import './icon/north-west';
50
50
  import './icon/open-in-new';
51
+ import './icon/search';
51
52
  import './icon/south';
52
53
  import './icon/south-east';
53
54
  import './icon/south-west';
@@ -77,4 +78,7 @@ import './icon-branded/user';
77
78
  import './icon-branded/users';
78
79
  import './dialog';
79
80
  import './grid';
80
- import './grid-item';
81
+ import './grid-item';
82
+ import './icon-button';
83
+ import './search';
84
+ import './search-option';
package/input/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import type { TSinchElementReact } from '../types';
2
2
  import type { DOMAttributes, FocusEvent, SyntheticEvent } from 'react';
3
+ declare const inputTypes: readonly ["text", "password"];
4
+ export declare type TTextInputType = typeof inputTypes[number];
3
5
  export declare type TSinchInputElement = HTMLElement & {
6
+ type: TTextInputType;
4
7
  value: string;
5
8
  label: string;
6
9
  placeholder: string | null;
@@ -12,6 +15,7 @@ export declare type TSinchInputElement = HTMLElement & {
12
15
  blur(): void;
13
16
  };
14
17
  export declare type TSinchInputReact = TSinchElementReact<TSinchInputElement> & {
18
+ type?: TTextInputType;
15
19
  value: string;
16
20
  label: string;
17
21
  placeholder?: string;
@@ -35,3 +39,4 @@ declare global {
35
39
  'sinch-input': TSinchInputElement;
36
40
  }
37
41
  }
42
+ export {};
package/input/index.js CHANGED
@@ -7,8 +7,9 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
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, isAttrTrue, updateAttribute, updateBooleanAttribute } 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%;height:48px;margin:2px 0;padding:0 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto)}#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([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-4);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><input id="input" type="text"/><div id="bottom"><span id="invalid"></span> <span id="additional"></span></div></div>';
10
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } 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%;height:48px;margin:2px 0;padding:0 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto)}#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)}#input[type=password]{font-size:1.5em;letter-spacing:.1em}: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-4);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><input id="input" type="text"/><div id="bottom"><span id="invalid"></span> <span id="additional"></span></div></div>';
12
+ const inputTypes = ['text', 'password'];
12
13
  const template = document.createElement('template');
13
14
  template.innerHTML = templateHTML;
14
15
  defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _selectionStart = new WeakMap(), _selectionEnd = new WeakMap(), _onInput = new WeakMap(), class extends HTMLElement {
@@ -115,17 +116,21 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
115
116
  }
116
117
 
117
118
  static get observedAttributes() {
118
- return ['value', 'placeholder', 'label', 'optionaltext', 'additionaltext', 'invalidtext', 'disabled'];
119
- }
120
-
121
- get type() {
122
- return 'text';
119
+ return ['type', 'value', 'placeholder', 'label', 'optionaltext', 'additionaltext', 'invalidtext', 'disabled'];
123
120
  }
124
121
 
125
122
  get nodeName() {
126
123
  return 'input';
127
124
  }
128
125
 
126
+ set type(value) {
127
+ updateAttribute(this, 'type', value);
128
+ }
129
+
130
+ get type() {
131
+ return getLiteralAttribute(this, inputTypes, 'type', 'text');
132
+ }
133
+
129
134
  set value(value) {
130
135
  updateAttribute(this, 'value', value);
131
136
  }
@@ -184,6 +189,12 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
184
189
 
185
190
  attributeChangedCallback(name, _, newVal) {
186
191
  switch (name) {
192
+ case 'type':
193
+ {
194
+ updateLiteralAttribute(_classPrivateFieldGet(this, _$input), inputTypes, 'type', newVal);
195
+ break;
196
+ }
197
+
187
198
  case 'value':
188
199
  {
189
200
  const nextVal = newVal ?? '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "files": [
5
5
  "theme.css",
6
6
  "**/*/*.js",
@@ -0,0 +1,34 @@
1
+ import '../icon/search';
2
+ import '../icon/close';
3
+ import type { TRect, TSinchElementReact } from '../types';
4
+ import type { FocusEvent, SyntheticEvent } from 'react';
5
+ export declare type TSinchSearchElement = HTMLElement & {
6
+ value: string;
7
+ label: string | null;
8
+ placeholder: string | null;
9
+ maxVisibleItems: number | null;
10
+ readonly dropdownRect: TRect;
11
+ focus(): void;
12
+ blur(): void;
13
+ };
14
+ export declare type TSinchSearchReact = TSinchElementReact<TSinchSearchElement> & {
15
+ value: string;
16
+ label?: string;
17
+ placeholder?: string;
18
+ maxVisibleItems?: number;
19
+ 'aria-label': string;
20
+ 'clear-aria-label': string;
21
+ onChange: (e: SyntheticEvent<TSinchSearchElement, CustomEvent<string>>) => void;
22
+ onFocus?: (e: FocusEvent<TSinchSearchElement>) => void;
23
+ onBlur?: (e: FocusEvent<TSinchSearchElement>) => void;
24
+ };
25
+ declare global {
26
+ namespace JSX {
27
+ interface IntrinsicElements {
28
+ 'sinch-search': TSinchSearchReact;
29
+ }
30
+ }
31
+ interface HTMLElementTagNameMap {
32
+ 'sinch-search': TSinchSearchElement;
33
+ }
34
+ }
@@ -0,0 +1,470 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
+
4
+ var _$label, _$input, _selectionStart, _selectionEnd, _$optionSlot, _$listbox, _$clear, _onInput, _onValueChange, _onClearMouseDown, _onClear, _onInputFocus, _onInputBlur, _onListboxClick, _onListboxKeyPress, _onListboxKeyDown, _onOptionSlotChange, _onExpand, _onCollapse, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _selectOption, _getOptionElements;
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 { isSearchOptionElement } from '../search-option';
15
+ import { attrValueToPixels, defineCustomElement, getAttribute, getIntegerAttribute, getRect, updateAttribute, updateIntegerAttribute } from '../utils';
16
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:100%;box-sizing:border-box;--sinch-size-icon:24px}#label{display:none;font:var(--sinch-font-title-4);color:var(--sinch-color-text-default);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%;height:24px;margin-bottom:2px}#input{all:initial;display:block;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:4px;width:100%;height:48px;padding:0 44px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto)}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#input:focus{border-color:var(--sinch-color-stormy-600)}#icon-search{position:absolute;left:12px;top:12px;pointer-events:none;--sinch-color-icon:var(--sinch-color-stormy-500)}#clear{all:initial;position:absolute;right:8px;top:8px;width:32px;height:32px;display:flex;align-items:center;justify-content:center;cursor:pointer;--sinch-color-icon:var(--sinch-color-stormy-300)}#clear:focus{--sinch-color-icon:var(--sinch-color-stormy-500)}:host([value=""]) #clear{display:none}:host([value=""]) #input{padding-right:12px}#listbox{display:none;position:absolute;z-index:1;left:0;top:calc(100% + 8px);width:100%;box-sizing:border-box;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);box-shadow:1px 2px 4px rgb(0 0 0 / 15%);overflow-y:auto;contain:content}:host([aria-expanded=true]) #listbox{display:block}:host([label]:not([label=""])) #label{display:block}</style><label id="label" for="input"></label><div id="wrapper"><input id="input" type="text"/><sinch-icon-search id="icon-search"></sinch-icon-search><button id="clear"><sinch-icon-close id="icon-close"></sinch-icon-close></button><div id="listbox"><slot name="option"></slot></div></div>';
17
+ import '../icon/search';
18
+ import '../icon/close';
19
+ const ITEM_HEIGHT = 40;
20
+
21
+ const findSelectedOption = elements => {
22
+ for (const el of elements) {
23
+ if (el.selected) {
24
+ return el;
25
+ }
26
+ }
27
+
28
+ return null;
29
+ };
30
+
31
+ const template = document.createElement('template');
32
+ template.innerHTML = templateHTML;
33
+ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new WeakMap(), _selectionStart = new WeakMap(), _selectionEnd = new WeakMap(), _$optionSlot = new WeakMap(), _$listbox = new WeakMap(), _$clear = new WeakMap(), _onInput = new WeakMap(), _onValueChange = new WeakSet(), _onClearMouseDown = new WeakMap(), _onClear = new WeakMap(), _onInputFocus = new WeakMap(), _onInputBlur = new WeakMap(), _onListboxClick = new WeakMap(), _onListboxKeyPress = new WeakMap(), _onListboxKeyDown = new WeakMap(), _onOptionSlotChange = new WeakMap(), _onExpand = new WeakSet(), _onCollapse = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _selectOption = new WeakSet(), _getOptionElements = new WeakSet(), class extends HTMLElement {
34
+ constructor() {
35
+ super();
36
+
37
+ _classPrivateMethodInitSpec(this, _getOptionElements);
38
+
39
+ _classPrivateMethodInitSpec(this, _selectOption);
40
+
41
+ _classPrivateMethodInitSpec(this, _getPrevOption);
42
+
43
+ _classPrivateMethodInitSpec(this, _getNextOption);
44
+
45
+ _classPrivateMethodInitSpec(this, _getLastOption);
46
+
47
+ _classPrivateMethodInitSpec(this, _getFirstOption);
48
+
49
+ _classPrivateMethodInitSpec(this, _onCollapse);
50
+
51
+ _classPrivateMethodInitSpec(this, _onExpand);
52
+
53
+ _classPrivateMethodInitSpec(this, _onValueChange);
54
+
55
+ _classPrivateFieldInitSpec(this, _$label, {
56
+ writable: true,
57
+ value: void 0
58
+ });
59
+
60
+ _classPrivateFieldInitSpec(this, _$input, {
61
+ writable: true,
62
+ value: void 0
63
+ });
64
+
65
+ _classPrivateFieldInitSpec(this, _selectionStart, {
66
+ writable: true,
67
+ value: null
68
+ });
69
+
70
+ _classPrivateFieldInitSpec(this, _selectionEnd, {
71
+ writable: true,
72
+ value: null
73
+ });
74
+
75
+ _classPrivateFieldInitSpec(this, _$optionSlot, {
76
+ writable: true,
77
+ value: void 0
78
+ });
79
+
80
+ _classPrivateFieldInitSpec(this, _$listbox, {
81
+ writable: true,
82
+ value: void 0
83
+ });
84
+
85
+ _classPrivateFieldInitSpec(this, _$clear, {
86
+ writable: true,
87
+ value: void 0
88
+ });
89
+
90
+ _classPrivateFieldInitSpec(this, _onInput, {
91
+ writable: true,
92
+ value: e => {
93
+ e.stopPropagation();
94
+
95
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, _classPrivateFieldGet(this, _$input).value, true);
96
+ }
97
+ });
98
+
99
+ _classPrivateFieldInitSpec(this, _onClearMouseDown, {
100
+ writable: true,
101
+ value: e => {
102
+ e.preventDefault();
103
+ }
104
+ });
105
+
106
+ _classPrivateFieldInitSpec(this, _onClear, {
107
+ writable: true,
108
+ value: e => {
109
+ e.stopPropagation();
110
+
111
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, '');
112
+
113
+ _classPrivateFieldGet(this, _$input).focus();
114
+ }
115
+ });
116
+
117
+ _classPrivateFieldInitSpec(this, _onInputFocus, {
118
+ writable: true,
119
+ value: () => {
120
+ _classPrivateMethodGet(this, _onExpand, _onExpand2).call(this);
121
+ }
122
+ });
123
+
124
+ _classPrivateFieldInitSpec(this, _onInputBlur, {
125
+ writable: true,
126
+ value: () => {
127
+ _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
128
+ }
129
+ });
130
+
131
+ _classPrivateFieldInitSpec(this, _onListboxClick, {
132
+ writable: true,
133
+ value: e => {
134
+ e.stopPropagation();
135
+ const $elem = e.target;
136
+
137
+ if (isSearchOptionElement($elem)) {
138
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, $elem.text);
139
+ }
140
+
141
+ _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
142
+ }
143
+ });
144
+
145
+ _classPrivateFieldInitSpec(this, _onListboxKeyPress, {
146
+ writable: true,
147
+ value: e => {
148
+ switch (e.code) {
149
+ case 'Enter':
150
+ {
151
+ e.preventDefault();
152
+ const $elem = findSelectedOption(_classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this));
153
+
154
+ if ($elem != null) {
155
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, $elem.text);
156
+ }
157
+
158
+ _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
159
+
160
+ break;
161
+ }
162
+ }
163
+ }
164
+ });
165
+
166
+ _classPrivateFieldInitSpec(this, _onListboxKeyDown, {
167
+ writable: true,
168
+ value: e => {
169
+ switch (e.code) {
170
+ case 'ArrowUp':
171
+ {
172
+ e.preventDefault();
173
+
174
+ _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getPrevOption, _getPrevOption2).call(this));
175
+
176
+ break;
177
+ }
178
+
179
+ case 'ArrowDown':
180
+ {
181
+ e.preventDefault();
182
+
183
+ _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getNextOption, _getNextOption2).call(this));
184
+
185
+ break;
186
+ }
187
+
188
+ case 'Escape':
189
+ {
190
+ e.preventDefault();
191
+
192
+ _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
193
+
194
+ break;
195
+ }
196
+ }
197
+ }
198
+ });
199
+
200
+ _classPrivateFieldInitSpec(this, _onOptionSlotChange, {
201
+ writable: true,
202
+ value: () => {
203
+ _classPrivateMethodGet(this, _onExpand, _onExpand2).call(this);
204
+ }
205
+ });
206
+
207
+ const shadowRoot = this.attachShadow({
208
+ mode: 'closed',
209
+ delegatesFocus: true
210
+ });
211
+ shadowRoot.appendChild(template.content.cloneNode(true));
212
+
213
+ _classPrivateFieldSet(this, _$input, shadowRoot.querySelector('#input'));
214
+
215
+ _classPrivateFieldSet(this, _$label, shadowRoot.querySelector('#label'));
216
+
217
+ _classPrivateFieldSet(this, _$listbox, shadowRoot.querySelector('#listbox'));
218
+
219
+ _classPrivateFieldSet(this, _$optionSlot, shadowRoot.querySelector('slot[name="option"]'));
220
+
221
+ _classPrivateFieldSet(this, _$clear, shadowRoot.querySelector('#clear'));
222
+ }
223
+
224
+ connectedCallback() {
225
+ this.setAttribute('role', 'listbox');
226
+ this.setAttribute('autocomplete', 'off');
227
+ this.setAttribute('aria-expanded', 'false');
228
+
229
+ _classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onInput));
230
+
231
+ _classPrivateFieldGet(this, _$input).addEventListener('focus', _classPrivateFieldGet(this, _onInputFocus));
232
+
233
+ _classPrivateFieldGet(this, _$input).addEventListener('blur', _classPrivateFieldGet(this, _onInputBlur));
234
+
235
+ _classPrivateFieldGet(this, _$input).addEventListener('keydown', _classPrivateFieldGet(this, _onListboxKeyDown));
236
+
237
+ _classPrivateFieldGet(this, _$input).addEventListener('keypress', _classPrivateFieldGet(this, _onListboxKeyPress));
238
+
239
+ _classPrivateFieldGet(this, _$listbox).addEventListener('click', _classPrivateFieldGet(this, _onListboxClick));
240
+
241
+ _classPrivateFieldGet(this, _$optionSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onOptionSlotChange));
242
+
243
+ _classPrivateFieldGet(this, _$clear).addEventListener('mousedown', _classPrivateFieldGet(this, _onClearMouseDown));
244
+
245
+ _classPrivateFieldGet(this, _$clear).addEventListener('click', _classPrivateFieldGet(this, _onClear));
246
+ }
247
+
248
+ disconnectedCallback() {
249
+ _classPrivateFieldGet(this, _$input).removeEventListener('input', _classPrivateFieldGet(this, _onInput));
250
+
251
+ _classPrivateFieldGet(this, _$input).removeEventListener('focus', _classPrivateFieldGet(this, _onInputFocus));
252
+
253
+ _classPrivateFieldGet(this, _$input).removeEventListener('blur', _classPrivateFieldGet(this, _onInputBlur));
254
+
255
+ _classPrivateFieldGet(this, _$input).removeEventListener('keydown', _classPrivateFieldGet(this, _onListboxKeyDown));
256
+
257
+ _classPrivateFieldGet(this, _$input).removeEventListener('keypress', _classPrivateFieldGet(this, _onListboxKeyPress));
258
+
259
+ _classPrivateFieldGet(this, _$listbox).removeEventListener('click', _classPrivateFieldGet(this, _onListboxClick));
260
+
261
+ _classPrivateFieldGet(this, _$optionSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onOptionSlotChange));
262
+
263
+ _classPrivateFieldGet(this, _$clear).removeEventListener('mousedown', _classPrivateFieldGet(this, _onClearMouseDown));
264
+
265
+ _classPrivateFieldGet(this, _$clear).removeEventListener('click', _classPrivateFieldGet(this, _onClear));
266
+ }
267
+
268
+ static get observedAttributes() {
269
+ return ['label', 'value', 'placeholder', 'maxvisibleitems', 'clear-aria-label'];
270
+ }
271
+
272
+ get type() {
273
+ return 'text';
274
+ }
275
+
276
+ get nodeName() {
277
+ return 'input';
278
+ }
279
+
280
+ set value(value) {
281
+ updateAttribute(this, 'value', value);
282
+ }
283
+
284
+ get value() {
285
+ return getAttribute(this, 'value', '');
286
+ }
287
+
288
+ set placeholder(value) {
289
+ updateAttribute(this, 'placeholder', value);
290
+ }
291
+
292
+ get placeholder() {
293
+ return getAttribute(this, 'placeholder', null);
294
+ }
295
+
296
+ set label(value) {
297
+ updateAttribute(this, 'label', value);
298
+ }
299
+
300
+ get label() {
301
+ return getAttribute(this, 'label', null);
302
+ }
303
+
304
+ set maxVisibleItems(value) {
305
+ updateIntegerAttribute(this, 'maxvisibleitems', value);
306
+ }
307
+
308
+ get maxVisibleItems() {
309
+ return getIntegerAttribute(this, 'maxvisibleitems', null);
310
+ }
311
+
312
+ get dropdownRect() {
313
+ return getRect(_classPrivateFieldGet(this, _$listbox));
314
+ }
315
+
316
+ attributeChangedCallback(name, oldVal, newVal) {
317
+ switch (name) {
318
+ case 'value':
319
+ {
320
+ const nextVal = newVal ?? '';
321
+
322
+ if (nextVal !== _classPrivateFieldGet(this, _$input).value) {
323
+ _classPrivateFieldGet(this, _$input).value = nextVal;
324
+ const isNextCursorEnd = _classPrivateFieldGet(this, _selectionStart) === null || _classPrivateFieldGet(this, _selectionStart) === nextVal.length;
325
+
326
+ if (!isNextCursorEnd) {
327
+ _classPrivateFieldGet(this, _$input).setSelectionRange(_classPrivateFieldGet(this, _selectionStart), _classPrivateFieldGet(this, _selectionEnd));
328
+ }
329
+ }
330
+
331
+ break;
332
+ }
333
+
334
+ case 'label':
335
+ {
336
+ _classPrivateFieldGet(this, _$label).textContent = newVal;
337
+ break;
338
+ }
339
+
340
+ case 'placeholder':
341
+ {
342
+ _classPrivateFieldGet(this, _$input).placeholder = newVal ?? '';
343
+ updateAttribute(this, 'aria-placeholder', newVal);
344
+ break;
345
+ }
346
+
347
+ case 'maxvisibleitems':
348
+ {
349
+ _classPrivateFieldGet(this, _$listbox).style.maxHeight = attrValueToPixels(newVal, {
350
+ min: 2,
351
+ multiplier: ITEM_HEIGHT
352
+ });
353
+ break;
354
+ }
355
+
356
+ case 'clear-aria-label':
357
+ {
358
+ updateAttribute(_classPrivateFieldGet(this, _$clear), 'aria-label', newVal);
359
+ }
360
+ }
361
+ }
362
+
363
+ focus() {
364
+ _classPrivateFieldGet(this, _$input).focus();
365
+ }
366
+
367
+ blur() {
368
+ _classPrivateFieldGet(this, _$input).blur();
369
+ }
370
+
371
+ }));
372
+
373
+ function _onValueChange2(nextValue) {
374
+ let preserveCursorPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
375
+ const prevValue = this.value;
376
+
377
+ if (prevValue !== nextValue) {
378
+ const nextSelectionStart = preserveCursorPosition ? _classPrivateFieldGet(this, _$input).selectionStart : nextValue.length;
379
+ const nextSelectionEnd = preserveCursorPosition ? _classPrivateFieldGet(this, _$input).selectionEnd : nextValue.length;
380
+
381
+ const prevSelectionStart = _classPrivateFieldGet(this, _selectionStart);
382
+
383
+ const prevSelectionEnd = _classPrivateFieldGet(this, _selectionEnd);
384
+
385
+ const isPrevCursorEnd = prevSelectionStart === prevSelectionEnd && prevSelectionStart === prevValue.length;
386
+ _classPrivateFieldGet(this, _$input).value = prevValue;
387
+
388
+ if (!isPrevCursorEnd) {
389
+ _classPrivateFieldGet(this, _$input).setSelectionRange(prevSelectionStart, prevSelectionEnd);
390
+ }
391
+
392
+ _classPrivateFieldSet(this, _selectionStart, nextSelectionStart);
393
+
394
+ _classPrivateFieldSet(this, _selectionEnd, nextSelectionEnd);
395
+
396
+ this.dispatchEvent(new CustomEvent('change', {
397
+ detail: nextValue,
398
+ bubbles: true
399
+ }));
400
+ }
401
+ }
402
+
403
+ function _onExpand2() {
404
+ const elems = _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this);
405
+
406
+ if (elems.length === 0 || document.activeElement !== this) {
407
+ _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
408
+
409
+ return;
410
+ }
411
+
412
+ this.setAttribute('aria-expanded', 'true');
413
+
414
+ _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, elems[0]);
415
+ }
416
+
417
+ function _onCollapse2() {
418
+ this.setAttribute('aria-expanded', 'false');
419
+ }
420
+
421
+ function _getFirstOption2() {
422
+ return _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this)[0] ?? null;
423
+ }
424
+
425
+ function _getLastOption2() {
426
+ return _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this).reverse()[0] ?? null;
427
+ }
428
+
429
+ function _getNextOption2() {
430
+ const $options = _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this);
431
+
432
+ const $selectedOption = findSelectedOption($options);
433
+ const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
434
+
435
+ if (currentIndex < 0) {
436
+ return _classPrivateMethodGet(this, _getFirstOption, _getFirstOption2).call(this);
437
+ }
438
+
439
+ return $options[(currentIndex + 1) % $options.length];
440
+ }
441
+
442
+ function _getPrevOption2() {
443
+ const $options = _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this);
444
+
445
+ const $selectedOption = findSelectedOption($options);
446
+ const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
447
+
448
+ if (currentIndex < 0) {
449
+ return _classPrivateMethodGet(this, _getLastOption, _getLastOption2).call(this);
450
+ }
451
+
452
+ return $options[(currentIndex - 1 + $options.length) % $options.length];
453
+ }
454
+
455
+ function _selectOption2($option) {
456
+ for (const $op of _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this)) {
457
+ const isSelected = $op === $option;
458
+ $op.selected = isSelected;
459
+
460
+ if (isSelected) {
461
+ $op.scrollIntoView?.({
462
+ block: 'nearest'
463
+ });
464
+ }
465
+ }
466
+ }
467
+
468
+ function _getOptionElements2() {
469
+ return _classPrivateFieldGet(this, _$optionSlot).assignedElements().filter(isSearchOptionElement);
470
+ }
@@ -0,0 +1,20 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ export declare const isSearchOptionElement: (element: EventTarget | Element | null) => element is TSinchSearchOptionElement;
3
+ export declare type TSinchSearchOptionElement = HTMLElement & {
4
+ text: string;
5
+ selected: boolean;
6
+ };
7
+ export declare type TSinchSearchOptionReact = TSinchElementReact<TSinchSearchOptionElement> & {
8
+ text: string;
9
+ 'aria-label': string;
10
+ };
11
+ declare global {
12
+ namespace JSX {
13
+ interface IntrinsicElements {
14
+ 'sinch-search-option': TSinchSearchOptionReact;
15
+ }
16
+ }
17
+ interface HTMLElementTagNameMap {
18
+ 'sinch-search-option': TSinchSearchOptionElement;
19
+ }
20
+ }
@@ -0,0 +1,76 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
+
4
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
5
+
6
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
7
+
8
+ import { defineCustomElement, getAttribute, getBooleanAttribute, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
9
+ const templateHTML = '<style>:host{display:block}#wrapper{display:block;box-sizing:border-box;line-height:40px;padding:0 12px;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host(:hover)>#wrapper,:host([data-selected])>#wrapper{background-color:var(--sinch-color-snow-500)}</style><div id="wrapper"></div>';
10
+ const template = document.createElement('template');
11
+ template.innerHTML = templateHTML;
12
+
13
+ var _$content = new WeakMap();
14
+
15
+ class SearchOption extends HTMLElement {
16
+ constructor() {
17
+ super();
18
+
19
+ _classPrivateFieldInitSpec(this, _$content, {
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+
24
+ const shadowRoot = this.attachShadow({
25
+ mode: 'closed'
26
+ });
27
+ shadowRoot.appendChild(template.content.cloneNode(true));
28
+
29
+ _classPrivateFieldSet(this, _$content, shadowRoot.querySelector('#wrapper'));
30
+ }
31
+
32
+ connectedCallback() {
33
+ this.setAttribute('role', 'option');
34
+ }
35
+
36
+ static get observedAttributes() {
37
+ return ['text'];
38
+ }
39
+
40
+ attributeChangedCallback(name, oldVal, newVal) {
41
+ if (oldVal === newVal) {
42
+ return;
43
+ }
44
+
45
+ switch (name) {
46
+ case 'text':
47
+ {
48
+ _classPrivateFieldGet(this, _$content).textContent = newVal;
49
+ break;
50
+ }
51
+ }
52
+ }
53
+
54
+ set text(value) {
55
+ updateAttribute(this, 'text', value);
56
+ }
57
+
58
+ get text() {
59
+ return getAttribute(this, 'text', '');
60
+ }
61
+
62
+ set selected(isSelected) {
63
+ updateBooleanAttribute(this, 'data-selected', isSelected);
64
+ updateExplicitBooleanAttribute(this, 'aria-selected', isSelected);
65
+ }
66
+
67
+ get selected() {
68
+ return getBooleanAttribute(this, 'data-selected');
69
+ }
70
+
71
+ }
72
+
73
+ defineCustomElement('sinch-search-option', SearchOption);
74
+ export const isSearchOptionElement = element => {
75
+ return element instanceof SearchOption;
76
+ };
@@ -11,7 +11,7 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
11
11
  import '../icon/north';
12
12
  import '../icon/south';
13
13
  import { defineCustomElement, getBooleanAttribute, isAttrTrue, updateBooleanAttribute } from '../utils';
14
- const templateHTML = '<style>:host{display:contents}input{all:initial;position:absolute;width:100%;height:100%;box-sizing:border-box;cursor:pointer}#up{display:none}#down{display:block}:host([value]:not([value=false])) #up{display:block}:host([value]:not([value=false])) #down{display:none}</style><sinch-icon-north id="up" size="16"></sinch-icon-north><sinch-icon-south id="down" size="16"></sinch-icon-south><input type="checkbox"/>';
14
+ const templateHTML = '<style>:host{display:contents;--sinch-size-icon:16px}input{all:initial;position:absolute;width:100%;height:100%;box-sizing:border-box;cursor:pointer}#up{display:none}#down{display:block}:host([value]:not([value=false])) #up{display:block}:host([value]:not([value=false])) #down{display:none}</style><sinch-icon-north id="up"></sinch-icon-north><sinch-icon-south id="down"></sinch-icon-south><input type="checkbox"/>';
15
15
  const template = document.createElement('template');
16
16
  template.innerHTML = templateHTML;
17
17
  defineCustomElement('sinch-table-head-sort', (_$input = new WeakMap(), class extends HTMLElement {
@@ -7,7 +7,7 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
7
7
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
8
8
 
9
9
  import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute } from '../utils';
10
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}*{pointer-events:none}#wrapper{display:flex;flex-direction:row;align-items:center;gap:12px;position:relative;width:100%;height:42px;padding:8px 20px;box-sizing:border-box;box-shadow:0 1px 0 0 var(--sinch-color-stormy-100);color:var(--sinch-color-stormy-500);--sinch-color-icon:var(--sinch-color-stormy-500)}#content{font:var(--sinch-font-title-4);flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host([checked]) #wrapper{box-shadow:0 2px 0 0 var(--sinch-color-stormy-500)}input{all:initial;position:absolute;left:0;top:0;box-sizing:border-box;width:100%;height:100%;cursor:pointer}:host([disabled]:not([disabled=false])) #wrapper{color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}input:disabled{cursor:unset}</style><div id="wrapper"><slot name="icon"></slot><label for="input" id="content" aria-hidden="true"></label> <input id="input" type="radio" aria-hidden="true"/></div>';
10
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}*{pointer-events:none}#wrapper{display:flex;flex-direction:row;align-items:center;gap:12px;position:relative;width:100%;height:42px;padding:8px 20px;box-sizing:border-box;box-shadow:0 1px 0 0 var(--sinch-color-stormy-100);color:var(--sinch-color-stormy-500);--sinch-color-icon:var(--sinch-color-stormy-500);--sinch-size-icon:16px}#content{font:var(--sinch-font-title-4);flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host([checked]) #wrapper{box-shadow:0 2px 0 0 var(--sinch-color-stormy-500)}input{all:initial;position:absolute;left:0;top:0;box-sizing:border-box;width:100%;height:100%;cursor:pointer}:host([disabled]:not([disabled=false])) #wrapper{color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}input:disabled{cursor:unset}</style><div id="wrapper"><slot name="icon"></slot><label for="input" id="content" aria-hidden="true"></label> <input id="input" type="radio" aria-hidden="true"/></div>';
11
11
  export const isTabsOptionElement = element => {
12
12
  return element instanceof Element && element.tagName === 'SINCH-TABS-OPTION';
13
13
  };
package/tag/index.js CHANGED
@@ -9,7 +9,7 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
9
9
 
10
10
  import '../icon/cancel';
11
11
  import { defineCustomElement, getBooleanAttribute, getAttribute, getLiteralAttribute, updateBooleanAttribute, updateAttribute, updateLiteralAttribute } 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)}: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}#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{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>';
13
13
  const categoryValues = ['candy', 'bolt', 'aqua', 'grass', 'berry', 'orange', 'night', 'mud', 'dirt'];
14
14
  const template = document.createElement('template');
15
15
  template.innerHTML = templateHTML;
@@ -2,12 +2,10 @@ import '../icon/cancel';
2
2
  import type { TSinchElementReact } from '../types';
3
3
  import type { FocusEvent, MouseEvent } from 'react';
4
4
  export declare type TSinchTagCloseElement = HTMLElement & {
5
- small: boolean;
6
5
  focus(): void;
7
6
  blur(): void;
8
7
  };
9
8
  export declare type TSinchTagCloseReact = TSinchElementReact<TSinchTagCloseElement> & {
10
- small?: boolean;
11
9
  onClick?: (e: MouseEvent<TSinchTagCloseElement>) => void;
12
10
  onFocus?: (e: FocusEvent<TSinchTagCloseElement>) => void;
13
11
  onBlur?: (e: FocusEvent<TSinchTagCloseElement>) => void;
@@ -1,26 +1,21 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$icon, _$button;
4
+ var _$button;
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 '../icon/cancel';
11
- import { defineCustomElement, getBooleanAttribute, updateAttribute, isAttrTrue } from '../utils';
12
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:14px;height:14px}:host([small]:not([small=false])) #wrapper{width:12px;height:12px}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>';
11
+ import { defineCustomElement } 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>';
13
13
  const template = document.createElement('template');
14
14
  template.innerHTML = templateHTML;
15
- defineCustomElement('sinch-tag-close', (_$icon = new WeakMap(), _$button = new WeakMap(), class extends HTMLElement {
15
+ defineCustomElement('sinch-tag-close', (_$button = new WeakMap(), class extends HTMLElement {
16
16
  constructor() {
17
17
  super();
18
18
 
19
- _classPrivateFieldInitSpec(this, _$icon, {
20
- writable: true,
21
- value: void 0
22
- });
23
-
24
19
  _classPrivateFieldInitSpec(this, _$button, {
25
20
  writable: true,
26
21
  value: void 0
@@ -32,33 +27,9 @@ defineCustomElement('sinch-tag-close', (_$icon = new WeakMap(), _$button = new W
32
27
  });
33
28
  shadowRoot.appendChild(template.content.cloneNode(true));
34
29
 
35
- _classPrivateFieldSet(this, _$icon, shadowRoot.querySelector('sinch-icon-cancel'));
36
-
37
30
  _classPrivateFieldSet(this, _$button, shadowRoot.querySelector('button'));
38
31
  }
39
32
 
40
- get small() {
41
- return getBooleanAttribute(this, 'small');
42
- }
43
-
44
- set small(isSmall) {
45
- updateAttribute(this, 'small', isSmall);
46
- }
47
-
48
- static get observedAttributes() {
49
- return ['small'];
50
- }
51
-
52
- attributeChangedCallback(name, _, newVal) {
53
- switch (name) {
54
- case 'small':
55
- {
56
- updateAttribute(_classPrivateFieldGet(this, _$icon), 'size', isAttrTrue(newVal) ? 12 : 14);
57
- break;
58
- }
59
- }
60
- }
61
-
62
33
  focus() {
63
34
  _classPrivateFieldGet(this, _$button).focus();
64
35
  }
package/utils.d.ts CHANGED
@@ -3,6 +3,7 @@ export declare const defineCustomElement: (name: string, constructor: CustomElem
3
3
  export declare const defineNectaryElements: (registry: CustomElementRegistry) => void;
4
4
  export declare type TEventHandler = (arg?: any) => void;
5
5
  export declare const updateBooleanAttribute: ($element: Element, attrName: string, attrValue: boolean | null | undefined) => void;
6
+ export declare const updateExplicitBooleanAttribute: ($element: Element, attrName: string, attrValue: boolean | null | undefined) => void;
6
7
  export declare const isAttrTrue: (attrValue: string | null) => boolean;
7
8
  export declare const getBooleanAttribute: ($element: Element, attrName: string) => boolean;
8
9
  export declare const updateAttribute: ($element: Element, attrName: string, attrValue: string | number | boolean | null | undefined) => void;
@@ -10,7 +11,7 @@ export declare function getAttribute($element: Element, attrName: string): strin
10
11
  export declare function getAttribute($element: Element, attrName: string, defaultValue: null): string | null;
11
12
  export declare function getAttribute($element: Element, attrName: string, defaultValue: string): string;
12
13
  export declare const isLiteralValue: <T extends readonly string[]>(literals: T, value: string | null | undefined) => value is T[number];
13
- export declare const updateLiteralAttribute: <T extends readonly string[]>($element: Element, literals: T, attrName: string, attrValue: T[number] | null | undefined) => void;
14
+ export declare const updateLiteralAttribute: <T extends readonly string[]>($element: Element, literals: T, attrName: string, attrValue: string | null | undefined) => void;
14
15
  export declare function getLiteralAttribute<T extends readonly string[]>($element: Element, literals: T, attrName: string): T[number] | undefined;
15
16
  export declare function getLiteralAttribute<T extends readonly string[]>($element: Element, literals: T, attrName: string, defaultValue: null): T[number] | null;
16
17
  export declare function getLiteralAttribute<T extends readonly string[]>($element: Element, literals: T, attrName: string, defaultValue: T[number]): T[number];
package/utils.js CHANGED
@@ -35,6 +35,9 @@ export const updateBooleanAttribute = ($element, attrName, attrValue) => {
35
35
  $element.removeAttribute(attrName);
36
36
  }
37
37
  };
38
+ export const updateExplicitBooleanAttribute = ($element, attrName, attrValue) => {
39
+ $element.setAttribute(attrName, attrValue === true ? 'true' : 'false');
40
+ };
38
41
  export const isAttrTrue = attrValue => {
39
42
  return attrValue === '' || attrValue !== 'false' && attrValue !== null;
40
43
  };