@stimulus-plumbers/controllers 0.2.9 → 0.3.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.
@@ -1,101 +0,0 @@
1
- export const visibilityConfig = {
2
- get visibleOnly() {
3
- return true;
4
- },
5
- hiddenClass: null,
6
- };
7
-
8
- /**
9
- * Maps each direction to its opposite direction.
10
- * Used for flipping and boundary calculations.
11
- */
12
- export const directionMap = {
13
- get top() {
14
- return 'bottom';
15
- },
16
- get bottom() {
17
- return 'top';
18
- },
19
- get left() {
20
- return 'right';
21
- },
22
- get right() {
23
- return 'left';
24
- },
25
- };
26
-
27
- /**
28
- * Creates a rect object with position and dimension properties.
29
- * @param {Object} params - Rectangle parameters
30
- * @param {number} params.x - X coordinate
31
- * @param {number} params.y - Y coordinate
32
- * @param {number} params.width - Width
33
- * @param {number} params.height - Height
34
- * @returns {Object} Rect object with x, y, width, height, left, right, top, bottom properties
35
- */
36
- export function defineRect({ x, y, width, height }) {
37
- return {
38
- x: x,
39
- y: y,
40
- width: width,
41
- height: height,
42
- left: x,
43
- right: x + width,
44
- top: y,
45
- bottom: y + height,
46
- };
47
- }
48
-
49
- /**
50
- * Returns the current viewport dimensions as a rect object.
51
- * @returns {Object} Viewport rect with dimensions and boundaries
52
- */
53
- export function viewportRect() {
54
- return defineRect({
55
- x: 0,
56
- y: 0,
57
- width: window.innerWidth || document.documentElement.clientWidth,
58
- height: window.innerHeight || document.documentElement.clientHeight,
59
- });
60
- }
61
-
62
- /**
63
- * Checks if an element is within the visible viewport.
64
- * @param {HTMLElement} target - Element to check
65
- * @returns {boolean} True if element is within viewport
66
- */
67
- export function isWithinViewport(target) {
68
- if (!(target instanceof HTMLElement)) return false;
69
-
70
- const outer = viewportRect();
71
- const inner = target.getBoundingClientRect();
72
- const vertical = inner.top <= outer.height && inner.top + inner.height > 0;
73
- const horizontal = inner.left <= outer.width && inner.left + inner.width > 0;
74
- return vertical && horizontal;
75
- }
76
-
77
- /**
78
- * Validates if a value is a valid Date object.
79
- * @param {*} value - Value to check
80
- * @returns {boolean} True if value is a valid Date
81
- */
82
- export function isValidDate(value) {
83
- return value instanceof Date && !isNaN(value);
84
- }
85
-
86
- /**
87
- * Attempts to parse values into a Date object.
88
- * @param {...*} values - Date values to parse
89
- * @returns {Date|undefined} Parsed Date object or undefined if invalid
90
- * @throws {string} If no values provided
91
- */
92
- export function tryParseDate(...values) {
93
- if (values.length === 0) throw 'Missing values to parse as date';
94
- if (values.length === 1) {
95
- const parsed = new Date(values[0]);
96
- if (values[0] && isValidDate(parsed)) return parsed;
97
- } else {
98
- const parsed = new Date(...values);
99
- if (isValidDate(parsed)) return parsed;
100
- }
101
- }
File without changes
File without changes
File without changes