@nectary/components 0.31.0 → 0.33.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/accordion-item/types.d.ts +0 -2
- package/action-menu/index.js +40 -18
- package/action-menu/types.d.ts +3 -0
- package/action-menu-option/index.js +22 -14
- package/action-menu-option/types.d.ts +0 -2
- package/alert-button/types.d.ts +0 -2
- package/alert-close/types.d.ts +1 -4
- package/button/types.d.ts +0 -2
- package/card-button/types.d.ts +0 -2
- package/card-link/types.d.ts +0 -2
- package/checkbox/types.d.ts +0 -2
- package/date-picker/index.js +1 -1
- package/date-picker/types.d.ts +16 -1
- package/dialog/index.js +47 -40
- package/dialog/types.d.ts +2 -0
- package/dropdown/index.js +11 -13
- package/dropdown/types.d.ts +0 -2
- package/icon-button/index.js +1 -1
- package/icon-button/types.d.ts +0 -2
- package/input/index.js +111 -26
- package/input/types.d.ts +0 -2
- package/link/index.d.ts +1 -1
- package/link/index.js +1 -1
- package/package.json +1 -1
- package/pagination/types.d.ts +0 -2
- package/popover/index.js +127 -33
- package/popover/types.d.ts +17 -2
- package/popover/utils.js +1 -1
- package/radio-option/types.d.ts +0 -2
- package/search/types.d.ts +0 -2
- package/segment/index.js +30 -3
- package/segment-collapse/types.d.ts +0 -2
- package/segmented-control-option/index.js +1 -1
- package/segmented-control-option/types.d.ts +0 -2
- package/segmented-icon-control-option/types.d.ts +0 -2
- package/select/index.js +1 -1
- package/select/types.d.ts +0 -2
- package/tabs-option/types.d.ts +0 -2
- package/tag-close/types.d.ts +1 -4
- package/text/index.js +1 -3
- package/textarea/index.js +36 -28
- package/textarea/types.d.ts +0 -2
- package/time-picker/index.d.ts +17 -0
- package/time-picker/index.js +525 -0
- package/time-picker/types.d.ts +31 -0
- package/time-picker/types.js +1 -0
- package/time-picker/utils.d.ts +11 -0
- package/time-picker/utils.js +94 -0
- package/toggle/types.d.ts +0 -2
- package/utils.js +1 -1
package/segment/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 _$caption, _$previewSlot, _$previewWrapper, _$infoSlot, _$infoWrapper, _$collapseSlot, _$collapseWrapper, _onPreviewSlotChange, _onInfoSlotChange, _onCollapseSlotChange;
|
|
4
|
+
var _$caption, _$previewSlot, _$previewWrapper, _$infoSlot, _$infoWrapper, _$collapseSlot, _$collapseWrapper, _$actionSlot, _$actionWrapper, _onPreviewSlotChange, _onInfoSlotChange, _onCollapseSlotChange, _onActionSlotChange;
|
|
5
5
|
|
|
6
6
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
7
|
|
|
@@ -10,11 +10,11 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
|
|
|
10
10
|
import '../title';
|
|
11
11
|
import { getTitleLevelFromType } from '../title/utils';
|
|
12
12
|
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getRect, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
|
|
13
|
-
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;gap:16px;width:100%;height:100%;border:1px solid var(--sinch-color-snow-700);border-radius:var(--sinch-shape-radius-l);box-sizing:border-box;background-color:var(--sinch-color-snow-100);color:var(--sinch-color-text-default);font:var(--sinch-font-body);box-shadow:var(--sinch-elevation-level-2);padding:8px 24px 16px}#header{display:flex;flex-direction:row;align-items:center;height:48px;gap:8px;--sinch-size-icon:32px}#caption{font:var(--sinch-font-title-l);color:var(--sinch-color-text-default);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:1em}#info{display:flex;flex-direction:row;align-items:center;gap:8px;margin-left:auto;align-self:stretch}#info.empty{display:none}#preview{flex:1;flex-basis:auto;height:48px;min-width:0;overflow:hidden;margin-left:24px}#preview.empty{display:none}#info.empty+#collapse{margin-left:auto}#collapse.empty{display:none}#preview:not(.empty)+#info.empty+#collapse:not(.empty),#preview:not(.empty)+#info:not(.empty){margin-left:24px}#content-wrapper{flex:1;min-height:0;overflow-y:auto}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px}:host([collapsed]:not([collapsed=false])) :is(#content-wrapper,#action){display:none}:host([collapsed]:not([collapsed=false])) #wrapper{padding-bottom:8px}::slotted([slot=icon]){margin-right:8px}</style><div id="wrapper"><div id="header"><slot name="icon"></slot><sinch-title id="caption" level="3" type="m"></sinch-title><div id="preview"><slot name="preview"></slot></div><div id="info"><slot name="info"></slot></div><div id="collapse"><slot name="collapse"></slot></div></div><div id="content-wrapper"><slot name="content"></slot></div><div id="action"><slot name="action"></slot></div></div>';
|
|
13
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;gap:16px;width:100%;height:100%;border:1px solid var(--sinch-color-snow-700);border-radius:var(--sinch-shape-radius-l);box-sizing:border-box;background-color:var(--sinch-color-snow-100);color:var(--sinch-color-text-default);font:var(--sinch-font-body);box-shadow:var(--sinch-elevation-level-2);padding:8px 24px 16px}#header{display:flex;flex-direction:row;align-items:center;height:48px;gap:8px;--sinch-size-icon:32px}#caption{font:var(--sinch-font-title-l);color:var(--sinch-color-text-default);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:1em}#info{display:flex;flex-direction:row;align-items:center;gap:8px;margin-left:auto;align-self:stretch}#info.empty{display:none}#preview{flex:1;flex-basis:auto;height:48px;min-width:0;overflow:hidden;margin-left:24px}#preview.empty{display:none}#info.empty+#collapse{margin-left:auto}#collapse.empty{display:none}#preview:not(.empty)+#info.empty+#collapse:not(.empty),#preview:not(.empty)+#info:not(.empty){margin-left:24px}#content-wrapper{flex:1;min-height:0;overflow-y:auto}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px}#action.empty{display:none}:host([collapsed]:not([collapsed=false])) :is(#content-wrapper,#action){display:none}:host([collapsed]:not([collapsed=false])) #wrapper{padding-bottom:8px}::slotted([slot=icon]){margin-right:8px}</style><div id="wrapper"><div id="header"><slot name="icon"></slot><sinch-title id="caption" level="3" type="m"></sinch-title><div id="preview"><slot name="preview"></slot></div><div id="info"><slot name="info"></slot></div><div id="collapse"><slot name="collapse"></slot></div></div><div id="content-wrapper"><slot name="content"></slot></div><div id="action"><slot name="action"></slot></div></div>';
|
|
14
14
|
import { assertSize, sizeValues } from './utils';
|
|
15
15
|
const template = document.createElement('template');
|
|
16
16
|
template.innerHTML = templateHTML;
|
|
17
|
-
defineCustomElement('sinch-segment', (_$caption = new WeakMap(), _$previewSlot = new WeakMap(), _$previewWrapper = new WeakMap(), _$infoSlot = new WeakMap(), _$infoWrapper = new WeakMap(), _$collapseSlot = new WeakMap(), _$collapseWrapper = new WeakMap(), _onPreviewSlotChange = new WeakMap(), _onInfoSlotChange = new WeakMap(), _onCollapseSlotChange = new WeakMap(), class extends NectaryElement {
|
|
17
|
+
defineCustomElement('sinch-segment', (_$caption = new WeakMap(), _$previewSlot = new WeakMap(), _$previewWrapper = new WeakMap(), _$infoSlot = new WeakMap(), _$infoWrapper = new WeakMap(), _$collapseSlot = new WeakMap(), _$collapseWrapper = new WeakMap(), _$actionSlot = new WeakMap(), _$actionWrapper = new WeakMap(), _onPreviewSlotChange = new WeakMap(), _onInfoSlotChange = new WeakMap(), _onCollapseSlotChange = new WeakMap(), _onActionSlotChange = new WeakMap(), class extends NectaryElement {
|
|
18
18
|
constructor() {
|
|
19
19
|
super();
|
|
20
20
|
|
|
@@ -53,6 +53,16 @@ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), _$previewSlot =
|
|
|
53
53
|
value: void 0
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
+
_classPrivateFieldInitSpec(this, _$actionSlot, {
|
|
57
|
+
writable: true,
|
|
58
|
+
value: void 0
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
_classPrivateFieldInitSpec(this, _$actionWrapper, {
|
|
62
|
+
writable: true,
|
|
63
|
+
value: void 0
|
|
64
|
+
});
|
|
65
|
+
|
|
56
66
|
_classPrivateFieldInitSpec(this, _onPreviewSlotChange, {
|
|
57
67
|
writable: true,
|
|
58
68
|
value: () => {
|
|
@@ -74,6 +84,13 @@ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), _$previewSlot =
|
|
|
74
84
|
}
|
|
75
85
|
});
|
|
76
86
|
|
|
87
|
+
_classPrivateFieldInitSpec(this, _onActionSlotChange, {
|
|
88
|
+
writable: true,
|
|
89
|
+
value: () => {
|
|
90
|
+
setClass(_classPrivateFieldGet(this, _$actionWrapper), 'empty', _classPrivateFieldGet(this, _$actionSlot).assignedElements().length === 0);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
77
94
|
const shadowRoot = this.attachShadow();
|
|
78
95
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
79
96
|
|
|
@@ -85,11 +102,15 @@ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), _$previewSlot =
|
|
|
85
102
|
|
|
86
103
|
_classPrivateFieldSet(this, _$collapseSlot, shadowRoot.querySelector('slot[name="collapse"]'));
|
|
87
104
|
|
|
105
|
+
_classPrivateFieldSet(this, _$actionSlot, shadowRoot.querySelector('slot[name="action"]'));
|
|
106
|
+
|
|
88
107
|
_classPrivateFieldSet(this, _$previewWrapper, shadowRoot.querySelector('#preview'));
|
|
89
108
|
|
|
90
109
|
_classPrivateFieldSet(this, _$infoWrapper, shadowRoot.querySelector('#info'));
|
|
91
110
|
|
|
92
111
|
_classPrivateFieldSet(this, _$collapseWrapper, shadowRoot.querySelector('#collapse'));
|
|
112
|
+
|
|
113
|
+
_classPrivateFieldSet(this, _$actionWrapper, shadowRoot.querySelector('#action'));
|
|
93
114
|
}
|
|
94
115
|
|
|
95
116
|
connectedCallback() {
|
|
@@ -99,11 +120,15 @@ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), _$previewSlot =
|
|
|
99
120
|
|
|
100
121
|
_classPrivateFieldGet(this, _$collapseSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onCollapseSlotChange));
|
|
101
122
|
|
|
123
|
+
_classPrivateFieldGet(this, _$actionSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onActionSlotChange));
|
|
124
|
+
|
|
102
125
|
_classPrivateFieldGet(this, _onPreviewSlotChange).call(this);
|
|
103
126
|
|
|
104
127
|
_classPrivateFieldGet(this, _onInfoSlotChange).call(this);
|
|
105
128
|
|
|
106
129
|
_classPrivateFieldGet(this, _onCollapseSlotChange).call(this);
|
|
130
|
+
|
|
131
|
+
_classPrivateFieldGet(this, _onActionSlotChange).call(this);
|
|
107
132
|
}
|
|
108
133
|
|
|
109
134
|
disconnectedCallback() {
|
|
@@ -112,6 +137,8 @@ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), _$previewSlot =
|
|
|
112
137
|
_classPrivateFieldGet(this, _$infoSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onInfoSlotChange));
|
|
113
138
|
|
|
114
139
|
_classPrivateFieldGet(this, _$collapseSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onCollapseSlotChange));
|
|
140
|
+
|
|
141
|
+
_classPrivateFieldGet(this, _$actionSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onActionSlotChange));
|
|
115
142
|
}
|
|
116
143
|
|
|
117
144
|
static get observedAttributes() {
|
|
@@ -2,8 +2,6 @@ import type { TSinchElementReact } from '../types';
|
|
|
2
2
|
import type { SyntheticEvent } from 'react';
|
|
3
3
|
export declare type TSinchSegmentExpandElement = HTMLElement & {
|
|
4
4
|
value: boolean;
|
|
5
|
-
focus(): void;
|
|
6
|
-
blur(): void;
|
|
7
5
|
addEventListener(type: 'change', listener: (e: CustomEvent<boolean>) => void): void;
|
|
8
6
|
setAttribute(name: 'value', value: string): void;
|
|
9
7
|
};
|
|
@@ -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, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
11
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;position:relative;flex-direction:row;align-items:center;gap:12px;width:100%;height:
|
|
11
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;position:relative;flex-direction:row;align-items:center;gap:12px;width:100%;height:32px;padding:0 16px;box-sizing:border-box;border:1px solid var(--sinch-color-snow-600);border-left-width:0;border-right-width:0;color:var(--sinch-color-stormy-500);background-color:var(--sinch-color-snow-100);--sinch-color-icon:var(--sinch-color-stormy-500);--sinch-size-icon:16px}#wrapper:hover{background-color:var(--sinch-color-snow-500)}:host(:first-child) #wrapper{border-left-width:1px;border-top-left-radius:4px;border-bottom-left-radius:4px}:host(:last-child) #wrapper{border-right-width:1px;border-top-right-radius:4px;border-bottom-right-radius:4px}#content{font:var(--sinch-font-title-s);flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host([checked]:not([checked=false])) #wrapper{border-color:var(--sinch-color-stormy-500)}:host([checked]:not([checked=false]):not(:first-child)) #wrapper::before{content:"";width:1px;background-color:var(--sinch-color-stormy-500);position:absolute;left:0;top:-1px;bottom:-1px}:host([checked]:not([checked=false]):not(:last-child)) #wrapper::after{content:"";width:1px;background-color:var(--sinch-color-stormy-500);position:absolute;right:0;top:-1px;bottom:-1px}#button{all:initial;position:absolute;left:0;top:0;box-sizing:border-box;width:100%;height:100%;cursor:pointer;z-index:1}#button:disabled{cursor:unset}#button:focus::before{content:"";position:absolute;left:-3px;right:-3px;top:-4px;bottom:-4px;border-style:solid;border-color:var(--sinch-color-aqua-400);border-width:0}#button:focus-visible::before{border-width:2px}:host(:first-child) #button:focus::before{left:-4px;border-top-left-radius:6px;border-bottom-left-radius:6px}:host(:last-child) #button:focus::before{right:-4px;border-top-right-radius:6px;border-bottom-right-radius:6px}@supports not selector(:focus-visible){#button:focus::before{border-width:2px}}:host([disabled]:not([disabled=false])) #wrapper{background-color:var(--sinch-color-snow-100);color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><slot name="icon"></slot><label for="button" id="content"></label> <button id="button"></button></div>';
|
|
12
12
|
const template = document.createElement('template');
|
|
13
13
|
template.innerHTML = templateHTML;
|
|
14
14
|
defineCustomElement('sinch-segmented-control-option', (_$button = new WeakMap(), _$label = new WeakMap(), _onClick = new WeakMap(), class extends NectaryElement {
|
|
@@ -3,8 +3,6 @@ export declare type TSinchSegmentedControlOptionElement = HTMLElement & {
|
|
|
3
3
|
value: string;
|
|
4
4
|
disabled: boolean;
|
|
5
5
|
text: string;
|
|
6
|
-
focus(): void;
|
|
7
|
-
blur(): void;
|
|
8
6
|
setAttribute(name: 'value', value: string): void;
|
|
9
7
|
setAttribute(name: 'text', value: string): void;
|
|
10
8
|
setAttribute(name: 'disabled', value: ''): void;
|
|
@@ -2,8 +2,6 @@ import type { TSinchElementReact } from '../types';
|
|
|
2
2
|
export declare type TSinchSegmentedIconControlOptionElement = HTMLElement & {
|
|
3
3
|
value: string;
|
|
4
4
|
disabled: boolean;
|
|
5
|
-
focus(): void;
|
|
6
|
-
blur(): void;
|
|
7
5
|
setAttribute(name: 'value', value: string): void;
|
|
8
6
|
setAttribute(name: 'disabled', value: ''): void;
|
|
9
7
|
};
|
package/select/index.js
CHANGED
|
@@ -13,7 +13,7 @@ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(
|
|
|
13
13
|
|
|
14
14
|
import '../dropdown';
|
|
15
15
|
import { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateIntegerAttribute } from '../utils';
|
|
16
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{position:relative
|
|
16
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{position:relative}sinch-dropdown{display:block}#button{all:initial;display:flex;align-items:center;gap:8px;border:1px solid var(--sinch-color-stormy-200);border-radius:var(--sinch-shape-radius-s);box-sizing:border-box;width:100%;height:48px;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);cursor:pointer}#button:focus{border-color:var(--sinch-color-stormy-600)}#dropdown-icon{fill:var(--sinch-color-stormy-500)}#button>*{pointer-events:none}#button[data-unselected]{color:var(--sinch-color-text-muted)}#button:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100);cursor:initial}#button:disabled #dropdown-icon{fill:var(--sinch-color-stormy-100)}:host([invalidtext]:not([invalidtext=""])) #button:not(:disabled){border-color:var(--sinch-color-text-invalid)}#content{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#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}::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="button"></label><slot name="tooltip"></slot><span id="optional"></span></div><sinch-dropdown id="dropdown" modal orientation="bottom"><button slot="target" id="button"><span id="content"></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><slot name="option" slot="option"></slot></sinch-dropdown><div id="bottom"><span id="invalid"></span> <span id="additional"></span></div></div>';
|
|
17
17
|
const template = document.createElement('template');
|
|
18
18
|
template.innerHTML = templateHTML;
|
|
19
19
|
defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _$dropdown = new WeakMap(), _$optionSlot = new WeakMap(), _$sh = new WeakMap(), _createElement = new WeakSet(), _updateButtonContent = new WeakSet(), _onValueChange = new WeakMap(), _getOptionWithValue = new WeakSet(), _onLabelClick = new WeakMap(), _onDropdownClick = new WeakMap(), _onDropdownClose = new WeakMap(), class extends NectaryElement {
|
package/select/types.d.ts
CHANGED
|
@@ -10,8 +10,6 @@ export declare type TSinchSelectElement = HTMLElement & {
|
|
|
10
10
|
maxVisibleItems: number | null;
|
|
11
11
|
disabled: boolean;
|
|
12
12
|
readonly dropdownRect: TRect;
|
|
13
|
-
focus(): void;
|
|
14
|
-
blur(): void;
|
|
15
13
|
addEventListener(type: 'change', listener: (e: CustomEvent<string>) => void): void;
|
|
16
14
|
setAttribute(name: 'value', value: string): void;
|
|
17
15
|
setAttribute(name: 'label', value: string): void;
|
package/tabs-option/types.d.ts
CHANGED
|
@@ -4,8 +4,6 @@ export declare type TSinchTabsOptionElement = HTMLElement & {
|
|
|
4
4
|
disabled: boolean;
|
|
5
5
|
checked: boolean;
|
|
6
6
|
text: string;
|
|
7
|
-
focus(): void;
|
|
8
|
-
blur(): void;
|
|
9
7
|
setAttribute(name: 'value', value: string): void;
|
|
10
8
|
setAttribute(name: 'disabled', value: ''): void;
|
|
11
9
|
setAttribute(name: 'checked', value: ''): void;
|
package/tag-close/types.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export declare type TSinchTagCloseElement = HTMLElement
|
|
3
|
-
focus(): void;
|
|
4
|
-
blur(): void;
|
|
5
|
-
};
|
|
2
|
+
export declare type TSinchTagCloseElement = HTMLElement;
|
|
6
3
|
export declare type TSinchTagCloseReact = TSinchElementReact<TSinchTagCloseElement>;
|
package/text/index.js
CHANGED
|
@@ -7,9 +7,7 @@ template.innerHTML = templateHTML;
|
|
|
7
7
|
defineCustomElement('sinch-text', class extends NectaryElement {
|
|
8
8
|
constructor() {
|
|
9
9
|
super();
|
|
10
|
-
const shadowRoot = this.attachShadow(
|
|
11
|
-
delegatesFocus: false
|
|
12
|
-
});
|
|
10
|
+
const shadowRoot = this.attachShadow();
|
|
13
11
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
14
12
|
}
|
|
15
13
|
|
package/textarea/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
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,
|
|
4
|
+
var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _cursorPos, _isPendingDk, _onCompositionStart, _onSelectionChange, _onInput;
|
|
5
5
|
|
|
6
6
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
7
|
|
|
8
8
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
9
|
|
|
10
10
|
import { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } 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:var(--sinch-shape-radius-s);width:100%;
|
|
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:var(--sinch-shape-radius-s);width:100%;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto);background-color:var(--sinch-color-snow-100);resize:none}#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([resizable]:not([resizable=false])) #input{resize:vertical}:host([invalidtext]:not([invalidtext=""])) #input:not(:disabled){border-color:var(--sinch-color-text-invalid)}#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}::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"></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(),
|
|
14
|
+
defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _cursorPos = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onSelectionChange = new WeakMap(), _onInput = new WeakMap(), class extends NectaryElement {
|
|
15
15
|
constructor() {
|
|
16
16
|
super();
|
|
17
17
|
|
|
@@ -40,12 +40,7 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
|
|
|
40
40
|
value: void 0
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
_classPrivateFieldInitSpec(this,
|
|
44
|
-
writable: true,
|
|
45
|
-
value: null
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
_classPrivateFieldInitSpec(this, _selectionEnd, {
|
|
43
|
+
_classPrivateFieldInitSpec(this, _cursorPos, {
|
|
49
44
|
writable: true,
|
|
50
45
|
value: null
|
|
51
46
|
});
|
|
@@ -62,6 +57,13 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
|
|
|
62
57
|
}
|
|
63
58
|
});
|
|
64
59
|
|
|
60
|
+
_classPrivateFieldInitSpec(this, _onSelectionChange, {
|
|
61
|
+
writable: true,
|
|
62
|
+
value: () => {
|
|
63
|
+
_classPrivateFieldSet(this, _cursorPos, _classPrivateFieldGet(this, _$input).selectionEnd);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
65
67
|
_classPrivateFieldInitSpec(this, _onInput, {
|
|
66
68
|
writable: true,
|
|
67
69
|
value: e => {
|
|
@@ -72,29 +74,23 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
|
|
|
72
74
|
const prevValue = this.value;
|
|
73
75
|
|
|
74
76
|
if (prevValue !== nextValue) {
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
const nextSelectionEnd = _classPrivateFieldGet(this, _$input).selectionEnd;
|
|
78
|
-
|
|
79
|
-
const prevSelectionStart = _classPrivateFieldGet(this, _selectionStart);
|
|
80
|
-
|
|
81
|
-
const prevSelectionEnd = _classPrivateFieldGet(this, _selectionEnd);
|
|
82
|
-
|
|
83
|
-
const isPrevCursorEnd = prevSelectionStart === prevSelectionEnd && prevSelectionStart === prevValue.length;
|
|
77
|
+
const nextCursorPos = _classPrivateFieldGet(this, _$input).selectionEnd;
|
|
84
78
|
|
|
85
79
|
if (!_classPrivateFieldGet(this, _isPendingDk)) {
|
|
86
80
|
_classPrivateFieldGet(this, _$input).value = prevValue;
|
|
87
|
-
}
|
|
88
81
|
|
|
89
|
-
|
|
82
|
+
const prevCursorPos = _classPrivateFieldGet(this, _cursorPos);
|
|
90
83
|
|
|
91
|
-
|
|
92
|
-
|
|
84
|
+
const isPrevCursorEnd = prevCursorPos === null || prevCursorPos === prevValue.length;
|
|
85
|
+
|
|
86
|
+
if (!isPrevCursorEnd) {
|
|
87
|
+
_classPrivateFieldGet(this, _$input).setSelectionRange(prevCursorPos, prevCursorPos);
|
|
88
|
+
}
|
|
93
89
|
}
|
|
94
90
|
|
|
95
|
-
_classPrivateFieldSet(this,
|
|
91
|
+
_classPrivateFieldSet(this, _isPendingDk, false);
|
|
96
92
|
|
|
97
|
-
_classPrivateFieldSet(this,
|
|
93
|
+
_classPrivateFieldSet(this, _cursorPos, nextCursorPos);
|
|
98
94
|
|
|
99
95
|
this.dispatchEvent(new CustomEvent('change', {
|
|
100
96
|
detail: nextValue,
|
|
@@ -125,12 +121,20 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
|
|
|
125
121
|
_classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onInput));
|
|
126
122
|
|
|
127
123
|
_classPrivateFieldGet(this, _$input).addEventListener('compositionstart', _classPrivateFieldGet(this, _onCompositionStart));
|
|
124
|
+
|
|
125
|
+
_classPrivateFieldGet(this, _$input).addEventListener('mousedown', _classPrivateFieldGet(this, _onSelectionChange));
|
|
126
|
+
|
|
127
|
+
_classPrivateFieldGet(this, _$input).addEventListener('keydown', _classPrivateFieldGet(this, _onSelectionChange));
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
disconnectedCallback() {
|
|
131
131
|
_classPrivateFieldGet(this, _$input).removeEventListener('input', _classPrivateFieldGet(this, _onInput));
|
|
132
132
|
|
|
133
133
|
_classPrivateFieldGet(this, _$input).removeEventListener('compositionstart', _classPrivateFieldGet(this, _onCompositionStart));
|
|
134
|
+
|
|
135
|
+
_classPrivateFieldGet(this, _$input).removeEventListener('mousedown', _classPrivateFieldGet(this, _onSelectionChange));
|
|
136
|
+
|
|
137
|
+
_classPrivateFieldGet(this, _$input).removeEventListener('keydown', _classPrivateFieldGet(this, _onSelectionChange));
|
|
134
138
|
}
|
|
135
139
|
|
|
136
140
|
static get observedAttributes() {
|
|
@@ -143,12 +147,16 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
|
|
|
143
147
|
{
|
|
144
148
|
const nextVal = newVal ?? '';
|
|
145
149
|
|
|
146
|
-
|
|
150
|
+
const prevVal = _classPrivateFieldGet(this, _$input).value;
|
|
151
|
+
|
|
152
|
+
if (nextVal !== prevVal) {
|
|
153
|
+
const prevCursorPos = _classPrivateFieldGet(this, _$input).selectionEnd;
|
|
154
|
+
|
|
155
|
+
const isPrevCursorEnd = prevCursorPos === prevVal.length;
|
|
147
156
|
_classPrivateFieldGet(this, _$input).value = nextVal;
|
|
148
|
-
const isNextCursorEnd = _classPrivateFieldGet(this, _selectionStart) === _classPrivateFieldGet(this, _selectionEnd) && (_classPrivateFieldGet(this, _selectionStart) === null || _classPrivateFieldGet(this, _selectionStart) === nextVal.length);
|
|
149
157
|
|
|
150
|
-
if (!
|
|
151
|
-
_classPrivateFieldGet(this, _$input).setSelectionRange(_classPrivateFieldGet(this,
|
|
158
|
+
if (!isPrevCursorEnd) {
|
|
159
|
+
_classPrivateFieldGet(this, _$input).setSelectionRange(_classPrivateFieldGet(this, _cursorPos), _classPrivateFieldGet(this, _cursorPos));
|
|
152
160
|
}
|
|
153
161
|
}
|
|
154
162
|
|
package/textarea/types.d.ts
CHANGED
|
@@ -13,8 +13,6 @@ export declare type TSinchTextareaElement = HTMLElement & {
|
|
|
13
13
|
selectionDirection: HTMLTextAreaElement['selectionDirection'];
|
|
14
14
|
rows: HTMLTextAreaElement['rows'];
|
|
15
15
|
resizable: boolean;
|
|
16
|
-
focus(): void;
|
|
17
|
-
blur(): void;
|
|
18
16
|
addEventListener(type: 'change', listener: (e: CustomEvent<string>) => void): void;
|
|
19
17
|
setAttribute(name: 'value', value: string): void;
|
|
20
18
|
setAttribute(name: 'label', value: string): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import '../icon-button';
|
|
2
|
+
import '../icons/done';
|
|
3
|
+
import '../icons/arrow-drop-up';
|
|
4
|
+
import '../icons/arrow-drop-down';
|
|
5
|
+
import '../segmented-control';
|
|
6
|
+
import '../segmented-control-option';
|
|
7
|
+
import type { TSinchTimePickerElement, TSinchTimePickerReact } from './types';
|
|
8
|
+
declare global {
|
|
9
|
+
namespace JSX {
|
|
10
|
+
interface IntrinsicElements {
|
|
11
|
+
'sinch-time-picker': TSinchTimePickerReact;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
interface HTMLElementTagNameMap {
|
|
15
|
+
'sinch-time-picker': TSinchTimePickerElement;
|
|
16
|
+
}
|
|
17
|
+
}
|