tyrell-components 1.0.0-RC16 → 1.0.0-RC18
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 +1 -1
- package/css/tyrell-colors-static.css +1 -316
- package/css/tyrell-theme.css +1 -1471
- package/css/tyrell.css +1 -1385
- package/dist/tyrell-colors-static.css +1 -1
- package/dist/tyrell-theme.css +1 -1
- package/dist/tyrell.js +1 -1
- package/lib/base/ty-component.d.ts +28 -15
- package/lib/base/ty-component.js +81 -38
- package/lib/components/button.d.ts +14 -0
- package/lib/components/button.js +55 -7
- package/lib/components/calendar-month.d.ts +7 -1
- package/lib/components/calendar-month.js +35 -28
- package/lib/components/calendar-navigation.js +19 -6
- package/lib/components/calendar.d.ts +27 -3
- package/lib/components/calendar.js +107 -63
- package/lib/components/checkbox.d.ts +8 -1
- package/lib/components/checkbox.js +27 -6
- package/lib/components/copy.d.ts +2 -0
- package/lib/components/copy.js +15 -31
- package/lib/components/date-picker.d.ts +53 -18
- package/lib/components/date-picker.js +217 -146
- package/lib/components/file-upload.d.ts +4 -1
- package/lib/components/file-upload.js +23 -5
- package/lib/components/input.d.ts +73 -3
- package/lib/components/input.js +158 -22
- package/lib/components/modal.d.ts +2 -0
- package/lib/components/modal.js +97 -17
- package/lib/components/option.d.ts +19 -0
- package/lib/components/option.js +45 -31
- package/lib/components/popup.js +115 -15
- package/lib/components/radio.d.ts +10 -1
- package/lib/components/radio.js +22 -29
- package/lib/components/resize-observer.js +2 -0
- package/lib/components/scroll-container.js +2 -0
- package/lib/components/select.d.ts +150 -190
- package/lib/components/select.js +501 -796
- package/lib/components/selected-tags.d.ts +14 -4
- package/lib/components/selected-tags.js +35 -8
- package/lib/components/switch.d.ts +9 -1
- package/lib/components/switch.js +27 -6
- package/lib/components/tabs.js +1 -1
- package/lib/components/tag.d.ts +0 -9
- package/lib/components/tag.js +0 -11
- package/lib/components/textarea.d.ts +47 -2
- package/lib/components/textarea.js +81 -17
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/styles/button.js +21 -19
- package/lib/styles/calendar-month.js +1 -1
- package/lib/styles/calendar.js +3 -0
- package/lib/styles/checkbox.js +11 -5
- package/lib/styles/date-picker.js +16 -4
- 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 +6 -7
- package/lib/styles/popup.d.ts +1 -1
- package/lib/styles/popup.js +2 -0
- package/lib/styles/radio.js +12 -6
- package/lib/styles/select-base.js +22 -60
- package/lib/styles/select.d.ts +1 -1
- package/lib/styles/select.js +13 -2
- package/lib/styles/switch.js +10 -5
- package/lib/styles/tag.js +3 -5
- package/lib/styles/textarea.d.ts +1 -1
- package/lib/styles/textarea.js +7 -0
- package/lib/types/common.d.ts +3 -3
- package/lib/utils/calendar-utils.d.ts +49 -0
- package/lib/utils/calendar-utils.js +63 -6
- package/lib/utils/property-manager.d.ts +6 -5
- package/lib/utils/property-manager.js +14 -15
- 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 +98 -2
- package/lib/utils/validity.js +244 -8
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +8 -6
- package/lib/base/ty-component.d.ts.map +0 -1
- package/lib/base/ty-component.js.map +0 -1
- package/lib/components/button.d.ts.map +0 -1
- package/lib/components/button.js.map +0 -1
- package/lib/components/calendar-month.d.ts.map +0 -1
- package/lib/components/calendar-month.js.map +0 -1
- package/lib/components/calendar-navigation.d.ts.map +0 -1
- package/lib/components/calendar-navigation.js.map +0 -1
- package/lib/components/calendar.d.ts.map +0 -1
- package/lib/components/calendar.js.map +0 -1
- package/lib/components/checkbox.d.ts.map +0 -1
- package/lib/components/checkbox.js.map +0 -1
- package/lib/components/copy.d.ts.map +0 -1
- package/lib/components/copy.js.map +0 -1
- package/lib/components/date-picker.d.ts.map +0 -1
- package/lib/components/date-picker.js.map +0 -1
- package/lib/components/dropdown.d.ts +0 -403
- package/lib/components/dropdown.d.ts.map +0 -1
- package/lib/components/dropdown.js +0 -1315
- package/lib/components/dropdown.js.map +0 -1
- package/lib/components/icon.d.ts.map +0 -1
- package/lib/components/icon.js.map +0 -1
- package/lib/components/input.d.ts.map +0 -1
- package/lib/components/input.js.map +0 -1
- package/lib/components/modal.d.ts.map +0 -1
- package/lib/components/modal.js.map +0 -1
- package/lib/components/multiselect.d.ts +0 -389
- package/lib/components/multiselect.d.ts.map +0 -1
- package/lib/components/multiselect.js +0 -1301
- package/lib/components/multiselect.js.map +0 -1
- package/lib/components/option.d.ts.map +0 -1
- package/lib/components/option.js.map +0 -1
- package/lib/components/popup.d.ts.map +0 -1
- package/lib/components/popup.js.map +0 -1
- package/lib/components/resize-observer.d.ts.map +0 -1
- package/lib/components/resize-observer.js.map +0 -1
- package/lib/components/scroll-container.d.ts.map +0 -1
- package/lib/components/scroll-container.js.map +0 -1
- package/lib/components/step.d.ts.map +0 -1
- package/lib/components/step.js.map +0 -1
- package/lib/components/tab.d.ts.map +0 -1
- package/lib/components/tab.js.map +0 -1
- package/lib/components/tabs.d.ts.map +0 -1
- package/lib/components/tabs.js.map +0 -1
- package/lib/components/tag.d.ts.map +0 -1
- package/lib/components/tag.js.map +0 -1
- package/lib/components/textarea.d.ts.map +0 -1
- package/lib/components/textarea.js.map +0 -1
- package/lib/components/tooltip.d.ts.map +0 -1
- package/lib/components/tooltip.js.map +0 -1
- package/lib/components/wizard.d.ts.map +0 -1
- package/lib/components/wizard.js.map +0 -1
- package/lib/icons/fontawesome/brands.d.ts.map +0 -1
- package/lib/icons/fontawesome/brands.js.map +0 -1
- package/lib/icons/fontawesome/regular.d.ts.map +0 -1
- package/lib/icons/fontawesome/regular.js.map +0 -1
- package/lib/icons/fontawesome/solid.d.ts.map +0 -1
- package/lib/icons/fontawesome/solid.js.map +0 -1
- package/lib/icons/heroicons/micro.d.ts.map +0 -1
- package/lib/icons/heroicons/micro.js.map +0 -1
- package/lib/icons/heroicons/mini.d.ts.map +0 -1
- package/lib/icons/heroicons/mini.js.map +0 -1
- package/lib/icons/heroicons/outline.d.ts.map +0 -1
- package/lib/icons/heroicons/outline.js.map +0 -1
- package/lib/icons/heroicons/solid.d.ts.map +0 -1
- package/lib/icons/heroicons/solid.js.map +0 -1
- package/lib/icons/lucide.d.ts.map +0 -1
- package/lib/icons/lucide.js.map +0 -1
- package/lib/icons/material/filled.d.ts.map +0 -1
- package/lib/icons/material/filled.js.map +0 -1
- package/lib/icons/material/outlined.d.ts.map +0 -1
- package/lib/icons/material/outlined.js.map +0 -1
- package/lib/icons/material/round.d.ts.map +0 -1
- package/lib/icons/material/round.js.map +0 -1
- package/lib/icons/material/sharp.d.ts.map +0 -1
- package/lib/icons/material/sharp.js.map +0 -1
- package/lib/icons/material/two-tone.d.ts.map +0 -1
- package/lib/icons/material/two-tone.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/styles/button.d.ts.map +0 -1
- package/lib/styles/button.js.map +0 -1
- package/lib/styles/calendar-month.d.ts.map +0 -1
- package/lib/styles/calendar-month.js.map +0 -1
- package/lib/styles/calendar-navigation.d.ts.map +0 -1
- package/lib/styles/calendar-navigation.js.map +0 -1
- package/lib/styles/calendar.d.ts.map +0 -1
- package/lib/styles/calendar.js.map +0 -1
- package/lib/styles/copy.d.ts.map +0 -1
- package/lib/styles/copy.js.map +0 -1
- package/lib/styles/date-picker.d.ts.map +0 -1
- package/lib/styles/date-picker.js.map +0 -1
- package/lib/styles/dropdown.d.ts +0 -12
- package/lib/styles/dropdown.d.ts.map +0 -1
- package/lib/styles/dropdown.js +0 -725
- package/lib/styles/dropdown.js.map +0 -1
- package/lib/styles/icon.d.ts.map +0 -1
- package/lib/styles/icon.js.map +0 -1
- package/lib/styles/input.d.ts.map +0 -1
- package/lib/styles/input.js.map +0 -1
- package/lib/styles/modal.d.ts.map +0 -1
- package/lib/styles/modal.js.map +0 -1
- package/lib/styles/multiselect.d.ts +0 -6
- package/lib/styles/multiselect.d.ts.map +0 -1
- package/lib/styles/multiselect.js +0 -568
- package/lib/styles/multiselect.js.map +0 -1
- package/lib/styles/option.d.ts.map +0 -1
- package/lib/styles/option.js.map +0 -1
- package/lib/styles/popup.d.ts.map +0 -1
- package/lib/styles/popup.js.map +0 -1
- package/lib/styles/resize-observer.d.ts.map +0 -1
- package/lib/styles/resize-observer.js.map +0 -1
- package/lib/styles/scroll-container.d.ts.map +0 -1
- package/lib/styles/scroll-container.js.map +0 -1
- package/lib/styles/step.d.ts.map +0 -1
- package/lib/styles/step.js.map +0 -1
- package/lib/styles/tab.d.ts.map +0 -1
- package/lib/styles/tab.js.map +0 -1
- package/lib/styles/tabs.d.ts.map +0 -1
- package/lib/styles/tabs.js.map +0 -1
- package/lib/styles/tag.d.ts.map +0 -1
- package/lib/styles/tag.js.map +0 -1
- package/lib/styles/textarea.d.ts.map +0 -1
- package/lib/styles/textarea.js.map +0 -1
- package/lib/styles/tooltip.d.ts.map +0 -1
- package/lib/styles/tooltip.js.map +0 -1
- package/lib/styles/wizard.d.ts.map +0 -1
- package/lib/styles/wizard.js.map +0 -1
- package/lib/types/common.d.ts.map +0 -1
- package/lib/types/common.js.map +0 -1
- package/lib/utils/calendar-utils.d.ts.map +0 -1
- package/lib/utils/calendar-utils.js.map +0 -1
- package/lib/utils/icon-registry.d.ts.map +0 -1
- package/lib/utils/icon-registry.js.map +0 -1
- package/lib/utils/locale.d.ts.map +0 -1
- package/lib/utils/locale.js.map +0 -1
- package/lib/utils/number-format.d.ts.map +0 -1
- package/lib/utils/number-format.js.map +0 -1
- package/lib/utils/parse-boolean.d.ts +0 -39
- package/lib/utils/parse-boolean.d.ts.map +0 -1
- package/lib/utils/parse-boolean.js +0 -23
- package/lib/utils/parse-boolean.js.map +0 -1
- package/lib/utils/positioning.d.ts.map +0 -1
- package/lib/utils/positioning.js.map +0 -1
- package/lib/utils/property-capture.d.ts.map +0 -1
- package/lib/utils/property-capture.js.map +0 -1
- package/lib/utils/property-manager.d.ts.map +0 -1
- package/lib/utils/property-manager.js.map +0 -1
- package/lib/utils/resize-observer.d.ts.map +0 -1
- package/lib/utils/resize-observer.js.map +0 -1
- package/lib/utils/scroll-lock.d.ts.map +0 -1
- package/lib/utils/scroll-lock.js.map +0 -1
- package/lib/utils/styles.d.ts.map +0 -1
- package/lib/utils/styles.js.map +0 -1
- package/lib/version.d.ts.map +0 -1
- package/lib/version.js.map +0 -1
package/lib/utils/scroll-lock.js
CHANGED
|
@@ -3,6 +3,7 @@ locked: false,
|
|
|
3
3
|
scrollY: 0,
|
|
4
4
|
activeLocks: new Set(),
|
|
5
5
|
};
|
|
6
|
+
let savedStyle = { overflow: '', paddingRight: '' };
|
|
6
7
|
function getBodyEl() {
|
|
7
8
|
return document.body;
|
|
8
9
|
}
|
|
@@ -15,6 +16,102 @@ return window.scrollY || getDocEl().scrollTop || 0;
|
|
|
15
16
|
function getScrollbarWidth() {
|
|
16
17
|
return window.innerWidth - getDocEl().clientWidth;
|
|
17
18
|
}
|
|
19
|
+
const KEY_SCROLL = {
|
|
20
|
+
ArrowDown: ['y', 1], ArrowUp: ['y', -1], PageDown: ['y', 1], PageUp: ['y', -1],
|
|
21
|
+
End: ['y', 1], Home: ['y', -1], ' ': ['y', 1], ArrowRight: ['x', 1], ArrowLeft: ['x', -1],
|
|
22
|
+
};
|
|
23
|
+
const TEXT_INPUT = /^(?:text|search|email|url|tel|password|number|date|datetime-local|month|week|time|range|color)$/;
|
|
24
|
+
function keyBelongsTo(el, key) {
|
|
25
|
+
if (el instanceof HTMLTextAreaElement || el instanceof HTMLSelectElement)
|
|
26
|
+
return true;
|
|
27
|
+
if (el instanceof HTMLElement && el.isContentEditable)
|
|
28
|
+
return true;
|
|
29
|
+
if (el instanceof HTMLInputElement) {
|
|
30
|
+
if (TEXT_INPUT.test(el.type))
|
|
31
|
+
return true;
|
|
32
|
+
if (el.type === 'radio' && key.startsWith('Arrow'))
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
if (key === ' ' && el.matches('button, input, summary, a[href], [role]'))
|
|
36
|
+
return true;
|
|
37
|
+
if (key !== ' ' && el.matches('[role]:not([role=dialog]):not([role=document]):not([role=presentation]):not([role=none])'))
|
|
38
|
+
return true;
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
function canScroll(el, axis, dir) {
|
|
42
|
+
const style = getComputedStyle(el);
|
|
43
|
+
const overflow = axis === 'y' ? style.overflowY : style.overflowX;
|
|
44
|
+
if (!/^(?:auto|scroll|overlay)$/.test(overflow) && !(el instanceof HTMLTextAreaElement))
|
|
45
|
+
return false;
|
|
46
|
+
const pos = axis === 'y' ? el.scrollTop : Math.abs(el.scrollLeft);
|
|
47
|
+
const max = axis === 'y' ? el.scrollHeight - el.clientHeight : el.scrollWidth - el.clientWidth;
|
|
48
|
+
if (max < 1)
|
|
49
|
+
return false;
|
|
50
|
+
return dir > 0 ? pos < max - 1 : pos > 0;
|
|
51
|
+
}
|
|
52
|
+
const HAS_POPOVER = typeof HTMLElement !== 'undefined' && 'popover' in HTMLElement.prototype;
|
|
53
|
+
function isOpenPopover(el) {
|
|
54
|
+
return HAS_POPOVER && el.hasAttribute('popover') && el.matches(':popover-open');
|
|
55
|
+
}
|
|
56
|
+
function scrollsInside(event, axis, dir) {
|
|
57
|
+
if (!dir)
|
|
58
|
+
return true;
|
|
59
|
+
const path = event.composedPath().filter((n) => n instanceof Element);
|
|
60
|
+
const root = path.findIndex((n) => (n instanceof HTMLDialogElement && n.open) || isOpenPopover(n));
|
|
61
|
+
return root >= 0 && path.slice(0, root + 1).some((n) => canScroll(n, axis, dir));
|
|
62
|
+
}
|
|
63
|
+
function guardWheel(e) {
|
|
64
|
+
if (e.ctrlKey)
|
|
65
|
+
return;
|
|
66
|
+
const axis = Math.abs(e.deltaX) > Math.abs(e.deltaY) || e.shiftKey ? 'x' : 'y';
|
|
67
|
+
const delta = axis === 'y' && !e.shiftKey ? e.deltaY : e.deltaX || e.deltaY;
|
|
68
|
+
if (e.cancelable && !scrollsInside(e, axis, Math.sign(delta)))
|
|
69
|
+
e.preventDefault();
|
|
70
|
+
}
|
|
71
|
+
let touchX = 0;
|
|
72
|
+
let touchY = 0;
|
|
73
|
+
function guardTouchStart(e) {
|
|
74
|
+
if (e.touches.length !== 1)
|
|
75
|
+
return;
|
|
76
|
+
touchX = e.touches[0].clientX;
|
|
77
|
+
touchY = e.touches[0].clientY;
|
|
78
|
+
}
|
|
79
|
+
function guardTouchMove(e) {
|
|
80
|
+
if (e.touches.length !== 1 || !e.cancelable)
|
|
81
|
+
return;
|
|
82
|
+
const { clientX, clientY } = e.touches[0];
|
|
83
|
+
const dx = touchX - clientX;
|
|
84
|
+
const dy = touchY - clientY;
|
|
85
|
+
touchX = clientX;
|
|
86
|
+
touchY = clientY;
|
|
87
|
+
const axis = Math.abs(dx) > Math.abs(dy) ? 'x' : 'y';
|
|
88
|
+
if (!scrollsInside(e, axis, Math.sign(axis === 'y' ? dy : dx)))
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
}
|
|
91
|
+
function guardKey(e) {
|
|
92
|
+
const scroll = KEY_SCROLL[e.key];
|
|
93
|
+
if (!scroll || e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey)
|
|
94
|
+
return;
|
|
95
|
+
const target = e.composedPath()[0];
|
|
96
|
+
if (target instanceof Element && keyBelongsTo(target, e.key))
|
|
97
|
+
return;
|
|
98
|
+
const [axis, dir] = scroll;
|
|
99
|
+
if (!scrollsInside(e, axis, e.key === ' ' && e.shiftKey ? -dir : dir))
|
|
100
|
+
e.preventDefault();
|
|
101
|
+
}
|
|
102
|
+
const WHEEL_OPTS = { capture: true, passive: false };
|
|
103
|
+
function addGuard() {
|
|
104
|
+
window.addEventListener('wheel', guardWheel, WHEEL_OPTS);
|
|
105
|
+
window.addEventListener('touchstart', guardTouchStart, { capture: true, passive: true });
|
|
106
|
+
window.addEventListener('touchmove', guardTouchMove, WHEEL_OPTS);
|
|
107
|
+
window.addEventListener('keydown', guardKey, true);
|
|
108
|
+
}
|
|
109
|
+
function removeGuard() {
|
|
110
|
+
window.removeEventListener('wheel', guardWheel, WHEEL_OPTS);
|
|
111
|
+
window.removeEventListener('touchstart', guardTouchStart, { capture: true });
|
|
112
|
+
window.removeEventListener('touchmove', guardTouchMove, WHEEL_OPTS);
|
|
113
|
+
window.removeEventListener('keydown', guardKey, true);
|
|
114
|
+
}
|
|
18
115
|
function lockBodyFixed() {
|
|
19
116
|
if (lockState.locked)
|
|
20
117
|
return;
|
|
@@ -25,11 +122,13 @@ console.log('🔒 Locking body scroll:', { scrollbarWidth });
|
|
|
25
122
|
}
|
|
26
123
|
lockState.scrollY = getScrollY();
|
|
27
124
|
lockState.locked = true;
|
|
125
|
+
savedStyle = { overflow: docEl.style.overflow, paddingRight: docEl.style.paddingRight };
|
|
28
126
|
docEl.style.overflow = 'hidden';
|
|
29
127
|
if (scrollbarWidth > 0) {
|
|
30
128
|
docEl.style.paddingRight = `${scrollbarWidth}px`;
|
|
31
129
|
}
|
|
32
130
|
docEl.classList.add('ty-scroll-locked');
|
|
131
|
+
addGuard();
|
|
33
132
|
}
|
|
34
133
|
function unlockBodyFixed() {
|
|
35
134
|
if (!lockState.locked)
|
|
@@ -38,9 +137,10 @@ const docEl = getDocEl();
|
|
|
38
137
|
if (window.tyScrollDebug) {
|
|
39
138
|
console.log('🔓 Unlocking body scroll');
|
|
40
139
|
}
|
|
140
|
+
removeGuard();
|
|
41
141
|
docEl.classList.remove('ty-scroll-locked');
|
|
42
|
-
docEl.style.overflow =
|
|
43
|
-
docEl.style.paddingRight =
|
|
142
|
+
docEl.style.overflow = savedStyle.overflow;
|
|
143
|
+
docEl.style.paddingRight = savedStyle.paddingRight;
|
|
44
144
|
lockState.locked = false;
|
|
45
145
|
}
|
|
46
146
|
export function lockScroll(componentId) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* For a component whose attributeChangedCallback assigns through its own
|
|
3
|
+
* accessors: call it in the constructor. While an element upgrades, the
|
|
4
|
+
* attribute callbacks run before connectedCallback and would overwrite the
|
|
5
|
+
* early values (an own property takes the assignment); taken off here, they
|
|
6
|
+
* reach the setters in upgradeProperties() instead, after the attributes.
|
|
7
|
+
*/
|
|
8
|
+
export declare function liftProperties(el: HTMLElement): void;
|
|
9
|
+
/**
|
|
10
|
+
* Properties set before the element upgraded (a framework rendering it
|
|
11
|
+
* before its definition loaded, a lazily defined element) are own data
|
|
12
|
+
* properties that shadow the class accessors, so later assignments would
|
|
13
|
+
* never reach a setter. Standard "upgrade property" pattern: read the own
|
|
14
|
+
* value, delete it, assign it again through the accessor. Covers every
|
|
15
|
+
* settable accessor on the prototype chain (value, checked, open, error,
|
|
16
|
+
* minLength, …). TyComponent does this itself; a component extending
|
|
17
|
+
* HTMLElement directly calls it at the start of connectedCallback.
|
|
18
|
+
* A value its setter rejects is reported, not thrown: connectedCallback
|
|
19
|
+
* goes on, as it would for an attribute with a bad value.
|
|
20
|
+
*/
|
|
21
|
+
export declare function upgradeProperties(el: HTMLElement): void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const accessorCache = new WeakMap();
|
|
2
|
+
function settableAccessors(ctor) {
|
|
3
|
+
let names = accessorCache.get(ctor);
|
|
4
|
+
if (!names) {
|
|
5
|
+
const set = new Set();
|
|
6
|
+
for (let proto = ctor.prototype; proto && proto !== HTMLElement.prototype; proto = Object.getPrototypeOf(proto)) {
|
|
7
|
+
for (const [name, d] of Object.entries(Object.getOwnPropertyDescriptors(proto))) {
|
|
8
|
+
if (d.set)
|
|
9
|
+
set.add(name);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
names = [...set];
|
|
13
|
+
accessorCache.set(ctor, names);
|
|
14
|
+
}
|
|
15
|
+
return names;
|
|
16
|
+
}
|
|
17
|
+
const lifted = new WeakMap();
|
|
18
|
+
function takeOwn(el) {
|
|
19
|
+
const taken = [];
|
|
20
|
+
for (const name of settableAccessors(el.constructor)) {
|
|
21
|
+
if (!Object.prototype.hasOwnProperty.call(el, name))
|
|
22
|
+
continue;
|
|
23
|
+
taken.push([name, el[name]]);
|
|
24
|
+
delete el[name];
|
|
25
|
+
}
|
|
26
|
+
return taken;
|
|
27
|
+
}
|
|
28
|
+
export function liftProperties(el) {
|
|
29
|
+
const taken = takeOwn(el);
|
|
30
|
+
if (taken.length)
|
|
31
|
+
lifted.set(el, taken);
|
|
32
|
+
}
|
|
33
|
+
export function upgradeProperties(el) {
|
|
34
|
+
const early = [...(lifted.get(el) ?? []), ...takeOwn(el)];
|
|
35
|
+
lifted.delete(el);
|
|
36
|
+
for (const [name, value] of early) {
|
|
37
|
+
if (value === undefined)
|
|
38
|
+
continue;
|
|
39
|
+
try {
|
|
40
|
+
;
|
|
41
|
+
el[name] = value;
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
reportError(e);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
package/lib/utils/validity.d.ts
CHANGED
|
@@ -9,18 +9,114 @@
|
|
|
9
9
|
* reportValidity() uses the component's own `error` display when it has one
|
|
10
10
|
* (ty-input, ty-textarea, ty-radio-group, ty-file-upload) instead of the
|
|
11
11
|
* browser's bubble, and clears that message again once the field is valid.
|
|
12
|
+
* Whenever the browser fires `invalid` on such a field — a submit attempt,
|
|
13
|
+
* form.reportValidity(), or checkValidity() on the field or its form — the
|
|
14
|
+
* message goes into that error line (no bubble), so a plain <form> needs no
|
|
15
|
+
* JS. For a check that shows nothing, read `field.validity.valid` or
|
|
16
|
+
* `form.matches(':invalid')`. A submit (a submitter click, Enter in a
|
|
17
|
+
* single-line field, form.requestSubmit()) and form.reportValidity() also
|
|
18
|
+
* move focus to the first failing field — the first in form order, like a
|
|
19
|
+
* native form, also when a later field shows a bubble. checkValidity() never
|
|
20
|
+
* does. For the script-run calls, a form holding a Ty field with an error
|
|
21
|
+
* line gets own requestSubmit / reportValidity wrappers (the prototype and
|
|
22
|
+
* other forms are left alone); they come off when the last such field leaves.
|
|
23
|
+
* An `error` the author set is never overwritten or removed;
|
|
24
|
+
* form.reset() clears every message the controller wrote.
|
|
12
25
|
*/
|
|
26
|
+
/**
|
|
27
|
+
* Run `fn` as a submit attempt: `invalid` events during it move focus to the
|
|
28
|
+
* first failing field. ty-button runs its form.requestSubmit() in this.
|
|
29
|
+
*/
|
|
30
|
+
export declare function asSubmitAttempt<T>(fn: () => T): T;
|
|
13
31
|
export declare class ValidityController {
|
|
14
32
|
private host;
|
|
15
33
|
private internals;
|
|
16
34
|
private own;
|
|
17
35
|
private custom;
|
|
18
|
-
/**
|
|
19
|
-
private
|
|
36
|
+
/** The message this controller last wrote into `error`. */
|
|
37
|
+
private written;
|
|
38
|
+
/** The anchor last handed to setValidity(). */
|
|
39
|
+
private anchor?;
|
|
40
|
+
/**
|
|
41
|
+
* Anchors a validation bubble was shown on, the last two. WebKit keeps a
|
|
42
|
+
* pointer to that anchor without keeping it alive: once a re-render drops
|
|
43
|
+
* it (ty-calendar rebuilds its grid) and it is garbage-collected, the next
|
|
44
|
+
* submit crashes the page. Held until two later bubbles replaced it.
|
|
45
|
+
*/
|
|
46
|
+
private shown;
|
|
47
|
+
/** The form whose requestSubmit / reportValidity this field keeps wrapped. */
|
|
48
|
+
private form;
|
|
20
49
|
constructor(host: HTMLElement, internals: ElementInternals);
|
|
50
|
+
/**
|
|
51
|
+
* The host connected, disconnected or changed form: keep its form's
|
|
52
|
+
* requestSubmit / reportValidity wrapped while it (or another Ty field with
|
|
53
|
+
* an error line) is in it. Only such a field needs it: a native control or
|
|
54
|
+
* a bubble field is focused by the browser itself.
|
|
55
|
+
*/
|
|
56
|
+
track(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Show the current message, if any, in the error display (on blur after an
|
|
59
|
+
* edit). During a pointer interaction it waits until after the click.
|
|
60
|
+
*/
|
|
61
|
+
reveal(): void;
|
|
62
|
+
/**
|
|
63
|
+
* `error` still holds what this controller wrote (a reportValidity(), a
|
|
64
|
+
* submit, a blur reveal), so it's ours to update and clear. Once the author
|
|
65
|
+
* sets their own message, it's theirs.
|
|
66
|
+
*/
|
|
67
|
+
private get errorFromReport();
|
|
68
|
+
private writeError;
|
|
69
|
+
/** Into `error`, unless the author's own message is there. */
|
|
70
|
+
private showError;
|
|
71
|
+
/**
|
|
72
|
+
* form.reset(): drop the message this controller showed and any blur
|
|
73
|
+
* reveal still waiting, so the field looks untouched again. An `error` the
|
|
74
|
+
* author set stays.
|
|
75
|
+
*/
|
|
76
|
+
reset(): void;
|
|
21
77
|
/** The component's own validity (replaces the previous one). */
|
|
22
78
|
set(flags: ValidityStateFlags, message?: string, anchor?: HTMLElement): void;
|
|
23
79
|
setCustom(message: string): void;
|
|
24
80
|
report(): boolean;
|
|
25
81
|
private sync;
|
|
26
82
|
}
|
|
83
|
+
type ProbeTag = 'input' | 'textarea' | 'select';
|
|
84
|
+
/**
|
|
85
|
+
* The browser's own (localized) message for a rule: a detached native control
|
|
86
|
+
* gets the same attributes and value and reports what it would say. `true`
|
|
87
|
+
* sets a boolean attribute; '', false and null leave the attribute off. One
|
|
88
|
+
* probe per tag, never in the document, stripped of every attribute before
|
|
89
|
+
* each use. Works for required and min/max; length rules only report after a
|
|
90
|
+
* user edit, so a probe can't word them (see lengthValidity()).
|
|
91
|
+
*/
|
|
92
|
+
export declare function nativeMessage(tag: ProbeTag, attrs: Record<string, string | boolean | null | undefined>, value?: string): string;
|
|
93
|
+
/**
|
|
94
|
+
* nativeMessage() plus the probe's own flags, for rules whose attribute the
|
|
95
|
+
* browser parses (min/max: ' 5 ' or '0x10' is no rule at all), so the flag
|
|
96
|
+
* and its message can't disagree. Read `validity` right away: the probe is
|
|
97
|
+
* reused by the next call.
|
|
98
|
+
*/
|
|
99
|
+
export declare function nativeValidity(tag: ProbeTag, attrs: Record<string, string | boolean | null | undefined>, value?: string): {
|
|
100
|
+
validity: ValidityState;
|
|
101
|
+
message: string;
|
|
102
|
+
};
|
|
103
|
+
/** Non-negative integer limit from an attribute string, or null when unset/invalid. */
|
|
104
|
+
export declare function toLimit(v: unknown): number | null;
|
|
105
|
+
/**
|
|
106
|
+
* minlength / maxlength for a text field (ty-input, ty-textarea): the failing
|
|
107
|
+
* flags with their messages. `control` is the inner native control carrying
|
|
108
|
+
* `minlength`; it only flags (and words, localized) a value the user typed,
|
|
109
|
+
* so its message is used then. Otherwise Ty's wording, and the author's
|
|
110
|
+
* too-short / too-long message always wins. Placeholders: {minlength}
|
|
111
|
+
* {maxlength} {length}.
|
|
112
|
+
*/
|
|
113
|
+
export declare function lengthValidity(value: string, rules: {
|
|
114
|
+
minlength: unknown;
|
|
115
|
+
maxlength: unknown;
|
|
116
|
+
tooShortMessage: string;
|
|
117
|
+
tooLongMessage: string;
|
|
118
|
+
}, control?: HTMLInputElement | HTMLTextAreaElement | null): {
|
|
119
|
+
tooShort?: string;
|
|
120
|
+
tooLong?: string;
|
|
121
|
+
};
|
|
122
|
+
export {};
|
package/lib/utils/validity.js
CHANGED
|
@@ -1,10 +1,201 @@
|
|
|
1
|
+
let submitAttempt = false;
|
|
2
|
+
let pointerPressed = false;
|
|
3
|
+
let touchRelease;
|
|
4
|
+
const pendingReveals = new Set();
|
|
5
|
+
let documentWatched = false;
|
|
6
|
+
function release() {
|
|
7
|
+
clearTimeout(touchRelease);
|
|
8
|
+
pointerPressed = false;
|
|
9
|
+
if (pendingReveals.size === 0)
|
|
10
|
+
return;
|
|
11
|
+
setTimeout(() => {
|
|
12
|
+
const waiting = [...pendingReveals];
|
|
13
|
+
pendingReveals.clear();
|
|
14
|
+
waiting.forEach((c) => c.reveal());
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function watchDocument() {
|
|
18
|
+
if (documentWatched)
|
|
19
|
+
return;
|
|
20
|
+
documentWatched = true;
|
|
21
|
+
const mark = () => {
|
|
22
|
+
submitAttempt = true;
|
|
23
|
+
setTimeout(() => { submitAttempt = false; });
|
|
24
|
+
};
|
|
25
|
+
document.addEventListener('click', (e) => {
|
|
26
|
+
const control = e.composedPath().find((n) => n instanceof HTMLButtonElement || n instanceof HTMLInputElement);
|
|
27
|
+
if (control?.form && (control.type === 'submit' || control.type === 'image'))
|
|
28
|
+
mark();
|
|
29
|
+
if (pointerPressed)
|
|
30
|
+
release();
|
|
31
|
+
}, true);
|
|
32
|
+
document.addEventListener('keydown', (e) => {
|
|
33
|
+
const target = e.composedPath()[0];
|
|
34
|
+
if (e.key === 'Enter' && !e.isComposing && target instanceof HTMLInputElement && target.form)
|
|
35
|
+
mark();
|
|
36
|
+
}, true);
|
|
37
|
+
document.addEventListener('pointerdown', () => {
|
|
38
|
+
clearTimeout(touchRelease);
|
|
39
|
+
pointerPressed = true;
|
|
40
|
+
}, true);
|
|
41
|
+
document.addEventListener('pointerup', (e) => {
|
|
42
|
+
if (e.pointerType === 'mouse')
|
|
43
|
+
release();
|
|
44
|
+
else
|
|
45
|
+
touchRelease = setTimeout(release, 1000);
|
|
46
|
+
}, true);
|
|
47
|
+
document.addEventListener('pointercancel', release, true);
|
|
48
|
+
watchRoot(document);
|
|
49
|
+
}
|
|
50
|
+
export function asSubmitAttempt(fn) {
|
|
51
|
+
const was = submitAttempt;
|
|
52
|
+
submitAttempt = true;
|
|
53
|
+
try {
|
|
54
|
+
return fn();
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
submitAttempt = was;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const formMethods = ['requestSubmit', 'reportValidity'];
|
|
61
|
+
const wrappedForms = new WeakMap();
|
|
62
|
+
function wrapForm(form) {
|
|
63
|
+
let entry = wrappedForms.get(form);
|
|
64
|
+
if (entry)
|
|
65
|
+
return entry;
|
|
66
|
+
entry = { fields: new Set(), ours: {} };
|
|
67
|
+
wrappedForms.set(form, entry);
|
|
68
|
+
for (const name of formMethods) {
|
|
69
|
+
if (typeof form[name] !== 'function')
|
|
70
|
+
continue;
|
|
71
|
+
const replaced = Object.getOwnPropertyDescriptor(form, name);
|
|
72
|
+
const previous = replaced ? form[name] : undefined;
|
|
73
|
+
const fn = function (...args) {
|
|
74
|
+
const next = previous ?? Object.getPrototypeOf(form)[name];
|
|
75
|
+
return asSubmitAttempt(() => next.apply(this, args));
|
|
76
|
+
};
|
|
77
|
+
Object.defineProperty(form, name, { value: fn, writable: true, configurable: true, enumerable: false });
|
|
78
|
+
entry.ours[name] = { fn, replaced };
|
|
79
|
+
}
|
|
80
|
+
return entry;
|
|
81
|
+
}
|
|
82
|
+
function unwrapForm(form, entry) {
|
|
83
|
+
wrappedForms.delete(form);
|
|
84
|
+
for (const name of formMethods) {
|
|
85
|
+
const own = entry.ours[name];
|
|
86
|
+
if (!own || Object.getOwnPropertyDescriptor(form, name)?.value !== own.fn)
|
|
87
|
+
continue;
|
|
88
|
+
if (own.replaced)
|
|
89
|
+
Object.defineProperty(form, name, own.replaced);
|
|
90
|
+
else
|
|
91
|
+
delete form[name];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const watchedRoots = new WeakSet();
|
|
95
|
+
function watchRoot(root) {
|
|
96
|
+
if (watchedRoots.has(root))
|
|
97
|
+
return;
|
|
98
|
+
watchedRoots.add(root);
|
|
99
|
+
root.addEventListener('invalid', (e) => {
|
|
100
|
+
if (!submitAttempt)
|
|
101
|
+
return;
|
|
102
|
+
const target = e.target;
|
|
103
|
+
const first = target.form ? firstInvalid(target.form) : undefined;
|
|
104
|
+
if (first && first !== target && hasErrorLine(first))
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
}, true);
|
|
107
|
+
}
|
|
108
|
+
function within(host, node) {
|
|
109
|
+
for (let n = node; n; n = n.getRootNode().host) {
|
|
110
|
+
if (host.contains(n))
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
function firstInvalid(form) {
|
|
116
|
+
return Array.from(form.elements).find((el) => {
|
|
117
|
+
const c = el;
|
|
118
|
+
return c.willValidate && c.validity && !c.validity.valid &&
|
|
119
|
+
c.checkVisibility?.({ visibilityProperty: true, checkVisibilityCSS: true }) !== false;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
const hosts = new WeakSet();
|
|
123
|
+
function hasErrorLine(el) {
|
|
124
|
+
return hosts.has(el) && 'error' in el;
|
|
125
|
+
}
|
|
1
126
|
export class ValidityController {
|
|
2
127
|
constructor(host, internals) {
|
|
3
128
|
this.host = host;
|
|
4
129
|
this.internals = internals;
|
|
5
130
|
this.own = { flags: {} };
|
|
6
131
|
this.custom = '';
|
|
7
|
-
this.
|
|
132
|
+
this.written = null;
|
|
133
|
+
this.shown = [];
|
|
134
|
+
this.form = null;
|
|
135
|
+
watchDocument();
|
|
136
|
+
hosts.add(host);
|
|
137
|
+
host.addEventListener('invalid', () => {
|
|
138
|
+
if (this.anchor && !this.shown.includes(this.anchor))
|
|
139
|
+
this.shown = [...this.shown.slice(-1), this.anchor];
|
|
140
|
+
});
|
|
141
|
+
host.addEventListener('invalid', (e) => {
|
|
142
|
+
if (!hasErrorLine(host))
|
|
143
|
+
return;
|
|
144
|
+
watchRoot(host.getRootNode());
|
|
145
|
+
e.preventDefault();
|
|
146
|
+
this.showError();
|
|
147
|
+
if (!submitAttempt)
|
|
148
|
+
return;
|
|
149
|
+
const form = this.internals.form;
|
|
150
|
+
if (!form || firstInvalid(form) === host)
|
|
151
|
+
host.focus();
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
track() {
|
|
155
|
+
const form = hasErrorLine(this.host) ? this.internals.form : null;
|
|
156
|
+
if (form === this.form)
|
|
157
|
+
return;
|
|
158
|
+
const old = this.form && wrappedForms.get(this.form);
|
|
159
|
+
if (old) {
|
|
160
|
+
old.fields.delete(this);
|
|
161
|
+
for (const c of old.fields)
|
|
162
|
+
if (c.internals.form !== this.form)
|
|
163
|
+
old.fields.delete(c);
|
|
164
|
+
if (old.fields.size === 0)
|
|
165
|
+
unwrapForm(this.form, old);
|
|
166
|
+
}
|
|
167
|
+
this.form = form;
|
|
168
|
+
if (form)
|
|
169
|
+
wrapForm(form).fields.add(this);
|
|
170
|
+
}
|
|
171
|
+
reveal() {
|
|
172
|
+
if (pointerPressed) {
|
|
173
|
+
pendingReveals.add(this);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if ('error' in this.host && !this.internals.validity.valid)
|
|
177
|
+
this.showError();
|
|
178
|
+
}
|
|
179
|
+
get errorFromReport() {
|
|
180
|
+
return this.written !== null && this.host.getAttribute('error') === this.written;
|
|
181
|
+
}
|
|
182
|
+
writeError(message) {
|
|
183
|
+
this.written = message;
|
|
184
|
+
if (message === null)
|
|
185
|
+
this.host.removeAttribute('error');
|
|
186
|
+
else
|
|
187
|
+
this.host.setAttribute('error', message);
|
|
188
|
+
}
|
|
189
|
+
showError() {
|
|
190
|
+
if (this.host.getAttribute('error') && !this.errorFromReport)
|
|
191
|
+
return;
|
|
192
|
+
this.writeError(this.internals.validationMessage);
|
|
193
|
+
}
|
|
194
|
+
reset() {
|
|
195
|
+
pendingReveals.delete(this);
|
|
196
|
+
if (this.errorFromReport)
|
|
197
|
+
this.writeError(null);
|
|
198
|
+
this.written = null;
|
|
8
199
|
}
|
|
9
200
|
set(flags, message, anchor) {
|
|
10
201
|
this.own = { flags, message, anchor };
|
|
@@ -19,8 +210,7 @@ const valid = this.internals.checkValidity();
|
|
|
19
210
|
if (valid)
|
|
20
211
|
return true;
|
|
21
212
|
if ('error' in this.host) {
|
|
22
|
-
this.
|
|
23
|
-
this.errorFromReport = true;
|
|
213
|
+
this.showError();
|
|
24
214
|
this.host.focus();
|
|
25
215
|
}
|
|
26
216
|
else {
|
|
@@ -29,7 +219,9 @@ this.internals.reportValidity();
|
|
|
29
219
|
return false;
|
|
30
220
|
}
|
|
31
221
|
sync() {
|
|
32
|
-
const { flags, message
|
|
222
|
+
const { flags, message } = this.own;
|
|
223
|
+
const anchor = this.own.anchor && within(this.host, this.own.anchor) ? this.own.anchor : undefined;
|
|
224
|
+
this.anchor = anchor;
|
|
33
225
|
const invalid = Object.values(flags).some(Boolean);
|
|
34
226
|
if (this.custom) {
|
|
35
227
|
this.internals.setValidity({ ...flags, customError: true }, this.custom, anchor);
|
|
@@ -40,14 +232,58 @@ this.internals.setValidity(flags, message || 'Invalid value', anchor);
|
|
|
40
232
|
else {
|
|
41
233
|
this.internals.setValidity({});
|
|
42
234
|
}
|
|
43
|
-
if (!this.errorFromReport)
|
|
235
|
+
if (!this.errorFromReport) {
|
|
236
|
+
this.written = null;
|
|
44
237
|
return;
|
|
238
|
+
}
|
|
45
239
|
if (this.internals.validity.valid) {
|
|
46
|
-
this.
|
|
47
|
-
this.errorFromReport = false;
|
|
240
|
+
this.writeError(null);
|
|
48
241
|
}
|
|
49
242
|
else if (this.host.getAttribute('error') !== this.internals.validationMessage) {
|
|
50
|
-
this.
|
|
243
|
+
this.showError();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
const probes = {};
|
|
248
|
+
export function nativeMessage(tag, attrs, value = '') {
|
|
249
|
+
const probe = (probes[tag] ?? (probes[tag] = document.createElement(tag)));
|
|
250
|
+
for (const name of probe.getAttributeNames())
|
|
251
|
+
probe.removeAttribute(name);
|
|
252
|
+
for (const [name, v] of Object.entries(attrs)) {
|
|
253
|
+
if (v === true)
|
|
254
|
+
probe.setAttribute(name, '');
|
|
255
|
+
else if (v)
|
|
256
|
+
probe.setAttribute(name, v);
|
|
257
|
+
}
|
|
258
|
+
probe.value = value;
|
|
259
|
+
return probe.validationMessage;
|
|
260
|
+
}
|
|
261
|
+
export function nativeValidity(tag, attrs, value = '') {
|
|
262
|
+
const message = nativeMessage(tag, attrs, value);
|
|
263
|
+
return { validity: probes[tag].validity, message };
|
|
264
|
+
}
|
|
265
|
+
export function toLimit(v) {
|
|
266
|
+
if (v === null || v === undefined || String(v).trim() === '')
|
|
267
|
+
return null;
|
|
268
|
+
const n = Number(v);
|
|
269
|
+
return Number.isInteger(n) && n >= 0 ? n : null;
|
|
270
|
+
}
|
|
271
|
+
function fillMessage(template, vars) {
|
|
272
|
+
return template.replace(/\{(\w+)\}/g, (match, key) => vars[key] != null ? String(vars[key]) : match);
|
|
273
|
+
}
|
|
274
|
+
export function lengthValidity(value, rules, control) {
|
|
275
|
+
const length = value.length;
|
|
276
|
+
const minLength = toLimit(rules.minlength);
|
|
277
|
+
const maxLength = toLimit(rules.maxlength);
|
|
278
|
+
const vars = { minlength: minLength, maxlength: maxLength, length };
|
|
279
|
+
const result = {};
|
|
280
|
+
if (minLength !== null && length < minLength) {
|
|
281
|
+
result.tooShort = !rules.tooShortMessage && control?.validity.tooShort
|
|
282
|
+
? control.validationMessage
|
|
283
|
+
: fillMessage(rules.tooShortMessage || 'Use at least {minlength} characters (now {length})', vars);
|
|
51
284
|
}
|
|
285
|
+
if (maxLength !== null && length > maxLength) {
|
|
286
|
+
result.tooLong = fillMessage(rules.tooLongMessage || 'Use at most {maxlength} characters (now {length})', vars);
|
|
52
287
|
}
|
|
288
|
+
return result;
|
|
53
289
|
}
|
package/lib/version.d.ts
CHANGED
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '1.0.0-
|
|
1
|
+
export const VERSION = '1.0.0-RC18';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tyrell-components",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-RC18",
|
|
4
4
|
"description": "Tyrell Components - Framework-agnostic web components with semantic design system",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -155,10 +155,11 @@
|
|
|
155
155
|
"scripts": {
|
|
156
156
|
"dev": "vite",
|
|
157
157
|
"generate:version": "node scripts/generate-version.js",
|
|
158
|
-
"build:lib": "npm run generate:version && tsc --project tsconfig.lib.json && tsc --project tsconfig.lib.dts.json && node scripts/strip-lib-comments.mjs",
|
|
159
|
-
"build:
|
|
160
|
-
"build:
|
|
161
|
-
"build:dev:
|
|
158
|
+
"build:lib": "npm run generate:version && npm run build:css && tsc --project tsconfig.lib.json && tsc --project tsconfig.lib.dts.json && node scripts/strip-lib-comments.mjs",
|
|
159
|
+
"build:css": "node scripts/build-css.mjs",
|
|
160
|
+
"build:cdn": "npm run generate:version && vite build --config vite.config.cdn.ts && npm run build:css",
|
|
161
|
+
"build:dev": "npm run generate:version && vite build --config vite.config.dev.ts && npm run build:css",
|
|
162
|
+
"build:dev:watch": "node scripts/build-css.mjs --watch & vite build --config vite.config.dev.ts --watch",
|
|
162
163
|
"build": "npm run build:lib && npm run build:cdn",
|
|
163
164
|
"prepublishOnly": "npm run build",
|
|
164
165
|
"preview": "vite preview",
|
|
@@ -175,6 +176,7 @@
|
|
|
175
176
|
"@web/dev-server-esbuild": "^1.0.5",
|
|
176
177
|
"@web/test-runner": "^0.20.2",
|
|
177
178
|
"@web/test-runner-chrome": "^0.18.1",
|
|
179
|
+
"@web/test-runner-commands": "^0.9.0",
|
|
178
180
|
"autoprefixer": "^10.4.27",
|
|
179
181
|
"axe-core": "^4.12.1",
|
|
180
182
|
"typescript": "^5.7.0",
|
|
@@ -183,7 +185,7 @@
|
|
|
183
185
|
},
|
|
184
186
|
"repository": {
|
|
185
187
|
"type": "git",
|
|
186
|
-
"url": "https://github.com/gersak/tyrell.git",
|
|
188
|
+
"url": "git+https://github.com/gersak/tyrell.git",
|
|
187
189
|
"directory": "packages/core"
|
|
188
190
|
},
|
|
189
191
|
"homepage": "https://gersak.github.io/tyrell/",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ty-component.d.ts","sourceRoot":"","sources":["../../src/base/ty-component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAA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