@jsenv/dom 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/jsenv_dom.js +259 -314
  2. package/package.json +2 -4
  3. package/index.js +0 -124
  4. package/src/attr/add_attribute_effect.js +0 -93
  5. package/src/attr/attributes.js +0 -32
  6. package/src/color/color_constrast.js +0 -69
  7. package/src/color/color_parsing.js +0 -319
  8. package/src/color/color_scheme.js +0 -28
  9. package/src/color/pick_light_or_dark.js +0 -34
  10. package/src/color/resolve_css_color.js +0 -60
  11. package/src/demos/3_columns_resize_demo.html +0 -84
  12. package/src/demos/3_rows_resize_demo.html +0 -89
  13. package/src/demos/aside_and_main_demo.html +0 -93
  14. package/src/demos/coordinates_demo.html +0 -450
  15. package/src/demos/document_autoscroll_demo.html +0 -517
  16. package/src/demos/drag_gesture_constraints_demo.html +0 -701
  17. package/src/demos/drag_gesture_demo.html +0 -1047
  18. package/src/demos/drag_gesture_element_to_impact_demo.html +0 -445
  19. package/src/demos/drag_reference_element_demo.html +0 -480
  20. package/src/demos/flex_details_set_demo.html +0 -302
  21. package/src/demos/flex_details_set_demo_2.html +0 -315
  22. package/src/demos/visible_rect_demo.html +0 -525
  23. package/src/element_signature.js +0 -100
  24. package/src/interaction/drag/constraint_feedback_line.js +0 -92
  25. package/src/interaction/drag/drag_constraint.js +0 -659
  26. package/src/interaction/drag/drag_debug_markers.js +0 -635
  27. package/src/interaction/drag/drag_element_positioner.js +0 -382
  28. package/src/interaction/drag/drag_gesture.js +0 -566
  29. package/src/interaction/drag/drag_resize_demo.html +0 -571
  30. package/src/interaction/drag/drag_to_move.js +0 -301
  31. package/src/interaction/drag/drag_to_resize_gesture.js +0 -68
  32. package/src/interaction/drag/drop_target_detection.js +0 -148
  33. package/src/interaction/drag/sticky_frontiers.js +0 -160
  34. package/src/interaction/event_marker.js +0 -14
  35. package/src/interaction/focus/active_element.js +0 -33
  36. package/src/interaction/focus/arrow_navigation.js +0 -599
  37. package/src/interaction/focus/element_is_focusable.js +0 -57
  38. package/src/interaction/focus/element_visibility.js +0 -111
  39. package/src/interaction/focus/find_focusable.js +0 -21
  40. package/src/interaction/focus/focus_group.js +0 -91
  41. package/src/interaction/focus/focus_group_registry.js +0 -12
  42. package/src/interaction/focus/focus_nav.js +0 -12
  43. package/src/interaction/focus/focus_nav_event_marker.js +0 -14
  44. package/src/interaction/focus/focus_trap.js +0 -105
  45. package/src/interaction/focus/tab_navigation.js +0 -128
  46. package/src/interaction/focus/tests/focus_group_skip_tab_test.html +0 -206
  47. package/src/interaction/focus/tests/tree_focus_test.html +0 -304
  48. package/src/interaction/focus/tests/tree_focus_test.jsx +0 -261
  49. package/src/interaction/focus/tests/tree_focus_test_preact.html +0 -13
  50. package/src/interaction/isolate_interactions.js +0 -161
  51. package/src/interaction/keyboard.js +0 -26
  52. package/src/interaction/scroll/capture_scroll.js +0 -47
  53. package/src/interaction/scroll/is_scrollable.js +0 -159
  54. package/src/interaction/scroll/scroll_container.js +0 -110
  55. package/src/interaction/scroll/scroll_trap.js +0 -44
  56. package/src/interaction/scroll/scrollbar_size.js +0 -20
  57. package/src/interaction/scroll/wheel_through.js +0 -138
  58. package/src/iterable_weak_set.js +0 -66
  59. package/src/position/dom_coords.js +0 -340
  60. package/src/position/offset_parent.js +0 -15
  61. package/src/position/position_fixed.js +0 -15
  62. package/src/position/position_sticky.js +0 -213
  63. package/src/position/sticky_rect.js +0 -79
  64. package/src/position/visible_rect.js +0 -486
  65. package/src/pub_sub.js +0 -31
  66. package/src/size/can_take_size.js +0 -11
  67. package/src/size/details_content_full_height.js +0 -63
  68. package/src/size/flex_details_set.js +0 -974
  69. package/src/size/get_available_height.js +0 -22
  70. package/src/size/get_available_width.js +0 -22
  71. package/src/size/get_border_sizes.js +0 -14
  72. package/src/size/get_height.js +0 -4
  73. package/src/size/get_inner_height.js +0 -15
  74. package/src/size/get_inner_width.js +0 -15
  75. package/src/size/get_margin_sizes.js +0 -10
  76. package/src/size/get_max_height.js +0 -57
  77. package/src/size/get_max_width.js +0 -47
  78. package/src/size/get_min_height.js +0 -14
  79. package/src/size/get_min_width.js +0 -14
  80. package/src/size/get_padding_sizes.js +0 -10
  81. package/src/size/get_width.js +0 -4
  82. package/src/size/hooks/use_available_height.js +0 -27
  83. package/src/size/hooks/use_available_width.js +0 -27
  84. package/src/size/hooks/use_max_height.js +0 -10
  85. package/src/size/hooks/use_max_width.js +0 -10
  86. package/src/size/hooks/use_resize_status.js +0 -62
  87. package/src/size/resize.js +0 -695
  88. package/src/size/resolve_css_size.js +0 -32
  89. package/src/style/dom_styles.js +0 -97
  90. package/src/style/style_composition.js +0 -121
  91. package/src/style/style_controller.js +0 -345
  92. package/src/style/style_default.js +0 -153
  93. package/src/style/style_default_demo.html +0 -128
  94. package/src/style/style_parsing.js +0 -375
  95. package/src/transition/demos/animation_resumption_test.xhtml +0 -500
  96. package/src/transition/demos/height_toggle_test.xhtml +0 -515
  97. package/src/transition/dom_transition.js +0 -254
  98. package/src/transition/easing.js +0 -48
  99. package/src/transition/group_transition.js +0 -261
  100. package/src/transition/transform_style_parser.js +0 -32
  101. package/src/transition/transition_playback.js +0 -366
  102. package/src/transition/transition_timeline.js +0 -79
  103. package/src/traversal.js +0 -247
  104. package/src/ui_transition/demos/content_states_transition_demo.html +0 -628
  105. package/src/ui_transition/demos/smooth_height_transition_demo.html +0 -149
  106. package/src/ui_transition/demos/transition_testing.html +0 -354
  107. package/src/ui_transition/ui_transition.js +0 -1470
  108. package/src/utils.js +0 -69
  109. package/src/value_effect.js +0 -35
