|
| 1 | +import { |
| 2 | + any, |
| 3 | + array, |
| 4 | + assign, |
| 5 | + boolean, |
| 6 | + enums, |
| 7 | + object, |
| 8 | + optional, |
| 9 | + string, |
| 10 | + union, |
| 11 | +} from "superstruct"; |
| 12 | +import { ActionConfig, actionConfigStruct, LovelaceCardConfig } from "../../ha"; |
| 13 | +import { LovelaceCardFeatureConfig } from "../../ha/panels/lovelace/card-features/types"; |
| 14 | +import { lovelaceCardConfigStruct } from "../../shared/config/lovelace-card-config"; |
| 15 | + |
| 16 | +export type MushroomBadgeConfig = { |
| 17 | + icon?: string; |
| 18 | + color?: string; |
| 19 | + position?: "top-start" | "top-end" | "bottom-start" | "bottom-end"; |
| 20 | +}; |
| 21 | + |
| 22 | +export type TemplateNewCardConfig = LovelaceCardConfig & { |
| 23 | + entity?: string; |
| 24 | + // Content |
| 25 | + primary?: string; |
| 26 | + secondary?: string; |
| 27 | + color?: string; |
| 28 | + icon?: string; |
| 29 | + picture?: string; |
| 30 | + // Badges |
| 31 | + badge_icon?: string; |
| 32 | + badge_text?: string; |
| 33 | + badge_color?: string; |
| 34 | + // Style |
| 35 | + vertical?: boolean; |
| 36 | + multiline_secondary?: boolean; |
| 37 | + // Interactions |
| 38 | + tap_action?: ActionConfig; |
| 39 | + hold_action?: ActionConfig; |
| 40 | + double_tap_action?: ActionConfig; |
| 41 | + icon_tap_action?: ActionConfig; |
| 42 | + icon_hold_action?: ActionConfig; |
| 43 | + icon_double_tap_action?: ActionConfig; |
| 44 | + // Features |
| 45 | + features?: LovelaceCardFeatureConfig[]; |
| 46 | + features_position?: "bottom" | "inline"; |
| 47 | + // Entity IDs for template |
| 48 | + entity_id?: string | string[]; |
| 49 | +}; |
| 50 | + |
| 51 | +export const templateNewCardConfigStruct = assign( |
| 52 | + lovelaceCardConfigStruct, |
| 53 | + object({ |
| 54 | + entity: optional(string()), |
| 55 | + primary: optional(string()), |
| 56 | + secondary: optional(string()), |
| 57 | + color: optional(string()), |
| 58 | + icon: optional(string()), |
| 59 | + picture: optional(string()), |
| 60 | + // Badges |
| 61 | + badge_icon: optional(string()), |
| 62 | + badge_text: optional(string()), |
| 63 | + badge_color: optional(string()), |
| 64 | + // Style |
| 65 | + vertical: optional(boolean()), |
| 66 | + multiline_secondary: optional(boolean()), |
| 67 | + // Interactions |
| 68 | + tap_action: optional(actionConfigStruct), |
| 69 | + hold_action: optional(actionConfigStruct), |
| 70 | + double_tap_action: optional(actionConfigStruct), |
| 71 | + icon_tap_action: optional(actionConfigStruct), |
| 72 | + icon_hold_action: optional(actionConfigStruct), |
| 73 | + icon_double_tap_action: optional(actionConfigStruct), |
| 74 | + // Features |
| 75 | + features: optional(array(any())), |
| 76 | + features_position: optional(enums(["bottom", "inline"])), |
| 77 | + // Entity IDs for template |
| 78 | + entity_id: optional(union([string(), array(string())])), |
| 79 | + }) |
| 80 | +); |
0 commit comments