@moontra/moonui 2.2.0 → 2.2.2
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/dist/index.d.mts +91 -14
- package/dist/index.d.ts +91 -14
- package/dist/index.js +1714 -369
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1546 -371
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/components/ui/alert.tsx +123 -93
- package/src/components/ui/avatar.tsx +2 -0
- package/src/components/ui/badge.tsx +19 -17
- package/src/components/ui/breadcrumb.tsx +2 -0
- package/src/components/ui/button.stories.tsx +4 -2
- package/src/components/ui/button.tsx +39 -33
- package/src/components/ui/calendar.tsx +1 -1
- package/src/components/ui/card-input.tsx +231 -0
- package/src/components/ui/card.stories.tsx +2 -0
- package/src/components/ui/card.tsx +2 -0
- package/src/components/ui/data-table.stories.tsx +4 -2
- package/src/components/ui/data-table.tsx +7 -7
- package/src/components/ui/date-picker.stories.tsx +2 -0
- package/src/components/ui/date-picker.tsx +18 -9
- package/src/components/ui/draggable-list.tsx +2 -0
- package/src/components/ui/index.ts +357 -44
- package/src/components/ui/input.stories.tsx +2 -0
- package/src/components/ui/input.tsx +2 -0
- package/src/components/ui/locked-component.tsx +222 -0
- package/src/components/ui/pagination.tsx +2 -0
- package/src/components/ui/phone-input.tsx +172 -0
- package/src/components/ui/popover-pro.tsx +424 -0
- package/src/components/ui/rich-text-editor/index.tsx +2 -1
- package/src/components/ui/scroll-area.tsx +48 -0
- package/src/components/ui/select.tsx +5 -1
- package/src/components/ui/separator.tsx +2 -2
- package/src/components/ui/swipeable-card.tsx +2 -0
- package/src/components/ui/table.tsx +2 -0
- package/src/components/ui/tabs.tsx +2 -0
- package/src/components/ui/tags-input.tsx +130 -0
- package/src/components/ui/textarea.tsx +2 -0
- package/src/components/ui/toast.tsx +2 -0
- package/src/index.tsx +4 -46
- package/src/lib/performance-profiler.ts +79 -0
- package/src/styles/index.css +315 -2
- package/src/use-performance-optimizer.ts +26 -26
- package/src/use-scroll-animation.ts +5 -7
|
@@ -19,11 +19,11 @@ export function usePerformanceOptimizer() {
|
|
|
19
19
|
const componentMetrics = performanceProfiler.getMeasurements('component');
|
|
20
20
|
if (componentMetrics.length > 0) {
|
|
21
21
|
const slowComponents = componentMetrics
|
|
22
|
-
.filter(m => m.duration > 16.67) // Slower than 60fps
|
|
23
|
-
.sort((a, b) => b.duration - a.duration)
|
|
22
|
+
.filter((m: any) => m.duration > 16.67) // Slower than 60fps
|
|
23
|
+
.sort((a: any, b: any) => b.duration - a.duration)
|
|
24
24
|
.slice(0, 5);
|
|
25
25
|
|
|
26
|
-
slowComponents.forEach(component => {
|
|
26
|
+
slowComponents.forEach((component: any) => {
|
|
27
27
|
suggestions.push({
|
|
28
28
|
type: 'component',
|
|
29
29
|
severity: component.duration > 50 ? 'high' : 'medium',
|
|
@@ -55,7 +55,7 @@ export function usePerformanceOptimizer() {
|
|
|
55
55
|
// Analyze layout shifts
|
|
56
56
|
const layoutShifts = performanceProfiler.getMeasurements('layout-shift');
|
|
57
57
|
if (layoutShifts.length > 0) {
|
|
58
|
-
const totalShift = layoutShifts.reduce((sum, shift) => sum + (shift.value || 0), 0);
|
|
58
|
+
const totalShift = layoutShifts.reduce((sum: any, shift: any) => sum + (shift.value || 0), 0);
|
|
59
59
|
|
|
60
60
|
if (totalShift > 0.1) {
|
|
61
61
|
suggestions.push({
|
|
@@ -112,9 +112,9 @@ export function useRenderOptimization<T>(
|
|
|
112
112
|
React.useEffect(() => {
|
|
113
113
|
if (process.env.NODE_ENV === 'development') {
|
|
114
114
|
const componentName = 'useRenderOptimization';
|
|
115
|
-
performanceProfiler.measureComponent(componentName
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
const endMeasure = performanceProfiler.measureComponent(componentName);
|
|
116
|
+
// Measure the impact of memoization
|
|
117
|
+
endMeasure();
|
|
118
118
|
}
|
|
119
119
|
}, dependencies);
|
|
120
120
|
|
|
@@ -126,7 +126,7 @@ export function useDebouncePerformance<T extends (...args: any[]) => void>(
|
|
|
126
126
|
callback: T,
|
|
127
127
|
delay: number = 300
|
|
128
128
|
): T {
|
|
129
|
-
const timeoutRef = React.useRef<NodeJS.Timeout>();
|
|
129
|
+
const timeoutRef = React.useRef<NodeJS.Timeout | undefined>(undefined);
|
|
130
130
|
|
|
131
131
|
const debouncedCallback = React.useCallback(
|
|
132
132
|
(...args: Parameters<T>) => {
|
|
@@ -135,9 +135,9 @@ export function useDebouncePerformance<T extends (...args: any[]) => void>(
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
timeoutRef.current = setTimeout(() => {
|
|
138
|
-
performanceProfiler.measureComponent('debounced-callback'
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
const endMeasure = performanceProfiler.measureComponent('debounced-callback');
|
|
139
|
+
callback(...args);
|
|
140
|
+
endMeasure();
|
|
141
141
|
}, delay);
|
|
142
142
|
},
|
|
143
143
|
[callback, delay]
|
|
@@ -167,9 +167,9 @@ export function useThrottlePerformance<T extends (...args: any[]) => void>(
|
|
|
167
167
|
|
|
168
168
|
if (now - lastCallRef.current >= delay) {
|
|
169
169
|
lastCallRef.current = now;
|
|
170
|
-
performanceProfiler.measureComponent('throttled-callback'
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
const endMeasure = performanceProfiler.measureComponent('throttled-callback');
|
|
171
|
+
callback(...args);
|
|
172
|
+
endMeasure();
|
|
173
173
|
}
|
|
174
174
|
},
|
|
175
175
|
[callback, delay]
|
|
@@ -187,16 +187,16 @@ export function useComponentLifecycleTracking(componentName: string) {
|
|
|
187
187
|
// Component mount
|
|
188
188
|
mountTime.current = performance.now();
|
|
189
189
|
|
|
190
|
-
performanceProfiler.measureComponent(`${componentName}-mount
|
|
191
|
-
|
|
192
|
-
|
|
190
|
+
const endMountMeasure = performanceProfiler.measureComponent(`${componentName}-mount`);
|
|
191
|
+
// Measure mount time
|
|
192
|
+
endMountMeasure();
|
|
193
193
|
|
|
194
194
|
return () => {
|
|
195
195
|
// Component unmount
|
|
196
196
|
const lifetime = performance.now() - mountTime.current;
|
|
197
|
-
performanceProfiler.measureComponent(`${componentName}-unmount
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
const endUnmountMeasure = performanceProfiler.measureComponent(`${componentName}-unmount`);
|
|
198
|
+
// Record component lifetime
|
|
199
|
+
endUnmountMeasure();
|
|
200
200
|
};
|
|
201
201
|
}, [componentName]);
|
|
202
202
|
|
|
@@ -205,9 +205,9 @@ export function useComponentLifecycleTracking(componentName: string) {
|
|
|
205
205
|
updateCount.current++;
|
|
206
206
|
|
|
207
207
|
if (updateCount.current > 1) {
|
|
208
|
-
performanceProfiler.measureComponent(`${componentName}-update
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
const endUpdateMeasure = performanceProfiler.measureComponent(`${componentName}-update`);
|
|
209
|
+
// Measure update time
|
|
210
|
+
endUpdateMeasure();
|
|
211
211
|
}
|
|
212
212
|
});
|
|
213
213
|
|
|
@@ -271,9 +271,9 @@ export function useLazyImageOptimization(src: string, threshold: number = 0.1) {
|
|
|
271
271
|
|
|
272
272
|
img.onload = () => {
|
|
273
273
|
const loadTime = performance.now() - startTime;
|
|
274
|
-
performanceProfiler.measureComponent('image-load'
|
|
275
|
-
|
|
276
|
-
|
|
274
|
+
const endImageMeasure = performanceProfiler.measureComponent('image-load');
|
|
275
|
+
// Record image load time
|
|
276
|
+
endImageMeasure();
|
|
277
277
|
setIsLoaded(true);
|
|
278
278
|
};
|
|
279
279
|
|
|
@@ -12,10 +12,9 @@ interface UseScrollAnimationOptions {
|
|
|
12
12
|
export function useScrollAnimation(options: UseScrollAnimationOptions = {}) {
|
|
13
13
|
const ref = useRef<HTMLElement>(null)
|
|
14
14
|
const isInView = useInView(ref, {
|
|
15
|
-
|
|
15
|
+
amount: options.threshold || 0.1,
|
|
16
16
|
once: options.triggerOnce ?? true,
|
|
17
|
-
|
|
18
|
-
})
|
|
17
|
+
} as any)
|
|
19
18
|
|
|
20
19
|
return { ref, isInView }
|
|
21
20
|
}
|
|
@@ -106,9 +105,8 @@ export function useInfiniteScroll(
|
|
|
106
105
|
) {
|
|
107
106
|
const ref = useRef<HTMLElement>(null)
|
|
108
107
|
const isInView = useInView(ref, {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
})
|
|
108
|
+
amount: options.threshold || 0.1,
|
|
109
|
+
} as any)
|
|
112
110
|
|
|
113
111
|
useEffect(() => {
|
|
114
112
|
if (isInView) {
|
|
@@ -153,7 +151,7 @@ export function useScrollTriggeredCounter(
|
|
|
153
151
|
const ref = useRef<HTMLElement>(null)
|
|
154
152
|
|
|
155
153
|
const isInView = useInView(ref, {
|
|
156
|
-
|
|
154
|
+
amount: 0.5,
|
|
157
155
|
once: true
|
|
158
156
|
})
|
|
159
157
|
|