@@ -1,213 +0,0 @@
1
- /**
2
- * Position Sticky Polyfill
3
- *
4
- * This module provides a workaround for position:sticky limitations when used with
5
- * overflow:auto/hidden parent elements (see https://github.com/w3c/csswg-drafts/issues/865).
6
- *
7
- * How it works:
8
- * 1. Creates a placeholder clone of the sticky element to maintain document flow
9
- * 2. Positions the real element using fixed positioning relative to viewport
10
- * 3. Adjusts position on scroll to emulate position:sticky behavior
11
- * 4. Handles parent boundary detection to keep element within its container
12
- * 5. Updates dimensions on resize and DOM changes
13
- *
14
- * Usage:
15
- * ```
16
- * const cleanup = initPositionSticky(element);
17
- * // Later when no longer needed
18
- * cleanup();
19
- * ```
20
- *
21
- * The element should have a CSS "top" value specified (e.g., top: 10px).
22
- */
23
-
24
- import { getScrollContainerSet } from "../interaction/scroll/scroll_container.js";
25
- import { getHeight } from "../size/get_height.js";
26
- import { getWidth } from "../size/get_width.js";
27
- import { forceStyles, setStyles } from "../style/dom_styles.js";
28
-
29
- import.meta.css = /* css */ `
30
- [data-position-sticky-placeholder] {
31
- opacity: 0 !important;
32
- position: static !important;
33
- width: auto !important;
34
- height: auto !important;
35
- }
36
- `;
37
-
38
- export const initPositionSticky = (element) => {
39
- const computedStyle = getComputedStyle(element);
40
- const topCssValue = computedStyle.top;
41
- const top = parseFloat(topCssValue);
42
- if (isNaN(top)) {
43
- return () => {}; // Early return if no valid top value
44
- }
45
-
46
- // Skip polyfill if native position:sticky would work (no overflow:auto/hidden parents)
47
- const scrollContainerSet = getScrollContainerSet(element);
48
- check_overflow_on_containers: {
49
- let hasOverflowHiddenOrAuto = false;
50
- for (const scrollContainer of scrollContainerSet) {
51
- const scrollContainerComputedStyle = getComputedStyle(scrollContainer);
52
- const overflowX = scrollContainerComputedStyle.overflowX;
53
- if (overflowX === "auto" || overflowX === "hidden") {
54
- hasOverflowHiddenOrAuto = true;
55
- break;
56
- }
57
- const overflowY = scrollContainerComputedStyle.overflowY;
58
- if (overflowY === "auto" || overflowY === "hidden") {
59
- hasOverflowHiddenOrAuto = true;
60
- break;
61
- }
62
- }
63
- if (!hasOverflowHiddenOrAuto) {
64
- return () => {}; // Native sticky will work fine
65
- }
66
- }
67
-
68
- const cleanupCallbackSet = new Set();
69
- const cleanup = () => {
70
- for (const cleanupCallback of cleanupCallbackSet) {
71
- cleanupCallback();
72
- }
73
- cleanupCallbackSet.clear();
74
- };
75
-
76
- const parentElement = element.parentElement;
77
- const createPlaceholderClone = () => {
78
- const clone = element.cloneNode(true);
79
- clone.setAttribute("data-position-sticky-placeholder", "");
80
- clone.removeAttribute("data-sticky");
81
- return clone;
82
- };
83
-
84
- let placeholder = createPlaceholderClone();
85
- parentElement.insertBefore(placeholder, element);
86
- cleanupCallbackSet.add(() => {
87
- placeholder.remove();
88
- });
89
-
90
- let width = getWidth(element);
91
- let height = getHeight(element);
92
-
93
- const updateSize = () => {
94
- const newPlaceholder = createPlaceholderClone();
95
- parentElement.replaceChild(newPlaceholder, placeholder);
96
- placeholder = newPlaceholder;
97
- width = getWidth(placeholder);
98
- height = getHeight(placeholder);
99
- updatePosition();
100
- };
101
-
102
- const updatePosition = () => {
103
- // Ensure placeholder dimensions match element
104
- setStyles(placeholder, {
105
- width: `${width}px`,
106
- height: `${height}px`,
107
- });
108
-
109
- const placeholderRect = placeholder.getBoundingClientRect();
110
- const parentRect = parentElement.getBoundingClientRect();
111
-
112
- // Calculate left position in viewport coordinates (fixed positioning)
113
- const leftPosition = placeholderRect.left;
114
- element.style.left = `${Math.round(leftPosition)}px`;
115
-
116
- // Determine if element should be sticky or at its natural position
117
- let topPosition;
118
- let isStuck = false;
119
-
120
- // Check if we need to stick the element
121
- if (placeholderRect.top <= top) {
122
- // Element should be stuck at "top" position in the viewport
123
- topPosition = top;
124
- isStuck = true;
125
-
126
- // But make sure it doesn't go beyond parent's bottom boundary
127
- const parentBottom = parentRect.bottom;
128
- const elementBottom = top + height;
129
-
130
- if (elementBottom > parentBottom) {
131
- // Adjust to stay within parent
132
- topPosition = parentBottom - height;
133
- }
134
- } else {
135
- // Element should be at its natural position in the flow
136
- topPosition = placeholderRect.top;
137
- }
138
-
139
- element.style.top = `${topPosition}px`;
140
- element.style.width = `${width}px`;
141
- element.style.height = `${height}px`;
142
-
143
- // Set attribute for potential styling
144
- if (isStuck) {
145
- element.setAttribute("data-sticky", "");
146
- } else {
147
- element.removeAttribute("data-sticky");
148
- }
149
- };
150
-
151
- element_is_fixed: {
152
- const restorePositionStyle = forceStyles(element, {
153
- "position": "fixed",
154
- "z-index": 1,
155
- "will-change": "transform", // Hint for hardware acceleration
156
- });
157
- cleanupCallbackSet.add(restorePositionStyle);
158
- }
159
-
160
- updatePosition();
161
-
162
- update_on_scroll: {
163
- const handleScroll = () => {
164
- updatePosition();
165
- };
166
-
167
- for (const scrollContainer of scrollContainerSet) {
168
- scrollContainer.addEventListener("scroll", handleScroll, {
169
- passive: true,
170
- });
171
- cleanupCallbackSet.add(() => {
172
- scrollContainer.removeEventListener("scroll", handleScroll, {
173
- passive: true,
174
- });
175
- });
176
- }
177
- }
178
-
179
- update_on_parent_size_change: {
180
- let animationFrame = null;
181
- const resizeObserver = new ResizeObserver(() => {
182
- if (animationFrame !== null) {
183
- return;
184
- }
185
- animationFrame = requestAnimationFrame(() => {
186
- animationFrame = null;
187
- updateSize();
188
- });
189
- });
190
- resizeObserver.observe(parentElement);
191
- cleanupCallbackSet.add(() => {
192
- resizeObserver.disconnect();
193
- cancelAnimationFrame(animationFrame);
194
- animationFrame = null;
195
- });
196
- }
197
-
198
- update_on_dom_mutation: {
199
- const mutationObserver = new MutationObserver(() => {
200
- updateSize();
201
- });
202
- mutationObserver.observe(element, {
203
- childList: true,
204
- subtree: true,
205
- characterData: true,
206
- });
207
- cleanupCallbackSet.add(() => {
208
- mutationObserver.disconnect();
209
- });
210
- }
211
-
212
- return cleanup;
213
- };
@@ -1,79 +0,0 @@
1
- import { getScrollContainer } from "../interaction/scroll/scroll_container.js";
2
-
3
- export const stickyAsRelativeCoords = (
4
- element,
5
- referenceElement,
6
- { scrollContainer = getScrollContainer(element) } = {},
7
- ) => {
8
- const hasStickyLeftAttribute = element.hasAttribute("data-sticky-left");
9
- const hasTopStickyAttribute = element.hasAttribute("data-sticky-top");
10
- if (!hasStickyLeftAttribute && !hasTopStickyAttribute) {
11
- return null;
12
- }
13
- const elementRect = element.getBoundingClientRect();
14
- const referenceElementRect = referenceElement.getBoundingClientRect();
15
- const computedStyle = getComputedStyle(element);
16
- const isDocumentScrolling = scrollContainer === document.documentElement;
17
-
18
- let leftPosition;
19
- let topPosition;
20
- if (isDocumentScrolling) {
21
- // For document scrolling: check if element is currently stuck and calculate offset
22
-
23
- if (hasStickyLeftAttribute) {
24
- const cssLeftValue = parseFloat(computedStyle.left) || 0;
25
- const isStuckLeft = elementRect.left <= cssLeftValue;
26
- if (isStuckLeft) {
27
- const elementOffsetRelative =
28
- elementRect.left - referenceElementRect.left;
29
- leftPosition = elementOffsetRelative - cssLeftValue;
30
- } else {
31
- leftPosition = 0;
32
- }
33
- }
34
- if (hasTopStickyAttribute) {
35
- const cssTopValue = parseFloat(computedStyle.top) || 0;
36
- const isStuckTop = elementRect.top <= cssTopValue;
37
- if (isStuckTop) {
38
- const elementOffsetRelative =
39
- elementRect.top - referenceElementRect.top;
40
- topPosition = elementOffsetRelative - cssTopValue;
41
- } else {
42
- topPosition = 0;
43
- }
44
- }
45
- return [leftPosition, topPosition];
46
- }
47
-
48
- // For container scrolling: check if element is currently stuck and calculate offset
49
- const scrollContainerRect = scrollContainer.getBoundingClientRect();
50
- if (hasStickyLeftAttribute) {
51
- const cssLeftValue = parseFloat(computedStyle.left) || 0;
52
- // Check if element is stuck to the left edge of the scrollable container
53
- const isStuckLeft =
54
- elementRect.left <= scrollContainerRect.left + cssLeftValue;
55
- if (isStuckLeft) {
56
- // Element is stuck - calculate its offset relative to reference element
57
- const elementOffsetRelative =
58
- elementRect.left - referenceElementRect.left;
59
- leftPosition = elementOffsetRelative - cssLeftValue;
60
- } else {
61
- // Element is not stuck - behaves like position: relative with no offset
62
- leftPosition = 0;
63
- }
64
- }
65
- if (hasTopStickyAttribute) {
66
- const cssTopValue = parseFloat(computedStyle.top) || 0;
67
- // Check if element is stuck to the top edge of the scrollable container
68
- const isStuckTop = elementRect.top <= scrollContainerRect.top + cssTopValue;
69
- if (isStuckTop) {
70
- // Element is stuck - calculate its offset relative to reference element
71
- const elementOffsetRelative = elementRect.top - referenceElementRect.top;
72
- topPosition = elementOffsetRelative - cssTopValue;
73
- } else {
74
- // Element is not stuck - behaves like position: relative with no offset
75
- topPosition = 0;
76
- }
77
- }
78
- return [leftPosition, topPosition];
79
- };