mtrl-addons 0.2.2 → 0.2.4

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 (129) hide show
  1. package/{src/components/index.ts → dist/components/index.d.ts} +0 -2
  2. package/dist/components/vlist/config.d.ts +86 -0
  3. package/{src/components/vlist/constants.ts → dist/components/vlist/constants.d.ts} +10 -11
  4. package/dist/components/vlist/features/api.d.ts +7 -0
  5. package/{src/components/vlist/features/index.ts → dist/components/vlist/features/index.d.ts} +0 -2
  6. package/dist/components/vlist/features/selection.d.ts +6 -0
  7. package/dist/components/vlist/features/viewport.d.ts +9 -0
  8. package/dist/components/vlist/features.d.ts +31 -0
  9. package/{src/components/vlist/index.ts → dist/components/vlist/index.d.ts} +1 -10
  10. package/dist/components/vlist/types.d.ts +596 -0
  11. package/dist/components/vlist/vlist.d.ts +29 -0
  12. package/dist/core/compose/features/gestures/index.d.ts +86 -0
  13. package/dist/core/compose/features/gestures/longpress.d.ts +85 -0
  14. package/dist/core/compose/features/gestures/pan.d.ts +108 -0
  15. package/dist/core/compose/features/gestures/pinch.d.ts +111 -0
  16. package/dist/core/compose/features/gestures/rotate.d.ts +111 -0
  17. package/dist/core/compose/features/gestures/swipe.d.ts +149 -0
  18. package/dist/core/compose/features/gestures/tap.d.ts +79 -0
  19. package/{src/core/compose/features/index.ts → dist/core/compose/features/index.d.ts} +1 -2
  20. package/{src/core/compose/index.ts → dist/core/compose/index.d.ts} +2 -11
  21. package/{src/core/gestures/index.ts → dist/core/gestures/index.d.ts} +1 -20
  22. package/dist/core/gestures/longpress.d.ts +23 -0
  23. package/dist/core/gestures/manager.d.ts +14 -0
  24. package/dist/core/gestures/pan.d.ts +12 -0
  25. package/dist/core/gestures/pinch.d.ts +14 -0
  26. package/dist/core/gestures/rotate.d.ts +14 -0
  27. package/dist/core/gestures/swipe.d.ts +20 -0
  28. package/dist/core/gestures/tap.d.ts +12 -0
  29. package/dist/core/gestures/types.d.ts +320 -0
  30. package/dist/core/gestures/utils.d.ts +57 -0
  31. package/dist/core/index.d.ts +13 -0
  32. package/dist/core/layout/config.d.ts +33 -0
  33. package/dist/core/layout/index.d.ts +51 -0
  34. package/dist/core/layout/jsx.d.ts +65 -0
  35. package/dist/core/layout/schema.d.ts +112 -0
  36. package/dist/core/layout/types.d.ts +69 -0
  37. package/dist/core/viewport/constants.d.ts +105 -0
  38. package/dist/core/viewport/features/base.d.ts +14 -0
  39. package/dist/core/viewport/features/collection.d.ts +41 -0
  40. package/dist/core/viewport/features/events.d.ts +13 -0
  41. package/{src/core/viewport/features/index.ts → dist/core/viewport/features/index.d.ts} +0 -7
  42. package/dist/core/viewport/features/item-size.d.ts +30 -0
  43. package/dist/core/viewport/features/loading.d.ts +34 -0
  44. package/dist/core/viewport/features/momentum.d.ts +17 -0
  45. package/dist/core/viewport/features/performance.d.ts +53 -0
  46. package/dist/core/viewport/features/placeholders.d.ts +38 -0
  47. package/dist/core/viewport/features/rendering.d.ts +16 -0
  48. package/dist/core/viewport/features/scrollbar.d.ts +26 -0
  49. package/dist/core/viewport/features/scrolling.d.ts +16 -0
  50. package/dist/core/viewport/features/utils.d.ts +43 -0
  51. package/dist/core/viewport/features/virtual.d.ts +18 -0
  52. package/{src/core/viewport/index.ts → dist/core/viewport/index.d.ts} +1 -17
  53. package/dist/core/viewport/types.d.ts +96 -0
  54. package/dist/core/viewport/utils/speed-tracker.d.ts +22 -0
  55. package/dist/core/viewport/viewport.d.ts +11 -0
  56. package/{src/index.ts → dist/index.d.ts} +0 -4
  57. package/dist/index.js +5143 -0
  58. package/dist/index.mjs +5111 -0
  59. package/dist/styles.css +254 -0
  60. package/dist/styles.css.map +1 -0
  61. package/package.json +16 -2
  62. package/.cursorrules +0 -117
  63. package/AI.md +0 -39
  64. package/CLAUDE.md +0 -882
  65. package/build.js +0 -377
  66. package/index.ts +0 -7
  67. package/scripts/analyze-orphaned-functions.ts +0 -387
  68. package/scripts/debug/vlist-selection.ts +0 -121
  69. package/src/components/vlist/config.ts +0 -323
  70. package/src/components/vlist/features/api.ts +0 -626
  71. package/src/components/vlist/features/selection.ts +0 -436
  72. package/src/components/vlist/features/viewport.ts +0 -59
  73. package/src/components/vlist/features.ts +0 -112
  74. package/src/components/vlist/types.ts +0 -723
  75. package/src/components/vlist/vlist.ts +0 -92
  76. package/src/core/compose/features/gestures/index.ts +0 -227
  77. package/src/core/compose/features/gestures/longpress.ts +0 -383
  78. package/src/core/compose/features/gestures/pan.ts +0 -424
  79. package/src/core/compose/features/gestures/pinch.ts +0 -475
  80. package/src/core/compose/features/gestures/rotate.ts +0 -485
  81. package/src/core/compose/features/gestures/swipe.ts +0 -492
  82. package/src/core/compose/features/gestures/tap.ts +0 -334
  83. package/src/core/gestures/longpress.ts +0 -68
  84. package/src/core/gestures/manager.ts +0 -418
  85. package/src/core/gestures/pan.ts +0 -48
  86. package/src/core/gestures/pinch.ts +0 -58
  87. package/src/core/gestures/rotate.ts +0 -58
  88. package/src/core/gestures/swipe.ts +0 -66
  89. package/src/core/gestures/tap.ts +0 -45
  90. package/src/core/gestures/types.ts +0 -387
  91. package/src/core/gestures/utils.ts +0 -128
  92. package/src/core/index.ts +0 -43
  93. package/src/core/layout/config.ts +0 -102
  94. package/src/core/layout/index.ts +0 -168
  95. package/src/core/layout/jsx.ts +0 -174
  96. package/src/core/layout/schema.ts +0 -1044
  97. package/src/core/layout/types.ts +0 -95
  98. package/src/core/viewport/constants.ts +0 -145
  99. package/src/core/viewport/features/base.ts +0 -73
  100. package/src/core/viewport/features/collection.ts +0 -1182
  101. package/src/core/viewport/features/events.ts +0 -130
  102. package/src/core/viewport/features/item-size.ts +0 -271
  103. package/src/core/viewport/features/loading.ts +0 -263
  104. package/src/core/viewport/features/momentum.ts +0 -269
  105. package/src/core/viewport/features/performance.ts +0 -161
  106. package/src/core/viewport/features/placeholders.ts +0 -335
  107. package/src/core/viewport/features/rendering.ts +0 -962
  108. package/src/core/viewport/features/scrollbar.ts +0 -434
  109. package/src/core/viewport/features/scrolling.ts +0 -634
  110. package/src/core/viewport/features/utils.ts +0 -94
  111. package/src/core/viewport/features/virtual.ts +0 -525
  112. package/src/core/viewport/types.ts +0 -133
  113. package/src/core/viewport/utils/speed-tracker.ts +0 -79
  114. package/src/core/viewport/viewport.ts +0 -265
  115. package/test/benchmarks/layout/advanced.test.ts +0 -656
  116. package/test/benchmarks/layout/comparison.test.ts +0 -519
  117. package/test/benchmarks/layout/performance-comparison.test.ts +0 -274
  118. package/test/benchmarks/layout/real-components.test.ts +0 -733
  119. package/test/benchmarks/layout/simple.test.ts +0 -321
  120. package/test/benchmarks/layout/stress.test.ts +0 -990
  121. package/test/collection/basic.test.ts +0 -304
  122. package/test/components/vlist-selection.test.ts +0 -240
  123. package/test/components/vlist.test.ts +0 -63
  124. package/test/core/collection/adapter.test.ts +0 -161
  125. package/test/core/collection/collection.test.ts +0 -394
  126. package/test/core/layout/layout.test.ts +0 -201
  127. package/test/utils/dom-helpers.ts +0 -275
  128. package/test/utils/performance-helpers.ts +0 -392
  129. package/tsconfig.json +0 -20
