c.e3089bb2.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import{_ as e,j as i,e as t,y as a,ef as o,d as n,n as l,a5 as s,J as c}from"./main-ec7846c8.js";import{s as r}from"./c.0e3055bd.js";import"./c.27e9c060.js";import"./c.40adef15.js";import"./c.3ced6349.js";import"./c.8e28b461.js";import"./c.eea05cf6.js";import"./c.d2f13ac1.js";import"./c.1024e243.js";import"./c.05172f3d.js";import"./c.4f015773.js";import"./c.541a83df.js";import"./c.3db34379.js";import"./c.227858d9.js";import"./c.87e5362a.js";import"./c.f490cc01.js";import"./c.5fe2e3ab.js";import"./c.749b9503.js";e([l("ha-help-tooltip")],(function(e,i){return{F:class extends i{constructor(...i){super(...i),e(this)}},d:[{kind:"field",decorators:[t()],key:"label",value:void 0},{kind:"field",decorators:[t()],key:"position",value:()=>"top"},{kind:"method",key:"render",value:function(){return a`
  2. <ha-svg-icon .path=${o}></ha-svg-icon>
  3. <paper-tooltip
  4. offset="4"
  5. .position=${this.position}
  6. .fitToVisibleBounds=${!0}
  7. >${this.label}</paper-tooltip
  8. >
  9. `}},{kind:"get",static:!0,key:"styles",value:function(){return n`
  10. ha-svg-icon {
  11. --mdc-icon-size: var(--ha-help-tooltip-size, 14px);
  12. color: var(--ha-help-tooltip-color, var(--disabled-text-color));
  13. }
  14. `}}]}}),i);const d=["more-info","toggle","navigate","url","call-service","none"];e([l("hui-action-editor")],(function(e,i){return{F:class extends i{constructor(...i){super(...i),e(this)}},d:[{kind:"field",decorators:[t()],key:"config",value:void 0},{kind:"field",decorators:[t()],key:"label",value:void 0},{kind:"field",decorators:[t()],key:"actions",value:void 0},{kind:"field",decorators:[t()],key:"tooltipText",value:void 0},{kind:"field",decorators:[t()],key:"hass",value:void 0},{kind:"get",key:"_navigation_path",value:function(){const e=this.config;return(null==e?void 0:e.navigation_path)||""}},{kind:"get",key:"_url_path",value:function(){const e=this.config;return(null==e?void 0:e.url_path)||""}},{kind:"get",key:"_service",value:function(){const e=this.config;return(null==e?void 0:e.service)||""}},{kind:"field",key:"_serviceAction",value(){return s((e=>{var i;return{service:this._service,data:null!==(i=e.data)&&void 0!==i?i:e.service_data,target:e.target}}))}},{kind:"method",key:"render",value:function(){var e,i,t,o,n,l,s;if(!this.hass)return a``;const c=null!==(e=this.actions)&&void 0!==e?e:d;return a`
  15. <div class="dropdown">
  16. <ha-select
  17. .label=${this.label}
  18. .configValue=${"action"}
  19. @selected=${this._actionPicked}
  20. .value=${null!==(i=null===(t=this.config)||void 0===t?void 0:t.action)&&void 0!==i?i:"default"}
  21. @closed=${r}
  22. fixedMenuPosition
  23. naturalMenuWidt
  24. >
  25. <mwc-list-item value="default">
  26. ${this.hass.localize("ui.panel.lovelace.editor.action-editor.actions.default_action")}
  27. </mwc-list-item>
  28. ${c.map((e=>a`
  29. <mwc-list-item .value=${e}>
  30. ${this.hass.localize(`ui.panel.lovelace.editor.action-editor.actions.${e}`)}
  31. </mwc-list-item>
  32. `))}
  33. </ha-select>
  34. ${this.tooltipText?a`
  35. <ha-help-tooltip .label=${this.tooltipText}></ha-help-tooltip>
  36. `:""}
  37. </div>
  38. ${"navigate"===(null===(o=this.config)||void 0===o?void 0:o.action)?a`
  39. <ha-navigation-picker
  40. .hass=${this.hass}
  41. .label=${this.hass.localize("ui.panel.lovelace.editor.action-editor.navigation_path")}
  42. .value=${this._navigation_path}
  43. @value-changed=${this._navigateValueChanged}
  44. ></ha-navigation-picker>
  45. `:""}
  46. ${"url"===(null===(n=this.config)||void 0===n?void 0:n.action)?a`
  47. <ha-textfield
  48. .label=${this.hass.localize("ui.panel.lovelace.editor.action-editor.url_path")}
  49. .value=${this._url_path}
  50. .configValue=${"url_path"}
  51. @input=${this._valueChanged}
  52. ></ha-textfield>
  53. `:""}
  54. ${"call-service"===(null===(l=this.config)||void 0===l?void 0:l.action)?a`
  55. <ha-service-control
  56. .hass=${this.hass}
  57. .value=${this._serviceAction(this.config)}
  58. .showAdvanced=${null===(s=this.hass.userData)||void 0===s?void 0:s.showAdvanced}
  59. narrow
  60. @value-changed=${this._serviceValueChanged}
  61. ></ha-service-control>
  62. `:""}
  63. `}},{kind:"method",key:"_actionPicked",value:function(e){var i;if(e.stopPropagation(),!this.hass)return;const t=e.target.value;if((null===(i=this.config)||void 0===i?void 0:i.action)===t)return;if("default"===t)return void c(this,"value-changed",{value:void 0});let a;switch(t){case"url":a={url_path:this._url_path};break;case"call-service":a={service:this._service};break;case"navigate":a={navigation_path:this._navigation_path}}c(this,"value-changed",{value:{action:t,...a}})}},{kind:"method",key:"_valueChanged",value:function(e){if(e.stopPropagation(),!this.hass)return;const i=e.target,t=e.target.value;this[`_${i.configValue}`]!==t&&i.configValue&&c(this,"value-changed",{value:{...this.config,[i.configValue]:t}})}},{kind:"method",key:"_serviceValueChanged",value:function(e){e.stopPropagation();const i={...this.config,service:e.detail.value.service||"",data:e.detail.value.data||{},target:e.detail.value.target||{}};"service_data"in i&&delete i.service_data,c(this,"value-changed",{value:i})}},{kind:"method",key:"_navigateValueChanged",value:function(e){e.stopPropagation();const i={...this.config,navigation_path:e.detail.value};c(this,"value-changed",{value:i})}},{kind:"get",static:!0,key:"styles",value:function(){return n`
  64. .dropdown {
  65. position: relative;
  66. }
  67. ha-help-tooltip {
  68. position: absolute;
  69. right: 40px;
  70. top: 16px;
  71. inset-inline-start: initial;
  72. inset-inline-end: 40px;
  73. direction: var(--direction);
  74. }
  75. ha-select,
  76. ha-textfield {
  77. width: 100%;
  78. }
  79. ha-service-control,
  80. ha-navigation-picker {
  81. display: block;
  82. }
  83. ha-textfield,
  84. ha-service-control,
  85. ha-navigation-picker {
  86. margin-top: 8px;
  87. }
  88. ha-service-control {
  89. --service-control-padding: 0;
  90. }
  91. `}}]}}),i);let h=e([l("ha-selector-ui-action")],(function(e,i){return{F:class extends i{constructor(...i){super(...i),e(this)}},d:[{kind:"field",decorators:[t()],key:"hass",value:void 0},{kind:"field",decorators:[t()],key:"selector",value:void 0},{kind:"field",decorators:[t()],key:"value",value:void 0},{kind:"field",decorators:[t()],key:"label",value:void 0},{kind:"field",decorators:[t()],key:"helper",value:void 0},{kind:"method",key:"render",value:function(){return a`
  92. <hui-action-editor
  93. .label=${this.label}
  94. .hass=${this.hass}
  95. .config=${this.value}
  96. .actions=${this.selector["ui-action"].actions}
  97. .tooltipText=${this.helper}
  98. @value-changed=${this._valueChanged}
  99. ></hui-action-editor>
  100. `}},{kind:"method",key:"_valueChanged",value:function(e){c(this,"value-changed",{value:e.detail.value})}}]}}),i);export{h as HaSelectorUiAction};