c.0f6bb17e.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. import{a as e,h as t,e as i,g as a,t as s,$ as o,j as r,R as n,w as l,r as h,n as c,m as d,L as p,N as u,o as v,b as f,aI as b,ai as m,c as k,E as g,aJ as y,aC as w,aK as x,aL as $,d as _,s as R}from"./main-ad130be7.js";import{f as z}from"./c.3243a8b0.js";import{c as j}from"./c.4a97632a.js";import"./c.f1291e50.js";import"./c.2d5ed670.js";import"./c.97b7c4b0.js";import{r as F}from"./c.4204ca09.js";import{i as P}from"./c.21c042d4.js";import{s as I}from"./c.2645c235.js";import"./c.a5f69ed4.js";import"./c.3f859915.js";import"./c.9b92f489.js";import"./c.82eccc94.js";import"./c.8e28b461.js";import"./c.4feb0cb8.js";import"./c.0ca5587f.js";import"./c.5d3ce9d6.js";import"./c.f6611997.js";import"./c.743a15a1.js";import"./c.4266acdb.js";e([c("ha-tab")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[i({type:Boolean,reflect:!0})],key:"active",value:()=>!1},{kind:"field",decorators:[i({type:Boolean,reflect:!0})],key:"narrow",value:()=>!1},{kind:"field",decorators:[i()],key:"name",value:void 0},{kind:"field",decorators:[a("mwc-ripple")],key:"_ripple",value:void 0},{kind:"field",decorators:[s()],key:"_shouldRenderRipple",value:()=>!1},{kind:"method",key:"render",value:function(){return o`
  2. <div
  3. tabindex="0"
  4. role="tab"
  5. aria-selected=${this.active}
  6. aria-label=${r(this.name)}
  7. @focus=${this.handleRippleFocus}
  8. @blur=${this.handleRippleBlur}
  9. @mousedown=${this.handleRippleActivate}
  10. @mouseup=${this.handleRippleDeactivate}
  11. @mouseenter=${this.handleRippleMouseEnter}
  12. @mouseleave=${this.handleRippleMouseLeave}
  13. @touchstart=${this.handleRippleActivate}
  14. @touchend=${this.handleRippleDeactivate}
  15. @touchcancel=${this.handleRippleDeactivate}
  16. @keydown=${this._handleKeyDown}
  17. >
  18. ${this.narrow?o`<slot name="icon"></slot>`:""}
  19. <span class="name">${this.name}</span>
  20. ${this._shouldRenderRipple?o`<mwc-ripple></mwc-ripple>`:""}
  21. </div>
  22. `}},{kind:"field",key:"_rippleHandlers",value(){return new n((()=>(this._shouldRenderRipple=!0,this._ripple)))}},{kind:"method",key:"_handleKeyDown",value:function(e){13===e.keyCode&&e.target.click()}},{kind:"method",decorators:[l({passive:!0})],key:"handleRippleActivate",value:function(e){this._rippleHandlers.startPress(e)}},{kind:"method",key:"handleRippleDeactivate",value:function(){this._rippleHandlers.endPress()}},{kind:"method",key:"handleRippleMouseEnter",value:function(){this._rippleHandlers.startHover()}},{kind:"method",key:"handleRippleMouseLeave",value:function(){this._rippleHandlers.endHover()}},{kind:"method",key:"handleRippleFocus",value:function(){this._rippleHandlers.startFocus()}},{kind:"method",key:"handleRippleBlur",value:function(){this._rippleHandlers.endFocus()}},{kind:"get",static:!0,key:"styles",value:function(){return h`
  23. div {
  24. padding: 0 32px;
  25. display: flex;
  26. flex-direction: column;
  27. text-align: center;
  28. box-sizing: border-box;
  29. align-items: center;
  30. justify-content: center;
  31. width: 100%;
  32. height: var(--header-height);
  33. cursor: pointer;
  34. position: relative;
  35. outline: none;
  36. }
  37. .name {
  38. white-space: nowrap;
  39. overflow: hidden;
  40. text-overflow: ellipsis;
  41. max-width: 100%;
  42. }
  43. :host([active]) {
  44. color: var(--primary-color);
  45. }
  46. :host(:not([narrow])[active]) div {
  47. border-bottom: 2px solid var(--primary-color);
  48. }
  49. :host([narrow]) {
  50. min-width: 0;
  51. display: flex;
  52. justify-content: center;
  53. overflow: hidden;
  54. }
  55. :host([narrow]) div {
  56. padding: 0 4px;
  57. }
  58. `}}]}}),t),e([c("hass-tabs-subpage")],(function(e,t){class a extends t{constructor(...t){super(...t),e(this)}}return{F:a,d:[{kind:"field",decorators:[i({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[i({type:Boolean})],key:"supervisor",value:()=>!1},{kind:"field",decorators:[i({attribute:!1})],key:"localizeFunc",value:void 0},{kind:"field",decorators:[i({type:String,attribute:"back-path"})],key:"backPath",value:void 0},{kind:"field",decorators:[i()],key:"backCallback",value:void 0},{kind:"field",decorators:[i({type:Boolean,attribute:"main-page"})],key:"mainPage",value:()=>!1},{kind:"field",decorators:[i({attribute:!1})],key:"route",value:void 0},{kind:"field",decorators:[i({attribute:!1})],key:"tabs",value:void 0},{kind:"field",decorators:[i({type:Boolean,reflect:!0})],key:"narrow",value:()=>!1},{kind:"field",decorators:[i({type:Boolean,reflect:!0,attribute:"is-wide"})],key:"isWide",value:()=>!1},{kind:"field",decorators:[i({type:Boolean,reflect:!0})],key:"rtl",value:()=>!1},{kind:"field",decorators:[s()],key:"_activeTab",value:void 0},{kind:"field",decorators:[F(".content")],key:"_savedScrollPos",value:void 0},{kind:"field",key:"_getTabs",value(){return d(((e,t,i,a,s,r,n)=>{const l=e.filter((e=>(!e.component||e.core||P(this.hass,e.component))&&(!e.advancedOnly||i)));if(l.length<2){if(1===l.length){const e=l[0];return[e.translationKey?n(e.translationKey):e.name]}return[""]}return l.map((e=>o`
  59. <a href=${e.path}>
  60. <ha-tab
  61. .hass=${this.hass}
  62. .active=${e.path===(null==t?void 0:t.path)}
  63. .narrow=${this.narrow}
  64. .name=${e.translationKey?n(e.translationKey):e.name}
  65. >
  66. ${e.iconPath?o`<ha-svg-icon
  67. slot="icon"
  68. .path=${e.iconPath}
  69. ></ha-svg-icon>`:""}
  70. </ha-tab>
  71. </a>
  72. `))}))}},{kind:"method",key:"willUpdate",value:function(e){if(e.has("route")&&(this._activeTab=this.tabs.find((e=>`${this.route.prefix}${this.route.path}`.includes(e.path)))),e.has("hass")){const t=e.get("hass");t&&t.language===this.hass.language||(this.rtl=j(this.hass))}p(u(a.prototype),"willUpdate",this).call(this,e)}},{kind:"method",key:"render",value:function(){var e,t;const i=this._getTabs(this.tabs,this._activeTab,null===(e=this.hass.userData)||void 0===e?void 0:e.showAdvanced,this.hass.config.components,this.hass.language,this.narrow,this.localizeFunc||this.hass.localize),a=i.length>1;return o`
  73. <div class="toolbar">
  74. ${this.mainPage||!this.backPath&&null!==(t=history.state)&&void 0!==t&&t.root?o`
  75. <ha-menu-button
  76. .hassio=${this.supervisor}
  77. .hass=${this.hass}
  78. .narrow=${this.narrow}
  79. ></ha-menu-button>
  80. `:this.backPath?o`
  81. <a href=${this.backPath}>
  82. <ha-icon-button-arrow-prev
  83. .hass=${this.hass}
  84. ></ha-icon-button-arrow-prev>
  85. </a>
  86. `:o`
  87. <ha-icon-button-arrow-prev
  88. .hass=${this.hass}
  89. @click=${this._backTapped}
  90. ></ha-icon-button-arrow-prev>
  91. `}
  92. ${this.narrow||!a?o`<div class="main-title">
  93. <slot name="header">${a?"":i[0]}</slot>
  94. </div>`:""}
  95. ${a?o`
  96. <div id="tabbar" class=${v({"bottom-bar":this.narrow})}>
  97. ${i}
  98. </div>
  99. `:""}
  100. <div id="toolbar-icon">
  101. <slot name="toolbar-icon"></slot>
  102. </div>
  103. </div>
  104. <div
  105. class="content ${v({tabs:a})}"
  106. @scroll=${this._saveScrollPos}
  107. >
  108. <slot></slot>
  109. </div>
  110. <div id="fab" class=${v({tabs:a})}>
  111. <slot name="fab"></slot>
  112. </div>
  113. `}},{kind:"method",decorators:[l({passive:!0})],key:"_saveScrollPos",value:function(e){this._savedScrollPos=e.target.scrollTop}},{kind:"method",key:"_backTapped",value:function(){this.backCallback?this.backCallback():history.back()}},{kind:"get",static:!0,key:"styles",value:function(){return h`
  114. :host {
  115. display: block;
  116. height: 100%;
  117. background-color: var(--primary-background-color);
  118. }
  119. :host([narrow]) {
  120. width: 100%;
  121. position: fixed;
  122. }
  123. ha-menu-button {
  124. margin-right: 24px;
  125. }
  126. .toolbar {
  127. display: flex;
  128. align-items: center;
  129. font-size: 20px;
  130. height: var(--header-height);
  131. background-color: var(--sidebar-background-color);
  132. font-weight: 400;
  133. border-bottom: 1px solid var(--divider-color);
  134. padding: 0 16px;
  135. box-sizing: border-box;
  136. }
  137. .toolbar a {
  138. color: var(--sidebar-text-color);
  139. text-decoration: none;
  140. }
  141. .bottom-bar a {
  142. width: 25%;
  143. }
  144. #tabbar {
  145. display: flex;
  146. font-size: 14px;
  147. overflow: hidden;
  148. }
  149. #tabbar > a {
  150. overflow: hidden;
  151. max-width: 45%;
  152. }
  153. #tabbar.bottom-bar {
  154. position: absolute;
  155. bottom: 0;
  156. left: 0;
  157. padding: 0 16px;
  158. box-sizing: border-box;
  159. background-color: var(--sidebar-background-color);
  160. border-top: 1px solid var(--divider-color);
  161. justify-content: space-around;
  162. z-index: 2;
  163. font-size: 12px;
  164. width: 100%;
  165. padding-bottom: env(safe-area-inset-bottom);
  166. }
  167. #tabbar:not(.bottom-bar) {
  168. flex: 1;
  169. justify-content: center;
  170. }
  171. :host(:not([narrow])) #toolbar-icon {
  172. min-width: 40px;
  173. }
  174. ha-menu-button,
  175. ha-icon-button-arrow-prev,
  176. ::slotted([slot="toolbar-icon"]) {
  177. display: flex;
  178. flex-shrink: 0;
  179. pointer-events: auto;
  180. color: var(--sidebar-icon-color);
  181. }
  182. .main-title {
  183. flex: 1;
  184. max-height: var(--header-height);
  185. line-height: 20px;
  186. color: var(--sidebar-text-color);
  187. margin: var(--main-title-margin, 0 0 0 24px);
  188. }
  189. .content {
  190. position: relative;
  191. width: calc(
  192. 100% - env(safe-area-inset-left) - env(safe-area-inset-right)
  193. );
  194. margin-left: env(safe-area-inset-left);
  195. margin-right: env(safe-area-inset-right);
  196. height: calc(100% - 1px - var(--header-height));
  197. height: calc(
  198. 100% - 1px - var(--header-height) - env(safe-area-inset-bottom)
  199. );
  200. overflow: auto;
  201. -webkit-overflow-scrolling: touch;
  202. }
  203. :host([narrow]) .content.tabs {
  204. height: calc(100% - 2 * var(--header-height));
  205. height: calc(
  206. 100% - 2 * var(--header-height) - env(safe-area-inset-bottom)
  207. );
  208. }
  209. #fab {
  210. position: fixed;
  211. right: calc(16px + env(safe-area-inset-right));
  212. bottom: calc(16px + env(safe-area-inset-bottom));
  213. z-index: 1;
  214. }
  215. :host([narrow]) #fab.tabs {
  216. bottom: calc(84px + env(safe-area-inset-bottom));
  217. }
  218. #fab[is-wide] {
  219. bottom: 24px;
  220. right: 24px;
  221. }
  222. :host([rtl]) #fab {
  223. right: auto;
  224. left: calc(16px + env(safe-area-inset-left));
  225. }
  226. :host([rtl][is-wide]) #fab {
  227. bottom: 24px;
  228. left: 24px;
  229. right: auto;
  230. }
  231. `}}]}}),t);let E=e([c("hacs-store-panel")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[i({attribute:!1})],key:"filters",value:()=>({})},{kind:"field",decorators:[i({attribute:!1})],key:"hacs",value:void 0},{kind:"field",decorators:[i()],key:"_searchInput",value:()=>""},{kind:"field",decorators:[i({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[i({attribute:!1})],key:"narrow",value:void 0},{kind:"field",decorators:[i({attribute:!1})],key:"isWide",value:void 0},{kind:"field",decorators:[i({attribute:!1})],key:"route",value:void 0},{kind:"field",decorators:[i({attribute:!1})],key:"sections",value:void 0},{kind:"field",decorators:[i()],key:"section",value:void 0},{kind:"field",key:"_repositoriesInActiveSection",value(){return d(((e,t)=>[(null==e?void 0:e.filter((e=>{var i,a,s;return(null===(i=this.hacs.sections)||void 0===i||null===(a=i.find((e=>e.id===t)))||void 0===a||null===(s=a.categories)||void 0===s?void 0:s.includes(e.category))&&e.installed})))||[],(null==e?void 0:e.filter((e=>{var i,a,s;return(null===(i=this.hacs.sections)||void 0===i||null===(a=i.find((e=>e.id===t)))||void 0===a||null===(s=a.categories)||void 0===s?void 0:s.includes(e.category))&&e.new&&!e.installed})))||[]]))}},{kind:"get",key:"allRepositories",value:function(){const[e,t]=this._repositoriesInActiveSection(this.hacs.repositories,this.section);return t.concat(e)}},{kind:"field",key:"_filterRepositories",value:()=>d(z)},{kind:"get",key:"visibleRepositories",value:function(){const e=this.allRepositories.filter((e=>{var t,i;return null===(t=this.filters[this.section])||void 0===t||null===(i=t.find((t=>t.id===e.category)))||void 0===i?void 0:i.checked}));return this._filterRepositories(e,this._searchInput)}},{kind:"method",key:"firstUpdated",value:async function(){this.addEventListener("filter-change",(e=>this._updateFilters(e)))}},{kind:"method",key:"_updateFilters",value:function(e){var t;const i=null===(t=this.filters[this.section])||void 0===t?void 0:t.find((t=>t.id===e.detail.id));this.filters[this.section].find((e=>e.id===i.id)).checked=!i.checked,this.requestUpdate()}},{kind:"method",key:"render",value:function(){var e;if(!this.hacs)return o``;const t=this._repositoriesInActiveSection(this.hacs.repositories,this.section)[1];if(!this.filters[this.section]&&this.hacs.info.categories){var i;const e=null===(i=f(this.hacs.language,this.route))||void 0===i?void 0:i.categories;this.filters[this.section]=[],null==e||e.filter((e=>{var t;return null===(t=this.hacs.info)||void 0===t?void 0:t.categories.includes(e)})).forEach((e=>{this.filters[this.section].push({id:e,value:e,checked:!0})}))}return o`<hass-tabs-subpage
  232. back-path="/hacs/entry"
  233. .hass=${this.hass}
  234. .narrow=${this.narrow}
  235. .route=${this.route}
  236. .tabs=${this.hacs.sections}
  237. hasFab
  238. >
  239. <ha-icon-overflow-menu
  240. slot="toolbar-icon"
  241. narrow
  242. .hass=${this.hass}
  243. .items=${[{path:b,label:this.hacs.localize("menu.documentation"),action:()=>m.open("https://hacs.xyz/","_blank","noreferrer=true")},{path:k,label:"GitHub",action:()=>m.open("https://github.com/hacs","_blank","noreferrer=true")},{path:g,label:this.hacs.localize("menu.open_issue"),action:()=>m.open("https://hacs.xyz/docs/issues","_blank","noreferrer=true")},{path:y,label:this.hacs.localize("menu.custom_repositories"),disabled:this.hacs.info.disabled_reason,action:()=>this.dispatchEvent(new CustomEvent("hacs-dialog",{detail:{type:"custom-repositories",repositories:this.hacs.repositories},bubbles:!0,composed:!0}))},{path:w,label:this.hacs.localize("menu.about"),action:()=>I(this,this.hacs)}]}
  244. >
  245. </ha-icon-overflow-menu>
  246. ${this.narrow?o`
  247. <search-input
  248. .hass=${this.hass}
  249. class="header"
  250. slot="header"
  251. .label=${this.hacs.localize("search.downloaded")}
  252. .filter=${this._searchInput||""}
  253. @value-changed=${this._inputValueChanged}
  254. ></search-input>
  255. `:o`<div class="search">
  256. <search-input
  257. .hass=${this.hass}
  258. .label=${0===t.length?this.hacs.localize("search.downloaded"):this.hacs.localize("search.downloaded_new")}
  259. .filter=${this._searchInput||""}
  260. @value-changed=${this._inputValueChanged}
  261. ></search-input>
  262. </div>`}
  263. <div class="content ${this.narrow?"narrow-content":""}">
  264. ${(null===(e=this.filters[this.section])||void 0===e?void 0:e.length)>1?o`<div class="filters">
  265. <hacs-filter
  266. .hacs=${this.hacs}
  267. .filters="${this.filters[this.section]}"
  268. ></hacs-filter>
  269. </div>`:""}
  270. ${null!=t&&t.length?o`<ha-alert .rtl=${j(this.hass)}>
  271. ${this.hacs.localize("store.new_repositories_note")}
  272. <mwc-button
  273. class="max-content"
  274. slot="action"
  275. .label=${this.hacs.localize("menu.dismiss")}
  276. @click=${this._clearAllNewRepositories}
  277. >
  278. </mwc-button>
  279. </ha-alert> `:""}
  280. <div class="container ${this.narrow?"narrow":""}">
  281. ${void 0===this.hacs.repositories?"":0===this.allRepositories.length?this._renderEmpty():0===this.visibleRepositories.length?this._renderNoResultsFound():this._renderRepositories()}
  282. </div>
  283. </div>
  284. <ha-fab
  285. slot="fab"
  286. .label=${this.hacs.localize("store.explore")}
  287. .extended=${!this.narrow}
  288. @click=${this._addRepository}
  289. >
  290. <ha-svg-icon slot="icon" .path=${x}></ha-svg-icon>
  291. </ha-fab>
  292. </hass-tabs-subpage>`}},{kind:"method",key:"_renderRepositories",value:function(){return this.visibleRepositories.map((e=>o`<hacs-repository-card
  293. .hass=${this.hass}
  294. .hacs=${this.hacs}
  295. .repository=${e}
  296. .narrow=${this.narrow}
  297. ?narrow=${this.narrow}
  298. ></hacs-repository-card>`))}},{kind:"method",key:"_clearAllNewRepositories",value:async function(){var e;await $(this.hass,{categories:(null===(e=f(this.hacs.language,this.route))||void 0===e?void 0:e.categories)||[]})}},{kind:"method",key:"_renderNoResultsFound",value:function(){return o`<ha-alert
  299. .rtl=${j(this.hass)}
  300. alert-type="warning"
  301. .title="${this.hacs.localize("store.no_repositories")} 😕"
  302. >
  303. ${this.hacs.localize("store.no_repositories_found_desc1",{searchInput:this._searchInput})}
  304. <br />
  305. ${this.hacs.localize("store.no_repositories_found_desc2")}
  306. </ha-alert>`}},{kind:"method",key:"_renderEmpty",value:function(){return o`<ha-alert
  307. .title="${this.hacs.localize("store.no_repositories")} 😕"
  308. .rtl=${j(this.hass)}
  309. >
  310. ${this.hacs.localize("store.no_repositories_desc1")}
  311. <br />
  312. ${this.hacs.localize("store.no_repositories_desc2")}
  313. </ha-alert>`}},{kind:"method",key:"_inputValueChanged",value:function(e){this._searchInput=e.detail.value,window.localStorage.setItem("hacs-search",this._searchInput)}},{kind:"method",key:"_addRepository",value:function(){this.dispatchEvent(new CustomEvent("hacs-dialog",{detail:{type:"add-repository",repositories:this.hacs.repositories,section:this.section},bubbles:!0,composed:!0}))}},{kind:"get",static:!0,key:"styles",value:function(){return[_,R,h`
  314. .filter {
  315. border-bottom: 1px solid var(--divider-color);
  316. }
  317. .content {
  318. height: calc(100vh - 128px);
  319. overflow: auto;
  320. }
  321. .narrow-content {
  322. height: calc(100vh - 128px);
  323. }
  324. .container {
  325. display: grid;
  326. grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
  327. justify-items: center;
  328. grid-gap: 8px 8px;
  329. padding: 8px 16px 16px;
  330. margin-bottom: 64px;
  331. }
  332. ha-svg-icon {
  333. color: var(--hcv-text-color-on-background);
  334. }
  335. hacs-repository-card {
  336. max-width: 500px;
  337. display: flex;
  338. flex-direction: column;
  339. justify-content: space-between;
  340. }
  341. hacs-repository-card[narrow] {
  342. width: 100%;
  343. }
  344. hacs-repository-card[narrow]:last-of-type {
  345. margin-bottom: 64px;
  346. }
  347. ha-alert {
  348. color: var(--hcv-text-color-primary);
  349. display: block;
  350. margin-top: -4px;
  351. }
  352. .narrow {
  353. width: 100%;
  354. display: block;
  355. padding: 0px;
  356. margin: 0;
  357. }
  358. search-input {
  359. display: block;
  360. }
  361. search-input.header {
  362. padding: 0;
  363. }
  364. .bottom-bar {
  365. position: fixed !important;
  366. }
  367. .max-content {
  368. width: max-content;
  369. }
  370. `]}}]}}),t);export{E as HacsStorePanel};