tyrell-components 1.0.0-TC58 → 1.0.0-TC60

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.
Files changed (73) hide show
  1. package/README.md +1 -1
  2. package/css/tyrell-colors-static.css +14 -0
  3. package/css/tyrell-theme.css +6 -5
  4. package/css/tyrell.css +8 -6
  5. package/dist/tyrell-colors-static.css +1 -1
  6. package/dist/tyrell-theme.css +1 -1
  7. package/dist/tyrell.js +1 -1
  8. package/lib/base/ty-component.d.ts +13 -12
  9. package/lib/base/ty-component.js +56 -21
  10. package/lib/components/button.d.ts +10 -0
  11. package/lib/components/button.js +22 -1
  12. package/lib/components/calendar-month.d.ts +7 -1
  13. package/lib/components/calendar-month.js +32 -18
  14. package/lib/components/calendar-navigation.js +19 -6
  15. package/lib/components/calendar.d.ts +25 -5
  16. package/lib/components/calendar.js +87 -37
  17. package/lib/components/checkbox.d.ts +5 -0
  18. package/lib/components/checkbox.js +18 -5
  19. package/lib/components/copy.d.ts +2 -0
  20. package/lib/components/copy.js +15 -31
  21. package/lib/components/date-picker.d.ts +7 -26
  22. package/lib/components/date-picker.js +14 -84
  23. package/lib/components/file-upload.js +6 -2
  24. package/lib/components/input.d.ts +0 -9
  25. package/lib/components/input.js +18 -40
  26. package/lib/components/modal.js +59 -18
  27. package/lib/components/option.d.ts +19 -0
  28. package/lib/components/option.js +38 -26
  29. package/lib/components/popup.js +56 -5
  30. package/lib/components/radio.d.ts +6 -0
  31. package/lib/components/radio.js +12 -28
  32. package/lib/components/select.d.ts +132 -194
  33. package/lib/components/select.js +436 -836
  34. package/lib/components/selected-tags.d.ts +8 -4
  35. package/lib/components/selected-tags.js +26 -8
  36. package/lib/components/switch.d.ts +4 -0
  37. package/lib/components/switch.js +18 -5
  38. package/lib/components/tabs.js +1 -1
  39. package/lib/components/textarea.d.ts +1 -0
  40. package/lib/components/textarea.js +21 -8
  41. package/lib/index.d.ts +1 -0
  42. package/lib/index.js +1 -0
  43. package/lib/styles/button.js +1 -0
  44. package/lib/styles/calendar-month.js +1 -1
  45. package/lib/styles/calendar.js +3 -0
  46. package/lib/styles/checkbox.js +11 -5
  47. package/lib/styles/date-picker.js +5 -10
  48. package/lib/styles/input.js +5 -9
  49. package/lib/styles/option.d.ts +1 -1
  50. package/lib/styles/option.js +6 -7
  51. package/lib/styles/popup.d.ts +1 -1
  52. package/lib/styles/popup.js +2 -0
  53. package/lib/styles/radio.js +10 -4
  54. package/lib/styles/select-base.js +6 -70
  55. package/lib/styles/select.d.ts +1 -1
  56. package/lib/styles/select.js +13 -2
  57. package/lib/styles/switch.js +10 -5
  58. package/lib/styles/tag.js +2 -1
  59. package/lib/types/common.d.ts +3 -1
  60. package/lib/utils/calendar-utils.d.ts +49 -0
  61. package/lib/utils/calendar-utils.js +63 -6
  62. package/lib/utils/property-manager.d.ts +0 -5
  63. package/lib/utils/property-manager.js +0 -11
  64. package/lib/utils/scroll-lock.d.ts +10 -4
  65. package/lib/utils/scroll-lock.js +102 -2
  66. package/lib/utils/validity.d.ts +27 -1
  67. package/lib/utils/validity.js +68 -16
  68. package/lib/version.d.ts +1 -1
  69. package/lib/version.js +1 -1
  70. package/package.json +1 -1
  71. package/dist/tyrell.js.map +0 -1
  72. package/lib/utils/error-flavor.d.ts +0 -8
  73. package/lib/utils/error-flavor.js +0 -1
@@ -1,7 +1,7 @@
1
1
  import { FLAVORS } from "../types/common.js";
2
2
  import { fieldSizeVars } from "./field-size.js";
3
3
  import { customScrollbarStyles } from "./custom-scrollbar.js";
4
- const selectFlavor = (f, fb) => {
4
+ const selectFlavor = (f, fb, also = "") => {
5
5
  const c = (s) => fb
6
6
  ? s
7
7
  ? `var(--ty-color-${f}${s}, var(--ty-color-${f}, var(--ty-color-${fb}${s})))`
@@ -10,7 +10,7 @@ const c = (s) => fb
10
10
  ? `var(--ty-color-${f}${s}, var(--ty-color-${f}))`
11
11
  : `var(--ty-color-${f})`;
12
12
  return `
13
- :host([flavor="${f}"]) {
13
+ :host([flavor="${f}"])${also} {
14
14
  --select-accent: var(--ty-input-${f}-border, ${c("-soft")});
15
15
  --select-accent-bold: ${c("")};
16
16
  --select-ring: color-mix(in oklab, ${c("")} 15%, transparent);
@@ -27,6 +27,7 @@ return `
27
27
  }
28
28
  `;
29
29
  };
30
+ const errorLook = `,\n:host([error]:not([error=""]))`;
30
31
  export const selectCustomFlavorCss = (base) => selectFlavor(base, "neutral");
31
32
  export const selectBaseStyles = `
32
33
  ${fieldSizeVars}
@@ -62,7 +63,6 @@ transition:
62
63
  opacity var(--ty-popup-duration, 180ms) var(--ty-popup-ease, cubic-bezier(0.34, 1.56, 0.64, 1)),
63
64
  scale var(--ty-popup-duration, 180ms) var(--ty-popup-ease, cubic-bezier(0.34, 1.56, 0.64, 1)),
64
65
  translate var(--ty-popup-duration, 180ms) var(--ty-popup-ease, cubic-bezier(0.34, 1.56, 0.64, 1));
65
- transform: translate(var(--dropdown-offset-x, 0px), var(--dropdown-offset-y, 0px));
66
66
  top: -1000px;
67
67
  left: -1000px;
68
68
  }
