@nectary/components 0.16.1 → 0.17.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.
@@ -2,12 +2,14 @@ import type { TSinchElementReact } from '../types';
2
2
  import type { FocusEvent, MouseEvent } from 'react';
3
3
  export declare type TSinchIconButtonElement = HTMLElement & {
4
4
  disabled: boolean;
5
+ small: boolean;
5
6
  focus(): void;
6
7
  blur(): void;
7
8
  };
8
9
  export declare type TSinchIconButtonReact = TSinchElementReact<TSinchIconButtonElement> & {
9
10
  'aria-label': string;
10
11
  disabled?: boolean;
12
+ small?: boolean;
11
13
  onClick: (e: MouseEvent<TSinchIconButtonElement>) => void;
12
14
  onFocus?: (e: FocusEvent<TSinchIconButtonElement>) => void;
13
15
  onBlur?: (e: FocusEvent<TSinchIconButtonElement>) => void;
@@ -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, 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>';
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)}:host([small]:not([small=false]))>button{width:32px;height:32px}button>*{pointer-events:none}</style><button><slot name="icon"></slot></button>';
12
12
  const template = document.createElement('template');
13
13
  template.innerHTML = templateHTML;
14
14
  defineCustomElement('sinch-icon-button', (_$button = new WeakMap(), class extends HTMLElement {
@@ -55,6 +55,14 @@ defineCustomElement('sinch-icon-button', (_$button = new WeakMap(), class extend
55
55
  return getBooleanAttribute(this, 'disabled');
56
56
  }
57
57
 
58
+ set small(isSmall) {
59
+ updateBooleanAttribute(this, 'small', isSmall);
60
+ }
61
+
62
+ get small() {
63
+ return getBooleanAttribute(this, 'small');
64
+ }
65
+
58
66
  focus() {
59
67
  _classPrivateFieldGet(this, _$button).focus();
60
68
  }
package/index.d.ts CHANGED
@@ -136,3 +136,5 @@ import './grid-item';
136
136
  import './icon-button';
137
137
  import './search';
138
138
  import './search-option';
139
+ import './segment';
140
+ import './segment-collapse';
package/index.js CHANGED
@@ -135,4 +135,6 @@ import './grid';
135
135
  import './grid-item';
136
136
  import './icon-button';
137
137
  import './search';
138
- import './search-option';
138
+ import './search-option';
139
+ import './segment';
140
+ import './segment-collapse';
package/input/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 _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _selectionStart, _selectionEnd, _isPendingDk, _onKeydown, _onInput;
4
+ var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _selectionStart, _selectionEnd, _isPendingDk, _onCompositionStart, _onInput;
5
5
 
6
6
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
7
 
@@ -12,7 +12,7 @@ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;ou
12
12
  const inputTypes = ['text', 'password'];
13
13
  const template = document.createElement('template');
14
14
  template.innerHTML = templateHTML;
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(), _isPendingDk = new WeakMap(), _onKeydown = new WeakMap(), _onInput = new WeakMap(), class extends HTMLElement {
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(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onInput = new WeakMap(), class extends HTMLElement {
16
16
  constructor() {
17
17
  super();
18
18
 
@@ -56,12 +56,10 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
56
56
  value: false
57
57
  });
58
58
 
59
- _classPrivateFieldInitSpec(this, _onKeydown, {
59
+ _classPrivateFieldInitSpec(this, _onCompositionStart, {
60
60
  writable: true,
61
- value: e => {
62
- if (e.key === 'Dead') {
63
- _classPrivateFieldSet(this, _isPendingDk, true);
64
- }
61
+ value: () => {
62
+ _classPrivateFieldSet(this, _isPendingDk, true);
65
63
  }
66
64
  });
67
65
 
@@ -129,13 +127,13 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
129
127
 
130
128
  _classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onInput));
131
129
 
132
- _classPrivateFieldGet(this, _$input).addEventListener('keydown', _classPrivateFieldGet(this, _onKeydown));
130
+ _classPrivateFieldGet(this, _$input).addEventListener('compositionstart', _classPrivateFieldGet(this, _onCompositionStart));
133
131
  }
134
132
 
135
133
  disconnectedCallback() {
136
134
  _classPrivateFieldGet(this, _$input).removeEventListener('input', _classPrivateFieldGet(this, _onInput));
137
135
 
138
- _classPrivateFieldGet(this, _$input).removeEventListener('keydown', _classPrivateFieldGet(this, _onKeydown));
136
+ _classPrivateFieldGet(this, _$input).removeEventListener('compositionstart', _classPrivateFieldGet(this, _onCompositionStart));
139
137
  }
140
138
 
141
139
  static get observedAttributes() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "0.16.1",
3
+ "version": "0.17.0",
4
4
  "files": [
5
5
  "theme.css",
6
6
  "**/*/*.js",
@@ -0,0 +1,20 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ declare type TSinchSegmentElement = HTMLElement & {
3
+ caption: string;
4
+ collapsed: boolean;
5
+ };
6
+ declare type TSinchSegmentReact = TSinchElementReact<TSinchSegmentElement> & {
7
+ caption: string;
8
+ collapsed?: boolean;
9
+ };
10
+ declare global {
11
+ namespace JSX {
12
+ interface IntrinsicElements {
13
+ 'sinch-segment': TSinchSegmentReact;
14
+ }
15
+ }
16
+ interface HTMLElementTagNameMap {
17
+ 'sinch-segment': TSinchSegmentElement;
18
+ }
19
+ }
20
+ export {};
@@ -0,0 +1,62 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
+
4
+ var _$caption;
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, getAttribute, getBooleanAttribute, updateAttribute, updateBooleanAttribute } from '../utils';
11
+ const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;width:100%;border-radius:4px;box-sizing:border-box;background-color:var(--sinch-color-snow-100);color:var(--sinch-color-text-default);font:var(--sinch-font-body);border:none;box-shadow:1px 2px 8px rgb(0 0 0 / 10%)}#header{position:relative;display:flex;flex-direction:row;align-items:center;gap:16px;height:32px;padding:24px 32px 16px;--sinch-size-icon:32px}#caption{font:var(--sinch-font-title-2);color:var(--sinch-color-text-default);flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#content-wrapper{padding:0 32px}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;padding:16px 32px 24px}#info{position:relative;display:flex;flex-direction:row;align-items:center;gap:16px;z-index:1}:host([collapsed]:not([collapsed=false])) :is(#content-wrapper,#action){display:none}:host([collapsed]:not([collapsed=false])) #header{padding-bottom:24px}</style><div id="wrapper"><div id="header"><slot name="icon"></slot><span id="caption"></span><div id="info"><slot name="info"></slot></div><slot name="collapse"></slot></div><div id="content-wrapper"><slot name="content"></slot></div><div id="action"><slot name="action"></slot></div></div>';
12
+ const template = document.createElement('template');
13
+ template.innerHTML = templateHTML;
14
+ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), class extends HTMLElement {
15
+ constructor() {
16
+ super();
17
+
18
+ _classPrivateFieldInitSpec(this, _$caption, {
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, _$caption, shadowRoot.querySelector('#caption'));
30
+ }
31
+
32
+ static get observedAttributes() {
33
+ return ['caption'];
34
+ }
35
+
36
+ attributeChangedCallback(name, _, newVal) {
37
+ switch (name) {
38
+ case 'caption':
39
+ {
40
+ _classPrivateFieldGet(this, _$caption).textContent = newVal;
41
+ break;
42
+ }
43
+ }
44
+ }
45
+
46
+ set caption(caption) {
47
+ updateAttribute(this, 'caption', caption);
48
+ }
49
+
50
+ get caption() {
51
+ return getAttribute(this, 'caption', '');
52
+ }
53
+
54
+ set collapsed(isChecked) {
55
+ updateBooleanAttribute(this, 'collapsed', isChecked);
56
+ }
57
+
58
+ get collapsed() {
59
+ return getBooleanAttribute(this, 'collapsed');
60
+ }
61
+
62
+ }));
@@ -0,0 +1,26 @@
1
+ import '../icon/expand-less';
2
+ import '../icon/expand-more';
3
+ import type { TSinchElementReact } from '../types';
4
+ import type { FocusEvent, SyntheticEvent } from 'react';
5
+ export declare type TSinchSegmentExpandElement = HTMLElement & {
6
+ value: boolean;
7
+ focus(): void;
8
+ blur(): void;
9
+ };
10
+ export declare type TSinchSegmentExpandReact = TSinchElementReact<TSinchSegmentExpandElement> & {
11
+ value: boolean;
12
+ 'aria-label': string;
13
+ onChange: (e: SyntheticEvent<TSinchSegmentExpandElement, CustomEvent<boolean>>) => void;
14
+ onFocus?: (e: FocusEvent<TSinchSegmentExpandElement>) => void;
15
+ onBlur?: (e: FocusEvent<TSinchSegmentExpandElement>) => void;
16
+ };
17
+ declare global {
18
+ namespace JSX {
19
+ interface IntrinsicElements {
20
+ 'sinch-segment-collapse': TSinchSegmentExpandReact;
21
+ }
22
+ }
23
+ interface HTMLElementTagNameMap {
24
+ 'sinch-segment-collapse': TSinchSegmentExpandElement;
25
+ }
26
+ }
@@ -0,0 +1,94 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
3
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
4
+
5
+ var _$input;
6
+
7
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
8
+
9
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
10
+
11
+ import '../icon/expand-less';
12
+ import '../icon/expand-more';
13
+ import { defineCustomElement, getBooleanAttribute, isAttrTrue, updateBooleanAttribute } from '../utils';
14
+ const templateHTML = '<style>:host{display:contents;--sinch-size-icon:32px}input{all:initial;position:absolute;left:0;top:0;width:100%;height:100%;box-sizing:border-box;cursor:pointer}input:focus~sinch-icon-expand-less,input:focus~sinch-icon-expand-more{border-radius:4px;box-shadow:0 0 0 1px var(--sinch-color-stormy-500) inset}#up{display:block}#down{display:none}:host([value]:not([value=false])) #up{display:none}:host([value]:not([value=false])) #down{display:block}</style><input type="checkbox"/><sinch-icon-expand-less id="up"></sinch-icon-expand-less><sinch-icon-expand-more id="down"></sinch-icon-expand-more>';
15
+ const template = document.createElement('template');
16
+ template.innerHTML = templateHTML;
17
+ defineCustomElement('sinch-segment-collapse', (_$input = new WeakMap(), class extends HTMLElement {
18
+ constructor() {
19
+ super();
20
+
21
+ _classPrivateFieldInitSpec(this, _$input, {
22
+ writable: true,
23
+ value: void 0
24
+ });
25
+
26
+ _defineProperty(this, 'onCheckboxInput', e => {
27
+ e.stopPropagation();
28
+
29
+ const isChecked = _classPrivateFieldGet(this, _$input).checked;
30
+
31
+ _classPrivateFieldGet(this, _$input).checked = this.value;
32
+ this.dispatchEvent(new CustomEvent('change', {
33
+ detail: isChecked,
34
+ bubbles: true
35
+ }));
36
+ });
37
+
38
+ const shadowRoot = this.attachShadow({
39
+ mode: 'closed'
40
+ });
41
+ shadowRoot.appendChild(template.content.cloneNode(true));
42
+
43
+ _classPrivateFieldSet(this, _$input, shadowRoot.querySelector('input'));
44
+ }
45
+
46
+ connectedCallback() {
47
+ this.setAttribute('role', 'checkbox');
48
+
49
+ _classPrivateFieldGet(this, _$input).addEventListener('input', this.onCheckboxInput);
50
+ }
51
+
52
+ disconnectedCallback() {
53
+ _classPrivateFieldGet(this, _$input).removeEventListener('input', this.onCheckboxInput);
54
+ }
55
+
56
+ get type() {
57
+ return 'text';
58
+ }
59
+
60
+ get nodeName() {
61
+ return 'input';
62
+ }
63
+
64
+ static get observedAttributes() {
65
+ return ['value'];
66
+ }
67
+
68
+ attributeChangedCallback(name, _, newVal) {
69
+ switch (name) {
70
+ case 'value':
71
+ {
72
+ _classPrivateFieldGet(this, _$input).checked = isAttrTrue(newVal);
73
+ break;
74
+ }
75
+ }
76
+ }
77
+
78
+ set value(isChecked) {
79
+ updateBooleanAttribute(this, 'value', isChecked);
80
+ }
81
+
82
+ get value() {
83
+ return getBooleanAttribute(this, 'value');
84
+ }
85
+
86
+ focus() {
87
+ _classPrivateFieldGet(this, _$input).focus();
88
+ }
89
+
90
+ blur() {
91
+ _classPrivateFieldGet(this, _$input).blur();
92
+ }
93
+
94
+ }));
package/textarea/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 _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _selectionStart, _selectionEnd, _isPendingDk, _onKeydown, _onInput;
4
+ var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _selectionStart, _selectionEnd, _isPendingDk, _onCompositionStart, _onInput;
5
5
 
6
6
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
7
 
@@ -11,7 +11,7 @@ import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, upd
11
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%;min-height:86px;margin:2px 0;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto);resize:vertical}#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><textarea id="input" rows="3"></textarea><div id="bottom"><span id="invalid"></span> <span id="additional"></span></div></div>';
12
12
  const template = document.createElement('template');
13
13
  template.innerHTML = templateHTML;
14
- defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _selectionStart = new WeakMap(), _selectionEnd = new WeakMap(), _isPendingDk = new WeakMap(), _onKeydown = new WeakMap(), _onInput = new WeakMap(), class extends HTMLElement {
14
+ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _selectionStart = new WeakMap(), _selectionEnd = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onInput = new WeakMap(), class extends HTMLElement {
15
15
  constructor() {
16
16
  super();
17
17
 
@@ -55,12 +55,10 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
55
55
  value: false
56
56
  });
57
57
 
58
- _classPrivateFieldInitSpec(this, _onKeydown, {
58
+ _classPrivateFieldInitSpec(this, _onCompositionStart, {
59
59
  writable: true,
60
- value: e => {
61
- if (e.key === 'Dead') {
62
- _classPrivateFieldSet(this, _isPendingDk, true);
63
- }
60
+ value: () => {
61
+ _classPrivateFieldSet(this, _isPendingDk, true);
64
62
  }
65
63
  });
66
64
 
@@ -129,13 +127,13 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
129
127
 
130
128
  _classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onInput));
131
129
 
132
- _classPrivateFieldGet(this, _$input).addEventListener('keydown', _classPrivateFieldGet(this, _onKeydown));
130
+ _classPrivateFieldGet(this, _$input).addEventListener('compositionstart', _classPrivateFieldGet(this, _onCompositionStart));
133
131
  }
134
132
 
135
133
  disconnectedCallback() {
136
134
  _classPrivateFieldGet(this, _$input).removeEventListener('input', _classPrivateFieldGet(this, _onInput));
137
135
 
138
- _classPrivateFieldGet(this, _$input).removeEventListener('keydown', _classPrivateFieldGet(this, _onKeydown));
136
+ _classPrivateFieldGet(this, _$input).removeEventListener('compositionstart', _classPrivateFieldGet(this, _onCompositionStart));
139
137
  }
140
138
 
141
139
  static get observedAttributes() {