custom-card-helpers 1.8.0 → 1.9.0
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/.github/workflows/release.yml +98 -0
- package/.github/workflows/test.yml +38 -0
- package/dist/binary_sensor_icon.d.ts +1 -1
- package/dist/compute-state-display.d.ts +2 -2
- package/dist/const.d.ts +1 -1
- package/dist/datetime/duration_to_seconds.d.ts +6 -1
- package/dist/datetime/format_date.d.ts +50 -2
- package/dist/datetime/format_date_time.d.ts +22 -2
- package/dist/datetime/format_time.d.ts +22 -2
- package/dist/datetime/relative_time.d.ts +7 -5
- package/dist/datetime/seconds_to_duration.d.ts +1 -1
- package/dist/datetime/use_am_pm.d.ts +7 -0
- package/dist/fire-event.d.ts +5 -5
- package/dist/format-number.d.ts +10 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.m.js +1 -1
- package/dist/index.m.js.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types.d.ts +17 -28
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +29 -0
- package/docs/assets/icons.css +1043 -0
- package/docs/assets/{images/icons.png → icons.png} +0 -0
- package/docs/assets/{images/icons@2x.png → icons@2x.png} +0 -0
- package/docs/assets/main.js +52 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1388 -0
- package/docs/assets/{images/widgets.png → widgets.png} +0 -0
- package/docs/assets/{images/widgets@2x.png → widgets@2x.png} +0 -0
- package/docs/enums/NumberFormat.html +1 -0
- package/docs/enums/TimeFormat.html +1 -0
- package/docs/index.html +10 -246
- package/docs/interfaces/ActionHandlerDetail.html +1 -0
- package/docs/interfaces/ActionHandlerOptions.html +1 -0
- package/docs/interfaces/BaseActionConfig.html +3 -0
- package/docs/interfaces/CallServiceActionConfig.html +1 -0
- package/docs/interfaces/ConfirmationRestrictionConfig.html +1 -0
- package/docs/interfaces/Credential.html +1 -0
- package/docs/interfaces/CurrentUser.html +1 -0
- package/docs/interfaces/CustomActionConfig.html +1 -0
- package/docs/interfaces/EntitiesCardEntityConfig.html +1 -0
- package/docs/interfaces/EntityConfig.html +1 -0
- package/docs/interfaces/FrontendLocaleData.html +1 -0
- package/docs/interfaces/HASSDomEvent.html +29 -0
- package/docs/interfaces/HomeAssistant.html +1 -0
- package/docs/interfaces/LovelaceBadgeConfig.html +1 -0
- package/docs/interfaces/LovelaceCard.html +291 -0
- package/docs/interfaces/LovelaceCardConfig.html +1 -0
- package/docs/interfaces/LovelaceCardEditor.html +291 -0
- package/docs/interfaces/LovelaceConfig.html +1 -0
- package/docs/interfaces/LovelaceElementConfigBase.html +1 -0
- package/docs/interfaces/LovelaceViewConfig.html +1 -0
- package/docs/interfaces/MFAModule.html +1 -0
- package/docs/interfaces/MoreInfoActionConfig.html +1 -0
- package/docs/interfaces/NavigateActionConfig.html +1 -0
- package/docs/interfaces/NoActionConfig.html +1 -0
- package/docs/interfaces/Panel.html +1 -0
- package/docs/interfaces/Panels.html +1 -0
- package/docs/interfaces/Resources.html +1 -0
- package/docs/interfaces/RestrictionConfig.html +1 -0
- package/docs/interfaces/ServiceCallRequest.html +1 -0
- package/docs/interfaces/ShowViewConfig.html +1 -0
- package/docs/interfaces/Theme.html +1 -0
- package/docs/interfaces/Themes.html +1 -0
- package/docs/interfaces/ToggleActionConfig.html +1 -0
- package/docs/interfaces/ToggleMenuActionConfig.html +1 -0
- package/docs/interfaces/Translation.html +1 -0
- package/docs/interfaces/UrlActionConfig.html +1 -0
- package/docs/interfaces/Window.html +1 -0
- package/docs/modules.html +151 -0
- package/package.json +11 -11
- package/src/binary_sensor_icon.ts +32 -23
- package/src/compute-rtl.ts +1 -1
- package/src/compute-state-display.ts +89 -44
- package/src/const.ts +1 -1
- package/src/cover_icon.ts +5 -5
- package/src/create-thing.ts +3 -1
- package/src/datetime/duration_to_seconds.ts +6 -1
- package/src/datetime/format_date.ts +119 -21
- package/src/datetime/format_date_time.ts +70 -23
- package/src/datetime/format_time.ts +57 -18
- package/src/datetime/relative_time.ts +23 -44
- package/src/datetime/seconds_to_duration.ts +3 -1
- package/src/datetime/timer_time_remaining.ts +1 -1
- package/src/datetime/use_am_pm.ts +22 -0
- package/src/domain_icons.ts +52 -52
- package/src/format-number.ts +65 -41
- package/src/handle-action.ts +1 -1
- package/src/handle-click.ts +1 -1
- package/src/input_datetime_icon.ts +2 -2
- package/src/sensor_icon.ts +19 -19
- package/src/translations/localize.ts +29 -46
- package/src/types.ts +22 -28
- package/tsconfig.json +11 -0
- package/dist/long-press-directive.d.ts +0 -10
- package/dist/lovelace-types.d.ts +0 -0
- package/dist/translations/localize.d.ts +0 -41
- package/docs/assets/css/main.css +0 -2679
- package/docs/assets/js/main.js +0 -1
- package/docs/assets/js/search.json +0 -1
- package/docs/enums/_types_.numberformat.html +0 -232
- package/docs/enums/_types_.timeformat.html +0 -204
- package/docs/globals.html +0 -290
- package/docs/interfaces/_fire_event_.__global.hassdomevents.html +0 -142
- package/docs/interfaces/_fire_event_.hassdomevent.html +0 -710
- package/docs/interfaces/_haptic_.__global.globaleventhandlerseventmap.html +0 -177
- package/docs/interfaces/_haptic_.__global.hassdomevents.html +0 -177
- package/docs/interfaces/_navigate_.__global.hassdomevents.html +0 -182
- package/docs/interfaces/_translations_localize_.formatstype.html +0 -206
- package/docs/interfaces/_translations_localize_.formattype.html +0 -150
- package/docs/interfaces/_types_.__global.hassdomevents.html +0 -341
- package/docs/interfaces/_types_.actionhandlerdetail.html +0 -171
- package/docs/interfaces/_types_.actionhandleroptions.html +0 -185
- package/docs/interfaces/_types_.baseactionconfig.html +0 -197
- package/docs/interfaces/_types_.callserviceactionconfig.html +0 -258
- package/docs/interfaces/_types_.confirmationrestrictionconfig.html +0 -185
- package/docs/interfaces/_types_.credential.html +0 -185
- package/docs/interfaces/_types_.currentuser.html +0 -241
- package/docs/interfaces/_types_.customactionconfig.html +0 -219
- package/docs/interfaces/_types_.entitiescardentityconfig.html +0 -391
- package/docs/interfaces/_types_.entityconfig.html +0 -232
- package/docs/interfaces/_types_.frontendlocaledata.html +0 -199
- package/docs/interfaces/_types_.frontendtranslationdata.html +0 -185
- package/docs/interfaces/_types_.homeassistant.html +0 -663
- package/docs/interfaces/_types_.lovelacebadgeconfig.html +0 -175
- package/docs/interfaces/_types_.lovelacecard.html +0 -6036
- package/docs/interfaces/_types_.lovelacecardconfig.html +0 -203
- package/docs/interfaces/_types_.lovelacecardeditor.html +0 -6001
- package/docs/interfaces/_types_.lovelaceconfig.html +0 -199
- package/docs/interfaces/_types_.lovelaceelementconfigbase.html +0 -185
- package/docs/interfaces/_types_.lovelaceviewconfig.html +0 -297
- package/docs/interfaces/_types_.mfamodule.html +0 -199
- package/docs/interfaces/_types_.moreinfoactionconfig.html +0 -233
- package/docs/interfaces/_types_.navigateactionconfig.html +0 -233
- package/docs/interfaces/_types_.noactionconfig.html +0 -219
- package/docs/interfaces/_types_.panel.html +0 -227
- package/docs/interfaces/_types_.panels.html +0 -143
- package/docs/interfaces/_types_.resources.html +0 -148
- package/docs/interfaces/_types_.restrictionconfig.html +0 -171
- package/docs/interfaces/_types_.showviewconfig.html +0 -171
- package/docs/interfaces/_types_.theme.html +0 -199
- package/docs/interfaces/_types_.themes.html +0 -193
- package/docs/interfaces/_types_.toggleactionconfig.html +0 -219
- package/docs/interfaces/_types_.togglemenuactionconfig.html +0 -219
- package/docs/interfaces/_types_.translation.html +0 -207
- package/docs/interfaces/_types_.urlactionconfig.html +0 -233
- package/docs/interfaces/_types_.window.html +0 -318
- package/docs/modules/_apply_themes_on_element_.html +0 -176
- package/docs/modules/_binary_sensor_icon_.html +0 -163
- package/docs/modules/_compute_card_size_.html +0 -158
- package/docs/modules/_compute_domain_.html +0 -158
- package/docs/modules/_compute_entity_.html +0 -158
- package/docs/modules/_compute_rtl_.html +0 -185
- package/docs/modules/_compute_state_display_.html +0 -167
- package/docs/modules/_compute_state_domain_.html +0 -158
- package/docs/modules/_const_.html +0 -342
- package/docs/modules/_cover_icon_.html +0 -158
- package/docs/modules/_create_thing_.html +0 -425
- package/docs/modules/_datetime_duration_to_seconds_.html +0 -158
- package/docs/modules/_datetime_format_date_.html +0 -174
- package/docs/modules/_datetime_format_date_time_.html +0 -174
- package/docs/modules/_datetime_format_time_.html +0 -174
- package/docs/modules/_datetime_relative_time_.html +0 -214
- package/docs/modules/_datetime_seconds_to_duration_.html +0 -185
- package/docs/modules/_datetime_timer_time_remaining_.html +0 -158
- package/docs/modules/_debounce_.html +0 -192
- package/docs/modules/_domain_icons_.html +0 -553
- package/docs/modules/_evaluate_filter_.html +0 -161
- package/docs/modules/_fire_event_.__global.html +0 -140
- package/docs/modules/_fire_event_.html +0 -243
- package/docs/modules/_format_number_.html +0 -229
- package/docs/modules/_get_lovelace_.html +0 -152
- package/docs/modules/_handle_action_.html +0 -237
- package/docs/modules/_handle_click_.html +0 -187
- package/docs/modules/_haptic_.__global.html +0 -144
- package/docs/modules/_haptic_.html +0 -196
- package/docs/modules/_has_action_.html +0 -158
- package/docs/modules/_has_changed_.html +0 -164
- package/docs/modules/_has_double_click_.html +0 -158
- package/docs/modules/_index_.html +0 -941
- package/docs/modules/_input_datetime_icon_.html +0 -158
- package/docs/modules/_lovelace_types_.html +0 -116
- package/docs/modules/_navigate_.__global.html +0 -140
- package/docs/modules/_navigate_.html +0 -175
- package/docs/modules/_scroll_to_target_.html +0 -172
- package/docs/modules/_sensor_icon_.html +0 -240
- package/docs/modules/_state_icon_.html +0 -220
- package/docs/modules/_toggle_entity_.html +0 -161
- package/docs/modules/_translations_localize_.html +0 -284
- package/docs/modules/_turn_on_off_entities_.html +0 -164
- package/docs/modules/_turn_on_off_entity_.html +0 -164
- package/docs/modules/_types_.__global.html +0 -140
- package/docs/modules/_types_.html +0 -384
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
name: "Release"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
prepare:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v2
|
|
13
|
+
|
|
14
|
+
- name: Get yarn cache directory path
|
|
15
|
+
id: yarn-cache-dir-path
|
|
16
|
+
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
17
|
+
|
|
18
|
+
- uses: actions/cache@v2
|
|
19
|
+
with:
|
|
20
|
+
path: '**/node_modules'
|
|
21
|
+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
|
22
|
+
|
|
23
|
+
- name: Setup Node
|
|
24
|
+
uses: actions/setup-node@v2
|
|
25
|
+
with:
|
|
26
|
+
node-version: '14'
|
|
27
|
+
cache: 'yarn'
|
|
28
|
+
|
|
29
|
+
- name: Install dependencies
|
|
30
|
+
if: steps.yarn-cache.outputs.cache-hit != 'true'
|
|
31
|
+
run: yarn install
|
|
32
|
+
|
|
33
|
+
#buildnpublish:
|
|
34
|
+
# needs: prepare
|
|
35
|
+
# runs-on: ubuntu-latest
|
|
36
|
+
# steps:
|
|
37
|
+
# - name: Checkout the repository
|
|
38
|
+
# uses: actions/checkout@v2
|
|
39
|
+
|
|
40
|
+
# - name: Get yarn cache directory path
|
|
41
|
+
# id: yarn-cache-dir-path
|
|
42
|
+
# run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
43
|
+
|
|
44
|
+
# - name: Setup Node
|
|
45
|
+
# uses: actions/setup-node@v2
|
|
46
|
+
# with:
|
|
47
|
+
# node-version: '14'
|
|
48
|
+
|
|
49
|
+
# - uses: actions/cache@v2
|
|
50
|
+
# with:
|
|
51
|
+
# path: '**/node_modules'
|
|
52
|
+
# key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
|
53
|
+
|
|
54
|
+
# - name: Install dependencies
|
|
55
|
+
# if: steps.yarn-cache.outputs.cache-hit != 'true'
|
|
56
|
+
# run: yarn install
|
|
57
|
+
|
|
58
|
+
# - name: Building
|
|
59
|
+
# run: yarn build
|
|
60
|
+
|
|
61
|
+
# - uses: JS-DevTools/npm-publish@v1
|
|
62
|
+
# with:
|
|
63
|
+
# token: ${{ secrets.NPM_TOKEN }}
|
|
64
|
+
|
|
65
|
+
docs:
|
|
66
|
+
# needs: buildnpublish
|
|
67
|
+
runs-on: ubuntu-latest
|
|
68
|
+
steps:
|
|
69
|
+
- name: Checkout the repository
|
|
70
|
+
uses: actions/checkout@v2
|
|
71
|
+
|
|
72
|
+
- name: Get yarn cache directory path
|
|
73
|
+
id: yarn-cache-dir-path
|
|
74
|
+
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
75
|
+
|
|
76
|
+
- name: Setup Node
|
|
77
|
+
uses: actions/setup-node@v2
|
|
78
|
+
with:
|
|
79
|
+
node-version: '14'
|
|
80
|
+
|
|
81
|
+
- uses: actions/cache@v2
|
|
82
|
+
with:
|
|
83
|
+
path: '**/node_modules'
|
|
84
|
+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
|
85
|
+
|
|
86
|
+
- name: Install dependencies
|
|
87
|
+
if: steps.yarn-cache.outputs.cache-hit != 'true'
|
|
88
|
+
run: yarn install
|
|
89
|
+
|
|
90
|
+
- name: Create the docs directory locally in CI
|
|
91
|
+
run: npm run docs
|
|
92
|
+
|
|
93
|
+
- name: Deploy 🚀
|
|
94
|
+
uses: JamesIves/github-pages-deploy-action@4.1.4
|
|
95
|
+
with:
|
|
96
|
+
# The Branch here is a reserved branch for github
|
|
97
|
+
branch: gh-pages
|
|
98
|
+
folder: docs
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: "Build"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- master
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
name: Test build
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v2
|
|
17
|
+
|
|
18
|
+
- name: Get yarn cache directory path
|
|
19
|
+
id: yarn-cache-dir-path
|
|
20
|
+
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
21
|
+
|
|
22
|
+
- uses: actions/cache@v2
|
|
23
|
+
with:
|
|
24
|
+
path: '**/node_modules'
|
|
25
|
+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
|
26
|
+
|
|
27
|
+
- name: Setup Node
|
|
28
|
+
uses: actions/setup-node@v2
|
|
29
|
+
with:
|
|
30
|
+
node-version: '14'
|
|
31
|
+
|
|
32
|
+
- name: Install dependencies
|
|
33
|
+
if: steps.yarn-cache.outputs.cache-hit != 'true'
|
|
34
|
+
run: yarn install
|
|
35
|
+
|
|
36
|
+
# Using TSC instead of microbundle because it detects the same errors and is alot quicker
|
|
37
|
+
- name: Build
|
|
38
|
+
run: tsc
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { HassEntity } from "home-assistant-js-websocket";
|
|
2
2
|
/** Return an icon representing a binary sensor state. */
|
|
3
|
-
export declare const binarySensorIcon: (state
|
|
3
|
+
export declare const binarySensorIcon: (state?: string | undefined, stateObj?: HassEntity | undefined) => "mdi:battery" | "mdi:battery-outline" | "mdi:battery-charging" | "mdi:thermometer" | "mdi:snowflake" | "mdi:server-network-off" | "mdi:server-network" | "mdi:door-closed" | "mdi:door-open" | "mdi:garage" | "mdi:garage-open" | "mdi:power-plug-off" | "mdi:power-plug" | "mdi:check-circle" | "mdi:alert-circle" | "mdi:smoke" | "mdi:fire" | "mdi:brightness-5" | "mdi:brightness-7" | "mdi:lock" | "mdi:lock-open" | "mdi:water-off" | "mdi:water" | "mdi:walk" | "mdi:run" | "mdi:home-outline" | "mdi:home" | "mdi:square" | "mdi:square-outline" | "mdi:stop" | "mdi:play" | "mdi:music-note-off" | "mdi:music-note" | "mdi:package" | "mdi:package-up" | "mdi:crop-portrait" | "mdi:vibrate" | "mdi:window-closed" | "mdi:window-open" | "mdi:radiobox-blank" | "mdi:checkbox-marked-circle";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { HassEntity } from "home-assistant-js-websocket";
|
|
2
2
|
import { LocalizeFunc } from "./translations/localize";
|
|
3
|
-
import {
|
|
4
|
-
export declare
|
|
3
|
+
import { FrontendLocaleData } from "./types";
|
|
4
|
+
export declare const computeStateDisplay: (localize: LocalizeFunc, stateObj: HassEntity, locale: FrontendLocaleData, state?: string | undefined) => string;
|
package/dist/const.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Constants to be used in the frontend. */
|
|
2
2
|
/** Icon to use when no icon specified for domain. */
|
|
3
|
-
export declare const DEFAULT_DOMAIN_ICON = "
|
|
3
|
+
export declare const DEFAULT_DOMAIN_ICON = "mdi:bookmark";
|
|
4
4
|
/** Panel to show when no panel is picked. */
|
|
5
5
|
export declare const DEFAULT_PANEL = "lovelace";
|
|
6
6
|
/** Domains that have a state card. */
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Convert a Duration hh:mm:ss format to seconds
|
|
3
|
+
* @param duration hh:mm:ss formated duration
|
|
4
|
+
* @returns duration in seconds
|
|
5
|
+
*/
|
|
6
|
+
export default function durationToSeconds(duration: string): number;
|
|
@@ -1,2 +1,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { FrontendLocaleData } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Formatting a Date to the dddd, mmmm yy format e.g. Tuesday, August 10
|
|
4
|
+
* @param dateObj The date to convert
|
|
5
|
+
* @param locale The users's locale settings
|
|
6
|
+
* @returns date string like "Tuesday, August 10"
|
|
7
|
+
*/
|
|
8
|
+
export declare const formatDateWeekday: (dateObj: Date, locale: FrontendLocaleData) => string;
|
|
9
|
+
/**
|
|
10
|
+
* Formatting a Date to the mmmm dd, yyyy format e.g. August 10, 2021
|
|
11
|
+
* @param dateObj The date to convert
|
|
12
|
+
* @param locale The users's locale settings
|
|
13
|
+
* @returns date string like "August 10, 2021"
|
|
14
|
+
*/
|
|
15
|
+
export declare const formatDate: (dateObj: Date, locale: FrontendLocaleData) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Formatting a Date to the classic date format e.g. 10/08/2021
|
|
18
|
+
* @param dateObj The date to convert
|
|
19
|
+
* @param locale The users's locale settings
|
|
20
|
+
* @returns classic date format "10/08/2021"
|
|
21
|
+
*/
|
|
22
|
+
export declare const formatDateNumeric: (dateObj: Date, locale: FrontendLocaleData) => string;
|
|
23
|
+
/**
|
|
24
|
+
* Formatting a Date to just a month with days e.g. Aug 10
|
|
25
|
+
* @param dateObj The date to convert
|
|
26
|
+
* @param locale The users's locale settings
|
|
27
|
+
* @returns month and day like "Aug 10"
|
|
28
|
+
*/
|
|
29
|
+
export declare const formatDateShort: (dateObj: Date, locale: FrontendLocaleData) => string;
|
|
30
|
+
/**
|
|
31
|
+
* Formatting a Date to just a month with year e.g. August 2021
|
|
32
|
+
* @param dateObj The date to convert
|
|
33
|
+
* @param locale The users's locale settings
|
|
34
|
+
* @returns month and year like "August 2021"
|
|
35
|
+
*/
|
|
36
|
+
export declare const formatDateMonthYear: (dateObj: Date, locale: FrontendLocaleData) => string;
|
|
37
|
+
/**
|
|
38
|
+
* Formatting a Date to just a month e.g. August
|
|
39
|
+
* @param dateObj The date to convert
|
|
40
|
+
* @param locale The users's locale settings
|
|
41
|
+
* @returns the written out months of the date
|
|
42
|
+
*/
|
|
43
|
+
export declare const formatDateMonth: (dateObj: Date, locale: FrontendLocaleData) => string;
|
|
44
|
+
/**
|
|
45
|
+
* Formatting a Date to just a year e.g. 2021
|
|
46
|
+
* @param dateObj The date to convert
|
|
47
|
+
* @param locale The users's locale settings
|
|
48
|
+
* @returns the year of the date in yyyy
|
|
49
|
+
*/
|
|
50
|
+
export declare const formatDateYear: (dateObj: Date, locale: FrontendLocaleData) => string;
|
|
@@ -1,2 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { FrontendLocaleData } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Formatting a dateObject to date with time e.g. August 9, 2021, 8:23 AM
|
|
4
|
+
* @param dateObj The date to convert
|
|
5
|
+
* @param locale The users's locale settings
|
|
6
|
+
* @returns month and day like "August 9, 2021, 8:23 AM"
|
|
7
|
+
*/
|
|
8
|
+
export declare const formatDateTime: (dateObj: Date, locale: FrontendLocaleData) => string;
|
|
9
|
+
/**
|
|
10
|
+
* Formatting a dateObject to date with time e.g. August 9, 2021, 8:23:15 AM
|
|
11
|
+
* @param dateObj The date to convert
|
|
12
|
+
* @param locale The users's locale settings
|
|
13
|
+
* @returns month and day like "August 9, 2021, 8:23:15 AM"
|
|
14
|
+
*/
|
|
15
|
+
export declare const formatDateTimeWithSeconds: (dateObj: Date, locale: FrontendLocaleData) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Formatting a Date to just date with AM/PM time e.g. 9/8/2021, 8:23 AM
|
|
18
|
+
* @param dateObj The date to convert
|
|
19
|
+
* @param locale The users's locale settings
|
|
20
|
+
* @returns month and day like "9/8/2021, 8:23 AM"
|
|
21
|
+
*/
|
|
22
|
+
export declare const formatDateTimeNumeric: (dateObj: Date, locale: FrontendLocaleData) => string;
|
|
@@ -1,2 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { FrontendLocaleData } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* 9:15 PM or 21:15
|
|
4
|
+
* @param dateObj The time to convert
|
|
5
|
+
* @param locale The users's locale settings
|
|
6
|
+
* @returns Reformated time in hh:mm
|
|
7
|
+
*/
|
|
8
|
+
export declare const formatTime: (dateObj: Date, locale: FrontendLocaleData) => string;
|
|
9
|
+
/**
|
|
10
|
+
* 9:15:24 PM or 21:15:24
|
|
11
|
+
* @param dateObj The time to convert
|
|
12
|
+
* @param locale The users's locale settings
|
|
13
|
+
* @returns Reformated time in hh:mm:ss
|
|
14
|
+
*/
|
|
15
|
+
export declare const formatTimeWithSeconds: (dateObj: Date, locale: FrontendLocaleData) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Tuesday 7:00 PM or Tuesday 19:00
|
|
18
|
+
* @param dateObj The datetime to convert
|
|
19
|
+
* @param locale The users's locale settings
|
|
20
|
+
* @returns Reformated weekday/time in dddd hh:mm
|
|
21
|
+
*/
|
|
22
|
+
export declare const formatTimeWeekday: (dateObj: Date, locale: FrontendLocaleData) => string;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { FrontendLocaleData } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Calculate a string representing a date object as relative time from now.
|
|
4
|
+
*
|
|
5
|
+
* Example output: 5 minutes ago, in 3 days.
|
|
6
|
+
*/
|
|
7
|
+
export declare const relativeTime: (from: Date, locale: FrontendLocaleData, to?: Date | undefined, includeTense?: boolean) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export default function secondsToDuration(d: number): string | null;
|
package/dist/fire-event.d.ts
CHANGED
|
@@ -21,8 +21,8 @@ export interface HASSDomEvent<T> extends Event {
|
|
|
21
21
|
* `node` on which to fire the event (HTMLElement, defaults to `this`).
|
|
22
22
|
* @return {Event} The new event that was fired.
|
|
23
23
|
*/
|
|
24
|
-
export declare const fireEvent: <HassEvent extends
|
|
25
|
-
bubbles?: boolean;
|
|
26
|
-
cancelable?: boolean;
|
|
27
|
-
composed?: boolean;
|
|
28
|
-
}) => Event;
|
|
24
|
+
export declare const fireEvent: <HassEvent extends keyof HASSDomEvents>(node: HTMLElement | Window, type: HassEvent, detail?: HASSDomEvents[HassEvent] | undefined, options?: {
|
|
25
|
+
bubbles?: boolean | undefined;
|
|
26
|
+
cancelable?: boolean | undefined;
|
|
27
|
+
composed?: boolean | undefined;
|
|
28
|
+
} | undefined) => Event;
|
package/dist/format-number.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HassEntity } from "home-assistant-js-websocket";
|
|
2
|
+
import { FrontendLocaleData } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Returns true if the entity is considered numeric based on the attributes it has
|
|
5
|
+
* @param stateObj The entity state object
|
|
6
|
+
*/
|
|
7
|
+
export declare const isNumericState: (stateObj: HassEntity) => boolean;
|
|
8
|
+
export declare const numberFormatToLocale: (localeOptions: FrontendLocaleData) => string | string[] | undefined;
|
|
9
|
+
export declare const round: (value: number, precision?: number) => number;
|
|
2
10
|
/**
|
|
3
11
|
* Formats a number based on the specified language with thousands separator(s) and decimal character for better legibility.
|
|
4
12
|
* @param num The number to format
|
|
5
13
|
* @param locale The user-selected language and number format, from `hass.locale`
|
|
6
14
|
* @param options Intl.NumberFormatOptions to use
|
|
7
15
|
*/
|
|
8
|
-
export declare const formatNumber: (num: string | number,
|
|
16
|
+
export declare const formatNumber: (num: string | number, localeOptions?: FrontendLocaleData | undefined, options?: Intl.NumberFormatOptions | undefined) => string;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=e(require("fecha"));function a(e){var t=e.split(":").map(Number);return 3600*t[0]+60*t[1]+t[2]}var r,n,s=function(){try{(new Date).toLocaleDateString("i")}catch(e){return"RangeError"===e.name}return!1}()?function(e,t){return e.toLocaleDateString(t.language,{year:"numeric",month:"long",day:"numeric"})}:function(e){return t.default.format(e,"mediumDate")},o=function(){try{(new Date).toLocaleString("i")}catch(e){return"RangeError"===e.name}return!1}()?function(e,t){return e.toLocaleString(t.language,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit"})}:function(e){return t.default.format(e,"haDateTime")},i=function(){try{(new Date).toLocaleTimeString("i")}catch(e){return"RangeError"===e.name}return!1}()?function(e,t){return e.toLocaleTimeString(t.language,{hour:"numeric",minute:"2-digit"})}:function(e){return t.default.format(e,"shortTime")},c=[60,60,24,7],u=["second","minute","hour","day"],l=function(e){return e<10?"0"+e:e};function m(){return(m=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e}).apply(this,arguments)}function h(e){return e.substr(0,e.indexOf("."))}function p(e){var t=e.locale.language||"en";return e.translationMetadata.translations[t]&&e.translationMetadata.translations[t].isRTL||!1}function f(e){return h(e.entity_id)}exports.NumberFormat=void 0,(r=exports.NumberFormat||(exports.NumberFormat={})).language="language",r.system="system",r.comma_decimal="comma_decimal",r.decimal_comma="decimal_comma",r.space_comma="space_comma",r.none="none",exports.TimeFormat=void 0,(n=exports.TimeFormat||(exports.TimeFormat={})).language="language",n.system="system",n.am_pm="12",n.twenty_four="24";var d=function(e,t,a){var r;switch(null==t?void 0:t.number_format){case exports.NumberFormat.comma_decimal:r=["en-US","en"];break;case exports.NumberFormat.decimal_comma:r=["de","es","it"];break;case exports.NumberFormat.space_comma:r=["fr","sv","cs"];break;case exports.NumberFormat.system:r=void 0;break;default:r=null==t?void 0:t.language}if(Number.isNaN=Number.isNaN||function e(t){return"number"==typeof t&&e(t)},!Number.isNaN(Number(e))&&Intl&&(null==t?void 0:t.number_format)!==exports.NumberFormat.none)try{return new Intl.NumberFormat(r,g(e,a)).format(Number(e))}catch(t){return console.error(t),new Intl.NumberFormat(void 0,g(e,a)).format(Number(e))}return e?e.toString():""},g=function(e,t){var a=t||{};if("string"!=typeof e)return a;if(!t||!t.minimumFractionDigits&&!t.maximumFractionDigits){var r=e.indexOf(".")>-1?e.split(".")[1].length:0;a.minimumFractionDigits=r,a.maximumFractionDigits=r}return a},b=["closed","locked","off"],v=new Set(["fan","input_boolean","light","switch","group","automation"]),_=function(e,t,a,r){r=r||{},a=null==a?{}:a;var n=new Event(t,{bubbles:void 0===r.bubbles||r.bubbles,cancelable:Boolean(r.cancelable),composed:void 0===r.composed||r.composed});return n.detail=a,e.dispatchEvent(n),n},y=new Set(["call-service","divider","section","weblink","cast","select"]),w={alert:"toggle",automation:"toggle",climate:"climate",cover:"cover",fan:"toggle",group:"group",input_boolean:"toggle",input_number:"input-number",input_select:"input-select",input_text:"input-text",light:"toggle",lock:"lock",media_player:"media-player",remote:"toggle",scene:"scene",script:"script",sensor:"sensor",timer:"timer",switch:"toggle",vacuum:"toggle",water_heater:"climate",input_datetime:"input-datetime"},x={alert:"hass:alert",automation:"hass:playlist-play",calendar:"hass:calendar",camera:"hass:video",climate:"hass:thermostat",configurator:"hass:settings",conversation:"hass:text-to-speech",device_tracker:"hass:account",fan:"hass:fan",group:"hass:google-circles-communities",history_graph:"hass:chart-line",homeassistant:"hass:home-assistant",homekit:"hass:home-automation",image_processing:"hass:image-filter-frames",input_boolean:"hass:drawing",input_datetime:"hass:calendar-clock",input_number:"hass:ray-vertex",input_select:"hass:format-list-bulleted",input_text:"hass:textbox",light:"hass:lightbulb",mailbox:"hass:mailbox",notify:"hass:comment-alert",person:"hass:account",plant:"hass:flower",proximity:"hass:apple-safari",remote:"hass:remote",scene:"hass:google-pages",script:"hass:file-document",sensor:"hass:eye",simple_alarm:"hass:bell",sun:"hass:white-balance-sunny",switch:"hass:flash",timer:"hass:timer",updater:"hass:cloud-upload",vacuum:"hass:robot-vacuum",water_heater:"hass:thermometer",weblink:"hass:open-in-new"};function k(e,t){if(e in x)return x[e];switch(e){case"alarm_control_panel":switch(t){case"armed_home":return"hass:bell-plus";case"armed_night":return"hass:bell-sleep";case"disarmed":return"hass:bell-outline";case"triggered":return"hass:bell-ring";default:return"hass:bell"}case"binary_sensor":return t&&"off"===t?"hass:radiobox-blank":"hass:checkbox-marked-circle";case"cover":return"closed"===t?"hass:window-closed":"hass:window-open";case"lock":return t&&"unlocked"===t?"hass:lock-open":"hass:lock";case"media_player":return t&&"off"!==t&&"idle"!==t?"hass:cast-connected":"hass:cast";case"zwave":switch(t){case"dead":return"hass:emoticon-dead";case"sleeping":return"hass:sleep";case"initializing":return"hass:timer-sand";default:return"hass:z-wave"}default:return console.warn("Unable to find icon for domain "+e+" ("+t+")"),"hass:bookmark"}}var S=function(e){_(window,"haptic",e)},N=function(e,t,a){void 0===a&&(a=!1),a?history.replaceState(null,"",t):history.pushState(null,"",t),_(window,"location-changed",{replace:a})},T=function(e,t,a){void 0===a&&(a=!0);var r,n=h(t),s="group"===n?"homeassistant":n;switch(n){case"lock":r=a?"unlock":"lock";break;case"cover":r=a?"open_cover":"close_cover";break;default:r=a?"turn_on":"turn_off"}return e.callService(s,r,{entity_id:t})},D=function(e,t){var a=b.includes(e.states[t].state);return T(e,t,a)},O=function(e,t,a,r){if(r||(r={action:"more-info"}),!r.confirmation||r.confirmation.exemptions&&r.confirmation.exemptions.some(function(e){return e.user===t.user.id})||(S("warning"),confirm(r.confirmation.text||"Are you sure you want to "+r.action+"?")))switch(r.action){case"more-info":(a.entity||a.camera_image)&&_(e,"hass-more-info",{entityId:a.entity?a.entity:a.camera_image});break;case"navigate":r.navigation_path&&N(0,r.navigation_path);break;case"url":r.url_path&&window.open(r.url_path);break;case"toggle":a.entity&&(D(t,a.entity),S("success"));break;case"call-service":if(!r.service)return void S("failure");var n=r.service.split(".",2);t.callService(n[0],n[1],r.service_data),S("success");break;case"fire-dom-event":_(e,"ll-custom",r)}},E={humidity:"hass:water-percent",illuminance:"hass:brightness-5",temperature:"hass:thermometer",pressure:"hass:gauge",power:"hass:flash",signal_strength:"hass:wifi"},F={binary_sensor:function(e){var t=e.state&&"off"===e.state;switch(e.attributes.device_class){case"battery":return t?"hass:battery":"hass:battery-outline";case"cold":return t?"hass:thermometer":"hass:snowflake";case"connectivity":return t?"hass:server-network-off":"hass:server-network";case"door":return t?"hass:door-closed":"hass:door-open";case"garage_door":return t?"hass:garage":"hass:garage-open";case"gas":case"power":case"problem":case"safety":case"smoke":return t?"hass:shield-check":"hass:alert";case"heat":return t?"hass:thermometer":"hass:fire";case"light":return t?"hass:brightness-5":"hass:brightness-7";case"lock":return t?"hass:lock":"hass:lock-open";case"moisture":return t?"hass:water-off":"hass:water";case"motion":return t?"hass:walk":"hass:run";case"occupancy":return t?"hass:home-outline":"hass:home";case"opening":return t?"hass:square":"hass:square-outline";case"plug":return t?"hass:power-plug-off":"hass:power-plug";case"presence":return t?"hass:home-outline":"hass:home";case"sound":return t?"hass:music-note-off":"hass:music-note";case"vibration":return t?"hass:crop-portrait":"hass:vibrate";case"window":return t?"hass:window-closed":"hass:window-open";default:return t?"hass:radiobox-blank":"hass:checkbox-marked-circle"}},cover:function(e){var t="closed"!==e.state;switch(e.attributes.device_class){case"garage":return t?"hass:garage-open":"hass:garage";case"door":return t?"hass:door-open":"hass:door-closed";case"shutter":return t?"hass:window-shutter-open":"hass:window-shutter";case"blind":return t?"hass:blinds-open":"hass:blinds";case"window":return t?"hass:window-open":"hass:window-closed";default:return k("cover",e.state)}},sensor:function(e){var t=e.attributes.device_class;if(t&&t in E)return E[t];if("battery"===t){var a=Number(e.state);if(isNaN(a))return"hass:battery-unknown";var r=10*Math.round(a/10);return r>=100?"hass:battery":r<=0?"hass:battery-alert":"hass:battery-"+r}var n=e.attributes.unit_of_measurement;return"°C"===n||"°F"===n?"hass:thermometer":k("sensor")},input_datetime:function(e){return e.attributes.has_date?e.attributes.has_time?k("input_datetime"):"hass:calendar":"hass:clock"}};exports.DEFAULT_DOMAIN_ICON="hass:bookmark",exports.DEFAULT_PANEL="lovelace",exports.DEFAULT_VIEW_ENTITY_ID="group.default_view",exports.DOMAINS_HIDE_MORE_INFO=["input_number","input_select","input_text","scene","weblink"],exports.DOMAINS_MORE_INFO_NO_HISTORY=["camera","configurator","history_graph","scene"],exports.DOMAINS_TOGGLE=v,exports.DOMAINS_WITH_CARD=["climate","cover","configurator","input_select","input_number","input_text","lock","media_player","scene","script","timer","vacuum","water_heater","weblink"],exports.DOMAINS_WITH_MORE_INFO=["alarm_control_panel","automation","camera","climate","configurator","cover","fan","group","history_graph","input_datetime","light","lock","media_player","script","sun","updater","vacuum","water_heater","weather"],exports.STATES_OFF=b,exports.UNIT_C="°C",exports.UNIT_F="°F",exports.applyThemesOnElement=function(e,t,a,r){void 0===r&&(r=!1),e._themes||(e._themes={});var n=t.default_theme;("default"===a||a&&t.themes[a])&&(n=a);var s=m({},e._themes);if("default"!==n){var o=t.themes[n];Object.keys(o).forEach(function(t){var a="--"+t;e._themes[a]="",s[a]=o[t]})}if(e.updateStyles?e.updateStyles(s):window.ShadyCSS&&window.ShadyCSS.styleSubtree(e,s),r){var i=document.querySelector("meta[name=theme-color]");if(i){i.hasAttribute("default-content")||i.setAttribute("default-content",i.getAttribute("content"));var c=s["--primary-color"]||i.getAttribute("default-content");i.setAttribute("content",c)}}},exports.computeCardSize=function(e){return"function"==typeof e.getCardSize?e.getCardSize():4},exports.computeDomain=h,exports.computeEntity=function(e){return e.substr(e.indexOf(".")+1)},exports.computeRTL=p,exports.computeRTLDirection=function(e){return p(e)?"rtl":"ltr"},exports.computeStateDisplay=function(e,t,a,r){var n=void 0!==r?r:t.state;if("unknown"===n||"unavailable"===n)return e("state.default."+n);if(t.attributes.unit_of_measurement)return d(n,a)+" "+t.attributes.unit_of_measurement;var c=f(t);if("input_datetime"===c){var u;if(!t.attributes.has_time)return u=new Date(t.attributes.year,t.attributes.month-1,t.attributes.day),s(u,a);if(!t.attributes.has_date){var l=new Date;return u=new Date(l.getFullYear(),l.getMonth(),l.getDay(),t.attributes.hour,t.attributes.minute),i(u,a)}return u=new Date(t.attributes.year,t.attributes.month-1,t.attributes.day,t.attributes.hour,t.attributes.minute),o(u,a)}return"humidifier"===c&&"on"===n&&t.attributes.humidity?t.attributes.humidity+" %":"counter"===c||"number"===c?d(n,a):t.attributes.device_class&&e("component."+c+".state."+t.attributes.device_class+"."+t.state)||e("component."+c+".state._."+t.state)||t.state},exports.computeStateDomain=f,exports.createThing=function(e,t){void 0===t&&(t=!1);var a=function(e,t){return r("hui-error-card",{type:"error",error:e,config:t})},r=function(e,t){var r=window.document.createElement(e);try{r.setConfig(t)}catch(r){return console.error(e,r),a(r.message,t)}return r};if(!e||"object"!=typeof e||!t&&!e.type)return a("No type defined",e);var n=e.type;if(n&&n.startsWith("custom:"))n=n.substr("custom:".length);else if(t)if(y.has(n))n="hui-"+n+"-row";else{if(!e.entity)return a("Invalid config given.",e);var s=e.entity.split(".",1)[0];n="hui-"+(w[s]||"text")+"-entity-row"}else n="hui-"+n+"-card";if(customElements.get(n))return r(n,e);var o=a("Custom element doesn't exist: "+e.type+".",e);o.style.display="None";var i=setTimeout(function(){o.style.display=""},2e3);return customElements.whenDefined(e.type).then(function(){clearTimeout(i),_(o,"ll-rebuild",{},o)}),o},exports.debounce=function(e,t,a){var r;return void 0===a&&(a=!1),function(){var n=[].slice.call(arguments),s=this,o=function(){r=null,a||e.apply(s,n)},i=a&&!r;clearTimeout(r),r=setTimeout(o,t),i&&e.apply(s,n)}},exports.domainIcon=k,exports.durationToSeconds=a,exports.evaluateFilter=function(e,t){var a=t.value||t,r=t.attribute?e.attributes[t.attribute]:e.state;switch(t.operator||"=="){case"==":return r===a;case"<=":return r<=a;case"<":return r<a;case">=":return r>=a;case">":return r>a;case"!=":return r!==a;case"regex":return r.match(a);default:return!1}},exports.fireEvent=_,exports.fixedIcons=x,exports.formatDate=s,exports.formatDateTime=o,exports.formatNumber=d,exports.formatTime=i,exports.forwardHaptic=S,exports.getLovelace=function(){var e=document.querySelector("home-assistant");if(e=(e=(e=(e=(e=(e=(e=(e=e&&e.shadowRoot)&&e.querySelector("home-assistant-main"))&&e.shadowRoot)&&e.querySelector("app-drawer-layout partial-panel-resolver"))&&e.shadowRoot||e)&&e.querySelector("ha-panel-lovelace"))&&e.shadowRoot)&&e.querySelector("hui-root")){var t=e.lovelace;return t.current_view=e.___curView,t}return null},exports.handleAction=function(e,t,a,r){var n;"double_tap"===r&&a.double_tap_action?n=a.double_tap_action:"hold"===r&&a.hold_action?n=a.hold_action:"tap"===r&&a.tap_action&&(n=a.tap_action),O(e,t,a,n)},exports.handleActionConfig=O,exports.handleClick=function(e,t,a,r,n){var s;if(n&&a.double_tap_action?s=a.double_tap_action:r&&a.hold_action?s=a.hold_action:!r&&a.tap_action&&(s=a.tap_action),s||(s={action:"more-info"}),!s.confirmation||s.confirmation.exemptions&&s.confirmation.exemptions.some(function(e){return e.user===t.user.id})||confirm(s.confirmation.text||"Are you sure you want to "+s.action+"?"))switch(s.action){case"more-info":(s.entity||a.entity||a.camera_image)&&(_(e,"hass-more-info",{entityId:s.entity?s.entity:a.entity?a.entity:a.camera_image}),s.haptic&&S(s.haptic));break;case"navigate":s.navigation_path&&(N(0,s.navigation_path),s.haptic&&S(s.haptic));break;case"url":s.url_path&&window.open(s.url_path),s.haptic&&S(s.haptic);break;case"toggle":a.entity&&(D(t,a.entity),s.haptic&&S(s.haptic));break;case"call-service":if(!s.service)return;var o=s.service.split(".",2),i=o[0],c=o[1],u=m({},s.service_data);"entity"===u.entity_id&&(u.entity_id=a.entity),t.callService(i,c,u),s.haptic&&S(s.haptic);break;case"fire-dom-event":_(e,"ll-custom",s),s.haptic&&S(s.haptic)}},exports.hasAction=function(e){return void 0!==e&&"none"!==e.action},exports.hasConfigOrEntityChanged=function(e,t,a){if(t.has("config")||a)return!0;if(e.config.entity){var r=t.get("hass");return!r||r.states[e.config.entity]!==e.hass.states[e.config.entity]}return!1},exports.hasDoubleClick=function(e){return void 0!==e&&"none"!==e.action},exports.navigate=N,exports.relativeTime=function(e,t,a){void 0===a&&(a={});var r,n=((a.compareTime||new Date).getTime()-e.getTime())/1e3,s=!1===a.includeTense?"duration":(n>=0?"past":"future")+"_duration";n=Math.abs(n);for(var o=0;o<c.length;o++){if(n<c[o]){n=Math.floor(n),r=t("ui.components.relative_time."+s+"."+u[o],"count",n);break}n/=c[o]}return void 0===r&&(r=t("ui.components.relative_time."+s+".week","count",n=Math.floor(n))),r},exports.secondsToDuration=function(e){var t=Math.floor(e/3600),a=Math.floor(e%3600/60),r=Math.floor(e%3600%60);return t>0?t+":"+l(a)+":"+l(r):a>0?a+":"+l(r):r>0?""+r:null},exports.stateIcon=function(e){if(!e)return"hass:bookmark";if(e.attributes.icon)return e.attributes.icon;var t=h(e.entity_id);return t in F?F[t](e):k(t,e.state)},exports.timerTimeRemaining=function(e){var t=a(e.attributes.remaining);if("active"===e.state){var r=(new Date).getTime(),n=new Date(e.last_changed).getTime();t=Math.max(t-(r-n)/1e3,0)}return t},exports.toggleEntity=D,exports.turnOnOffEntities=function(e,t,a){void 0===a&&(a=!0);var r={};t.forEach(function(t){if(b.includes(e.states[t].state)===a){var n=h(t),s=["cover","lock"].includes(n)?n:"homeassistant";s in r||(r[s]=[]),r[s].push(t)}}),Object.keys(r).forEach(function(t){var n;switch(t){case"lock":n=a?"unlock":"lock";break;case"cover":n=a?"open_cover":"close_cover";break;default:n=a?"turn_on":"turn_off"}e.callService(t,n,{entity_id:r[t]})})},exports.turnOnOffEntity=T;
|
|
1
|
+
var e,t,r=require("@formatjs/intl-utils"),n=function(e,t){return i(t).format(e)},i=function(e){return new Intl.DateTimeFormat(e.language,{year:"numeric",month:"long",day:"numeric"})};exports.NumberFormat=void 0,(e=exports.NumberFormat||(exports.NumberFormat={})).language="language",e.system="system",e.comma_decimal="comma_decimal",e.decimal_comma="decimal_comma",e.space_comma="space_comma",e.none="none",exports.TimeFormat=void 0,(t=exports.TimeFormat||(exports.TimeFormat={})).language="language",t.system="system",t.am_pm="12",t.twenty_four="24";var a=function(e){if(e.time_format===exports.TimeFormat.language||e.time_format===exports.TimeFormat.system){var t=e.time_format===exports.TimeFormat.language?e.language:void 0,r=(new Date).toLocaleString(t);return r.includes("AM")||r.includes("PM")}return e.time_format===exports.TimeFormat.am_pm},o=function(e,t){return u(t).format(e)},u=function(e){return new Intl.DateTimeFormat(e.language,{year:"numeric",month:"long",day:"numeric",hour:a(e)?"numeric":"2-digit",minute:"2-digit",hour12:a(e)})},c=function(e,t){return m(t).format(e)},m=function(e){return new Intl.DateTimeFormat(e.language,{hour:"numeric",minute:"2-digit",hour12:a(e)})};function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function l(e){return e.substr(0,e.indexOf("."))}function d(e){var t,r=(null==e||null==(t=e.locale)?void 0:t.language)||"en";return e.translationMetadata.translations[r]&&e.translationMetadata.translations[r].isRTL||!1}function p(e){return l(e.entity_id)}var f=function(e){return!!e.attributes.unit_of_measurement||!!e.attributes.state_class},g=function(e){switch(e.number_format){case exports.NumberFormat.comma_decimal:return["en-US","en"];case exports.NumberFormat.decimal_comma:return["de","es","it"];case exports.NumberFormat.space_comma:return["fr","sv","cs"];case exports.NumberFormat.system:return;default:return e.language}},h=function(e,t){return void 0===t&&(t=2),Math.round(e*Math.pow(10,t))/Math.pow(10,t)},b=function(e,t,r){var n=t?g(t):void 0;if(Number.isNaN=Number.isNaN||function e(t){return"number"==typeof t&&e(t)},(null==t?void 0:t.number_format)!==exports.NumberFormat.none&&!Number.isNaN(Number(e))&&Intl)try{return new Intl.NumberFormat(n,_(e,r)).format(Number(e))}catch(t){return console.error(t),new Intl.NumberFormat(void 0,_(e,r)).format(Number(e))}return"string"==typeof e?e:h(e,null==r?void 0:r.maximumFractionDigits).toString()+("currency"===(null==r?void 0:r.style)?" "+r.currency:"")},_=function(e,t){var r=s({maximumFractionDigits:2},t);if("string"!=typeof e)return r;if(!t||!t.minimumFractionDigits&&!t.maximumFractionDigits){var n=e.indexOf(".")>-1?e.split(".")[1].length:0;r.minimumFractionDigits=n,r.maximumFractionDigits=n}return r},v=["closed","locked","off"],y=new Set(["fan","input_boolean","light","switch","group","automation"]),w=function(e,t,r,n){n=n||{},r=null==r?{}:r;var i=new Event(t,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});return i.detail=r,e.dispatchEvent(i),i},x=new Set(["call-service","divider","section","weblink","cast","select"]),k={alert:"toggle",automation:"toggle",climate:"climate",cover:"cover",fan:"toggle",group:"group",input_boolean:"toggle",input_number:"input-number",input_select:"input-select",input_text:"input-text",light:"toggle",lock:"lock",media_player:"media-player",remote:"toggle",scene:"scene",script:"script",sensor:"sensor",timer:"timer",switch:"toggle",vacuum:"toggle",water_heater:"climate",input_datetime:"input-datetime"},D={alert:"mdi:alert",automation:"mdi:playlist-play",calendar:"mdi:calendar",camera:"mdi:video",climate:"mdi:thermostat",configurator:"mdi:settings",conversation:"mdi:text-to-speech",device_tracker:"mdi:account",fan:"mdi:fan",group:"mdi:google-circles-communities",history_graph:"mdi:chart-line",homeassistant:"mdi:home-assistant",homekit:"mdi:home-automation",image_processing:"mdi:image-filter-frames",input_boolean:"mdi:drawing",input_datetime:"mdi:calendar-clock",input_number:"mdi:ray-vertex",input_select:"mdi:format-list-bulleted",input_text:"mdi:textbox",light:"mdi:lightbulb",mailbox:"mdi:mailbox",notify:"mdi:comment-alert",person:"mdi:account",plant:"mdi:flower",proximity:"mdi:apple-safari",remote:"mdi:remote",scene:"mdi:google-pages",script:"mdi:file-document",sensor:"mdi:eye",simple_alarm:"mdi:bell",sun:"mdi:white-balance-sunny",switch:"mdi:flash",timer:"mdi:timer",updater:"mdi:cloud-upload",vacuum:"mdi:robot-vacuum",water_heater:"mdi:thermometer",weblink:"mdi:open-in-new"};function T(e,t){if(e in D)return D[e];switch(e){case"alarm_control_panel":switch(t){case"armed_home":return"mdi:bell-plus";case"armed_night":return"mdi:bell-sleep";case"disarmed":return"mdi:bell-outline";case"triggered":return"mdi:bell-ring";default:return"mdi:bell"}case"binary_sensor":return t&&"off"===t?"mdi:radiobox-blank":"mdi:checkbox-marked-circle";case"cover":return"closed"===t?"mdi:window-closed":"mdi:window-open";case"lock":return t&&"unlocked"===t?"mdi:lock-open":"mdi:lock";case"media_player":return t&&"off"!==t&&"idle"!==t?"mdi:cast-connected":"mdi:cast";case"zwave":switch(t){case"dead":return"mdi:emoticon-dead";case"sleeping":return"mdi:sleep";case"initializing":return"mdi:timer-sand";default:return"mdi:z-wave"}default:return console.warn("Unable to find icon for domain "+e+" ("+t+")"),"mdi:bookmark"}}var F=function(e){w(window,"haptic",e)},N=function(e,t,r){void 0===r&&(r=!1),r?history.replaceState(null,"",t):history.pushState(null,"",t),w(window,"location-changed",{replace:r})},S=function(e,t,r){void 0===r&&(r=!0);var n,i=l(t),a="group"===i?"homeassistant":i;switch(i){case"lock":n=r?"unlock":"lock";break;case"cover":n=r?"open_cover":"close_cover";break;default:n=r?"turn_on":"turn_off"}return e.callService(a,n,{entity_id:t})},I=function(e,t){var r=v.includes(e.states[t].state);return S(e,t,r)},O=function(e,t,r,n){if(n||(n={action:"more-info"}),!n.confirmation||n.confirmation.exemptions&&n.confirmation.exemptions.some(function(e){return e.user===t.user.id})||(F("warning"),confirm(n.confirmation.text||"Are you sure you want to "+n.action+"?")))switch(n.action){case"more-info":(r.entity||r.camera_image)&&w(e,"hass-more-info",{entityId:r.entity?r.entity:r.camera_image});break;case"navigate":n.navigation_path&&N(0,n.navigation_path);break;case"url":n.url_path&&window.open(n.url_path);break;case"toggle":r.entity&&(I(t,r.entity),F("success"));break;case"call-service":if(!n.service)return void F("failure");var i=n.service.split(".",2);t.callService(i[0],i[1],n.service_data,n.target),F("success");break;case"fire-dom-event":w(e,"ll-custom",n)}},E={humidity:"mdi:water-percent",illuminance:"mdi:brightness-5",temperature:"mdi:thermometer",pressure:"mdi:gauge",power:"mdi:flash",signal_strength:"mdi:wifi"},A={binary_sensor:function(e,t){var r="off"===e;switch(null==t?void 0:t.attributes.device_class){case"battery":return r?"mdi:battery":"mdi:battery-outline";case"battery_charging":return r?"mdi:battery":"mdi:battery-charging";case"cold":return r?"mdi:thermometer":"mdi:snowflake";case"connectivity":return r?"mdi:server-network-off":"mdi:server-network";case"door":return r?"mdi:door-closed":"mdi:door-open";case"garage_door":return r?"mdi:garage":"mdi:garage-open";case"power":return r?"mdi:power-plug-off":"mdi:power-plug";case"gas":case"problem":case"safety":case"tamper":return r?"mdi:check-circle":"mdi:alert-circle";case"smoke":return r?"mdi:check-circle":"mdi:smoke";case"heat":return r?"mdi:thermometer":"mdi:fire";case"light":return r?"mdi:brightness-5":"mdi:brightness-7";case"lock":return r?"mdi:lock":"mdi:lock-open";case"moisture":return r?"mdi:water-off":"mdi:water";case"motion":return r?"mdi:walk":"mdi:run";case"occupancy":return r?"mdi:home-outline":"mdi:home";case"opening":return r?"mdi:square":"mdi:square-outline";case"plug":return r?"mdi:power-plug-off":"mdi:power-plug";case"presence":return r?"mdi:home-outline":"mdi:home";case"running":return r?"mdi:stop":"mdi:play";case"sound":return r?"mdi:music-note-off":"mdi:music-note";case"update":return r?"mdi:package":"mdi:package-up";case"vibration":return r?"mdi:crop-portrait":"mdi:vibrate";case"window":return r?"mdi:window-closed":"mdi:window-open";default:return r?"mdi:radiobox-blank":"mdi:checkbox-marked-circle"}},cover:function(e){var t="closed"!==e.state;switch(e.attributes.device_class){case"garage":return t?"mdi:garage-open":"mdi:garage";case"door":return t?"mdi:door-open":"mdi:door-closed";case"shutter":return t?"mdi:window-shutter-open":"mdi:window-shutter";case"blind":return t?"mdi:blinds-open":"mdi:blinds";case"window":return t?"mdi:window-open":"mdi:window-closed";default:return T("cover",e.state)}},sensor:function(e){var t=e.attributes.device_class;if(t&&t in E)return E[t];if("battery"===t){var r=Number(e.state);if(isNaN(r))return"mdi:battery-unknown";var n=10*Math.round(r/10);return n>=100?"mdi:battery":n<=0?"mdi:battery-alert":"hass:battery-"+n}var i=e.attributes.unit_of_measurement;return"°C"===i||"°F"===i?"mdi:thermometer":T("sensor")},input_datetime:function(e){return e.attributes.has_date?e.attributes.has_time?T("input_datetime"):"mdi:calendar":"mdi:clock"}};exports.DEFAULT_DOMAIN_ICON="mdi:bookmark",exports.DEFAULT_PANEL="lovelace",exports.DEFAULT_VIEW_ENTITY_ID="group.default_view",exports.DOMAINS_HIDE_MORE_INFO=["input_number","input_select","input_text","scene","weblink"],exports.DOMAINS_MORE_INFO_NO_HISTORY=["camera","configurator","history_graph","scene"],exports.DOMAINS_TOGGLE=y,exports.DOMAINS_WITH_CARD=["climate","cover","configurator","input_select","input_number","input_text","lock","media_player","scene","script","timer","vacuum","water_heater","weblink"],exports.DOMAINS_WITH_MORE_INFO=["alarm_control_panel","automation","camera","climate","configurator","cover","fan","group","history_graph","input_datetime","light","lock","media_player","script","sun","updater","vacuum","water_heater","weather"],exports.STATES_OFF=v,exports.UNIT_C="°C",exports.UNIT_F="°F",exports.applyThemesOnElement=function(e,t,r,n){void 0===n&&(n=!1),e._themes||(e._themes={});var i=t.default_theme;("default"===r||r&&t.themes[r])&&(i=r);var a=s({},e._themes);if("default"!==i){var o=t.themes[i];Object.keys(o).forEach(function(t){var r="--"+t;e._themes[r]="",a[r]=o[t]})}if(e.updateStyles?e.updateStyles(a):window.ShadyCSS&&window.ShadyCSS.styleSubtree(e,a),n){var u=document.querySelector("meta[name=theme-color]");if(u){u.hasAttribute("default-content")||u.setAttribute("default-content",u.getAttribute("content"));var c=a["--primary-color"]||u.getAttribute("default-content");u.setAttribute("content",c)}}},exports.computeCardSize=function(e){return"function"==typeof e.getCardSize?e.getCardSize():4},exports.computeDomain=l,exports.computeEntity=function(e){return e.substr(e.indexOf(".")+1)},exports.computeRTL=d,exports.computeRTLDirection=function(e){return d(e)?"rtl":"ltr"},exports.computeStateDisplay=function(e,t,r,i){var a=void 0!==i?i:t.state;if("unknown"===a||"unavailable"===a)return e("state.default."+a);if(f(t)){if("monetary"===t.attributes.device_class)try{return b(a,r,{style:"currency",currency:t.attributes.unit_of_measurement})}catch(e){}return b(a,r)+(t.attributes.unit_of_measurement?" "+t.attributes.unit_of_measurement:"")}var u=p(t);if("input_datetime"===u){var m;if(void 0===i)return t.attributes.has_date&&t.attributes.has_time?(m=new Date(t.attributes.year,t.attributes.month-1,t.attributes.day,t.attributes.hour,t.attributes.minute),o(m,r)):t.attributes.has_date?(m=new Date(t.attributes.year,t.attributes.month-1,t.attributes.day),n(m,r)):t.attributes.has_time?((m=new Date).setHours(t.attributes.hour,t.attributes.minute),c(m,r)):t.state;try{var s=i.split(" ");if(2===s.length)return o(new Date(s.join("T")),r);if(1===s.length){if(i.includes("-"))return n(new Date(i+"T00:00"),r);if(i.includes(":")){var l=new Date;return c(new Date(l.toISOString().split("T")[0]+"T"+i),r)}}return i}catch(e){return i}}return"humidifier"===u&&"on"===a&&t.attributes.humidity?t.attributes.humidity+" %":"counter"===u||"number"===u||"input_number"===u?b(a,r):t.attributes.device_class&&e("component."+u+".state."+t.attributes.device_class+"."+a)||e("component."+u+".state._."+a)||a},exports.computeStateDomain=p,exports.createThing=function(e,t){void 0===t&&(t=!1);var r=function(e,t){return n("hui-error-card",{type:"error",error:e,config:t})},n=function(e,t){var n=window.document.createElement(e);try{if(!n.setConfig)return;n.setConfig(t)}catch(n){return console.error(e,n),r(n.message,t)}return n};if(!e||"object"!=typeof e||!t&&!e.type)return r("No type defined",e);var i=e.type;if(i&&i.startsWith("custom:"))i=i.substr("custom:".length);else if(t)if(x.has(i))i="hui-"+i+"-row";else{if(!e.entity)return r("Invalid config given.",e);var a=e.entity.split(".",1)[0];i="hui-"+(k[a]||"text")+"-entity-row"}else i="hui-"+i+"-card";if(customElements.get(i))return n(i,e);var o=r("Custom element doesn't exist: "+e.type+".",e);o.style.display="None";var u=setTimeout(function(){o.style.display=""},2e3);return customElements.whenDefined(e.type).then(function(){clearTimeout(u),w(o,"ll-rebuild",{},o)}),o},exports.debounce=function(e,t,r){var n;return void 0===r&&(r=!1),function(){var i=[].slice.call(arguments),a=this,o=function(){n=null,r||e.apply(a,i)},u=r&&!n;clearTimeout(n),n=setTimeout(o,t),u&&e.apply(a,i)}},exports.domainIcon=T,exports.evaluateFilter=function(e,t){var r=t.value||t,n=t.attribute?e.attributes[t.attribute]:e.state;switch(t.operator||"=="){case"==":return n===r;case"<=":return n<=r;case"<":return n<r;case">=":return n>=r;case">":return n>r;case"!=":return n!==r;case"regex":return n.match(r);default:return!1}},exports.fireEvent=w,exports.fixedIcons=D,exports.formatDate=n,exports.formatDateMonth=function(e,t){return function(e){return new Intl.DateTimeFormat(e.language,{month:"long"})}(t).format(e)},exports.formatDateMonthYear=function(e,t){return function(e){return new Intl.DateTimeFormat(e.language,{month:"long",year:"numeric"})}(t).format(e)},exports.formatDateNumeric=function(e,t){return function(e){return new Intl.DateTimeFormat(e.language,{year:"numeric",month:"numeric",day:"numeric"})}(t).format(e)},exports.formatDateShort=function(e,t){return function(e){return new Intl.DateTimeFormat(e.language,{day:"numeric",month:"short"})}(t).format(e)},exports.formatDateTime=o,exports.formatDateTimeNumeric=function(e,t){return function(e){return new Intl.DateTimeFormat(e.language,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"2-digit",hour12:a(e)})}(t).format(e)},exports.formatDateTimeWithSeconds=function(e,t){return function(e){return new Intl.DateTimeFormat(e.language,{year:"numeric",month:"long",day:"numeric",hour:a(e)?"numeric":"2-digit",minute:"2-digit",second:"2-digit",hour12:a(e)})}(t).format(e)},exports.formatDateWeekday=function(e,t){return function(e){return new Intl.DateTimeFormat(e.language,{weekday:"long",month:"long",day:"numeric"})}(t).format(e)},exports.formatDateYear=function(e,t){return function(e){return new Intl.DateTimeFormat(e.language,{year:"numeric"})}(t).format(e)},exports.formatNumber=b,exports.formatTime=c,exports.formatTimeWeekday=function(e,t){return function(e){return new Intl.DateTimeFormat(e.language,{hour:a(e)?"numeric":"2-digit",minute:"2-digit",second:"2-digit",hour12:a(e)})}(t).format(e)},exports.formatTimeWithSeconds=function(e,t){return function(e){return new Intl.DateTimeFormat(e.language,{hour:a(e)?"numeric":"2-digit",minute:"2-digit",second:"2-digit",hour12:a(e)})}(t).format(e)},exports.forwardHaptic=F,exports.getLovelace=function(){var e=document.querySelector("home-assistant");if(e=(e=(e=(e=(e=(e=(e=(e=e&&e.shadowRoot)&&e.querySelector("home-assistant-main"))&&e.shadowRoot)&&e.querySelector("app-drawer-layout partial-panel-resolver"))&&e.shadowRoot||e)&&e.querySelector("ha-panel-lovelace"))&&e.shadowRoot)&&e.querySelector("hui-root")){var t=e.lovelace;return t.current_view=e.___curView,t}return null},exports.handleAction=function(e,t,r,n){var i;"double_tap"===n&&r.double_tap_action?i=r.double_tap_action:"hold"===n&&r.hold_action?i=r.hold_action:"tap"===n&&r.tap_action&&(i=r.tap_action),O(e,t,r,i)},exports.handleActionConfig=O,exports.handleClick=function(e,t,r,n,i){var a;if(i&&r.double_tap_action?a=r.double_tap_action:n&&r.hold_action?a=r.hold_action:!n&&r.tap_action&&(a=r.tap_action),a||(a={action:"more-info"}),!a.confirmation||a.confirmation.exemptions&&a.confirmation.exemptions.some(function(e){return e.user===t.user.id})||confirm(a.confirmation.text||"Are you sure you want to "+a.action+"?"))switch(a.action){case"more-info":(a.entity||r.entity||r.camera_image)&&(w(e,"hass-more-info",{entityId:a.entity?a.entity:r.entity?r.entity:r.camera_image}),a.haptic&&F(a.haptic));break;case"navigate":a.navigation_path&&(N(0,a.navigation_path),a.haptic&&F(a.haptic));break;case"url":a.url_path&&window.open(a.url_path),a.haptic&&F(a.haptic);break;case"toggle":r.entity&&(I(t,r.entity),a.haptic&&F(a.haptic));break;case"call-service":if(!a.service)return;var o=a.service.split(".",2),u=o[0],c=o[1],m=s({},a.service_data);"entity"===m.entity_id&&(m.entity_id=r.entity),t.callService(u,c,m,a.target),a.haptic&&F(a.haptic);break;case"fire-dom-event":w(e,"ll-custom",a),a.haptic&&F(a.haptic)}},exports.hasAction=function(e){return void 0!==e&&"none"!==e.action},exports.hasConfigOrEntityChanged=function(e,t,r){if(t.has("config")||r)return!0;if(e.config.entity){var n=t.get("hass");return!n||n.states[e.config.entity]!==e.hass.states[e.config.entity]}return!1},exports.hasDoubleClick=function(e){return void 0!==e&&"none"!==e.action},exports.isNumericState=f,exports.navigate=N,exports.numberFormatToLocale=g,exports.relativeTime=function(e,t,n,i){void 0===i&&(i=!0);var a=r.selectUnit(e,n);return i?function(e){return new Intl.RelativeTimeFormat(e.language,{numeric:"auto"})}(t).format(a.value,a.unit):Intl.NumberFormat(t.language,{style:"unit",unit:a.unit,unitDisplay:"long"}).format(Math.abs(a.value))},exports.round=h,exports.stateIcon=function(e){if(!e)return"mdi:bookmark";if(e.attributes.icon)return e.attributes.icon;var t=l(e.entity_id);return t in A?A[t](e):T(t,e.state)},exports.timerTimeRemaining=function(e){var t,r=3600*(t=e.attributes.remaining.split(":").map(Number))[0]+60*t[1]+t[2];if("active"===e.state){var n=(new Date).getTime(),i=new Date(e.last_changed).getTime();r=Math.max(r-(n-i)/1e3,0)}return r},exports.toggleEntity=I,exports.turnOnOffEntities=function(e,t,r){void 0===r&&(r=!0);var n={};t.forEach(function(t){if(v.includes(e.states[t].state)===r){var i=l(t),a=["cover","lock"].includes(i)?i:"homeassistant";a in n||(n[a]=[]),n[a].push(t)}}),Object.keys(n).forEach(function(t){var i;switch(t){case"lock":i=r?"unlock":"lock";break;case"cover":i=r?"open_cover":"close_cover";break;default:i=r?"turn_on":"turn_off"}e.callService(t,i,{entity_id:n[t]})})},exports.turnOnOffEntity=S;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|