mtrl 0.4.5 → 0.5.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 (93) hide show
  1. package/README.md +61 -60
  2. package/dist/README.md +61 -60
  3. package/dist/components/chips/chips.d.ts +2 -2
  4. package/dist/components/chips/config.d.ts +1 -1
  5. package/dist/components/chips/features/controller.d.ts +1 -1
  6. package/dist/components/chips/features/dom.d.ts +15 -0
  7. package/dist/components/chips/features/index.d.ts +5 -4
  8. package/dist/components/chips/schema.d.ts +2 -2
  9. package/dist/components/list/api.d.ts +82 -39
  10. package/dist/components/list/config.d.ts +23 -19
  11. package/dist/components/list/features/index.d.ts +1 -1
  12. package/dist/components/list/features/renderer.d.ts +9 -0
  13. package/dist/components/list/features/selection.d.ts +1 -1
  14. package/dist/components/list/list.d.ts +3 -2
  15. package/dist/components/list/types.d.ts +68 -121
  16. package/dist/components/progress/constants.d.ts +3 -3
  17. package/dist/components/slider/features/canvas.d.ts +2 -2
  18. package/dist/components/slider/features/dom.d.ts +21 -0
  19. package/dist/components/slider/features/index.d.ts +5 -4
  20. package/dist/components/slider/slider.d.ts +4 -4
  21. package/dist/components/textfield/api.d.ts +2 -0
  22. package/dist/components/textfield/features/error.d.ts +54 -0
  23. package/dist/components/textfield/features/index.d.ts +1 -0
  24. package/dist/components/textfield/features/supporting-text.d.ts +1 -1
  25. package/dist/components/textfield/types.d.ts +7 -0
  26. package/dist/core/compose/features/icon.d.ts +2 -2
  27. package/dist/core/compose/features/index.d.ts +0 -2
  28. package/dist/core/compose/features/textlabel.d.ts +2 -2
  29. package/dist/core/compose/index.d.ts +1 -5
  30. package/dist/core/dom/attributes.d.ts +32 -2
  31. package/dist/core/dom/classes.d.ts +15 -13
  32. package/dist/core/dom/create.d.ts +35 -87
  33. package/dist/core/dom/index.d.ts +6 -6
  34. package/dist/core/dom/utils.d.ts +1 -10
  35. package/dist/core/index.d.ts +18 -22
  36. package/dist/index.cjs +15 -15
  37. package/dist/index.cjs.map +35 -73
  38. package/dist/index.d.ts +1 -6
  39. package/dist/index.js +15 -15
  40. package/dist/index.js.map +35 -73
  41. package/dist/package.json +1 -1
  42. package/dist/styles.css +2 -2
  43. package/package.json +3 -2
  44. package/dist/components/list/features/listmanager.d.ts +0 -9
  45. package/dist/components/slider/schema.d.ts +0 -65
  46. package/dist/core/collection/adapters/base.d.ts +0 -47
  47. package/dist/core/collection/adapters/route.d.ts +0 -149
  48. package/dist/core/collection/collection.d.ts +0 -131
  49. package/dist/core/collection/index.d.ts +0 -10
  50. package/dist/core/collection/list-manager/config.d.ts +0 -29
  51. package/dist/core/collection/list-manager/dom-elements.d.ts +0 -30
  52. package/dist/core/collection/list-manager/index.d.ts +0 -61
  53. package/dist/core/collection/list-manager/item-measurement.d.ts +0 -91
  54. package/dist/core/collection/list-manager/renderer.d.ts +0 -31
  55. package/dist/core/collection/list-manager/scroll-tracker.d.ts +0 -20
  56. package/dist/core/collection/list-manager/state.d.ts +0 -60
  57. package/dist/core/collection/list-manager/types.d.ts +0 -361
  58. package/dist/core/collection/list-manager/utils/recycling.d.ts +0 -34
  59. package/dist/core/collection/list-manager/utils/visibility.d.ts +0 -45
  60. package/dist/core/compose/features/gestures/longpress.d.ts +0 -85
  61. package/dist/core/compose/features/gestures/pan.d.ts +0 -108
  62. package/dist/core/compose/features/gestures/pinch.d.ts +0 -111
  63. package/dist/core/compose/features/gestures/rotate.d.ts +0 -111
  64. package/dist/core/compose/features/gestures/swipe.d.ts +0 -149
  65. package/dist/core/compose/features/gestures/tap.d.ts +0 -79
  66. package/dist/core/compose/features/gestures.d.ts +0 -86
  67. package/dist/core/composition/features/dom.d.ts +0 -19
  68. package/dist/core/composition/features/icon.d.ts +0 -45
  69. package/dist/core/composition/features/index.d.ts +0 -7
  70. package/dist/core/composition/features/label.d.ts +0 -49
  71. package/dist/core/composition/features/layout.d.ts +0 -31
  72. package/dist/core/composition/index.d.ts +0 -16
  73. package/dist/core/gestures/index.d.ts +0 -12
  74. package/dist/core/gestures/longpress.d.ts +0 -23
  75. package/dist/core/gestures/manager.d.ts +0 -14
  76. package/dist/core/gestures/pan.d.ts +0 -12
  77. package/dist/core/gestures/pinch.d.ts +0 -14
  78. package/dist/core/gestures/rotate.d.ts +0 -14
  79. package/dist/core/gestures/swipe.d.ts +0 -20
  80. package/dist/core/gestures/tap.d.ts +0 -12
  81. package/dist/core/gestures/types.d.ts +0 -320
  82. package/dist/core/gestures/utils.d.ts +0 -57
  83. package/dist/core/layout/array.d.ts +0 -20
  84. package/dist/core/layout/config.d.ts +0 -32
  85. package/dist/core/layout/create.d.ts +0 -14
  86. package/dist/core/layout/index.d.ts +0 -13
  87. package/dist/core/layout/jsx.d.ts +0 -13
  88. package/dist/core/layout/object.d.ts +0 -14
  89. package/dist/core/layout/processor.d.ts +0 -28
  90. package/dist/core/layout/result.d.ts +0 -12
  91. package/dist/core/layout/template.d.ts +0 -12
  92. package/dist/core/layout/types.d.ts +0 -137
  93. package/dist/core/layout/utils.d.ts +0 -38
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mtrl",
3
- "version": "0.4.5",
3
+ "version": "0.5.0",
4
4
  "description": "A functional TypeScript/JavaScript component library with composable architecture based on Material Design 3",
