@hakit/components
Version:
A series of components to work with @hakit/core
41 lines • 3.21 kB
TypeScript
import { HassEntityWithService, FilterByDomain, EntityName } from '@hakit/core';
import { IconProps } from '@iconify/react';
import { CardBaseProps } from '../..';
import { FormatFunction } from './types';
type CustomFormatter = (date: Date, formatter: FormatFunction) => React.ReactNode;
type OmitProperties = "title" | "as" | "active" | "entity" | "service" | "serviceData" | "longPressCallback" | "modalProps";
export interface TimeCardProps extends Omit<CardBaseProps<"div">, OmitProperties> {
/** provide a custom entity to read the time from, if not found/provided it will update from machine time @default "sensor.time" */
timeEntity?: FilterByDomain<EntityName, "sensor">;
/** provide a custom entity to read the date from, if not found/provided it will update from machine time @default "sensor.date" */
dateEntity?: FilterByDomain<EntityName, "sensor">;
/** time format, by providing this it will bypass the sensor.time entity if available, for formatting options @see https://www.npmjs.com/package/intl-dateformat#formatters @default "hh:mm a", you can also provide a custom function which will call every time the component re-renders */
timeFormat?: string | CustomFormatter;
/** date format, by providing this it will bypass the sensor.date entity if available, for formatting options @see https://www.npmjs.com/package/intl-dateformat#formatters @default "dddd, MMMM DD YYYY", you can also provide a custom function which will call every time the component re-renders */
dateFormat?: string | CustomFormatter;
/** add this if you do not want to include the date, @default false */
hideDate?: boolean;
/** add this if you do not want to include the time, @default false */
hideTime?: boolean;
/** remove the icon before the time, @default false */
hideIcon?: boolean;
/** update throttle time in milliseconds for the timer when you're not using the entities and using custom formatters @default 1000 */
throttleTime?: number;
/** the name of the icon, defaults to the sensor.date icon or mdi:calendar @default mdi:calendar */
icon?: string;
/** the props for the icon, which includes styles for the icon */
iconProps?: Omit<IconProps, "icon">;
/** center everything instead of left aligned @default false */
center?: boolean;
/** callback when the card is pressed, it will return the time sensor entity */
onClick?: (entity: HassEntityWithService<"sensor">, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
}
/** There's no required props on this component, by default it retrieves information from the time and date sensor
* from your home assistant information and the dates are formatted by the timezone specified in your home assistant settings.
*
* If you do NOT want to use the entities from home assistant, even if they're available, simply provide a "format" attribute and it will skip
* the retrieval of the time and date sensors and use the format provided using a custom implementation outside of home assistant.
* */
export declare function TimeCard(props: TimeCardProps): import("@emotion/react/jsx-runtime").JSX.Element;
export {};
//# sourceMappingURL=index.d.ts.map