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,168 +0,0 @@
1
- /**
2
- * @module core/layout
3
- * @description Unified layout system for mtrl-addons
4
- * Provides array, object, and JSX-based layout creation with integrated optimizations
5
- */
6
-
7
- // Import for use in convenience functions
8
- import { createLayout, clearClassCache, clearFragmentPool } from "./schema";
9
-
10
- // Core schema processor and utilities
11
- export {
12
- createLayout,
13
- processClassNames,
14
- isComponent,
15
- flattenLayout,
16
- applyLayoutClasses,
17
- applyLayoutItemClasses,
18
- createLayoutResult,
19
- clearClassCache,
20
- clearFragmentPool,
21
- } from "./schema";
22
-
23
- // Essential types
24
- export type {
25
- LayoutConfig,
26
- LayoutItemConfig,
27
- LayoutOptions,
28
- LayoutResult,
29
- ComponentLike,
30
- ElementOptions,
31
- ElementDefinition,
32
- Schema,
33
- } from "./types";
34
-
35
- // Configuration utilities
36
- export {
37
- cleanupLayoutClasses,
38
- getLayoutType,
39
- getLayoutPrefix,
40
- setLayoutClasses,
41
- } from "./config";
42
-
43
- // JSX support
44
- export {
45
- h,
46
- Fragment,
47
- createJsxLayout,
48
- component,
49
- renderElements,
50
- jsx,
51
- } from "./jsx";
52
-
53
- // Default export for convenient usage
54
- export { createLayout as default } from "./schema";
55
-
56
- /**
57
- * Convenience function to create a layout with common patterns
58
- * Provides a simpler API for common use cases
59
- */
60
- export function layout(
61
- type: "stack" | "row" | "grid" | "flex" = "stack",
62
- options: Record<string, any> = {}
63
- ): any {
64
- return createLayout([
65
- "div",
66
- {
67
- layout: { type },
68
- ...options,
69
- },
70
- ]);
71
- }
72
-
73
- /**
74
- * Creates a responsive grid layout
75
- * Automatically handles responsive breakpoints
76
- */
77
- export function grid(
78
- columns: number | "auto-fit" | "auto-fill" = "auto-fit",
79
- options: Record<string, any> = {}
80
- ): any {
81
- return createLayout([
82
- "div",
83
- {
84
- layout: {
85
- type: "grid",
86
- columns,
87
- gap: options.gap || "1rem",
88
- ...options.layout,
89
- },
90
- ...options,
91
- },
92
- ]);
93
- }
94
-
95
- /**
96
- * Creates a flexible row layout
97
- * Automatically handles mobile stacking
98
- */
99
- export function row(options: Record<string, any> = {}): any {
100
- return createLayout([
101
- "div",
102
- {
103
- layout: {
104
- type: "row",
105
- gap: options.gap || "1rem",
106
- mobileStack: options.mobileStack !== false,
107
- ...options.layout,
108
- },
109
- ...options,
110
- },
111
- ]);
112
- }
113
-
114
- /**
115
- * Creates a vertical stack layout
116
- * Default layout type with consistent spacing
117
- */
118
- export function stack(options: Record<string, any> = {}): any {
119
- return createLayout([
120
- "div",
121
- {
122
- layout: {
123
- type: "stack",
124
- gap: options.gap || "1rem",
125
- ...options.layout,
126
- },
127
- ...options,
128
- },
129
- ]);
130
- }
131
-
132
- /**
133
- * Creates a layout from a template function
134
- * Useful for dynamic layouts
135
- */
136
- export function template(
137
- fn: (props: Record<string, any>) => any,
138
- props: Record<string, any> = {}
139
- ): any {
140
- const schema = fn(props);
141
- return createLayout(schema);
142
- }
143
-
144
- /**
145
- * Performance utilities for layout management
146
- */
147
- export const performance = {
148
- clearCache: clearClassCache,
149
- clearFragmentPool,
150
-
151
- /**
152
- * Clears all cached resources
153
- */
154
- clearAll(): void {
155
- clearClassCache();
156
- clearFragmentPool();
157
- },
158
-
159
- /**
160
- * Gets current cache stats
161
- */
162
- getStats(): Record<string, any> {
163
- return {
164
- // Stats would be implemented in the actual cache system
165
- message: "Performance stats available in browser console",
166
- };
167
- },
168
- };
@@ -1,174 +0,0 @@
1
- /**
2
- * @module core/layout/jsx
3
- * @description JSX-like syntax support for layout creation
4
- * Provides a simple h() function for creating elements without React dependency
5
- */
6
-
7
- import type { LayoutResult } from "./types";
8
- import { createLayout } from "./schema";
9
-
10
- /**
11
- * Fragment symbol for JSX fragments
12
- */
13
- export const Fragment = Symbol("Fragment");
14
-
15
- /**
16
- * JSX-like hyperscript function
17
- * Creates elements in a React-like syntax without React dependency
18
- *
19
- * @param tag - HTML tag name, component function, or Fragment
20
- * @param props - Element properties and attributes
21
- * @param children - Child elements
22
- * @returns DOM element or component
23
- */
24
- export function h(
25
- tag: string | Function | typeof Fragment,
26
- props?: Record<string, any> | null,
27
- ...children: any[]
28
- ): any {
29
- // Handle Fragment
30
- if (tag === Fragment) {
31
- const fragment = document.createDocumentFragment();
32
- children.forEach((child) => {
33
- if (child != null) {
34
- const element =
35
- typeof child === "string" ? document.createTextNode(child) : child;
36
- fragment.appendChild(element);
37
- }
38
- });
39
- return fragment;
40
- }
41
-
42
- // Handle string tags (HTML elements)
43
- if (typeof tag === "string") {
44
- const element = document.createElement(tag);
45
-
46
- // Apply props
47
- if (props) {
48
- for (const [key, value] of Object.entries(props)) {
49
- if (key === "className" || key === "class") {
50
- element.className = value;
51
- } else if (key.startsWith("on") && typeof value === "function") {
52
- // Event handler
53
- const eventName = key.slice(2).toLowerCase();
54
- element.addEventListener(eventName, value);
55
- } else if (key === "style" && typeof value === "object") {
56
- // Style object
57
- Object.assign(element.style, value);
58
- } else if (key === "dangerouslySetInnerHTML") {
59
- // HTML content
60
- element.innerHTML = value.__html || "";
61
- } else if (value != null) {
62
- // Regular attribute
63
- element.setAttribute(key, value.toString());
64
- }
65
- }
66
- }
67
-
68
- // Append children
69
- children.forEach((child) => {
70
- if (child != null) {
71
- if (typeof child === "string") {
72
- element.appendChild(document.createTextNode(child));
73
- } else if (child instanceof Node) {
74
- element.appendChild(child);
75
- } else {
76
- element.appendChild(document.createTextNode(String(child)));
77
- }
78
- }
79
- });
80
-
81
- return element;
82
- }
83
-
84
- // Handle component functions
85
- if (typeof tag === "function") {
86
- const allProps = props || {};
87
- if (children.length > 0) {
88
- allProps.children = children;
89
- }
90
- return tag(allProps);
91
- }
92
-
93
- // Fallback to div
94
- return h("div", props, ...children);
95
- }
96
-
97
- /**
98
- * Creates a layout using JSX-like syntax
99
- * Provides a bridge between JSX and the layout system
100
- *
101
- * @param jsxElement - JSX element created with h()
102
- * @param parentElement - Parent element to attach to
103
- * @returns Layout result
104
- */
105
- export function createJsxLayout(
106
- jsxElement: any,
107
- parentElement?: any
108
- ): LayoutResult {
109
- // Convert JSX element to layout schema
110
- const schema = jsxElement;
111
-
112
- // Create layout using the standard createLayout function
113
- return createLayout(schema, parentElement);
114
- }
115
-
116
- /**
117
- * Utility to create a simple component from a function
118
- * Useful for creating reusable JSX components
119
- *
120
- * @param fn - Component function
121
- * @returns Component that can be used in JSX
122
- */
123
- export function component(fn: (props: Record<string, any>) => any): Function {
124
- return function (props: Record<string, any>): any {
125
- return fn(props || {});
126
- };
127
- }
128
-
129
- /**
130
- * Utility to render multiple JSX elements
131
- * Useful for creating lists or collections
132
- *
133
- * @param elements - Array of JSX elements
134
- * @param parentElement - Parent element to attach to
135
- * @returns Array of layout results
136
- */
137
- export function renderElements(
138
- elements: any[],
139
- parentElement?: any
140
- ): LayoutResult[] {
141
- return elements.map((element) => createJsxLayout(element, parentElement));
142
- }
143
-
144
- /**
145
- * Common JSX element creators for convenience
146
- */
147
- export const jsx = {
148
- div: (props?: Record<string, any>, ...children: any[]) =>
149
- h("div", props, ...children),
150
- span: (props?: Record<string, any>, ...children: any[]) =>
151
- h("span", props, ...children),
152
- p: (props?: Record<string, any>, ...children: any[]) =>
153
- h("p", props, ...children),
154
- button: (props?: Record<string, any>, ...children: any[]) =>
155
- h("button", props, ...children),
156
- input: (props?: Record<string, any>) => h("input", props),
157
- img: (props?: Record<string, any>) => h("img", props),
158
- a: (props?: Record<string, any>, ...children: any[]) =>
159
- h("a", props, ...children),
160
- ul: (props?: Record<string, any>, ...children: any[]) =>
161
- h("ul", props, ...children),
162
- li: (props?: Record<string, any>, ...children: any[]) =>
163
- h("li", props, ...children),
164
- section: (props?: Record<string, any>, ...children: any[]) =>
165
- h("section", props, ...children),
166
- header: (props?: Record<string, any>, ...children: any[]) =>
167
- h("header", props, ...children),
168
- footer: (props?: Record<string, any>, ...children: any[]) =>
169
- h("footer", props, ...children),
170
- main: (props?: Record<string, any>, ...children: any[]) =>
171
- h("main", props, ...children),
172
- article: (props?: Record<string, any>, ...children: any[]) =>
173
- h("article", props, ...children),
174
- };