import { StateRepository } from '../core'; /** * Service for detecting the current device viewport size category * * The Device service provides reactive methods to determine whether the current * viewport size falls into desktop, tablet, or phone categories. This is useful * for creating responsive components that adapt their UI based on available screen * real estate. * * Since Device extends {@link StateRepository}, components can use the `@State` * decorator to automatically re-render when the device size category changes * (e.g., when the user resizes their browser window or rotates their device). * * @example Checking device size * ```ts * import { PlatformServiceName } from '@limetech/lime-web-components'; * * class ExportButton { * private createExport(): string { * const device = platform.get(PlatformServiceName.Device); * * if (device.isPhoneSize()) { * return this.generateMobileExport(); * } * * return this.generateDesktopExport(); * } * * private generateMobileExport(): string { * return 'name,status'; * } * * private generateDesktopExport(): string { * return 'name,email,phone,address,status'; * } * } * ``` * * @example Conditional logic based on viewport size * ```ts * import { PlatformServiceName } from '@limetech/lime-web-components'; * * function getColumns(): string[] { * const device = platform.get(PlatformServiceName.Device); * * if (device.isDesktopSize()) { * return ['name', 'email', 'phone', 'address', 'status']; * } * * if (device.isTabletSize()) { * return ['name', 'email', 'status']; * } * * return ['name', 'status']; * } * ``` * * @public * @group Device */ export interface Device extends StateRepository { /** * Check if the current viewport size is in the desktop category * * Desktop size typically indicates a large screen with ample horizontal space * for full-featured layouts, multiple columns, and detailed information display. * * @returns `true` if the viewport is desktop-sized, `false` otherwise */ isDesktopSize(): boolean; /** * Check if the current viewport size is in the tablet category * * Tablet size typically indicates a medium-sized screen where some layout * adjustments may be needed compared to desktop, but more space is available * than on phone screens. * * @returns `true` if the viewport is tablet-sized, `false` otherwise */ isTabletSize(): boolean; /** * Check if the current viewport size is in the phone category * * Phone size typically indicates a small screen where compact layouts, single * columns, and simplified navigation patterns are most appropriate. * * @returns `true` if the viewport is phone-sized, `false` otherwise */ isPhoneSize(): boolean; }