mtrl 0.4.4 → 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.
- package/README.md +61 -60
- package/dist/README.md +61 -60
- package/dist/components/chips/chips.d.ts +2 -2
- package/dist/components/chips/config.d.ts +1 -1
- package/dist/components/chips/features/controller.d.ts +1 -1
- package/dist/components/chips/features/dom.d.ts +15 -0
- package/dist/components/chips/features/index.d.ts +5 -4
- package/dist/components/chips/schema.d.ts +2 -2
- package/dist/components/list/api.d.ts +82 -39
- package/dist/components/list/config.d.ts +23 -19
- package/dist/components/list/features/index.d.ts +1 -1
- package/dist/components/list/features/renderer.d.ts +9 -0
- package/dist/components/list/features/selection.d.ts +1 -1
- package/dist/components/list/list.d.ts +3 -2
- package/dist/components/list/types.d.ts +68 -121
- package/dist/components/progress/constants.d.ts +3 -3
- package/dist/components/slider/features/canvas.d.ts +2 -2
- package/dist/components/slider/features/dom.d.ts +21 -0
- package/dist/components/slider/features/index.d.ts +5 -4
- package/dist/components/slider/slider.d.ts +4 -4
- package/dist/components/textfield/api.d.ts +2 -0
- package/dist/components/textfield/features/error.d.ts +54 -0
- package/dist/components/textfield/features/index.d.ts +1 -0
- package/dist/components/textfield/features/placement.d.ts +1 -1
- package/dist/components/textfield/features/supporting-text.d.ts +1 -1
- package/dist/components/textfield/types.d.ts +7 -0
- package/dist/core/compose/features/icon.d.ts +2 -2
- package/dist/core/compose/features/index.d.ts +0 -2
- package/dist/core/compose/features/textinput.d.ts +4 -0
- package/dist/core/compose/features/textlabel.d.ts +2 -2
- package/dist/core/compose/index.d.ts +1 -5
- package/dist/core/dom/attributes.d.ts +32 -2
- package/dist/core/dom/classes.d.ts +15 -13
- package/dist/core/dom/create.d.ts +35 -87
- package/dist/core/dom/index.d.ts +6 -6
- package/dist/core/dom/utils.d.ts +1 -10
- package/dist/core/index.d.ts +18 -22
- package/dist/index.cjs +15 -15
- package/dist/index.cjs.map +36 -74
- package/dist/index.d.ts +1 -6
- package/dist/index.js +15 -15
- package/dist/index.js.map +36 -74
- package/dist/package.json +1 -1
- package/dist/styles.css +2 -2
- package/package.json +4 -3
- package/dist/components/list/features/listmanager.d.ts +0 -9
- package/dist/components/slider/schema.d.ts +0 -65
- package/dist/core/collection/adapters/base.d.ts +0 -47
- package/dist/core/collection/adapters/route.d.ts +0 -149
- package/dist/core/collection/collection.d.ts +0 -131
- package/dist/core/collection/index.d.ts +0 -10
- package/dist/core/collection/list-manager/config.d.ts +0 -29
- package/dist/core/collection/list-manager/dom-elements.d.ts +0 -30
- package/dist/core/collection/list-manager/index.d.ts +0 -61
- package/dist/core/collection/list-manager/item-measurement.d.ts +0 -91
- package/dist/core/collection/list-manager/renderer.d.ts +0 -31
- package/dist/core/collection/list-manager/scroll-tracker.d.ts +0 -20
- package/dist/core/collection/list-manager/state.d.ts +0 -60
- package/dist/core/collection/list-manager/types.d.ts +0 -361
- package/dist/core/collection/list-manager/utils/recycling.d.ts +0 -34
- package/dist/core/collection/list-manager/utils/visibility.d.ts +0 -45
- package/dist/core/compose/features/gestures/longpress.d.ts +0 -85
- package/dist/core/compose/features/gestures/pan.d.ts +0 -108
- package/dist/core/compose/features/gestures/pinch.d.ts +0 -111
- package/dist/core/compose/features/gestures/rotate.d.ts +0 -111
- package/dist/core/compose/features/gestures/swipe.d.ts +0 -149
- package/dist/core/compose/features/gestures/tap.d.ts +0 -79
- package/dist/core/compose/features/gestures.d.ts +0 -86
- package/dist/core/composition/features/dom.d.ts +0 -19
- package/dist/core/composition/features/icon.d.ts +0 -45
- package/dist/core/composition/features/index.d.ts +0 -7
- package/dist/core/composition/features/label.d.ts +0 -49
- package/dist/core/composition/features/layout.d.ts +0 -31
- package/dist/core/composition/index.d.ts +0 -16
- package/dist/core/gestures/index.d.ts +0 -12
- package/dist/core/gestures/longpress.d.ts +0 -23
- package/dist/core/gestures/manager.d.ts +0 -14
- package/dist/core/gestures/pan.d.ts +0 -12
- package/dist/core/gestures/pinch.d.ts +0 -14
- package/dist/core/gestures/rotate.d.ts +0 -14
- package/dist/core/gestures/swipe.d.ts +0 -20
- package/dist/core/gestures/tap.d.ts +0 -12
- package/dist/core/gestures/types.d.ts +0 -320
- package/dist/core/gestures/utils.d.ts +0 -57
- package/dist/core/layout/array.d.ts +0 -20
- package/dist/core/layout/config.d.ts +0 -32
- package/dist/core/layout/create.d.ts +0 -14
- package/dist/core/layout/index.d.ts +0 -13
- package/dist/core/layout/jsx.d.ts +0 -13
- package/dist/core/layout/object.d.ts +0 -14
- package/dist/core/layout/processor.d.ts +0 -28
- package/dist/core/layout/result.d.ts +0 -12
- package/dist/core/layout/template.d.ts +0 -12
- package/dist/core/layout/types.d.ts +0 -137
- package/dist/core/layout/utils.d.ts +0 -38
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* API configuration options for
|
|
2
|
+
* API configuration options for List component
|
|
3
3
|
*/
|
|
4
4
|
interface ApiOptions {
|
|
5
5
|
list: {
|
|
6
|
-
refresh: () =>
|
|
7
|
-
|
|
8
|
-
hasNext: boolean;
|
|
9
|
-
items: any[];
|
|
10
|
-
}>;
|
|
11
|
-
scrollToItem: (itemId: string, position?: 'start' | 'center' | 'end') => void;
|
|
12
|
-
getVisibleItems: () => any[];
|
|
6
|
+
refresh: () => void;
|
|
7
|
+
getItems: () => any[];
|
|
13
8
|
getAllItems: () => any[];
|
|
9
|
+
getVisibleItems: () => any[];
|
|
10
|
+
scrollToItem: (itemId: string | number, position?: "start" | "center" | "end", animate?: boolean) => void;
|
|
11
|
+
scrollToIndex: (index: number, position?: "start" | "center" | "end", animate?: boolean) => void;
|
|
14
12
|
isLoading: () => boolean;
|
|
15
13
|
hasNextPage: () => boolean;
|
|
16
14
|
};
|
|
15
|
+
selection: {
|
|
16
|
+
getSelectedItems: () => any[];
|
|
17
|
+
getSelectedItemIds: () => string[];
|
|
18
|
+
isItemSelected: (itemId: string | number) => boolean;
|
|
19
|
+
selectItem: (itemId: string | number) => any;
|
|
20
|
+
deselectItem: (itemId: string | number) => any;
|
|
21
|
+
clearSelection: () => any;
|
|
22
|
+
setSelection: (itemIds: (string | number)[]) => any;
|
|
23
|
+
};
|
|
17
24
|
events: {
|
|
18
25
|
on: (event: string, handler: Function) => any;
|
|
19
26
|
off: (event: string, handler: Function) => any;
|
|
@@ -21,13 +28,9 @@ interface ApiOptions {
|
|
|
21
28
|
lifecycle: {
|
|
22
29
|
destroy: () => void;
|
|
23
30
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
selectItem?: (itemId: string) => any;
|
|
28
|
-
deselectItem?: (itemId: string) => any;
|
|
29
|
-
clearSelection?: () => any;
|
|
30
|
-
setSelection?: (itemIds: string[]) => any;
|
|
31
|
+
config: {
|
|
32
|
+
animate?: boolean;
|
|
33
|
+
};
|
|
31
34
|
}
|
|
32
35
|
/**
|
|
33
36
|
* Component with required elements and methods for API enhancement
|
|
@@ -38,52 +41,92 @@ interface ComponentWithElements {
|
|
|
38
41
|
off?: (event: string, handler: Function) => any;
|
|
39
42
|
}
|
|
40
43
|
/**
|
|
41
|
-
* Enhances a
|
|
44
|
+
* Enhances a List component with API methods
|
|
42
45
|
* @param {ApiOptions} options - API configuration options
|
|
43
46
|
* @returns {Function} Higher-order function that adds API methods to component
|
|
44
47
|
*/
|
|
45
|
-
export declare const withAPI: ({ list, events, lifecycle }: ApiOptions) => (component: ComponentWithElements) => {
|
|
48
|
+
export declare const withAPI: ({ list, selection, events, lifecycle, config }: ApiOptions) => (component: ComponentWithElements) => {
|
|
46
49
|
element: HTMLElement;
|
|
47
50
|
/**
|
|
48
|
-
* Refreshes the list
|
|
49
|
-
* @returns {Promise<
|
|
51
|
+
* Refreshes the list display
|
|
52
|
+
* @returns {Promise<Object>} Promise that resolves with component
|
|
50
53
|
*/
|
|
51
54
|
refresh: () => Promise<ComponentWithElements>;
|
|
52
55
|
/**
|
|
53
|
-
*
|
|
54
|
-
* @returns {
|
|
56
|
+
* Gets all items in the list
|
|
57
|
+
* @returns {Array} All items
|
|
55
58
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
getAllItems: () => any[];
|
|
60
|
+
/**
|
|
61
|
+
* Gets all visible items (same as getAllItems for rendered lists)
|
|
62
|
+
* @returns {Array} Visible items
|
|
63
|
+
*/
|
|
64
|
+
getVisibleItems: () => any[];
|
|
60
65
|
/**
|
|
61
66
|
* Scrolls to a specific item by ID
|
|
62
|
-
* @param {string} itemId - Item ID to scroll to
|
|
67
|
+
* @param {string|number} itemId - Item ID to scroll to
|
|
63
68
|
* @param {string} position - Position ('start', 'center', 'end')
|
|
69
|
+
* @param {boolean} animate - Whether to animate the scroll
|
|
64
70
|
* @returns {Object} Component instance for chaining
|
|
65
71
|
*/
|
|
66
|
-
scrollToItem: (itemId: string, position?: "start" | "center" | "end") => ComponentWithElements;
|
|
72
|
+
scrollToItem: (itemId: string | number, position?: "start" | "center" | "end", animate?: boolean) => ComponentWithElements;
|
|
67
73
|
/**
|
|
68
|
-
*
|
|
69
|
-
* @
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
* Gets all loaded items
|
|
74
|
-
* @returns {Array} All loaded items
|
|
74
|
+
* Scrolls to a specific index
|
|
75
|
+
* @param {number} index - Index to scroll to
|
|
76
|
+
* @param {string} position - Position ('start', 'center', 'end')
|
|
77
|
+
* @param {boolean} animate - Whether to animate the scroll
|
|
78
|
+
* @returns {Promise<Object>} Promise that resolves when scroll is complete
|
|
75
79
|
*/
|
|
76
|
-
|
|
80
|
+
scrollToIndex: (index: number, position?: "start" | "center" | "end", animate?: boolean) => Promise<ComponentWithElements>;
|
|
77
81
|
/**
|
|
78
|
-
* Checks if the list is currently loading
|
|
79
|
-
* @returns {boolean}
|
|
82
|
+
* Checks if the list is currently loading (always false for rendered lists)
|
|
83
|
+
* @returns {boolean} Always false
|
|
80
84
|
*/
|
|
81
85
|
isLoading: () => boolean;
|
|
82
86
|
/**
|
|
83
|
-
* Checks if the list has more items to load
|
|
84
|
-
* @returns {boolean}
|
|
87
|
+
* Checks if the list has more items to load (always false for rendered lists)
|
|
88
|
+
* @returns {boolean} Always false
|
|
85
89
|
*/
|
|
86
90
|
hasNextPage: () => boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Gets the currently selected items
|
|
93
|
+
* @returns {Array} Selected items
|
|
94
|
+
*/
|
|
95
|
+
getSelectedItems: () => any[];
|
|
96
|
+
/**
|
|
97
|
+
* Gets the IDs of currently selected items
|
|
98
|
+
* @returns {Array} Selected item IDs
|
|
99
|
+
*/
|
|
100
|
+
getSelectedItemIds: () => string[];
|
|
101
|
+
/**
|
|
102
|
+
* Checks if an item is selected
|
|
103
|
+
* @param {string|number} itemId - Item ID to check
|
|
104
|
+
* @returns {boolean} True if item is selected
|
|
105
|
+
*/
|
|
106
|
+
isItemSelected: (itemId: string | number) => boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Selects an item
|
|
109
|
+
* @param {string|number} itemId - Item ID to select
|
|
110
|
+
* @returns {Object} Component instance for chaining
|
|
111
|
+
*/
|
|
112
|
+
selectItem: (itemId: string | number) => ComponentWithElements;
|
|
113
|
+
/**
|
|
114
|
+
* Deselects an item
|
|
115
|
+
* @param {string|number} itemId - Item ID to deselect
|
|
116
|
+
* @returns {Object} Component instance for chaining
|
|
117
|
+
*/
|
|
118
|
+
deselectItem: (itemId: string | number) => ComponentWithElements;
|
|
119
|
+
/**
|
|
120
|
+
* Clears all selections
|
|
121
|
+
* @returns {Object} Component instance for chaining
|
|
122
|
+
*/
|
|
123
|
+
clearSelection: () => ComponentWithElements;
|
|
124
|
+
/**
|
|
125
|
+
* Sets the selection to the specified item IDs
|
|
126
|
+
* @param {Array} itemIds - Item IDs to select
|
|
127
|
+
* @returns {Object} Component instance for chaining
|
|
128
|
+
*/
|
|
129
|
+
setSelection: (itemIds: (string | number)[]) => ComponentWithElements;
|
|
87
130
|
/**
|
|
88
131
|
* Adds an event listener to the list
|
|
89
132
|
* @param {string} event - Event name
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
import { ListConfig } from
|
|
1
|
+
import { ListConfig } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Default configuration for the List component
|
|
4
4
|
*/
|
|
5
|
-
export declare const defaultConfig:
|
|
6
|
-
collection: "items";
|
|
7
|
-
transform: (item: any) => any;
|
|
8
|
-
baseUrl: "http://localhost:4000/api";
|
|
9
|
-
items: any[];
|
|
10
|
-
pageSize: 20;
|
|
11
|
-
renderBufferSize: 5;
|
|
12
|
-
renderItem: any;
|
|
13
|
-
trackSelection: boolean;
|
|
14
|
-
multiSelect: boolean;
|
|
15
|
-
};
|
|
5
|
+
export declare const defaultConfig: Partial<ListConfig>;
|
|
16
6
|
/**
|
|
17
7
|
* Creates the base configuration for List component
|
|
18
8
|
* @param {ListConfig} config - User provided configuration
|
|
@@ -37,18 +27,29 @@ export declare const getElementConfig: (config: any) => {
|
|
|
37
27
|
};
|
|
38
28
|
/**
|
|
39
29
|
* Creates API configuration for the List component
|
|
40
|
-
* @param {Object} component - Component with list
|
|
30
|
+
* @param {Object} component - Component with list features
|
|
31
|
+
* @param {Object} config - Base configuration
|
|
41
32
|
* @returns {Object} API configuration object
|
|
42
33
|
*/
|
|
43
|
-
export declare const getApiConfig: (component: any) => {
|
|
34
|
+
export declare const getApiConfig: (component: any, config: any) => {
|
|
44
35
|
list: {
|
|
45
36
|
refresh: any;
|
|
46
|
-
|
|
47
|
-
scrollToItem: any;
|
|
48
|
-
getVisibleItems: any;
|
|
37
|
+
getItems: any;
|
|
49
38
|
getAllItems: any;
|
|
50
|
-
|
|
51
|
-
|
|
39
|
+
getVisibleItems: any;
|
|
40
|
+
scrollToItem: any;
|
|
41
|
+
scrollToIndex: any;
|
|
42
|
+
isLoading: () => boolean;
|
|
43
|
+
hasNextPage: () => boolean;
|
|
44
|
+
};
|
|
45
|
+
selection: {
|
|
46
|
+
getSelectedItems: any;
|
|
47
|
+
getSelectedItemIds: any;
|
|
48
|
+
isItemSelected: any;
|
|
49
|
+
selectItem: any;
|
|
50
|
+
deselectItem: any;
|
|
51
|
+
clearSelection: any;
|
|
52
|
+
setSelection: any;
|
|
52
53
|
};
|
|
53
54
|
events: {
|
|
54
55
|
on: any;
|
|
@@ -57,5 +58,8 @@ export declare const getApiConfig: (component: any) => {
|
|
|
57
58
|
lifecycle: {
|
|
58
59
|
destroy: any;
|
|
59
60
|
};
|
|
61
|
+
config: {
|
|
62
|
+
animate: any;
|
|
63
|
+
};
|
|
60
64
|
};
|
|
61
65
|
export default defaultConfig;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as
|
|
1
|
+
export { default as withRenderer } from './renderer';
|
|
2
2
|
export { default as withSelection } from './selection';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds item rendering capabilities to a component
|
|
3
|
+
* Renders static data directly without virtual scrolling or complex management
|
|
4
|
+
*
|
|
5
|
+
* @param config - Configuration options
|
|
6
|
+
* @returns Function that enhances a component with item rendering capabilities
|
|
7
|
+
*/
|
|
8
|
+
export declare const withRenderer: (config: any) => (component: any) => any;
|
|
9
|
+
export default withRenderer;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Adds selection management capabilities to a list component
|
|
3
|
-
*
|
|
3
|
+
* Simplified implementation for rendered lists
|
|
4
4
|
*
|
|
5
5
|
* @param config - Configuration options
|
|
6
6
|
* @returns Function that enhances a component with selection management
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Creates a new List component
|
|
3
3
|
*
|
|
4
|
-
* The List component provides a
|
|
5
|
-
* with built-in
|
|
4
|
+
* The List component provides a simple way to render static arrays of data
|
|
5
|
+
* with built-in selection capabilities. For virtual scrolling and complex
|
|
6
|
+
* data management, use the VirtualList component from mtrl-addons.
|
|
6
7
|
*
|
|
7
8
|
* @param {Object} config - Configuration options for the list
|
|
8
9
|
* @returns {Object} List component instance
|
|
@@ -3,56 +3,18 @@
|
|
|
3
3
|
* @interface ListConfig
|
|
4
4
|
*/
|
|
5
5
|
export interface ListConfig {
|
|
6
|
-
/**
|
|
7
|
-
* Collection name to fetch data from
|
|
8
|
-
* @default 'items'
|
|
9
|
-
*/
|
|
10
|
-
collection?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Transform function for API items
|
|
13
|
-
* @param {any} item - Raw item from API
|
|
14
|
-
* @returns {any} Transformed item
|
|
15
|
-
*/
|
|
16
|
-
transform?: (item: any) => any;
|
|
17
|
-
/**
|
|
18
|
-
* Base URL for API requests
|
|
19
|
-
* @default 'http://localhost:4000/api'
|
|
20
|
-
*/
|
|
21
|
-
baseUrl?: string;
|
|
22
6
|
/**
|
|
23
7
|
* Static array of items to display
|
|
24
|
-
* @
|
|
25
|
-
*/
|
|
26
|
-
items?: any[];
|
|
27
|
-
/**
|
|
28
|
-
* Default height for items in pixels
|
|
29
|
-
* This is used for calculation before actual measurement
|
|
30
|
-
* @default 48
|
|
8
|
+
* @required
|
|
31
9
|
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Number of items to fetch per page
|
|
35
|
-
* @default 20
|
|
36
|
-
*/
|
|
37
|
-
pageSize?: number;
|
|
38
|
-
/**
|
|
39
|
-
* Number of extra items to render above/below viewport
|
|
40
|
-
* Higher values reduce blank spaces during fast scrolling but impact performance
|
|
41
|
-
* @default 5
|
|
42
|
-
*/
|
|
43
|
-
renderBufferSize?: number;
|
|
10
|
+
items: any[];
|
|
44
11
|
/**
|
|
45
12
|
* Function to render an item
|
|
46
13
|
* @param {any} item - Item to render
|
|
47
14
|
* @param {number} index - Item index in the list
|
|
48
15
|
* @returns {HTMLElement} Rendered DOM element
|
|
49
16
|
*/
|
|
50
|
-
renderItem
|
|
51
|
-
/**
|
|
52
|
-
* Callback when items are loaded
|
|
53
|
-
* @param {Object} data - Load result data
|
|
54
|
-
*/
|
|
55
|
-
afterLoad?: (data: LoadResult) => void;
|
|
17
|
+
renderItem?: (item: any, index: number) => HTMLElement;
|
|
56
18
|
/**
|
|
57
19
|
* Whether to track item selection
|
|
58
20
|
* When true, clicked items will receive a selected class
|
|
@@ -67,7 +29,7 @@ export interface ListConfig {
|
|
|
67
29
|
/**
|
|
68
30
|
* Initial selection state (array of item IDs)
|
|
69
31
|
*/
|
|
70
|
-
initialSelection?: string[];
|
|
32
|
+
initialSelection?: (string | number)[];
|
|
71
33
|
/**
|
|
72
34
|
* ARIA label for accessibility
|
|
73
35
|
*/
|
|
@@ -76,32 +38,22 @@ export interface ListConfig {
|
|
|
76
38
|
* Additional CSS classes
|
|
77
39
|
*/
|
|
78
40
|
class?: string;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Result of a load operation
|
|
82
|
-
* @interface LoadResult
|
|
83
|
-
*/
|
|
84
|
-
export interface LoadResult {
|
|
85
|
-
/**
|
|
86
|
-
* Whether the list is currently loading
|
|
87
|
-
*/
|
|
88
|
-
loading: boolean;
|
|
89
41
|
/**
|
|
90
|
-
*
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Whether there are previous items (if paginating)
|
|
42
|
+
* Default animation behavior for scroll operations
|
|
43
|
+
* When true, scroll operations will be animated by default
|
|
44
|
+
* @default false
|
|
95
45
|
*/
|
|
96
|
-
|
|
46
|
+
animate?: boolean;
|
|
97
47
|
/**
|
|
98
|
-
*
|
|
48
|
+
* Component prefix for CSS class names
|
|
49
|
+
* @default 'mtrl'
|
|
99
50
|
*/
|
|
100
|
-
|
|
51
|
+
prefix?: string;
|
|
101
52
|
/**
|
|
102
|
-
*
|
|
53
|
+
* Component name used in CSS class generation
|
|
54
|
+
* @default 'list'
|
|
103
55
|
*/
|
|
104
|
-
|
|
56
|
+
componentName?: string;
|
|
105
57
|
}
|
|
106
58
|
/**
|
|
107
59
|
* Selection event data
|
|
@@ -137,41 +89,35 @@ export interface SelectEvent {
|
|
|
137
89
|
* Load event data
|
|
138
90
|
* @interface LoadEvent
|
|
139
91
|
*/
|
|
140
|
-
export interface LoadEvent
|
|
92
|
+
export interface LoadEvent {
|
|
141
93
|
/**
|
|
142
|
-
*
|
|
94
|
+
* Loaded items
|
|
143
95
|
*/
|
|
144
|
-
|
|
96
|
+
items: any[];
|
|
145
97
|
/**
|
|
146
|
-
*
|
|
98
|
+
* Whether the list is currently loading
|
|
147
99
|
*/
|
|
148
|
-
|
|
100
|
+
loading: boolean;
|
|
149
101
|
/**
|
|
150
|
-
* Whether
|
|
102
|
+
* Whether there are more items to load
|
|
151
103
|
*/
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Virtual List component interface - enhanced list with virtual scrolling
|
|
156
|
-
* @interface VirtualListComponent
|
|
157
|
-
*/
|
|
158
|
-
export interface VirtualListComponent extends ListComponent {
|
|
104
|
+
hasNext: boolean;
|
|
159
105
|
/**
|
|
160
|
-
*
|
|
161
|
-
|
|
106
|
+
* Whether there are previous items
|
|
107
|
+
*/
|
|
108
|
+
hasPrev: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Component instance
|
|
162
111
|
*/
|
|
163
|
-
|
|
112
|
+
component: ListComponent;
|
|
164
113
|
/**
|
|
165
|
-
*
|
|
166
|
-
* @returns {number} Current scroll position
|
|
114
|
+
* Prevent default behavior
|
|
167
115
|
*/
|
|
168
|
-
|
|
116
|
+
preventDefault?: () => void;
|
|
169
117
|
/**
|
|
170
|
-
*
|
|
171
|
-
* @param {number} scrollTop - Scroll position to set
|
|
172
|
-
* @returns {VirtualListComponent} Component instance for chaining
|
|
118
|
+
* Whether default was prevented
|
|
173
119
|
*/
|
|
174
|
-
|
|
120
|
+
defaultPrevented?: boolean;
|
|
175
121
|
}
|
|
176
122
|
/**
|
|
177
123
|
* List component interface
|
|
@@ -183,43 +129,44 @@ export interface ListComponent {
|
|
|
183
129
|
*/
|
|
184
130
|
element: HTMLElement;
|
|
185
131
|
/**
|
|
186
|
-
* Refreshes the list
|
|
187
|
-
* @returns {Promise<
|
|
188
|
-
*/
|
|
189
|
-
refresh: () => Promise<VirtualListComponent>;
|
|
190
|
-
/**
|
|
191
|
-
* Loads more items
|
|
192
|
-
* @returns {Promise<{hasNext: boolean, items: any[]}>} Promise with load result
|
|
132
|
+
* Refreshes the list display
|
|
133
|
+
* @returns {Promise<ListComponent>} Promise that resolves with component
|
|
193
134
|
*/
|
|
194
|
-
|
|
195
|
-
hasNext: boolean;
|
|
196
|
-
items: any[];
|
|
197
|
-
}>;
|
|
135
|
+
refresh: () => Promise<ListComponent>;
|
|
198
136
|
/**
|
|
199
|
-
*
|
|
200
|
-
* @
|
|
201
|
-
* @param {string} position - Position ('start', 'center', 'end')
|
|
202
|
-
* @returns {VirtualListComponent} Component instance for chaining
|
|
137
|
+
* Gets all items in the list
|
|
138
|
+
* @returns {any[]} All items
|
|
203
139
|
*/
|
|
204
|
-
|
|
140
|
+
getAllItems: () => any[];
|
|
205
141
|
/**
|
|
206
|
-
* Gets all
|
|
142
|
+
* Gets all visible items (same as getAllItems for rendered lists)
|
|
207
143
|
* @returns {any[]} Visible items
|
|
208
144
|
*/
|
|
209
145
|
getVisibleItems: () => any[];
|
|
210
146
|
/**
|
|
211
|
-
*
|
|
212
|
-
* @
|
|
147
|
+
* Scrolls to a specific item by ID
|
|
148
|
+
* @param {string | number} itemId - Item ID to scroll to
|
|
149
|
+
* @param {string} position - Position ('start', 'center', 'end')
|
|
150
|
+
* @param {boolean} animate - Whether to animate the scroll
|
|
151
|
+
* @returns {ListComponent} Component instance for chaining
|
|
213
152
|
*/
|
|
214
|
-
|
|
153
|
+
scrollToItem: (itemId: string | number, position?: "start" | "center" | "end", animate?: boolean) => ListComponent;
|
|
154
|
+
/**
|
|
155
|
+
* Scroll to a specific index in the list
|
|
156
|
+
* @param {number} index - Index to scroll to (0-based)
|
|
157
|
+
* @param {string} position - Position ('start', 'center', 'end')
|
|
158
|
+
* @param {boolean} animate - Whether to animate the scroll
|
|
159
|
+
* @returns {Promise<ListComponent>} Promise that resolves when scroll is complete
|
|
160
|
+
*/
|
|
161
|
+
scrollToIndex: (index: number, position?: "start" | "center" | "end", animate?: boolean) => Promise<ListComponent>;
|
|
215
162
|
/**
|
|
216
|
-
* Checks if the list is currently loading
|
|
217
|
-
* @returns {boolean}
|
|
163
|
+
* Checks if the list is currently loading (always false for rendered lists)
|
|
164
|
+
* @returns {boolean} Always false
|
|
218
165
|
*/
|
|
219
166
|
isLoading: () => boolean;
|
|
220
167
|
/**
|
|
221
|
-
* Checks if the list has more items to load
|
|
222
|
-
* @returns {boolean}
|
|
168
|
+
* Checks if the list has more items to load (always false for rendered lists)
|
|
169
|
+
* @returns {boolean} Always false
|
|
223
170
|
*/
|
|
224
171
|
hasNextPage: () => boolean;
|
|
225
172
|
/**
|
|
@@ -234,22 +181,22 @@ export interface ListComponent {
|
|
|
234
181
|
getSelectedItemIds: () => string[];
|
|
235
182
|
/**
|
|
236
183
|
* Checks if an item is selected
|
|
237
|
-
* @param {string} itemId - Item ID to check
|
|
184
|
+
* @param {string | number} itemId - Item ID to check
|
|
238
185
|
* @returns {boolean} True if item is selected
|
|
239
186
|
*/
|
|
240
|
-
isItemSelected: (itemId: string) => boolean;
|
|
187
|
+
isItemSelected: (itemId: string | number) => boolean;
|
|
241
188
|
/**
|
|
242
189
|
* Selects an item
|
|
243
|
-
* @param {string} itemId - Item ID to select
|
|
190
|
+
* @param {string | number} itemId - Item ID to select
|
|
244
191
|
* @returns {ListComponent} Component instance for chaining
|
|
245
192
|
*/
|
|
246
|
-
selectItem: (itemId: string) => ListComponent;
|
|
193
|
+
selectItem: (itemId: string | number) => ListComponent;
|
|
247
194
|
/**
|
|
248
195
|
* Deselects an item
|
|
249
|
-
* @param {string} itemId - Item ID to deselect
|
|
196
|
+
* @param {string | number} itemId - Item ID to deselect
|
|
250
197
|
* @returns {ListComponent} Component instance for chaining
|
|
251
198
|
*/
|
|
252
|
-
deselectItem: (itemId: string) => ListComponent;
|
|
199
|
+
deselectItem: (itemId: string | number) => ListComponent;
|
|
253
200
|
/**
|
|
254
201
|
* Clears all selections
|
|
255
202
|
* @returns {ListComponent} Component instance for chaining
|
|
@@ -257,10 +204,10 @@ export interface ListComponent {
|
|
|
257
204
|
clearSelection: () => ListComponent;
|
|
258
205
|
/**
|
|
259
206
|
* Sets the selection to the specified item IDs
|
|
260
|
-
* @param {string[]} itemIds - Item IDs to select
|
|
207
|
+
* @param {(string | number)[]} itemIds - Item IDs to select
|
|
261
208
|
* @returns {ListComponent} Component instance for chaining
|
|
262
209
|
*/
|
|
263
|
-
setSelection: (itemIds: string[]) => ListComponent;
|
|
210
|
+
setSelection: (itemIds: (string | number)[]) => ListComponent;
|
|
264
211
|
/**
|
|
265
212
|
* Adds an event listener to the list
|
|
266
213
|
* @param {string} event - Event name
|
|
@@ -285,10 +232,10 @@ export interface ListComponent {
|
|
|
285
232
|
* @interface ListEvents
|
|
286
233
|
*/
|
|
287
234
|
export interface ListEvents {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
235
|
+
select: (event: SelectEvent) => void;
|
|
236
|
+
load: (event: LoadEvent) => void;
|
|
237
|
+
scroll: (event: {
|
|
291
238
|
originalEvent: Event;
|
|
292
|
-
component:
|
|
239
|
+
component: ListComponent;
|
|
293
240
|
}) => void;
|
|
294
241
|
}
|
|
@@ -105,9 +105,9 @@ export declare const PROGRESS_WAVE: {
|
|
|
105
105
|
/** Linear progress wave parameters */
|
|
106
106
|
readonly LINEAR: {
|
|
107
107
|
/** Base amplitude of the wave in pixels */
|
|
108
|
-
readonly AMPLITUDE:
|
|
108
|
+
readonly AMPLITUDE: 4;
|
|
109
109
|
/** Speed of wave animation in waves per second (Hz) */
|
|
110
|
-
readonly SPEED:
|
|
110
|
+
readonly SPEED: 1;
|
|
111
111
|
/** Number of complete waves per 100 pixels */
|
|
112
112
|
readonly FREQUENCY: 2;
|
|
113
113
|
/** Number of complete waves per 100 pixels for indeterminate */
|
|
@@ -128,7 +128,7 @@ export declare const PROGRESS_WAVE: {
|
|
|
128
128
|
/** Amplitude as percentage of radius for indeterminate (4 = 4%) */
|
|
129
129
|
readonly INDETERMINATE_AMPLITUDE: 4;
|
|
130
130
|
/** Speed of wave rotation in rotations per second (Hz), negative value means clockwise */
|
|
131
|
-
readonly SPEED: 1
|
|
131
|
+
readonly SPEED: 1;
|
|
132
132
|
/** Number of complete waves around the circle */
|
|
133
133
|
readonly FREQUENCY: 10;
|
|
134
134
|
/** Number of complete waves for indeterminate animation */
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SliderConfig } from "../types";
|
|
2
|
+
import { ElementComponent } from "../../../core/compose/component";
|
|
3
|
+
/**
|
|
4
|
+
* Creates the inner slider DOM structure using optimized createElement
|
|
5
|
+
* This works alongside withElement to create slider-specific inner elements
|
|
6
|
+
*
|
|
7
|
+
* @param config Slider configuration
|
|
8
|
+
* @returns Component enhancement function
|
|
9
|
+
*/
|
|
10
|
+
export declare const withDom: (config: SliderConfig) => <T extends ElementComponent>(component: T) => T & {
|
|
11
|
+
container: HTMLElement;
|
|
12
|
+
handle: HTMLElement;
|
|
13
|
+
valueBubble: HTMLElement;
|
|
14
|
+
secondHandle?: HTMLElement;
|
|
15
|
+
secondValueBubble?: HTMLElement;
|
|
16
|
+
getContainer: () => HTMLElement;
|
|
17
|
+
getHandle: () => HTMLElement;
|
|
18
|
+
getValueBubble: () => HTMLElement;
|
|
19
|
+
getSecondHandle?: () => HTMLElement | null;
|
|
20
|
+
getSecondValueBubble?: () => HTMLElement | null;
|
|
21
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { withRange } from
|
|
2
|
-
export { withStates } from
|
|
3
|
-
export { withController } from
|
|
4
|
-
export { withCanvas } from
|
|
1
|
+
export { withRange } from "./range";
|
|
2
|
+
export { withStates } from "./states";
|
|
3
|
+
export { withController } from "./controller";
|
|
4
|
+
export { withCanvas } from "./canvas";
|
|
5
|
+
export { withDom } from "./dom";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { SliderConfig, SliderComponent } from
|
|
1
|
+
import { SliderConfig, SliderComponent } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Creates a new Slider component
|
|
4
4
|
*
|
|
5
5
|
* Slider follows a clear architectural pattern:
|
|
6
|
-
* 1.
|
|
7
|
-
* 2. Feature enhancement - Adds specific capabilities (range, icons
|
|
8
|
-
* 3. DOM creation -
|
|
6
|
+
* 1. Base component - Creates the foundation with event system
|
|
7
|
+
* 2. Feature enhancement - Adds specific capabilities (range, icons)
|
|
8
|
+
* 3. DOM creation - Creates DOM elements directly using optimized createElement
|
|
9
9
|
* 4. Canvas rendering - Uses canvas for visual elements, keeping handles as DOM
|
|
10
10
|
* 5. State management - Handles visual states and appearance
|
|
11
11
|
* 6. Controller - Manages behavior, events, and UI rendering
|
|
@@ -8,6 +8,8 @@ type ComponentWithDensity = BaseComponent & {
|
|
|
8
8
|
set: (density: string) => void;
|
|
9
9
|
};
|
|
10
10
|
updateElementPositions?: () => void;
|
|
11
|
+
setError?: (error: boolean, message?: string) => any;
|
|
12
|
+
isError?: () => boolean;
|
|
11
13
|
};
|
|
12
14
|
/**
|
|
13
15
|
* Enhances textfield component with API methods
|