@nectary/components 0.34.0 → 0.35.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/index.js +35 -10
- package/accordion/types.d.ts +3 -2
- package/accordion-item/index.js +8 -4
- package/action-menu/index.js +7 -8
- package/action-menu/types.d.ts +3 -3
- package/action-menu-option/index.js +23 -3
- package/action-menu-option/types.d.ts +2 -0
- package/alert/index.js +1 -1
- package/avatar/index.js +1 -1
- package/button/index.js +68 -4
- package/button/types.d.ts +6 -0
- package/checkbox/index.js +64 -6
- package/checkbox/types.d.ts +8 -2
- package/date-picker/index.js +37 -12
- package/date-picker/types.d.ts +4 -2
- package/dialog/index.js +5 -6
- package/dialog/types.d.ts +3 -3
- package/dropdown/index.js +44 -28
- package/dropdown/types.d.ts +6 -4
- package/dropdown-checkbox-option/index.js +1 -1
- package/dropdown-checkbox-option/types.d.ts +0 -2
- package/dropdown-radio-option/index.js +1 -1
- package/dropdown-radio-option/types.d.ts +0 -2
- package/dropdown-text-option/index.js +1 -1
- package/dropdown-text-option/types.d.ts +0 -2
- package/horizontal-stepper-item/index.js +1 -1
- package/icon-button/index.js +67 -3
- package/icon-button/types.d.ts +6 -0
- package/icons/create-icon-class.js +1 -1
- package/icons-branded/create-icon-class.js +3 -7
- package/icons-branded/types.d.ts +3 -0
- package/icons-channel/create-icon-class.js +3 -7
- package/icons-channel/types.d.ts +3 -0
- package/input/index.d.ts +0 -1
- package/input/index.js +58 -5
- package/input/types.d.ts +8 -2
- package/link/index.js +81 -3
- package/link/types.d.ts +9 -0
- package/package.json +1 -1
- package/pagination/index.js +24 -8
- package/pagination/types.d.ts +3 -1
- package/popover/index.js +5 -6
- package/popover/types.d.ts +4 -3
- package/radio/index.js +36 -8
- package/radio/types.d.ts +3 -1
- package/radio-option/index.js +1 -1
- package/search/types.d.ts +0 -1
- package/segment-collapse/index.js +28 -12
- package/segment-collapse/types.d.ts +3 -1
- package/segmented-control/index.js +28 -23
- package/segmented-control/types.d.ts +3 -2
- package/segmented-control-option/index.js +59 -13
- package/segmented-control-option/types.d.ts +4 -0
- package/segmented-icon-control/index.js +27 -16
- package/segmented-icon-control/types.d.ts +5 -2
- package/segmented-icon-control-option/index.js +54 -12
- package/segmented-icon-control-option/types.d.ts +4 -0
- package/select/index.js +68 -9
- package/select/types.d.ts +8 -2
- package/tabs/index.js +32 -8
- package/tabs/types.d.ts +3 -2
- package/tabs-option/index.js +2 -2
- package/textarea/index.js +58 -4
- package/textarea/types.d.ts +7 -2
- package/tile-control/index.d.ts +11 -0
- package/tile-control/index.js +181 -0
- package/tile-control/types.d.ts +38 -0
- package/tile-control/types.js +1 -0
- package/tile-control-option/index.d.ts +11 -0
- package/tile-control-option/index.js +161 -0
- package/tile-control-option/types.d.ts +37 -0
- package/tile-control-option/types.js +1 -0
- package/time-picker/index.js +17 -3
- package/time-picker/types.d.ts +4 -2
- package/toggle/index.js +63 -5
- package/toggle/types.d.ts +3 -1
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, _cursorPos, _isPendingDk, _onCompositionStart, _onSelectionChange, _onInput;
|
|
4
|
+
var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _cursorPos, _isPendingDk, _onCompositionStart, _onSelectionChange, _onInput, _onInputFocus, _onInputBlur, _onChangeReactHandler, _onFocusReactHandler, _onBlurReactHandler;
|
|
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 { 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%;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
|
|
10
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, getReactEventHandler, 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;display:block;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(), _cursorPos = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onSelectionChange = new WeakMap(), _onInput = new WeakMap(), class extends NectaryElement {
|
|
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(), _onInputFocus = new WeakMap(), _onInputBlur = new WeakMap(), _onChangeReactHandler = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
|
|
15
15
|
constructor() {
|
|
16
16
|
super();
|
|
17
17
|
|
|
@@ -96,10 +96,48 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
|
|
|
96
96
|
detail: nextValue,
|
|
97
97
|
bubbles: true
|
|
98
98
|
}));
|
|
99
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
100
|
+
detail: nextValue
|
|
101
|
+
}));
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
104
|
});
|
|
102
105
|
|
|
106
|
+
_classPrivateFieldInitSpec(this, _onInputFocus, {
|
|
107
|
+
writable: true,
|
|
108
|
+
value: () => {
|
|
109
|
+
this.dispatchEvent(new CustomEvent('-focus'));
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
_classPrivateFieldInitSpec(this, _onInputBlur, {
|
|
114
|
+
writable: true,
|
|
115
|
+
value: () => {
|
|
116
|
+
this.dispatchEvent(new CustomEvent('-blur'));
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
121
|
+
writable: true,
|
|
122
|
+
value: e => {
|
|
123
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
_classPrivateFieldInitSpec(this, _onFocusReactHandler, {
|
|
128
|
+
writable: true,
|
|
129
|
+
value: () => {
|
|
130
|
+
getReactEventHandler(this, 'on-focus')?.();
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
_classPrivateFieldInitSpec(this, _onBlurReactHandler, {
|
|
135
|
+
writable: true,
|
|
136
|
+
value: () => {
|
|
137
|
+
getReactEventHandler(this, 'on-blur')?.();
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
103
141
|
const shadowRoot = this.attachShadow();
|
|
104
142
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
105
143
|
|
|
@@ -125,6 +163,14 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
|
|
|
125
163
|
_classPrivateFieldGet(this, _$input).addEventListener('mousedown', _classPrivateFieldGet(this, _onSelectionChange));
|
|
126
164
|
|
|
127
165
|
_classPrivateFieldGet(this, _$input).addEventListener('keydown', _classPrivateFieldGet(this, _onSelectionChange));
|
|
166
|
+
|
|
167
|
+
_classPrivateFieldGet(this, _$input).addEventListener('focus', _classPrivateFieldGet(this, _onInputFocus));
|
|
168
|
+
|
|
169
|
+
_classPrivateFieldGet(this, _$input).addEventListener('blur', _classPrivateFieldGet(this, _onInputBlur));
|
|
170
|
+
|
|
171
|
+
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
172
|
+
this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
173
|
+
this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
128
174
|
}
|
|
129
175
|
|
|
130
176
|
disconnectedCallback() {
|
|
@@ -135,6 +181,14 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
|
|
|
135
181
|
_classPrivateFieldGet(this, _$input).removeEventListener('mousedown', _classPrivateFieldGet(this, _onSelectionChange));
|
|
136
182
|
|
|
137
183
|
_classPrivateFieldGet(this, _$input).removeEventListener('keydown', _classPrivateFieldGet(this, _onSelectionChange));
|
|
184
|
+
|
|
185
|
+
_classPrivateFieldGet(this, _$input).removeEventListener('focus', _classPrivateFieldGet(this, _onInputFocus));
|
|
186
|
+
|
|
187
|
+
_classPrivateFieldGet(this, _$input).removeEventListener('blur', _classPrivateFieldGet(this, _onInputBlur));
|
|
188
|
+
|
|
189
|
+
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
190
|
+
this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
191
|
+
this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
138
192
|
}
|
|
139
193
|
|
|
140
194
|
static get observedAttributes() {
|
package/textarea/types.d.ts
CHANGED
|
@@ -13,7 +13,9 @@ export declare type TSinchTextareaElement = HTMLElement & {
|
|
|
13
13
|
selectionDirection: HTMLTextAreaElement['selectionDirection'];
|
|
14
14
|
rows: HTMLTextAreaElement['rows'];
|
|
15
15
|
resizable: boolean;
|
|
16
|
-
addEventListener(type: 'change', listener: (e: CustomEvent<string>) => void): void;
|
|
16
|
+
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
17
|
+
addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
|
|
18
|
+
addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
|
|
17
19
|
setAttribute(name: 'value', value: string): void;
|
|
18
20
|
setAttribute(name: 'label', value: string): void;
|
|
19
21
|
setAttribute(name: 'placeholder', value: string): void;
|
|
@@ -35,5 +37,8 @@ export declare type TSinchTextareaReact = TSinchElementReact<TSinchTextareaEleme
|
|
|
35
37
|
'aria-label': string;
|
|
36
38
|
rows?: number;
|
|
37
39
|
resizable?: boolean;
|
|
38
|
-
onChange
|
|
40
|
+
onChange?: (e: SyntheticEvent<TSinchTextareaElement, CustomEvent<string>>) => void;
|
|
41
|
+
'on-change'?: (e: CustomEvent<string>) => void;
|
|
42
|
+
'on-focus'?: (e: CustomEvent<void>) => void;
|
|
43
|
+
'on-blur'?: (e: CustomEvent<void>) => void;
|
|
39
44
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TSinchTileControlElement, TSinchTileControlReact } from './types';
|
|
2
|
+
declare global {
|
|
3
|
+
namespace JSX {
|
|
4
|
+
interface IntrinsicElements {
|
|
5
|
+
'sinch-tile-control': TSinchTileControlReact;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
interface HTMLElementTagNameMap {
|
|
9
|
+
'sinch-tile-control': TSinchTileControlElement;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$slot, _onSlotChange, _onOptionChange, _onValueChange, _onSmallChange, _onChangeReactHandler;
|
|
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 { defineCustomElement, getAttribute, getBooleanAttribute, getCsvSet, getFirstCsvValue, getIntegerAttribute, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv, updateIntegerAttribute } from '../utils';
|
|
15
|
+
const templateHTML = '<style>:host{display:block;outline:0;--sinch-grid-num-columns:1}#wrapper{display:grid;grid-template-columns:repeat(var(--sinch-grid-num-columns),auto);gap:16px;width:fit-content}:host([small]:not([small=false])) #wrapper{gap:8px}:host([cols="2"]){--sinch-grid-num-columns:2}:host([cols="3"]){--sinch-grid-num-columns:3}:host([cols="4"]){--sinch-grid-num-columns:4}:host([cols="5"]){--sinch-grid-num-columns:5}:host([cols="6"]){--sinch-grid-num-columns:6}:host([cols="7"]){--sinch-grid-num-columns:7}:host([cols="8"]){--sinch-grid-num-columns:8}</style><div id="wrapper"><slot></slot></div>';
|
|
16
|
+
const template = document.createElement('template');
|
|
17
|
+
template.innerHTML = templateHTML;
|
|
18
|
+
defineCustomElement('sinch-tile-control', (_$slot = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), _onValueChange = new WeakSet(), _onSmallChange = new WeakSet(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
|
|
22
|
+
_classPrivateMethodInitSpec(this, _onSmallChange);
|
|
23
|
+
|
|
24
|
+
_classPrivateMethodInitSpec(this, _onValueChange);
|
|
25
|
+
|
|
26
|
+
_classPrivateFieldInitSpec(this, _$slot, {
|
|
27
|
+
writable: true,
|
|
28
|
+
value: void 0
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
_classPrivateFieldInitSpec(this, _onSlotChange, {
|
|
32
|
+
writable: true,
|
|
33
|
+
value: () => {
|
|
34
|
+
_classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, this.value);
|
|
35
|
+
|
|
36
|
+
_classPrivateMethodGet(this, _onSmallChange, _onSmallChange2).call(this);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
_classPrivateFieldInitSpec(this, _onOptionChange, {
|
|
41
|
+
writable: true,
|
|
42
|
+
value: e => {
|
|
43
|
+
e.stopPropagation();
|
|
44
|
+
const $elem = e.target;
|
|
45
|
+
const value = e.detail;
|
|
46
|
+
const detail = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute($elem, 'data-checked')) : value;
|
|
47
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
48
|
+
detail,
|
|
49
|
+
bubbles: true
|
|
50
|
+
}));
|
|
51
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
52
|
+
detail
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
58
|
+
writable: true,
|
|
59
|
+
value: e => {
|
|
60
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const shadowRoot = this.attachShadow();
|
|
65
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
66
|
+
|
|
67
|
+
_classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
connectedCallback() {
|
|
71
|
+
this.setAttribute('role', 'tablist');
|
|
72
|
+
|
|
73
|
+
_classPrivateFieldGet(this, _$slot).addEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
|
|
74
|
+
|
|
75
|
+
_classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
|
|
76
|
+
|
|
77
|
+
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
disconnectedCallback() {
|
|
81
|
+
_classPrivateFieldGet(this, _$slot).removeEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
|
|
82
|
+
|
|
83
|
+
_classPrivateFieldGet(this, _$slot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
|
|
84
|
+
|
|
85
|
+
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static get observedAttributes() {
|
|
89
|
+
return ['value', 'small', 'multiple'];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
get nodeName() {
|
|
93
|
+
return 'select';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
set value(value) {
|
|
97
|
+
updateAttribute(this, 'value', value);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
get value() {
|
|
101
|
+
return getAttribute(this, 'value', '');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
set small(isSmall) {
|
|
105
|
+
updateBooleanAttribute(this, 'small', isSmall);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
get small() {
|
|
109
|
+
return getBooleanAttribute(this, 'small');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
set multiple(isMultiple) {
|
|
113
|
+
updateBooleanAttribute(this, 'multiple', isMultiple);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
get multiple() {
|
|
117
|
+
return getBooleanAttribute(this, 'multiple');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
set cols(value) {
|
|
121
|
+
updateIntegerAttribute(this, 'cols', value);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
get cols() {
|
|
125
|
+
return getIntegerAttribute(this, 'cols', 1);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
129
|
+
if (oldVal === newVal) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
switch (name) {
|
|
134
|
+
case 'value':
|
|
135
|
+
{
|
|
136
|
+
_classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, newVal ?? '');
|
|
137
|
+
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
case 'small':
|
|
142
|
+
{
|
|
143
|
+
_classPrivateMethodGet(this, _onSmallChange, _onSmallChange2).call(this);
|
|
144
|
+
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
case 'multiple':
|
|
149
|
+
{
|
|
150
|
+
_classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, this.value);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
}));
|
|
156
|
+
|
|
157
|
+
function _onValueChange2(csv) {
|
|
158
|
+
if (this.multiple) {
|
|
159
|
+
const values = getCsvSet(csv);
|
|
160
|
+
|
|
161
|
+
for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
|
|
162
|
+
const isChecked = !getBooleanAttribute($option, 'disabled') && values.has(getAttribute($option, 'value', ''));
|
|
163
|
+
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
const value = getFirstCsvValue(csv);
|
|
167
|
+
|
|
168
|
+
for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
|
|
169
|
+
const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
|
|
170
|
+
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function _onSmallChange2() {
|
|
176
|
+
const isSmall = this.small;
|
|
177
|
+
|
|
178
|
+
for (const $opt of _classPrivateFieldGet(this, _$slot).assignedElements()) {
|
|
179
|
+
updateBooleanAttribute($opt, 'data-small', isSmall);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
import type { SyntheticEvent } from 'react';
|
|
3
|
+
export declare type TSinchTileControlElement = HTMLElement & {
|
|
4
|
+
/** Value */
|
|
5
|
+
value: string;
|
|
6
|
+
/** Small */
|
|
7
|
+
small: boolean;
|
|
8
|
+
/** Multiple */
|
|
9
|
+
multiple: boolean;
|
|
10
|
+
/** Number of columns from 1 to 8 */
|
|
11
|
+
cols: number;
|
|
12
|
+
/** Change value event */
|
|
13
|
+
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
14
|
+
/** Value */
|
|
15
|
+
setAttribute(name: 'value', value: string): void;
|
|
16
|
+
/** Small */
|
|
17
|
+
setAttribute(name: 'small', value: ''): void;
|
|
18
|
+
/** Multiple */
|
|
19
|
+
setAttribute(name: 'multiple', value: ''): void;
|
|
20
|
+
/** Number of columns from 1 to 8 */
|
|
21
|
+
setAttribute(name: 'cols', value: string): void;
|
|
22
|
+
};
|
|
23
|
+
export declare type TSinchTileControlReact = TSinchElementReact<TSinchTileControlElement> & {
|
|
24
|
+
/** Value */
|
|
25
|
+
value: string;
|
|
26
|
+
/** Multiple */
|
|
27
|
+
multiple?: boolean;
|
|
28
|
+
/** Small */
|
|
29
|
+
small?: boolean;
|
|
30
|
+
/** Number of columns from 1 to 8 */
|
|
31
|
+
cols: number;
|
|
32
|
+
/** Label that is used for a11y */
|
|
33
|
+
'aria-label': string;
|
|
34
|
+
/** @deprecated Change value handler */
|
|
35
|
+
onChange?: (event: SyntheticEvent<TSinchTileControlElement, CustomEvent<string>>) => void;
|
|
36
|
+
/** Change value handler */
|
|
37
|
+
'on-change'?: (e: CustomEvent<string>) => void;
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TSinchTileControlOptionElement, TSinchTileControlOptionReact } from './types';
|
|
2
|
+
declare global {
|
|
3
|
+
namespace JSX {
|
|
4
|
+
interface IntrinsicElements {
|
|
5
|
+
'sinch-tile-control-option': TSinchTileControlOptionReact;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
interface HTMLElementTagNameMap {
|
|
9
|
+
'sinch-tile-control-option': TSinchTileControlOptionElement;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$button, _$text, _onButtonClick, _onButtonFocus, _onButtonBlur, _onFocusReactHandler, _onBlurReactHandler;
|
|
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, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
11
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}button{all:initial;position:relative;display:flex;flex-direction:column;justify-content:space-between;box-sizing:border-box;width:88px;height:88px;padding:16px 8px 8px;border-radius:var(--sinch-shape-radius-l);background-color:var(--sinch-color-snow-100);box-shadow:var(--sinch-elevation-leve-1);cursor:pointer}:host([data-small])>button{width:64px;height:64px;border-radius:var(--sinch-shape-radius-m);padding:12px 4px 4px}button::before{content:"";position:absolute;left:0;top:0;bottom:0;right:0;border:1px solid var(--sinch-color-snow-700);border-radius:var(--sinch-shape-radius-l);pointer-events:none}:host([data-small])>button::before{border-radius:var(--sinch-shape-radius-m)}button:focus-visible::after{position:absolute;content:"";left:50%;top:50%;transform:translate(-50%,-50%);width:100%;height:100%;padding:2px;border:2px solid var(--sinch-color-aqua-400);border-radius:calc(var(--sinch-shape-radius-l) + 4px);pointer-events:none}:host([data-small])>button:focus-visible::after{border-radius:calc(var(--sinch-shape-radius-m) + 4px)}@supports not selector(:focus-visible){button:focus::after{position:absolute;content:"";left:50%;top:50%;transform:translate(-50%,-50%);width:100%;height:100%;padding:2px;border:2px solid var(--sinch-color-aqua-400);border-radius:calc(var(--sinch-shape-radius-l) + 4px)}:host([data-small])>button:focus::after{border-radius:calc(var(--sinch-shape-radius-m) + 4px)}}button:enabled:hover{background-color:var(--sinch-color-tropical-100)}button:enabled:hover::before{border-color:var(--sinch-color-tropical-100)}:host([data-checked])>button:enabled,button:enabled:active{box-shadow:var(--sinch-elevation-level-0)}:host([data-checked])>button:enabled::before,button:enabled:active::before{border-width:2px;border-color:var(--sinch-color-stormy-500)}button:disabled{cursor:initial}button:disabled>#icon,button:disabled>#text{opacity:.5}#text{display:inline-block;min-height:20px;text-align:center;font:var(--sinch-font-text-xs);color:var(--sinch-color-stormy-500);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#icon{width:32px;height:32px;align-self:center;--sinch-size-icon:32px;--sinch-color-icon:var(--sinch-color-stormy-500)}:host([data-small]) #icon{width:24px;height:24px;--sinch-size-icon:24px}button>*{pointer-events:none}</style><button><div id="icon"><slot name="icon"></slot></div><span id="text"></span></button>';
|
|
12
|
+
const template = document.createElement('template');
|
|
13
|
+
template.innerHTML = templateHTML;
|
|
14
|
+
defineCustomElement('sinch-tile-control-option', (_$button = new WeakMap(), _$text = new WeakMap(), _onButtonClick = new WeakMap(), _onButtonFocus = new WeakMap(), _onButtonBlur = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
|
|
18
|
+
_classPrivateFieldInitSpec(this, _$button, {
|
|
19
|
+
writable: true,
|
|
20
|
+
value: void 0
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
_classPrivateFieldInitSpec(this, _$text, {
|
|
24
|
+
writable: true,
|
|
25
|
+
value: void 0
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
_classPrivateFieldInitSpec(this, _onButtonClick, {
|
|
29
|
+
writable: true,
|
|
30
|
+
value: e => {
|
|
31
|
+
e.stopPropagation();
|
|
32
|
+
this.dispatchEvent(new CustomEvent('option-change', {
|
|
33
|
+
detail: this.value,
|
|
34
|
+
bubbles: true
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
_classPrivateFieldInitSpec(this, _onButtonFocus, {
|
|
40
|
+
writable: true,
|
|
41
|
+
value: () => {
|
|
42
|
+
this.dispatchEvent(new CustomEvent('-focus'));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
_classPrivateFieldInitSpec(this, _onButtonBlur, {
|
|
47
|
+
writable: true,
|
|
48
|
+
value: () => {
|
|
49
|
+
this.dispatchEvent(new CustomEvent('-blur'));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
_classPrivateFieldInitSpec(this, _onFocusReactHandler, {
|
|
54
|
+
writable: true,
|
|
55
|
+
value: () => {
|
|
56
|
+
getReactEventHandler(this, 'on-focus')?.();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
_classPrivateFieldInitSpec(this, _onBlurReactHandler, {
|
|
61
|
+
writable: true,
|
|
62
|
+
value: () => {
|
|
63
|
+
getReactEventHandler(this, 'on-blur')?.();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const shadowRoot = this.attachShadow();
|
|
68
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
69
|
+
|
|
70
|
+
_classPrivateFieldSet(this, _$button, shadowRoot.querySelector('button'));
|
|
71
|
+
|
|
72
|
+
_classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
connectedCallback() {
|
|
76
|
+
this.setAttribute('role', 'tab');
|
|
77
|
+
|
|
78
|
+
_classPrivateFieldGet(this, _$button).addEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
|
|
79
|
+
|
|
80
|
+
_classPrivateFieldGet(this, _$button).addEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
|
|
81
|
+
|
|
82
|
+
_classPrivateFieldGet(this, _$button).addEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
|
|
83
|
+
|
|
84
|
+
this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
85
|
+
this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
disconnectedCallback() {
|
|
89
|
+
_classPrivateFieldGet(this, _$button).removeEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
|
|
90
|
+
|
|
91
|
+
_classPrivateFieldGet(this, _$button).removeEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
|
|
92
|
+
|
|
93
|
+
_classPrivateFieldGet(this, _$button).removeEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
|
|
94
|
+
|
|
95
|
+
this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
96
|
+
this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static get observedAttributes() {
|
|
100
|
+
return ['data-checked', 'text', 'disabled'];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
104
|
+
if (oldVal === newVal) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
switch (name) {
|
|
109
|
+
case 'text':
|
|
110
|
+
{
|
|
111
|
+
_classPrivateFieldGet(this, _$text).textContent = newVal;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
case 'data-checked':
|
|
116
|
+
{
|
|
117
|
+
updateExplicitBooleanAttribute(this, 'aria-selected', isAttrTrue(newVal));
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
case 'disabled':
|
|
122
|
+
{
|
|
123
|
+
_classPrivateFieldGet(this, _$button).disabled = isAttrTrue(newVal);
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
set value(value) {
|
|
130
|
+
updateAttribute(this, 'value', value);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
get value() {
|
|
134
|
+
return getAttribute(this, 'value', '');
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
set disabled(isDisabled) {
|
|
138
|
+
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
get disabled() {
|
|
142
|
+
return getBooleanAttribute(this, 'disabled');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
set text(value) {
|
|
146
|
+
updateAttribute(this, 'text', value);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
get text() {
|
|
150
|
+
return getAttribute(this, 'text', '');
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
focus() {
|
|
154
|
+
_classPrivateFieldGet(this, _$button).focus();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
blur() {
|
|
158
|
+
_classPrivateFieldGet(this, _$button).blur();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
}));
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
export declare type TSinchTileControlOptionElement = HTMLElement & {
|
|
3
|
+
/** Value */
|
|
4
|
+
value: string;
|
|
5
|
+
/** Text content */
|
|
6
|
+
text: string;
|
|
7
|
+
/** Disabled */
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
/** Small */
|
|
10
|
+
small: boolean;
|
|
11
|
+
/** Focus event */
|
|
12
|
+
addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
|
|
13
|
+
/** Blur event */
|
|
14
|
+
addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
|
|
15
|
+
/** Value */
|
|
16
|
+
setAttribute(name: 'value', value: string): void;
|
|
17
|
+
/** Text content */
|
|
18
|
+
setAttribute(attr: 'text', value: string): void;
|
|
19
|
+
/** Disabled */
|
|
20
|
+
setAttribute(name: 'disabled', value: ''): void;
|
|
21
|
+
/** Small */
|
|
22
|
+
setAttribute(name: 'small', value: ''): void;
|
|
23
|
+
};
|
|
24
|
+
export declare type TSinchTileControlOptionReact = TSinchElementReact<TSinchTileControlOptionElement> & {
|
|
25
|
+
/** Value */
|
|
26
|
+
value: string;
|
|
27
|
+
/** Text content */
|
|
28
|
+
text: string;
|
|
29
|
+
/** Label that is used for a11y */
|
|
30
|
+
'aria-label': string;
|
|
31
|
+
/** Disabled */
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
/** Focus handler */
|
|
34
|
+
'on-focus'?: (e: CustomEvent<void>) => void;
|
|
35
|
+
/** Blur handler */
|
|
36
|
+
'on-blur'?: (e: CustomEvent<void>) => void;
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/time-picker/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 _$pickerHours, _$pickerMinutes, _$pickerTouch, _$needleHour, _$needleMinute, _$headerHours, _$headerHoursText, _$headerMinutes, _$headerMinutesText, _$ampm, _$submitButton, _hour, _minute, _getClickDegree, _onPickerClick, _render, _selectHour, _selectMinute, _onAmPmChange, _onSubmitButtonClick, _onHoursKeydown, _onMinutesKeydown;
|
|
4
|
+
var _$pickerHours, _$pickerMinutes, _$pickerTouch, _$needleHour, _$needleMinute, _$headerHours, _$headerHoursText, _$headerMinutes, _$headerMinutesText, _$ampm, _$submitButton, _hour, _minute, _getClickDegree, _onPickerClick, _render, _selectHour, _selectMinute, _onAmPmChange, _onSubmitButtonClick, _onHoursKeydown, _onMinutesKeydown, _onChangeReactHandler;
|
|
5
5
|
|
|
6
6
|
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
7
7
|
|
|
@@ -17,7 +17,7 @@ import '../icons/arrow-drop-up';
|
|
|
17
17
|
import '../icons/arrow-drop-down';
|
|
18
18
|
import '../segmented-control';
|
|
19
19
|
import '../segmented-control-option';
|
|
20
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, getRect, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
20
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, getRect, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
21
21
|
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:column;width:248px;padding:16px;box-sizing:border-box;gap:16px}#header{position:relative;width:100%;height:48px;font:var(--sinch-font-title-xl);line-height:48px}#footer{display:flex;justify-content:center;width:100%;height:32px}#picker{position:relative;width:216px;height:216px;border-radius:50%;box-sizing:border-box;border:1px solid var(--sinch-color-stormy-500)}#digit-minutes,#picker-hours{position:absolute;left:0;top:0;width:100%;height:100%;border-radius:50%}.digit-hour-12,.digit-hour-24,.digit-minute{position:absolute;width:28px;height:28px;font:var(--sinch-font-text-s);line-height:28px;text-align:center;color:var(--sinch-color-text-default);top:calc(50% - 14px);left:calc(50% - 14px);z-index:1;cursor:pointer}.digit-hour-24{font:var(--sinch-font-text-xs);line-height:28px;color:var(--sinch-color-text-muted)}.digit-minute{font:var(--sinch-font-text-xs);line-height:28px;color:var(--sinch-color-text-muted)}.digit-hour-12:hover,.digit-hour-24:hover,.digit-minute:hover{color:var(--sinch-color-tropical-500)}.digit-hour-12.selected,.digit-hour-24.selected,.digit-minute.selected{color:var(--sinch-color-tropical-500)}.digit-hour-12.selected{font-size:16px}.digit-hour-24.selected{font-size:16px}.digit-minute.selected{font-size:16px}#picker-touch{position:absolute;left:0;top:0;width:100%;height:100%;cursor:pointer;border-radius:50%}#needle-hour,#needle-minute,#picker-touch::after{background-color:var(--sinch-color-stormy-500)}#needle-hour,#needle-minute{position:absolute;transform-origin:bottom center;transform:rotate(0);bottom:50%;height:50px;transition-duration:.25s;transition-timing-function:ease-in-out;transition-property:transform height;z-index:2}@media (prefers-reduced-motion){#needle-hour,#needle-minute{transition:none}}#needle-hour{width:4px;left:calc(50% - 2px);border-radius:2px}#needle-minute{width:2px;left:calc(50% - 1px);border-radius:1px}#needle-minute:not(.selected)::after{content:"";position:absolute;transform:translateX(-50%);left:0;top:-16px;width:4px;height:4px;border-radius:50%;background-color:var(--sinch-color-tropical-500)}#picker-touch::after{content:"";position:absolute;top:50%;left:50%;width:12px;height:12px;border-radius:50%;transform:translate(-50%,-50%)}#header-hours,#header-minutes{position:absolute;padding:0 4px;width:50px;outline:0;--sinch-icon-size:24px}#header-hours{right:calc(50% + 8px);text-align:right}#header-minutes{left:calc(50% + 8px)}#header-hours::before,#header-minutes::before{content:"";display:none;position:absolute;border-radius:12px;left:50%;top:50%;width:100%;height:100%;transform:translate(-50%,-50%);padding:1px;border:1px solid var(--sinch-color-aqua-400)}#header-hours-down,#header-hours-up,#header-minutes-down,#header-minutes-up{display:none;position:absolute;left:50%;transform:translateX(-50%)}#header-hours-up,#header-minutes-up{top:-18px}#header-hours-down,#header-minutes-down{bottom:-18px}#header-hours:focus #header-hours-down,#header-hours:focus #header-hours-up,#header-hours:focus::before{display:block}#header-minutes:focus #header-minutes-down,#header-minutes:focus #header-minutes-up,#header-minutes:focus::before{display:block}#header-colon{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}#submit{position:absolute;right:0;top:50%;transform:translateY(-50%)}:host([ampm]) .digit-hour-24{display:none}:host(:not([ampm])) #footer{display:none}</style><div id="wrapper"><div id="header"><div id="header-hours" tabindex="0" role="meter" aria-valuemin="0" aria-valuemax="23" aria-valuenow="0" aria-valuetext="0"><span>00</span><sinch-icon-arrow-drop-up id="header-hours-up"></sinch-icon-arrow-drop-up><sinch-icon-arrow-drop-down id="header-hours-down"></sinch-icon-arrow-drop-down></div><div id="header-colon">:</div><div id="header-minutes" tabindex="0" role="meter" aria-valuemin="0" aria-valuemax="59" aria-valuenow="0" aria-valuetext="0"><span>00</span><sinch-icon-arrow-drop-up id="header-minutes-up"></sinch-icon-arrow-drop-up><sinch-icon-arrow-drop-down id="header-minutes-down"></sinch-icon-arrow-drop-down></div><sinch-icon-button id="submit" small aria-label="Submit"><sinch-icon-done slot="icon"></sinch-icon-done></sinch-icon-button></div><div id="picker" aria-hidden="true"><div id="picker-hours"></div><div id="picker-minutes"></div><div id="picker-touch"><div id="needle-hour"></div><div id="needle-minute"></div></div></div><div id="footer"><sinch-segmented-control id="ampm"><sinch-segmented-control-option value="am" text="AM" aria-label="AM"></sinch-segmented-control-option><sinch-segmented-control-option value="pm" text="PM" aria-label="PM"></sinch-segmented-control-option></sinch-segmented-control></div></div>';
|
|
22
22
|
import { getNeedleRotationDeg, getShortestCssDeg, hourToIndex, parseTime, stringifyHour, stringifyHourFace, stringifyMinute, stringifyTime } from './utils';
|
|
23
23
|
const template = document.createElement('template');
|
|
@@ -32,7 +32,7 @@ const HOUR_24_RADIUS = HOUR_12_RADIUS - HOUR_24_DIGIT_SIZE;
|
|
|
32
32
|
const NEEDLE_HOUR_12_LENGTH = HOUR_12_RADIUS;
|
|
33
33
|
const NEEDLE_HOUR_24_LENGTH = HOUR_24_RADIUS;
|
|
34
34
|
const NEEDLE_MINUTE_LENGTH = MINUTE_RADIUS;
|
|
35
|
-
defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$pickerMinutes = new WeakMap(), _$pickerTouch = new WeakMap(), _$needleHour = new WeakMap(), _$needleMinute = new WeakMap(), _$headerHours = new WeakMap(), _$headerHoursText = new WeakMap(), _$headerMinutes = new WeakMap(), _$headerMinutesText = new WeakMap(), _$ampm = new WeakMap(), _$submitButton = new WeakMap(), _hour = new WeakMap(), _minute = new WeakMap(), _getClickDegree = new WeakSet(), _onPickerClick = new WeakMap(), _render = new WeakSet(), _selectHour = new WeakSet(), _selectMinute = new WeakSet(), _onAmPmChange = new WeakMap(), _onSubmitButtonClick = new WeakMap(), _onHoursKeydown = new WeakMap(), _onMinutesKeydown = new WeakMap(), class extends NectaryElement {
|
|
35
|
+
defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$pickerMinutes = new WeakMap(), _$pickerTouch = new WeakMap(), _$needleHour = new WeakMap(), _$needleMinute = new WeakMap(), _$headerHours = new WeakMap(), _$headerHoursText = new WeakMap(), _$headerMinutes = new WeakMap(), _$headerMinutesText = new WeakMap(), _$ampm = new WeakMap(), _$submitButton = new WeakMap(), _hour = new WeakMap(), _minute = new WeakMap(), _getClickDegree = new WeakSet(), _onPickerClick = new WeakMap(), _render = new WeakSet(), _selectHour = new WeakSet(), _selectMinute = new WeakSet(), _onAmPmChange = new WeakMap(), _onSubmitButtonClick = new WeakMap(), _onHoursKeydown = new WeakMap(), _onMinutesKeydown = new WeakMap(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
|
|
36
36
|
constructor() {
|
|
37
37
|
super();
|
|
38
38
|
|
|
@@ -182,6 +182,9 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
|
|
|
182
182
|
bubbles: true,
|
|
183
183
|
detail: value
|
|
184
184
|
}));
|
|
185
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
186
|
+
detail: value
|
|
187
|
+
}));
|
|
185
188
|
}
|
|
186
189
|
});
|
|
187
190
|
|
|
@@ -235,6 +238,13 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
|
|
|
235
238
|
}
|
|
236
239
|
});
|
|
237
240
|
|
|
241
|
+
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
242
|
+
writable: true,
|
|
243
|
+
value: e => {
|
|
244
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
|
|
238
248
|
const shadowRoot = this.attachShadow();
|
|
239
249
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
240
250
|
|
|
@@ -323,6 +333,8 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
|
|
|
323
333
|
_classPrivateFieldGet(this, _$headerHours).addEventListener('keydown', _classPrivateFieldGet(this, _onHoursKeydown));
|
|
324
334
|
|
|
325
335
|
_classPrivateFieldGet(this, _$headerMinutes).addEventListener('keydown', _classPrivateFieldGet(this, _onMinutesKeydown));
|
|
336
|
+
|
|
337
|
+
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
326
338
|
}
|
|
327
339
|
|
|
328
340
|
disconnectedCallback() {
|
|
@@ -335,6 +347,8 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
|
|
|
335
347
|
_classPrivateFieldGet(this, _$headerHours).removeEventListener('keydown', _classPrivateFieldGet(this, _onHoursKeydown));
|
|
336
348
|
|
|
337
349
|
_classPrivateFieldGet(this, _$headerMinutes).removeEventListener('keydown', _classPrivateFieldGet(this, _onMinutesKeydown));
|
|
350
|
+
|
|
351
|
+
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
338
352
|
}
|
|
339
353
|
|
|
340
354
|
static get observedAttributes() {
|