@casinogate/ui 1.9.7 → 1.9.9
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.
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
initialItems = [],
|
|
41
41
|
loadImmediate = true,
|
|
42
42
|
dependsOn,
|
|
43
|
+
onChangeDependency,
|
|
43
44
|
clearOnDependencyChange = true,
|
|
44
45
|
|
|
45
46
|
...restProps
|
|
@@ -114,11 +115,6 @@
|
|
|
114
115
|
|
|
115
116
|
currentPage = page;
|
|
116
117
|
hasMore = result.hasMore;
|
|
117
|
-
|
|
118
|
-
// Check if viewport needs more items after render
|
|
119
|
-
requestAnimationFrame(() => {
|
|
120
|
-
checkNeedMoreItems();
|
|
121
|
-
});
|
|
122
118
|
} catch (err) {
|
|
123
119
|
error = err instanceof Error ? err.message : 'Failed to fetch data';
|
|
124
120
|
} finally {
|
|
@@ -126,34 +122,15 @@
|
|
|
126
122
|
}
|
|
127
123
|
};
|
|
128
124
|
|
|
129
|
-
//
|
|
130
|
-
const checkNeedMoreItems = () => {
|
|
131
|
-
if (!viewportRef || isLoading || !hasMore) return;
|
|
132
|
-
|
|
133
|
-
const { scrollHeight, clientHeight } = viewportRef;
|
|
134
|
-
|
|
135
|
-
// If content doesn't fill viewport, load more
|
|
136
|
-
if (scrollHeight <= clientHeight) {
|
|
137
|
-
loadMore();
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
// Fetch on first open or check viewport fill
|
|
125
|
+
// Fetch on first open
|
|
142
126
|
watch(
|
|
143
127
|
() => open,
|
|
144
128
|
() => {
|
|
145
129
|
if (!open) return;
|
|
146
130
|
|
|
147
|
-
|
|
148
|
-
if (items.length === 0 && !isLoading && !loadImmediate) {
|
|
149
|
-
fetchData(1);
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
131
|
+
if (isLoading || items.length > 0 || loadImmediate) return;
|
|
152
132
|
|
|
153
|
-
|
|
154
|
-
requestAnimationFrame(() => {
|
|
155
|
-
checkNeedMoreItems();
|
|
156
|
-
});
|
|
133
|
+
fetchData(1);
|
|
157
134
|
}
|
|
158
135
|
);
|
|
159
136
|
|
|
@@ -172,13 +149,14 @@
|
|
|
172
149
|
// Watch for dependency changes and reset
|
|
173
150
|
let previousDependency = $state<unknown>(dependsOn?.());
|
|
174
151
|
watch(
|
|
175
|
-
() => dependsOn?.(),
|
|
152
|
+
() => $state.snapshot(dependsOn?.()),
|
|
176
153
|
(newValue) => {
|
|
177
|
-
if (previousDependency === undefined && newValue === undefined) return;
|
|
178
154
|
if (previousDependency === newValue) return;
|
|
179
155
|
|
|
180
156
|
previousDependency = newValue;
|
|
181
157
|
|
|
158
|
+
onChangeDependency?.(newValue);
|
|
159
|
+
|
|
182
160
|
// Reset state
|
|
183
161
|
items = [];
|
|
184
162
|
currentPage = 1;
|
|
@@ -192,6 +170,9 @@
|
|
|
192
170
|
|
|
193
171
|
// Reload data
|
|
194
172
|
fetchData(1);
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
lazy: true,
|
|
195
176
|
}
|
|
196
177
|
);
|
|
197
178
|
|
|
@@ -116,4 +116,8 @@ export type SelectAsyncProps = Omit<SelectProps, 'collection'> & {
|
|
|
116
116
|
* Whether to clear the selected value when dependsOn changes **(default: true)**
|
|
117
117
|
*/
|
|
118
118
|
clearOnDependencyChange?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Callback when dependsOn changes
|
|
121
|
+
*/
|
|
122
|
+
onChangeDependency?: (value: unknown) => void;
|
|
119
123
|
};
|