@rakeyshgidwani/roger-ui-bank-theme-stan-design 0.2.6 → 0.2.8
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/CHANGELOG.md +1 -1
- package/dist/components/ui/accessibility-demo.d.ts +259 -0
- package/dist/components/ui/accessibility-demo.esm.js +265 -0
- package/dist/components/ui/accessibility-demo.js +265 -0
- package/dist/components/ui/advanced-component-architecture-demo.d.ts +718 -0
- package/dist/components/ui/advanced-component-architecture-demo.esm.js +860 -0
- package/dist/components/ui/advanced-component-architecture-demo.js +860 -0
- package/dist/components/ui/advanced-transition-system-demo.d.ts +660 -0
- package/dist/components/ui/advanced-transition-system-demo.esm.js +624 -0
- package/dist/components/ui/advanced-transition-system-demo.js +624 -0
- package/dist/components/ui/advanced-transition-system.d.ts +391 -0
- package/dist/components/ui/advanced-transition-system.esm.js +351 -0
- package/dist/components/ui/advanced-transition-system.js +351 -0
- package/dist/components/ui/animation/animated-container.d.ts +162 -0
- package/dist/components/ui/animation/animated-container.esm.js +143 -0
- package/dist/components/ui/animation/animated-container.js +143 -0
- package/dist/components/ui/animation/index.d.ts +9 -0
- package/dist/components/ui/animation/index.esm.js +19 -0
- package/dist/components/ui/animation/index.js +19 -0
- package/dist/components/ui/animation/staggered-container.d.ts +64 -0
- package/dist/components/ui/animation/staggered-container.esm.js +59 -0
- package/dist/components/ui/animation/staggered-container.js +59 -0
- package/dist/components/ui/animation-demo.d.ts +238 -0
- package/dist/components/ui/animation-demo.esm.js +218 -0
- package/dist/components/ui/animation-demo.js +218 -0
- package/dist/components/ui/badge.d.ts +28 -0
- package/dist/components/ui/badge.esm.js +30 -0
- package/dist/components/ui/badge.js +30 -0
- package/dist/components/ui/battery-conscious-animation-demo.d.ts +561 -0
- package/dist/components/ui/battery-conscious-animation-demo.esm.js +533 -0
- package/dist/components/ui/battery-conscious-animation-demo.js +533 -0
- package/dist/components/ui/border-radius-shadow-demo.d.ts +183 -0
- package/dist/components/ui/border-radius-shadow-demo.esm.js +176 -0
- package/dist/components/ui/border-radius-shadow-demo.js +176 -0
- package/dist/components/ui/button.d.ts +33 -0
- package/dist/components/ui/button.esm.js +30 -0
- package/dist/components/ui/button.js +30 -0
- package/dist/components/ui/card.d.ts +205 -0
- package/dist/components/ui/card.esm.js +182 -0
- package/dist/components/ui/card.js +182 -0
- package/dist/components/ui/checkbox.d.ts +26 -0
- package/dist/components/ui/checkbox.esm.js +30 -0
- package/dist/components/ui/checkbox.js +30 -0
- package/dist/components/ui/color-preview.d.ts +402 -0
- package/dist/components/ui/color-preview.esm.js +388 -0
- package/dist/components/ui/color-preview.js +388 -0
- package/dist/components/ui/data-display/chart.d.ts +646 -0
- package/dist/components/ui/data-display/chart.esm.js +625 -0
- package/dist/components/ui/data-display/chart.js +625 -0
- package/dist/components/ui/data-display/data-grid-simple.d.ts +73 -0
- package/dist/components/ui/data-display/data-grid-simple.esm.js +76 -0
- package/dist/components/ui/data-display/data-grid-simple.js +76 -0
- package/dist/components/ui/data-display/data-grid.d.ts +670 -0
- package/dist/components/ui/data-display/data-grid.esm.js +667 -0
- package/dist/components/ui/data-display/data-grid.js +667 -0
- package/dist/components/ui/data-display/list.d.ts +448 -0
- package/dist/components/ui/data-display/list.esm.js +448 -0
- package/dist/components/ui/data-display/list.js +448 -0
- package/dist/components/ui/data-display/table.d.ts +472 -0
- package/dist/components/ui/data-display/table.esm.js +474 -0
- package/dist/components/ui/data-display/table.js +474 -0
- package/dist/components/ui/data-display/timeline.d.ts +433 -0
- package/dist/components/ui/data-display/timeline.esm.js +436 -0
- package/dist/components/ui/data-display/timeline.js +436 -0
- package/dist/components/ui/data-display/tree.d.ts +594 -0
- package/dist/components/ui/data-display/tree.esm.js +570 -0
- package/dist/components/ui/data-display/tree.js +570 -0
- package/dist/components/ui/data-display/types.d.ts +534 -0
- package/dist/components/ui/data-display/types.esm.js +511 -0
- package/dist/components/ui/data-display/types.js +511 -0
- package/dist/components/ui/enterprise-mobile-experience-demo.d.ts +735 -0
- package/dist/components/ui/enterprise-mobile-experience-demo.esm.js +699 -0
- package/dist/components/ui/enterprise-mobile-experience-demo.js +699 -0
- package/dist/components/ui/enterprise-mobile-experience.d.ts +461 -0
- package/dist/components/ui/enterprise-mobile-experience.esm.js +413 -0
- package/dist/components/ui/enterprise-mobile-experience.js +413 -0
- package/dist/components/ui/feedback/alert.d.ts +154 -0
- package/dist/components/ui/feedback/alert.esm.js +150 -0
- package/dist/components/ui/feedback/alert.js +150 -0
- package/dist/components/ui/feedback/progress.d.ts +288 -0
- package/dist/components/ui/feedback/progress.esm.js +269 -0
- package/dist/components/ui/feedback/progress.js +269 -0
- package/dist/components/ui/feedback/skeleton.d.ts +182 -0
- package/dist/components/ui/feedback/skeleton.esm.js +175 -0
- package/dist/components/ui/feedback/skeleton.js +175 -0
- package/dist/components/ui/feedback/toast.d.ts +277 -0
- package/dist/components/ui/feedback/toast.esm.js +256 -0
- package/dist/components/ui/feedback/toast.js +256 -0
- package/dist/components/ui/feedback/types.d.ts +123 -0
- package/dist/components/ui/feedback/types.esm.js +125 -0
- package/dist/components/ui/feedback/types.js +125 -0
- package/dist/components/ui/font-preview.d.ts +282 -0
- package/dist/components/ui/font-preview.esm.js +286 -0
- package/dist/components/ui/font-preview.js +286 -0
- package/dist/components/ui/form-demo.d.ts +544 -0
- package/dist/components/ui/form-demo.esm.js +516 -0
- package/dist/components/ui/form-demo.js +516 -0
- package/dist/components/ui/hardware-acceleration-demo.d.ts +540 -0
- package/dist/components/ui/hardware-acceleration-demo.esm.js +497 -0
- package/dist/components/ui/hardware-acceleration-demo.js +497 -0
- package/dist/components/ui/input.d.ts +33 -0
- package/dist/components/ui/input.esm.js +32 -0
- package/dist/components/ui/input.js +32 -0
- package/dist/components/ui/label.d.ts +13 -0
- package/dist/components/ui/label.esm.js +16 -0
- package/dist/components/ui/label.js +16 -0
- package/dist/components/ui/layout-demo.d.ts +352 -0
- package/dist/components/ui/layout-demo.esm.js +342 -0
- package/dist/components/ui/layout-demo.js +342 -0
- package/dist/components/ui/layouts/adaptive-layout.d.ts +132 -0
- package/dist/components/ui/layouts/adaptive-layout.esm.js +120 -0
- package/dist/components/ui/layouts/adaptive-layout.js +120 -0
- package/dist/components/ui/layouts/desktop-layout.d.ts +219 -0
- package/dist/components/ui/layouts/desktop-layout.esm.js +204 -0
- package/dist/components/ui/layouts/desktop-layout.js +204 -0
- package/dist/components/ui/layouts/index.d.ts +5 -0
- package/dist/components/ui/layouts/index.esm.js +10 -0
- package/dist/components/ui/layouts/index.js +10 -0
- package/dist/components/ui/layouts/mobile-layout.d.ts +158 -0
- package/dist/components/ui/layouts/mobile-layout.esm.js +152 -0
- package/dist/components/ui/layouts/mobile-layout.js +152 -0
- package/dist/components/ui/layouts/tablet-layout.d.ts +192 -0
- package/dist/components/ui/layouts/tablet-layout.esm.js +183 -0
- package/dist/components/ui/layouts/tablet-layout.js +183 -0
- package/dist/components/ui/mobile-form-validation.d.ts +439 -0
- package/dist/components/ui/mobile-form-validation.esm.js +418 -0
- package/dist/components/ui/mobile-form-validation.js +418 -0
- package/dist/components/ui/mobile-input-demo.d.ts +197 -0
- package/dist/components/ui/mobile-input-demo.esm.js +195 -0
- package/dist/components/ui/mobile-input-demo.js +195 -0
- package/dist/components/ui/mobile-input.d.ts +273 -0
- package/dist/components/ui/mobile-input.esm.js +216 -0
- package/dist/components/ui/mobile-input.js +216 -0
- package/dist/components/ui/mobile-skeleton-loading-demo.d.ts +628 -0
- package/dist/components/ui/mobile-skeleton-loading-demo.esm.js +621 -0
- package/dist/components/ui/mobile-skeleton-loading-demo.js +621 -0
- package/dist/components/ui/navigation/breadcrumb.d.ts +149 -0
- package/dist/components/ui/navigation/breadcrumb.esm.js +155 -0
- package/dist/components/ui/navigation/breadcrumb.js +155 -0
- package/dist/components/ui/navigation/index.d.ts +25 -0
- package/dist/components/ui/navigation/index.esm.js +14 -0
- package/dist/components/ui/navigation/index.js +14 -0
- package/dist/components/ui/navigation/menu.d.ts +366 -0
- package/dist/components/ui/navigation/menu.esm.js +360 -0
- package/dist/components/ui/navigation/menu.js +360 -0
- package/dist/components/ui/navigation/navigation-demo.d.ts +169 -0
- package/dist/components/ui/navigation/navigation-demo.esm.js +317 -0
- package/dist/components/ui/navigation/navigation-demo.js +317 -0
- package/dist/components/ui/navigation/pagination.d.ts +261 -0
- package/dist/components/ui/navigation/pagination.esm.js +260 -0
- package/dist/components/ui/navigation/pagination.js +260 -0
- package/dist/components/ui/navigation/sidebar.d.ts +375 -0
- package/dist/components/ui/navigation/sidebar.esm.js +369 -0
- package/dist/components/ui/navigation/sidebar.js +369 -0
- package/dist/components/ui/navigation/stepper.d.ts +294 -0
- package/dist/components/ui/navigation/stepper.esm.js +292 -0
- package/dist/components/ui/navigation/stepper.js +292 -0
- package/dist/components/ui/navigation/tabs.d.ts +196 -0
- package/dist/components/ui/navigation/tabs.esm.js +194 -0
- package/dist/components/ui/navigation/tabs.js +194 -0
- package/dist/components/ui/navigation/types.d.ts +293 -0
- package/dist/components/ui/navigation/types.esm.js +298 -0
- package/dist/components/ui/navigation/types.js +298 -0
- package/dist/components/ui/overlay/backdrop.d.ts +79 -0
- package/dist/components/ui/overlay/backdrop.esm.js +80 -0
- package/dist/components/ui/overlay/backdrop.js +80 -0
- package/dist/components/ui/overlay/focus-manager.d.ts +141 -0
- package/dist/components/ui/overlay/focus-manager.esm.js +141 -0
- package/dist/components/ui/overlay/focus-manager.js +141 -0
- package/dist/components/ui/overlay/index.d.ts +27 -0
- package/dist/components/ui/overlay/index.esm.js +16 -0
- package/dist/components/ui/overlay/index.js +16 -0
- package/dist/components/ui/overlay/modal.d.ts +262 -0
- package/dist/components/ui/overlay/modal.esm.js +266 -0
- package/dist/components/ui/overlay/modal.js +266 -0
- package/dist/components/ui/overlay/overlay-manager.d.ts +107 -0
- package/dist/components/ui/overlay/overlay-manager.esm.js +105 -0
- package/dist/components/ui/overlay/overlay-manager.js +105 -0
- package/dist/components/ui/overlay/popover.d.ts +450 -0
- package/dist/components/ui/overlay/popover.esm.js +446 -0
- package/dist/components/ui/overlay/popover.js +446 -0
- package/dist/components/ui/overlay/portal.d.ts +75 -0
- package/dist/components/ui/overlay/portal.esm.js +79 -0
- package/dist/components/ui/overlay/portal.js +79 -0
- package/dist/components/ui/overlay/tooltip.d.ts +298 -0
- package/dist/components/ui/overlay/tooltip.esm.js +288 -0
- package/dist/components/ui/overlay/tooltip.js +288 -0
- package/dist/components/ui/overlay/types.d.ts +194 -0
- package/dist/components/ui/overlay/types.esm.js +195 -0
- package/dist/components/ui/overlay/types.js +195 -0
- package/dist/components/ui/performance-demo.d.ts +583 -0
- package/dist/components/ui/performance-demo.esm.js +549 -0
- package/dist/components/ui/performance-demo.js +549 -0
- package/dist/components/ui/semantic-input-system-demo.d.ts +490 -0
- package/dist/components/ui/semantic-input-system-demo.esm.js +465 -0
- package/dist/components/ui/semantic-input-system-demo.js +465 -0
- package/dist/components/ui/theme-customizer.d.ts +378 -0
- package/dist/components/ui/theme-customizer.esm.js +354 -0
- package/dist/components/ui/theme-customizer.js +354 -0
- package/dist/components/ui/theme-preview.d.ts +305 -0
- package/dist/components/ui/theme-preview.esm.js +258 -0
- package/dist/components/ui/theme-preview.js +258 -0
- package/dist/components/ui/theme-switcher.d.ts +259 -0
- package/dist/components/ui/theme-switcher.esm.js +238 -0
- package/dist/components/ui/theme-switcher.js +238 -0
- package/dist/components/ui/theme-toggle.d.ts +34 -0
- package/dist/components/ui/theme-toggle.esm.js +38 -0
- package/dist/components/ui/theme-toggle.js +38 -0
- package/dist/components/ui/token-demo.d.ts +188 -0
- package/dist/components/ui/token-demo.esm.js +183 -0
- package/dist/components/ui/token-demo.js +183 -0
- package/dist/components/ui/touch-demo.d.ts +455 -0
- package/dist/components/ui/touch-demo.esm.js +433 -0
- package/dist/components/ui/touch-demo.js +433 -0
- package/dist/components/ui/touch-friendly-interface-demo.d.ts +512 -0
- package/dist/components/ui/touch-friendly-interface-demo.esm.js +481 -0
- package/dist/components/ui/touch-friendly-interface-demo.js +481 -0
- package/dist/components/ui/touch-friendly-interface.d.ts +292 -0
- package/dist/components/ui/touch-friendly-interface.esm.js +272 -0
- package/dist/components/ui/touch-friendly-interface.js +272 -0
- package/dist/hooks/index.d.ts +161 -0
- package/dist/hooks/index.esm.js +190 -0
- package/dist/hooks/index.js +190 -0
- package/dist/hooks/use-accessibility-support.d.ts +516 -0
- package/dist/hooks/use-accessibility-support.esm.js +488 -0
- package/dist/hooks/use-accessibility-support.js +488 -0
- package/dist/hooks/use-adaptive-layout.d.ts +287 -0
- package/dist/hooks/use-adaptive-layout.esm.js +266 -0
- package/dist/hooks/use-adaptive-layout.js +266 -0
- package/dist/hooks/use-advanced-patterns.d.ts +292 -0
- package/dist/hooks/use-advanced-patterns.esm.js +279 -0
- package/dist/hooks/use-advanced-patterns.js +279 -0
- package/dist/hooks/use-advanced-transition-system.d.ts +390 -0
- package/dist/hooks/use-advanced-transition-system.esm.js +352 -0
- package/dist/hooks/use-advanced-transition-system.js +352 -0
- package/dist/hooks/use-animation-profile.d.ts +285 -0
- package/dist/hooks/use-animation-profile.esm.js +259 -0
- package/dist/hooks/use-animation-profile.js +259 -0
- package/dist/hooks/use-battery-animations.d.ts +382 -0
- package/dist/hooks/use-battery-animations.esm.js +359 -0
- package/dist/hooks/use-battery-animations.js +359 -0
- package/dist/hooks/use-battery-conscious-loading.d.ts +473 -0
- package/dist/hooks/use-battery-conscious-loading.esm.js +432 -0
- package/dist/hooks/use-battery-conscious-loading.js +432 -0
- package/dist/hooks/use-battery-optimization.d.ts +328 -0
- package/dist/hooks/use-battery-optimization.esm.js +307 -0
- package/dist/hooks/use-battery-optimization.js +307 -0
- package/dist/hooks/use-battery-status.d.ts +297 -0
- package/dist/hooks/use-battery-status.esm.js +277 -0
- package/dist/hooks/use-battery-status.js +277 -0
- package/dist/hooks/use-component-performance.d.ts +342 -0
- package/dist/hooks/use-component-performance.esm.js +329 -0
- package/dist/hooks/use-component-performance.js +329 -0
- package/dist/hooks/use-device-loading-states.d.ts +456 -0
- package/dist/hooks/use-device-loading-states.esm.js +416 -0
- package/dist/hooks/use-device-loading-states.js +416 -0
- package/dist/hooks/use-device.d.ts +104 -0
- package/dist/hooks/use-device.esm.js +99 -0
- package/dist/hooks/use-device.js +99 -0
- package/dist/hooks/use-enterprise-mobile-experience.d.ts +486 -0
- package/dist/hooks/use-enterprise-mobile-experience.esm.js +439 -0
- package/dist/hooks/use-enterprise-mobile-experience.js +439 -0
- package/dist/hooks/use-form-feedback.d.ts +401 -0
- package/dist/hooks/use-form-feedback.esm.js +360 -0
- package/dist/hooks/use-form-feedback.js +360 -0
- package/dist/hooks/use-form-performance.d.ts +511 -0
- package/dist/hooks/use-form-performance.esm.js +478 -0
- package/dist/hooks/use-form-performance.js +478 -0
- package/dist/hooks/use-frame-rate.d.ts +249 -0
- package/dist/hooks/use-frame-rate.esm.js +232 -0
- package/dist/hooks/use-frame-rate.js +232 -0
- package/dist/hooks/use-gestures.d.ts +336 -0
- package/dist/hooks/use-gestures.esm.js +314 -0
- package/dist/hooks/use-gestures.js +314 -0
- package/dist/hooks/use-hardware-acceleration.d.ts +339 -0
- package/dist/hooks/use-hardware-acceleration.esm.js +313 -0
- package/dist/hooks/use-hardware-acceleration.js +313 -0
- package/dist/hooks/use-input-accessibility.d.ts +451 -0
- package/dist/hooks/use-input-accessibility.esm.js +417 -0
- package/dist/hooks/use-input-accessibility.js +417 -0
- package/dist/hooks/use-input-performance.d.ts +503 -0
- package/dist/hooks/use-input-performance.esm.js +471 -0
- package/dist/hooks/use-input-performance.js +471 -0
- package/dist/hooks/use-layout-performance.d.ts +317 -0
- package/dist/hooks/use-layout-performance.esm.js +298 -0
- package/dist/hooks/use-layout-performance.js +298 -0
- package/dist/hooks/use-loading-accessibility.d.ts +532 -0
- package/dist/hooks/use-loading-accessibility.esm.js +495 -0
- package/dist/hooks/use-loading-accessibility.js +495 -0
- package/dist/hooks/use-loading-performance.d.ts +471 -0
- package/dist/hooks/use-loading-performance.esm.js +449 -0
- package/dist/hooks/use-loading-performance.js +449 -0
- package/dist/hooks/use-memory-usage.d.ts +285 -0
- package/dist/hooks/use-memory-usage.esm.js +268 -0
- package/dist/hooks/use-memory-usage.js +268 -0
- package/dist/hooks/use-mobile-form-layout.d.ts +462 -0
- package/dist/hooks/use-mobile-form-layout.esm.js +427 -0
- package/dist/hooks/use-mobile-form-layout.js +427 -0
- package/dist/hooks/use-mobile-form-validation.d.ts +516 -0
- package/dist/hooks/use-mobile-form-validation.esm.js +451 -0
- package/dist/hooks/use-mobile-form-validation.js +451 -0
- package/dist/hooks/use-mobile-keyboard-optimization.d.ts +469 -0
- package/dist/hooks/use-mobile-keyboard-optimization.esm.js +431 -0
- package/dist/hooks/use-mobile-keyboard-optimization.js +431 -0
- package/dist/hooks/use-mobile-layout.d.ts +300 -0
- package/dist/hooks/use-mobile-layout.esm.js +280 -0
- package/dist/hooks/use-mobile-layout.js +280 -0
- package/dist/hooks/use-mobile-optimization.d.ts +404 -0
- package/dist/hooks/use-mobile-optimization.esm.js +378 -0
- package/dist/hooks/use-mobile-optimization.js +378 -0
- package/dist/hooks/use-mobile-skeleton.d.ts +399 -0
- package/dist/hooks/use-mobile-skeleton.esm.js +369 -0
- package/dist/hooks/use-mobile-skeleton.js +369 -0
- package/dist/hooks/use-mobile-touch.d.ts +412 -0
- package/dist/hooks/use-mobile-touch.esm.js +379 -0
- package/dist/hooks/use-mobile-touch.js +379 -0
- package/dist/hooks/use-performance-throttling.d.ts +346 -0
- package/dist/hooks/use-performance-throttling.esm.js +324 -0
- package/dist/hooks/use-performance-throttling.js +324 -0
- package/dist/hooks/use-performance.d.ts +314 -0
- package/dist/hooks/use-performance.esm.js +278 -0
- package/dist/hooks/use-performance.js +278 -0
- package/dist/hooks/use-reusable-architecture.d.ts +412 -0
- package/dist/hooks/use-reusable-architecture.esm.js +385 -0
- package/dist/hooks/use-reusable-architecture.js +385 -0
- package/dist/hooks/use-semantic-input-types.d.ts +354 -0
- package/dist/hooks/use-semantic-input-types.esm.js +315 -0
- package/dist/hooks/use-semantic-input-types.js +315 -0
- package/dist/hooks/use-semantic-input.d.ts +563 -0
- package/dist/hooks/use-semantic-input.esm.js +513 -0
- package/dist/hooks/use-semantic-input.js +513 -0
- package/dist/hooks/use-tablet-layout.d.ts +382 -0
- package/dist/hooks/use-tablet-layout.esm.js +355 -0
- package/dist/hooks/use-tablet-layout.js +355 -0
- package/dist/hooks/use-touch-friendly-input.d.ts +520 -0
- package/dist/hooks/use-touch-friendly-input.esm.js +480 -0
- package/dist/hooks/use-touch-friendly-input.js +480 -0
- package/dist/hooks/use-touch-friendly-interface.d.ts +329 -0
- package/dist/hooks/use-touch-friendly-interface.esm.js +299 -0
- package/dist/hooks/use-touch-friendly-interface.js +299 -0
- package/dist/hooks/use-touch-optimization.d.ts +373 -0
- package/dist/hooks/use-touch-optimization.esm.js +348 -0
- package/dist/hooks/use-touch-optimization.js +348 -0
- package/dist/index.esm.js +2 -2
- package/dist/index.js +2 -2
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.esm.js +6 -0
- package/dist/lib/utils.js +6 -0
- package/dist/plugins/theme-css-generator.d.ts +345 -0
- package/dist/plugins/theme-css-generator.esm.js +305 -0
- package/dist/plugins/theme-css-generator.js +305 -0
- package/dist/styles.css +1 -1
- package/dist/themes/ThemeContext.d.ts +27 -0
- package/dist/themes/ThemeContext.esm.js +31 -0
- package/dist/themes/ThemeContext.js +31 -0
- package/dist/themes/ThemeProvider.d.ts +222 -0
- package/dist/themes/ThemeProvider.esm.js +229 -0
- package/dist/themes/ThemeProvider.js +229 -0
- package/dist/themes/accessibility/index.d.ts +7 -0
- package/dist/themes/accessibility/index.esm.js +27 -0
- package/dist/themes/accessibility/index.js +27 -0
- package/dist/themes/accessibility.d.ts +259 -0
- package/dist/themes/accessibility.esm.js +220 -0
- package/dist/themes/accessibility.js +220 -0
- package/dist/themes/aria-patterns.d.ts +418 -0
- package/dist/themes/aria-patterns.esm.js +384 -0
- package/dist/themes/aria-patterns.js +384 -0
- package/dist/themes/base-themes.d.ts +34 -0
- package/dist/themes/base-themes.esm.js +52 -0
- package/dist/themes/base-themes.js +52 -0
- package/dist/themes/colorManager.d.ts +327 -0
- package/dist/themes/colorManager.esm.js +362 -0
- package/dist/themes/colorManager.js +362 -0
- package/dist/themes/examples/dark-theme.d.ts +139 -0
- package/dist/themes/examples/dark-theme.esm.js +124 -0
- package/dist/themes/examples/dark-theme.js +124 -0
- package/dist/themes/examples/minimal-theme.d.ts +93 -0
- package/dist/themes/examples/minimal-theme.esm.js +86 -0
- package/dist/themes/examples/minimal-theme.js +86 -0
- package/dist/themes/focus-management.d.ts +699 -0
- package/dist/themes/focus-management.esm.js +642 -0
- package/dist/themes/focus-management.js +642 -0
- package/dist/themes/fontLoader.d.ts +163 -0
- package/dist/themes/fontLoader.esm.js +192 -0
- package/dist/themes/fontLoader.js +192 -0
- package/dist/themes/high-contrast.d.ts +619 -0
- package/dist/themes/high-contrast.esm.js +573 -0
- package/dist/themes/high-contrast.js +573 -0
- package/dist/themes/index.d.ts +11 -0
- package/dist/themes/index.esm.js +19 -0
- package/dist/themes/index.js +19 -0
- package/dist/themes/inheritance.d.ts +160 -0
- package/dist/themes/inheritance.esm.js +219 -0
- package/dist/themes/inheritance.js +219 -0
- package/dist/themes/keyboard-navigation.d.ts +550 -0
- package/dist/themes/keyboard-navigation.esm.js +521 -0
- package/dist/themes/keyboard-navigation.js +521 -0
- package/dist/themes/motion-reduction.d.ts +660 -0
- package/dist/themes/motion-reduction.esm.js +602 -0
- package/dist/themes/motion-reduction.js +602 -0
- package/dist/themes/navigation.d.ts +232 -0
- package/dist/themes/navigation.esm.js +238 -0
- package/dist/themes/navigation.js +238 -0
- package/dist/themes/screen-reader.d.ts +645 -0
- package/dist/themes/screen-reader.esm.js +580 -0
- package/dist/themes/screen-reader.js +580 -0
- package/dist/themes/systemThemeDetector.d.ts +148 -0
- package/dist/themes/systemThemeDetector.esm.js +174 -0
- package/dist/themes/systemThemeDetector.js +174 -0
- package/dist/themes/themeCSSUpdater.d.ts +229 -0
- package/dist/themes/themeCSSUpdater.esm.js +250 -0
- package/dist/themes/themeCSSUpdater.js +250 -0
- package/dist/themes/themePersistence.d.ts +192 -0
- package/dist/themes/themePersistence.esm.js +217 -0
- package/dist/themes/themePersistence.js +217 -0
- package/dist/themes/themes/stan-design.d.ts +678 -0
- package/dist/themes/themes/stan-design.esm.js +518 -0
- package/dist/themes/themes/stan-design.js +518 -0
- package/dist/themes/types.d.ts +454 -0
- package/dist/themes/types.esm.js +446 -0
- package/dist/themes/types.js +446 -0
- package/dist/themes/useSystemTheme.d.ts +43 -0
- package/dist/themes/useSystemTheme.esm.js +48 -0
- package/dist/themes/useSystemTheme.js +48 -0
- package/dist/themes/useTheme.d.ts +20 -0
- package/dist/themes/useTheme.esm.js +87 -0
- package/dist/themes/useTheme.js +87 -0
- package/dist/themes/validation.d.ts +406 -0
- package/dist/themes/validation.esm.js +411 -0
- package/dist/themes/validation.js +411 -0
- package/dist/tokens/index.d.ts +25 -0
- package/dist/tokens/index.esm.js +23 -0
- package/dist/tokens/index.js +23 -0
- package/dist/tokens/tokenExporter.d.ts +336 -0
- package/dist/tokens/tokenExporter.esm.js +371 -0
- package/dist/tokens/tokenExporter.js +371 -0
- package/dist/tokens/tokenGenerator.d.ts +250 -0
- package/dist/tokens/tokenGenerator.esm.js +267 -0
- package/dist/tokens/tokenGenerator.js +267 -0
- package/dist/tokens/tokenManager.d.ts +194 -0
- package/dist/tokens/tokenManager.esm.js +235 -0
- package/dist/tokens/tokenManager.js +235 -0
- package/dist/tokens/tokenValidator.d.ts +488 -0
- package/dist/tokens/tokenValidator.esm.js +497 -0
- package/dist/tokens/tokenValidator.js +497 -0
- package/dist/tokens/types.d.ts +78 -0
- package/dist/tokens/types.esm.js +64 -0
- package/dist/tokens/types.js +64 -0
- package/dist/utils/bundle-analyzer.d.ts +260 -0
- package/dist/utils/bundle-analyzer.esm.js +242 -0
- package/dist/utils/bundle-analyzer.js +242 -0
- package/dist/utils/bundle-splitting.d.ts +483 -0
- package/dist/utils/bundle-splitting.esm.js +458 -0
- package/dist/utils/bundle-splitting.js +458 -0
- package/dist/utils/lazy-loading.d.ts +437 -0
- package/dist/utils/lazy-loading.esm.js +415 -0
- package/dist/utils/lazy-loading.js +415 -0
- package/dist/utils/performance-monitor.d.ts +513 -0
- package/dist/utils/performance-monitor.esm.js +472 -0
- package/dist/utils/performance-monitor.js +472 -0
- package/dist/utils/tree-shaking.d.ts +274 -0
- package/dist/utils/tree-shaking.esm.js +266 -0
- package/dist/utils/tree-shaking.js +266 -0
- package/package.json +1 -1
- package/src/index.ts +2 -2
- package/src/themes/accessibility/index.ts +1 -1
- package/src/themes/focus-management.ts +3 -3
- package/src/themes/keyboard-navigation.ts +3 -3
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback, useRef } from 'react'
|
|
2
|
+
|
|
3
|
+
export interface BatteryStatus {
|
|
4
|
+
level}
|
|
5
|
+
|
|
6
|
+
export interface BatteryOptimizationConfig {
|
|
7
|
+
enableBatteryMonitoring?}
|
|
8
|
+
|
|
9
|
+
export interface BatteryOptimizationCallbacks {
|
|
10
|
+
onBatteryStatusChange?) => void
|
|
11
|
+
onLowBatteryWarning?) => void
|
|
12
|
+
onCriticalBatteryWarning?) => void
|
|
13
|
+
onPerformanceThrottled?, reason) => void
|
|
14
|
+
onOptimizationApplied?) => void
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const useBatteryOptimization = (
|
|
18
|
+
config= {},
|
|
19
|
+
callbacks= {}
|
|
20
|
+
) => {
|
|
21
|
+
const {
|
|
22
|
+
enableBatteryMonitoring = true,
|
|
23
|
+
enablePerformanceThrottling = true,
|
|
24
|
+
enableUserPreferences = true,
|
|
25
|
+
enableAdaptiveOptimization = true,
|
|
26
|
+
lowBatteryThreshold = 0.2,
|
|
27
|
+
criticalBatteryThreshold = 0.1,
|
|
28
|
+
userPreferenceLevel = 'balanced'
|
|
29
|
+
} = config
|
|
30
|
+
|
|
31
|
+
const [batteryStatus, setBatteryStatus] = useState<BatteryStatus>({
|
|
32
|
+
level,
|
|
33
|
+
charging,
|
|
34
|
+
chargingTime,
|
|
35
|
+
dischargingTime,
|
|
36
|
+
isLow,
|
|
37
|
+
isCritical})
|
|
38
|
+
const [isOptimizing, setIsOptimizing] = useState(false)
|
|
39
|
+
const [optimizations, setOptimizations] = useState<string[]>([])
|
|
40
|
+
const [currentThrottleLevel, setCurrentThrottleLevel] = useState<string>('none')
|
|
41
|
+
const [userPreferences, setUserPreferences] = useState<string>(userPreferenceLevel)
|
|
42
|
+
|
|
43
|
+
const batteryRef = useRef<any>(null)
|
|
44
|
+
const batteryCheckIntervalRef = useRef<number | null>(null)
|
|
45
|
+
const optimizationTimerRef = useRef<number | null>(null)
|
|
46
|
+
|
|
47
|
+
// Get battery status
|
|
48
|
+
const getBatteryStatus = useCallback(async ()=> {
|
|
49
|
+
if (!enableBatteryMonitoring || !('getBattery' in navigator)) return null
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
const battery = await (navigator as any).getBattery()
|
|
53
|
+
batteryRef.current = battery
|
|
54
|
+
|
|
55
|
+
const status= {
|
|
56
|
+
level,
|
|
57
|
+
charging,
|
|
58
|
+
chargingTime,
|
|
59
|
+
dischargingTime,
|
|
60
|
+
isLow= lowBatteryThreshold,
|
|
61
|
+
isCritical= criticalBatteryThreshold
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
setBatteryStatus(status)
|
|
65
|
+
callbacks.onBatteryStatusChange?.(status)
|
|
66
|
+
|
|
67
|
+
// Check for warnings
|
|
68
|
+
if (status.isCritical) {
|
|
69
|
+
callbacks.onCriticalBatteryWarning?.(status)
|
|
70
|
+
} else if (status.isLow) {
|
|
71
|
+
callbacks.onLowBatteryWarning?.(status)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return status
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.warn('Battery API not available, error)
|
|
77
|
+
return null
|
|
78
|
+
}
|
|
79
|
+
}, [enableBatteryMonitoring, lowBatteryThreshold, criticalBatteryThreshold, callbacks])
|
|
80
|
+
|
|
81
|
+
// Apply performance throttling based on battery level
|
|
82
|
+
const applyPerformanceThrottling = useCallback((level) => {
|
|
83
|
+
if (!enablePerformanceThrottling) return
|
|
84
|
+
|
|
85
|
+
setIsOptimizing(true)
|
|
86
|
+
setCurrentThrottleLevel(level)
|
|
87
|
+
|
|
88
|
+
setTimeout(() => {
|
|
89
|
+
let optimizations] = []
|
|
90
|
+
|
|
91
|
+
switch (level) {
|
|
92
|
+
case 'light'= [
|
|
93
|
+
'Light performance throttling applied',
|
|
94
|
+
'Animation complexity reduced by 20%',
|
|
95
|
+
'Hardware acceleration optimized for battery'
|
|
96
|
+
]
|
|
97
|
+
break
|
|
98
|
+
case 'moderate'= [
|
|
99
|
+
'Moderate performance throttling applied',
|
|
100
|
+
'Animation complexity reduced by 40%',
|
|
101
|
+
'GPU utilization limited for battery efficiency',
|
|
102
|
+
'Non-essential animations disabled'
|
|
103
|
+
]
|
|
104
|
+
break
|
|
105
|
+
case 'aggressive'= [
|
|
106
|
+
'Aggressive performance throttling applied',
|
|
107
|
+
'Animation complexity reduced by 70%',
|
|
108
|
+
'Hardware acceleration minimized',
|
|
109
|
+
'Only essential animations enabled',
|
|
110
|
+
'Background processes optimized'
|
|
111
|
+
]
|
|
112
|
+
break
|
|
113
|
+
default= ['Performance throttling disabled']
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
setOptimizations(prev => [...prev, ...optimizations])
|
|
117
|
+
setIsOptimizing(false)
|
|
118
|
+
|
|
119
|
+
callbacks.onPerformanceThrottled?.(level, 'Battery optimization')
|
|
120
|
+
optimizations.forEach(optimization => {
|
|
121
|
+
callbacks.onOptimizationApplied?.(optimization)
|
|
122
|
+
})
|
|
123
|
+
}, 300)
|
|
124
|
+
}, [enablePerformanceThrottling, callbacks])
|
|
125
|
+
|
|
126
|
+
// Apply battery optimizations
|
|
127
|
+
const applyBatteryOptimizations = useCallback(() => {
|
|
128
|
+
if (!enableAdaptiveOptimization) return
|
|
129
|
+
|
|
130
|
+
setIsOptimizing(true)
|
|
131
|
+
|
|
132
|
+
setTimeout(() => {
|
|
133
|
+
const optimizations] = []
|
|
134
|
+
|
|
135
|
+
if (batteryStatus.isCritical) {
|
|
136
|
+
optimizations.push('Critical battery mode)
|
|
137
|
+
optimizations.push('All non-essential features disabled')
|
|
138
|
+
optimizations.push('Hardware acceleration completely disabled')
|
|
139
|
+
applyPerformanceThrottling('aggressive')
|
|
140
|
+
} else if (batteryStatus.isLow) {
|
|
141
|
+
optimizations.push('Low battery mode)
|
|
142
|
+
optimizations.push('Performance throttling applied')
|
|
143
|
+
optimizations.push('Hardware acceleration optimized for battery')
|
|
144
|
+
applyPerformanceThrottling('moderate')
|
|
145
|
+
} else if (batteryStatus.level < 0.5) {
|
|
146
|
+
optimizations.push('Medium battery)
|
|
147
|
+
optimizations.push('Hardware acceleration optimized')
|
|
148
|
+
applyPerformanceThrottling('light')
|
|
149
|
+
} else {
|
|
150
|
+
optimizations.push('High battery)
|
|
151
|
+
optimizations.push('Hardware acceleration at full capacity')
|
|
152
|
+
applyPerformanceThrottling('none')
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
setOptimizations(prev => [...prev, ...optimizations])
|
|
156
|
+
setIsOptimizing(false)
|
|
157
|
+
|
|
158
|
+
optimizations.forEach(optimization => {
|
|
159
|
+
callbacks.onOptimizationApplied?.(optimization)
|
|
160
|
+
})
|
|
161
|
+
}, 200)
|
|
162
|
+
}, [enableAdaptiveOptimization, batteryStatus, applyPerformanceThrottling, callbacks])
|
|
163
|
+
|
|
164
|
+
// Handle user preferences
|
|
165
|
+
const updateUserPreferences = useCallback((preference) => {
|
|
166
|
+
if (!enableUserPreferences) return
|
|
167
|
+
|
|
168
|
+
setUserPreferences(preference)
|
|
169
|
+
|
|
170
|
+
let optimizations] = []
|
|
171
|
+
|
|
172
|
+
switch (preference) {
|
|
173
|
+
case 'performance'= [
|
|
174
|
+
'User preference,
|
|
175
|
+
'Hardware acceleration at maximum',
|
|
176
|
+
'Battery optimization disabled'
|
|
177
|
+
]
|
|
178
|
+
applyPerformanceThrottling('none')
|
|
179
|
+
break
|
|
180
|
+
case 'balanced'= [
|
|
181
|
+
'User preference,
|
|
182
|
+
'Hardware acceleration optimized',
|
|
183
|
+
'Battery and performance balanced'
|
|
184
|
+
]
|
|
185
|
+
applyPerformanceThrottling('light')
|
|
186
|
+
break
|
|
187
|
+
case 'battery'= [
|
|
188
|
+
'User preference,
|
|
189
|
+
'Hardware acceleration optimized for battery',
|
|
190
|
+
'Performance throttling applied'
|
|
191
|
+
]
|
|
192
|
+
applyPerformanceThrottling('moderate')
|
|
193
|
+
break
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
setOptimizations(prev => [...prev, ...optimizations])
|
|
197
|
+
optimizations.forEach(optimization => {
|
|
198
|
+
callbacks.onOptimizationApplied?.(optimization)
|
|
199
|
+
})
|
|
200
|
+
}, [enableUserPreferences, applyPerformanceThrottling, callbacks])
|
|
201
|
+
|
|
202
|
+
// Get optimization recommendations
|
|
203
|
+
const getOptimizationRecommendations = useCallback(() => {
|
|
204
|
+
const recommendations = []
|
|
205
|
+
|
|
206
|
+
if (batteryStatus.isCritical) {
|
|
207
|
+
recommendations.push('Critical battery)
|
|
208
|
+
recommendations.push('Reduce screen brightness and disable animations')
|
|
209
|
+
recommendations.push('Close unnecessary applications and tabs')
|
|
210
|
+
} else if (batteryStatus.isLow) {
|
|
211
|
+
recommendations.push('Low battery)
|
|
212
|
+
recommendations.push('Reduce animation complexity and GPU usage')
|
|
213
|
+
recommendations.push('Optimize background processes')
|
|
214
|
+
} else if (batteryStatus.level < 0.5) {
|
|
215
|
+
recommendations.push('Medium battery)
|
|
216
|
+
recommendations.push('Monitor hardware acceleration usage')
|
|
217
|
+
recommendations.push('Balance performance and battery life')
|
|
218
|
+
} else {
|
|
219
|
+
recommendations.push('High battery)
|
|
220
|
+
recommendations.push('Hardware acceleration at maximum capacity')
|
|
221
|
+
recommendations.push('Monitor for optimal performance')
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return recommendations
|
|
225
|
+
}, [batteryStatus])
|
|
226
|
+
|
|
227
|
+
// Initialize battery monitoring
|
|
228
|
+
useEffect(() => {
|
|
229
|
+
if (!enableBatteryMonitoring) return
|
|
230
|
+
|
|
231
|
+
try {
|
|
232
|
+
// Get initial battery status
|
|
233
|
+
getBatteryStatus()
|
|
234
|
+
|
|
235
|
+
// Set up battery monitoring interval
|
|
236
|
+
batteryCheckIntervalRef.current = window.setInterval(getBatteryStatus, 10000) // Check every 10 seconds
|
|
237
|
+
|
|
238
|
+
return () => {
|
|
239
|
+
if (batteryCheckIntervalRef.current) {
|
|
240
|
+
clearInterval(batteryCheckIntervalRef.current)
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
} catch (error) {
|
|
244
|
+
console.warn('Battery optimization initialization failed, error)
|
|
245
|
+
}
|
|
246
|
+
}, [enableBatteryMonitoring, getBatteryStatus])
|
|
247
|
+
|
|
248
|
+
// Apply optimizations when battery status changes
|
|
249
|
+
useEffect(() => {
|
|
250
|
+
if (enableAdaptiveOptimization) {
|
|
251
|
+
applyBatteryOptimizations()
|
|
252
|
+
}
|
|
253
|
+
}, [enableAdaptiveOptimization, applyBatteryOptimizations])
|
|
254
|
+
|
|
255
|
+
// Set initial user preferences
|
|
256
|
+
useEffect(() => {
|
|
257
|
+
if (enableUserPreferences) {
|
|
258
|
+
updateUserPreferences(userPreferenceLevel)
|
|
259
|
+
}
|
|
260
|
+
}, [enableUserPreferences, userPreferenceLevel, updateUserPreferences])
|
|
261
|
+
|
|
262
|
+
// Cleanup on unmount
|
|
263
|
+
useEffect(() => {
|
|
264
|
+
return () => {
|
|
265
|
+
if (batteryCheckIntervalRef.current) {
|
|
266
|
+
clearInterval(batteryCheckIntervalRef.current)
|
|
267
|
+
}
|
|
268
|
+
if (optimizationTimerRef.current) {
|
|
269
|
+
clearTimeout(optimizationTimerRef.current)
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}, [])
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
// State
|
|
276
|
+
batteryStatus,
|
|
277
|
+
isOptimizing,
|
|
278
|
+
optimizations,
|
|
279
|
+
currentThrottleLevel,
|
|
280
|
+
userPreferences,
|
|
281
|
+
|
|
282
|
+
// Actions
|
|
283
|
+
getBatteryStatus,
|
|
284
|
+
applyPerformanceThrottling,
|
|
285
|
+
applyBatteryOptimizations,
|
|
286
|
+
updateUserPreferences,
|
|
287
|
+
|
|
288
|
+
// Computed values
|
|
289
|
+
isLowBattery,
|
|
290
|
+
isCriticalBattery,
|
|
291
|
+
batteryPercentage),
|
|
292
|
+
optimizationRecommendations),
|
|
293
|
+
isCharging,
|
|
294
|
+
estimatedTimeRemaining,
|
|
295
|
+
|
|
296
|
+
// Utility functions
|
|
297
|
+
getBatteryHealth) => {
|
|
298
|
+
if (batteryStatus.level >= 0.8) return 'excellent'
|
|
299
|
+
if (batteryStatus.level >= 0.6) return 'good'
|
|
300
|
+
if (batteryStatus.level >= 0.4) return 'fair'
|
|
301
|
+
if (batteryStatus.level >= 0.2) return 'poor'
|
|
302
|
+
return 'critical'
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export default useBatteryOptimization
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
export interface BatteryMetrics {
|
|
2
|
+
level: number
|
|
3
|
+
charging: boolean
|
|
4
|
+
chargingTime: number
|
|
5
|
+
dischargingTime: number
|
|
6
|
+
isLowPowerMode: boolean
|
|
7
|
+
isCriticalBattery: boolean
|
|
8
|
+
performanceMode: 'high' | 'medium' | 'low'
|
|
9
|
+
throttlingEnabled: boolean
|
|
10
|
+
throttlingReason?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface BatteryThresholds {
|
|
14
|
+
low: number
|
|
15
|
+
critical: number
|
|
16
|
+
warning: number
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface BatteryCallbacks {
|
|
20
|
+
onBatteryLow?: (level: number) => void
|
|
21
|
+
onBatteryCritical?: (level: number) => void
|
|
22
|
+
onChargingStateChange?: (charging: boolean) => void
|
|
23
|
+
onPerformanceModeChange?: (mode: BatteryMetrics['performanceMode']) => void
|
|
24
|
+
onThrottlingChange?: (enabled: boolean, reason?: string) => void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface BatteryOptions {
|
|
28
|
+
updateInterval?: number
|
|
29
|
+
thresholds?: Partial<BatteryThresholds>
|
|
30
|
+
enableThrottling?: boolean
|
|
31
|
+
callbacks?: BatteryCallbacks
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const DEFAULT_THRESHOLDS: BatteryThresholds = {
|
|
35
|
+
low: 0.3,
|
|
36
|
+
critical: 0.15,
|
|
37
|
+
warning: 0.5
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export declare const useBatteryStatus: (options: BatteryOptions = {}) => {
|
|
41
|
+
const {
|
|
42
|
+
updateInterval = 5000,
|
|
43
|
+
thresholds = {},
|
|
44
|
+
enableThrottling = true,
|
|
45
|
+
callbacks = {}
|
|
46
|
+
} = options
|
|
47
|
+
|
|
48
|
+
const [metrics, setMetrics] = useState<BatteryMetrics>({
|
|
49
|
+
level: 1,
|
|
50
|
+
charging: true,
|
|
51
|
+
chargingTime: 0,
|
|
52
|
+
dischargingTime: 0,
|
|
53
|
+
isLowPowerMode: false,
|
|
54
|
+
isCriticalBattery: false,
|
|
55
|
+
performanceMode: 'high',
|
|
56
|
+
throttlingEnabled: false
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const [isMonitoring, setIsMonitoring] = useState(false)
|
|
60
|
+
const intervalIdRef = useRef<NodeJS.Timeout>()
|
|
61
|
+
const batteryRef = useRef<any>(null)
|
|
62
|
+
|
|
63
|
+
// Merge default thresholds with custom ones
|
|
64
|
+
const finalThresholds = useMemo(() => ({
|
|
65
|
+
...DEFAULT_THRESHOLDS,
|
|
66
|
+
...thresholds
|
|
67
|
+
}), [thresholds])
|
|
68
|
+
|
|
69
|
+
// Determine performance mode based on battery level
|
|
70
|
+
const determinePerformanceMode = useCallback((level: number, charging: boolean): BatteryMetrics['performanceMode'] => {
|
|
71
|
+
if (charging) return 'high'
|
|
72
|
+
if (level <= finalThresholds.critical) return 'low'
|
|
73
|
+
if (level <= finalThresholds.low) return 'medium'
|
|
74
|
+
return 'high'
|
|
75
|
+
}, [finalThresholds])
|
|
76
|
+
|
|
77
|
+
// Determine if throttling should be enabled
|
|
78
|
+
const shouldThrottle = useCallback((level: number, charging: boolean): { should: boolean; reason?: string } => {
|
|
79
|
+
if (!enableThrottling) return { should: false }
|
|
80
|
+
|
|
81
|
+
if (level <= finalThresholds.critical) {
|
|
82
|
+
return { should: true, reason: 'Critical battery level' }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (level <= finalThresholds.low && !charging) {
|
|
86
|
+
return { should: true, reason: 'Low battery level' }
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return { should: false }
|
|
90
|
+
}, [enableThrottling, finalThresholds])
|
|
91
|
+
|
|
92
|
+
// Update battery information
|
|
93
|
+
const updateBatteryInfo = useCallback(async () => {
|
|
94
|
+
if ('getBattery' in navigator) {
|
|
95
|
+
try {
|
|
96
|
+
if (!batteryRef.current) {
|
|
97
|
+
batteryRef.current = await (navigator as any).getBattery()
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const battery = batteryRef.current
|
|
101
|
+
const level = battery.level
|
|
102
|
+
const charging = battery.charging
|
|
103
|
+
const chargingTime = battery.chargingTime
|
|
104
|
+
const dischargingTime = battery.dischargingTime
|
|
105
|
+
|
|
106
|
+
const isLowPowerMode = level < finalThresholds.low
|
|
107
|
+
const isCriticalBattery = level < finalThresholds.critical
|
|
108
|
+
|
|
109
|
+
// Determine performance mode
|
|
110
|
+
const performanceMode = determinePerformanceMode(level, charging)
|
|
111
|
+
|
|
112
|
+
// Determine throttling
|
|
113
|
+
const { should: shouldThrottleNow, reason } = shouldThrottle(level, charging)
|
|
114
|
+
|
|
115
|
+
const newMetrics: BatteryMetrics = {
|
|
116
|
+
level,
|
|
117
|
+
charging,
|
|
118
|
+
chargingTime,
|
|
119
|
+
dischargingTime,
|
|
120
|
+
isLowPowerMode,
|
|
121
|
+
isCriticalBattery,
|
|
122
|
+
performanceMode,
|
|
123
|
+
throttlingEnabled: shouldThrottleNow,
|
|
124
|
+
throttlingReason: reason
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
setMetrics(newMetrics)
|
|
128
|
+
|
|
129
|
+
// Check thresholds and call callbacks
|
|
130
|
+
if (level <= finalThresholds.critical && callbacks.onBatteryCritical) {
|
|
131
|
+
callbacks.onBatteryCritical(level)
|
|
132
|
+
} else if (level <= finalThresholds.low && callbacks.onBatteryLow) {
|
|
133
|
+
callbacks.onBatteryLow(level)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (charging !== metrics.charging && callbacks.onChargingStateChange) {
|
|
137
|
+
callbacks.onChargingStateChange(charging)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (performanceMode !== metrics.performanceMode && callbacks.onPerformanceModeChange) {
|
|
141
|
+
callbacks.onPerformanceModeChange(performanceMode)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (shouldThrottleNow !== metrics.throttlingEnabled && callbacks.onThrottlingChange) {
|
|
145
|
+
callbacks.onThrottlingChange(shouldThrottleNow, reason)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
} catch (error) {
|
|
149
|
+
console.warn('Battery API not available:', error)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}, [finalThresholds, callbacks, metrics.charging, metrics.performanceMode, metrics.throttlingEnabled, determinePerformanceMode, shouldThrottle])
|
|
153
|
+
|
|
154
|
+
// Start monitoring
|
|
155
|
+
const startMonitoring = useCallback(() => {
|
|
156
|
+
if (isMonitoring) return
|
|
157
|
+
|
|
158
|
+
setIsMonitoring(true)
|
|
159
|
+
|
|
160
|
+
// Initial battery check
|
|
161
|
+
updateBatteryInfo()
|
|
162
|
+
|
|
163
|
+
// Set up interval for battery updates
|
|
164
|
+
intervalIdRef.current = setInterval(updateBatteryInfo, updateInterval)
|
|
165
|
+
}, [isMonitoring, updateBatteryInfo, updateInterval])
|
|
166
|
+
|
|
167
|
+
// Stop monitoring
|
|
168
|
+
const stopMonitoring = useCallback(() => {
|
|
169
|
+
setIsMonitoring(false)
|
|
170
|
+
|
|
171
|
+
if (intervalIdRef.current) {
|
|
172
|
+
clearInterval(intervalIdRef.current)
|
|
173
|
+
}
|
|
174
|
+
}, [])
|
|
175
|
+
|
|
176
|
+
// Manual throttling controls
|
|
177
|
+
const enableThrottlingMode = useCallback((reason?: string) => {
|
|
178
|
+
setMetrics(prev => ({
|
|
179
|
+
...prev,
|
|
180
|
+
throttlingEnabled: true,
|
|
181
|
+
throttlingReason: reason || 'Manual override'
|
|
182
|
+
}))
|
|
183
|
+
}, [])
|
|
184
|
+
|
|
185
|
+
const disableThrottlingMode = useCallback(() => {
|
|
186
|
+
setMetrics(prev => ({
|
|
187
|
+
...prev,
|
|
188
|
+
throttlingEnabled: false,
|
|
189
|
+
throttlingReason: undefined
|
|
190
|
+
}))
|
|
191
|
+
}, [])
|
|
192
|
+
|
|
193
|
+
// Auto-start monitoring on mount
|
|
194
|
+
useEffect(() => {
|
|
195
|
+
startMonitoring()
|
|
196
|
+
return () => stopMonitoring()
|
|
197
|
+
}, [startMonitoring, stopMonitoring])
|
|
198
|
+
|
|
199
|
+
// Battery optimization recommendations
|
|
200
|
+
const getOptimizationRecommendations = useCallback(() => {
|
|
201
|
+
const recommendations: string[] = []
|
|
202
|
+
|
|
203
|
+
if (metrics.isCriticalBattery) {
|
|
204
|
+
recommendations.push('Critical battery level - enable maximum power saving mode')
|
|
205
|
+
recommendations.push('Reduce animation complexity and disable non-essential features')
|
|
206
|
+
recommendations.push('Consider switching to low-power theme')
|
|
207
|
+
} else if (metrics.isLowPowerMode) {
|
|
208
|
+
recommendations.push('Low battery detected - enable power saving optimizations')
|
|
209
|
+
recommendations.push('Reduce background processing and network requests')
|
|
210
|
+
recommendations.push('Optimize rendering performance')
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (metrics.throttlingEnabled) {
|
|
214
|
+
recommendations.push('Performance throttling active - adjust user experience accordingly')
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (!metrics.charging && metrics.level < 0.5) {
|
|
218
|
+
recommendations.push('Battery below 50% - consider enabling power saving features')
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return recommendations
|
|
222
|
+
}, [metrics])
|
|
223
|
+
|
|
224
|
+
// Power saving suggestions
|
|
225
|
+
const getPowerSavingSuggestions = useCallback(() => {
|
|
226
|
+
const suggestions: string[] = []
|
|
227
|
+
|
|
228
|
+
if (metrics.isLowPowerMode) {
|
|
229
|
+
suggestions.push('Reduce animation frame rate')
|
|
230
|
+
suggestions.push('Implement lazy loading for images and content')
|
|
231
|
+
suggestions.push('Use CSS transforms instead of JavaScript animations')
|
|
232
|
+
suggestions.push('Optimize network requests and caching')
|
|
233
|
+
suggestions.push('Consider using Intersection Observer for scroll-based animations')
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (metrics.isCriticalBattery) {
|
|
237
|
+
suggestions.push('Disable all non-essential animations')
|
|
238
|
+
suggestions.push('Implement aggressive content virtualization')
|
|
239
|
+
suggestions.push('Reduce DOM manipulation frequency')
|
|
240
|
+
suggestions.push('Use passive event listeners')
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return suggestions
|
|
244
|
+
}, [metrics])
|
|
245
|
+
|
|
246
|
+
// Battery status summary
|
|
247
|
+
const getBatteryStatus = useCallback(() => {
|
|
248
|
+
if (metrics.charging) {
|
|
249
|
+
return `Charging (${Math.round(metrics.level * 100)}%)`
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (metrics.isCriticalBattery) {
|
|
253
|
+
return `Critical (${Math.round(metrics.level * 100)}%)`
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (metrics.isLowPowerMode) {
|
|
257
|
+
return `Low (${Math.round(metrics.level * 100)}%)`
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return `Good (${Math.round(metrics.level * 100)}%)`
|
|
261
|
+
}, [metrics])
|
|
262
|
+
|
|
263
|
+
return {
|
|
264
|
+
// Metrics
|
|
265
|
+
metrics,
|
|
266
|
+
|
|
267
|
+
// Controls
|
|
268
|
+
startMonitoring,
|
|
269
|
+
stopMonitoring,
|
|
270
|
+
isMonitoring,
|
|
271
|
+
enableThrottlingMode,
|
|
272
|
+
disableThrottlingMode,
|
|
273
|
+
|
|
274
|
+
// Status
|
|
275
|
+
batteryLevel: metrics.level,
|
|
276
|
+
isCharging: metrics.charging,
|
|
277
|
+
isLowPowerMode: metrics.isLowPowerMode,
|
|
278
|
+
isCriticalBattery: metrics.isCriticalBattery,
|
|
279
|
+
performanceMode: metrics.performanceMode,
|
|
280
|
+
throttlingEnabled: metrics.throttlingEnabled,
|
|
281
|
+
throttlingReason: metrics.throttlingReason,
|
|
282
|
+
|
|
283
|
+
// Optimization
|
|
284
|
+
getOptimizationRecommendations,
|
|
285
|
+
getPowerSavingSuggestions,
|
|
286
|
+
getBatteryStatus,
|
|
287
|
+
|
|
288
|
+
// Raw values
|
|
289
|
+
level: metrics.level,
|
|
290
|
+
charging: metrics.charging,
|
|
291
|
+
chargingTime: metrics.chargingTime,
|
|
292
|
+
dischargingTime: metrics.dischargingTime,
|
|
293
|
+
|
|
294
|
+
// Thresholds
|
|
295
|
+
thresholds: finalThresholds
|
|
296
|
+
}
|
|
297
|
+
}
|