From 716b08371322a4eab8134ae9bd89d25ca4b9dca1 Mon Sep 17 00:00:00 2001 From: andrey-git Date: Mon, 28 May 2018 22:29:59 +0300 Subject: [PATCH] Release 20180528 --- CHANGELOG.md | 4 + README.md | 11 +- docs/features.md | 20 +- scripts-dbg-es5.js | 2503 ++++++++++++++++++++++++++ scripts-dbg.js | 2415 +++++++++++++++++++++++++ scripts-es5.js.map | 2 +- scripts.js.map | 2 +- src/utils/version.js | 2 +- state-card-custom-ui-dbg-es5.html | 2494 +------------------------ state-card-custom-ui-dbg-es5.html.gz | Bin 70171 -> 61 bytes state-card-custom-ui-dbg.html | 2407 +------------------------ state-card-custom-ui-dbg.html.gz | Bin 67635 -> 57 bytes state-card-custom-ui-es5.html | 2 +- state-card-custom-ui-es5.html.gz | Bin 10681 -> 10729 bytes state-card-custom-ui.html | 6 +- state-card-custom-ui.html.gz | Bin 9529 -> 9564 bytes 16 files changed, 4952 insertions(+), 4916 deletions(-) create mode 100644 scripts-dbg-es5.js create mode 100644 scripts-dbg.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 621c8cb..ba8905a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Changelog +#### 2018-05-21 +* New feature: [`control_element`](docs/features.md#custom-controls) +* Fix theming on Firefix/Edge. + #### 2018-05-21 * Hotfix release for HA 0.70+ diff --git a/README.md b/README.md index abb464f..fb61e88 100644 --- a/README.md +++ b/README.md @@ -23,13 +23,10 @@ Please ask questions and post feature requests in the [forum](https://community. ## Changelog #### 2018-05-21 -* Hotfix release for HA 0.70+ - -#### 2018-04-29 -* Add support for `action_name` attribute that can be used to change the displayed action on scene and script cards. -* Make confirmable controls protect slider on 2nd line +* New feature: [`control_element`](docs/features.md#custom-controls) +* Fix theming on Firefix/Edge. -#### 2018-04-27 -* Add support for `icon_color` attribute to force-set icon color of any entity. +#### 2018-05-21 +* Hotfix release for HA 0.70+ [Full Changelog](CHANGELOG.md) diff --git a/docs/features.md b/docs/features.md index cdbfde6..4212aa6 100644 --- a/docs/features.md +++ b/docs/features.md @@ -14,11 +14,12 @@ + [Secondary custom UI](#secondary-customui) * [Features available for almost all domains](#features-available-for-almost-all-domains) + [You can always show the last-changed text](#you-can-always-show-the-last-changed-text) -* [Features available for light, cover, "plain", and "toggle" cards](#features-available-for-light-cover-plain-and-toggle-cards) +* [Features available for light, cover, climate, "plain", and "toggle" cards](#features-available-for-light-cover-climate-plain-and-toggle-cards) - [You can hide the control altogether](#you-can-hide-the-control-altogether) - [You can add extra data below the entity name](#you-can-add-extra-data-below-the-entity-name) - [Add badge to the state card](#add-badge-to-the-state-card) - [Confirmable controls](#confirmable-controls) + - [Custom controls](#custom-controls) * [Features available for light and cover domains only](#features-available-for-light-and-cover-domains-only) - [If there is not enough horizontal space the mode is set by `state_card_mode` parameter](#if-there-is-not-enough-horizontal-space-the-mode-is-set-by-state_card_mode-parameter) - [If the slider got moved to a new line it will be 200 px wide.](#if-the-slider-got-moved-to-a-new-line-it-will-be-200-px-wide) @@ -254,11 +255,12 @@ Use `show_last_changed: true` Note that if you use the [extra_data_template](#you-can-add-extra-data-below-the-entity-name-requires-ha-043) below it will take precedence over `show_last_changed` -## Features available for light, cover, "plain", and "toggle" cards. +## Features available for light, cover, climate, "plain", and "toggle" cards. The next features are available for 4 types of cards: * Light -* Cover, +* Cover +* Climate * "Plain" i.e. card with icon, name, and state. * "Toggle" i.e. card with icon, name, and toggle. @@ -324,6 +326,18 @@ Sometimes you don't want to flip a switch by mistake. Use `confirm_controls_show_lock` to block the control and show a transparent lock icon over it. Tapping on the lock will open it for 5 seconds allowing to use the control. If you would like to prevent accidental flip without the visual lock hint, use `confirm_controls` instead. +#### Custom controls + +You can replace the default control with another control by using `control_element` attribute. + +For example: +```yaml +switch.my: + control_element: my-custom-switch-element +``` + +You can also use `control_element: ''` to show the state, like the "plain" card does. + ## Features available for light and cover domains only If there is enough space the card will have icon+name on the left, optional slider in the middle and toggle on the right: diff --git a/scripts-dbg-es5.js b/scripts-dbg-es5.js new file mode 100644 index 0000000..9dcf7c5 --- /dev/null +++ b/scripts-dbg-es5.js @@ -0,0 +1,2503 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = "./src/entrypoints/scripts.js"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "../home-assistant-polymer/src/common/const.js": +/*!*****************************************************!*\ + !*** ../home-assistant-polymer/src/common/const.js ***! + \*****************************************************/ +/*! exports provided: DEFAULT_DOMAIN_ICON, DOMAINS_WITH_CARD, DOMAINS_MORE_INFO_NO_HISTORY, STATES_OFF, UNIT_C, UNIT_F, DEFAULT_VIEW_ENTITY_ID */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_DOMAIN_ICON", function() { return DEFAULT_DOMAIN_ICON; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DOMAINS_WITH_CARD", function() { return DOMAINS_WITH_CARD; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DOMAINS_MORE_INFO_NO_HISTORY", function() { return DOMAINS_MORE_INFO_NO_HISTORY; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "STATES_OFF", function() { return STATES_OFF; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UNIT_C", function() { return UNIT_C; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UNIT_F", function() { return UNIT_F; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_VIEW_ENTITY_ID", function() { return DEFAULT_VIEW_ENTITY_ID; }); +/** Constants to be used in the frontend. */ + +// Constants should be alphabetically sorted by name. +// Arrays with values should be alphabetically sorted if order doesn't matter. +// Each constant should have a description what it is supposed to be used for. + +/** Icon to use when no icon specified for domain. */ +var DEFAULT_DOMAIN_ICON = 'mdi:bookmark'; + +/** Domains that have a state card. */ +var DOMAINS_WITH_CARD = ['climate', 'cover', 'configurator', 'input_select', 'input_number', 'input_text', 'media_player', 'scene', 'script', 'timer', 'weblink']; + +/** Domains that should have the history hidden in the more info dialog. */ +var DOMAINS_MORE_INFO_NO_HISTORY = ['camera', 'configurator', 'history_graph', 'scene']; + +/** States that we consider "off". */ +var STATES_OFF = ['closed', 'off', 'unlocked']; + +/** Temperature units. */ +var UNIT_C = '°C'; +var UNIT_F = '°F'; + +/** Entity ID of the default view. */ +var DEFAULT_VIEW_ENTITY_ID = 'group.default_view'; + +/***/ }), + +/***/ "../home-assistant-polymer/src/common/dom/apply_themes_on_element.js": +/*!***************************************************************************!*\ + !*** ../home-assistant-polymer/src/common/dom/apply_themes_on_element.js ***! + \***************************************************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return applyThemesOnElement; }); +/** + * Apply a theme to an element by setting the CSS variables on it. + * + * element: Element to apply theme on. + * themes: HASS Theme information + * localTheme: selected theme. + * updateMeta: boolean if we should update the theme-color meta element. +*/ +function applyThemesOnElement(element, themes, localTheme) { + var updateMeta = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; + + if (!element._themes) { + element._themes = {}; + } + var themeName = themes.default_theme; + if (localTheme === 'default' || localTheme && themes.themes[localTheme]) { + themeName = localTheme; + } + var styles = Object.assign({}, element._themes); + if (themeName !== 'default') { + var theme = themes.themes[themeName]; + Object.keys(theme).forEach(function (key) { + var prefixedKey = '--' + key; + element._themes[prefixedKey] = ''; + styles[prefixedKey] = theme[key]; + }); + } + if (element.updateStyles) { + element.updateStyles(styles); + } else if (window.ShadyCSS) { + // implement updateStyles() method of Polemer elements + window.ShadyCSS.styleSubtree( /** @type {!HTMLElement} */element, styles); + } + + if (!updateMeta) return; + + var meta = document.querySelector('meta[name=theme-color]'); + if (meta) { + if (!meta.hasAttribute('default-content')) { + meta.setAttribute('default-content', meta.getAttribute('content')); + } + var themeColor = styles['--primary-color'] || meta.getAttribute('default-content'); + meta.setAttribute('content', themeColor); + } +} + +/***/ }), + +/***/ "../home-assistant-polymer/src/common/dom/dynamic_content_updater.js": +/*!***************************************************************************!*\ + !*** ../home-assistant-polymer/src/common/dom/dynamic_content_updater.js ***! + \***************************************************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return dynamicContentUpdater; }); +/** + * Update root's child element to be newElementTag replacing another existing child if any. + * Copy attributes into the child element. + */ +function dynamicContentUpdater(root, newElementTag, attributes) { + var rootEl = root; + var customEl = void 0; + + if (rootEl.lastChild && rootEl.lastChild.tagName === newElementTag) { + customEl = rootEl.lastChild; + } else { + if (rootEl.lastChild) { + rootEl.removeChild(rootEl.lastChild); + } + // Creating an element with upper case works fine in Chrome, but in FF it doesn't immediately + // become a defined Custom Element. Polymer does that in some later pass. + customEl = document.createElement(newElementTag.toLowerCase()); + } + + if (customEl.setProperties) { + customEl.setProperties(attributes); + } else { + // If custom element definition wasn't loaded yet - setProperties would be + // missing, but no harm in setting attributes one-by-one then. + Object.keys(attributes).forEach(function (key) { + customEl[key] = attributes[key]; + }); + } + + if (customEl.parentNode === null) { + rootEl.appendChild(customEl); + } +} + +/***/ }), + +/***/ "../home-assistant-polymer/src/common/entity/can_toggle_domain.js": +/*!************************************************************************!*\ + !*** ../home-assistant-polymer/src/common/entity/can_toggle_domain.js ***! + \************************************************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return canToggleDomain; }); +function canToggleDomain(hass, domain) { + var services = hass.config.services[domain]; + if (!services) { + return false; + } + + if (domain === 'lock') { + return 'lock' in services; + } else if (domain === 'cover') { + return 'open_cover' in services; + } + return 'turn_on' in services; +} + +/***/ }), + +/***/ "../home-assistant-polymer/src/common/entity/can_toggle_state.js": +/*!***********************************************************************!*\ + !*** ../home-assistant-polymer/src/common/entity/can_toggle_state.js ***! + \***********************************************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return canToggleState; }); +/* harmony import */ var _can_toggle_domain_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./can_toggle_domain.js */ "../home-assistant-polymer/src/common/entity/can_toggle_domain.js"); +/* harmony import */ var _compute_state_domain_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./compute_state_domain.js */ "../home-assistant-polymer/src/common/entity/compute_state_domain.js"); + + + +function canToggleState(hass, stateObj) { + var domain = Object(_compute_state_domain_js__WEBPACK_IMPORTED_MODULE_1__["default"])(stateObj); + if (domain === 'group') { + return stateObj.state === 'on' || stateObj.state === 'off'; + } + if (domain === 'climate') { + return !!((stateObj.attributes || {}).supported_features & 4096); + } + + return Object(_can_toggle_domain_js__WEBPACK_IMPORTED_MODULE_0__["default"])(hass, domain); +} + +/***/ }), + +/***/ "../home-assistant-polymer/src/common/entity/compute_domain.js": +/*!*********************************************************************!*\ + !*** ../home-assistant-polymer/src/common/entity/compute_domain.js ***! + \*********************************************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return computeDomain; }); +function computeDomain(entityId) { + return entityId.substr(0, entityId.indexOf('.')); +} + +/***/ }), + +/***/ "../home-assistant-polymer/src/common/entity/compute_state_domain.js": +/*!***************************************************************************!*\ + !*** ../home-assistant-polymer/src/common/entity/compute_state_domain.js ***! + \***************************************************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return computeStateDomain; }); +/* harmony import */ var _compute_domain_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./compute_domain.js */ "../home-assistant-polymer/src/common/entity/compute_domain.js"); + + +function computeStateDomain(stateObj) { + if (!stateObj._domain) { + stateObj._domain = Object(_compute_domain_js__WEBPACK_IMPORTED_MODULE_0__["default"])(stateObj.entity_id); + } + + return stateObj._domain; +} + +/***/ }), + +/***/ "../home-assistant-polymer/src/common/entity/get_group_entities.js": +/*!*************************************************************************!*\ + !*** ../home-assistant-polymer/src/common/entity/get_group_entities.js ***! + \*************************************************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return getGroupEntities; }); +function getGroupEntities(entities, group) { + var result = {}; + + group.attributes.entity_id.forEach(function (entityId) { + var entity = entities[entityId]; + + if (entity) { + result[entity.entity_id] = entity; + } + }); + + return result; +} + +/***/ }), + +/***/ "../home-assistant-polymer/src/common/entity/get_view_entities.js": +/*!************************************************************************!*\ + !*** ../home-assistant-polymer/src/common/entity/get_view_entities.js ***! + \************************************************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return getViewEntities; }); +/* harmony import */ var _compute_domain_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./compute_domain.js */ "../home-assistant-polymer/src/common/entity/compute_domain.js"); +/* harmony import */ var _get_group_entities_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./get_group_entities.js */ "../home-assistant-polymer/src/common/entity/get_group_entities.js"); + + + +// Return an object containing all entities that the view will show +// including embedded groups. +function getViewEntities(entities, view) { + var viewEntities = {}; + + view.attributes.entity_id.forEach(function (entityId) { + var entity = entities[entityId]; + + if (entity && !entity.attributes.hidden) { + viewEntities[entity.entity_id] = entity; + + if (Object(_compute_domain_js__WEBPACK_IMPORTED_MODULE_0__["default"])(entity.entity_id) === 'group') { + var groupEntities = Object(_get_group_entities_js__WEBPACK_IMPORTED_MODULE_1__["default"])(entities, entity); + + Object.keys(groupEntities).forEach(function (grEntityId) { + var grEntity = groupEntities[grEntityId]; + + if (!grEntity.attributes.hidden) { + viewEntities[grEntityId] = grEntity; + } + }); + } + } + }); + + return viewEntities; +} + +/***/ }), + +/***/ "../home-assistant-polymer/src/common/entity/state_card_type.js": +/*!**********************************************************************!*\ + !*** ../home-assistant-polymer/src/common/entity/state_card_type.js ***! + \**********************************************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return stateCardType; }); +/* harmony import */ var _can_toggle_state_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./can_toggle_state.js */ "../home-assistant-polymer/src/common/entity/can_toggle_state.js"); +/* harmony import */ var _compute_state_domain_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./compute_state_domain.js */ "../home-assistant-polymer/src/common/entity/compute_state_domain.js"); +/* harmony import */ var _const_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../const.js */ "../home-assistant-polymer/src/common/const.js"); + + + + +function stateCardType(hass, stateObj) { + if (stateObj.state === 'unavailable') { + return 'display'; + } + + var domain = Object(_compute_state_domain_js__WEBPACK_IMPORTED_MODULE_1__["default"])(stateObj); + + if (_const_js__WEBPACK_IMPORTED_MODULE_2__["DOMAINS_WITH_CARD"].includes(domain)) { + return domain; + } else if (Object(_can_toggle_state_js__WEBPACK_IMPORTED_MODULE_0__["default"])(hass, stateObj) && stateObj.attributes.control !== 'hidden') { + return 'toggle'; + } + return 'display'; +} + +/***/ }), + +/***/ "./node_modules/@polymer/polymer/lib/utils/boot.js": +/*!*********************************************************!*\ + !*** ./node_modules/@polymer/polymer/lib/utils/boot.js ***! + \*********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/** +@license +Copyright (c) 2017 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +*/ + +window.JSCompiler_renameProperty = function (prop) { + return prop; +}; + +/***/ }), + +/***/ "./node_modules/@polymer/polymer/lib/utils/html-tag.js": +/*!*************************************************************!*\ + !*** ./node_modules/@polymer/polymer/lib/utils/html-tag.js ***! + \*************************************************************/ +/*! exports provided: html, htmlLiteral */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "html", function() { return html; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "htmlLiteral", function() { return htmlLiteral; }); +/* harmony import */ var _boot_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boot.js */ "./node_modules/@polymer/polymer/lib/utils/boot.js"); +/* harmony import */ var _boot_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_boot_js__WEBPACK_IMPORTED_MODULE_0__); +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** +@license +Copyright (c) 2017 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +*/ + + +/** + * Class representing a static string value which can be used to filter + * strings by asseting that they have been created via this class. The + * `value` property returns the string passed to the constructor. + */ + +var LiteralString = function () { + function LiteralString(string) { + _classCallCheck(this, LiteralString); + + /** @type {string} */ + this.value = string.toString(); + } + /** + * @return {string} LiteralString string value + */ + + + _createClass(LiteralString, [{ + key: 'toString', + value: function toString() { + return this.value; + } + }]); + + return LiteralString; +}(); + +/** + * @param {*} value Object to stringify into HTML + * @return {string} HTML stringified form of `obj` + */ + + +function literalValue(value) { + if (value instanceof LiteralString) { + return (/** @type {!LiteralString} */value.value + ); + } else { + throw new Error('non-literal value passed to Polymer\'s htmlLiteral function: ' + value); + } +} + +/** + * @param {*} value Object to stringify into HTML + * @return {string} HTML stringified form of `obj` + */ +function htmlValue(value) { + if (value instanceof HTMLTemplateElement) { + return (/** @type {!HTMLTemplateElement } */value.innerHTML + ); + } else if (value instanceof LiteralString) { + return literalValue(value); + } else { + throw new Error('non-template value passed to Polymer\'s html function: ' + value); + } +} + +/** + * A template literal tag that creates an HTML