@nectary/components 0.33.0 → 0.34.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.
package/dialog/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import '../icon-button';
2
2
  import '../icons/close';
3
+ import '../stop-events';
3
4
  import type { TSinchDialogElement, TSinchDialogReact } from './types';
4
5
  declare global {
5
6
  namespace JSX {
package/dialog/index.js CHANGED
@@ -14,8 +14,9 @@ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(
14
14
  import dialogPolyfill from 'dialog-polyfill';
15
15
  import '../icon-button';
16
16
  import '../icons/close';
17
+ import '../stop-events';
17
18
  import { defineCustomElement, getAttribute, getBooleanAttribute, getRect, isAttrTrue, updateAttribute, getReactEventHandler, NectaryElement, updateBooleanAttribute } from '../utils';
18
- const templateHTML = '<style>dialog{position:fixed;left:0;right:0;margin:auto;display:flex;flex-direction:column;padding:24px;max-width:var(--sinch-dialog-max-width,512px);max-height:unset;border-radius:var(--sinch-shape-radius-l);box-sizing:border-box;contain:content;background-color:var(--sinch-color-snow-100);color:var(--sinch-color-text-default);font:var(--sinch-font-body);border:none;box-shadow:var(--sinch-elevation-level-3)}dialog:not([open]){display:none}dialog+.backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background-color:#000;opacity:.55}dialog::backdrop{background-color:#000;opacity:.55}._dialog_overlay{position:fixed;top:0;right:0;bottom:0;left:0}dialog.fixed{position:fixed;top:50%;transform:translate(0,-50%)}#header{display:flex;flex-direction:row;justify-content:space-between;align-items:flex-start;margin-bottom:16px}#caption{font:var(--sinch-font-title-m);color:var(--sinch-color-text-default);white-space:nowrap;text-overflow:ellipsis;overflow:hidden}#content-wrapper{min-height:0;overflow:auto;max-height:var(--sinch-dialog-max-height,50vh)}#buttons{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;margin-top:24px}sinch-icon-button{transform:translate(4px,-4px)}</style><dialog><div id="header"><span id="caption"></span><sinch-icon-button id="close" small tabindex="0"><sinch-icon-close slot="icon"></sinch-icon-close></sinch-icon-button></div><div id="content-wrapper"><slot name="content"></slot></div><div id="buttons"><slot name="buttons"></slot></div></dialog>';
19
+ const templateHTML = '<style>dialog{position:fixed;left:0;right:0;margin:auto;display:flex;flex-direction:column;padding:24px;max-width:var(--sinch-dialog-max-width,512px);max-height:unset;border-radius:var(--sinch-shape-radius-l);box-sizing:border-box;contain:content;background-color:var(--sinch-color-snow-100);color:var(--sinch-color-text-default);font:var(--sinch-font-body);border:none;box-shadow:var(--sinch-elevation-level-3)}dialog:not([open]){display:none}dialog+.backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background-color:#000;opacity:.55}dialog::backdrop{background-color:#000;opacity:.55}._dialog_overlay{position:fixed;top:0;right:0;bottom:0;left:0}dialog.fixed{position:fixed;top:50%;transform:translate(0,-50%)}#header{display:flex;flex-direction:row;justify-content:space-between;align-items:flex-start;margin-bottom:16px}#caption{font:var(--sinch-font-title-m);color:var(--sinch-color-text-default);white-space:nowrap;text-overflow:ellipsis;overflow:hidden}#content{min-height:0;overflow:auto;max-height:var(--sinch-dialog-max-height,50vh)}#buttons{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;margin-top:24px}sinch-icon-button{transform:translate(4px,-4px)}</style><dialog><div id="header"><span id="caption"></span><sinch-icon-button id="close" small tabindex="0"><sinch-icon-close slot="icon"></sinch-icon-close></sinch-icon-button></div><div id="content"><sinch-stop-events events="close"><slot name="content"></slot></sinch-stop-events></div><div id="buttons"><sinch-stop-events events="close"><slot name="buttons"></slot></sinch-stop-events></div></dialog>';
19
20
  const template = document.createElement('template');
20
21
  template.innerHTML = templateHTML;
21
22
  defineCustomElement('sinch-dialog', (_$dialog = new WeakMap(), _$closeButton = new WeakMap(), _$caption = new WeakMap(), _isConnected = new WeakMap(), _prevOverflowValue = new WeakMap(), _onCancel = new WeakMap(), _onCloseClick = new WeakMap(), _onBackdropClick = new WeakMap(), _onCloseReactHandler = new WeakMap(), _dispatchCloseEvent = new WeakSet(), _setOpen = new WeakSet(), class extends NectaryElement {
@@ -62,9 +63,7 @@ defineCustomElement('sinch-dialog', (_$dialog = new WeakMap(), _$closeButton = n
62
63
 
63
64
  _classPrivateFieldInitSpec(this, _onCloseClick, {
64
65
  writable: true,
65
- value: e => {
66
- e.stopPropagation();
67
-
66
+ value: () => {
68
67
  _classPrivateMethodGet(this, _dispatchCloseEvent, _dispatchCloseEvent2).call(this);
69
68
  }
70
69
  });
@@ -80,8 +79,6 @@ defineCustomElement('sinch-dialog', (_$dialog = new WeakMap(), _$closeButton = n
80
79
  const isInside = e.x >= rect.x && e.x < rect.x + rect.width && e.y >= rect.y && e.y < rect.y + rect.height;
81
80
 
82
81
  if (!isInside) {
83
- e.stopPropagation();
84
-
85
82
  _classPrivateMethodGet(this, _dispatchCloseEvent, _dispatchCloseEvent2).call(this);
86
83
  }
87
84
  }
@@ -0,0 +1,13 @@
1
+ import '../icons/check';
2
+ import '../icons/error-outline';
3
+ import type { TSinchHorizontalStepperElement, TSinchHorizontalStepperReact } from './types';
4
+ declare global {
5
+ namespace JSX {
6
+ interface IntrinsicElements {
7
+ 'sinch-horizontal-stepper': TSinchHorizontalStepperReact;
8
+ }
9
+ }
10
+ interface HTMLElementTagNameMap {
11
+ 'sinch-horizontal-stepper': TSinchHorizontalStepperElement;
12
+ }
13
+ }
@@ -0,0 +1,104 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
+
4
+ var _$itemsSlot, _$progressBar, _updateItems;
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 '../icons/check';
11
+ import '../icons/error-outline';
12
+ import { clampNumber, defineCustomElement, getAttribute, getIntegerAttribute, NectaryElement, updateAttribute } from '../utils';
13
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;display:flex;flex-direction:row;gap:28px;width:fit-content}#progress{position:absolute;height:1px;background-color:var(--sinch-color-snow-700);left:72px;right:72px;top:16px;transform:translateY(-50%)}#bar{position:absolute;height:1px;background-color:var(--sinch-color-stormy-400);left:0;top:0}</style><div id="wrapper"><div id="progress"><div id="bar"></div></div><slot></slot></div>';
14
+ const template = document.createElement('template');
15
+ template.innerHTML = templateHTML;
16
+ defineCustomElement('sinch-horizontal-stepper', (_$itemsSlot = new WeakMap(), _$progressBar = new WeakMap(), _updateItems = new WeakMap(), class extends NectaryElement {
17
+ constructor() {
18
+ super();
19
+
20
+ _classPrivateFieldInitSpec(this, _$itemsSlot, {
21
+ writable: true,
22
+ value: void 0
23
+ });
24
+
25
+ _classPrivateFieldInitSpec(this, _$progressBar, {
26
+ writable: true,
27
+ value: void 0
28
+ });
29
+
30
+ _classPrivateFieldInitSpec(this, _updateItems, {
31
+ writable: true,
32
+ value: () => {
33
+ const $items = _classPrivateFieldGet(this, _$itemsSlot).assignedElements();
34
+
35
+ const activeIndex = clampNumber(getIntegerAttribute(this, 'index', 0), 0, $items.length + 1);
36
+
37
+ for (let i = 0; i < $items.length; i++) {
38
+ const $el = $items[i];
39
+ const itemIndex = i + 1;
40
+ $el.setAttribute('data-index', String(itemIndex));
41
+
42
+ if (itemIndex === activeIndex) {
43
+ $el.setAttribute('data-progress', 'active');
44
+ } else if (itemIndex < activeIndex) {
45
+ $el.setAttribute('data-progress', 'done');
46
+ } else {
47
+ $el.removeAttribute('data-progress');
48
+ }
49
+ }
50
+
51
+ const valueIndex = clampNumber(activeIndex - 1, 0, $items.length - 1);
52
+ _classPrivateFieldGet(this, _$progressBar).style.width = `${Math.floor(valueIndex / Math.max(1, $items.length - 1) * 100)}%`;
53
+ this.setAttribute('aria-valuemax', String($items.length));
54
+ this.setAttribute('aria-valuenow', String(valueIndex + 1));
55
+ }
56
+ });
57
+
58
+ const shadowRoot = this.attachShadow();
59
+ shadowRoot.appendChild(template.content.cloneNode(true));
60
+
61
+ _classPrivateFieldSet(this, _$itemsSlot, shadowRoot.querySelector('slot'));
62
+
63
+ _classPrivateFieldSet(this, _$progressBar, shadowRoot.querySelector('#bar'));
64
+ }
65
+
66
+ connectedCallback() {
67
+ this.setAttribute('role', 'progressbar');
68
+ this.setAttribute('aria-valuemin', '0');
69
+
70
+ _classPrivateFieldGet(this, _$itemsSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _updateItems));
71
+ }
72
+
73
+ disconnectedCallback() {
74
+ _classPrivateFieldGet(this, _$itemsSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _updateItems));
75
+ }
76
+
77
+ static get observedAttributes() {
78
+ return ['index'];
79
+ }
80
+
81
+ attributeChangedCallback(name, oldVal, newVal) {
82
+ if (oldVal === newVal) {
83
+ return;
84
+ }
85
+
86
+ switch (name) {
87
+ case 'index':
88
+ {
89
+ _classPrivateFieldGet(this, _updateItems).call(this);
90
+
91
+ break;
92
+ }
93
+ }
94
+ }
95
+
96
+ set index(value) {
97
+ updateAttribute(this, 'index', value);
98
+ }
99
+
100
+ get index() {
101
+ return getAttribute(this, 'index', '1');
102
+ }
103
+
104
+ }));
@@ -0,0 +1,9 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ export declare type TSinchHorizontalStepperElement = HTMLElement & {
3
+ index: string;
4
+ setAttribute(name: 'index', value: string): void;
5
+ };
6
+ export declare type TSinchHorizontalStepperReact = TSinchElementReact<TSinchHorizontalStepperElement> & {
7
+ index: string;
8
+ 'aria-label': string;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import '../icons/check';
2
+ import '../icons/exclamation';
3
+ import type { TSinchHorizontalStepperItemElement, TSinchHorizontalStepperItemReact } from './types';
4
+ declare global {
5
+ namespace JSX {
6
+ interface IntrinsicElements {
7
+ 'sinch-horizontal-stepper-item': TSinchHorizontalStepperItemReact;
8
+ }
9
+ }
10
+ interface HTMLElementTagNameMap {
11
+ 'sinch-horizontal-stepper-item': TSinchHorizontalStepperItemElement;
12
+ }
13
+ }
@@ -0,0 +1,100 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
+
4
+ var _$label, _$description, _$circleText;
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 '../icons/check';
11
+ import '../icons/exclamation';
12
+ import { defineCustomElement, getAttribute, getLiteralAttribute, NectaryElement, updateAttribute, updateLiteralAttribute } from '../utils';
13
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{width:144px;min-height:64px;display:flex;flex-direction:column}#circle{position:relative;display:flex;align-items:center;justify-content:center;align-self:center;width:32px;height:32px;background-color:var(--sinch-color-snow-700);font:var(--sinch-font-title-s);line-height:32px;text-align:center;color:var(--sinch-color-stormy-500);border:1px solid transparent;border-radius:50%;box-sizing:border-box;--sinch-icon-size:20px}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-stormy-500);text-align:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-top:8px}#description{font:var(--sinch-font-text-xs);color:var(--sinch-color-stormy-300);text-align:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#icon-error,#icon-success{display:none}:host([data-progress=active]) #circle{color:var(--sinch-color-snow-100);background-color:var(--sinch-color-stormy-400)}:host([data-progress=done]) #circle{border-color:var(--sinch-color-stormy-400)}:host([data-progress=done]:not([status])) #icon-success{display:block}:host([data-progress=done][status=error]) #circle{background-color:var(--sinch-color-error-200);border-color:var(--sinch-color-stormy-400)}:host([data-progress=done][status=error]) #icon-error{display:block}:host([data-progress=done]:not([status=skip])) #circle-text{display:none}</style><div id="wrapper"><div id="circle" aria-hidden="true"><sinch-icon-check id="icon-success"></sinch-icon-check><sinch-icon-exclamation id="icon-error"></sinch-icon-exclamation><span id="circle-text"></span></div><span id="label"></span> <span id="description"></span></div>';
14
+ import { statusValues } from './utils';
15
+ const template = document.createElement('template');
16
+ template.innerHTML = templateHTML;
17
+ defineCustomElement('sinch-horizontal-stepper-item', (_$label = new WeakMap(), _$description = new WeakMap(), _$circleText = new WeakMap(), class extends NectaryElement {
18
+ constructor() {
19
+ super();
20
+
21
+ _classPrivateFieldInitSpec(this, _$label, {
22
+ writable: true,
23
+ value: void 0
24
+ });
25
+
26
+ _classPrivateFieldInitSpec(this, _$description, {
27
+ writable: true,
28
+ value: void 0
29
+ });
30
+
31
+ _classPrivateFieldInitSpec(this, _$circleText, {
32
+ writable: true,
33
+ value: void 0
34
+ });
35
+
36
+ const shadowRoot = this.attachShadow();
37
+ shadowRoot.appendChild(template.content.cloneNode(true));
38
+
39
+ _classPrivateFieldSet(this, _$label, shadowRoot.querySelector('#label'));
40
+
41
+ _classPrivateFieldSet(this, _$description, shadowRoot.querySelector('#description'));
42
+
43
+ _classPrivateFieldSet(this, _$circleText, shadowRoot.querySelector('#circle-text'));
44
+ }
45
+
46
+ connectedCallback() {}
47
+
48
+ disconnectedCallback() {}
49
+
50
+ static get observedAttributes() {
51
+ return ['label', 'description', 'data-index'];
52
+ }
53
+
54
+ attributeChangedCallback(name, oldVal, newVal) {
55
+ switch (name) {
56
+ case 'label':
57
+ {
58
+ _classPrivateFieldGet(this, _$label).textContent = newVal;
59
+ break;
60
+ }
61
+
62
+ case 'description':
63
+ {
64
+ _classPrivateFieldGet(this, _$description).textContent = newVal;
65
+ break;
66
+ }
67
+
68
+ case 'data-index':
69
+ {
70
+ _classPrivateFieldGet(this, _$circleText).textContent = newVal;
71
+ break;
72
+ }
73
+ }
74
+ }
75
+
76
+ set label(value) {
77
+ updateAttribute(this, 'label', value);
78
+ }
79
+
80
+ get label() {
81
+ return getAttribute(this, 'label', '');
82
+ }
83
+
84
+ set description(value) {
85
+ updateAttribute(this, 'description', value);
86
+ }
87
+
88
+ get description() {
89
+ return getAttribute(this, 'description', '');
90
+ }
91
+
92
+ get status() {
93
+ return getLiteralAttribute(this, statusValues, 'status', null);
94
+ }
95
+
96
+ set status(value) {
97
+ updateLiteralAttribute(this, statusValues, 'status', value);
98
+ }
99
+
100
+ }));
@@ -0,0 +1,15 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ export declare type TSinchHorizontalStepperStatusType = 'error' | 'skip';
3
+ export declare type TSinchHorizontalStepperItemElement = HTMLElement & {
4
+ label: string;
5
+ description: string | null;
6
+ status: TSinchHorizontalStepperStatusType | null;
7
+ setAttribute(name: 'label', value: string): void;
8
+ setAttribute(name: 'description', value: string): void;
9
+ setAttribute(name: 'status', value: TSinchHorizontalStepperStatusType): void;
10
+ };
11
+ export declare type TSinchHorizontalStepperItemReact = TSinchElementReact<TSinchHorizontalStepperItemElement> & {
12
+ label: string;
13
+ description?: string;
14
+ status?: TSinchHorizontalStepperStatusType;
15
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { TSinchHorizontalStepperStatusType } from './types';
2
+ export declare const statusValues: TSinchHorizontalStepperStatusType[];
@@ -0,0 +1 @@
1
+ export const statusValues = ['skip', 'error'];
@@ -0,0 +1,11 @@
1
+ import type { TSinchIconElement, TSinchIconReact } from '../types';
2
+ declare global {
3
+ namespace JSX {
4
+ interface IntrinsicElements {
5
+ 'sinch-icon-exclamation': TSinchIconReact;
6
+ }
7
+ }
8
+ interface HTMLElementTagNameMap {
9
+ 'sinch-icon-exclamation': 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" focusable="false"><path d="M11 14V5h2v9Zm0 5v-2h2v2Z"/></svg>';
4
+ defineCustomElement('sinch-icon-exclamation', createIconClass(templateHTML));
package/input/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import '../stop-events';
1
2
  import type { TSinchInputElement, TSinchInputReact } from './types';
2
3
  declare global {
3
4
  namespace JSX {
package/input/index.js CHANGED
@@ -1,18 +1,19 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _$iconSlot, _$iconWrapper, _$rightSlot, _$rightWrapper, _cursorPos, _isPendingDk, _onCompositionStart, _onSelectionChange, _onInput, _onIconSlotChange, _onRightSlotChange, _onEventFilter;
4
+ var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _$iconSlot, _$iconWrapper, _$rightSlot, _$rightWrapper, _cursorPos, _isPendingDk, _onCompositionStart, _onSelectionChange, _onInput, _onIconSlotChange, _onRightSlotChange;
5
5
 
6
6
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
7
 
8
8
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
9
 
10
+ import '../stop-events';
10
11
  import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, 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-wrapper{position:relative;display:flex;flex-direction:row;align-items:center;box-sizing:border-box;border-radius:var(--sinch-shape-radius-s);width:100%;height:48px;background-color:var(--sinch-color-snow-100)}#input{all:initial;flex:1;min-width:0;height:48px;padding:0 12px 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)}#border{position:absolute;border:1px solid var(--sinch-color-stormy-200);border-radius:var(--sinch-shape-radius-s);left:0;right:0;top:0;bottom:0;pointer-events:none}:host([invalidtext]:not([invalidtext=""]):not([disabled])) #border{border-color:var(--sinch-color-text-invalid)}#input:disabled{color:var(--sinch-color-stormy-100)}#input:disabled::placeholder{color:var(--sinch-color-snow-500)}#input:disabled+#border{border-color:var(--sinch-color-snow-500)}#input:focus+#border{border-color:var(--sinch-color-stormy-600)}#input[type=password]{font-size:1.5em;letter-spacing:.1em}#bottom,#top{display:flex;align-items:baseline}#top{height:24px;margin-bottom:2px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted);line-height:20px;margin-top:2px}#additional:empty{display:none}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid);line-height:20px;margin-top:2px}#invalid:empty{display:none}#icon{position:absolute;left:12px;top:12px;pointer-events:none;--sinch-icon-size:24px}#icon.empty{display:none}#icon.empty~#input{padding-left:12px}#right{display:flex;flex-direction:row;align-self:stretch;align-items:center;gap:4px;padding-right:8px}#right.empty{display:none}::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><div id="input-wrapper"><div id="icon"><slot name="icon"></slot></div><input id="input" type="text"/><div id="border"></div><div id="right"><slot name="right"></slot></div></div><div id="bottom"><div id="invalid"></div><div id="additional"></div></div></div>';
12
+ 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-wrapper{position:relative;display:flex;flex-direction:row;align-items:center;box-sizing:border-box;border-radius:var(--sinch-shape-radius-s);width:100%;height:48px;background-color:var(--sinch-color-snow-100)}#input{all:initial;flex:1;min-width:0;height:48px;padding:0 12px 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)}#border{position:absolute;border:1px solid var(--sinch-color-stormy-200);border-radius:var(--sinch-shape-radius-s);left:0;right:0;top:0;bottom:0;pointer-events:none}:host([invalidtext]:not([invalidtext=""]):not([disabled])) #border{border-color:var(--sinch-color-text-invalid)}#input:disabled{color:var(--sinch-color-stormy-100)}#input:disabled::placeholder{color:var(--sinch-color-snow-500)}#input:disabled+#border{border-color:var(--sinch-color-snow-500)}#input:focus+#border{border-color:var(--sinch-color-stormy-600)}#input[type=password]{font-size:1.5em;letter-spacing:.1em}#bottom,#top{display:flex;align-items:baseline}#top{height:24px;margin-bottom:2px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted);line-height:20px;margin-top:2px}#additional:empty{display:none}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid);line-height:20px;margin-top:2px}#invalid:empty{display:none}#icon{position:absolute;left:12px;top:12px;pointer-events:none;--sinch-icon-size:24px}#icon.empty{display:none}#icon.empty~#input{padding-left:12px}#right{display:flex;flex-direction:row;align-self:stretch;align-items:center;gap:4px;padding-right:8px}#right.empty{display:none}::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><div id="input-wrapper"><div id="icon"><slot name="icon"></slot></div><input id="input" type="text"/><div id="border"></div><div id="right"><sinch-stop-events events="input,change,focusin,focusout"><slot name="right"></slot></sinch-stop-events></div></div><div id="bottom"><div id="invalid"></div><div id="additional"></div></div></div>';
12
13
  import { inputTypes } from './utils';
13
14
  const template = document.createElement('template');
14
15
  template.innerHTML = templateHTML;
15
- defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _$iconSlot = new WeakMap(), _$iconWrapper = new WeakMap(), _$rightSlot = new WeakMap(), _$rightWrapper = new WeakMap(), _cursorPos = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onSelectionChange = new WeakMap(), _onInput = new WeakMap(), _onIconSlotChange = new WeakMap(), _onRightSlotChange = new WeakMap(), _onEventFilter = new WeakMap(), class extends NectaryElement {
16
+ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _$iconSlot = new WeakMap(), _$iconWrapper = new WeakMap(), _$rightSlot = new WeakMap(), _$rightWrapper = new WeakMap(), _cursorPos = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onSelectionChange = new WeakMap(), _onInput = new WeakMap(), _onIconSlotChange = new WeakMap(), _onRightSlotChange = new WeakMap(), class extends NectaryElement {
16
17
  constructor() {
17
18
  super();
18
19
 
@@ -135,13 +136,6 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
135
136
  }
136
137
  });
137
138
 
138
- _classPrivateFieldInitSpec(this, _onEventFilter, {
139
- writable: true,
140
- value: e => {
141
- e.stopPropagation();
142
- }
143
- });
144
-
145
139
  const shadowRoot = this.attachShadow();
146
140
  shadowRoot.appendChild(template.content.cloneNode(true));
147
141
 
@@ -179,14 +173,6 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
179
173
 
180
174
  _classPrivateFieldGet(this, _$rightSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onRightSlotChange));
181
175
 
182
- _classPrivateFieldGet(this, _$rightSlot).addEventListener('input', _classPrivateFieldGet(this, _onEventFilter));
183
-
184
- _classPrivateFieldGet(this, _$rightSlot).addEventListener('change', _classPrivateFieldGet(this, _onEventFilter));
185
-
186
- _classPrivateFieldGet(this, _$rightSlot).addEventListener('focusin', _classPrivateFieldGet(this, _onEventFilter));
187
-
188
- _classPrivateFieldGet(this, _$rightSlot).addEventListener('focusout', _classPrivateFieldGet(this, _onEventFilter));
189
-
190
176
  _classPrivateFieldGet(this, _onIconSlotChange).call(this);
191
177
 
192
178
  _classPrivateFieldGet(this, _onRightSlotChange).call(this);
@@ -204,14 +190,6 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
204
190
  _classPrivateFieldGet(this, _$iconSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onIconSlotChange));
205
191
 
206
192
  _classPrivateFieldGet(this, _$rightSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onRightSlotChange));
207
-
208
- _classPrivateFieldGet(this, _$rightSlot).removeEventListener('input', _classPrivateFieldGet(this, _onEventFilter));
209
-
210
- _classPrivateFieldGet(this, _$rightSlot).removeEventListener('change', _classPrivateFieldGet(this, _onEventFilter));
211
-
212
- _classPrivateFieldGet(this, _$rightSlot).removeEventListener('focusin', _classPrivateFieldGet(this, _onEventFilter));
213
-
214
- _classPrivateFieldGet(this, _$rightSlot).removeEventListener('focusout', _classPrivateFieldGet(this, _onEventFilter));
215
193
  }
216
194
 
217
195
  static get observedAttributes() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "0.33.0",
3
+ "version": "0.34.0",
4
4
  "files": [
5
5
  "theme.css",
6
6
  "**/*/*.js",
package/popover/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$target, _$dialog, _isConnected, _resizeThrottle, _prevOverflowValue, _onExpand, _onCollapse, _isOpen, _onResize, _updateOrientation, _updateOrientationModal, _onBackdropClick, _onCancel, _onCloseReactHandler, _onTargetKeydown, _dispatchCloseEvent;
4
+ var _$target, _$dialog, _isConnected, _resizeThrottle, _prevOverflowValue, _onExpand, _onCollapse, _isOpen, _onResize, _updateOrientation, _updateOrientationModal, _onBackdropMouseDown, _onCancel, _onCloseReactHandler, _onTargetKeydown, _dispatchCloseEvent;
5
5
 
6
6
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
7
 
@@ -18,7 +18,7 @@ import { orientationValues } from './utils';
18
18
  const template = document.createElement('template');
19
19
  template.innerHTML = templateHTML;
20
20
  const POPOVER_OFFSET = 4;
21
- defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new WeakMap(), _isConnected = new WeakMap(), _resizeThrottle = new WeakMap(), _prevOverflowValue = new WeakMap(), _onExpand = new WeakSet(), _onCollapse = new WeakSet(), _isOpen = new WeakSet(), _onResize = new WeakMap(), _updateOrientation = new WeakMap(), _updateOrientationModal = new WeakMap(), _onBackdropClick = new WeakMap(), _onCancel = new WeakMap(), _onCloseReactHandler = new WeakMap(), _onTargetKeydown = new WeakMap(), _dispatchCloseEvent = new WeakSet(), class extends NectaryElement {
21
+ defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new WeakMap(), _isConnected = new WeakMap(), _resizeThrottle = new WeakMap(), _prevOverflowValue = new WeakMap(), _onExpand = new WeakSet(), _onCollapse = new WeakSet(), _isOpen = new WeakSet(), _onResize = new WeakMap(), _updateOrientation = new WeakMap(), _updateOrientationModal = new WeakMap(), _onBackdropMouseDown = new WeakMap(), _onCancel = new WeakMap(), _onCloseReactHandler = new WeakMap(), _onTargetKeydown = new WeakMap(), _dispatchCloseEvent = new WeakSet(), class extends NectaryElement {
22
22
  constructor() {
23
23
  super();
24
24
 
@@ -132,7 +132,7 @@ defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new W
132
132
  }
133
133
  });
134
134
 
135
- _classPrivateFieldInitSpec(this, _onBackdropClick, {
135
+ _classPrivateFieldInitSpec(this, _onBackdropMouseDown, {
136
136
  writable: true,
137
137
  value: e => {
138
138
  if (e.target !== _classPrivateFieldGet(this, _$dialog)) {
@@ -143,8 +143,6 @@ defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new W
143
143
  const isInside = e.x >= rect.x && e.x < rect.x + rect.width && e.y >= rect.y && e.y < rect.y + rect.height;
144
144
 
145
145
  if (!isInside) {
146
- e.stopPropagation();
147
-
148
146
  _classPrivateMethodGet(this, _dispatchCloseEvent, _dispatchCloseEvent2).call(this);
149
147
  }
150
148
  }
@@ -201,7 +199,7 @@ defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new W
201
199
 
202
200
  _classPrivateFieldGet(this, _$dialog).addEventListener('cancel', _classPrivateFieldGet(this, _onCancel));
203
201
 
204
- _classPrivateFieldGet(this, _$dialog).addEventListener('mousedown', _classPrivateFieldGet(this, _onBackdropClick));
202
+ _classPrivateFieldGet(this, _$dialog).addEventListener('mousedown', _classPrivateFieldGet(this, _onBackdropMouseDown));
205
203
 
206
204
  this.addEventListener('close', _classPrivateFieldGet(this, _onCloseReactHandler));
207
205
 
@@ -217,7 +215,7 @@ defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new W
217
215
  disconnectedCallback() {
218
216
  _classPrivateFieldGet(this, _$dialog).removeEventListener('cancel', _classPrivateFieldGet(this, _onCancel));
219
217
 
220
- _classPrivateFieldGet(this, _$dialog).removeEventListener('mousedown', _classPrivateFieldGet(this, _onBackdropClick));
218
+ _classPrivateFieldGet(this, _$dialog).removeEventListener('mousedown', _classPrivateFieldGet(this, _onBackdropMouseDown));
221
219
 
222
220
  this.removeEventListener('close', _classPrivateFieldGet(this, _onCloseReactHandler));
223
221
 
package/select/types.d.ts CHANGED
@@ -1,33 +1,61 @@
1
1
  import type { TRect, TSinchElementReact } from '../types';
2
2
  import type { SyntheticEvent } from 'react';
3
3
  export declare type TSinchSelectElement = HTMLElement & {
4
+ /** Value that matches one of the options `value` */
4
5
  value: string;
6
+ /** Label */
5
7
  label: string;
8
+ /** Text that appears when it has no value set */
6
9
  placeholder: string | null;
10
+ /** Optional text */
7
11
  optionalText: string | null;
8
- invalidText: string | null;
12
+ /** Additional text */
9
13
  additionalText: string | null;
10
- maxVisibleItems: number | null;
14
+ /** Invalid text, controls the overall invalid state */
15
+ invalidText: string | null;
16
+ /** Disabled */
11
17
  disabled: boolean;
18
+ /** Number of visible at the same time options in the list */
19
+ maxVisibleItems: number | null;
12
20
  readonly dropdownRect: TRect;
21
+ /** Change value event */
13
22
  addEventListener(type: 'change', listener: (e: CustomEvent<string>) => void): void;
23
+ /** Value that matches one of the options `value` */
14
24
  setAttribute(name: 'value', value: string): void;
25
+ /** Label */
15
26
  setAttribute(name: 'label', value: string): void;
27
+ /** Text that appears when it has no value set */
16
28
  setAttribute(name: 'placeholder', value: string): void;
29
+ /** Optional text */
17
30
  setAttribute(name: 'optionaltext', value: string): void;
31
+ /** Additional text */
18
32
  setAttribute(name: 'additionaltext', value: string): void;
19
- setAttribute(name: 'maxvisibleitems', value: string): void;
33
+ /** Invalid text, controls the overall invalid state */
34
+ setAttribute(name: 'invalidtext', value: string): void;
35
+ /** Disabled */
20
36
  setAttribute(name: 'disabled', value: ''): void;
37
+ /** Number of visible at the same time options in the list */
38
+ setAttribute(name: 'maxvisibleitems', value: string): void;
21
39
  };
22
40
  export declare type TSinchSelectReact = TSinchElementReact<TSinchSelectElement> & {
41
+ /** Value that matches one of the options `value` */
23
42
  value: string;
43
+ /** Label */
24
44
  label: string;
45
+ /** Label that is used for a11y – might be different from `label` */
46
+ 'aria-label': string;
47
+ /** Text that appears when it has no value set */
25
48
  placeholder?: string;
49
+ /** Optional text */
26
50
  optionalText?: string;
27
- invalidText?: string;
51
+ /** Additional text */
28
52
  additionalText?: string;
53
+ /** Invalid text, controls the overall invalid state */
54
+ invalidText?: string;
55
+ /** Disabled */
29
56
  disabled?: boolean;
57
+ /** Number of visible at the same time options in the list */
30
58
  maxVisibleItems?: number;
31
- 'aria-label': string;
59
+ /** Change value handler */
32
60
  onChange: (e: SyntheticEvent<TSinchSelectElement, CustomEvent<string>>) => void;
33
61
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,40 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+
3
+ var _stopEvent;
4
+
5
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
6
+
7
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
8
+
9
+ import { defineCustomElement, getCsvSet } from '../utils';
10
+ defineCustomElement('sinch-stop-events', (_stopEvent = new WeakMap(), class extends HTMLElement {
11
+ constructor() {
12
+ super();
13
+
14
+ _classPrivateFieldInitSpec(this, _stopEvent, {
15
+ writable: true,
16
+ value: e => {
17
+ e.stopPropagation();
18
+ }
19
+ });
20
+
21
+ this.style.display = 'contents';
22
+ }
23
+
24
+ connectedCallback() {
25
+ const events = getCsvSet(this.getAttribute('events'));
26
+
27
+ for (const event of events) {
28
+ this.addEventListener(event, _classPrivateFieldGet(this, _stopEvent));
29
+ }
30
+ }
31
+
32
+ disconnectedCallback() {
33
+ const events = getCsvSet(this.getAttribute('events'));
34
+
35
+ for (const event of events) {
36
+ this.removeEventListener(event, _classPrivateFieldGet(this, _stopEvent));
37
+ }
38
+ }
39
+
40
+ }));
package/utils.d.ts CHANGED
@@ -23,6 +23,7 @@ export declare const updateLiteralAttribute: <T extends readonly string[]>($elem
23
23
  export declare function getLiteralAttribute<T extends readonly string[]>($element: Element, literals: T, attrName: string): T[number];
24
24
  export declare function getLiteralAttribute<T extends readonly string[]>($element: Element, literals: T, attrName: string, defaultValue: null): T[number] | null;
25
25
  export declare function getLiteralAttribute<T extends readonly string[]>($element: Element, literals: T, attrName: string, defaultValue: T[number]): T[number];
26
+ export declare const clampNumber: (value: number, min: number, max: number) => number;
26
27
  declare type TRange = {
27
28
  min?: number;
28
29
  max?: number;
package/utils.js CHANGED
@@ -99,6 +99,9 @@ export function getLiteralAttribute($element, literals, attrName, defaultValue)
99
99
 
100
100
  return defaultValue;
101
101
  }
102
+ export const clampNumber = (value, min, max) => {
103
+ return Math.min(max, Math.max(min, value));
104
+ };
102
105
 
103
106
  const applyRange = (value, range) => {
104
107
  let result = value;