tyrell-components 1.0.0-RC15 → 1.0.0-RC17
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/README.md +44 -52
- package/css/tyrell-colors-static.css +14 -0
- package/css/tyrell-theme.css +13 -7
- package/css/tyrell.css +15 -22
- package/dist/tyrell-colors-static.css +1 -1
- package/dist/tyrell-theme.css +1 -1
- package/dist/tyrell.css +1 -1
- package/dist/tyrell.js +1 -1
- package/lib/base/ty-component.d.ts +37 -15
- package/lib/base/ty-component.js +90 -26
- package/lib/components/button.d.ts +14 -0
- package/lib/components/button.js +61 -7
- package/lib/components/calendar-month.d.ts +7 -1
- package/lib/components/calendar-month.js +38 -30
- package/lib/components/calendar-navigation.d.ts +11 -0
- package/lib/components/calendar-navigation.js +68 -44
- package/lib/components/calendar.d.ts +52 -3
- package/lib/components/calendar.js +274 -61
- package/lib/components/checkbox.d.ts +8 -1
- package/lib/components/checkbox.js +29 -8
- package/lib/components/copy.d.ts +2 -0
- package/lib/components/copy.js +24 -33
- package/lib/components/date-picker.d.ts +68 -34
- package/lib/components/date-picker.js +386 -389
- package/lib/components/file-upload.d.ts +7 -0
- package/lib/components/file-upload.js +36 -4
- package/lib/components/input.d.ts +73 -3
- package/lib/components/input.js +159 -24
- package/lib/components/modal.d.ts +4 -8
- package/lib/components/modal.js +103 -33
- package/lib/components/option.js +7 -5
- package/lib/components/popup.js +117 -14
- package/lib/components/radio.d.ts +24 -0
- package/lib/components/radio.js +55 -32
- package/lib/components/resize-observer.js +2 -0
- package/lib/components/scroll-container.d.ts +3 -2
- package/lib/components/scroll-container.js +7 -8
- package/lib/components/select.d.ts +68 -11
- package/lib/components/select.js +196 -44
- package/lib/components/selected-tags.d.ts +7 -1
- package/lib/components/selected-tags.js +10 -1
- package/lib/components/switch.d.ts +9 -1
- package/lib/components/switch.js +29 -8
- package/lib/components/tab.d.ts +49 -1
- package/lib/components/tab.js +151 -10
- package/lib/components/tabs.d.ts +14 -2
- package/lib/components/tabs.js +185 -136
- package/lib/components/tag.d.ts +4 -7
- package/lib/components/tag.js +6 -7
- package/lib/components/textarea.d.ts +51 -5
- package/lib/components/textarea.js +95 -30
- package/lib/components/tooltip.d.ts +4 -3
- package/lib/components/tooltip.js +34 -24
- package/lib/components/wizard.d.ts +5 -4
- package/lib/components/wizard.js +120 -156
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -0
- package/lib/styles/button.js +21 -19
- package/lib/styles/calendar-month.d.ts +3 -0
- package/lib/styles/calendar-month.js +43 -27
- package/lib/styles/calendar-navigation.d.ts +1 -1
- package/lib/styles/calendar-navigation.js +55 -26
- package/lib/styles/calendar.d.ts +3 -2
- package/lib/styles/calendar.js +77 -0
- package/lib/styles/checkbox.js +31 -13
- package/lib/styles/copy.js +5 -1
- package/lib/styles/date-picker.js +68 -26
- package/lib/styles/file-upload.d.ts +1 -1
- package/lib/styles/file-upload.js +3 -3
- package/lib/styles/icon.d.ts +1 -1
- package/lib/styles/icon.js +2 -2
- package/lib/styles/input.js +6 -10
- package/lib/styles/option.d.ts +1 -1
- package/lib/styles/option.js +7 -3
- package/lib/styles/popup.d.ts +1 -1
- package/lib/styles/popup.js +10 -5
- package/lib/styles/radio.js +18 -6
- package/lib/styles/scroll-container.d.ts +1 -1
- package/lib/styles/scroll-container.js +1 -1
- package/lib/styles/select-base.js +24 -3
- package/lib/styles/select.d.ts +1 -1
- package/lib/styles/select.js +10 -0
- package/lib/styles/step.d.ts +1 -1
- package/lib/styles/step.js +1 -9
- package/lib/styles/switch.js +14 -6
- package/lib/styles/tab.d.ts +1 -1
- package/lib/styles/tab.js +67 -3
- package/lib/styles/tabs.d.ts +1 -1
- package/lib/styles/tabs.js +7 -3
- package/lib/styles/tag.js +3 -3
- package/lib/styles/textarea.d.ts +1 -1
- package/lib/styles/textarea.js +7 -0
- package/lib/styles/wizard.d.ts +9 -5
- package/lib/styles/wizard.js +211 -99
- package/lib/types/common.d.ts +2 -2
- package/lib/utils/calendar-utils.d.ts +49 -0
- package/lib/utils/calendar-utils.js +63 -6
- package/lib/utils/property-manager.d.ts +7 -1
- package/lib/utils/property-manager.js +16 -4
- package/lib/utils/scroll-lock.d.ts +10 -4
- package/lib/utils/scroll-lock.js +102 -2
- package/lib/utils/upgrade-properties.d.ts +21 -0
- package/lib/utils/upgrade-properties.js +47 -0
- package/lib/utils/validity.d.ts +122 -0
- package/lib/utils/validity.js +289 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +27 -5
|
@@ -4,7 +4,8 @@ import { ensureStyles } from '../utils/styles.js';
|
|
|
4
4
|
import { textareaStyles } from '../styles/textarea.js';
|
|
5
5
|
import { CustomScrollbar, isCustomScrollbarEnabled } from '../utils/custom-scrollbar.js';
|
|
6
6
|
import { customScrollbarStyles } from '../styles/custom-scrollbar.js';
|
|
7
|
-
|
|
7
|
+
import { nativeMessage, lengthValidity, toLimit } from '../utils/validity.js';
|
|
8
|
+
import { REQUIRED_ICON_SVG } from '../utils/icons.js';
|
|
8
9
|
export class TyTextarea extends TyComponent {
|
|
9
10
|
constructor() {
|
|
10
11
|
super();
|
|
@@ -13,19 +14,32 @@ this._dummyEl = null;
|
|
|
13
14
|
this._scrollbar = null;
|
|
14
15
|
this._isFocused = false;
|
|
15
16
|
this.handleInputEvent = (e) => {
|
|
17
|
+
this._userEdited = true;
|
|
18
|
+
e.stopPropagation();
|
|
19
|
+
e.stopImmediatePropagation();
|
|
16
20
|
const target = e.target;
|
|
17
21
|
const newValue = target.value;
|
|
18
22
|
this.value = newValue;
|
|
19
23
|
if (this._textareaEl && this._dummyEl) {
|
|
20
24
|
this.resizeTextarea(this._textareaEl, this._dummyEl);
|
|
21
25
|
}
|
|
22
|
-
this.
|
|
26
|
+
this._internals.setFormValue(this.value || '');
|
|
27
|
+
this.updateValidity();
|
|
28
|
+
this.emitValueEvent('input', e);
|
|
23
29
|
};
|
|
30
|
+
this._valueAtFocus = null;
|
|
24
31
|
this.handleFocusEvent = () => {
|
|
25
32
|
this._isFocused = true;
|
|
33
|
+
this._valueAtFocus = this.value;
|
|
26
34
|
};
|
|
27
|
-
this.handleBlurEvent = () => {
|
|
35
|
+
this.handleBlurEvent = (e) => {
|
|
28
36
|
this._isFocused = false;
|
|
37
|
+
if (this._userEdited)
|
|
38
|
+
this.revealValidity();
|
|
39
|
+
if (this._valueAtFocus !== null && this.value !== this._valueAtFocus) {
|
|
40
|
+
this.emitValueEvent('change', e);
|
|
41
|
+
}
|
|
42
|
+
this._valueAtFocus = null;
|
|
29
43
|
};
|
|
30
44
|
const shadow = this.shadowRoot;
|
|
31
45
|
ensureStyles(shadow, { css: textareaStyles, id: 'ty-textarea' });
|
|
@@ -34,20 +48,22 @@ ensureStyles(shadow, { css: customScrollbarStyles, id: 'ty-custom-scrollbar' });
|
|
|
34
48
|
}
|
|
35
49
|
}
|
|
36
50
|
onConnect() {
|
|
51
|
+
this.updateFormValue();
|
|
52
|
+
if (this._rendered) {
|
|
53
|
+
this.render();
|
|
54
|
+
if (this._textareaEl)
|
|
55
|
+
this.setupTextareaEvents(this._textareaEl);
|
|
56
|
+
}
|
|
37
57
|
}
|
|
38
58
|
onDisconnect() {
|
|
39
59
|
this._destroyScrollbar();
|
|
40
|
-
if (this._textareaEl)
|
|
41
|
-
|
|
42
|
-
this._textareaEl.parentNode?.replaceChild(newTextarea, this._textareaEl);
|
|
43
|
-
this._textareaEl = null;
|
|
44
|
-
}
|
|
45
|
-
this._dummyEl = null;
|
|
60
|
+
if (this._textareaEl)
|
|
61
|
+
this.removeTextareaEvents(this._textareaEl);
|
|
46
62
|
}
|
|
47
63
|
onPropertiesChanged(changes) {
|
|
48
64
|
}
|
|
49
65
|
getFormValue() {
|
|
50
|
-
return this.getProperty('value') ||
|
|
66
|
+
return this.getProperty('value') || '';
|
|
51
67
|
}
|
|
52
68
|
get value() { return this.getProperty('value'); }
|
|
53
69
|
set value(v) { this.setProperty('value', v); }
|
|
@@ -59,8 +75,19 @@ get label() { return this.getProperty('label'); }
|
|
|
59
75
|
set label(v) { this.setProperty('label', v); }
|
|
60
76
|
get disabled() { return this.getProperty('disabled'); }
|
|
61
77
|
set disabled(v) { this.setProperty('disabled', v); }
|
|
78
|
+
focus(options) {
|
|
79
|
+
this.shadowRoot?.querySelector('textarea')?.focus(options);
|
|
80
|
+
}
|
|
62
81
|
get required() { return this.getProperty('required'); }
|
|
63
82
|
set required(v) { this.setProperty('required', v); }
|
|
83
|
+
get minLength() { return toLimit(this.getProperty('minlength')) ?? -1; }
|
|
84
|
+
set minLength(v) { this.setProperty('minlength', v == null || v < 0 ? '' : String(v)); }
|
|
85
|
+
get maxLength() { return toLimit(this.getProperty('maxlength')) ?? -1; }
|
|
86
|
+
set maxLength(v) { this.setProperty('maxlength', v == null || v < 0 ? '' : String(v)); }
|
|
87
|
+
get tooShortMessage() { return this.getProperty('tooShortMessage'); }
|
|
88
|
+
set tooShortMessage(v) { this.setProperty('tooShortMessage', v ?? ''); }
|
|
89
|
+
get tooLongMessage() { return this.getProperty('tooLongMessage'); }
|
|
90
|
+
set tooLongMessage(v) { this.setProperty('tooLongMessage', v ?? ''); }
|
|
64
91
|
get error() { return this.getProperty('error'); }
|
|
65
92
|
set error(v) { this.setProperty('error', v); }
|
|
66
93
|
get size() {
|
|
@@ -167,6 +194,10 @@ textareaEl.style.overflowY = 'hidden';
|
|
|
167
194
|
this._destroyScrollbar();
|
|
168
195
|
}
|
|
169
196
|
}
|
|
197
|
+
else if (maxHeight !== null && measuredHeight >= maxHeight && !this._scrollbar) {
|
|
198
|
+
textareaEl.style.overflowY = 'auto';
|
|
199
|
+
this._setupScrollbar(textareaEl);
|
|
200
|
+
}
|
|
170
201
|
this._scrollbar?.update();
|
|
171
202
|
}
|
|
172
203
|
_setupScrollbar(textareaEl) {
|
|
@@ -194,22 +225,16 @@ if (this._textareaEl) {
|
|
|
194
225
|
this._textareaEl.style.scrollbarWidth = '';
|
|
195
226
|
}
|
|
196
227
|
}
|
|
197
|
-
|
|
198
|
-
const value = this.value;
|
|
199
|
-
this._internals.setFormValue(value || '');
|
|
200
|
-
this.updateValidity();
|
|
228
|
+
emitValueEvent(type, originalEvent) {
|
|
201
229
|
const data = {
|
|
202
230
|
bubbles: true,
|
|
203
231
|
composed: true,
|
|
204
232
|
detail: {
|
|
205
|
-
value,
|
|
233
|
+
value: this.value,
|
|
206
234
|
originalEvent
|
|
207
235
|
}
|
|
208
236
|
};
|
|
209
|
-
|
|
210
|
-
this.dispatchEvent(new CustomEvent('input', data));
|
|
211
|
-
this.dispatchEvent(new CustomEvent('change', data));
|
|
212
|
-
}, 0);
|
|
237
|
+
this.dispatchEvent(new CustomEvent(type, data));
|
|
213
238
|
}
|
|
214
239
|
buildClassList() {
|
|
215
240
|
const classes = [this.size];
|
|
@@ -236,10 +261,14 @@ textareaEl.style.maxHeight = this.maxHeight;
|
|
|
236
261
|
}
|
|
237
262
|
setupTextareaEvents(textareaEl) {
|
|
238
263
|
textareaEl.addEventListener('input', this.handleInputEvent);
|
|
239
|
-
textareaEl.addEventListener('change', this.handleInputEvent);
|
|
240
264
|
textareaEl.addEventListener('focus', this.handleFocusEvent);
|
|
241
265
|
textareaEl.addEventListener('blur', this.handleBlurEvent);
|
|
242
266
|
}
|
|
267
|
+
removeTextareaEvents(textareaEl) {
|
|
268
|
+
textareaEl.removeEventListener('input', this.handleInputEvent);
|
|
269
|
+
textareaEl.removeEventListener('focus', this.handleFocusEvent);
|
|
270
|
+
textareaEl.removeEventListener('blur', this.handleBlurEvent);
|
|
271
|
+
}
|
|
243
272
|
render() {
|
|
244
273
|
const root = this.shadowRoot;
|
|
245
274
|
const existingContainer = root.querySelector('.textarea-container');
|
|
@@ -249,18 +278,19 @@ const existingError = root.querySelector('.error-message');
|
|
|
249
278
|
if (existingContainer && existingTextarea) {
|
|
250
279
|
if (this.label) {
|
|
251
280
|
if (existingLabel) {
|
|
252
|
-
existingLabel.innerHTML = this.label
|
|
253
|
-
|
|
254
|
-
existingLabel.style.display = 'block';
|
|
281
|
+
existingLabel.innerHTML = `${this.label}${this.required ? `<span class="required-icon">${REQUIRED_ICON_SVG}</span>` : ''}`;
|
|
282
|
+
existingLabel.style.display = 'flex';
|
|
255
283
|
}
|
|
256
284
|
}
|
|
257
285
|
else if (existingLabel) {
|
|
258
286
|
existingLabel.style.display = 'none';
|
|
259
287
|
}
|
|
288
|
+
if (existingTextarea.value !== (this.value || ''))
|
|
260
289
|
existingTextarea.value = this.value || '';
|
|
261
290
|
existingTextarea.placeholder = this.placeholder || '';
|
|
262
291
|
existingTextarea.disabled = this.disabled;
|
|
263
292
|
existingTextarea.required = this.required;
|
|
293
|
+
this.syncConstraintAttributes(existingTextarea);
|
|
264
294
|
existingTextarea.className = this.buildClassList();
|
|
265
295
|
if (this.label)
|
|
266
296
|
existingTextarea.setAttribute('aria-label', this.label);
|
|
@@ -300,9 +330,8 @@ container.className = 'textarea-container';
|
|
|
300
330
|
const labelEl = document.createElement('label');
|
|
301
331
|
labelEl.className = 'ty-field-label';
|
|
302
332
|
if (this.label) {
|
|
303
|
-
labelEl.innerHTML = this.label
|
|
304
|
-
|
|
305
|
-
labelEl.style.display = 'block';
|
|
333
|
+
labelEl.innerHTML = `${this.label}${this.required ? `<span class="required-icon">${REQUIRED_ICON_SVG}</span>` : ''}`;
|
|
334
|
+
labelEl.style.display = 'flex';
|
|
306
335
|
}
|
|
307
336
|
else {
|
|
308
337
|
labelEl.style.display = 'none';
|
|
@@ -312,6 +341,7 @@ textareaEl.value = this.value || '';
|
|
|
312
341
|
textareaEl.placeholder = this.placeholder || '';
|
|
313
342
|
textareaEl.disabled = this.disabled;
|
|
314
343
|
textareaEl.required = this.required;
|
|
344
|
+
this.syncConstraintAttributes(textareaEl);
|
|
315
345
|
textareaEl.className = this.buildClassList();
|
|
316
346
|
if (this.label)
|
|
317
347
|
textareaEl.setAttribute('aria-label', this.label);
|
|
@@ -363,19 +393,34 @@ this._textareaEl = textareaEl;
|
|
|
363
393
|
}
|
|
364
394
|
this.updateValidity();
|
|
365
395
|
}
|
|
396
|
+
syncConstraintAttributes(ta) {
|
|
397
|
+
const set = (name, limit) => limit !== null ? ta.setAttribute(name, String(limit)) : ta.removeAttribute(name);
|
|
398
|
+
set('minlength', toLimit(this.getProperty('minlength')));
|
|
399
|
+
set('maxlength', toLimit(this.getProperty('maxlength')));
|
|
400
|
+
}
|
|
366
401
|
updateValidity() {
|
|
367
402
|
const ta = this.shadowRoot?.querySelector('textarea');
|
|
368
403
|
if (this.disabled) {
|
|
369
|
-
this.
|
|
404
|
+
this.applyValidity({});
|
|
370
405
|
return;
|
|
371
406
|
}
|
|
372
407
|
const current = ta ? ta.value : String(this.value ?? '');
|
|
373
|
-
if (
|
|
374
|
-
this.
|
|
408
|
+
if (current.trim() === '') {
|
|
409
|
+
if (this.required) {
|
|
410
|
+
this.applyValidity({ valueMissing: true }, nativeMessage('textarea', { required: true }), ta ?? undefined);
|
|
375
411
|
}
|
|
376
412
|
else {
|
|
377
|
-
this.
|
|
413
|
+
this.applyValidity({});
|
|
414
|
+
}
|
|
415
|
+
return;
|
|
378
416
|
}
|
|
417
|
+
const { tooShort, tooLong } = lengthValidity(current, {
|
|
418
|
+
minlength: this.getProperty('minlength'),
|
|
419
|
+
maxlength: this.getProperty('maxlength'),
|
|
420
|
+
tooShortMessage: this.tooShortMessage,
|
|
421
|
+
tooLongMessage: this.tooLongMessage,
|
|
422
|
+
}, ta);
|
|
423
|
+
this.applyValidity({ tooShort: !!tooShort, tooLong: !!tooLong }, tooShort ?? tooLong, ta ?? undefined);
|
|
379
424
|
}
|
|
380
425
|
}
|
|
381
426
|
TyTextarea.formAssociated = true;
|
|
@@ -411,6 +456,26 @@ type: 'boolean',
|
|
|
411
456
|
visual: true,
|
|
412
457
|
default: false
|
|
413
458
|
},
|
|
459
|
+
minlength: {
|
|
460
|
+
type: 'string',
|
|
461
|
+
visual: true,
|
|
462
|
+
default: ''
|
|
463
|
+
},
|
|
464
|
+
maxlength: {
|
|
465
|
+
type: 'string',
|
|
466
|
+
visual: true,
|
|
467
|
+
default: ''
|
|
468
|
+
},
|
|
469
|
+
tooShortMessage: {
|
|
470
|
+
type: 'string',
|
|
471
|
+
visual: true,
|
|
472
|
+
default: ''
|
|
473
|
+
},
|
|
474
|
+
tooLongMessage: {
|
|
475
|
+
type: 'string',
|
|
476
|
+
visual: true,
|
|
477
|
+
default: ''
|
|
478
|
+
},
|
|
414
479
|
error: {
|
|
415
480
|
type: 'string',
|
|
416
481
|
visual: true,
|
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
import { type Placement } from '../utils/positioning.js';
|
|
7
7
|
import type { Flavor } from '../types/common.js';
|
|
8
8
|
/**
|
|
9
|
-
* Tooltip flavors:
|
|
10
|
-
*
|
|
9
|
+
* Tooltip flavors are the standard ones: neutral (default) / primary /
|
|
10
|
+
* success / danger / warning with + and - tones, or a custom flavor.
|
|
11
|
+
* 'dark' is kept as a silent alias for neutral.
|
|
11
12
|
*/
|
|
12
|
-
export type TooltipFlavor = 'dark' |
|
|
13
|
+
export type TooltipFlavor = 'dark' | Flavor;
|
|
13
14
|
/**
|
|
14
15
|
* Tooltip attributes configuration
|
|
15
16
|
*/
|
|
@@ -7,9 +7,9 @@ const timeoutState = new WeakMap();
|
|
|
7
7
|
const popoverElements = new WeakMap();
|
|
8
8
|
const anchorElements = new WeakMap();
|
|
9
9
|
function validateFlavor(flavor) {
|
|
10
|
-
const full = flavor || '
|
|
10
|
+
const full = flavor || 'neutral';
|
|
11
11
|
const base = full.replace(/[+-]$/, '');
|
|
12
|
-
return /^[A-Za-z][A-Za-z0-9_-]*$/.test(base) ? full : '
|
|
12
|
+
return /^[A-Za-z][A-Za-z0-9_-]*$/.test(base) ? full : 'neutral';
|
|
13
13
|
}
|
|
14
14
|
function getTimeoutState(el) {
|
|
15
15
|
let state = timeoutState.get(el);
|
|
@@ -120,32 +120,19 @@ function applyFlavorStyles(popover, flavor) {
|
|
|
120
120
|
popover.style.removeProperty('background');
|
|
121
121
|
popover.style.removeProperty('color');
|
|
122
122
|
popover.style.removeProperty('border-color');
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
const base = flavor.replace(/[+-]$/, '');
|
|
124
|
+
const shade = flavor.slice(base.length);
|
|
125
|
+
if ((base === 'neutral' || base === 'dark') && shade === '') {
|
|
125
126
|
popover.style.background = 'var(--ty-tooltip-bg, #262626)';
|
|
126
127
|
popover.style.color = 'var(--ty-tooltip-color, #f5f5f5)';
|
|
127
128
|
popover.style.borderColor = 'var(--ty-tooltip-border, #404040)';
|
|
128
|
-
|
|
129
|
-
case 'light':
|
|
130
|
-
popover.style.background = 'var(--ty-surface-elevated, #ffffff)';
|
|
131
|
-
popover.style.color = 'var(--ty-text-strong, #111827)';
|
|
132
|
-
popover.style.borderColor = 'var(--ty-border, #e5e7eb)';
|
|
133
|
-
break;
|
|
134
|
-
case 'info':
|
|
135
|
-
popover.style.background = 'var(--ty-bg-info, #06b6d4)';
|
|
136
|
-
popover.style.color = 'var(--ty-text-strong, #f0f9ff)';
|
|
137
|
-
popover.style.borderColor = 'var(--ty-border-info, #22d3ee)';
|
|
138
|
-
break;
|
|
139
|
-
default: {
|
|
140
|
-
const base = flavor.replace(/[+-]$/, '');
|
|
141
|
-
const shade = flavor.slice(base.length);
|
|
142
|
-
const bgSfx = shade === '+' ? '-bold' : shade === '-' ? '-soft' : '';
|
|
143
|
-
popover.style.background = `var(--ty-bg-${base}${bgSfx}, var(--ty-bg-neutral))`;
|
|
144
|
-
popover.style.color = `var(--ty-color-${base}-strong, var(--ty-color-neutral-strong))`;
|
|
145
|
-
popover.style.borderColor = `var(--ty-border-${base}, var(--ty-color-${base}))`;
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
129
|
+
return;
|
|
148
130
|
}
|
|
131
|
+
const f = base === 'dark' ? 'neutral' : base;
|
|
132
|
+
const sfx = shade === '+' ? '-strong' : shade === '-' ? '-soft' : '';
|
|
133
|
+
popover.style.background = `var(--ty-solid-${f}${sfx}, var(--ty-tooltip-bg, #262626))`;
|
|
134
|
+
popover.style.color = `var(--ty-solid-${f}${sfx}-fg, var(--ty-solid-${f}-fg, var(--ty-tooltip-color, #f5f5f5)))`;
|
|
135
|
+
popover.style.borderColor = 'transparent';
|
|
149
136
|
}
|
|
150
137
|
function updatePosition(el) {
|
|
151
138
|
const { placement, offset } = getTooltipAttributes(el);
|
|
@@ -228,6 +215,26 @@ clearTimeout(state.hideTimeout);
|
|
|
228
215
|
state.hideTimeout = null;
|
|
229
216
|
}
|
|
230
217
|
}
|
|
218
|
+
const escapeHandlers = new WeakMap();
|
|
219
|
+
function listenForEscape(el) {
|
|
220
|
+
if (escapeHandlers.has(el))
|
|
221
|
+
return;
|
|
222
|
+
const handler = (e) => {
|
|
223
|
+
if (e.key === 'Escape') {
|
|
224
|
+
clearTimeouts(el);
|
|
225
|
+
hideTooltip(el);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
escapeHandlers.set(el, handler);
|
|
229
|
+
document.addEventListener('keydown', handler, true);
|
|
230
|
+
}
|
|
231
|
+
function stopListeningForEscape(el) {
|
|
232
|
+
const handler = escapeHandlers.get(el);
|
|
233
|
+
if (!handler)
|
|
234
|
+
return;
|
|
235
|
+
document.removeEventListener('keydown', handler, true);
|
|
236
|
+
escapeHandlers.delete(el);
|
|
237
|
+
}
|
|
231
238
|
function showTooltip(el) {
|
|
232
239
|
const { disabled } = getTooltipAttributes(el);
|
|
233
240
|
if (disabled)
|
|
@@ -238,12 +245,14 @@ popover.showPopover();
|
|
|
238
245
|
el._open = true;
|
|
239
246
|
updatePosition(el);
|
|
240
247
|
setupAutoUpdate(el);
|
|
248
|
+
listenForEscape(el);
|
|
241
249
|
}
|
|
242
250
|
catch (e) {
|
|
243
251
|
console.warn('[ty-tooltip] Failed to show popover', e);
|
|
244
252
|
}
|
|
245
253
|
}
|
|
246
254
|
function hideTooltip(el) {
|
|
255
|
+
stopListeningForEscape(el);
|
|
247
256
|
const popover = popoverElements.get(el);
|
|
248
257
|
if (!popover)
|
|
249
258
|
return;
|
|
@@ -289,6 +298,7 @@ anchor.removeEventListener('focusout', handleBlur);
|
|
|
289
298
|
function cleanup(el) {
|
|
290
299
|
clearTimeouts(el);
|
|
291
300
|
cleanupAutoUpdate(el);
|
|
301
|
+
stopListeningForEscape(el);
|
|
292
302
|
const eventsCleanup = eventCleanup.get(el);
|
|
293
303
|
if (eventsCleanup) {
|
|
294
304
|
eventsCleanup();
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Wizard Component —
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* and
|
|
2
|
+
* Wizard Component — stepper with an inline indicator rail (compact
|
|
3
|
+
* "Step N of M" header in narrow containers), sliding panels (carousel, like
|
|
4
|
+
* ty-tabs), and step completion tracking. Expects `ty-step` children.
|
|
5
|
+
* "Dumb" like ty-tabs: it renders and fires events; all navigation and
|
|
6
|
+
* validation is the consumer's.
|
|
6
7
|
*/
|
|
7
8
|
/**
|
|
8
9
|
* Wizard container attributes configuration
|