@@ -1,387 +0,0 @@
1
- // src/core/gestures/types.ts
2
- /**
3
- * @module core/gestures
4
- * @description Type definitions for the gesture system
5
- */
6
-
7
- /**
8
- * Types of gestures supported by the system
9
- */
10
- export enum GESTURE_TYPES {
11
- TAP = 'tap',
12
- SWIPE = 'swipe',
13
- SWIPE_LEFT = 'swipeleft',
14
- SWIPE_RIGHT = 'swiperight',
15
- SWIPE_UP = 'swipeup',
16
- SWIPE_DOWN = 'swipedown',
17
- PINCH = 'pinch',
18
- ROTATE = 'rotate',
19
- LONG_PRESS = 'longpress',
20
- PAN = 'pan'
21
- }
22
-
23
- /**
24
- * Direction of swipe gestures
25
- */
26
- export enum SWIPE_DIRECTIONS {
27
- UP = 'up',
28
- DOWN = 'down',
29
- LEFT = 'left',
30
- RIGHT = 'right'
31
- }
32
-
33
- /**
34
- * Configuration options for gesture recognition
35
- */
36
- export interface GestureConfig {
37
- /**
38
- * Minimum distance (in pixels) to recognize a swipe
39
- * @default 30
40
- */
41
- swipeThreshold?: number;
42
-
43
- /**
44
- * Maximum time (in ms) in which a swipe must be completed
45
- * @default 300
46
- */
47
- swipeTimeThreshold?: number;
48
-
49
- /**
50
- * Time (in ms) to recognize a long press
51
- * @default 500
52
- */
53
- longPressTime?: number;
54
-
55
- /**
56
- * Distance threshold (in pixels) for tap recognition
57
- * @default 10
58
- */
59
- tapDistanceThreshold?: number;
60
-
61
- /**
62
- * Whether to prevent default behaviors on touch events
63
- * @default true
64
- */
65
- preventDefault?: boolean;
66
-
67
- /**
68
- * Whether to stop event propagation
69
- * @default false
70
- */
71
- stopPropagation?: boolean;
72
-
73
- [key: string]: any;
74
- }
75
-
76
- /**
77
- * Base gesture event data
78
- */
79
- export interface GestureEvent {
80
- /**
81
- * Type of the gesture
82
- */
83
- type: string;
84
-
85
- /**
86
- * Original DOM event
87
- */
88
- originalEvent: Event;
89
-
90
- /**
91
- * Element the gesture was triggered on
92
- */
93
- target: EventTarget;
94
-
95
- /**
96
- * Timestamp when the gesture started
97
- */
98
- startTime: number;
99
-
100
- /**
101
- * Timestamp when the gesture ended
102
- */
103
- endTime: number;
104
-
105
- /**
106
- * Gesture duration in milliseconds
107
- */
108
- duration: number;
109
-
110
- /**
111
- * Whether default behavior was prevented
112
- */
113
- defaultPrevented: boolean;
114
-
115
- /**
116
- * Prevent default behavior
117
- */
118
- preventDefault: () => void;
119
-
120
- /**
121
- * Stop event propagation
122
- */
123
- stopPropagation: () => void;
124
- }
125
-
126
- /**
127
- * Tap gesture event data
128
- */
129
- export interface TapEvent extends GestureEvent {
130
- type: 'tap';
131
-
132
- /**
133
- * Number of taps (for double tap detection)
134
- */
135
- count: number;
136
-
137
- /**
138
- * X position of the tap
139
- */
140
- x: number;
141
-
142
- /**
143
- * Y position of the tap
144
- */
145
- y: number;
146
- }
147
-
148
- /**
149
- * Swipe gesture event data
150
- */
151
- export interface SwipeEvent extends GestureEvent {
152
- type: 'swipe' | 'swipeleft' | 'swiperight' | 'swipeup' | 'swipedown';
153
-
154
- /**
155
- * Direction of the swipe
156
- */
157
- direction: 'up' | 'down' | 'left' | 'right';
158
-
159
- /**
160
- * Distance swiped in the X direction
161
- */
162
- deltaX: number;
163
-
164
- /**
165
- * Distance swiped in the Y direction
166
- */
167
- deltaY: number;
168
-
169
- /**
170
- * Total distance swiped
171
- */
172
- distance: number;
173
-
174
- /**
175
- * Velocity of the swipe in pixels per millisecond
176
- */
177
- velocity: number;
178
-
179
- /**
180
- * Start X position
181
- */
182
- startX: number;
183
-
184
- /**
185
- * Start Y position
186
- */
187
- startY: number;
188
-
189
- /**
190
- * End X position
191
- */
192
- endX: number;
193
-
194
- /**
195
- * End Y position
196
- */
197
- endY: number;
198
- }
199
-
200
- /**
201
- * Long press gesture event data
202
- */
203
- export interface LongPressEvent extends GestureEvent {
204
- type: 'longpress';
205
-
206
- /**
207
- * X position of the long press
208
- */
209
- x: number;
210
-
211
- /**
212
- * Y position of the long press
213
- */
214
- y: number;
215
- }
216
-
217
- /**
218
- * Pinch gesture event data
219
- */
220
- export interface PinchEvent extends GestureEvent {
221
- type: 'pinch';
222
-
223
- /**
224
- * Scale factor of the pinch (>1 for zoom in, <1 for zoom out)
225
- */
226
- scale: number;
227
-
228
- /**
229
- * Center X position of the pinch
230
- */
231
- centerX: number;
232
-
233
- /**
234
- * Center Y position of the pinch
235
- */
236
- centerY: number;
237
- }
238
-
239
- /**
240
- * Rotate gesture event data
241
- */
242
- export interface RotateEvent extends GestureEvent {
243
- type: 'rotate';
244
-
245
- /**
246
- * Rotation angle in degrees
247
- */
248
- rotation: number;
249
-
250
- /**
251
- * Center X position of the rotation
252
- */
253
- centerX: number;
254
-
255
- /**
256
- * Center Y position of the rotation
257
- */
258
- centerY: number;
259
- }
260
-
261
- /**
262
- * Pan gesture event data
263
- */
264
- export interface PanEvent extends GestureEvent {
265
- type: 'pan';
266
-
267
- /**
268
- * Distance panned in the X direction
269
- */
270
- deltaX: number;
271
-
272
- /**
273
- * Distance panned in the Y direction
274
- */
275
- deltaY: number;
276
-
277
- /**
278
- * Start X position
279
- */
280
- startX: number;
281
-
282
- /**
283
- * Start Y position
284
- */
285
- startY: number;
286
-
287
- /**
288
- * Current X position
289
- */
290
- currentX: number;
291
-
292
- /**
293
- * Current Y position
294
- */
295
- currentY: number;
296
- }
297
-
298
- /**
299
- * Union type of all gesture events
300
- */
301
- export type AnyGestureEvent =
302
- | TapEvent
303
- | SwipeEvent
304
- | LongPressEvent
305
- | PinchEvent
306
- | RotateEvent
307
- | PanEvent;
308
-
309
- /**
310
- * Handler for gesture events
311
- */
312
- export type GestureHandler = (event: AnyGestureEvent) => void;
313
-
314
- /**
315
- * Gesture state for tracking touch interactions
316
- */
317
- export interface GestureState {
318
- active: boolean;
319
- startTime: number;
320
- startX: number;
321
- startY: number;
322
- lastX: number;
323
- lastY: number;
324
- currentX: number;
325
- currentY: number;
326
- touchCount: number;
327
- longPressTimer: number | null;
328
- startDistance: number;
329
- startAngle: number;
330
- lastTapTime: number;
331
- tapCount: number;
332
- target: EventTarget | null;
333
- }
334
-
335
- /**
336
- * Context for gesture detection
337
- */
338
- export interface GestureDetectionContext {
339
- state: GestureState;
340
- options: Required<GestureConfig>;
341
- originalEvent: Event;
342
- }
343
-
344
- /**
345
- * Gesture manager interface
346
- */
347
- export interface GestureManager {
348
- /**
349
- * Add an event listener for a gesture
350
- * @param eventType - Gesture type
351
- * @param handler - Event handler
352
- * @returns Gesture manager for chaining
353
- */
354
- on: (eventType: string, handler: GestureHandler) => GestureManager;
355
-
356
- /**
357
- * Remove an event listener for a gesture
358
- * @param eventType - Gesture type
359
- * @param handler - Event handler
360
- * @returns Gesture manager for chaining
361
- */
362
- off: (eventType: string, handler: GestureHandler) => GestureManager;
363
-
364
- /**
365
- * Check if a gesture is supported on the current device
366
- * @param gestureType - Type of gesture to check
367
- * @returns Whether the gesture is supported
368
- */
369
- isSupported: (gestureType: string) => boolean;
370
-
371
- /**
372
- * Enable gesture recognition
373
- * @returns Gesture manager for chaining
374
- */
375
- enable: () => GestureManager;
376
-
377
- /**
378
- * Disable gesture recognition
379
- * @returns Gesture manager for chaining
380
- */
381
- disable: () => GestureManager;
382
-
383
- /**
384
- * Clean up event listeners
385
- */
386
- destroy: () => void;
387
- }
@@ -1,128 +0,0 @@
1
- // src/core/gestures/utils.ts
2
- /**
3
- * @module core/gestures
4
- * @description Utility functions for gesture detection
5
- */
6
-
7
- import { GestureEvent, GestureState } from "./types";
8
-
9
- /**
10
- * Calculate distance between two points
11
- *
12
- * @param x1 - X coordinate of first point
13
- * @param y1 - Y coordinate of first point
14
- * @param x2 - X coordinate of second point
15
- * @param y2 - Y coordinate of second point
16
- * @returns Distance between the points
17
- */
18
- export function getDistance(
19
- x1: number,
20
- y1: number,
21
- x2: number,
22
- y2: number
23
- ): number {
24
- return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
25
- }
26
-
27
- /**
28
- * Calculate angle between two points in degrees (0-360)
29
- *
30
- * @param x1 - X coordinate of first point
31
- * @param y1 - Y coordinate of first point
32
- * @param x2 - X coordinate of second point
33
- * @param y2 - Y coordinate of second point
34
- * @returns Angle in degrees
35
- */
36
- export function getAngle(
37
- x1: number,
38
- y1: number,
39
- x2: number,
40
- y2: number
41
- ): number {
42
- const angle = (Math.atan2(y2 - y1, x2 - x1) * 180) / Math.PI;
43
- return angle < 0 ? angle + 360 : angle;
44
- }
45
-
46
- /**
47
- * Create a base gesture event
48
- *
49
- * @param type - Type of gesture
50
- * @param originalEvent - Original DOM event
51
- * @param state - Current gesture state
52
- * @returns Base gesture event object
53
- */
54
- export function createGestureEvent(
55
- type: string,
56
- originalEvent: Event,
57
- state: GestureState
58
- ): GestureEvent {
59
- const endTime = Date.now();
60
- let defaultPrevented = false;
61
-
62
- const event: GestureEvent = {
63
- type,
64
- originalEvent,
65
- target:
66
- (state.target as EventTarget) || (originalEvent.target as EventTarget),
67
- startTime: state.startTime,
68
- endTime,
69
- duration: endTime - state.startTime,
70
- defaultPrevented,
71
- preventDefault: () => {
72
- defaultPrevented = true;
73
- event.defaultPrevented = true;
74
- if (originalEvent.cancelable) {
75
- originalEvent.preventDefault();
76
- }
77
- },
78
- stopPropagation: () => {
79
- originalEvent.stopPropagation();
80
- },
81
- };
82
-
83
- return event;
84
- }
85
-
86
- /**
87
- * Detect if the device supports touch events
88
- *
89
- * @returns Whether touch is supported
90
- */
91
- export function hasTouchSupport(): boolean {
92
- const maxPoints = (navigator as any).maxTouchPoints;
93
- return (
94
- "ontouchstart" in window || (typeof maxPoints === "number" && maxPoints > 0)
95
- );
96
- }
97
-
98
- /**
99
- * Detect if the device supports pointer events
100
- *
101
- * @returns Whether pointer events are supported
102
- */
103
- export function hasPointerSupport(): boolean {
104
- return !!window.PointerEvent;
105
- }
106
-
107
- /**
108
- * Extract normalized touch coordinates from an event
109
- * Works with mouse events, touch events and pointer events
110
- *
111
- * @param e - DOM event
112
- * @returns Object with clientX and clientY coordinates
113
- */
114
- export function getTouchCoordinates(
115
- e: MouseEvent | TouchEvent | PointerEvent
116
- ): { clientX: number; clientY: number } {
117
- if ("touches" in e && Array.isArray(e.touches) && e.touches.length > 0) {
118
- return {
119
- clientX: e.touches[0].clientX,
120
- clientY: e.touches[0].clientY,
121
- };
122
- }
123
-
124
- return {
125
- clientX: (e as MouseEvent | PointerEvent).clientX,
126
- clientY: (e as MouseEvent | PointerEvent).clientY,
127
- };
128
- }
package/src/core/index.ts DELETED
@@ -1,43 +0,0 @@
1
- /**
2
- * Core Module Exports
3
- *
4
- * Central export point for all core functionality
5
- */
6
-
7
- export * from "./compose";
8
-
9
- // Layout system
10
- export {
11
- createLayout,
12
- applyLayoutClasses,
13
- cleanupLayoutClasses,
14
- } from "./layout";
15
- export type { LayoutConfig } from "./layout/types";
16
-
17
- // Viewport system
18
- export { createViewport } from "./viewport";
19
- export type {
20
- ViewportConfig,
21
- ViewportComponent,
22
- ViewportContext,
23
- ItemRange,
24
- ViewportInfo,
25
- } from "./viewport/types";
26
-
27
- // Gesture system
28
- export { createGestureManager } from "./gestures";
29
- export type {
30
- GestureManager,
31
- GestureConfig,
32
- GestureEvent,
33
- TapEvent,
34
- SwipeEvent,
35
- LongPressEvent,
36
- PinchEvent,
37
- RotateEvent,
38
- PanEvent,
39
- AnyGestureEvent,
40
- GestureHandler,
41
- } from "./gestures";
42
-
43
- export * from "./compose";
@@ -1,102 +0,0 @@
1
- /**
2
- * @module core/layout/config
3
- * @description Essential layout configuration utilities
4
- * Core functionality is integrated into schema.ts for better performance
5
- */
6
-
7
- // Configuration constants
8
- const PREFIX = "mtrl"; // TODO: Make this configurable from main mtrl config
9
- const PREFIX_WITH_DASH = `${PREFIX}-`;
10
-
11
- /**
12
- * Simple DOM utilities
13
- */
14
- function addClass(element: any, className: string): void {
15
- if (element && className && element.classList) {
16
- element.classList.add(className);
17
- }
18
- }
19
-
20
- function hasClass(element: any, className: string): boolean {
21
- return element && element.classList && element.classList.contains(className);
22
- }
23
-
24
- /**
25
- * Helper function to clean up previous layout classes from an element
26
- * Useful for dynamic class management
27
- *
28
- * @param element - Element to clean layout classes from
29
- */
30
- export function cleanupLayoutClasses(element: any): void {
31
- if (!element || !element.classList) return;
32
-
33
- // Get all classes from the element
34
- const classList = Array.from(element.classList) as string[];
35
-
36
- // Find and remove layout-related classes
37
- const layoutClasses = classList.filter(
38
- (cls: string) =>
39
- cls.startsWith(`${PREFIX_WITH_DASH}layout--`) ||
40
- cls.includes(`-${PREFIX_WITH_DASH}layout--`)
41
- );
42
-
43
- // Remove each layout class
44
- layoutClasses.forEach((cls: string) => {
45
- element.classList.remove(cls);
46
- });
47
- }
48
-
49
- /**
50
- * Helper function to get the layout type from element classes
51
- *
52
- * @param element - Element to check
53
- * @returns Layout type if found, empty string otherwise
54
- */
55
- export function getLayoutType(element: any): string {
56
- return hasClass(element, `${PREFIX_WITH_DASH}layout--stack`)
57
- ? "stack"
58
- : hasClass(element, `${PREFIX_WITH_DASH}layout--row`)
59
- ? "row"
60
- : hasClass(element, `${PREFIX_WITH_DASH}layout--grid`)
61
- ? "grid"
62
- : "";
63
- }
64
-
65
- /**
66
- * Gets the configured prefix for the layout system
67
- * @returns Current prefix with dash
68
- */
69
- export function getLayoutPrefix(): string {
70
- return PREFIX_WITH_DASH;
71
- }
72
-
73
- /**
74
- * Sets layout classes on an element dynamically
75
- * Useful for programmatic layout updates
76
- *
77
- * @param element - Target element
78
- * @param layoutType - Layout type to apply
79
- * @param classes - Additional classes to apply
80
- */
81
- export function setLayoutClasses(
82
- element: any,
83
- layoutType: string,
84
- classes: string[] = []
85
- ): void {
86
- if (!element || !layoutType) return;
87
-
88
- // Clean up existing layout classes first
89
- cleanupLayoutClasses(element);
90
-
91
- // Apply base layout type
92
- addClass(element, `${PREFIX_WITH_DASH}layout--${layoutType}`);
93
-
94
- // Apply additional classes
95
- classes.forEach((cls) => {
96
- if (cls.startsWith("layout--") || cls.startsWith("layout__")) {
97
- addClass(element, `${PREFIX_WITH_DASH}${cls}`);
98
- } else {
99
- addClass(element, cls);
100
- }
101
- });
102
- }