@@ -256,27 +256,9 @@ width: max(100%, 20em);
256
256
  :host([has-trigger]) .error-message {
257
257
  padding-left: 0;
258
258
  }
259
- .select-stub.error:not(.custom-trigger) {
260
- border-color: var(--ty-color-danger);
259
+ .select-stub.error:not(.custom-trigger):not([disabled]) {
261
260
  background: var(--ty-bg-danger-soft);
262
261
  }
263
- .select-stub.error:not(.custom-trigger):focus,
264
- .select-stub.error:not(.custom-trigger):focus-visible {
265
- border-color: var(--ty-color-danger-bold);
266
- box-shadow: 0 0 0 3px var(--input-shadow-focus, var(--ty-input-shadow-focus));
267
- }
268
- .dropdown-mode-mobile .dropdown-wrapper:has(.mobile-dialog[open]) .select-chips {
269
- display: none;
270
- }
271
- .select-stub.has-tags {
272
- padding: 0.25rem 2.5rem 0.25rem 0.5rem;
273
- width: 100%;
274
- }
275
- .select-stub.has-tags slot[name="selected"] {
276
- display: flex;
277
- flex-wrap: wrap;
278
- gap: 0.25rem;
279
- }
280
262
  .dropdown-chevron {
281
263
  position: absolute;
282
264
  top: 50%;
@@ -295,13 +277,6 @@ transform: translateY(-50%) rotate(180deg);
295
277
  width: 100%;
296
278
  height: 100%;
297
279
  }
298
- .select-chips {
299
- display: flex;
300
- flex-wrap: wrap;
301
- gap: 0.5rem;
302
- align-items: center;
303
- min-width: 0;
304
- }
305
280
  .dropdown-placeholder {
306
281
  color: var(--input-placeholder, var(--ty-input-placeholder, #9ca3af));
307
282
  font-size: var(--ty-field-font);
@@ -352,27 +327,6 @@ position: relative;
352
327
  .dropdown-options-wrapper:hover .ty-scrollbar-track-y.has-overflow {
353
328
  opacity: 1;
354
329
  }
355
- .dropdown-options ty-tag {
356
- user-select: none;
357
- transition: transform 0.1s ease;
358
- }
359
- .dropdown-options ty-tag:hover {
360
- transform: scale(1.02);
361
- }
362
- .dropdown-options ty-tag:active {
363
- transform: scale(0.98);
364
- }
365
- .dropdown-options ty-tag[selected] {
366
- opacity: 0.5;
367
- }
368
- .select-chips ty-tag {
369
- max-width: 150px;
370
- }
371
- @media (max-width: 640px) {
372
- .select-chips ty-tag {
373
- max-width: 100px;
374
- }
375
- }
376
330
  .select-container {
377
331
  display: flex;
378
332
  flex-direction: column;
@@ -711,30 +665,12 @@ display: block;
711
665
  .dropdown-mode-mobile .mobile-available-section[data-empty="true"] slot {
712
666
  display: none;
713
667
  }
714
- .dropdown-mode-mobile .section-content ::slotted(ty-tag) {
715
- cursor: pointer;
716
- user-select: none;
717
- transition: transform 0.1s ease;
718
- margin: 2px 0;
719
- animation: ty-select-tag-enter 180ms cubic-bezier(0.16, 1, 0.3, 1);
720
- }
721
- @media (hover: hover) {
722
- .dropdown-mode-mobile .section-content ::slotted(ty-tag:hover) {
723
- transform: scale(1.02);
724
- }
725
- }
726
- .dropdown-mode-mobile .section-content ::slotted(ty-tag:active) {
727
- transform: scale(0.96);
728
- }
729
- .dropdown-mode-mobile .section-content ::slotted(ty-tag[hidden]) {
730
- display: none !important;
731
- }
732
668
  @keyframes ty-select-tag-enter {
733
669
  from { opacity: 0; transform: scale(0.85); }
734
670
  to { opacity: 1; transform: scale(1); }
735
671
  }
736
672
  @media (prefers-reduced-motion: reduce) {
737
- .dropdown-mode-mobile .section-content ::slotted(ty-tag) {
673
+ .dropdown-mode-mobile .mobile-selected-chip {
738
674
  animation: none;
739
675
  }
740
676
  }
@@ -807,5 +743,5 @@ animation-duration: 1.6s;
807
743
  }
808
744
  }
809
745
  ${customScrollbarStyles}
810
- ${FLAVORS.filter((f) => f !== "neutral").map((f) => selectFlavor(f)).join("")}
746
+ ${FLAVORS.filter((f) => f !== "neutral").map((f) => selectFlavor(f, undefined, f === "danger" ? errorLook : "")).join("")}
811
747
  `;
@@ -8,4 +8,4 @@
8
8
  * - .compact: content-hugging trigger for toolbars, count badge
9
9
  * - .custom-trigger (slot="trigger"): all chrome stripped
10
10
  */
11
- export declare const selectStyles = "\n/* Compact skin hugs its content (field skin = base styles) */\n.select-stub.compact {\n display: inline-flex;\n flex-wrap: nowrap;\n width: auto;\n gap: 0.5rem;\n /* extra right padding = room for the absolutely-positioned chevron */\n padding: 0.5rem 2.25rem 0.5rem 0.875rem;\n}\n\n/* Consumer-provided trigger (slot=\"trigger\"): no chrome at all */\n.select-stub.custom-trigger {\n display: inline-block;\n width: auto;\n border: none;\n background: none;\n padding: 0;\n min-height: 0;\n border-radius: 0;\n}\n.select-stub.custom-trigger:hover {\n border: none;\n}\n\n.select-count {\n flex-shrink: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 1.25rem;\n height: 1.25rem;\n padding: 0 0.375rem;\n border-radius: 9999px;\n /* --ty-text-primary never existed as a token \u2014 this silently fell back\n to inherited/unset color. Now follows the select's own flavor. */\n background: color-mix(in oklab, var(--select-accent, var(--ty-color-primary)) 15%, transparent);\n color: var(--select-accent-bold, var(--ty-color-primary-strong));\n font-size: var(--ty-font-xs);\n font-weight: var(--ty-font-semibold);\n font-style: normal;\n}\n.select-count[hidden] {\n display: none;\n}\n\n/* Clear (x) button \u2014 normal flex child of .select-stub, not absolutely\n positioned like .dropdown-chevron: it just takes its own space in the\n row, no padding-right gutter math needed. Lives in the trigger slot's\n fallback content, so it's automatically absent under slot=\"trigger\". */\n.select-clear {\n flex-shrink: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 1rem;\n height: 1rem;\n padding: 0;\n border: none;\n background: none;\n color: var(--input-placeholder, var(--ty-input-placeholder));\n cursor: pointer;\n border-radius: var(--ty-radius-sm);\n transition: var(--ty-local-transition, all 0.15s ease);\n}\n/* Pull toward the chevron: the stub's right padding (chevron room) left 12px\n between them on the field skin, 8px on compact. Both land at 6px. */\n.select-stub .select-clear {\n margin-right: -0.375rem;\n}\n.select-stub.compact .select-clear {\n margin-right: -0.125rem;\n}\n.select-clear[hidden] {\n display: none;\n}\n.select-clear:hover {\n /* Destructive utility action \u2014 neutral at rest, warns danger-red on\n hover regardless of the field's own flavor. */\n color: var(--ty-color-danger);\n background-color: var(--ty-bg-danger-soft);\n}\n.select-clear svg {\n width: 100%;\n height: 100%;\n}\n\n/* Selection text (field skin): single line, ellipsis, input colors.\n flex-basis 0, not auto \u2014 .select-stub is flex-wrap:wrap, and auto's\n hypothetical size is the FULL untruncated text width (wrap-line\n assignment happens before shrinking), which pushed fixed-size siblings\n (.select-clear) onto a second line even though the text visibly had\n room after truncating. 0 makes this item contribute ~nothing to the\n line-fit check up front; grow/shrink + overflow:hidden still truncate\n it identically. */\n.select-stub .dropdown-placeholder {\n font-style: normal;\n flex: 1 1 0%;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: var(--input-color, var(--ty-input-color));\n}\n\n.select-stub .dropdown-placeholder.placeholder-shown {\n color: var(--input-placeholder, var(--ty-input-placeholder));\n}\n.select-stub .dropdown-placeholder[hidden] {\n display: none;\n}\n\n/* Single-select display clone (slot=\"selected\"): the selected ty-option\n projected into the stub \u2014 its own :host([cloned]) styling strips the\n list-row chrome; here it just takes the text's flex slot. */\n.select-stub slot[name=\"selected\"] {\n display: none;\n}\n.select-stub.has-clone slot[name=\"selected\"] {\n display: block;\n /* flex-basis 0, not auto \u2014 same reasoning as .dropdown-placeholder above:\n .select-stub is flex-wrap:wrap, and auto's hypothetical size is the\n clone's full untruncated text width, which pushes .select-clear onto\n a second line. */\n flex: 1 1 0%;\n min-width: 0;\n overflow: hidden;\n}\n.select-stub.compact.has-clone slot[name=\"selected\"] {\n flex: 0 1 auto;\n}\n\n/* start/end slot content (icons etc.) \u2014 spacing comes from the stub's flex\n gap; muted like ty-input adornments. end sits before the chevron. */\n.select-stub ::slotted([slot=\"start\"]),\n.select-stub ::slotted([slot=\"end\"]) {\n flex-shrink: 0;\n color: var(--ty-text-soft);\n}\n\n/* Compact skin: the text IS the trigger label \u2014 no grow, regular text color.\n flex-basis: auto (not the field skin's 0%) \u2014 content-hugging needs its\n natural content width as the starting point; 0% would collapse it since\n grow is also 0 here (nothing left to expand it back out). */\n.select-stub.compact .dropdown-placeholder {\n flex: 0 1 auto;\n color: var(--ty-text);\n}\n\n/* Trigger stays visible while the popup is open (the popup hides it) */\n.dropdown-wrapper:has(.dropdown-chevron.open) .select-stub {\n opacity: 1;\n pointer-events: auto;\n}\n\n/* One-panel popup: search header fused with the options list */\n\n/* Single unified shadow around the whole panel (header + list as one silhouette) */\n.dropdown-dialog.open {\n filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.14)) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.08));\n}\n\n/* Card-style header: the search input keeps its own bordered-field look\n (base styles) and sits inset in the panel, TagPicker-style \u2014 no divider,\n whitespace separates it from the list. The header's OWN surface/border is\n part of the floating panel's chrome, not a form field \u2014 --ty-surface-\n floating/--ty-floating-border, matching .dropdown-options below it (same\n reasoning as the base-panel fix: --ty-input-* is deliberately faint for\n resting form fields and read as a missing/mismatched edge here). */\n.dropdown-header {\n background: var(--ty-surface-floating);\n border: 1px solid var(--ty-floating-border);\n border-bottom: none;\n border-radius: var(--ty-radius-lg) var(--ty-radius-lg) 0 0;\n padding: var(--ty-spacing-2) var(--ty-spacing-2) var(--ty-spacing-1);\n}\n.dropdown-dialog.position-below .dropdown-header {\n margin-bottom: 0;\n}\n.dropdown-dialog.position-above .dropdown-header {\n margin-top: 0;\n border-top: none;\n border-bottom: 1px solid var(--ty-floating-border);\n border-radius: 0 0 var(--ty-radius-lg) var(--ty-radius-lg);\n padding: var(--ty-spacing-1) var(--ty-spacing-2) var(--ty-spacing-2);\n}\n\n/* Magnifier adornment inside the search field (header padding + field inset) */\n.dropdown-search-icon {\n position: absolute;\n top: 50%;\n left: calc(var(--ty-spacing-2) + var(--ty-spacing-3));\n transform: translateY(-50%);\n width: 1rem;\n height: 1rem;\n color: var(--input-placeholder, var(--ty-input-placeholder));\n pointer-events: none;\n}\n.dropdown-search-icon svg {\n width: 100%;\n height: 100%;\n}\n\n/* Mobile header: flex row, icon flows inline before the input. Same 32x32\n footprint as .mobile-close-button (18px glyph centered in the box, not a\n bare 18px glyph flush at the edge) so the row has two matching bookends \u2014\n a bare icon on one side and a 32px circle on the other read as lopsided\n even with equal flex gap on both sides. Matching them also centers the\n search input's flex:1 fill symmetrically between the two. Fixed white +\n 18px glyph, same reasoning as .mobile-header-label \u2014 this sits on the\n dark ::backdrop blur in both themes, not a theme surface. */\n.dropdown-mode-mobile .mobile-header-content .dropdown-search-icon {\n position: static;\n transform: none;\n flex-shrink: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n color: #ffffff;\n}\n.dropdown-mode-mobile .mobile-header-content .dropdown-search-icon svg {\n width: 18px;\n height: 18px;\n}\n\n/* Search input: bordered field from base styles; just size + icon room */\n.dropdown-search-input {\n min-height: 2.25rem;\n padding-right: var(--ty-spacing-2);\n /* room for the magnifier adornment */\n padding-left: calc(var(--ty-spacing-3) + 1rem + var(--ty-spacing-2));\n}\n/* Trigger already has a chevron - no second one inside the search row */\n.dropdown-search-chevron {\n display: none;\n}\n\n/* With the search row hidden nothing inside is focusable, so the <dialog>\n itself receives focus on open \u2014 suppress its UA focus ring */\n.dropdown-dialog:focus,\n.dropdown-dialog:focus-visible {\n outline: none;\n}\n\n/* Search row hidden ('auto' below threshold / searchable=\"false\"):\n the options panel owns the whole silhouette */\n.dropdown-header[hidden] {\n display: none;\n}\n.dropdown-header[hidden] ~ .dropdown-options-wrapper .dropdown-options {\n border-top: 1px solid var(--ty-floating-border);\n border-radius: var(--ty-radius-lg);\n}\n.mobile-search-input[hidden],\n.mobile-header-content .dropdown-search-icon[hidden] {\n display: none;\n}\n\n/* Options: vertical list rows fused under the search header.\n No own shadow/animation - the panel appears as one via dialog opacity. */\n.dropdown-options {\n flex-direction: column;\n flex-wrap: nowrap;\n align-items: stretch;\n gap: 0;\n /* Card-style list: rounded rows sit inset from the panel edges */\n padding: var(--ty-spacing-1);\n border-top: none;\n border-radius: 0 0 var(--ty-radius-lg) var(--ty-radius-lg);\n box-shadow: none;\n transform: none;\n transition: none;\n /* ~9-10 visible rows before scrolling (custom scrollbar, native hidden) */\n max-height: 24rem;\n}\n.dropdown-dialog.position-below .dropdown-options {\n box-shadow: none;\n}\n.dropdown-dialog.position-above .dropdown-options {\n border-top: 1px solid var(--ty-floating-border);\n border-bottom: none;\n border-radius: var(--ty-radius-lg) var(--ty-radius-lg) 0 0;\n}\n\n/* Loading panel continues the fused silhouette exactly like .dropdown-options \u2014\n the base layer styles it as a floating card (radius + shadow), which left a\n see-through gap under the search header while loading. */\n.dropdown-loading {\n border-top: none;\n border-radius: 0 0 var(--ty-radius-lg) var(--ty-radius-lg);\n box-shadow: none;\n}\n.dropdown-dialog.position-above .dropdown-loading {\n border-top: 1px solid var(--ty-floating-border);\n border-bottom: none;\n border-radius: var(--ty-radius-lg) var(--ty-radius-lg) 0 0;\n}\n\n/* Selection tick lives inside ty-option (lucide check on [selected]) */\n\n/* Mobile modal: same vertical list */\n.dropdown-mode-mobile .section-content ::slotted(ty-option) {\n display: block;\n width: 100%;\n}\n";
11
+ export declare const selectStyles = "\n/* Compact skin hugs its content (field skin = base styles) */\n.select-stub.compact {\n display: inline-flex;\n flex-wrap: nowrap;\n width: auto;\n gap: 0.5rem;\n /* extra right padding = room for the absolutely-positioned chevron */\n padding: 0.5rem 2.25rem 0.5rem 0.875rem;\n}\n\n/* Consumer-provided trigger (slot=\"trigger\"): no chrome at all */\n.select-stub.custom-trigger {\n display: inline-block;\n width: auto;\n border: none;\n background: none;\n padding: 0;\n min-height: 0;\n border-radius: 0;\n}\n.select-stub.custom-trigger:hover {\n border: none;\n}\n\n.select-count {\n flex-shrink: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 1.25rem;\n height: 1.25rem;\n padding: 0 0.375rem;\n border-radius: 9999px;\n /* --ty-text-primary never existed as a token \u2014 this silently fell back\n to inherited/unset color. Now follows the select's own flavor. */\n background: color-mix(in oklab, var(--select-accent, var(--ty-color-primary)) 15%, transparent);\n color: var(--select-accent-bold, var(--ty-color-primary-strong));\n font-size: var(--ty-font-xs);\n font-weight: var(--ty-font-semibold);\n font-style: normal;\n}\n.select-count[hidden] {\n display: none;\n}\n\n/* Clear (x) button \u2014 normal flex child of .select-stub, not absolutely\n positioned like .dropdown-chevron: it just takes its own space in the\n row, no padding-right gutter math needed. Lives in the trigger slot's\n fallback content, so it's automatically absent under slot=\"trigger\". */\n.select-clear {\n flex-shrink: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 1rem;\n height: 1rem;\n padding: 0;\n border: none;\n background: none;\n color: var(--input-placeholder, var(--ty-input-placeholder));\n cursor: pointer;\n border-radius: var(--ty-radius-sm);\n transition: var(--ty-local-transition, all 0.15s ease);\n}\n/* Pull toward the chevron: the stub's right padding (chevron room) left 12px\n between them on the field skin, 8px on compact. Both land at 6px. */\n.select-stub .select-clear {\n margin-right: -0.375rem;\n}\n.select-stub.compact .select-clear {\n margin-right: -0.125rem;\n}\n.select-clear[hidden] {\n display: none;\n}\n.select-clear:hover {\n /* Destructive utility action \u2014 neutral at rest, warns danger-red on\n hover regardless of the field's own flavor. */\n color: var(--ty-color-danger);\n background-color: var(--ty-bg-danger-soft);\n}\n.select-clear svg {\n width: 100%;\n height: 100%;\n}\n\n/* Selection text (field skin): single line, ellipsis, input colors.\n flex-basis 0, not auto \u2014 .select-stub is flex-wrap:wrap, and auto's\n hypothetical size is the FULL untruncated text width (wrap-line\n assignment happens before shrinking), which pushed fixed-size siblings\n (.select-clear) onto a second line even though the text visibly had\n room after truncating. 0 makes this item contribute ~nothing to the\n line-fit check up front; grow/shrink + overflow:hidden still truncate\n it identically. */\n.select-stub .dropdown-placeholder {\n font-style: normal;\n flex: 1 1 0%;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: var(--input-color, var(--ty-input-color));\n}\n\n.select-stub .dropdown-placeholder.placeholder-shown {\n color: var(--input-placeholder, var(--ty-input-placeholder));\n}\n.select-stub .dropdown-placeholder[hidden] {\n display: none;\n}\n\n/* Single select, closed: the picked option itself is assigned to the\n selected slot (select.ts assignSlots); it takes the text's flex slot. */\n.select-stub slot[name=\"selected\"] {\n display: none;\n}\n.select-stub.has-option slot[name=\"selected\"] {\n display: block;\n /* flex-basis 0, not auto \u2014 same reasoning as .dropdown-placeholder above:\n .select-stub is flex-wrap:wrap, and auto's hypothetical size is the\n option's full untruncated text width, which pushes .select-clear onto\n a second line. */\n flex: 1 1 0%;\n min-width: 0;\n overflow: hidden;\n}\n.select-stub.compact.has-option slot[name=\"selected\"] {\n flex: 0 1 auto;\n}\n.select-stub ::slotted(ty-option) {\n display: block;\n min-width: 0;\n overflow: hidden;\n --ty-option-hidden-display: block;\n /* Never the pointer's target: a click opens the select either way, and\n WebKit leaves :hover stuck on the trigger when the hovered option moves\n to the list on open */\n pointer-events: none;\n}\n\n/* start/end slot content (icons etc.) \u2014 spacing comes from the stub's flex\n gap; muted like ty-input adornments. end sits before the chevron. */\n.select-stub ::slotted([slot=\"start\"]),\n.select-stub ::slotted([slot=\"end\"]) {\n flex-shrink: 0;\n color: var(--ty-text-soft);\n}\n\n/* Compact skin: the text IS the trigger label \u2014 no grow, regular text color.\n flex-basis: auto (not the field skin's 0%) \u2014 content-hugging needs its\n natural content width as the starting point; 0% would collapse it since\n grow is also 0 here (nothing left to expand it back out). */\n.select-stub.compact .dropdown-placeholder {\n flex: 0 1 auto;\n color: var(--ty-text);\n}\n\n/* Trigger stays visible while the popup is open (the popup hides it) */\n.dropdown-wrapper:has(.dropdown-chevron.open) .select-stub {\n opacity: 1;\n pointer-events: auto;\n}\n\n/* One-panel popup: search header fused with the options list */\n\n/* Single unified shadow around the whole panel (header + list as one silhouette) */\n.dropdown-dialog.open {\n filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.14)) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.08));\n}\n\n/* Card-style header: the search input keeps its own bordered-field look\n (base styles) and sits inset in the panel, TagPicker-style \u2014 no divider,\n whitespace separates it from the list. The header's OWN surface/border is\n part of the floating panel's chrome, not a form field \u2014 --ty-surface-\n floating/--ty-floating-border, matching .dropdown-options below it (same\n reasoning as the base-panel fix: --ty-input-* is deliberately faint for\n resting form fields and read as a missing/mismatched edge here). */\n.dropdown-header {\n background: var(--ty-surface-floating);\n border: 1px solid var(--ty-floating-border);\n border-bottom: none;\n border-radius: var(--ty-radius-lg) var(--ty-radius-lg) 0 0;\n padding: var(--ty-spacing-2) var(--ty-spacing-2) var(--ty-spacing-1);\n}\n.dropdown-dialog.position-below .dropdown-header {\n margin-bottom: 0;\n}\n.dropdown-dialog.position-above .dropdown-header {\n margin-top: 0;\n border-top: none;\n border-bottom: 1px solid var(--ty-floating-border);\n border-radius: 0 0 var(--ty-radius-lg) var(--ty-radius-lg);\n padding: var(--ty-spacing-1) var(--ty-spacing-2) var(--ty-spacing-2);\n}\n\n/* Magnifier adornment inside the search field (header padding + field inset) */\n.dropdown-search-icon {\n position: absolute;\n top: 50%;\n left: calc(var(--ty-spacing-2) + var(--ty-spacing-3));\n transform: translateY(-50%);\n width: 1rem;\n height: 1rem;\n color: var(--input-placeholder, var(--ty-input-placeholder));\n pointer-events: none;\n}\n.dropdown-search-icon svg {\n width: 100%;\n height: 100%;\n}\n\n/* Mobile header: flex row, icon flows inline before the input. Same 32x32\n footprint as .mobile-close-button (18px glyph centered in the box, not a\n bare 18px glyph flush at the edge) so the row has two matching bookends \u2014\n a bare icon on one side and a 32px circle on the other read as lopsided\n even with equal flex gap on both sides. Matching them also centers the\n search input's flex:1 fill symmetrically between the two. Fixed white +\n 18px glyph, same reasoning as .mobile-header-label \u2014 this sits on the\n dark ::backdrop blur in both themes, not a theme surface. */\n.dropdown-mode-mobile .mobile-header-content .dropdown-search-icon {\n position: static;\n transform: none;\n flex-shrink: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n color: #ffffff;\n}\n.dropdown-mode-mobile .mobile-header-content .dropdown-search-icon svg {\n width: 18px;\n height: 18px;\n}\n\n/* Search input: bordered field from base styles; just size + icon room */\n.dropdown-search-input {\n min-height: 2.25rem;\n padding-right: var(--ty-spacing-2);\n /* room for the magnifier adornment */\n padding-left: calc(var(--ty-spacing-3) + 1rem + var(--ty-spacing-2));\n}\n/* Trigger already has a chevron - no second one inside the search row */\n.dropdown-search-chevron {\n display: none;\n}\n\n/* With the search row hidden nothing inside is focusable, so the <dialog>\n itself receives focus on open \u2014 suppress its UA focus ring */\n.dropdown-dialog:focus,\n.dropdown-dialog:focus-visible {\n outline: none;\n}\n\n/* Search row hidden ('auto' below threshold / searchable=\"false\"):\n the options panel owns the whole silhouette */\n.dropdown-header[hidden] {\n display: none;\n}\n.dropdown-header[hidden] ~ .dropdown-options-wrapper .dropdown-options {\n border-top: 1px solid var(--ty-floating-border);\n border-radius: var(--ty-radius-lg);\n}\n.mobile-search-input[hidden],\n.mobile-header-content .dropdown-search-icon[hidden] {\n display: none;\n}\n\n/* Options: vertical list rows fused under the search header.\n No own shadow/animation - the panel appears as one via dialog opacity. */\n.dropdown-options {\n flex-direction: column;\n flex-wrap: nowrap;\n align-items: stretch;\n gap: 0;\n /* Card-style list: rounded rows sit inset from the panel edges */\n padding: var(--ty-spacing-1);\n border-top: none;\n border-radius: 0 0 var(--ty-radius-lg) var(--ty-radius-lg);\n box-shadow: none;\n transform: none;\n transition: none;\n /* ~9-10 visible rows before scrolling (custom scrollbar, native hidden) */\n max-height: 24rem;\n}\n.dropdown-dialog.position-below .dropdown-options {\n box-shadow: none;\n}\n.dropdown-dialog.position-above .dropdown-options {\n border-top: 1px solid var(--ty-floating-border);\n border-bottom: none;\n border-radius: var(--ty-radius-lg) var(--ty-radius-lg) 0 0;\n}\n\n/* Loading panel continues the fused silhouette exactly like .dropdown-options \u2014\n the base layer styles it as a floating card (radius + shadow), which left a\n see-through gap under the search header while loading. */\n.dropdown-loading {\n border-top: none;\n border-radius: 0 0 var(--ty-radius-lg) var(--ty-radius-lg);\n box-shadow: none;\n}\n.dropdown-dialog.position-above .dropdown-loading {\n border-top: 1px solid var(--ty-floating-border);\n border-bottom: none;\n border-radius: var(--ty-radius-lg) var(--ty-radius-lg) 0 0;\n}\n\n/* Selection tick lives inside ty-option (lucide check on [selected]) */\n\n/* Mobile modal: same vertical list */\n.dropdown-mode-mobile .section-content ::slotted(ty-option) {\n display: block;\n width: 100%;\n}\n\n/* Options the author hid and options the search left out. Beats the display\n rule above, which beats the browser's own [hidden] { display: none }. */\n#options-slot::slotted([hidden]),\n#options-slot::slotted([filtered-out]) {\n display: none !important;\n}\n";
@@ -86,15 +86,22 @@ display: none;
86
86
  .select-stub slot[name="selected"] {
87
87
  display: none;
88
88
  }
89
- .select-stub.has-clone slot[name="selected"] {
89
+ .select-stub.has-option slot[name="selected"] {
90
90
  display: block;
91
91
  flex: 1 1 0%;
92
92
  min-width: 0;
93
93
  overflow: hidden;
94
94
  }
95
- .select-stub.compact.has-clone slot[name="selected"] {
95
+ .select-stub.compact.has-option slot[name="selected"] {
96
96
  flex: 0 1 auto;
97
97
  }
98
+ .select-stub ::slotted(ty-option) {
99
+ display: block;
100
+ min-width: 0;
101
+ overflow: hidden;
102
+ --ty-option-hidden-display: block;
103
+ pointer-events: none;
104
+ }
98
105
  .select-stub ::slotted([slot="start"]),
99
106
  .select-stub ::slotted([slot="end"]) {
100
107
  flex-shrink: 0;
@@ -215,4 +222,8 @@ border-radius: var(--ty-radius-lg) var(--ty-radius-lg) 0 0;
215
222
  display: block;
216
223
  width: 100%;
217
224
  }
225
+ #options-slot::slotted([hidden]),
226
+ #options-slot::slotted([filtered-out]) {
227
+ display: none !important;
228
+ }
218
229
  `;
@@ -16,23 +16,28 @@ ${inputStyles}
16
16
  :host {
17
17
  display: inline-flex;
18
18
  width: auto;
19
- vertical-align: middle;
19
+ height: 1.25em;
20
+ height: 1lh;
21
+ align-items: center;
22
+ vertical-align: baseline;
23
+ overflow: visible;
24
+ }
25
+ :host::before {
26
+ content: "\\200b";
27
+ width: 0;
20
28
  }
21
29
  .switch-container {
22
30
  display: inline-flex;
31
+ flex-shrink: 0;
23
32
  align-items: center;
24
- min-height: 1.25em;
25
- min-height: 1lh;
26
33
  cursor: pointer;
27
34
  user-select: none;
28
35
  outline: none;
29
- vertical-align: middle;
30
36
  }
31
37
  .switch-container.disabled {
32
38
  cursor: not-allowed;
33
39
  opacity: 0.55;
34
40
  }
35
- .switch-container:focus-visible .switch-track,
36
41
  .switch-container.focused .switch-track {
37
42
  box-shadow: 0 0 0 3px var(--ty-input-shadow-focus);
38
43
  }
package/lib/styles/tag.js CHANGED
@@ -28,7 +28,8 @@ box-shadow: 0 0 0 3px var(--ty-color-${f}-faint);
28
28
  }
29
29
  `;
30
30
  export const tagStyles = `
31
- :host([hidden]) {
31
+ :host([hidden]),
32
+ :host([filtered-out]) {
32
33
  display: none !important;
33
34
  }
34
35
  .tag-container {
@@ -95,8 +95,10 @@ export interface TyTagElement extends TyBaseElement {
95
95
  export interface TyOptionElement extends Omit<HTMLElement, 'hidden'> {
96
96
  /** Option value */
97
97
  value?: string;
98
- /** Selected state */
98
+ /** The app's mark, read by ty-select only in `external-selection` mode */
99
99
  selected?: boolean;
100
+ /** Set by the parent ty-select: draws the check and aria-selected */
101
+ checked?: boolean;
100
102
  /** Disabled state */
101
103
  disabled?: boolean;
102
104
  /** Highlighted state (keyboard navigation) */
@@ -41,6 +41,14 @@ export interface DayContext {
41
41
  /** Calendar's selected day (if any) */
42
42
  selectedDay?: number;
43
43
  }
44
+ /**
45
+ * Local midnight of a calendar day. Not the Date constructor: it reads years
46
+ * 0-99 as 1900-1999. Noon is never skipped by a clock change, so the day
47
+ * can't shift before setHours.
48
+ */
49
+ export declare function localMidnight(year: number, month: number, day: number): Date;
50
+ /** UTC midnight of a calendar day, as a timestamp. Not Date.UTC(): it reads years 0-99 as 1900-1999. */
51
+ export declare function utcMidnight(year: number, month: number, day: number): number;
44
52
  /**
45
53
  * Generate a 42-day calendar grid for a given month
46
54
  *
@@ -109,3 +117,44 @@ export declare function parseISODate(isoString: string): {
109
117
  month: number;
110
118
  day: number;
111
119
  } | null;
120
+ /**
121
+ * Date/time components in local time, as ty-date-picker holds them.
122
+ */
123
+ export interface DateTimeParts {
124
+ year?: number;
125
+ month?: number;
126
+ day?: number;
127
+ hour?: number;
128
+ minute?: number;
129
+ second?: number;
130
+ epoch?: number;
131
+ }
132
+ /** A Date whose UTC fields are these components: formats a wall-clock as written (timeZone 'UTC'). */
133
+ export declare function wallClockDate(c: DateTimeParts): Date;
134
+ /**
135
+ * Parse any date value ty-date-picker reads into local components:
136
+ * - Date only: '2024-09-21' (that calendar day)
137
+ * - Datetime-local: '2024-09-21T10:30[:45]' (local wall-clock)
138
+ * - UTC strings: '2024-09-21T08:30:00Z' or '2024-09-21T08:30:00.000Z'
139
+ * - With timezone: '2024-09-21T10:30:00+02:00'
140
+ * - Timestamps: milliseconds since epoch (a number, not a digit string)
141
+ *
142
+ * A zone-less value is taken as written, even a time the clocks skip when
143
+ * summer time starts (like <input type=datetime-local>); 2024-02-30 or 24:00
144
+ * is no value. An instant reads as its LOCAL day and time, and keeps its
145
+ * epoch.
146
+ */
147
+ export declare function parseDateTime(value: string | number | null | undefined): DateTimeParts | null;
148
+ /**
149
+ * The calendar day of any value parseDateTime reads, or a Date: an instant
150
+ * is its local day. Years outside 1-9999 (no 4-digit YYYY-MM-DD) are no day.
151
+ */
152
+ export declare function parseDateDay(value: string | number | Date | null | undefined): {
153
+ year: number;
154
+ month: number;
155
+ day: number;
156
+ } | null;
157
+ /** 'YYYY-MM-DD' of a calendar day (years below 1000 padded to 4 digits). */
158
+ export declare function formatISODay(year: number, month: number, day: number): string;
159
+ /** Any value parseDateDay reads as 'YYYY-MM-DD', or null. */
160
+ export declare function toISODay(value: string | number | Date | null | undefined): string | null;
@@ -13,8 +13,16 @@ return date1.getFullYear() === date2.getFullYear()
13
13
  && date1.getMonth() === date2.getMonth()
14
14
  && date1.getDate() === date2.getDate();
15
15
  }
16
- function createMidnightDate(year, month, day) {
17
- return new Date(year, month - 1, day, 0, 0, 0, 0);
16
+ export function localMidnight(year, month, day) {
17
+ const date = new Date(2000, 0, 1, 12);
18
+ date.setFullYear(year, month - 1, day);
19
+ date.setHours(0, 0, 0, 0);
20
+ return date;
21
+ }
22
+ export function utcMidnight(year, month, day) {
23
+ const date = new Date(0);
24
+ date.setUTCFullYear(year, month - 1, day);
25
+ return date.getTime();
18
26
  }
19
27
  function getTodayMidnight() {
20
28
  const now = new Date();
@@ -41,7 +49,7 @@ const isToday = isSameDay(date, todayMidnight);
41
49
  const isSelected = selection?.year === year
42
50
  && selection?.month === month
43
51
  && selection?.day === dayInMonth;
44
- const utcValue = Date.UTC(year, month - 1, dayInMonth, 0, 0, 0, 0);
52
+ const utcValue = utcMidnight(year, month, dayInMonth);
45
53
  const localValue = date.getTime();
46
54
  return {
47
55
  value: utcValue,
@@ -69,7 +77,7 @@ monday.setHours(0, 0, 0, 0);
69
77
  return monday;
70
78
  }
71
79
  function getMonthGridStart(year, month) {
72
- const firstDay = createMidnightDate(year, month, 1);
80
+ const firstDay = localMidnight(year, month, 1);
73
81
  return getMondayOfWeek(firstDay);
74
82
  }
75
83
  function addDays(date, days) {
@@ -120,9 +128,58 @@ if (month < 1 || month > 12)
120
128
  return null;
121
129
  if (day < 1 || day > 31)
122
130
  return null;
123
- const date = new Date(year, month - 1, day);
124
- if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) {
131
+ const date = new Date(utcMidnight(year, month, day));
132
+ if (date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day) {
125
133
  return null;
126
134
  }
127
135
  return { year, month, day };
128
136
  }
137
+ const LOCAL_VALUE = /^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?)?$/;
138
+ export function wallClockDate(c) {
139
+ const date = new Date(0);
140
+ date.setUTCFullYear(c.year, c.month - 1, c.day);
141
+ date.setUTCHours(c.hour || 0, c.minute || 0, c.second || 0);
142
+ return date;
143
+ }
144
+ export function parseDateTime(value) {
145
+ if (value === null || value === undefined || value === '')
146
+ return null;
147
+ if (typeof value === 'string') {
148
+ const local = LOCAL_VALUE.exec(value);
149
+ if (local) {
150
+ const [year, month, day, hour, minute, second] = local.slice(1, 7).map((g) => Number(g ?? 0));
151
+ const components = { year, month, day, hour, minute, second };
152
+ const check = wallClockDate(components);
153
+ const real = check.getUTCMonth() === month - 1 && check.getUTCDate() === day &&
154
+ hour < 24 && minute < 60 && second < 60;
155
+ return real ? components : null;
156
+ }
157
+ }
158
+ const dateObj = typeof value === 'number' || typeof value === 'string' ? new Date(value) : null;
159
+ if (!dateObj || isNaN(dateObj.getTime())) {
160
+ return null;
161
+ }
162
+ return {
163
+ year: dateObj.getFullYear(),
164
+ month: dateObj.getMonth() + 1,
165
+ day: dateObj.getDate(),
166
+ hour: dateObj.getHours(),
167
+ minute: dateObj.getMinutes(),
168
+ second: dateObj.getSeconds(),
169
+ epoch: dateObj.getTime(),
170
+ };
171
+ }
172
+ export function parseDateDay(value) {
173
+ const parts = parseDateTime(value instanceof Date ? value.getTime() : value);
174
+ if (!parts || parts.year < 1 || parts.year > 9999)
175
+ return null;
176
+ return { year: parts.year, month: parts.month, day: parts.day };
177
+ }
178
+ export function formatISODay(year, month, day) {
179
+ const pad = (n, w) => n.toString().padStart(w, '0');
180
+ return `${pad(year, 4)}-${pad(month, 2)}-${pad(day, 2)}`;
181
+ }
182
+ export function toISODay(value) {
183
+ const d = parseDateDay(value);
184
+ return d && formatISODay(d.year, d.month, d.day);
185
+ }
@@ -15,7 +15,6 @@ export interface PropertyConfig {
15
15
  default?: any;
16
16
  validate?: (value: any) => boolean;
17
17
  coerce?: (value: any) => any;
18
- aliases?: Record<string, any>;
19
18
  }
20
19
  /**
21
20
  * Represents a property change
@@ -88,8 +87,4 @@ export declare class PropertyManager<T = any> {
88
87
  * Check if a property should emit change events
89
88
  */
90
89
  shouldEmitChange(name: string): boolean;
91
- /**
92
- * Handle property aliases (extra attribute names mapped to a fixed value)
93
- */
94
- handleAlias(aliasName: string, value: any): PropertyChange | null;
95
90
  }
@@ -125,15 +125,4 @@ return this._config[name]?.formValue ?? false;
125
125
  shouldEmitChange(name) {
126
126
  return this._config[name]?.emitChange ?? false;
127
127
  }
128
- handleAlias(aliasName, value) {
129
- for (const [propName, config] of Object.entries(this._config)) {
130
- if (config.aliases && aliasName in config.aliases) {
131
- if (value === null)
132
- return this.updateProperty(propName, defaultOf(config), 'attribute');
133
- const aliasedValue = config.aliases[aliasName];
134
- return this.updateProperty(propName, aliasedValue, 'attribute');
135
- }
136
- }
137
- return null;
138
- }
139
128
  }
@@ -1,9 +1,15 @@
1
1
  /**
2
- * CSS-based scroll prevention.
2
+ * Page scroll lock, reference-counted so multiple components can lock at once.
3
3
  *
4
- * Prevents page scrolling via CSS rather than event cancellation — no event
5
- * manipulation, no interference with component keyboard navigation, scroll
6
- * position preserved. Reference-counted so multiple components can lock at once.
4
+ * Two parts: overflow: hidden on <html> (the document scroller), and a guard
5
+ * for apps that scroll their own container (a full-height layout with an
6
+ * inner overflow: auto div), which <html> overflow doesn't reach. The guard
7
+ * cancels wheel, touchmove and scroll keys that would scroll anything outside
8
+ * the open dialog they come from (every lock holder is a top-layer <dialog>):
9
+ * scrollers inside the dialog keep working until their edge, nothing chains
10
+ * out of it, and events from the page behind scroll nothing. Keys a control
11
+ * uses itself (text fields, selects, Space on buttons, arrows in widgets) are
12
+ * left alone.
7
13
  */
8
14
  declare global {
9
15
  interface Window {
@@ -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) {