5
5
  "author": "floor",
6
6
  "license": "MIT License",
@@ -75,6 +75,7 @@
75
75
  "jsdom": "^26.0.0",
76
76
  "sass": "^1.85.1",
77
77
  "typedoc": "^0.27.9",
78
- "typescript": "^5.8.2"
78
+ "typescript": "^5.8.2",
79
+ "@types/bun": "latest"
79
80
  }
80
81
  }
@@ -1,9 +0,0 @@
1
- /**
2
- * Adds list management capabilities to a component
3
- * Optimized implementation for better performance
4
- *
5
- * @param config - Configuration options
6
- * @returns Function that enhances a component with list management
7
- */
8
- export declare const withListManager: (config: any) => (component: any) => any;
9
- export default withListManager;
@@ -1,65 +0,0 @@
1
- import { SliderConfig } from './types';
2
- /**
3
- * Creates the base slider structure definition
4
- * When using canvas mode, only handle and value bubble are DOM elements
5
- *
6
- * @param component Component for class name generation
7
- * @param config Slider configuration
8
- * @returns Structure schema object
9
- */
10
- export declare function createSliderSchema(component: any, config: SliderConfig): {
11
- element: {
12
- options: {
13
- className: any[];
14
- attributes: {
15
- tabindex: string;
16
- role: string;
17
- 'aria-disabled': string;
18
- };
19
- };
20
- children: {
21
- container: {
22
- options: {
23
- className: any;
24
- style: {
25
- position: string;
26
- };
27
- };
28
- children: {
29
- handle: {
30
- options: {
31
- className: any;
32
- attributes: {
33
- role: string;
34
- 'aria-valuemin': string;
35
- 'aria-valuemax': string;
36
- 'aria-valuenow': string;
37
- 'aria-orientation': string;
38
- tabindex: string;
39
- 'aria-disabled': string;
40
- 'data-value': string;
41
- 'data-handle-index': string;
42
- };
43
- style: {
44
- left: string;
45
- };
46
- };
47
- };
48
- valueBubble: {
49
- options: {
50
- className: any;
51
- attributes: {
52
- 'aria-hidden': string;
53
- 'data-handle-index': string;
54
- };
55
- text: string;
56
- style: {
57
- left: string;
58
- };
59
- };
60
- };
61
- };
62
- };
63
- };
64
- };
65
- };
@@ -1,47 +0,0 @@
1
- /**
2
- * Query operators for filtering data
3
- */
4
- export declare const OPERATORS: {
5
- readonly EQ: "eq";
6
- readonly NE: "ne";
7
- readonly GT: "gt";
8
- readonly GTE: "gte";
9
- readonly LT: "lt";
10
- readonly LTE: "lte";
11
- readonly IN: "in";
12
- readonly NIN: "nin";
13
- readonly CONTAINS: "contains";
14
- readonly STARTS_WITH: "startsWith";
15
- readonly ENDS_WITH: "endsWith";
16
- };
17
- /**
18
- * Type for query operators
19
- */
20
- export type Operator = keyof typeof OPERATORS;
21
- /**
22
- * Configuration for base adapter
23
- */
24
- export interface BaseAdapterConfig {
25
- /**
26
- * Error handler function
27
- */
28
- onError?: (error: Error, context?: any) => void;
29
- }
30
- /**
31
- * Base adapter interface
32
- */
33
- export interface BaseAdapter {
34
- /**
35
- * Handles errors in adapter operations
36
- * @param error - The error that occurred
37
- * @param context - Optional context information about the error
38
- * @throws The original error after processing
39
- */
40
- handleError(error: Error, context?: any): never;
41
- }
42
- /**
43
- * Creates a base adapter with error handling
44
- * @param config - Adapter configuration
45
- * @returns Base adapter with error handling
46
- */
47
- export declare const createBaseAdapter: (config?: BaseAdapterConfig) => BaseAdapter;
@@ -1,149 +0,0 @@
1
- /**
2
- * Pagination strategies supported by the route adapter
3
- */
4
- export type PaginationStrategy = 'cursor' | 'offset' | 'page';
5
- /**
6
- * Pagination configuration
7
- */
8
- export interface PaginationConfig {
9
- /**
10
- * Pagination strategy to use
11
- * @default 'cursor'
12
- */
13
- strategy: PaginationStrategy;
14
- /**
15
- * Parameter name for pagination cursor
16
- * @default 'cursor'
17
- */
18
- cursorParamName?: string;
19
- /**
20
- * Parameter name for page number
21
- * @default 'page'
22
- */
23
- pageParamName?: string;
24
- /**
25
- * Parameter name for page size / items per page
26
- * @default 'per_page'
27
- */
28
- perPageParamName?: string;
29
- /**
30
- * Parameter name for offset
31
- * @default 'offset'
32
- */
33
- offsetParamName?: string;
34
- /**
35
- * Parameter name for limit
36
- * @default 'limit'
37
- */
38
- limitParamName?: string;
39
- /**
40
- * Default page size for pagination
41
- * @default 20
42
- */
43
- defaultPageSize?: number;
44
- }
45
- /**
46
- * Route adapter configuration interface
47
- */
48
- export interface RouteAdapterConfig {
49
- /**
50
- * Base URL for API requests
51
- */
52
- base?: string;
53
- /**
54
- * API endpoints
55
- */
56
- endpoints?: {
57
- create?: string;
58
- list?: string;
59
- update?: string;
60
- delete?: string;
61
- };
62
- /**
63
- * HTTP headers to include with requests
64
- */
65
- headers?: Record<string, string>;
66
- /**
67
- * Whether to enable response caching
68
- */
69
- cache?: boolean;
70
- /**
71
- * Error handler function
72
- */
73
- onError?: (error: Error, context?: any) => void;
74
- /**
75
- * Custom adapter options
76
- */
77
- adapter?: {
78
- /**
79
- * Custom response parser
80
- */
81
- parseResponse?: (response: any) => any;
82
- };
83
- /**
84
- * Pagination configuration
85
- */
86
- pagination?: PaginationConfig;
87
- }
88
- /**
89
- * Response metadata interface
90
- */
91
- export interface ResponseMeta {
92
- /**
93
- * Cursor for next page (cursor-based pagination)
94
- */
95
- cursor: string | null;
96
- /**
97
- * Whether there are more items available
98
- */
99
- hasNext: boolean;
100
- /**
101
- * Total number of items (if available)
102
- */
103
- total?: number;
104
- /**
105
- * Current page number (page-based pagination)
106
- */
107
- page?: number;
108
- /**
109
- * Total number of pages (page-based pagination)
110
- */
111
- pages?: number;
112
- /**
113
- * Current offset (offset-based pagination)
114
- */
115
- offset?: number;
116
- }
117
- /**
118
- * Parsed response interface
119
- */
120
- export interface ParsedResponse<T = any> {
121
- /**
122
- * Items returned in the response
123
- */
124
- items: T[];
125
- /**
126
- * Pagination metadata
127
- */
128
- meta: ResponseMeta;
129
- }
130
- export declare const createRouteAdapter: (config?: RouteAdapterConfig) => {
131
- create: (items: any[]) => Promise<ParsedResponse>;
132
- read: (query?: Record<string, any>, options?: Record<string, any>) => Promise<ParsedResponse>;
133
- update: (items: any[]) => Promise<ParsedResponse>;
134
- delete: (ids: string[]) => Promise<ParsedResponse>;
135
- query: (query?: Record<string, any>, options?: Record<string, any>) => Promise<ParsedResponse>;
136
- /**
137
- * Change the pagination strategy
138
- * @param strategy - New pagination strategy
139
- * @returns Updated adapter
140
- */
141
- setPaginationStrategy: (strategy: PaginationStrategy) => void;
142
- /**
143
- * Get the current pagination configuration
144
- * @returns Current pagination config
145
- */
146
- getPaginationConfig: () => Required<PaginationConfig>;
147
- disconnect: () => void;
148
- handleError(error: Error, context?: any): never;
149
- };
@@ -1,131 +0,0 @@
1
- /**
2
- * Event types for collection changes
3
- */
4
- export declare const COLLECTION_EVENTS: {
5
- readonly CHANGE: "change";
6
- readonly ADD: "add";
7
- readonly UPDATE: "update";
8
- readonly REMOVE: "remove";
9
- readonly ERROR: "error";
10
- readonly LOADING: "loading";
11
- };
12
- /**
13
- * Collection event type
14
- */
15
- export type CollectionEvent = (typeof COLLECTION_EVENTS)[keyof typeof COLLECTION_EVENTS];
16
- /**
17
- * Observer callback type for collection events
18
- */
19
- export type CollectionObserver<T = unknown> = (payload: {
20
- event: CollectionEvent;
21
- data: T | readonly T[] | readonly string[] | boolean | Error | null;
22
- }) => void;
23
- /**
24
- * Query operators for filtering
25
- */
26
- export declare const OPERATORS: {
27
- readonly EQ: "eq";
28
- readonly NE: "ne";
29
- readonly GT: "gt";
30
- readonly GTE: "gte";
31
- readonly LT: "lt";
32
- readonly LTE: "lte";
33
- readonly IN: "in";
34
- readonly NIN: "nin";
35
- readonly CONTAINS: "contains";
36
- readonly STARTS_WITH: "startsWith";
37
- readonly ENDS_WITH: "endsWith";
38
- };
39
- /**
40
- * Type for all collection items
41
- */
42
- export interface CollectionItem {
43
- id: string;
44
- [key: string]: unknown;
45
- }
46
- /**
47
- * Collection configuration
48
- */
49
- export interface CollectionConfig<T extends CollectionItem> {
50
- /**
51
- * Transform function for items
52
- */
53
- transform?: (item: unknown) => T;
54
- /**
55
- * Validation function for items
56
- */
57
- validate?: (item: unknown) => boolean;
58
- /**
59
- * Initial capacity for collection
60
- */
61
- initialCapacity?: number;
62
- }
63
- /**
64
- * Collection interface
65
- */
66
- export interface Collection<T extends CollectionItem> {
67
- /**
68
- * Subscribe to collection changes
69
- * @param observer - Observer callback
70
- * @returns Unsubscribe function
71
- */
72
- subscribe: (observer: CollectionObserver) => () => void;
73
- /**
74
- * Get collection items based on current query and sort
75
- * @returns Collection items
76
- */
77
- getItems: () => readonly T[];
78
- /**
79
- * Get collection size
80
- * @returns Number of items
81
- */
82
- getSize: () => number;
83
- /**
84
- * Get loading state
85
- * @returns Loading state
86
- */
87
- isLoading: () => boolean;
88
- /**
89
- * Get error state
90
- * @returns Error object
91
- */
92
- getError: () => Error | null;
93
- /**
94
- * Set query filter
95
- * @param queryFn - Query function
96
- */
97
- query: (queryFn: ((item: T) => boolean) | null) => void;
98
- /**
99
- * Set sort function
100
- * @param sortFn - Sort function
101
- */
102
- sort: (sortFn: ((a: T, b: T) => number) | null) => void;
103
- /**
104
- * Add items to collection
105
- * @param items - Items to add
106
- * @returns Added items
107
- */
108
- add: (items: T | readonly T[]) => Promise<readonly T[]>;
109
- /**
110
- * Update items in collection
111
- * @param items - Items to update
112
- * @returns Updated items
113
- */
114
- update: (items: T | readonly T[]) => Promise<readonly T[]>;
115
- /**
116
- * Remove items from collection
117
- * @param ids - Item IDs to remove
118
- * @returns Removed item IDs
119
- */
120
- remove: (ids: string | readonly string[]) => Promise<readonly string[]>;
121
- /**
122
- * Clear all items from collection
123
- */
124
- clear: () => void;
125
- }
126
- /**
127
- * Creates a collection for managing items
128
- * @param config - Collection configuration
129
- * @returns Collection interface
130
- */
131
- export declare const createCollection: <T extends CollectionItem>(config?: CollectionConfig<T>) => Collection<T>;
@@ -1,10 +0,0 @@
1
- export { createCollection } from './collection';
2
- export { COLLECTION_EVENTS } from './collection';
3
- export { OPERATORS as COLLECTION_OPERATORS } from './collection';
4
- export type { CollectionItem, CollectionConfig, CollectionEvent, CollectionObserver, Collection } from './collection';
5
- export { createListManager, transforms } from './list-manager';
6
- export type { ListManager, ListManagerConfig, ListItem, List, PageLoader, PageLoaderConfig, LoadStatus, PaginationMeta } from './list-manager';
7
- export { createBaseAdapter, OPERATORS } from './adapters/base';
8
- export type { BaseAdapter, BaseAdapterConfig, Operator } from './adapters/base';
9
- export { createRouteAdapter } from './adapters/route';
10
- export type { RouteAdapterConfig, ParsedResponse } from './adapters/route';
@@ -1,29 +0,0 @@
1
- import { ListManagerConfig } from './types';
2
- /**
3
- * Default configuration for list manager
4
- */
5
- export declare const DEFAULT_CONFIG: Partial<ListManagerConfig>;
6
- /**
7
- * Merges user configuration with default configuration
8
- * @param config User configuration
9
- * @returns Merged configuration
10
- */
11
- export declare function mergeConfig(config: ListManagerConfig): ListManagerConfig;
12
- /**
13
- * Validates configuration and sets up defaults
14
- * @param config User configuration
15
- * @returns Validated configuration object
16
- */
17
- export declare function validateConfig(config: ListManagerConfig): ListManagerConfig;
18
- /**
19
- * Determines if the list manager should use API mode
20
- * @param config User configuration
21
- * @returns Whether to use API mode
22
- */
23
- export declare function determineApiMode(config: ListManagerConfig): boolean;
24
- /**
25
- * Gets all static items from config
26
- * @param config User configuration
27
- * @returns Static items array or empty array
28
- */
29
- export declare function getStaticItems(config: ListManagerConfig): any[];
@@ -1,30 +0,0 @@
1
- import { ListManagerElements } from './types';
2
- /**
3
- * Creates and initializes the DOM elements needed by the list manager
4
- * @param container Container element
5
- * @returns Initialized DOM elements
6
- */
7
- export declare function createDomElements(container: HTMLElement): ListManagerElements;
8
- /**
9
- * Creates sentinel elements for intersection observer
10
- * @param elements List manager elements
11
- * @returns The DOM elements with sentinels added
12
- */
13
- export declare function createSentinels(elements: ListManagerElements): ListManagerElements;
14
- /**
15
- * Updates the position of the bottom sentinel based on total height
16
- * @param elements List manager elements
17
- * @param totalHeight Total height of list
18
- */
19
- export declare function updateSentinelPositions(elements: ListManagerElements, totalHeight: number): void;
20
- /**
21
- * Updates the spacer element height
22
- * @param elements List manager elements
23
- * @param totalHeight Total height to set
24
- */
25
- export declare function updateSpacerHeight(elements: ListManagerElements, totalHeight: number): void;
26
- /**
27
- * Cleans up DOM elements
28
- * @param elements List manager elements
29
- */
30
- export declare function cleanupDomElements(elements: ListManagerElements): void;
@@ -1,61 +0,0 @@
1
- import { ListManagerConfig, ListManager, LoadStatus } from "./types";
2
- /**
3
- * Creates a list manager for a specific collection
4
- * @param {string} collection - Collection name
5
- * @param {HTMLElement} container - Container element
6
- * @param {ListManagerConfig} config - Configuration options
7
- * @returns {ListManager} List manager methods
8
- */
9
- export declare const createListManager: (collection: string, container: HTMLElement, config: ListManagerConfig) => ListManager;
10
- /**
11
- * Utility to create a cursor-based page loader
12
- * @param list List interface
13
- * @param listManager List manager instance
14
- * @param config Page loader configuration
15
- * @returns Page loader interface
16
- */
17
- export declare const createPageLoader: (list: {
18
- setItems: (items: any[]) => void;
19
- }, listManager: ReturnType<typeof createListManager>, config?: {
20
- onLoad?: (status: LoadStatus) => void;
21
- pageSize?: number;
22
- }) => {
23
- load: (cursor?: any, addToHistory?: boolean) => Promise<{
24
- hasNext: boolean;
25
- hasPrev: boolean;
26
- }>;
27
- loadNext: () => Promise<{
28
- hasNext: boolean;
29
- hasPrev: boolean;
30
- }>;
31
- loadPrev: () => Promise<{
32
- hasNext: boolean;
33
- hasPrev: boolean;
34
- }>;
35
- readonly loading: boolean;
36
- readonly cursor: string;
37
- };
38
- /**
39
- * Transform functions for common collections
40
- */
41
- export declare const transforms: {
42
- track: (track: any) => {
43
- id: any;
44
- headline: any;
45
- supportingText: any;
46
- meta: any;
47
- };
48
- playlist: (playlist: any) => {
49
- id: any;
50
- headline: any;
51
- supportingText: string;
52
- meta: any;
53
- };
54
- country: (country: any) => {
55
- id: any;
56
- headline: any;
57
- supportingText: any;
58
- meta: any;
59
- };
60
- };
61
- export * from "./types";
@@ -1,91 +0,0 @@
1
- import { ListManagerConfig } from './types';
2
- /**
3
- * Create item height measurement utilities
4
- * @param defaultHeight Default height for items with no measurement
5
- * @returns Object containing measurement functions
6
- */
7
- export declare const createItemMeasurement: (defaultHeight?: number) => {
8
- /**
9
- * Setup measurement system with configuration options
10
- * Should be called on initialization
11
- * @param config List configuration options
12
- */
13
- setup: (config?: ListManagerConfig) => void;
14
- /**
15
- * Measures the height of an item using its DOM element
16
- * @param item Item to measure
17
- * @param element DOM element of the item
18
- * @returns The measured height
19
- */
20
- measureItemHeight: (item: any, element: HTMLElement) => number;
21
- /**
22
- * Gets the height of an item, using cached value if available
23
- * @param item Item to get height for
24
- * @returns Item height in pixels
25
- */
26
- getItemHeight: (item: any) => number;
27
- /**
28
- * Set custom heights for specific items
29
- * Only applied when in dynamic measurement mode
30
- * @param heightsMap Map of item IDs to heights
31
- * @returns Whether any heights were updated
32
- */
33
- setItemHeights: (heightsMap: Record<string, number>) => boolean;
34
- /**
35
- * Calculates total height of all items
36
- * @param items Array of items
37
- * @returns Total height in pixels
38
- */
39
- calculateTotalHeight: (items: any[]) => number;
40
- /**
41
- * Get offset of an item from the top of the list
42
- * @param items List of all items
43
- * @param itemId ID of item to find offset for
44
- * @returns Offset in pixels or -1 if not found
45
- */
46
- getItemOffset: (items: any[], itemId: string) => number;
47
- /**
48
- * Get the offset at a specific index
49
- * @param index Index to get offset for
50
- * @returns Offset in pixels
51
- */
52
- getOffsetAtIndex: (index: number) => number;
53
- /**
54
- * Measures elements that have been marked for measurement
55
- * Only takes effect in dynamic measurement mode
56
- * @param container Container element
57
- * @param items List of all items
58
- * @returns Whether any heights were updated
59
- */
60
- measureMarkedElements: (container: HTMLElement, items: any[]) => boolean;
61
- /**
62
- * Check if offsets are currently cached
63
- * @returns Whether offsets are cached
64
- */
65
- hasCachedOffsets: () => boolean;
66
- /**
67
- * Cache offsets for all items
68
- * @param items Array of all items
69
- */
70
- calculateOffsets: (items: any[]) => void;
71
- /**
72
- * Clears all cached heights and offsets
73
- */
74
- clear: () => void;
75
- /**
76
- * Gets all cached heights
77
- * @returns Map of item IDs to heights
78
- */
79
- getAllHeights: () => Map<string, number>;
80
- /**
81
- * Gets current default height
82
- * @returns Current default height
83
- */
84
- getDefaultHeight: () => number;
85
- /**
86
- * Checks if using uniform height mode
87
- * @returns Whether using uniform height
88
- */
89
- isUsingUniformHeight: () => boolean;
90
- };
91
- export type ItemMeasurement = ReturnType<typeof createItemMeasurement>;
@@ -1,31 +0,0 @@
1
- import { ListManagerConfig, ListManagerElements, VisibleRange } from "./types";
2
- import { RecyclingPool } from "./utils/recycling";
3
- import { ItemMeasurement } from "./item-measurement";
4
- /**
5
- * Creates a renderer for list items
6
- * @param config List manager configuration
7
- * @param elements DOM elements used by the list manager
8
- * @param itemMeasurement Item measurement utilities
9
- * @param recyclePool Element recycling pool
10
- * @returns Renderer functions
11
- */
12
- export declare const createRenderer: (config: ListManagerConfig, elements: ListManagerElements, itemMeasurement: ItemMeasurement, recyclePool: RecyclingPool) => {
13
- /**
14
- * Sets a render hook function that will be called for each rendered item
15
- * @param hookFn Hook function
16
- */
17
- setRenderHook: (hookFn: (item: any, element: HTMLElement) => void) => void;
18
- /**
19
- * Renders visible items in the viewport
20
- * @param items All items
21
- * @param visibleRange Visible range with start and end indices
22
- * @returns Map of item IDs to rendered elements
23
- */
24
- renderVisibleItems: (items: any[], visibleRange: VisibleRange) => Map<string, HTMLElement>;
25
- /**
26
- * Gets all currently rendered item elements
27
- * @returns Map of item IDs to elements
28
- */
29
- getItemElements: () => Map<string, HTMLElement>;
30
- };
31
- export type Renderer = ReturnType<typeof createRenderer>;