@limetech/lime-crm-building-blocks 1.140.0 → 2.0.1

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.
Files changed (216) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/cjs/file-contents-url-CIoCVl85.js +14 -0
  3. package/dist/cjs/{filter-group-logic-BPpM2NqX.js → filter-group-logic-EDLGrkTt.js} +12 -12
  4. package/dist/cjs/{filter-operators-BTWvpD6A.js → filter-operators-CVCyCZ7Q.js} +11 -11
  5. package/dist/cjs/index.cjs.js +2 -2
  6. package/dist/cjs/{index.esm-Se3EtD3m.js → index.esm-CcYbS__E.js} +210 -181
  7. package/dist/cjs/lime-crm-building-blocks.cjs.js +1 -1
  8. package/dist/cjs/{lime-query-validation-CJC3mtnT.js → lime-query-validation-B0oYW7Z6.js} +7 -7
  9. package/dist/cjs/limebb-browser.cjs.entry.js +1 -1
  10. package/dist/cjs/limebb-chat-icon-list_3.cjs.entry.js +1 -1
  11. package/dist/cjs/limebb-chat-list.cjs.entry.js +1 -1
  12. package/dist/cjs/limebb-component-config.cjs.entry.js +1 -1
  13. package/dist/cjs/limebb-component-picker.cjs.entry.js +1 -1
  14. package/dist/cjs/limebb-composer-toolbar.cjs.entry.js +1 -1
  15. package/dist/cjs/limebb-currency-picker.cjs.entry.js +1 -1
  16. package/dist/cjs/limebb-data-cells.cjs.entry.js +1 -1
  17. package/dist/cjs/limebb-date-picker.cjs.entry.js +1 -1
  18. package/dist/cjs/limebb-feed-timeline-item.cjs.entry.js +22 -6
  19. package/dist/cjs/limebb-feed.cjs.entry.js +1 -1
  20. package/dist/cjs/limebb-filter-chip_6.cjs.entry.js +22 -22
  21. package/dist/cjs/limebb-info-tile.cjs.entry.js +10 -9
  22. package/dist/cjs/limebb-inline-image.cjs.entry.js +49 -0
  23. package/dist/cjs/limebb-kanban-group.cjs.entry.js +2 -2
  24. package/dist/cjs/limebb-kanban-item.cjs.entry.js +1 -1
  25. package/dist/cjs/limebb-lime-query-builder.cjs.entry.js +3 -3
  26. package/dist/cjs/limebb-lime-query-filter-builder.cjs.entry.js +5 -5
  27. package/dist/cjs/limebb-lime-query-filter-comparison_2.cjs.entry.js +4 -4
  28. package/dist/cjs/limebb-lime-query-order-by-editor_2.cjs.entry.js +2 -2
  29. package/dist/cjs/limebb-lime-query-response-format-builder.cjs.entry.js +3 -3
  30. package/dist/cjs/limebb-limeobject-file-viewer.cjs.entry.js +3 -3
  31. package/dist/cjs/limebb-loader.cjs.entry.js +2 -2
  32. package/dist/cjs/limebb-locale-picker.cjs.entry.js +1 -1
  33. package/dist/cjs/limebb-mention.cjs.entry.js +1 -1
  34. package/dist/cjs/limebb-notification-item.cjs.entry.js +1 -1
  35. package/dist/cjs/limebb-notification-list.cjs.entry.js +1 -1
  36. package/dist/cjs/limebb-object-chip.cjs.entry.js +3 -3
  37. package/dist/cjs/limebb-percentage-visualizer.cjs.entry.js +1 -1
  38. package/dist/cjs/limebb-property-selector.cjs.entry.js +3 -3
  39. package/dist/cjs/limebb-rule-arg-filter-editor.cjs.entry.js +2 -2
  40. package/dist/cjs/limebb-rule-chip-popover.cjs.entry.js +2 -2
  41. package/dist/cjs/limebb-rule-editor.cjs.entry.js +2 -2
  42. package/dist/cjs/limebb-rule-gate.cjs.entry.js +1 -1
  43. package/dist/cjs/limebb-text-editor.cjs.entry.js +51 -144
  44. package/dist/cjs/limebb-trend-indicator.cjs.entry.js +1 -1
  45. package/dist/cjs/limebb-value-comparison-editor.cjs.entry.js +9 -9
  46. package/dist/cjs/{limetype-CmgP0nbZ.js → limetype-C-fVThrI.js} +1 -1
  47. package/dist/cjs/loader.cjs.js +1 -1
  48. package/dist/collection/collection-manifest.json +1 -0
  49. package/dist/collection/components/feed/feed-item/feed-timeline-item.js +21 -5
  50. package/dist/collection/components/info-tile/info-tile.js +1 -1
  51. package/dist/collection/components/info-tile/loader.js +2 -1
  52. package/dist/collection/components/inline-image/inline-image.css +12 -0
  53. package/dist/collection/components/inline-image/inline-image.js +146 -0
  54. package/dist/collection/components/rule-editor/value-comparison-editor/value-comparison-editor.js +1 -1
  55. package/dist/collection/components/text-editor/text-editor.js +57 -45
  56. package/dist/collection/util/file-contents-url.js +10 -0
  57. package/dist/components/chat-item.js +1 -1
  58. package/dist/components/currency-picker.js +1 -1
  59. package/dist/components/date-picker.js +1 -1
  60. package/dist/components/feed-timeline-item.js +1 -1
  61. package/dist/components/file-contents-url.js +1 -0
  62. package/dist/components/filter-chip.js +1 -1
  63. package/dist/components/filter-condition-picker.js +1 -1
  64. package/dist/components/filter-operators.js +1 -1
  65. package/dist/components/index.esm.js +1 -1
  66. package/dist/components/kanban-group.js +1 -1
  67. package/dist/components/kanban-item.js +1 -1
  68. package/dist/components/lime-query-filter-builder.js +1 -1
  69. package/dist/components/lime-query-filter-comparison-editor.js +1 -1
  70. package/dist/components/lime-query-filter-comparison.js +1 -1
  71. package/dist/components/lime-query-filter-expression.js +1 -1
  72. package/dist/components/lime-query-validation.js +1 -1
  73. package/dist/components/lime-query-value-input.js +1 -1
  74. package/dist/components/limebb-browser.js +1 -1
  75. package/dist/components/limebb-chat-list.js +1 -1
  76. package/dist/components/limebb-component-config.js +1 -1
  77. package/dist/components/limebb-component-picker.js +1 -1
  78. package/dist/components/limebb-composer-toolbar.js +1 -1
  79. package/dist/components/limebb-data-cells.js +1 -1
  80. package/dist/components/limebb-feed.js +1 -1
  81. package/dist/components/limebb-info-tile.js +1 -1
  82. package/dist/components/limebb-inline-image.d.ts +11 -0
  83. package/dist/components/limebb-inline-image.js +1 -0
  84. package/dist/components/limebb-lime-query-builder.js +1 -1
  85. package/dist/components/limebb-lime-query-response-format-builder.js +1 -1
  86. package/dist/components/limebb-limeobject-file-viewer.js +1 -1
  87. package/dist/components/limebb-loader.js +1 -1
  88. package/dist/components/limebb-locale-picker.js +1 -1
  89. package/dist/components/limebb-mention.js +1 -1
  90. package/dist/components/limebb-notification-list.js +1 -1
  91. package/dist/components/limebb-object-chip.js +1 -1
  92. package/dist/components/limebb-rule-arg-filter-editor.js +1 -1
  93. package/dist/components/limebb-rule-editor.js +1 -1
  94. package/dist/components/limebb-rule-gate.js +1 -1
  95. package/dist/components/limebb-text-editor.js +1 -1
  96. package/dist/components/limebb-trend-indicator.js +1 -1
  97. package/dist/components/limebb-value-comparison-editor.js +1 -1
  98. package/dist/components/limetype-field.js +1 -1
  99. package/dist/components/notification-item.js +1 -1
  100. package/dist/components/percentage-visualizer.js +1 -1
  101. package/dist/components/property-selector.js +1 -1
  102. package/dist/components/rule-chip-popover.js +1 -1
  103. package/dist/esm/file-contents-url-Oswz9F3I.js +12 -0
  104. package/dist/esm/{filter-group-logic-BMY_GEsX.js → filter-group-logic-DS1inQTh.js} +12 -12
  105. package/dist/esm/{filter-operators-Lw-ccmxQ.js → filter-operators-CsZi5iCV.js} +11 -11
  106. package/dist/esm/{index.esm-C-L5fkQs.js → index.esm-BjIhvFKX.js} +200 -172
  107. package/dist/esm/index.js +2 -2
  108. package/dist/esm/lime-crm-building-blocks.js +1 -1
  109. package/dist/esm/{lime-query-validation-BwvluehW.js → lime-query-validation-CVV7mrLj.js} +7 -7
  110. package/dist/esm/limebb-browser.entry.js +1 -1
  111. package/dist/esm/limebb-chat-icon-list_3.entry.js +1 -1
  112. package/dist/esm/limebb-chat-list.entry.js +1 -1
  113. package/dist/esm/limebb-component-config.entry.js +1 -1
  114. package/dist/esm/limebb-component-picker.entry.js +1 -1
  115. package/dist/esm/limebb-composer-toolbar.entry.js +1 -1
  116. package/dist/esm/limebb-currency-picker.entry.js +1 -1
  117. package/dist/esm/limebb-data-cells.entry.js +1 -1
  118. package/dist/esm/limebb-date-picker.entry.js +1 -1
  119. package/dist/esm/limebb-feed-timeline-item.entry.js +22 -6
  120. package/dist/esm/limebb-feed.entry.js +1 -1
  121. package/dist/esm/limebb-filter-chip_6.entry.js +22 -22
  122. package/dist/esm/limebb-info-tile.entry.js +10 -9
  123. package/dist/esm/limebb-inline-image.entry.js +47 -0
  124. package/dist/esm/limebb-kanban-group.entry.js +2 -2
  125. package/dist/esm/limebb-kanban-item.entry.js +1 -1
  126. package/dist/esm/limebb-lime-query-builder.entry.js +3 -3
  127. package/dist/esm/limebb-lime-query-filter-builder.entry.js +5 -5
  128. package/dist/esm/limebb-lime-query-filter-comparison_2.entry.js +4 -4
  129. package/dist/esm/limebb-lime-query-order-by-editor_2.entry.js +2 -2
  130. package/dist/esm/limebb-lime-query-response-format-builder.entry.js +3 -3
  131. package/dist/esm/limebb-limeobject-file-viewer.entry.js +3 -3
  132. package/dist/esm/limebb-loader.entry.js +2 -2
  133. package/dist/esm/limebb-locale-picker.entry.js +1 -1
  134. package/dist/esm/limebb-mention.entry.js +1 -1
  135. package/dist/esm/limebb-notification-item.entry.js +1 -1
  136. package/dist/esm/limebb-notification-list.entry.js +1 -1
  137. package/dist/esm/limebb-object-chip.entry.js +3 -3
  138. package/dist/esm/limebb-percentage-visualizer.entry.js +1 -1
  139. package/dist/esm/limebb-property-selector.entry.js +3 -3
  140. package/dist/esm/limebb-rule-arg-filter-editor.entry.js +2 -2
  141. package/dist/esm/limebb-rule-chip-popover.entry.js +2 -2
  142. package/dist/esm/limebb-rule-editor.entry.js +2 -2
  143. package/dist/esm/limebb-rule-gate.entry.js +1 -1
  144. package/dist/esm/limebb-text-editor.entry.js +51 -144
  145. package/dist/esm/limebb-trend-indicator.entry.js +1 -1
  146. package/dist/esm/limebb-value-comparison-editor.entry.js +9 -9
  147. package/dist/esm/{limetype-D4ZaWZ-3.js → limetype-BbMRN-SU.js} +1 -1
  148. package/dist/esm/loader.js +1 -1
  149. package/dist/lime-crm-building-blocks/index.esm.js +1 -1
  150. package/dist/lime-crm-building-blocks/lime-crm-building-blocks.esm.js +1 -1
  151. package/dist/lime-crm-building-blocks/p-1c6e5402.entry.js +1 -0
  152. package/dist/lime-crm-building-blocks/{p-9452fb56.entry.js → p-240cbd82.entry.js} +1 -1
  153. package/dist/lime-crm-building-blocks/{p-58f18819.entry.js → p-25984c90.entry.js} +1 -1
  154. package/dist/lime-crm-building-blocks/{p-80e04b27.entry.js → p-397a6191.entry.js} +1 -1
  155. package/dist/lime-crm-building-blocks/{p-a6e9cefe.entry.js → p-52a92d89.entry.js} +1 -1
  156. package/dist/lime-crm-building-blocks/p-585f6cfe.entry.js +1 -0
  157. package/dist/lime-crm-building-blocks/{p-05a1762a.entry.js → p-59fb624c.entry.js} +1 -1
  158. package/dist/lime-crm-building-blocks/{p-fb8d854b.entry.js → p-5beb508a.entry.js} +1 -1
  159. package/dist/lime-crm-building-blocks/{p-92bf5318.entry.js → p-662fb8b6.entry.js} +1 -1
  160. package/dist/lime-crm-building-blocks/{p-00ca6522.entry.js → p-673226a6.entry.js} +1 -1
  161. package/dist/lime-crm-building-blocks/{p-e242b955.entry.js → p-69b08896.entry.js} +1 -1
  162. package/dist/lime-crm-building-blocks/{p-01f84b0c.entry.js → p-6c2e25d9.entry.js} +1 -1
  163. package/dist/lime-crm-building-blocks/{p-3bf316f9.entry.js → p-742926a3.entry.js} +1 -1
  164. package/dist/lime-crm-building-blocks/p-78d362b4.entry.js +1 -0
  165. package/dist/lime-crm-building-blocks/p-79c492b2.entry.js +1 -0
  166. package/dist/lime-crm-building-blocks/{p-dba6f583.entry.js → p-7a5c2dda.entry.js} +1 -1
  167. package/dist/lime-crm-building-blocks/{p-354257f4.entry.js → p-7ce967b6.entry.js} +1 -1
  168. package/dist/lime-crm-building-blocks/{p-d40f53a5.entry.js → p-906b4eca.entry.js} +1 -1
  169. package/dist/lime-crm-building-blocks/p-CE43qjk3.js +1 -0
  170. package/dist/lime-crm-building-blocks/p-Cw4kdMw3.js +1 -0
  171. package/dist/lime-crm-building-blocks/p-DLehg4hi.js +1 -0
  172. package/dist/lime-crm-building-blocks/{p-CI6VHE0w.js → p-Dhyy9Td7.js} +1 -1
  173. package/dist/lime-crm-building-blocks/p-Oswz9F3I.js +1 -0
  174. package/dist/lime-crm-building-blocks/p-a3058b72.entry.js +1 -0
  175. package/dist/lime-crm-building-blocks/p-b78ub0mY.js +1 -0
  176. package/dist/lime-crm-building-blocks/{p-f3cb68d6.entry.js → p-bc297cf4.entry.js} +1 -1
  177. package/dist/lime-crm-building-blocks/{p-cac2a49f.entry.js → p-bcd8c767.entry.js} +1 -1
  178. package/dist/lime-crm-building-blocks/p-c4e5e589.entry.js +1 -0
  179. package/dist/lime-crm-building-blocks/p-c97c4604.entry.js +1 -0
  180. package/dist/lime-crm-building-blocks/{p-8986f27b.entry.js → p-d014ec57.entry.js} +1 -1
  181. package/dist/lime-crm-building-blocks/p-d20404ec.entry.js +1 -0
  182. package/dist/lime-crm-building-blocks/{p-fb050628.entry.js → p-d2e85be2.entry.js} +1 -1
  183. package/dist/lime-crm-building-blocks/{p-dec2b87d.entry.js → p-d3fe25a7.entry.js} +1 -1
  184. package/dist/lime-crm-building-blocks/{p-f1090436.entry.js → p-d43cf8d1.entry.js} +1 -1
  185. package/dist/lime-crm-building-blocks/{p-430e3d11.entry.js → p-dd7aec09.entry.js} +1 -1
  186. package/dist/lime-crm-building-blocks/{p-b34817df.entry.js → p-e2e1358d.entry.js} +1 -1
  187. package/dist/lime-crm-building-blocks/{p-c0fa239a.entry.js → p-e4a21ebe.entry.js} +1 -1
  188. package/dist/lime-crm-building-blocks/{p-c4e2dca5.entry.js → p-e581d0b7.entry.js} +1 -1
  189. package/dist/lime-crm-building-blocks/{p-863f456c.entry.js → p-e6a85c26.entry.js} +1 -1
  190. package/dist/lime-crm-building-blocks/p-e8b2df7c.entry.js +1 -0
  191. package/dist/lime-crm-building-blocks/{p-6fe4c1cd.entry.js → p-ef890206.entry.js} +1 -1
  192. package/dist/lime-crm-building-blocks/{p-d7d21bad.entry.js → p-f6377fa5.entry.js} +1 -1
  193. package/dist/lime-crm-building-blocks/p-f9e9d18e.entry.js +1 -0
  194. package/dist/test/setup.js +1 -0
  195. package/dist/types/components/feed/feed-item/feed-timeline-item.d.ts +2 -0
  196. package/dist/types/components/inline-image/inline-image.d.ts +32 -0
  197. package/dist/types/components/text-editor/text-editor.d.ts +17 -11
  198. package/dist/types/components.d.ts +93 -14
  199. package/dist/types/interface.d.ts +0 -5
  200. package/dist/types/util/file-contents-url.d.ts +9 -0
  201. package/package.json +12 -13
  202. package/dist/collection/components/text-editor/uploader/building-blocks-upload-handler.js +0 -112
  203. package/dist/lime-crm-building-blocks/p-29758303.entry.js +0 -1
  204. package/dist/lime-crm-building-blocks/p-2dab7d4b.entry.js +0 -1
  205. package/dist/lime-crm-building-blocks/p-43bdd66b.entry.js +0 -1
  206. package/dist/lime-crm-building-blocks/p-752742f8.entry.js +0 -1
  207. package/dist/lime-crm-building-blocks/p-B-WBKAaa.js +0 -1
  208. package/dist/lime-crm-building-blocks/p-BjXRsiQr.js +0 -1
  209. package/dist/lime-crm-building-blocks/p-Bkno2RtN.js +0 -1
  210. package/dist/lime-crm-building-blocks/p-D1RJ1y7s.js +0 -1
  211. package/dist/lime-crm-building-blocks/p-c891125e.entry.js +0 -1
  212. package/dist/lime-crm-building-blocks/p-cd7106f7.entry.js +0 -1
  213. package/dist/lime-crm-building-blocks/p-dbbc5ba7.entry.js +0 -1
  214. package/dist/lime-crm-building-blocks/p-ec1e079e.entry.js +0 -1
  215. package/dist/lime-crm-building-blocks/p-edeb359f.entry.js +0 -1
  216. package/dist/types/components/text-editor/uploader/building-blocks-upload-handler.d.ts +0 -62
@@ -1 +1 @@
1
- import{proxyCustomElement as t,HTMLElement as i,getElement as e,h as s,transformTag as h}from"@stencil/core/internal/client";import{g as o}from"./limetype.js";import{f as a}from"./dom.js";import{M as l,b as r}from"./index.esm.js";const n=l("object-resolver");function c(t,i){return`object/${t}/${i}`}class d{constructor(t){this.onStateChange=t,this.state={loadFailed:!1},this.hasPendingLoad=!1,this.isDisconnected=!1}get resolvedPlatform(){return this._platform}connect(t,i,e,s){this.limetype=t,this.objectid=i,this.isDisconnected=!1,this.hasPendingLoad=!1,this._platform=s||this.findPlatform(e),this._platform?(this.resolveLimeType(),this.loadLimeObject()):n.error(`No platform found. Pass "platform" prop or place the component inside a parent that exposes "platform". limetype=${t}, objectid=${i}`)}update(t,i){this.limetype=t,this.objectid=i,this.updateState({limeobject:void 0,limetypeData:void 0,loadFailed:!1}),this.hasPendingLoad||(this.hasPendingLoad=!0,queueMicrotask((()=>{if(this.hasPendingLoad=!1,!this.isDisconnected){if(!this._platform)return this.updateState({loadFailed:!0}),void n.warn(`Cannot update: no platform available. limetype=${this.limetype}, objectid=${this.objectid}`);this.resolveLimeType(),this.loadLimeObject()}})))}disconnect(){this.isDisconnected=!0}findPlatform(t){const i=a(t,this.hasPlatformProp);return null==i?void 0:i.platform}hasPlatformProp(t){return"platform"in t&&!!t.platform&&"object"==typeof t.platform}resolveLimeType(){const t=this._platform.get(r.LimeTypeRepository);this.updateState({limetypeData:t.getLimeType(this.limetype)})}async loadLimeObject(){const t=this.limetype,i=this.objectid,e=this._platform.get(r.LimeObjectRepository),s=e.getObject(t,i);if(s)this.updateState({limeobject:s});else{try{await e.loadObject(t,i)}catch(e){if(this.isStale(t,i))return;return this.updateState({loadFailed:!0}),void n.error(`Failed to load ${t}/${i}`,e)}this.isStale(t,i)||this.updateState({limeobject:e.getObject(t,i)})}}isStale(t,i){return this.isDisconnected||this.limetype!==t||this.objectid!==i}updateState(t){this.state=Object.assign(Object.assign({},this.state),t),this.isDisconnected||this.onStateChange(this.state)}}const m=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.size="default",this.data={loadFailed:!1},this.resolver=new d((t=>{this.data=t}))}connectedCallback(){this.resolver.connect(this.limetype,this.objectid,e(this),this.platform)}disconnectedCallback(){this.resolver.disconnect()}handlePropChange(){this.resolver.update(this.limetype,this.objectid)}render(){if(!this.resolver.resolvedPlatform)return;const t=o(this.data.limetypeData);return s("limel-chip",{text:this.getChipText(),icon:t,size:this.size,link:{href:c(this.limetype,this.objectid)},loading:!this.data.limeobject&&!this.data.loadFailed})}getChipText(){var t;return(null===(t=this.data.limeobject)||void 0===t?void 0:t.descriptive)?this.data.limeobject.descriptive:this.data.loadFailed?this.getErrorText():""}getErrorText(){if(!this.resolver.resolvedPlatform)return"loading failed";try{return this.resolver.resolvedPlatform.get(r.Translate).get("webclient.limeobject.errors.load-failed")}catch(t){return"loading failed"}}static get watchers(){return{limetype:[{handlePropChange:0}],objectid:[{handlePropChange:0}]}}static get style(){return":host{display:inline-block;vertical-align:baseline}"}},[1,"limebb-object-chip",{limetype:[1],objectid:[2],size:[1],platform:[16],data:[32]},void 0,{limetype:[{handlePropChange:0}],objectid:[{handlePropChange:0}]}]),p=m,u=function(){"undefined"!=typeof customElements&&["limebb-object-chip"].forEach((t=>{"limebb-object-chip"===t&&(customElements.get(h(t))||customElements.define(h(t),m))}))};export{p as LimebbObjectChip,u as defineCustomElement}
1
+ import{proxyCustomElement as t,HTMLElement as i,getElement as e,h as s,transformTag as h}from"@stencil/core/internal/client";import{g as o}from"./limetype.js";import{f as a}from"./dom.js";import{b as l,n as r}from"./index.esm.js";const n=l("object-resolver");function c(t,i){return`object/${t}/${i}`}class d{constructor(t){this.onStateChange=t,this.state={loadFailed:!1},this.hasPendingLoad=!1,this.isDisconnected=!1}get resolvedPlatform(){return this._platform}connect(t,i,e,s){this.limetype=t,this.objectid=i,this.isDisconnected=!1,this.hasPendingLoad=!1,this._platform=s||this.findPlatform(e),this._platform?(this.resolveLimeType(),this.loadLimeObject()):n.error(`No platform found. Pass "platform" prop or place the component inside a parent that exposes "platform". limetype=${t}, objectid=${i}`)}update(t,i){this.limetype=t,this.objectid=i,this.updateState({limeobject:void 0,limetypeData:void 0,loadFailed:!1}),this.hasPendingLoad||(this.hasPendingLoad=!0,queueMicrotask((()=>{if(this.hasPendingLoad=!1,!this.isDisconnected){if(!this._platform)return this.updateState({loadFailed:!0}),void n.warn(`Cannot update: no platform available. limetype=${this.limetype}, objectid=${this.objectid}`);this.resolveLimeType(),this.loadLimeObject()}})))}disconnect(){this.isDisconnected=!0}findPlatform(t){const i=a(t,this.hasPlatformProp);return null==i?void 0:i.platform}hasPlatformProp(t){return"platform"in t&&!!t.platform&&"object"==typeof t.platform}resolveLimeType(){const t=this._platform.get(r.LimeTypeRepository);this.updateState({limetypeData:t.getLimeType(this.limetype)})}async loadLimeObject(){const t=this.limetype,i=this.objectid,e=this._platform.get(r.LimeObjectRepository),s=e.getObject(t,i);if(s)this.updateState({limeobject:s});else{try{await e.loadObject(t,i)}catch(e){if(this.isStale(t,i))return;return this.updateState({loadFailed:!0}),void n.error(`Failed to load ${t}/${i}`,e)}this.isStale(t,i)||this.updateState({limeobject:e.getObject(t,i)})}}isStale(t,i){return this.isDisconnected||this.limetype!==t||this.objectid!==i}updateState(t){this.state=Object.assign(Object.assign({},this.state),t),this.isDisconnected||this.onStateChange(this.state)}}const m=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.size="default",this.data={loadFailed:!1},this.resolver=new d((t=>{this.data=t}))}connectedCallback(){this.resolver.connect(this.limetype,this.objectid,e(this),this.platform)}disconnectedCallback(){this.resolver.disconnect()}handlePropChange(){this.resolver.update(this.limetype,this.objectid)}render(){if(!this.resolver.resolvedPlatform)return;const t=o(this.data.limetypeData);return s("limel-chip",{text:this.getChipText(),icon:t,size:this.size,link:{href:c(this.limetype,this.objectid)},loading:!this.data.limeobject&&!this.data.loadFailed})}getChipText(){var t;return(null===(t=this.data.limeobject)||void 0===t?void 0:t.descriptive)?this.data.limeobject.descriptive:this.data.loadFailed?this.getErrorText():""}getErrorText(){if(!this.resolver.resolvedPlatform)return"loading failed";try{return this.resolver.resolvedPlatform.get(r.Translate).get("webclient.limeobject.errors.load-failed")}catch(t){return"loading failed"}}static get watchers(){return{limetype:[{handlePropChange:0}],objectid:[{handlePropChange:0}]}}static get style(){return":host{display:inline-block;vertical-align:baseline}"}},[1,"limebb-object-chip",{limetype:[1],objectid:[2],size:[1],platform:[16],data:[32]},void 0,{limetype:[{handlePropChange:0}],objectid:[{handlePropChange:0}]}]),p=m,u=function(){"undefined"!=typeof customElements&&["limebb-object-chip"].forEach((t=>{"limebb-object-chip"===t&&(customElements.get(h(t))||customElements.define(h(t),m))}))};export{p as LimebbObjectChip,u as defineCustomElement}
@@ -1 +1 @@
1
- import{proxyCustomElement as e,HTMLElement as i,createEvent as t,h as r,transformTag as l}from"@stencil/core/internal/client";import{O as o}from"./index.esm.js";import{d as s}from"./filter-chip.js";import{d as m}from"./filter-condition-picker.js";import{d as c}from"./lime-query-filter-builder.js";import{d as n}from"./lime-query-filter-comparison.js";import{d as b}from"./lime-query-filter-comparison-editor.js";import{e as u,b as a,d as f}from"./lime-query-filter-expression.js";import{d as p}from"./lime-query-value-input.js";import{d}from"./property-selector.js";const y=e(class extends i{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.change=t(this,"change",7),this.value={},this.handleExpressionChange=e=>{e.stopPropagation(),this.change.emit({expression:e.detail})}}render(){var e,i;const t=null===(e=this.resolvedContext)||void 0===e?void 0:e.limetype;return t?r("limebb-lime-query-filter-builder",{platform:this.platform,context:this.context,limetype:t,expression:null===(i=this.value)||void 0===i?void 0:i.expression,onExpressionChange:this.handleExpressionChange}):r("limel-callout",{type:"note"},"Select a limetype on the surface to author a filter.")}static get style(){return":host{display:block}"}},[1,"limebb-rule-arg-filter-editor",{platform:[16],context:[16],value:[16],resolvedContext:[32]}]);!function(e,i,t,r){var l,o=arguments.length,s=o<3?i:null===r?r=Object.getOwnPropertyDescriptor(i,t):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,i,t,r);else for(var m=e.length-1;m>=0;m--)(l=e[m])&&(s=(o<3?l(s):o>3?l(i,t,s):l(i,t))||s);o>3&&s&&Object.defineProperty(i,t,s)}([o("context")],y.prototype,"resolvedContext",void 0);const h=y,q=function(){"undefined"!=typeof customElements&&["limebb-rule-arg-filter-editor","limebb-filter-chip","limebb-filter-condition-picker","limebb-lime-query-filter-builder","limebb-lime-query-filter-comparison","limebb-lime-query-filter-comparison-editor","limebb-lime-query-filter-expression","limebb-lime-query-filter-group","limebb-lime-query-filter-not","limebb-lime-query-value-input","limebb-property-selector"].forEach((e=>{switch(e){case"limebb-rule-arg-filter-editor":customElements.get(l(e))||customElements.define(l(e),y);break;case"limebb-filter-chip":customElements.get(l(e))||s();break;case"limebb-filter-condition-picker":customElements.get(l(e))||m();break;case"limebb-lime-query-filter-builder":customElements.get(l(e))||c();break;case"limebb-lime-query-filter-comparison":customElements.get(l(e))||n();break;case"limebb-lime-query-filter-comparison-editor":customElements.get(l(e))||b();break;case"limebb-lime-query-filter-expression":customElements.get(l(e))||f();break;case"limebb-lime-query-filter-group":customElements.get(l(e))||a();break;case"limebb-lime-query-filter-not":customElements.get(l(e))||u();break;case"limebb-lime-query-value-input":customElements.get(l(e))||p();break;case"limebb-property-selector":customElements.get(l(e))||d()}}))};export{h as LimebbRuleArgFilterEditor,q as defineCustomElement}
1
+ import{proxyCustomElement as e,HTMLElement as i,createEvent as t,h as r,transformTag as l}from"@stencil/core/internal/client";import{M as o}from"./index.esm.js";import{d as s}from"./filter-chip.js";import{d as m}from"./filter-condition-picker.js";import{d as c}from"./lime-query-filter-builder.js";import{d as n}from"./lime-query-filter-comparison.js";import{d as b}from"./lime-query-filter-comparison-editor.js";import{e as u,b as a,d as f}from"./lime-query-filter-expression.js";import{d as p}from"./lime-query-value-input.js";import{d}from"./property-selector.js";const y=e(class extends i{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.change=t(this,"change",7),this.value={},this.handleExpressionChange=e=>{e.stopPropagation(),this.change.emit({expression:e.detail})}}render(){var e,i;const t=null===(e=this.resolvedContext)||void 0===e?void 0:e.limetype;return t?r("limebb-lime-query-filter-builder",{platform:this.platform,context:this.context,limetype:t,expression:null===(i=this.value)||void 0===i?void 0:i.expression,onExpressionChange:this.handleExpressionChange}):r("limel-callout",{type:"note"},"Select a limetype on the surface to author a filter.")}static get style(){return":host{display:block}"}},[1,"limebb-rule-arg-filter-editor",{platform:[16],context:[16],value:[16],resolvedContext:[32]}]);!function(e,i,t,r){var l,o=arguments.length,s=o<3?i:null===r?r=Object.getOwnPropertyDescriptor(i,t):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,i,t,r);else for(var m=e.length-1;m>=0;m--)(l=e[m])&&(s=(o<3?l(s):o>3?l(i,t,s):l(i,t))||s);o>3&&s&&Object.defineProperty(i,t,s)}([o("context")],y.prototype,"resolvedContext",void 0);const h=y,q=function(){"undefined"!=typeof customElements&&["limebb-rule-arg-filter-editor","limebb-filter-chip","limebb-filter-condition-picker","limebb-lime-query-filter-builder","limebb-lime-query-filter-comparison","limebb-lime-query-filter-comparison-editor","limebb-lime-query-filter-expression","limebb-lime-query-filter-group","limebb-lime-query-filter-not","limebb-lime-query-value-input","limebb-property-selector"].forEach((e=>{switch(e){case"limebb-rule-arg-filter-editor":customElements.get(l(e))||customElements.define(l(e),y);break;case"limebb-filter-chip":customElements.get(l(e))||s();break;case"limebb-filter-condition-picker":customElements.get(l(e))||m();break;case"limebb-lime-query-filter-builder":customElements.get(l(e))||c();break;case"limebb-lime-query-filter-comparison":customElements.get(l(e))||n();break;case"limebb-lime-query-filter-comparison-editor":customElements.get(l(e))||b();break;case"limebb-lime-query-filter-expression":customElements.get(l(e))||f();break;case"limebb-lime-query-filter-group":customElements.get(l(e))||a();break;case"limebb-lime-query-filter-not":customElements.get(l(e))||u();break;case"limebb-lime-query-value-input":customElements.get(l(e))||p();break;case"limebb-property-selector":customElements.get(l(e))||d()}}))};export{h as LimebbRuleArgFilterEditor,q as defineCustomElement}
@@ -1 +1 @@
1
- import{h as e,proxyCustomElement as t,HTMLElement as n,createEvent as r,transformTag as i}from"@stencil/core/internal/client";import{O as l,b as o}from"./index.esm.js";import{d as s}from"./rule-chip-popover.js";function u(e,t){return t?{type:"not",rule:e}:e}function a(e,t){return e.length===t.length&&e.every(((e,n)=>e===t[n]))}function c(e,t){return e.filter((e=>a(e.path,t)))}function d(e,t){let n=e;for(const e of t){if(void 0===n)return;n=f(n,e)}return n}function h(e,t,n){if(0===t.length)return n;const[r,...i]=t;if("not"===e.type&&"rule"===r)return Object.assign(Object.assign({},e),{rule:h(e.rule,i,n)});if(("all"===e.type||"any"===e.type)&&"rules"===r){if(0===i.length)return n;const[t,...r]=i;if("number"!=typeof t)return e;const l=[...e.rules];return l[t]=h(l[t],r,n),Object.assign(Object.assign({},e),{rules:l})}return e}function f(e,t){return"not"===e.type&&"rule"===t?e.rule:"all"!==e.type&&"any"!==e.type||"rules"!==t?"all"!==e.type&&"any"!==e.type||"number"!=typeof t?e:e.rules[t]:e}const p={name:"question",color:"rgb(var(--color-glaucous-light))"};function b(e,t){return{"rule-node":!0,["rule-node--"+e]:!0,"rule-node--invalid":t.length>0}}function v(e,t){return[...e.values()].map((e=>({value:e.id,text:e.title?t.get(e.title):e.id,secondaryText:e.description?t.get(e.description):"",icon:e.icon}))).sort(((e,t)=>e.text.localeCompare(t.text)))}function m(e,t){return e.reads.every((e=>t.has(e)))}function g(e){return"__chip__:"+e}function y(e,t){return[...e,"rules",t]}function _(e){return"ref"===e.type?{ref:e,isNegated:!1}:"not"===e.type&&"ref"===e.rule.type?{ref:e.rule,isNegated:!0}:null}const x=({groupNode:t,groupPath:n,chipChildren:r,ctx:i})=>{const l=new Map,o=r.map((e=>{const t=g(e.index);l.set(t,e);const n=function(e,t){var n;return null!==(n=e.find((e=>e.value===t)))&&void 0!==n?n:{value:t,text:t,icon:p}}(i.allPrimitiveOptions,e.ref.id);return Object.assign(Object.assign({},n),{text:e.isNegated?"¬ "+n.text:n.text,value:t})})),s=function(e){return t=>Promise.resolve(function(e,t){if(!t)return e;const n=t.toLocaleLowerCase().split(/\s+/);return e.filter((e=>n.every((t=>{var n,r;return e.text.toLocaleLowerCase().includes(t)||(null===(n=e.secondaryText)||void 0===n?void 0:n.toLocaleLowerCase().includes(t))||(null===(r=e.value)||void 0===r?void 0:r.toLocaleLowerCase().includes(t))}))))}(e,t))}(i.availablePrimitiveOptions),u=function(e,t,n){var r;const i=N(t,n);return null===i?null:null!==(r=e.find((e=>e.index===i)))&&void 0!==r?r:null}(r,n,i.openChipPath),a="all"===t.type?"&":"|";return e("limel-popover",{class:"rule-node__chips-popover",open:null!==u,openDirection:"bottom-start",onClose:i.onPopoverClose},e("div",{slot:"trigger",class:"rule-node__chips"},e("limel-picker",{multiple:!0,label:i.translator.get("webclient.rule-editor.rules-label"),value:o,searcher:s,delimiter:a,readonly:i.readonly,disabled:i.disabled,onChange:C(t,n,l,i),onInteract:O(n,l,i)})),e("div",null,function(t,n,r){if(!t)return null;const i=y(n,t.index);return e("limebb-rule-chip-popover",{platform:r.platform,context:r.context,refNode:t.ref,isNegated:t.isNegated,metadata:r.metadataById.get(t.ref.id),readonly:r.readonly,disabled:r.disabled,isMutable:r.isMutable,focusOnOpen:r.focusOnOpen,onNegate:j(t,i,r),onUpdateArgs:w(t,i,r),onDeleteChip:k(i,r)})}(u,n,i)))},C=(e,t,n,r)=>i=>{i.stopPropagation();const l=Array.isArray(i.detail)?i.detail:[],o=N(t,r.openChipPath);if(null!==o){const e=g(o);l.every((t=>t.value!==e))&&r.onPopoverClose()}const s=l.flatMap((e=>{if("string"!=typeof e.value)return[];const t=n.get(e.value);return t?[t.isNegated?{type:"not",rule:t.ref}:t.ref]:[{type:"ref",id:e.value}]})),u=e.rules.filter((e=>null===_(e)));r.onReplaceNode(t,Object.assign(Object.assign({},e),{rules:[...s,...u]}))},O=(e,t,n)=>r=>{r.stopPropagation();const i=function(e){if("string"==typeof e)return e;if(e&&"object"==typeof e&&"value"in e){const t=e.value;return"string"==typeof t?t:void 0}}(r.detail),l=i?t.get(i):void 0;l&&n.onChipInteract([...e,"rules",l.index])},j=(e,t,n)=>r=>{r.stopPropagation(),n.onReplaceNode(t,r.detail?{type:"not",rule:e.ref}:e.ref)},w=(e,t,n)=>r=>{r.stopPropagation();const i=e.isNegated?[...t,"rule"]:t;n.onUpdateArgs(i,r.detail)},k=(e,t)=>()=>{t.onDelete(e)};function N(e,t){if(!t||t.length<2)return null;if(!a(function(e){return e.slice(0,-2)}(t),e))return null;const n=t.at(-1);return"number"==typeof n?n:null}const P=({node:t,path:n,isNegated:r,ctx:i})=>{const l=r?[...n,"rule"]:n,o=r?[...c(i.issues,n),...c(i.issues,l)]:c(i.issues,n),s=[],u=[];for(const[e,n]of t.rules.entries()){const t=_(n);t?s.push(Object.assign(Object.assign({},t),{index:e})):u.push({child:n,index:e})}const a=function(e){return[{value:"all",text:e.translator.get("webclient.rule-editor.combinator.all")},{value:"any",text:e.translator.get("webclient.rule-editor.combinator.any")}]}(i),d=a.find((e=>e.value===t.type));return e("div",{class:b(t.type,o),key:R(n)},e("div",{class:"rule-node__header"},e("limel-select",{class:"rule-node__combinator-select",value:d,options:a,disabled:!i.isMutable,onChange:A(t,n,r,i)}),function(t,n,r,i){return i.isMutable?e("div",{class:"rule-node__header-actions"},e("limel-switch",{class:"rule-node__negate-switch",label:i.translator.get("webclient.rule-editor.negate"),value:r,onChange:V(t,n,i)}),e("limel-icon-button",{icon:"trash",label:i.translator.get("webclient.rule-editor.delete"),onClick:()=>i.onDelete(n)})):null}(t,n,r,i)),e("div",{class:"rule-node__body"},e(S,{issues:o}),e(x,{groupNode:t,groupPath:l,chipChildren:s,ctx:i}),function(t,n,r){return 0===t.length?null:e("div",{class:"rule-node__children"},t.map((t=>e(D,{node:t.child,path:[...n,"rules",t.index],ctx:r}))))}(u,l,i),function(t,n,r,i){return i.isMutable?e("div",{class:"rule-node__footer"},e("limel-button",{icon:"add",label:i.translator.get("webclient.rule-editor.add-nested-group"),onClick:z(t,n,r,i)})):null}(t,n,r,i)))};function R(e){return 0===e.length?"root":e.join("/")}function M(e,t,n,r){r.onReplaceNode(t,u(e,n))}const A=(e,t,n,r)=>i=>{i.stopPropagation();const l=i.detail.value;l!==e.type&&M(Object.assign(Object.assign({},e),{type:l}),t,n,r)},z=(e,t,n,r)=>()=>{M(function(e){return Object.assign(Object.assign({},e),{rules:[...e.rules,{type:"all",rules:[]}]})}(e),t,n,r)},V=(e,t,n)=>r=>{r.stopPropagation(),n.onReplaceNode(t,u(e,r.detail))},D=t=>{const{node:n,path:r,ctx:i}=t,l=I(n);return l?e(P,{node:l.node,path:r,isNegated:l.isNegated,ctx:i}):null},E=e=>"not"===e.type&&("all"===e.rule.type||"any"===e.rule.type);function I(e){if("all"===e.type||"any"===e.type)return{node:e,isNegated:!1};if(E(e))return{node:e.rule,isNegated:!0};if("not"===e.type){const t=I(e.rule);if(t)return{node:t.node,isNegated:!t.isNegated}}return null}const S=({issues:t})=>0===t.length?null:t.map((t=>e("div",{class:"rule-node__issue"},t.message)));const L=t(class extends n{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.change=r(this,"change",7),this.issues=[],this.openChipPath=null,this.focusOnOpen=!1,this.metadataById=new Map,this.allPrimitiveOptions=[],this.availablePrimitiveOptions=[],this.reachableSlots=new Set,this.normalizedCache=null,this.hasLoaded=!1,this.handleDelete=e=>{this.openChipPath=null,this.focusOnOpen=!1,this.emitIfChanged(function(e,t){if(0===t.length)return{type:"all",rules:[]};const n=t.slice(0,-1),r=t.at(-1),i=d(e,n);if(void 0===i)return e;if(("all"===i.type||"any"===i.type)&&"number"==typeof r){const t=[...i.rules];return t.splice(r,1),h(e,n,Object.assign(Object.assign({},i),{rules:t}))}return"not"===i.type&&"rule"===r?h(e,n,{type:"all",rules:[]}):e}(this.normalizedValue,e))},this.handleUpdateArgs=(e,t)=>{this.emitIfChanged(function(e,t,n){const r=d(e,t);return void 0===r||"ref"!==r.type?e:h(e,t,Object.assign(Object.assign({},r),{args:n}))}(this.normalizedValue,e,t))},this.handleReplaceNode=(e,t)=>{const n=this.autoOpenPathFor(e,t);this.focusOnOpen=null!==n,null!==n&&(this.openChipPath=n),this.emitIfChanged(function(e,t,n){return h(e,t,n)}(this.normalizedValue,e,t))},this.handleChipInteract=e=>{this.openChipPath=e,this.focusOnOpen=!1},this.handlePopoverClose=()=>{this.openChipPath=null,this.focusOnOpen=!1}}componentWillLoad(){this.rebuildFromRegistries()}rebuildFromRegistries(){this.computeReachableSlots(),this.indexMetadata(),this.rebuildAvailableOptions(),this.runValidation()}connectedCallback(){this.hasLoaded&&(this.computeReachableSlots(),this.rebuildAvailableOptions(),this.runValidation())}componentDidLoad(){this.hasLoaded=!0,this.emitNormalization()}onValueChange(){this.emitNormalization()||this.runValidation()}onAvailableContextsChange(){this.rebuildFromRegistries()}render(){return e("div",{key:"abe9c739c5fbd0749a593187fd36953482530aeb",class:{"rule-editor":!0,"rule-editor--disabled":this.disabled}},this.renderLabel(),e(D,{key:"ba99e8de897dec3825fb74f78d42b3f503ead775",node:this.normalizedValue,path:[],ctx:this.createRenderContext()}),this.renderHelperText())}renderLabel(){return this.label?e("div",{class:"rule-editor__label"},this.label):null}renderHelperText(){return this.helperText?e("div",{class:"rule-editor__helper-text"},this.helperText):null}createRenderContext(){return{issues:this.issues,metadataById:this.metadataById,allPrimitiveOptions:this.allPrimitiveOptions,availablePrimitiveOptions:this.availablePrimitiveOptions,isMutable:!this.readonly&&!this.disabled,readonly:this.readonly,disabled:this.disabled,platform:this.platform,context:this.effectiveContext,translator:this.translator,openChipPath:this.openChipPath,focusOnOpen:this.focusOnOpen,onDelete:this.handleDelete,onUpdateArgs:this.handleUpdateArgs,onReplaceNode:this.handleReplaceNode,onChipInteract:this.handleChipInteract,onPopoverClose:this.handlePopoverClose}}autoOpenPathFor(e,t){var n;if("all"!==t.type&&"any"!==t.type)return null;const r=d(this.normalizedValue,e);if(void 0===r||"all"!==r.type&&"any"!==r.type)return null;const i=new Set(r.rules.map((e=>{var t;return null===(t=_(e))||void 0===t?void 0:t.ref})).filter((e=>void 0!==e))),l=t.rules.map(((e,t)=>{var n;const r=null===(n=_(e))||void 0===n?void 0:n.ref;return r&&!i.has(r)?{ref:r,index:t}:null})).filter((e=>null!==e));if(1!==l.length)return null;const[{ref:o,index:s}]=l;return(null===(n=this.metadataById.get(o.id))||void 0===n?void 0:n.configComponent)?y(e,s):null}indexMetadata(){var e,t,n;const r=null!==(n=null===(t=(e=this.ruleRegistry).listMetadata)||void 0===t?void 0:t.call(e))&&void 0!==n?n:[];this.metadataById=new Map(r.map((e=>[e.id,e]))),this.allPrimitiveOptions=v(this.metadataById,this.translator)}rebuildAvailableOptions(){this.availablePrimitiveOptions=v(this.availablePrimitiveMetadata(),this.translator)}availablePrimitiveMetadata(){const e=new Map;for(const[t,n]of this.metadataById)m(n,this.reachableSlots)&&e.set(t,n);return e}computeReachableSlots(){var e;const t=this.contextRegistry,n=t.list().map((e=>e.id)).filter((e=>void 0!==t.get(e,this.host)));this.reachableSlots=new Set([...n,...null!==(e=this.availableContexts)&&void 0!==e?e:[]])}runValidation(){if(!this.value)return void(this.issues=[]);const e=this.ruleRegistry.validate(this.normalizedValue,[...this.reachableSlots]);this.issues=e.ok?[]:e.issues}emitIfChanged(e){e!==this.normalizedValue&&this.change.emit(function(e){return"all"!==e.type&&"any"!==e.type?e:0===e.rules.length?void 0:e}(e))}get normalizedValue(){if(null!==this.normalizedCache&&this.normalizedCache.source===this.value)return this.normalizedCache.normalized;const e=function(e){return e?I(e)?e:{type:"all",rules:[e]}:{type:"all",rules:[]}}(this.value);return this.normalizedCache={source:this.value,normalized:e},e}emitNormalization(){if(!this.value)return!1;const e=this.normalizedValue;return e!==this.value&&(this.change.emit(e),!0)}get ruleRegistry(){return this.platform.get(o.RuleRegistry)}get translator(){return this.platform.get(o.Translate)}get contextRegistry(){return this.platform.get(o.ContextRegistry)}get effectiveContext(){var e,t;return(null===(e=this.context)||void 0===e?void 0:e.limetype)?this.context:(null===(t=this.resolvedContext)||void 0===t?void 0:t.limetype)?this.resolvedContext:T}get host(){return this}static get watchers(){return{value:[{onValueChange:0}],availableContexts:[{onAvailableContextsChange:0}]}}static get style(){return":host{display:block}.rule-editor--disabled{opacity:0.6;pointer-events:none}.rule-editor__label{font-size:0.75rem;font-weight:600;color:rgb(var(--contrast-1500));margin-bottom:0.25rem}.rule-editor__helper-text{font-size:0.75rem;color:rgb(var(--contrast-1300));margin-top:0.25rem}.rule-node{border:1px solid rgb(var(--contrast-500));border-radius:0.5rem;margin:0.25rem 0;overflow:hidden;background-color:rgb(var(--contrast-100))}.rule-node--invalid{border-color:rgb(var(--color-red-default))}.rule-node--all>.rule-node__header,.rule-node--any>.rule-node__header{background-color:rgb(var(--contrast-300));padding:0.375rem 0.75rem;border-bottom:1px solid rgb(var(--contrast-500))}.rule-node__header{display:flex;align-items:center;gap:0.5rem}.rule-node__header-actions{margin-left:auto;display:grid;grid-auto-flow:column;grid-gap:0.5rem;padding:0.125rem;align-items:center}.rule-node__combinator-select{min-width:6rem}.rule-node__body{padding:0.75rem;display:flex;flex-direction:column;gap:0.75rem}limel-popover.rule-node__chips-popover{display:contents;--popover-surface-width:min(calc(100vw - 4rem), 50rem)}.rule-node__chips{display:block;width:100%}.rule-node__chips limel-picker{display:block;width:100%}.rule-node__children{display:flex;flex-direction:column;gap:0.5rem}.rule-node__footer{display:flex;justify-content:center}.rule-node__issue{color:rgb(var(--color-red-default));font-size:0.875rem}"}},[1,"limebb-rule-editor",{platform:[16],context:[16],value:[16],availableContexts:[16],required:[516],readonly:[516],disabled:[516],label:[513],helperText:[1,"helper-text"],resolvedContext:[32],issues:[32],openChipPath:[32],availablePrimitiveOptions:[32]},void 0,{value:[{onValueChange:0}],availableContexts:[{onAvailableContextsChange:0}]}]);!function(e,t,n,r){var i,l=arguments.length,o=l<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(l<3?i(o):l>3?i(t,n,o):i(t,n))||o);l>3&&o&&Object.defineProperty(t,n,o)}([l("context")],L.prototype,"resolvedContext",void 0);const T=Object.freeze({limetype:null,id:null}),q=L,F=function(){"undefined"!=typeof customElements&&["limebb-rule-editor","limebb-rule-chip-popover"].forEach((e=>{switch(e){case"limebb-rule-editor":customElements.get(i(e))||customElements.define(i(e),L);break;case"limebb-rule-chip-popover":customElements.get(i(e))||s()}}))};export{q as LimebbRuleEditor,F as defineCustomElement}
1
+ import{h as e,proxyCustomElement as t,HTMLElement as n,createEvent as r,transformTag as i}from"@stencil/core/internal/client";import{M as l,n as o}from"./index.esm.js";import{d as s}from"./rule-chip-popover.js";function u(e,t){return t?{type:"not",rule:e}:e}function a(e,t){return e.length===t.length&&e.every(((e,n)=>e===t[n]))}function c(e,t){return e.filter((e=>a(e.path,t)))}function d(e,t){let n=e;for(const e of t){if(void 0===n)return;n=f(n,e)}return n}function h(e,t,n){if(0===t.length)return n;const[r,...i]=t;if("not"===e.type&&"rule"===r)return Object.assign(Object.assign({},e),{rule:h(e.rule,i,n)});if(("all"===e.type||"any"===e.type)&&"rules"===r){if(0===i.length)return n;const[t,...r]=i;if("number"!=typeof t)return e;const l=[...e.rules];return l[t]=h(l[t],r,n),Object.assign(Object.assign({},e),{rules:l})}return e}function f(e,t){return"not"===e.type&&"rule"===t?e.rule:"all"!==e.type&&"any"!==e.type||"rules"!==t?"all"!==e.type&&"any"!==e.type||"number"!=typeof t?e:e.rules[t]:e}const p={name:"question",color:"rgb(var(--color-glaucous-light))"};function b(e,t){return{"rule-node":!0,["rule-node--"+e]:!0,"rule-node--invalid":t.length>0}}function v(e,t){return[...e.values()].map((e=>({value:e.id,text:e.title?t.get(e.title):e.id,secondaryText:e.description?t.get(e.description):"",icon:e.icon}))).sort(((e,t)=>e.text.localeCompare(t.text)))}function m(e,t){return e.reads.every((e=>t.has(e)))}function g(e){return"__chip__:"+e}function y(e,t){return[...e,"rules",t]}function _(e){return"ref"===e.type?{ref:e,isNegated:!1}:"not"===e.type&&"ref"===e.rule.type?{ref:e.rule,isNegated:!0}:null}const x=({groupNode:t,groupPath:n,chipChildren:r,ctx:i})=>{const l=new Map,o=r.map((e=>{const t=g(e.index);l.set(t,e);const n=function(e,t){var n;return null!==(n=e.find((e=>e.value===t)))&&void 0!==n?n:{value:t,text:t,icon:p}}(i.allPrimitiveOptions,e.ref.id);return Object.assign(Object.assign({},n),{text:e.isNegated?"¬ "+n.text:n.text,value:t})})),s=function(e){return t=>Promise.resolve(function(e,t){if(!t)return e;const n=t.toLocaleLowerCase().split(/\s+/);return e.filter((e=>n.every((t=>{var n,r;return e.text.toLocaleLowerCase().includes(t)||(null===(n=e.secondaryText)||void 0===n?void 0:n.toLocaleLowerCase().includes(t))||(null===(r=e.value)||void 0===r?void 0:r.toLocaleLowerCase().includes(t))}))))}(e,t))}(i.availablePrimitiveOptions),u=function(e,t,n){var r;const i=N(t,n);return null===i?null:null!==(r=e.find((e=>e.index===i)))&&void 0!==r?r:null}(r,n,i.openChipPath),a="all"===t.type?"&":"|";return e("limel-popover",{class:"rule-node__chips-popover",open:null!==u,openDirection:"bottom-start",onClose:i.onPopoverClose},e("div",{slot:"trigger",class:"rule-node__chips"},e("limel-picker",{multiple:!0,label:i.translator.get("webclient.rule-editor.rules-label"),value:o,searcher:s,delimiter:a,readonly:i.readonly,disabled:i.disabled,onChange:C(t,n,l,i),onInteract:O(n,l,i)})),e("div",null,function(t,n,r){if(!t)return null;const i=y(n,t.index);return e("limebb-rule-chip-popover",{platform:r.platform,context:r.context,refNode:t.ref,isNegated:t.isNegated,metadata:r.metadataById.get(t.ref.id),readonly:r.readonly,disabled:r.disabled,isMutable:r.isMutable,focusOnOpen:r.focusOnOpen,onNegate:j(t,i,r),onUpdateArgs:w(t,i,r),onDeleteChip:k(i,r)})}(u,n,i)))},C=(e,t,n,r)=>i=>{i.stopPropagation();const l=Array.isArray(i.detail)?i.detail:[],o=N(t,r.openChipPath);if(null!==o){const e=g(o);l.every((t=>t.value!==e))&&r.onPopoverClose()}const s=l.flatMap((e=>{if("string"!=typeof e.value)return[];const t=n.get(e.value);return t?[t.isNegated?{type:"not",rule:t.ref}:t.ref]:[{type:"ref",id:e.value}]})),u=e.rules.filter((e=>null===_(e)));r.onReplaceNode(t,Object.assign(Object.assign({},e),{rules:[...s,...u]}))},O=(e,t,n)=>r=>{r.stopPropagation();const i=function(e){if("string"==typeof e)return e;if(e&&"object"==typeof e&&"value"in e){const t=e.value;return"string"==typeof t?t:void 0}}(r.detail),l=i?t.get(i):void 0;l&&n.onChipInteract([...e,"rules",l.index])},j=(e,t,n)=>r=>{r.stopPropagation(),n.onReplaceNode(t,r.detail?{type:"not",rule:e.ref}:e.ref)},w=(e,t,n)=>r=>{r.stopPropagation();const i=e.isNegated?[...t,"rule"]:t;n.onUpdateArgs(i,r.detail)},k=(e,t)=>()=>{t.onDelete(e)};function N(e,t){if(!t||t.length<2)return null;if(!a(function(e){return e.slice(0,-2)}(t),e))return null;const n=t.at(-1);return"number"==typeof n?n:null}const P=({node:t,path:n,isNegated:r,ctx:i})=>{const l=r?[...n,"rule"]:n,o=r?[...c(i.issues,n),...c(i.issues,l)]:c(i.issues,n),s=[],u=[];for(const[e,n]of t.rules.entries()){const t=_(n);t?s.push(Object.assign(Object.assign({},t),{index:e})):u.push({child:n,index:e})}const a=function(e){return[{value:"all",text:e.translator.get("webclient.rule-editor.combinator.all")},{value:"any",text:e.translator.get("webclient.rule-editor.combinator.any")}]}(i),d=a.find((e=>e.value===t.type));return e("div",{class:b(t.type,o),key:M(n)},e("div",{class:"rule-node__header"},e("limel-select",{class:"rule-node__combinator-select",value:d,options:a,disabled:!i.isMutable,onChange:A(t,n,r,i)}),function(t,n,r,i){return i.isMutable?e("div",{class:"rule-node__header-actions"},e("limel-switch",{class:"rule-node__negate-switch",label:i.translator.get("webclient.rule-editor.negate"),value:r,onChange:V(t,n,i)}),e("limel-icon-button",{icon:"trash",label:i.translator.get("webclient.rule-editor.delete"),onClick:()=>i.onDelete(n)})):null}(t,n,r,i)),e("div",{class:"rule-node__body"},e(S,{issues:o}),e(x,{groupNode:t,groupPath:l,chipChildren:s,ctx:i}),function(t,n,r){return 0===t.length?null:e("div",{class:"rule-node__children"},t.map((t=>e(D,{node:t.child,path:[...n,"rules",t.index],ctx:r}))))}(u,l,i),function(t,n,r,i){return i.isMutable?e("div",{class:"rule-node__footer"},e("limel-button",{icon:"add",label:i.translator.get("webclient.rule-editor.add-nested-group"),onClick:z(t,n,r,i)})):null}(t,n,r,i)))};function M(e){return 0===e.length?"root":e.join("/")}function R(e,t,n,r){r.onReplaceNode(t,u(e,n))}const A=(e,t,n,r)=>i=>{i.stopPropagation();const l=i.detail.value;l!==e.type&&R(Object.assign(Object.assign({},e),{type:l}),t,n,r)},z=(e,t,n,r)=>()=>{R(function(e){return Object.assign(Object.assign({},e),{rules:[...e.rules,{type:"all",rules:[]}]})}(e),t,n,r)},V=(e,t,n)=>r=>{r.stopPropagation(),n.onReplaceNode(t,u(e,r.detail))},D=t=>{const{node:n,path:r,ctx:i}=t,l=I(n);return l?e(P,{node:l.node,path:r,isNegated:l.isNegated,ctx:i}):null},E=e=>"not"===e.type&&("all"===e.rule.type||"any"===e.rule.type);function I(e){if("all"===e.type||"any"===e.type)return{node:e,isNegated:!1};if(E(e))return{node:e.rule,isNegated:!0};if("not"===e.type){const t=I(e.rule);if(t)return{node:t.node,isNegated:!t.isNegated}}return null}const S=({issues:t})=>0===t.length?null:t.map((t=>e("div",{class:"rule-node__issue"},t.message)));const L=t(class extends n{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.change=r(this,"change",7),this.issues=[],this.openChipPath=null,this.focusOnOpen=!1,this.metadataById=new Map,this.allPrimitiveOptions=[],this.availablePrimitiveOptions=[],this.reachableSlots=new Set,this.normalizedCache=null,this.hasLoaded=!1,this.handleDelete=e=>{this.openChipPath=null,this.focusOnOpen=!1,this.emitIfChanged(function(e,t){if(0===t.length)return{type:"all",rules:[]};const n=t.slice(0,-1),r=t.at(-1),i=d(e,n);if(void 0===i)return e;if(("all"===i.type||"any"===i.type)&&"number"==typeof r){const t=[...i.rules];return t.splice(r,1),h(e,n,Object.assign(Object.assign({},i),{rules:t}))}return"not"===i.type&&"rule"===r?h(e,n,{type:"all",rules:[]}):e}(this.normalizedValue,e))},this.handleUpdateArgs=(e,t)=>{this.emitIfChanged(function(e,t,n){const r=d(e,t);return void 0===r||"ref"!==r.type?e:h(e,t,Object.assign(Object.assign({},r),{args:n}))}(this.normalizedValue,e,t))},this.handleReplaceNode=(e,t)=>{const n=this.autoOpenPathFor(e,t);this.focusOnOpen=null!==n,null!==n&&(this.openChipPath=n),this.emitIfChanged(function(e,t,n){return h(e,t,n)}(this.normalizedValue,e,t))},this.handleChipInteract=e=>{this.openChipPath=e,this.focusOnOpen=!1},this.handlePopoverClose=()=>{this.openChipPath=null,this.focusOnOpen=!1}}componentWillLoad(){this.rebuildFromRegistries()}rebuildFromRegistries(){this.computeReachableSlots(),this.indexMetadata(),this.rebuildAvailableOptions(),this.runValidation()}connectedCallback(){this.hasLoaded&&(this.computeReachableSlots(),this.rebuildAvailableOptions(),this.runValidation())}componentDidLoad(){this.hasLoaded=!0,this.emitNormalization()}onValueChange(){this.emitNormalization()||this.runValidation()}onAvailableContextsChange(){this.rebuildFromRegistries()}render(){return e("div",{key:"abe9c739c5fbd0749a593187fd36953482530aeb",class:{"rule-editor":!0,"rule-editor--disabled":this.disabled}},this.renderLabel(),e(D,{key:"ba99e8de897dec3825fb74f78d42b3f503ead775",node:this.normalizedValue,path:[],ctx:this.createRenderContext()}),this.renderHelperText())}renderLabel(){return this.label?e("div",{class:"rule-editor__label"},this.label):null}renderHelperText(){return this.helperText?e("div",{class:"rule-editor__helper-text"},this.helperText):null}createRenderContext(){return{issues:this.issues,metadataById:this.metadataById,allPrimitiveOptions:this.allPrimitiveOptions,availablePrimitiveOptions:this.availablePrimitiveOptions,isMutable:!this.readonly&&!this.disabled,readonly:this.readonly,disabled:this.disabled,platform:this.platform,context:this.effectiveContext,translator:this.translator,openChipPath:this.openChipPath,focusOnOpen:this.focusOnOpen,onDelete:this.handleDelete,onUpdateArgs:this.handleUpdateArgs,onReplaceNode:this.handleReplaceNode,onChipInteract:this.handleChipInteract,onPopoverClose:this.handlePopoverClose}}autoOpenPathFor(e,t){var n;if("all"!==t.type&&"any"!==t.type)return null;const r=d(this.normalizedValue,e);if(void 0===r||"all"!==r.type&&"any"!==r.type)return null;const i=new Set(r.rules.map((e=>{var t;return null===(t=_(e))||void 0===t?void 0:t.ref})).filter((e=>void 0!==e))),l=t.rules.map(((e,t)=>{var n;const r=null===(n=_(e))||void 0===n?void 0:n.ref;return r&&!i.has(r)?{ref:r,index:t}:null})).filter((e=>null!==e));if(1!==l.length)return null;const[{ref:o,index:s}]=l;return(null===(n=this.metadataById.get(o.id))||void 0===n?void 0:n.configComponent)?y(e,s):null}indexMetadata(){var e,t,n;const r=null!==(n=null===(t=(e=this.ruleRegistry).listMetadata)||void 0===t?void 0:t.call(e))&&void 0!==n?n:[];this.metadataById=new Map(r.map((e=>[e.id,e]))),this.allPrimitiveOptions=v(this.metadataById,this.translator)}rebuildAvailableOptions(){this.availablePrimitiveOptions=v(this.availablePrimitiveMetadata(),this.translator)}availablePrimitiveMetadata(){const e=new Map;for(const[t,n]of this.metadataById)m(n,this.reachableSlots)&&e.set(t,n);return e}computeReachableSlots(){var e;const t=this.contextRegistry,n=t.list().map((e=>e.id)).filter((e=>void 0!==t.get(e,this.host)));this.reachableSlots=new Set([...n,...null!==(e=this.availableContexts)&&void 0!==e?e:[]])}runValidation(){if(!this.value)return void(this.issues=[]);const e=this.ruleRegistry.validate(this.normalizedValue,[...this.reachableSlots]);this.issues=e.ok?[]:e.issues}emitIfChanged(e){e!==this.normalizedValue&&this.change.emit(function(e){return"all"!==e.type&&"any"!==e.type?e:0===e.rules.length?void 0:e}(e))}get normalizedValue(){if(null!==this.normalizedCache&&this.normalizedCache.source===this.value)return this.normalizedCache.normalized;const e=function(e){return e?I(e)?e:{type:"all",rules:[e]}:{type:"all",rules:[]}}(this.value);return this.normalizedCache={source:this.value,normalized:e},e}emitNormalization(){if(!this.value)return!1;const e=this.normalizedValue;return e!==this.value&&(this.change.emit(e),!0)}get ruleRegistry(){return this.platform.get(o.RuleRegistry)}get translator(){return this.platform.get(o.Translate)}get contextRegistry(){return this.platform.get(o.ContextRegistry)}get effectiveContext(){var e,t;return(null===(e=this.context)||void 0===e?void 0:e.limetype)?this.context:(null===(t=this.resolvedContext)||void 0===t?void 0:t.limetype)?this.resolvedContext:T}get host(){return this}static get watchers(){return{value:[{onValueChange:0}],availableContexts:[{onAvailableContextsChange:0}]}}static get style(){return":host{display:block}.rule-editor--disabled{opacity:0.6;pointer-events:none}.rule-editor__label{font-size:0.75rem;font-weight:600;color:rgb(var(--contrast-1500));margin-bottom:0.25rem}.rule-editor__helper-text{font-size:0.75rem;color:rgb(var(--contrast-1300));margin-top:0.25rem}.rule-node{border:1px solid rgb(var(--contrast-500));border-radius:0.5rem;margin:0.25rem 0;overflow:hidden;background-color:rgb(var(--contrast-100))}.rule-node--invalid{border-color:rgb(var(--color-red-default))}.rule-node--all>.rule-node__header,.rule-node--any>.rule-node__header{background-color:rgb(var(--contrast-300));padding:0.375rem 0.75rem;border-bottom:1px solid rgb(var(--contrast-500))}.rule-node__header{display:flex;align-items:center;gap:0.5rem}.rule-node__header-actions{margin-left:auto;display:grid;grid-auto-flow:column;grid-gap:0.5rem;padding:0.125rem;align-items:center}.rule-node__combinator-select{min-width:6rem}.rule-node__body{padding:0.75rem;display:flex;flex-direction:column;gap:0.75rem}limel-popover.rule-node__chips-popover{display:contents;--popover-surface-width:min(calc(100vw - 4rem), 50rem)}.rule-node__chips{display:block;width:100%}.rule-node__chips limel-picker{display:block;width:100%}.rule-node__children{display:flex;flex-direction:column;gap:0.5rem}.rule-node__footer{display:flex;justify-content:center}.rule-node__issue{color:rgb(var(--color-red-default));font-size:0.875rem}"}},[1,"limebb-rule-editor",{platform:[16],context:[16],value:[16],availableContexts:[16],required:[516],readonly:[516],disabled:[516],label:[513],helperText:[1,"helper-text"],resolvedContext:[32],issues:[32],openChipPath:[32],availablePrimitiveOptions:[32]},void 0,{value:[{onValueChange:0}],availableContexts:[{onAvailableContextsChange:0}]}]);!function(e,t,n,r){var i,l=arguments.length,o=l<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(l<3?i(o):l>3?i(t,n,o):i(t,n))||o);l>3&&o&&Object.defineProperty(t,n,o)}([l("context")],L.prototype,"resolvedContext",void 0);const T=Object.freeze({limetype:null,id:null}),q=L,F=function(){"undefined"!=typeof customElements&&["limebb-rule-editor","limebb-rule-chip-popover"].forEach((e=>{switch(e){case"limebb-rule-editor":customElements.get(i(e))||customElements.define(i(e),L);break;case"limebb-rule-chip-popover":customElements.get(i(e))||s()}}))};export{q as LimebbRuleEditor,F as defineCustomElement}
@@ -1 +1 @@
1
- import{proxyCustomElement as e,HTMLElement as t,h as s,Host as i,transformTag as o}from"@stencil/core/internal/client";import{b as n}from"./index.esm.js";const l=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.shouldRender=!1}componentWillLoad(){this.evaluate()}disconnectedCallback(){var e;null===(e=this.stopSubscription)||void 0===e||e.call(this)}onRuleChange(){this.evaluate()}onScopeChange(){this.evaluate()}render(){return s(i,{key:"ce41c51b7f8b049d7d89374ef0c452b2e961aa23",hidden:!this.shouldRender},s("slot",{key:"ad04db83bceca78bf7bb2eb7b7b2dae018025319"}))}get ruleRegistry(){return this.platform.get(n.RuleRegistry)}evaluate(){var e;if(null===(e=this.stopSubscription)||void 0===e||e.call(this),this.stopSubscription=void 0,this.rule)try{const e=this.ruleRegistry.compile(this.rule);if(this.scope)return void(this.shouldRender=e.evaluate(this.scope));this.stopSubscription=this.ruleRegistry.subscribe(e,{host:this.host},(e=>{this.shouldRender=e}))}catch(e){console.warn("rule-gate failed to compile rule; hiding slot",{rule:this.rule,error:e}),this.shouldRender=!1}else this.shouldRender=!0}get host(){return this}static get watchers(){return{rule:[{onRuleChange:0}],scope:[{onScopeChange:0}]}}static get style(){return":host{display:block}:host([hidden]){display:none}"}},[257,"limebb-rule-gate",{platform:[16],rule:[16],scope:[16],shouldRender:[32]},void 0,{rule:[{onRuleChange:0}],scope:[{onScopeChange:0}]}]),r=l,h=function(){"undefined"!=typeof customElements&&["limebb-rule-gate"].forEach((e=>{"limebb-rule-gate"===e&&(customElements.get(o(e))||customElements.define(o(e),l))}))};export{r as LimebbRuleGate,h as defineCustomElement}
1
+ import{proxyCustomElement as e,HTMLElement as t,h as s,Host as i,transformTag as o}from"@stencil/core/internal/client";import{n}from"./index.esm.js";const l=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.shouldRender=!1}componentWillLoad(){this.evaluate()}disconnectedCallback(){var e;null===(e=this.stopSubscription)||void 0===e||e.call(this)}onRuleChange(){this.evaluate()}onScopeChange(){this.evaluate()}render(){return s(i,{key:"ce41c51b7f8b049d7d89374ef0c452b2e961aa23",hidden:!this.shouldRender},s("slot",{key:"ad04db83bceca78bf7bb2eb7b7b2dae018025319"}))}get ruleRegistry(){return this.platform.get(n.RuleRegistry)}evaluate(){var e;if(null===(e=this.stopSubscription)||void 0===e||e.call(this),this.stopSubscription=void 0,this.rule)try{const e=this.ruleRegistry.compile(this.rule);if(this.scope)return void(this.shouldRender=e.evaluate(this.scope));this.stopSubscription=this.ruleRegistry.subscribe(e,{host:this.host},(e=>{this.shouldRender=e}))}catch(e){console.warn("rule-gate failed to compile rule; hiding slot",{rule:this.rule,error:e}),this.shouldRender=!1}else this.shouldRender=!0}get host(){return this}static get watchers(){return{rule:[{onRuleChange:0}],scope:[{onScopeChange:0}]}}static get style(){return":host{display:block}:host([hidden]){display:none}"}},[257,"limebb-rule-gate",{platform:[16],rule:[16],scope:[16],shouldRender:[32]},void 0,{rule:[{onRuleChange:0}],scope:[{onScopeChange:0}]}]),r=l,h=function(){"undefined"!=typeof customElements&&["limebb-rule-gate"].forEach((e=>{"limebb-rule-gate"===e&&(customElements.get(o(e))||customElements.define(o(e),l))}))};export{r as LimebbRuleGate,h as defineCustomElement}
@@ -1 +1 @@
1
- import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as s,transformTag as r}from"@stencil/core/internal/client";import{b as n,r as o,c as a,L as h}from"./index.esm.js";import{A as c,E as u,b as l,a as d,T as f}from"./keycodes.js";import{o as m,U as b,c as v,a as p,d as g,n as y,i as j,S as w,g as x}from"./_Uint8Array.js";import{d as O}from"./_defineProperty.js";import{c as k,e as S,S as I,i as E,a as C,r as T}from"./_MapCache.js";import{c as A}from"./random-string.js";import{h as P,b as M,c as F}from"./limetype.js";import{i as N}from"./non-null.js";import{d as _}from"./empty-state.js";import{d as L}from"./text-editor-picker.js";import{i as R}from"./isSymbol.js";var z=/\s/,D=/^\s+/;var U=/^[-+]0x[0-9a-f]+$/i,$=/^0b[01]+$/i,Q=/^0o[0-7]+$/i,G=parseInt;function q(t){if("number"==typeof t)return t;if(R(t))return NaN;if(k(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=k(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=function(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&z.test(t.charAt(e)););return e}(t)+1).replace(D,""):t}(t);var i=$.test(t);return i||Q.test(t)?G(t.slice(2),i?2:8):U.test(t)?NaN:+t}var W=Object.create,B=function(){function t(){}return function(e){if(!k(e))return{};if(W)return W(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}(),H=Object.prototype.hasOwnProperty;var K=m(Object.getPrototypeOf,Object);"object"==typeof exports&&exports&&!exports.nodeType&&exports&&"object"==typeof module&&module&&!module.nodeType&&module;var V=Object.prototype.hasOwnProperty;function J(t){var e=new t.constructor(t.byteLength);return new b(e).set(new b(t)),e}var X=/\w*$/,Y=I?I.prototype:void 0,Z=Y?Y.valueOf:void 0;var tt=y&&y.isMap,et=tt?g(tt):function(t){return E(t)&&"[object Map]"==p(t)},it=y&&y.isSet,st=it?g(it):function(t){return E(t)&&"[object Set]"==p(t)},rt="[object Arguments]",nt="[object Function]",ot="[object Object]",at={};function ht(t,e,i,s,r,n){var o;if(void 0!==o)return o;if(!k(t))return t;var a=C(t);if(a)o=function(t){var e=t.length,i=new t.constructor(e);return e&&"string"==typeof t[0]&&V.call(t,"index")&&(i.index=t.index,i.input=t.input),i}(t);else{var h=p(t),c=h==nt||"[object GeneratorFunction]"==h;if(j(t))return function(t){return t.slice()}(t);if(h==ot||h==rt||c&&!r)o=c?{}:function(t){return"function"!=typeof t.constructor||v(t)?{}:B(K(t))}(t);else{if(!at[h])return r?t:{};o=function(t,e){var i=t.constructor;switch(e){case"[object ArrayBuffer]":return J(t);case"[object Boolean]":case"[object Date]":return new i(+t);case"[object DataView]":return function(t){var e=J(t.buffer);return new t.constructor(e,t.byteOffset,t.byteLength)}(t);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t){var e=J(t.buffer);return new t.constructor(e,t.byteOffset,t.length)}(t);case"[object Map]":case"[object Set]":return new i;case"[object Number]":case"[object String]":return new i(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,X.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return function(t){return Z?Object(Z.call(t)):{}}(t)}}(t,h)}}n||(n=new w);var u=n.get(t);if(u)return u;n.set(t,o),st(t)?t.forEach((function(s){o.add(ht(s,e,i,0,t,n))})):et(t)&&t.forEach((function(s,r){o.set(r,ht(s,e,i,0,t,n))}));var l=a?void 0:x(t);return function(t,e){for(var i=-1,s=null==t?0:t.length;++i<s&&!1!==e(t[i],i););}(l||t,(function(s,r){l&&(s=t[r=s]),function(t,e,i){var s=t[e];H.call(t,e)&&S(s,i)&&(void 0!==i||e in t)||function(t,e,i){"__proto__"==e&&O?O(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i}(t,e,i)}(o,r,ht(s,e,i,0,t,n))})),o}at[rt]=at["[object Array]"]=at["[object ArrayBuffer]"]=at["[object DataView]"]=at["[object Boolean]"]=at["[object Date]"]=at["[object Float32Array]"]=at["[object Float64Array]"]=at["[object Int8Array]"]=at["[object Int16Array]"]=at["[object Int32Array]"]=at["[object Map]"]=at["[object Number]"]=at[ot]=at["[object RegExp]"]=at["[object Set]"]=at["[object String]"]=at["[object Symbol]"]=at["[object Uint8Array]"]=at["[object Uint8ClampedArray]"]=at["[object Uint16Array]"]=at["[object Uint32Array]"]=!0,at["[object Error]"]=at[nt]=at["[object WeakMap]"]=!1;var ct=function(){return T.Date.now()},ut=Math.max,lt=Math.min;function dt(t,e){return t.map(((t,i)=>{const s=function(t){return ht(t,5)}(t);return Object.assign(Object.assign({},s),{selected:i===e})}))}class ft{get limeObjectService(){return this.platform.get(n.LimeObjectRepository)}get queryService(){return this.platform.get(n.Query)}get viewFactoryRegistry(){return this.platform.get(n.ViewFactoryRegistry)}get contextRegistry(){return this.platform.get(n.ContextRegistry)}get translator(){var t;return null===(t=this.platform)||void 0===t?void 0:t.get(n.Translate)}get triggerCharacter(){return this._triggerCharacter}get triggerHandler(){return this._triggerHandler}constructor(t,e,i,s){this.platform=t,this.context=e,this.searchableLimetypes=i,this.host=s,this.groupCounts={},this._triggerCharacter="@",this._triggerHandler={searcher:t=>this.searcher(t),inserter:(t,e)=>this.inserter(t,e),emptySearchMessage:"Start typing a name...",noItemsFoundMessage:"No results for your search...",nodeDefinition:{customElement:{tagName:"limebb-mention",attributes:["limetype","objectid","href"]},mapAttributes:t=>({limetype:t.value.getLimetype().name,objectid:t.value.id,href:`object/${this.context.limetype}/${this.context.id}`})}},this.searcher=async t=>{if(!t)return[];const{objects:e}=await this.limeObjectService.search(t,this.searchableLimetypes,10);return this.createSearchListItems(e)},this.inserter=async(t,e)=>{var i;const s=this.triggerHandler.nodeDefinition;s&&t.insert({node:{tagName:s.customElement.tagName,attributes:s.mapAttributes(e)},children:[null===(i=e.value)||void 0===i?void 0:i.descriptive]})}}async initialize(){await this.loadGroupCounts()}async loadGroupCounts(){const t=this.searchableLimetypes.filter((t=>!M(t,"user")&&P(t,"user"))).map((t=>this.getGroupCounts(t)));for(const e of await Promise.all(t))Object.assign(this.groupCounts,e)}async getGroupCounts(t){var e;const i=F(t,"user"),s=t.name;try{const t=await this.queryService.execute({limetype:s,responseFormat:{object:{_id:null,[i.name]:{count:{aggregate:{op:o.Count}}}}}});if(!(null===(e=t.objects)||void 0===e?void 0:e.length))return{[s]:{}};const r=this.createGroupCount(t.objects,i.name);return{[s]:r}}catch(e){return console.error("Error fetching group count for limetype: "+t.name,e),{[s]:{}}}}createGroupCount(t,e){const i={};for(const s of t){const{_id:t,[e]:r}=s;i[t]=r.count}return i}createSearchListItems(t=[]){return t.map((t=>this.createSearchListItem(t))).filter(N)}createSearchListItem(t){const e=this.viewFactoryRegistry.getFactory("search"),i=this.limeObjectService.getObject(t._limetype,t._id);if(!i)return null;const s=e(i,this.contextRegistry.scope({host:this.host})),r=this.getGroupCountComponent(i);return Object.assign(Object.assign({},s),r?{primaryComponent:r}:{})}getGroupCountComponent(t){var e;const i=t.getLimetype(),s=null===(e=this.groupCounts[i.name])||void 0===e?void 0:e[t.id],r=F(i,"user");if(void 0!==s&&r)return{name:"limebb-mention-group-counter",props:{count:s,limetype:r.relation.getLimetype(),helperLabel:this.translator.get("webclient.notification-center.members-will-be-notified")}}}}class mt{constructor(t,e){this.file=t,this.http=e,this.uploadCancelled=!1,this.getUrl=t=>"api/v1/file/"+(null!=t?t:"")}async initialize(){this.uploadService=await this.http.createFileUpload(a.Post,this.getUrl(),this.file),this.progressCallback&&(this.uploadService.onProgress=this.progressCallback)}async upload(){return this.uploadService.upload()}getFileName(){return this.file.name}cancel(){this.uploadService.cancel(),this.uploadCancelled=!0}set onProgress(t){this.progressCallback=t,this.uploadService&&(this.uploadService.onProgress=t)}}class bt{constructor(t){this.platform=t}async handleImagePasted(t){const e=null==t?void 0:t.fileInfo;if(!e)return;if(!this.validateImageSize(e))return;t.insertThumbnail();const i=await this.createFileUpload(e),s=null==i?void 0:i.href;return s&&void 0!==(null==i?void 0:i.fileId)?t.insertImage(s):t.insertFailedThumbnail(),i}parseFileIdFromSrc(t){if(t){const e=/\/(\d+)\/contents\/?$/.exec(t);if(e&&e[1])return Number(e[1])}}validateImageSize(t){return!!t.fileContent&&t.fileContent.size<=52428800}async createFileUpload(t){var e;if(!t.fileContent)return;const i=new mt(t.fileContent,this.http);await i.initialize();const s=Object.assign(Object.assign({},t),{progress:0,file:i,state:"added",fileId:void 0,href:void 0,id:t.id});i.onProgress=t=>{0===s.progress&&(s.state="uploading"),s.progress=t,100===t&&(s.state="finalizing")};const r=await i.upload();return s.fileId=r.id,s.filename=r.filename,s.extension=r.extension,s.contentType=r.contentType,s.size=r.size,s.state="done",s.href=null===(e=r._links)||void 0===e?void 0:e.contents.href,s}get http(){return this.platform.get(n.Http)}}const vt=t(class extends e{watchOpen(){this.setupHandlers(),this.setPickerMessage()}watchQuery(){this.setPickerMessage()}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.change=i(this,"change",7),this.metadataChange=i(this,"metadataChange",7),this.allowMentioning=!1,this.contentType="markdown",this.language="en",this.disabled=!1,this.readonly=!1,this.invalid=!1,this.required=!1,this.ui="standard",this.allowResize=!0,this.value="",this.triggerMap={},this.customElements=[],this.allowInlineImages=!1,this.items=[],this.highlightedItemIndex=0,this.isPickerOpen=!1,this.isSearching=!1,this.registeredTriggers=[],this.registeredTriggerMap=this.triggerMap,this.registeredCustomElements=this.customElements,this.activeTrigger=void 0,this.handleMouseClick=t=>{this.textEditorPickerElement&&(t.target===this.textEditorPickerElement||this.resetTriggerAndPicker())},this.handleKeyPress=t=>{if(!this.isPickerOpen||!this.activeTrigger)return;if(![u,l,c,d,f].includes(t.key))return;if(t.stopPropagation(),t.preventDefault(),"keyup"===t.type)return;const e={[u]:this.handleEscapeKey,[d]:this.handleEnterOrTabKey,[f]:this.handleEnterOrTabKey,[c]:this.handleArrowKeyPress,[l]:this.handleArrowKeyPress}[t.key];e&&e(t)},this.handleArrowKeyPress=t=>{this.highlightedItemIndex=this.findNonSeparatorIndex(t.key,this.highlightedItemIndex)},this.findNonSeparatorIndex=(t,e,i=0)=>{if(0===this.items.length||i>this.items.length)return e;const s=((t,e,i)=>(e+(t===c?1:-1)+i)%i)(t,e,this.items.length);return this.isListSeparator(this.items[s])?this.findNonSeparatorIndex(t,s,i+1):s},this.handleEscapeKey=()=>{var t;null===(t=this.triggerFunction)||void 0===t||t.stopTrigger(),this.resetTriggerAndPicker()},this.handleEnterOrTabKey=t=>{this.handleItemSelection(t)},this.handleMetadataChange=t=>{t.stopPropagation();const e=t.detail,i=this.getEnhancedImages(e.images||[]),s=Object.assign(Object.assign({},e),{images:i});this.metadataChange.emit(s)},this.handleImagePasted=t=>{t.stopPropagation(),this.allowInlineImages&&this.uploadHandler.handleImagePasted(t.detail)},this.handleTriggerStart=t=>{t.stopPropagation(),this.activeTrigger=t.detail.trigger,this.triggerFunction=t.detail.textEditor,this.isPickerOpen=!0},this.handleTriggerStop=t=>{t.stopPropagation(),this.resetTriggerAndPicker()},this.handleTriggerChange=t=>{var e;t.stopImmediatePropagation(),this.editorPickerQuery=t.detail.value;const i=null===(e=this.registeredTriggerMap[t.detail.trigger])||void 0===e?void 0:e.searcher;i&&(this.isSearching=!0,this.debouncedSearchFn(i,this.editorPickerQuery))},this.resetTriggerAndPicker=()=>{this.isPickerOpen=!1,this.activeTrigger=void 0,this.triggerFunction=void 0,this.isSearching=!1,this.highlightedItemIndex=0,this.items=[]},this.handleItemSelection=t=>{var e;let i;if(t instanceof CustomEvent)i=t.detail;else{if(!(t instanceof KeyboardEvent))return;{const t=this.items[this.highlightedItemIndex];if(this.isListSeparator(t))return;i=t}}if(!this.activeTrigger||(null==i?void 0:i.disabled))return;const s=this.registeredTriggerMap[this.activeTrigger];try{s.inserter(this.triggerFunction,i)}catch(t){console.error("Error inserting",t)}this.resetTriggerAndPicker(),null===(e=this.textEditor)||void 0===e||e.focus()},this.handleVisibilityChange=()=>{"hidden"===document.visibilityState&&this.saveDraft()},this.handleBeforeUnload=()=>{this.saveDraft()},this.portalId=A(),this.debouncedSearchFn=function(t,e,i){var s,r,n,o,a,h,c=0,u=!1,l=!1,d=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function f(e){var i=s,n=r;return s=r=void 0,c=e,o=t.apply(n,i)}function m(t){var i=t-h;return void 0===h||i>=e||i<0||l&&t-c>=n}function b(){var t=ct();if(m(t))return v(t);a=setTimeout(b,function(t){var i=e-(t-h);return l?lt(i,n-(t-c)):i}(t))}function v(t){return a=void 0,d&&s?f(t):(s=r=void 0,o)}function p(){var t=ct(),i=m(t);if(s=arguments,r=this,h=t,i){if(void 0===a)return function(t){return c=t,a=setTimeout(b,e),u?f(t):o}(h);if(l)return clearTimeout(a),a=setTimeout(b,e),f(h)}return void 0===a&&(a=setTimeout(b,e)),o}return e=q(e)||0,k(i)&&(u=!!i.leading,n=(l="maxWait"in i)?ut(q(i.maxWait)||0,e):n,d="trailing"in i?!!i.trailing:d),p.cancel=function(){void 0!==a&&clearTimeout(a),c=0,s=h=r=a=void 0},p.flush=function(){return void 0===a?o:v(ct())},p}((async(t,e)=>{try{const i=await t(e);if(e!==this.editorPickerQuery||!this.activeTrigger)return;this.items=i}catch(t){console.error("Error searching",t)}finally{this.isSearching=!1}}),300)}connectedCallback(){var t,e,i,s;if(this.draftIdentifier){const r=null!==(e=null===(t=this.context)||void 0===t?void 0:t.id)&&void 0!==e?e:"no-limeobject",n=null!==(s=null===(i=this.context)||void 0===i?void 0:i.limetype)&&void 0!==s?s:"no-limetype";this.textEditorInnerId=["text-editor-draft",n,r,this.draftIdentifier].join("-")}this.textEditorInnerId&&(document.addEventListener("visibilitychange",this.handleVisibilityChange),window.addEventListener("beforeunload",this.handleBeforeUnload)),this.uploadHandler=new bt(this.platform)}componentWillLoad(){this.allowMentioning&&this.registerMentions(),this.registerTriggers(),this.loadDraft()}disconnectedCallback(){document.removeEventListener("visibilitychange",this.handleVisibilityChange),window.removeEventListener("beforeunload",this.handleBeforeUnload),document.removeEventListener("mousedown",this.handleMouseClick),this.saveDraft(),this.host&&(this.host.removeEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.removeEventListener("keydown",this.handleKeyPress,{capture:!0})),this.debouncedSearchFn&&this.debouncedSearchFn.cancel&&this.debouncedSearchFn.cancel()}registerMentions(){const t=new ft(this.platform,this.context,this.searchableLimetypes,this.host),e=t.triggerHandler.nodeDefinition;e&&(this.registeredCustomElements.push(e.customElement),this.registeredTriggerMap[t.triggerCharacter]=t.triggerHandler,t.initialize())}registerTriggers(){this.registeredTriggers=Object.keys(this.registeredTriggerMap)}setPickerMessage(){var t;if(!this.activeTrigger)return;const e=this.registeredTriggerMap[this.activeTrigger];this.pickerMessage=(null===(t=this.editorPickerQuery)||void 0===t?void 0:t.length)>0?e.noItemsFoundMessage:e.emptySearchMessage}setupHandlers(){this.isPickerOpen?(this.host.addEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.addEventListener("keydown",this.handleKeyPress,{capture:!0}),document.addEventListener("mousedown",this.handleMouseClick)):(this.host.removeEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.removeEventListener("keydown",this.handleKeyPress,{capture:!0}),document.removeEventListener("mousedown",this.handleMouseClick))}isListSeparator(t){return"separator"in t&&!0===t.separator}render(){return[s("limel-text-editor",{key:"0f637527386d51f5b5c3e3a49b42acebafcba3fd",ref:t=>this.textEditor=t,tabindex:this.disabled?-1:0,value:this.value,contentType:this.contentType,customElements:this.registeredCustomElements,"aria-disabled":this.disabled,language:this.language,triggers:this.registeredTriggers,onTriggerStart:this.handleTriggerStart,onTriggerStop:this.handleTriggerStop,onTriggerChange:this.handleTriggerChange,onImagePasted:this.handleImagePasted,onMetadataChange:this.handleMetadataChange,ui:this.ui,allowResize:this.allowResize,required:this.required,disabled:this.disabled,readonly:this.readonly,helperText:this.helperText,placeholder:this.placeholder,label:this.label,invalid:this.invalid}),this.renderPicker()]}renderPicker(){if(this.isPickerOpen)return s("limel-portal",{containerId:this.portalId,visible:this.isPickerOpen,openDirection:"top",inheritParentWidth:!0,anchor:this.textEditor},s("limebb-text-editor-picker",{ref:t=>this.textEditorPickerElement=t,items:dt(this.items,this.highlightedItemIndex),onItemSelected:this.handleItemSelection,emptyMessage:this.pickerMessage,isSearching:this.isSearching}))}getEnhancedImages(t){return t.map((t=>{let e;return"success"===t.state&&(e=this.uploadHandler.parseFileIdFromSrc(t.src)),e?Object.assign(Object.assign({},t),{fileId:e}):t}))}loadDraft(){if(!this.userDataService||!this.textEditorInnerId)return;if(this.value)return;const t=this.userDataService.get(this.textEditorInnerId);t&&this.change.emit(t)}saveDraft(){var t,e,i,s;if(!this.textEditorInnerId)return;const r=null===(t=this.value)||void 0===t?void 0:t.trim(),n=null===(e=this.userDataService)||void 0===e?void 0:e.get(this.textEditorInnerId);r&&r!==n?null===(i=this.userDataService)||void 0===i||i.set(this.textEditorInnerId,r):!r&&n&&(null===(s=this.userDataService)||void 0===s||s.set(this.textEditorInnerId,void 0))}get userDataService(){return this.platform.get(n.UserDataRepository)}static get delegatesFocus(){return!0}get host(){return this}static get watchers(){return{isPickerOpen:[{watchOpen:0}],editorPickerQuery:[{watchQuery:0}]}}static get style(){return":host(limebb-text-editor){display:block;width:100%;min-width:5rem;min-height:5rem;height:100%;max-height:var(--text-editor-max-height, calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)) - 4rem))}"}},[17,"limebb-text-editor",{platform:[16],context:[16],allowMentioning:[4,"allow-mentioning"],contentType:[1,"content-type"],language:[513],disabled:[516],readonly:[516],helperText:[513,"helper-text"],placeholder:[513],label:[513],invalid:[516],required:[516],selectedContext:[16],ui:[513],allowResize:[4,"allow-resize"],value:[1],draftIdentifier:[1,"draft-identifier"],triggerMap:[16],customElements:[16],allowInlineImages:[4,"allow-inline-images"],items:[32],highlightedItemIndex:[32],editorPickerQuery:[32],searchableLimetypes:[32],isPickerOpen:[32],isSearching:[32]},void 0,{isPickerOpen:[{watchOpen:0}],editorPickerQuery:[{watchQuery:0}]}]);!function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);n>3&&o&&Object.defineProperty(e,i,o)}([h({map:[function(t){return Object.values(t).filter((t=>M(t,"user")||P(t,"user")))}]})],vt.prototype,"searchableLimetypes",void 0);const pt=vt,gt=function(){"undefined"!=typeof customElements&&["limebb-text-editor","limebb-empty-state","limebb-text-editor-picker"].forEach((t=>{switch(t){case"limebb-text-editor":customElements.get(r(t))||customElements.define(r(t),vt);break;case"limebb-empty-state":customElements.get(r(t))||_();break;case"limebb-text-editor-picker":customElements.get(r(t))||L()}}))};export{pt as LimebbTextEditor,gt as defineCustomElement}
1
+ import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as s,transformTag as r}from"@stencil/core/internal/client";import{n,s as o,c as a,I as h,_ as c}from"./index.esm.js";import{A as u,E as l,b as d,a as f,T as m}from"./keycodes.js";import{o as p,U as b,c as v,a as g,d as y,n as j,i as w,S as x,g as k}from"./_Uint8Array.js";import{d as O}from"./_defineProperty.js";import{c as S,e as E,S as I,i as T,a as C,r as A}from"./_MapCache.js";import{c as P}from"./random-string.js";import{h as M,b as N,c as F}from"./limetype.js";import{i as _}from"./non-null.js";import{g as R}from"./file-contents-url.js";import{d as U}from"./empty-state.js";import{d as D}from"./text-editor-picker.js";import{i as L}from"./isSymbol.js";var z=/\s/,Q=/^\s+/;var $=/^[-+]0x[0-9a-f]+$/i,G=/^0b[01]+$/i,q=/^0o[0-7]+$/i,W=parseInt;function B(t){if("number"==typeof t)return t;if(L(t))return NaN;if(S(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=S(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=function(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&z.test(t.charAt(e)););return e}(t)+1).replace(Q,""):t}(t);var i=G.test(t);return i||q.test(t)?W(t.slice(2),i?2:8):$.test(t)?NaN:+t}var H=Object.create,K=function(){function t(){}return function(e){if(!S(e))return{};if(H)return H(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}(),V=Object.prototype.hasOwnProperty;var J=p(Object.getPrototypeOf,Object);"object"==typeof exports&&exports&&!exports.nodeType&&exports&&"object"==typeof module&&module&&!module.nodeType&&module;var X=Object.prototype.hasOwnProperty;function Y(t){var e=new t.constructor(t.byteLength);return new b(e).set(new b(t)),e}var Z=/\w*$/,tt=I?I.prototype:void 0,et=tt?tt.valueOf:void 0;var it=j&&j.isMap,st=it?y(it):function(t){return T(t)&&"[object Map]"==g(t)},rt=j&&j.isSet,nt=rt?y(rt):function(t){return T(t)&&"[object Set]"==g(t)},ot="[object Arguments]",at="[object Function]",ht="[object Object]",ct={};function ut(t,e,i,s,r,n){var o;if(void 0!==o)return o;if(!S(t))return t;var a=C(t);if(a)o=function(t){var e=t.length,i=new t.constructor(e);return e&&"string"==typeof t[0]&&X.call(t,"index")&&(i.index=t.index,i.input=t.input),i}(t);else{var h=g(t),c=h==at||"[object GeneratorFunction]"==h;if(w(t))return function(t){return t.slice()}(t);if(h==ht||h==ot||c&&!r)o=c?{}:function(t){return"function"!=typeof t.constructor||v(t)?{}:K(J(t))}(t);else{if(!ct[h])return r?t:{};o=function(t,e){var i=t.constructor;switch(e){case"[object ArrayBuffer]":return Y(t);case"[object Boolean]":case"[object Date]":return new i(+t);case"[object DataView]":return function(t){var e=Y(t.buffer);return new t.constructor(e,t.byteOffset,t.byteLength)}(t);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t){var e=Y(t.buffer);return new t.constructor(e,t.byteOffset,t.length)}(t);case"[object Map]":case"[object Set]":return new i;case"[object Number]":case"[object String]":return new i(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,Z.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return function(t){return et?Object(et.call(t)):{}}(t)}}(t,h)}}n||(n=new x);var u=n.get(t);if(u)return u;n.set(t,o),nt(t)?t.forEach((function(s){o.add(ut(s,e,i,0,t,n))})):st(t)&&t.forEach((function(s,r){o.set(r,ut(s,e,i,0,t,n))}));var l=a?void 0:k(t);return function(t,e){for(var i=-1,s=null==t?0:t.length;++i<s&&!1!==e(t[i],i););}(l||t,(function(s,r){l&&(s=t[r=s]),function(t,e,i){var s=t[e];V.call(t,e)&&E(s,i)&&(void 0!==i||e in t)||function(t,e,i){"__proto__"==e&&O?O(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i}(t,e,i)}(o,r,ut(s,e,i,0,t,n))})),o}ct[ot]=ct["[object Array]"]=ct["[object ArrayBuffer]"]=ct["[object DataView]"]=ct["[object Boolean]"]=ct["[object Date]"]=ct["[object Float32Array]"]=ct["[object Float64Array]"]=ct["[object Int8Array]"]=ct["[object Int16Array]"]=ct["[object Int32Array]"]=ct["[object Map]"]=ct["[object Number]"]=ct[ht]=ct["[object RegExp]"]=ct["[object Set]"]=ct["[object String]"]=ct["[object Symbol]"]=ct["[object Uint8Array]"]=ct["[object Uint8ClampedArray]"]=ct["[object Uint16Array]"]=ct["[object Uint32Array]"]=!0,ct["[object Error]"]=ct[at]=ct["[object WeakMap]"]=!1;var lt=function(){return A.Date.now()},dt=Math.max,ft=Math.min;function mt(t,e){return t.map(((t,i)=>{const s=function(t){return ut(t,5)}(t);return Object.assign(Object.assign({},s),{selected:i===e})}))}class pt{get limeObjectService(){return this.platform.get(n.LimeObjectRepository)}get queryService(){return this.platform.get(n.Query)}get viewFactoryRegistry(){return this.platform.get(n.ViewFactoryRegistry)}get contextRegistry(){return this.platform.get(n.ContextRegistry)}get translator(){var t;return null===(t=this.platform)||void 0===t?void 0:t.get(n.Translate)}get triggerCharacter(){return this._triggerCharacter}get triggerHandler(){return this._triggerHandler}constructor(t,e,i,s){this.platform=t,this.context=e,this.searchableLimetypes=i,this.host=s,this.groupCounts={},this._triggerCharacter="@",this._triggerHandler={searcher:t=>this.searcher(t),inserter:(t,e)=>this.inserter(t,e),emptySearchMessage:"Start typing a name...",noItemsFoundMessage:"No results for your search...",nodeDefinition:{customElement:{tagName:"limebb-mention",attributes:["limetype","objectid","href"]},mapAttributes:t=>({limetype:t.value.getLimetype().name,objectid:t.value.id,href:`object/${this.context.limetype}/${this.context.id}`})}},this.searcher=async t=>{if(!t)return[];const{objects:e}=await this.limeObjectService.search(t,this.searchableLimetypes,10);return this.createSearchListItems(e)},this.inserter=async(t,e)=>{var i;const s=this.triggerHandler.nodeDefinition;s&&t.insert({node:{tagName:s.customElement.tagName,attributes:s.mapAttributes(e)},children:[null===(i=e.value)||void 0===i?void 0:i.descriptive]})}}async initialize(){await this.loadGroupCounts()}async loadGroupCounts(){const t=this.searchableLimetypes.filter((t=>!N(t,"user")&&M(t,"user"))).map((t=>this.getGroupCounts(t)));for(const e of await Promise.all(t))Object.assign(this.groupCounts,e)}async getGroupCounts(t){var e;const i=F(t,"user"),s=t.name;try{const t=await this.queryService.execute({limetype:s,responseFormat:{object:{_id:null,[i.name]:{count:{aggregate:{op:o.Count}}}}}});if(!(null===(e=t.objects)||void 0===e?void 0:e.length))return{[s]:{}};const r=this.createGroupCount(t.objects,i.name);return{[s]:r}}catch(e){return console.error("Error fetching group count for limetype: "+t.name,e),{[s]:{}}}}createGroupCount(t,e){const i={};for(const s of t){const{_id:t,[e]:r}=s;i[t]=r.count}return i}createSearchListItems(t=[]){return t.map((t=>this.createSearchListItem(t))).filter(_)}createSearchListItem(t){const e=this.viewFactoryRegistry.getFactory("search"),i=this.limeObjectService.getObject(t._limetype,t._id);if(!i)return null;const s=e(i,this.contextRegistry.scope({host:this.host})),r=this.getGroupCountComponent(i);return Object.assign(Object.assign({},s),r?{primaryComponent:r}:{})}getGroupCountComponent(t){var e;const i=t.getLimetype(),s=null===(e=this.groupCounts[i.name])||void 0===e?void 0:e[t.id],r=F(i,"user");if(void 0!==s&&r)return{name:"limebb-mention-group-counter",props:{count:s,limetype:r.relation.getLimetype(),helperLabel:this.translator.get("webclient.notification-center.members-will-be-notified")}}}}class bt{constructor(t,e){this.file=t,this.http=e,this.uploadCancelled=!1,this.getUrl=t=>"api/v1/file/"+(null!=t?t:"")}async initialize(){this.uploadService=await this.http.createFileUpload(a.Post,this.getUrl(),this.file),this.progressCallback&&(this.uploadService.onProgress=this.progressCallback)}async upload(){return this.uploadService.upload()}getFileName(){return this.file.name}cancel(){this.uploadService.cancel(),this.uploadCancelled=!0}set onProgress(t){this.progressCallback=t,this.uploadService&&(this.uploadService.onProgress=t)}}var vt=function(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o};const gt=t(class extends e{watchOpen(){this.setupHandlers(),this.setPickerMessage()}watchQuery(){this.setPickerMessage()}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.change=i(this,"change",7),this.imageUploadingChange=i(this,"imageUploadingChange",7),this.allowMentioning=!1,this.contentType="markdown",this.language="en",this.disabled=!1,this.readonly=!1,this.invalid=!1,this.required=!1,this.ui="standard",this.allowResize=!0,this.value="",this.triggerMap={},this.customElements=[],this.allowPasteImages=!1,this.items=[],this.highlightedItemIndex=0,this.isPickerOpen=!1,this.isSearching=!1,this.registeredTriggers=[],this.registeredTriggerMap=this.triggerMap,this.registeredCustomElements=this.customElements,this.activeTrigger=void 0,this.pendingUploads=0,this.handleMouseClick=t=>{this.textEditorPickerElement&&(t.target===this.textEditorPickerElement||this.resetTriggerAndPicker())},this.handleKeyPress=t=>{if(!this.isPickerOpen||!this.activeTrigger)return;if(![l,d,u,f,m].includes(t.key))return;if(t.stopPropagation(),t.preventDefault(),"keyup"===t.type)return;const e={[l]:this.handleEscapeKey,[f]:this.handleEnterOrTabKey,[m]:this.handleEnterOrTabKey,[u]:this.handleArrowKeyPress,[d]:this.handleArrowKeyPress}[t.key];e&&e(t)},this.handleArrowKeyPress=t=>{this.highlightedItemIndex=this.findNonSeparatorIndex(t.key,this.highlightedItemIndex)},this.findNonSeparatorIndex=(t,e,i=0)=>{if(0===this.items.length||i>this.items.length)return e;const s=((t,e,i)=>(e+(t===u?1:-1)+i)%i)(t,e,this.items.length);return this.isListSeparator(this.items[s])?this.findNonSeparatorIndex(t,s,i+1):s},this.handleEscapeKey=()=>{var t;null===(t=this.triggerFunction)||void 0===t||t.stopTrigger(),this.resetTriggerAndPicker()},this.handleEnterOrTabKey=t=>{this.handleItemSelection(t)},this.handleTriggerStart=t=>{t.stopPropagation(),this.activeTrigger=t.detail.trigger,this.triggerFunction=t.detail.textEditor,this.isPickerOpen=!0},this.handleTriggerStop=t=>{t.stopPropagation(),this.resetTriggerAndPicker()},this.handleTriggerChange=t=>{var e;t.stopImmediatePropagation(),this.editorPickerQuery=t.detail.value;const i=null===(e=this.registeredTriggerMap[t.detail.trigger])||void 0===e?void 0:e.searcher;i&&(this.isSearching=!0,this.debouncedSearchFn(i,this.editorPickerQuery))},this.resetTriggerAndPicker=()=>{this.isPickerOpen=!1,this.activeTrigger=void 0,this.triggerFunction=void 0,this.isSearching=!1,this.highlightedItemIndex=0,this.items=[]},this.handleItemSelection=t=>{var e;let i;if(t instanceof CustomEvent)i=t.detail;else{if(!(t instanceof KeyboardEvent))return;{const t=this.items[this.highlightedItemIndex];if(this.isListSeparator(t))return;i=t}}if(!this.activeTrigger||(null==i?void 0:i.disabled))return;const s=this.registeredTriggerMap[this.activeTrigger];try{s.inserter(this.triggerFunction,i)}catch(t){console.error("Error inserting",t)}this.resetTriggerAndPicker(),null===(e=this.textEditor)||void 0===e||e.focus()},this.handleVisibilityChange=()=>{"hidden"===document.visibilityState&&this.saveDraft()},this.handleBeforeUnload=()=>{this.saveDraft()},this.portalId=P(),this.debouncedSearchFn=function(t,e,i){var s,r,n,o,a,h,c=0,u=!1,l=!1,d=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function f(e){var i=s,n=r;return s=r=void 0,c=e,o=t.apply(n,i)}function m(t){var i=t-h;return void 0===h||i>=e||i<0||l&&t-c>=n}function p(){var t=lt();if(m(t))return b(t);a=setTimeout(p,function(t){var i=e-(t-h);return l?ft(i,n-(t-c)):i}(t))}function b(t){return a=void 0,d&&s?f(t):(s=r=void 0,o)}function v(){var t=lt(),i=m(t);if(s=arguments,r=this,h=t,i){if(void 0===a)return function(t){return c=t,a=setTimeout(p,e),u?f(t):o}(h);if(l)return clearTimeout(a),a=setTimeout(p,e),f(h)}return void 0===a&&(a=setTimeout(p,e)),o}return e=B(e)||0,S(i)&&(u=!!i.leading,n=(l="maxWait"in i)?dt(B(i.maxWait)||0,e):n,d="trailing"in i?!!i.trailing:d),v.cancel=function(){void 0!==a&&clearTimeout(a),c=0,s=h=r=a=void 0},v.flush=function(){return void 0===a?o:b(lt())},v}((async(t,e)=>{try{const i=await t(e);if(e!==this.editorPickerQuery||!this.activeTrigger)return;this.items=i}catch(t){console.error("Error searching",t)}finally{this.isSearching=!1}}),300)}connectedCallback(){var t,e,i,s;if(this.draftIdentifier){const r=null!==(e=null===(t=this.context)||void 0===t?void 0:t.id)&&void 0!==e?e:"no-limeobject",n=null!==(s=null===(i=this.context)||void 0===i?void 0:i.limetype)&&void 0!==s?s:"no-limetype";this.textEditorInnerId=["text-editor-draft",n,r,this.draftIdentifier].join("-")}this.textEditorInnerId&&(document.addEventListener("visibilitychange",this.handleVisibilityChange),window.addEventListener("beforeunload",this.handleBeforeUnload))}componentWillLoad(){this.allowMentioning&&this.registerMentions(),this.registerTriggers(),this.loadDraft()}disconnectedCallback(){document.removeEventListener("visibilitychange",this.handleVisibilityChange),window.removeEventListener("beforeunload",this.handleBeforeUnload),document.removeEventListener("mousedown",this.handleMouseClick),this.saveDraft(),this.host&&(this.host.removeEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.removeEventListener("keydown",this.handleKeyPress,{capture:!0})),this.debouncedSearchFn&&this.debouncedSearchFn.cancel&&this.debouncedSearchFn.cancel()}registerMentions(){const t=new pt(this.platform,this.context,this.searchableLimetypes,this.host),e=t.triggerHandler.nodeDefinition;e&&(this.registeredCustomElements.push(e.customElement),this.registeredTriggerMap[t.triggerCharacter]=t.triggerHandler,t.initialize())}registerTriggers(){this.registeredTriggers=Object.keys(this.registeredTriggerMap)}setPickerMessage(){var t;if(!this.activeTrigger)return;const e=this.registeredTriggerMap[this.activeTrigger];this.pickerMessage=(null===(t=this.editorPickerQuery)||void 0===t?void 0:t.length)>0?e.noItemsFoundMessage:e.emptySearchMessage}setupHandlers(){this.isPickerOpen?(this.host.addEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.addEventListener("keydown",this.handleKeyPress,{capture:!0}),document.addEventListener("mousedown",this.handleMouseClick)):(this.host.removeEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.removeEventListener("keydown",this.handleKeyPress,{capture:!0}),document.removeEventListener("mousedown",this.handleMouseClick))}isListSeparator(t){return"separator"in t&&!0===t.separator}render(){return[s("limel-text-editor",{key:"7c5597fd2affe6f7a625c3fabfbaaef70ac41b00",ref:t=>this.textEditor=t,tabindex:this.disabled?-1:0,value:this.value,contentType:this.contentType,customElements:this.registeredCustomElements,"aria-disabled":this.disabled,language:this.language,triggers:this.registeredTriggers,onTriggerStart:this.handleTriggerStart,onTriggerStop:this.handleTriggerStop,onTriggerChange:this.handleTriggerChange,inlineImages:this.inlineImages,ui:this.ui,allowResize:this.allowResize,required:this.required,disabled:this.disabled,readonly:this.readonly,helperText:this.helperText,placeholder:this.placeholder,label:this.label,invalid:this.invalid}),this.renderPicker()]}renderPicker(){if(this.isPickerOpen)return s("limel-portal",{containerId:this.portalId,visible:this.isPickerOpen,openDirection:"top",inheritParentWidth:!0,anchor:this.textEditor},s("limebb-text-editor-picker",{ref:t=>this.textEditorPickerElement=t,items:mt(this.items,this.highlightedItemIndex),onItemSelected:this.handleItemSelection,emptyMessage:this.pickerMessage,isSearching:this.isSearching}))}get inlineImages(){return Object.assign({tagName:"limebb-inline-image",getUrl:t=>R(this.appName,t)},this.allowPasteImages&&{upload:t=>this.uploadImage(t)})}async uploadImage(t){0===this.pendingUploads&&this.imageUploadingChange.emit(!0),this.pendingUploads++;try{return await this.uploadFile(t)}finally{this.pendingUploads--,0===this.pendingUploads&&this.imageUploadingChange.emit(!1)}}async uploadFile(t){if(t.size>52428800)throw Error("Image exceeds the maximum file size");const e=this.platform.get(n.Http),i=new bt(t,e);await i.initialize();const s=await i.upload();if(!s.id)throw Error("File upload response is missing an id");return s.id+""}loadDraft(){if(!this.userDataService||!this.textEditorInnerId)return;if(this.value)return;const t=this.userDataService.get(this.textEditorInnerId);t&&this.change.emit(t)}saveDraft(){var t,e,i,s;if(!this.textEditorInnerId)return;const r=null===(t=this.value)||void 0===t?void 0:t.trim(),n=null===(e=this.userDataService)||void 0===e?void 0:e.get(this.textEditorInnerId);r&&r!==n?null===(i=this.userDataService)||void 0===i||i.set(this.textEditorInnerId,r):!r&&n&&(null===(s=this.userDataService)||void 0===s||s.set(this.textEditorInnerId,void 0))}get userDataService(){return this.platform.get(n.UserDataRepository)}static get delegatesFocus(){return!0}get host(){return this}static get watchers(){return{isPickerOpen:[{watchOpen:0}],editorPickerQuery:[{watchQuery:0}]}}static get style(){return":host(limebb-text-editor){display:block;width:100%;min-width:5rem;min-height:5rem;height:100%;max-height:var(--text-editor-max-height, calc(100vh - (env(safe-area-inset-top) + env(safe-area-inset-bottom)) - 4rem))}"}},[17,"limebb-text-editor",{platform:[16],context:[16],allowMentioning:[4,"allow-mentioning"],contentType:[1,"content-type"],language:[513],disabled:[516],readonly:[516],helperText:[513,"helper-text"],placeholder:[513],label:[513],invalid:[516],required:[516],selectedContext:[16],ui:[513],allowResize:[4,"allow-resize"],value:[1],draftIdentifier:[1,"draft-identifier"],triggerMap:[16],customElements:[16],allowPasteImages:[4,"allow-paste-images"],items:[32],highlightedItemIndex:[32],editorPickerQuery:[32],searchableLimetypes:[32],appName:[32],isPickerOpen:[32],isSearching:[32]},void 0,{isPickerOpen:[{watchOpen:0}],editorPickerQuery:[{watchQuery:0}]}]);vt([h({map:[function(t){return Object.values(t).filter((t=>N(t,"user")||M(t,"user")))}]})],gt.prototype,"searchableLimetypes",void 0),vt([c()],gt.prototype,"appName",void 0);const yt=gt,jt=function(){"undefined"!=typeof customElements&&["limebb-text-editor","limebb-empty-state","limebb-text-editor-picker"].forEach((t=>{switch(t){case"limebb-text-editor":customElements.get(r(t))||customElements.define(r(t),gt);break;case"limebb-empty-state":customElements.get(r(t))||U();break;case"limebb-text-editor-picker":customElements.get(r(t))||D()}}))};export{yt as LimebbTextEditor,jt as defineCustomElement}
@@ -1 +1 @@
1
- import{proxyCustomElement as o,HTMLElement as r,h as e,Host as t,transformTag as a}from"@stencil/core/internal/client";import{b as i}from"./index.esm.js";import{g as s,n as l}from"./normalize-value.js";const n=o(class extends r{constructor(o){super(),!1!==o&&this.__registerHost(),this.__attachShadow(),this.suffix="%",this.reducePresence=!0,this.locale="en",this.labelId="a"+crypto.randomUUID(),this.tooltipId="a"+crypto.randomUUID(),this.helperTextId="a"+crypto.randomUUID(),this.renderHelperLine=()=>{if(this.hasHelperText())return e("limel-helper-line",{helperTextId:this.helperTextId,helperText:this.helperText,invalid:this.invalid})},this.hasHelperText=()=>null!=this.helperText}valueChanged(o){this.numValue=this.parseValue(o)}componentWillLoad(){try{this.locale=this.platform.get(i.UserPreferencesRepository).get("locale"),this.numberFormat=new Intl.NumberFormat(this.locale)}catch(o){console.warn(`Could not get user's locale (${this.locale}), falling back to 'en'.`),this.locale="en",this.numberFormat=new Intl.NumberFormat("en")}this.numValue=this.parseValue(this.value)}render(){return e(t,{key:"b963d9086b70b11dce31375284e54574f54b4f0c",class:this.getContainerClassList()},e("limel-notched-outline",{key:"d2d2587a0239cba584177dbc1806762e9d783460",id:this.tooltipId,label:this.label,labelId:this.labelId,invalid:this.invalid,required:this.required,hasValue:!0,hasFloatingLabel:!0,"aria-labelledby":this.labelId,"aria-describedby":this.helperTextId,"aria-controls":this.helperTextId},e("div",{key:"8e7b6c37d803c5c682220681e93c3a096d4e02d2",slot:"content",tabIndex:0},this.renderVisualization())),this.renderHelperLine(),this.renderTooltip())}renderVisualization(){if(!this.reducePresence||0!==this.numValue&&this.hasValue())return this.hasValue()?[this.getArrowIcon(),e("span",null,this.renderGrowthPercentage(),this.renderGrowthAmount())]:e("span",{class:"no-value"},"–")}renderTooltip(){if(void 0===this.formerValue)return;const o=this.value+" - "+(this.formerValue>0?this.formerValue:"("+this.formerValue+")")+" = "+this.calculateGrowth()+` ${this.suffix} `,r=this.calculatePercentage();return e("limel-tooltip",{openDirection:"top-start",elementId:this.tooltipId,label:r+"%",helperLabel:o})}renderGrowthPercentage(){if(void 0===this.formerValue)return this.formatValue(this.numValue,this.suffix);const o=this.calculatePercentage();return null!==o?this.formatValue(o,"%"):void 0}renderGrowthAmount(){if(void 0===this.formerValue)return;const o=this.calculateGrowth();return e("span",{class:"growth-unit"},"( ",this.formatValue(o,this.suffix)," )")}hasValue(){return null!=this.value&&""!==this.value}getContainerClassList(){if(!this.hasValue())return;const o=this.getPercentage(),r=s(o);return Object.assign({},r&&{[r]:!0})}getPercentage(){return void 0===this.formerValue?this.numValue:this.calculatePercentage()}calculateGrowth(){return this.numValue-this.formerValue}calculatePercentage(){return 0===this.formerValue?null:Number.parseFloat(((this.numValue-this.formerValue)/Math.abs(this.formerValue)*100).toFixed(2))}unifyMinusSign(o){return o.replaceAll("−","-")}convertToUnicodeMinus(o){return o.replaceAll("-","−")}parseValue(o){return"string"==typeof o?Number.parseFloat(l(this.unifyMinusSign(o),this.locale)):o}formatValue(o,r){const e=`${this.numberFormat.format(o)} ${r}`;return o>0?"+"+e:this.convertToUnicodeMinus(e)}getArrowIcon(){return e("limel-icon",{class:"icon",name:"right","aria-hidden":"true",role:"presentation"})}static get watchers(){return{value:[{valueChanged:0}]}}static get style(){return'@charset "UTF-8";*{box-sizing:border-box}:host(limebb-trend-indicator){position:relative;display:block;height:100%;width:100%}limel-notched-outline:not([invalid]:not([invalid=false])) .limel-notched-outline--outlines{--limel-notched-outline-border-color:transparent}div[slot=content]:focus{outline:none}div[slot=content]:focus-visible{outline:none;box-shadow:var(--shadow-depth-8-focused)}div[slot=content]{display:flex;align-items:center;gap:0.5rem;border-radius:inherit;background-color:transparent !important}:host(limebb-trend-indicator):has(label) div[slot=content]{min-height:2.5rem;padding:0 0.375rem 0 1rem}:host(limebb-trend-indicator[former-value]) div[slot=content]{cursor:help}div[slot=content] span{flex-shrink:0}.icon{flex-shrink:0;display:flex;transition-property:color, background-color, transform;transition-duration:0.4s;transition-timing-function:ease;width:1.25rem;height:1.25rem;border-radius:50%;padding:0.12rem;color:rgb(var(--color-white));background-color:rgb(var(--color-gray-default), 0.5)}:host(.has-value-40to30-negative) .icon{color:rgb(var(--color-gray-darker))}:host(.has-value-30to20-negative) .icon{color:rgb(var(--color-gray-darker))}:host(.has-value-20to10-negative) .icon{color:rgb(var(--color-gray-darker))}:host(.has-value-10to0-negative) .icon{color:rgb(var(--color-gray-darker))}:host(.has-value-0to10-positive) .icon{color:rgb(var(--color-gray-dark))}:host(.has-value-10to20-positive) .icon{color:rgb(var(--color-gray-dark))}:host(.has-value-20to30-positive) .icon{color:rgb(var(--color-gray-dark))}:host(.has-value-30to40-positive) .icon{color:rgb(var(--color-gray-dark))}:host(.has-value-200or-larger-negative) .icon{background-color:rgb(var(--color-red-darker));transform:rotate(90deg)}:host(.has-value-200to100-negative) .icon{background-color:rgb(var(--color-red-dark));transform:rotate(90deg)}:host(.has-value-100to90-negative) .icon{background-color:rgb(var(--color-red-dark));transform:rotate(90deg)}:host(.has-value-90to80-negative) .icon{background-color:rgb(var(--color-red-dark));transform:rotate(81deg)}:host(.has-value-80to70-negative) .icon{background-color:rgb(var(--color-red-default));transform:rotate(72deg)}:host(.has-value-70to60-negative) .icon{background-color:rgb(var(--color-red-default));transform:rotate(63deg)}:host(.has-value-60to50-negative) .icon{background-color:rgb(var(--color-coral-default));transform:rotate(54deg)}:host(.has-value-50to40-negative) .icon{background-color:rgb(var(--color-coral-default));transform:rotate(45deg)}:host(.has-value-40to30-negative) .icon{background-color:rgb(var(--color-orange-default));transform:rotate(36deg)}:host(.has-value-30to20-negative) .icon{background-color:rgb(var(--color-orange-default));transform:rotate(27deg)}:host(.has-value-20to10-negative) .icon{background-color:rgb(var(--color-amber-default));transform:rotate(18deg)}:host(.has-value-10to0-negative) .icon{background-color:rgb(var(--color-amber-default));transform:rotate(9deg)}:host(.has-value-0) .icon{background-color:rgb(var(--color-gray-default));transform:rotate(0deg)}:host(.has-value-0to10-positive) .icon{background-color:rgb(var(--color-yellow-default));transform:rotate(-9deg)}:host(.has-value-10to20-positive) .icon{background-color:rgb(var(--color-yellow-default));transform:rotate(-18deg)}:host(.has-value-20to30-positive) .icon{background-color:rgb(var(--color-grass-default));transform:rotate(-27deg)}:host(.has-value-30to40-positive) .icon{background-color:rgb(var(--color-grass-default));transform:rotate(-36deg)}:host(.has-value-40to50-positive) .icon{background-color:rgb(var(--color-lime-default));transform:rotate(-45deg)}:host(.has-value-50to60-positive) .icon{background-color:rgb(var(--color-lime-default));transform:rotate(-54deg)}:host(.has-value-60to70-positive) .icon{background-color:rgb(var(--color-teal-default));transform:rotate(-63deg)}:host(.has-value-70to80-positive) .icon{background-color:rgb(var(--color-teal-default));transform:rotate(-72deg)}:host(.has-value-80to90-positive) .icon{background-color:rgb(var(--color-teal-dark));transform:rotate(-81deg)}:host(.has-value-90to100-positive) .icon{background-color:rgb(var(--color-teal-dark));transform:rotate(-90deg)}:host(.has-value-100to200-positive) .icon{background-color:rgb(var(--color-teal-dark));transform:rotate(-90deg)}:host(.has-value-200or-larger-positive) .icon{background-color:rgb(var(--color-teal-darker));transform:rotate(-90deg)}:host(.has-value-0) .icon{background-color:rgb(var(--color-gray-default), 0.5);transform:rotate(0deg)}:host(.has-value-0) .icon polyline{color:transparent}:host(.has-value-200or-larger-negative) .icon:after,:host(.has-value-200or-larger-negative) .icon:before,:host(.has-value-200to100-negative) .icon:after,:host(.has-value-200to100-negative) .icon:before,:host(.has-value-100to200-positive) .icon:after,:host(.has-value-100to200-positive) .icon:before,:host(.has-value-200or-larger-positive) .icon:after,:host(.has-value-200or-larger-positive) .icon:before{transition:border-color 0.6s ease;content:"";position:absolute;inset:0;margin:auto;border:1px solid transparent;border-radius:50%}:host(.has-value-200or-larger-negative) .icon:before,:host(.has-value-200to100-negative) .icon:before,:host(.has-value-100to200-positive) .icon:before,:host(.has-value-200or-larger-positive) .icon:before{transform:scale(1.2)}:host(.has-value-200or-larger-negative) .icon:after,:host(.has-value-200to100-negative) .icon:after,:host(.has-value-100to200-positive) .icon:after,:host(.has-value-200or-larger-positive) .icon:after{transform:scale(1.4);opacity:0.4}:host(.has-value-200to100-negative) .icon:before,:host(.has-value-200or-larger-negative) .icon:before{border-color:rgb(var(--color-red-dark))}:host(.has-value-200or-larger-negative) .icon:after{border-color:rgb(var(--color-red-darker))}:host(.has-value-100to200-positive) .icon:before,:host(.has-value-200or-larger-positive) .icon:before{border-color:rgb(var(--color-teal-dark))}:host(.has-value-200or-larger-positive) .icon:after{border-color:rgb(var(--color-teal-darker))}.no-value{transform:translateY(0.5rem)}.growth-unit{padding-left:0.5rem;opacity:0.5}:host(limebb-trend-indicator:focus),:host(limebb-trend-indicator:focus-visible),:host(limebb-trend-indicator:focus-within){--limel-h-l-grid-template-rows-transition-speed:0.46s;--limel-h-l-grid-template-rows:1fr}:host(limebb-trend-indicator){--limel-h-l-grid-template-rows-transition-speed:0.3s;--limel-h-l-grid-template-rows:0fr}:host(limebb-trend-indicator:focus) limel-helper-line,:host(limebb-trend-indicator:focus-visible) limel-helper-line,:host(limebb-trend-indicator:focus-within) limel-helper-line,:host(limebb-trend-indicator:hover) limel-helper-line{will-change:grid-template-rows}'}},[1,"limebb-trend-indicator",{platform:[16],context:[16],value:[520],formerValue:[514,"former-value"],suffix:[513],label:[513],invalid:[516],required:[516],helperText:[513,"helper-text"],reducePresence:[516,"reduce-presence"]},void 0,{value:[{valueChanged:0}]}]),c=n,h=function(){"undefined"!=typeof customElements&&["limebb-trend-indicator"].forEach((o=>{"limebb-trend-indicator"===o&&(customElements.get(a(o))||customElements.define(a(o),n))}))};export{c as LimebbTrendIndicator,h as defineCustomElement}
1
+ import{proxyCustomElement as o,HTMLElement as r,h as e,Host as t,transformTag as a}from"@stencil/core/internal/client";import{n as i}from"./index.esm.js";import{g as s,n as l}from"./normalize-value.js";const n=o(class extends r{constructor(o){super(),!1!==o&&this.__registerHost(),this.__attachShadow(),this.suffix="%",this.reducePresence=!0,this.locale="en",this.labelId="a"+crypto.randomUUID(),this.tooltipId="a"+crypto.randomUUID(),this.helperTextId="a"+crypto.randomUUID(),this.renderHelperLine=()=>{if(this.hasHelperText())return e("limel-helper-line",{helperTextId:this.helperTextId,helperText:this.helperText,invalid:this.invalid})},this.hasHelperText=()=>null!=this.helperText}valueChanged(o){this.numValue=this.parseValue(o)}componentWillLoad(){try{this.locale=this.platform.get(i.UserPreferencesRepository).get("locale"),this.numberFormat=new Intl.NumberFormat(this.locale)}catch(o){console.warn(`Could not get user's locale (${this.locale}), falling back to 'en'.`),this.locale="en",this.numberFormat=new Intl.NumberFormat("en")}this.numValue=this.parseValue(this.value)}render(){return e(t,{key:"b963d9086b70b11dce31375284e54574f54b4f0c",class:this.getContainerClassList()},e("limel-notched-outline",{key:"d2d2587a0239cba584177dbc1806762e9d783460",id:this.tooltipId,label:this.label,labelId:this.labelId,invalid:this.invalid,required:this.required,hasValue:!0,hasFloatingLabel:!0,"aria-labelledby":this.labelId,"aria-describedby":this.helperTextId,"aria-controls":this.helperTextId},e("div",{key:"8e7b6c37d803c5c682220681e93c3a096d4e02d2",slot:"content",tabIndex:0},this.renderVisualization())),this.renderHelperLine(),this.renderTooltip())}renderVisualization(){if(!this.reducePresence||0!==this.numValue&&this.hasValue())return this.hasValue()?[this.getArrowIcon(),e("span",null,this.renderGrowthPercentage(),this.renderGrowthAmount())]:e("span",{class:"no-value"},"–")}renderTooltip(){if(void 0===this.formerValue)return;const o=this.value+" - "+(this.formerValue>0?this.formerValue:"("+this.formerValue+")")+" = "+this.calculateGrowth()+` ${this.suffix} `,r=this.calculatePercentage();return e("limel-tooltip",{openDirection:"top-start",elementId:this.tooltipId,label:r+"%",helperLabel:o})}renderGrowthPercentage(){if(void 0===this.formerValue)return this.formatValue(this.numValue,this.suffix);const o=this.calculatePercentage();return null!==o?this.formatValue(o,"%"):void 0}renderGrowthAmount(){if(void 0===this.formerValue)return;const o=this.calculateGrowth();return e("span",{class:"growth-unit"},"( ",this.formatValue(o,this.suffix)," )")}hasValue(){return null!=this.value&&""!==this.value}getContainerClassList(){if(!this.hasValue())return;const o=this.getPercentage(),r=s(o);return Object.assign({},r&&{[r]:!0})}getPercentage(){return void 0===this.formerValue?this.numValue:this.calculatePercentage()}calculateGrowth(){return this.numValue-this.formerValue}calculatePercentage(){return 0===this.formerValue?null:Number.parseFloat(((this.numValue-this.formerValue)/Math.abs(this.formerValue)*100).toFixed(2))}unifyMinusSign(o){return o.replaceAll("−","-")}convertToUnicodeMinus(o){return o.replaceAll("-","−")}parseValue(o){return"string"==typeof o?Number.parseFloat(l(this.unifyMinusSign(o),this.locale)):o}formatValue(o,r){const e=`${this.numberFormat.format(o)} ${r}`;return o>0?"+"+e:this.convertToUnicodeMinus(e)}getArrowIcon(){return e("limel-icon",{class:"icon",name:"right","aria-hidden":"true",role:"presentation"})}static get watchers(){return{value:[{valueChanged:0}]}}static get style(){return'@charset "UTF-8";*{box-sizing:border-box}:host(limebb-trend-indicator){position:relative;display:block;height:100%;width:100%}limel-notched-outline:not([invalid]:not([invalid=false])) .limel-notched-outline--outlines{--limel-notched-outline-border-color:transparent}div[slot=content]:focus{outline:none}div[slot=content]:focus-visible{outline:none;box-shadow:var(--shadow-depth-8-focused)}div[slot=content]{display:flex;align-items:center;gap:0.5rem;border-radius:inherit;background-color:transparent !important}:host(limebb-trend-indicator):has(label) div[slot=content]{min-height:2.5rem;padding:0 0.375rem 0 1rem}:host(limebb-trend-indicator[former-value]) div[slot=content]{cursor:help}div[slot=content] span{flex-shrink:0}.icon{flex-shrink:0;display:flex;transition-property:color, background-color, transform;transition-duration:0.4s;transition-timing-function:ease;width:1.25rem;height:1.25rem;border-radius:50%;padding:0.12rem;color:rgb(var(--color-white));background-color:rgb(var(--color-gray-default), 0.5)}:host(.has-value-40to30-negative) .icon{color:rgb(var(--color-gray-darker))}:host(.has-value-30to20-negative) .icon{color:rgb(var(--color-gray-darker))}:host(.has-value-20to10-negative) .icon{color:rgb(var(--color-gray-darker))}:host(.has-value-10to0-negative) .icon{color:rgb(var(--color-gray-darker))}:host(.has-value-0to10-positive) .icon{color:rgb(var(--color-gray-dark))}:host(.has-value-10to20-positive) .icon{color:rgb(var(--color-gray-dark))}:host(.has-value-20to30-positive) .icon{color:rgb(var(--color-gray-dark))}:host(.has-value-30to40-positive) .icon{color:rgb(var(--color-gray-dark))}:host(.has-value-200or-larger-negative) .icon{background-color:rgb(var(--color-red-darker));transform:rotate(90deg)}:host(.has-value-200to100-negative) .icon{background-color:rgb(var(--color-red-dark));transform:rotate(90deg)}:host(.has-value-100to90-negative) .icon{background-color:rgb(var(--color-red-dark));transform:rotate(90deg)}:host(.has-value-90to80-negative) .icon{background-color:rgb(var(--color-red-dark));transform:rotate(81deg)}:host(.has-value-80to70-negative) .icon{background-color:rgb(var(--color-red-default));transform:rotate(72deg)}:host(.has-value-70to60-negative) .icon{background-color:rgb(var(--color-red-default));transform:rotate(63deg)}:host(.has-value-60to50-negative) .icon{background-color:rgb(var(--color-coral-default));transform:rotate(54deg)}:host(.has-value-50to40-negative) .icon{background-color:rgb(var(--color-coral-default));transform:rotate(45deg)}:host(.has-value-40to30-negative) .icon{background-color:rgb(var(--color-orange-default));transform:rotate(36deg)}:host(.has-value-30to20-negative) .icon{background-color:rgb(var(--color-orange-default));transform:rotate(27deg)}:host(.has-value-20to10-negative) .icon{background-color:rgb(var(--color-amber-default));transform:rotate(18deg)}:host(.has-value-10to0-negative) .icon{background-color:rgb(var(--color-amber-default));transform:rotate(9deg)}:host(.has-value-0) .icon{background-color:rgb(var(--color-gray-default));transform:rotate(0deg)}:host(.has-value-0to10-positive) .icon{background-color:rgb(var(--color-yellow-default));transform:rotate(-9deg)}:host(.has-value-10to20-positive) .icon{background-color:rgb(var(--color-yellow-default));transform:rotate(-18deg)}:host(.has-value-20to30-positive) .icon{background-color:rgb(var(--color-grass-default));transform:rotate(-27deg)}:host(.has-value-30to40-positive) .icon{background-color:rgb(var(--color-grass-default));transform:rotate(-36deg)}:host(.has-value-40to50-positive) .icon{background-color:rgb(var(--color-lime-default));transform:rotate(-45deg)}:host(.has-value-50to60-positive) .icon{background-color:rgb(var(--color-lime-default));transform:rotate(-54deg)}:host(.has-value-60to70-positive) .icon{background-color:rgb(var(--color-teal-default));transform:rotate(-63deg)}:host(.has-value-70to80-positive) .icon{background-color:rgb(var(--color-teal-default));transform:rotate(-72deg)}:host(.has-value-80to90-positive) .icon{background-color:rgb(var(--color-teal-dark));transform:rotate(-81deg)}:host(.has-value-90to100-positive) .icon{background-color:rgb(var(--color-teal-dark));transform:rotate(-90deg)}:host(.has-value-100to200-positive) .icon{background-color:rgb(var(--color-teal-dark));transform:rotate(-90deg)}:host(.has-value-200or-larger-positive) .icon{background-color:rgb(var(--color-teal-darker));transform:rotate(-90deg)}:host(.has-value-0) .icon{background-color:rgb(var(--color-gray-default), 0.5);transform:rotate(0deg)}:host(.has-value-0) .icon polyline{color:transparent}:host(.has-value-200or-larger-negative) .icon:after,:host(.has-value-200or-larger-negative) .icon:before,:host(.has-value-200to100-negative) .icon:after,:host(.has-value-200to100-negative) .icon:before,:host(.has-value-100to200-positive) .icon:after,:host(.has-value-100to200-positive) .icon:before,:host(.has-value-200or-larger-positive) .icon:after,:host(.has-value-200or-larger-positive) .icon:before{transition:border-color 0.6s ease;content:"";position:absolute;inset:0;margin:auto;border:1px solid transparent;border-radius:50%}:host(.has-value-200or-larger-negative) .icon:before,:host(.has-value-200to100-negative) .icon:before,:host(.has-value-100to200-positive) .icon:before,:host(.has-value-200or-larger-positive) .icon:before{transform:scale(1.2)}:host(.has-value-200or-larger-negative) .icon:after,:host(.has-value-200to100-negative) .icon:after,:host(.has-value-100to200-positive) .icon:after,:host(.has-value-200or-larger-positive) .icon:after{transform:scale(1.4);opacity:0.4}:host(.has-value-200to100-negative) .icon:before,:host(.has-value-200or-larger-negative) .icon:before{border-color:rgb(var(--color-red-dark))}:host(.has-value-200or-larger-negative) .icon:after{border-color:rgb(var(--color-red-darker))}:host(.has-value-100to200-positive) .icon:before,:host(.has-value-200or-larger-positive) .icon:before{border-color:rgb(var(--color-teal-dark))}:host(.has-value-200or-larger-positive) .icon:after{border-color:rgb(var(--color-teal-darker))}.no-value{transform:translateY(0.5rem)}.growth-unit{padding-left:0.5rem;opacity:0.5}:host(limebb-trend-indicator:focus),:host(limebb-trend-indicator:focus-visible),:host(limebb-trend-indicator:focus-within){--limel-h-l-grid-template-rows-transition-speed:0.46s;--limel-h-l-grid-template-rows:1fr}:host(limebb-trend-indicator){--limel-h-l-grid-template-rows-transition-speed:0.3s;--limel-h-l-grid-template-rows:0fr}:host(limebb-trend-indicator:focus) limel-helper-line,:host(limebb-trend-indicator:focus-visible) limel-helper-line,:host(limebb-trend-indicator:focus-within) limel-helper-line,:host(limebb-trend-indicator:hover) limel-helper-line{will-change:grid-template-rows}'}},[1,"limebb-trend-indicator",{platform:[16],context:[16],value:[520],formerValue:[514,"former-value"],suffix:[513],label:[513],invalid:[516],required:[516],helperText:[513,"helper-text"],reducePresence:[516,"reduce-presence"]},void 0,{value:[{valueChanged:0}]}]),c=n,h=function(){"undefined"!=typeof customElements&&["limebb-trend-indicator"].forEach((o=>{"limebb-trend-indicator"===o&&(customElements.get(a(o))||customElements.define(a(o),n))}))};export{c as LimebbTrendIndicator,h as defineCustomElement}
@@ -1 +1 @@
1
- import{proxyCustomElement as e,HTMLElement as t,createEvent as i,h as s,transformTag as r}from"@stencil/core/internal/client";import{n as a}from"./index.esm.js";import{o as n,c as o,a as l}from"./filter-operators.js";import{d as h}from"./filter-condition-picker.js";const u=[{value:"string",text:"Text"},{value:"number",text:"Number"},{value:"date",text:"Date"},{value:"datetime",text:"Date & time"},{value:"time",text:"Time"}],d=[a.EQUALS,a.NOT_EQUALS,a.LESS,a.LESS_OR_EQUAL,a.GREATER,a.GREATER_OR_EQUAL],c=n(d),m={string:"string",number:"integer",date:"date",datetime:"date",time:"time"},v="__relative_offset__",p="__specific__",f=[{value:"$now",text:"Now"},{value:"$today",text:"Today"},{value:"$tomorrow",text:"Tomorrow"},{value:"$yesterday",text:"Yesterday"},{value:"$this_week",text:"This week"},{value:"$this_month",text:"This month"},{value:"$this_quarter",text:"This quarter"},{value:"$this_year",text:"This year"}],b=new Set(f.map((e=>e.value))),x=[{value:"next",text:"Next"},{value:"previous",text:"Previous"}],y=[{value:"day",text:"days"},{value:"week",text:"weeks"},{value:"month",text:"months"},{value:"quarter",text:"quarters"},{value:"year",text:"years"}],g=/^\$(next|previous)_(day|week|month|quarter|year)\((\d+)\)$/,k=new Set(["date","datetime","time"]),w=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.change=i(this,"change",7),this.value={},this.direction="next",this.unit="week",this.count=1,this.countInput="1",this.countInvalid=!1,this.handleTypeChange=e=>{var t,i;e.stopPropagation(),this.resetOperandState(),this.emit(this.currentOperator,void 0,null!==(i=null===(t=e.detail)||void 0===t?void 0:t.value)&&void 0!==i?i:"string")},this.handleConditionChange=e=>{e.stopPropagation();const t=o(e.detail);t&&this.emit(t,this.value.operand)},this.handleScalarOperandChange=e=>{e.stopPropagation(),this.emit(this.currentOperator,this.parseScalarOperand(e.detail))},this.handleOperandKeyChange=e=>{var t;e.stopPropagation();const i=this.currentOperator,s=null===(t=e.detail)||void 0===t?void 0:t.value;if(this.operandKey=s,s!==v)return s===p?(this.specificDate||(this.specificDate=new Date),void this.emit(i,this.formatSpecific(this.specificDate))):void this.emit(i,s||void 0);this.emit(i,this.relativeOffsetToken())},this.handleDirectionChange=e=>{var t,i;e.stopPropagation(),this.direction=null!==(i=null===(t=e.detail)||void 0===t?void 0:t.value)&&void 0!==i?i:"next",this.emitRelativeOffset()},this.handleUnitChange=e=>{var t,i;e.stopPropagation(),this.unit=null!==(i=null===(t=e.detail)||void 0===t?void 0:t.value)&&void 0!==i?i:"week",this.emitRelativeOffset()},this.handleCountChange=e=>{e.stopPropagation(),this.countInput=e.detail+"";const t=Number.parseInt(this.countInput,10);Number.isNaN(t)||t<1?this.countInvalid=!0:(this.countInvalid=!1,this.count=t,this.emitRelativeOffset())},this.handleSpecificDateChange=e=>{e.stopPropagation();const t=this.currentOperator,i=e.detail instanceof Date?e.detail:void 0;this.specificDate=i,this.emit(t,i?this.formatSpecific(i):void 0)}}componentWillLoad(){this.syncFromValue(this.value)}onValueChange(e){this.syncFromValue(e)}get valueType(){var e;return null!==(e=this.value.valueType)&&void 0!==e?e:"string"}get currentOperator(){var e;return null!==(e=this.value.operator)&&void 0!==e?e:d[0]}render(){const e=u.find((e=>e.value===this.valueType));return s("div",{key:"ad1ae4fae21a213a2364a8b07db2ed157bf75419",class:"rule"},s("limel-select",{key:"e8dfb3d4499344b7f22b8cea5c40b59f4d15e21f",class:"type-select",label:"Compare as",options:u,value:e,onChange:this.handleTypeChange}),s("limebb-filter-condition-picker",{key:"777d5eece2263568bf46c4a5348befeec0fe2035",class:"operator-select",platform:this.platform,propertyType:m[this.valueType],conditions:c,value:l(this.currentOperator),onChange:this.handleConditionChange}),this.renderOperand())}renderOperand(){return k.has(this.valueType)?this.renderTemporalOperand():this.renderScalarInput()}renderScalarInput(){return s("limel-input-field",{class:"operand-input",label:"Compared with",type:"number"===this.valueType?"number":"text",value:void 0===this.value.operand?"":this.value.operand+"",onChange:this.handleScalarOperandChange})}renderTemporalOperand(){const e=this.operandOptions(),t=e.find((e=>e.value===this.operandKey));return[s("limel-select",{key:"operand-select",class:"operand-select",label:"Compared with",options:e,value:t,onChange:this.handleOperandKeyChange}),this.renderTemporalSubControl()]}operandOptions(){if("time"===this.valueType)return[{value:"$now",text:"Now"},{value:p,text:"Specific time…"}];const e="datetime"===this.valueType?"Specific date & time…":"Specific date…";return[..."date"===this.valueType?f.filter((e=>"$now"!==e.value)):f,{value:v,text:"Relative offset…"},{value:p,text:e}]}renderTemporalSubControl(){return this.operandKey===v?this.renderOffsetBuilder():this.operandKey===p?this.renderDatePicker():null}renderOffsetBuilder(){const e=x.find((e=>e.value===this.direction)),t=y.find((e=>e.value===this.unit));return s("div",{key:"offset-builder",class:"offset-builder"},s("limel-select",{class:"offset-direction",options:x,value:e,onChange:this.handleDirectionChange}),s("limel-input-field",{class:"offset-count",label:"Amount",type:"number",required:!0,invalid:this.countInvalid,value:this.countInput,onChange:this.handleCountChange}),s("limel-select",{class:"offset-unit",options:y,value:t,onChange:this.handleUnitChange}))}renderDatePicker(){return s("limel-date-picker",{key:"specific-picker",class:"operand-picker",label:"Compared with",type:this.valueType,value:this.specificDate,onChange:this.handleSpecificDateChange})}emitRelativeOffset(){this.emit(this.currentOperator,this.relativeOffsetToken())}relativeOffsetToken(){return`$${this.direction}_${this.unit}(${this.count})`}parseScalarOperand(e){const t=e+"";if(""===t.trim())return;if("number"!==this.valueType)return t;const i=Number(t);return Number.isNaN(i)?void 0:i}formatSpecific(e){return"datetime"===this.valueType?e.toISOString():"time"===this.valueType?`${$(e.getHours())}:${$(e.getMinutes())}:${$(e.getSeconds())}`:`${e.getFullYear()}-${$(e.getMonth()+1)}-${$(e.getDate())}`}emit(e,t,i=this.valueType){const s={valueType:i};e&&(s.operator=e),void 0!==t&&(s.operand=t),this.change.emit(s)}resetOperandState(){this.operandKey=void 0,this.specificDate=void 0,this.direction="next",this.unit="week",this.count=1,this.countInput="1",this.countInvalid=!1}syncFromValue(e){const t=null==e?void 0:e.operand;if("string"!=typeof t||""===t)return;if(!k.has(this.valueType))return void(this.operandKey=void 0);const i=g.exec(t);if(i){const[,e,t,s]=i;return this.operandKey=v,this.direction=e,this.unit=t,this.count=Number(s),this.countInput=s,void(this.countInvalid=!1)}b.has(t)?this.operandKey=t:(this.operandKey=p,this.specificDate=this.parseSpecific(t))}parseSpecific(e){const t=new Date(this.specificDateText(e));return Number.isNaN(t.getTime())?void 0:t}specificDateText(e){return"time"===this.valueType?"1970-01-01T"+e:"date"===this.valueType?e+"T00:00:00":e}static get watchers(){return{value:[{onValueChange:0}]}}static get style(){return":host{display:block}.rule{display:grid;gap:0.5rem;grid-template-columns:repeat(auto-fit, minmax(12rem, 1fr))}.offset-builder{display:flex;gap:0.5rem;align-items:flex-end;grid-column:1/-1}.offset-builder .offset-count{max-width:6rem}"}},[1,"limebb-value-comparison-editor",{value:[16],platform:[16],operandKey:[32],direction:[32],unit:[32],count:[32],countInput:[32],countInvalid:[32],specificDate:[32]},void 0,{value:[{onValueChange:0}]}]);function $(e){return(e+"").padStart(2,"0")}const T=w,C=function(){"undefined"!=typeof customElements&&["limebb-value-comparison-editor","limebb-filter-condition-picker"].forEach((e=>{switch(e){case"limebb-value-comparison-editor":customElements.get(r(e))||customElements.define(r(e),w);break;case"limebb-filter-condition-picker":customElements.get(r(e))||h()}}))};export{T as LimebbValueComparisonEditor,C as defineCustomElement}
1
+ import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as s,transformTag as r}from"@stencil/core/internal/client";import{o as a}from"./index.esm.js";import{o as n,c as o,a as l}from"./filter-operators.js";import{d as h}from"./filter-condition-picker.js";const u=[{value:"string",text:"Text"},{value:"number",text:"Number"},{value:"date",text:"Date"},{value:"datetime",text:"Date & time"},{value:"time",text:"Time"}],d=[a.EQUALS,a.NOT_EQUALS,a.LESS,a.LESS_OR_EQUAL,a.GREATER,a.GREATER_OR_EQUAL],c=n(d),m={string:"string",number:"integer",date:"date",datetime:"date",time:"time"},v="__relative_offset__",p="__specific__",f=[{value:"$now",text:"Now"},{value:"$today",text:"Today"},{value:"$tomorrow",text:"Tomorrow"},{value:"$yesterday",text:"Yesterday"},{value:"$this_week",text:"This week"},{value:"$this_month",text:"This month"},{value:"$this_quarter",text:"This quarter"},{value:"$this_year",text:"This year"}],b=new Set(f.map((t=>t.value))),x=[{value:"next",text:"Next"},{value:"previous",text:"Previous"}],y=[{value:"day",text:"days"},{value:"week",text:"weeks"},{value:"month",text:"months"},{value:"quarter",text:"quarters"},{value:"year",text:"years"}],g=/^\$(next|previous)_(day|week|month|quarter|year)\((\d+)\)$/,k=new Set(["date","datetime","time"]),w=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.change=i(this,"change",7),this.value={},this.direction="next",this.unit="week",this.count=1,this.countInput="1",this.countInvalid=!1,this.handleTypeChange=t=>{var e,i;t.stopPropagation(),this.resetOperandState(),this.emit(this.currentOperator,void 0,null!==(i=null===(e=t.detail)||void 0===e?void 0:e.value)&&void 0!==i?i:"string")},this.handleConditionChange=t=>{t.stopPropagation();const e=o(t.detail);e&&this.emit(e,this.value.operand)},this.handleScalarOperandChange=t=>{t.stopPropagation(),this.emit(this.currentOperator,this.parseScalarOperand(t.detail))},this.handleOperandKeyChange=t=>{var e;t.stopPropagation();const i=this.currentOperator,s=null===(e=t.detail)||void 0===e?void 0:e.value;if(this.operandKey=s,s!==v)return s===p?(this.specificDate||(this.specificDate=new Date),void this.emit(i,this.formatSpecific(this.specificDate))):void this.emit(i,s||void 0);this.emit(i,this.relativeOffsetToken())},this.handleDirectionChange=t=>{var e,i;t.stopPropagation(),this.direction=null!==(i=null===(e=t.detail)||void 0===e?void 0:e.value)&&void 0!==i?i:"next",this.emitRelativeOffset()},this.handleUnitChange=t=>{var e,i;t.stopPropagation(),this.unit=null!==(i=null===(e=t.detail)||void 0===e?void 0:e.value)&&void 0!==i?i:"week",this.emitRelativeOffset()},this.handleCountChange=t=>{t.stopPropagation(),this.countInput=t.detail+"";const e=Number.parseInt(this.countInput,10);Number.isNaN(e)||e<1?this.countInvalid=!0:(this.countInvalid=!1,this.count=e,this.emitRelativeOffset())},this.handleSpecificDateChange=t=>{t.stopPropagation();const e=this.currentOperator,i=t.detail instanceof Date?t.detail:void 0;this.specificDate=i,this.emit(e,i?this.formatSpecific(i):void 0)}}componentWillLoad(){this.syncFromValue(this.value)}onValueChange(t){this.syncFromValue(t)}get valueType(){var t;return null!==(t=this.value.valueType)&&void 0!==t?t:"string"}get currentOperator(){var t;return null!==(t=this.value.operator)&&void 0!==t?t:d[0]}render(){const t=u.find((t=>t.value===this.valueType));return s("div",{key:"46633e3dd6527173fdb2a54f50e7844175dbbbe5",class:"rule"},s("limel-select",{key:"98f82c22a21840061c57a942c273b85416c539cb",class:"type-select",label:"Compare as",options:u,value:t,onChange:this.handleTypeChange}),s("limebb-filter-condition-picker",{key:"dac247e83cb2fac41b0e6fdb49f070d5c1b18081",class:"operator-select",platform:this.platform,propertyType:m[this.valueType],conditions:c,value:l(this.currentOperator),onChange:this.handleConditionChange}),this.renderOperand())}renderOperand(){return k.has(this.valueType)?this.renderTemporalOperand():this.renderScalarInput()}renderScalarInput(){return s("limel-input-field",{class:"operand-input",label:"Compared with",type:"number"===this.valueType?"number":"text",value:void 0===this.value.operand?"":this.value.operand+"",onChange:this.handleScalarOperandChange})}renderTemporalOperand(){const t=this.operandOptions(),e=t.find((t=>t.value===this.operandKey));return[s("limel-select",{key:"operand-select",class:"operand-select",label:"Compared with",options:t,value:e,onChange:this.handleOperandKeyChange}),this.renderTemporalSubControl()]}operandOptions(){if("time"===this.valueType)return[{value:"$now",text:"Now"},{value:p,text:"Specific time…"}];const t="datetime"===this.valueType?"Specific date & time…":"Specific date…";return[..."date"===this.valueType?f.filter((t=>"$now"!==t.value)):f,{value:v,text:"Relative offset…"},{value:p,text:t}]}renderTemporalSubControl(){return this.operandKey===v?this.renderOffsetBuilder():this.operandKey===p?this.renderDatePicker():null}renderOffsetBuilder(){const t=x.find((t=>t.value===this.direction)),e=y.find((t=>t.value===this.unit));return s("div",{key:"offset-builder",class:"offset-builder"},s("limel-select",{class:"offset-direction",options:x,value:t,onChange:this.handleDirectionChange}),s("limel-input-field",{class:"offset-count",label:"Amount",type:"number",required:!0,invalid:this.countInvalid,value:this.countInput,onChange:this.handleCountChange}),s("limel-select",{class:"offset-unit",options:y,value:e,onChange:this.handleUnitChange}))}renderDatePicker(){return s("limel-date-picker",{key:"specific-picker",class:"operand-picker",label:"Compared with",type:this.valueType,value:this.specificDate,onChange:this.handleSpecificDateChange})}emitRelativeOffset(){this.emit(this.currentOperator,this.relativeOffsetToken())}relativeOffsetToken(){return`$${this.direction}_${this.unit}(${this.count})`}parseScalarOperand(t){const e=t+"";if(""===e.trim())return;if("number"!==this.valueType)return e;const i=Number(e);return Number.isNaN(i)?void 0:i}formatSpecific(t){return"datetime"===this.valueType?t.toISOString():"time"===this.valueType?`${$(t.getHours())}:${$(t.getMinutes())}:${$(t.getSeconds())}`:`${t.getFullYear()}-${$(t.getMonth()+1)}-${$(t.getDate())}`}emit(t,e,i=this.valueType){const s={valueType:i};t&&(s.operator=t),void 0!==e&&(s.operand=e),this.change.emit(s)}resetOperandState(){this.operandKey=void 0,this.specificDate=void 0,this.direction="next",this.unit="week",this.count=1,this.countInput="1",this.countInvalid=!1}syncFromValue(t){const e=null==t?void 0:t.operand;if("string"!=typeof e||""===e)return;if(!k.has(this.valueType))return void(this.operandKey=void 0);const i=g.exec(e);if(i){const[,t,e,s]=i;return this.operandKey=v,this.direction=t,this.unit=e,this.count=Number(s),this.countInput=s,void(this.countInvalid=!1)}b.has(e)?this.operandKey=e:(this.operandKey=p,this.specificDate=this.parseSpecific(e))}parseSpecific(t){const e=new Date(this.specificDateText(t));return Number.isNaN(e.getTime())?void 0:e}specificDateText(t){return"time"===this.valueType?"1970-01-01T"+t:"date"===this.valueType?t+"T00:00:00":t}static get watchers(){return{value:[{onValueChange:0}]}}static get style(){return":host{display:block}.rule{display:grid;gap:0.5rem;grid-template-columns:repeat(auto-fit, minmax(12rem, 1fr))}.offset-builder{display:flex;gap:0.5rem;align-items:flex-end;grid-column:1/-1}.offset-builder .offset-count{max-width:6rem}"}},[1,"limebb-value-comparison-editor",{value:[16],platform:[16],operandKey:[32],direction:[32],unit:[32],count:[32],countInput:[32],countInvalid:[32],specificDate:[32]},void 0,{value:[{onValueChange:0}]}]);function $(t){return(t+"").padStart(2,"0")}const T=w,C=function(){"undefined"!=typeof customElements&&["limebb-value-comparison-editor","limebb-filter-condition-picker"].forEach((t=>{switch(t){case"limebb-value-comparison-editor":customElements.get(r(t))||customElements.define(r(t),w);break;case"limebb-filter-condition-picker":customElements.get(r(t))||h()}}))};export{T as LimebbValueComparisonEditor,C as defineCustomElement}
@@ -1 +1 @@
1
- import{proxyCustomElement as e,HTMLElement as t,createEvent as i,h as s,transformTag as l}from"@stencil/core/internal/client";import{b as o}from"./index.esm.js";import{g as n}from"./limetype.js";import{i as r}from"./non-null.js";import{b as a}from"./_baseIsEqual.js";import{i as m,a as d,b as h}from"./_MapCache.js";function p(e){return"string"==typeof e||!d(e)&&m(e)&&"[object String]"==h(e)}const u=["string","text","phone","integer","decimal","percent","time","date","year","quarter","month","yesno","link","user","xml","option","set","file","system"],f=u.filter((e=>"system"!==e));f.push("belongsto","hasone","hasmany","hasandbelongstomany");const c=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.change=i(this,"change",7),this.propertyFields=[],this.fieldName="limetype",this.handleChange=e=>{e.stopPropagation();let t="";e.detail&&"value"in e.detail&&(t=e.detail.value),this.change.emit(t||void 0)}}componentWillLoad(){const e=this.platform.get(o.Application).getLanguage();this.collator=new Intl.Collator(e,{numeric:!0,sensitivity:"base"})}componentShouldUpdate(e,t,i){var s,l,o,n;return"formInfo"!==i||(o=null===(s=null==e?void 0:e.schema)||void 0===s?void 0:s.oneOf,n=null===(l=null==t?void 0:t.schema)||void 0===l?void 0:l.oneOf,!a(o,n))}render(){var e;const t=this.getLimeTypes().map(v);t.sort(((e,t)=>this.collator.compare(e.text,t.text)));let i=t.find((e=>e.value===this.value)),l=this.invalid;return this.value&&!i&&(l=!0,t.unshift({text:(null===(e=this.limeTypeRepository.getLimeType(this.value))||void 0===e?void 0:e.localname.singular)||this.value,value:this.value}),i=t[0]),t.unshift({text:"",value:""}),s("limel-select",{key:"4c17fbdd5760fcb83fef57f7204df42c91f70f7f",label:this.label,options:t,value:i,required:this.required,helperText:this.helperText,invalid:l,disabled:this.disabled||this.readonly,onChange:this.handleChange})}componentWillRender(){this.updatePropertyFields(this.value||"")}getLimeTypes(){var e,t;let i=this.limetypes;return(null===(t=null===(e=this.formInfo)||void 0===e?void 0:e.schema)||void 0===t?void 0:t.oneOf)&&(i=this.formInfo.schema.oneOf.map((e=>e.const)).filter(p)),i?i.map((e=>this.limeTypeRepository.getLimeType(e))).filter(r):this.limeTypeRepository.getLimeTypes()}updatePropertyFields(e){for(const t of this.propertyFields)t.limetype=e,t.allowedPropertyTypes===u&&(t.allowedPropertyTypes=f)}get limeTypeRepository(){return this.platform.get(o.LimeTypeRepository)}},[0,"limebb-limetype-field",{platform:[16],context:[16],label:[513],required:[516],readonly:[516],disabled:[516],value:[513],helperText:[513,"helper-text"],invalid:[4],limetypes:[16],propertyFields:[16],fieldName:[1,"field-name"],formInfo:[16]}]),v=e=>({text:e.localname.singular,value:e.name,icon:n(e)});function y(){"undefined"!=typeof customElements&&["limebb-limetype-field"].forEach((e=>{"limebb-limetype-field"===e&&(customElements.get(l(e))||customElements.define(l(e),c))}))}export{c as L,y as d}
1
+ import{proxyCustomElement as e,HTMLElement as t,createEvent as i,h as s,transformTag as l}from"@stencil/core/internal/client";import{n as o}from"./index.esm.js";import{g as n}from"./limetype.js";import{i as r}from"./non-null.js";import{b as a}from"./_baseIsEqual.js";import{i as m,a as d,b as h}from"./_MapCache.js";function p(e){return"string"==typeof e||!d(e)&&m(e)&&"[object String]"==h(e)}const u=["string","text","phone","integer","decimal","percent","time","date","year","quarter","month","yesno","link","user","xml","option","set","file","system"],f=u.filter((e=>"system"!==e));f.push("belongsto","hasone","hasmany","hasandbelongstomany");const c=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.change=i(this,"change",7),this.propertyFields=[],this.fieldName="limetype",this.handleChange=e=>{e.stopPropagation();let t="";e.detail&&"value"in e.detail&&(t=e.detail.value),this.change.emit(t||void 0)}}componentWillLoad(){const e=this.platform.get(o.Application).getLanguage();this.collator=new Intl.Collator(e,{numeric:!0,sensitivity:"base"})}componentShouldUpdate(e,t,i){var s,l,o,n;return"formInfo"!==i||(o=null===(s=null==e?void 0:e.schema)||void 0===s?void 0:s.oneOf,n=null===(l=null==t?void 0:t.schema)||void 0===l?void 0:l.oneOf,!a(o,n))}render(){var e;const t=this.getLimeTypes().map(v);t.sort(((e,t)=>this.collator.compare(e.text,t.text)));let i=t.find((e=>e.value===this.value)),l=this.invalid;return this.value&&!i&&(l=!0,t.unshift({text:(null===(e=this.limeTypeRepository.getLimeType(this.value))||void 0===e?void 0:e.localname.singular)||this.value,value:this.value}),i=t[0]),t.unshift({text:"",value:""}),s("limel-select",{key:"4c17fbdd5760fcb83fef57f7204df42c91f70f7f",label:this.label,options:t,value:i,required:this.required,helperText:this.helperText,invalid:l,disabled:this.disabled||this.readonly,onChange:this.handleChange})}componentWillRender(){this.updatePropertyFields(this.value||"")}getLimeTypes(){var e,t;let i=this.limetypes;return(null===(t=null===(e=this.formInfo)||void 0===e?void 0:e.schema)||void 0===t?void 0:t.oneOf)&&(i=this.formInfo.schema.oneOf.map((e=>e.const)).filter(p)),i?i.map((e=>this.limeTypeRepository.getLimeType(e))).filter(r):this.limeTypeRepository.getLimeTypes()}updatePropertyFields(e){for(const t of this.propertyFields)t.limetype=e,t.allowedPropertyTypes===u&&(t.allowedPropertyTypes=f)}get limeTypeRepository(){return this.platform.get(o.LimeTypeRepository)}},[0,"limebb-limetype-field",{platform:[16],context:[16],label:[513],required:[516],readonly:[516],disabled:[516],value:[513],helperText:[513,"helper-text"],invalid:[4],limetypes:[16],propertyFields:[16],fieldName:[1,"field-name"],formInfo:[16]}]),v=e=>({text:e.localname.singular,value:e.name,icon:n(e)});function y(){"undefined"!=typeof customElements&&["limebb-limetype-field"].forEach((e=>{"limebb-limetype-field"===e&&(customElements.get(l(e))||customElements.define(l(e),c))}))}export{c as L,y as d}
@@ -1 +1 @@
1
- import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as r,Host as o,transformTag as n}from"@stencil/core/internal/client";import{b as a}from"./index.esm.js";const s=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.interact=i(this,"interact",7),this.handleClick=()=>{this.isItemClickable()&&this.handleNotificationListItemClick()},this.handleKeyDown=t=>{this.isItemClickable()&&"Enter"===t.key&&this.handleNotificationListItemClick()},this.renderHeading=()=>{if(!this.item.heading)return;if(!this.item.author)return r("limel-markdown",{value:this.translator.get(this.item.heading)});const t=this.getAuthorLink(),e=this.translator.get(this.item.heading,{author:t});return r("limel-markdown",{class:"heading",value:e})},this.createMenuItem=t=>{var e,i;return"separator"in t?t:{value:t,text:null!==(e=t.label)&&void 0!==e?e:"",secondaryText:t.description,disabled:t.disabled,icon:null!==(i=t.icon)&&void 0!==i?i:""}},this.handleMenuItemSelect=t=>{var e;t.stopPropagation();const i=null===(e=t.detail.value)||void 0===e?void 0:e.command;i&&this.commandbus.handle(i)},this.handleNotificationListItemClick=()=>{this.interact.emit(this.item)}}render(){var t,e;return r(o,{key:"478562eb1347b383b23e73f28f0143fceec96b7a",id:this.item.id,class:{"is-clickable":this.isItemClickable(),"is-read":!!(null===(t=this.item)||void 0===t?void 0:t.read),"is-selected":!!(null===(e=this.item)||void 0===e?void 0:e.selected)},onClick:this.handleClick,onKeyDown:this.handleKeyDown,tabindex:0},this.renderSource(),this.renderContent())}isItemClickable(){var t;return!!(null===(t=this.item)||void 0===t?void 0:t.clickable)}renderSource(){return r("div",{class:"header"},this.renderIcon(),this.renderCaption(),this.renderTimestamp(),this.renderUnpromotedActionsMenu())}renderIcon(){var t,e,i,o;if(this.item.icon)return r("limel-icon",{class:"icon",badge:!0,name:null!==(e=null===(t=this.item.icon)||void 0===t?void 0:t.name)&&void 0!==e?e:"dot_circle",style:{color:`${null===(i=this.item.icon)||void 0===i?void 0:i.color}`,"background-color":`${null===(o=this.item.icon)||void 0===o?void 0:o.backgroundColor}`}})}renderContent(){return r("div",{class:"content"},r("div",{class:"body"},this.renderHeadline(),this.renderValue()),this.renderAuthorPicture())}renderHeadline(){if(this.item.heading)return r("div",{class:"headline"},this.renderHeading())}getAuthorLink(){if(!this.item.author)return;if("string"==typeof this.item.author.name)return this.item.author.name;const{href:t,text:e}=this.item.author.name;return`[${e}](${t})`}renderAuthorPicture(){var t;if(null===(t=this.item.author)||void 0===t?void 0:t.picture)return r("img",{class:"author-avatar",loading:"lazy",src:this.item.author.picture})}renderCaption(){if(this.item.caption)return r("h2",{class:"caption"},this.item.caption)}renderValue(){if(this.item.value)return r("limel-markdown",{class:"body-text",value:this.item.value})}renderUnpromotedActionsMenu(){var t,e;if(!(null===(t=this.item.unpromotedActions)||void 0===t?void 0:t.length))return;const i=this.item.unpromotedActions.map(this.createMenuItem);return r("limel-menu",{class:"unpromoted-actions-menu",items:i,openDirection:"bottom-end",onSelect:this.handleMenuItemSelect},r("limel-icon-button",{icon:"menu_2",slot:"trigger",label:null===(e=this.translator)||void 0===e?void 0:e.get("webclient.more-actions")}))}renderTimestamp(){const t=this.item.timestamp;if(t)return r("span",{class:"timestamp"},this.dateTimeFormatter.format(t,"timeofday"))}get dateTimeFormatter(){return this.platform.get(a.DateTimeFormatter)}get translator(){var t;return null===(t=this.platform)||void 0===t?void 0:t.get(a.Translate)}get commandbus(){var t;return null===(t=this.platform)||void 0===t?void 0:t.get(a.CommandBus)}static get style(){return'@charset "UTF-8";*{box-sizing:border-box}:host(limebb-notification-item){isolation:isolate;position:relative;box-sizing:border-box;display:flex;flex-direction:column;gap:0.25rem;margin-left:0.5rem;border-radius:0.75rem;border:1px solid rgb(var(--contrast-500))}:host(limebb-notification-item):before{content:"";display:block;position:absolute;left:-1rem;top:0.85rem;border-radius:50%;height:0.5rem;width:0.5rem;transition:background-color 0.2s ease, scale 0.2s cubic-bezier(0.82, 0.3, 0.14, 1.36);scale:var(--limebb-notification-item-unread-badge-scale, 0.6);background-color:var(--limebb-notification-item-unread-badge-color, transparent)}:host(limebb-notification-item:hover) .timestamp{color:rgb(var(--contrast-1100))}:host(limebb-notification-item:hover) .body-text{opacity:1}.header{display:flex;align-items:center;gap:0.25rem;min-height:2rem;padding:0 0 0 0.25rem;margin-bottom:0.25rem}.header:not(:has(.icon)){padding-left:0.75rem}.header:not(:has(.unpromoted-actions-menu)){padding-right:0.5rem}.caption,.timestamp{font-size:0.75rem}.caption{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin:0;flex-grow:1;font-weight:600;color:rgb(var(--contrast-900))}.timestamp{flex-shrink:0;margin-left:auto;transition:color 0.4s ease, opacity 0.2s ease;color:rgb(var(--contrast-900))}.headline{display:flex;gap:0.25rem;align-items:center}.content{display:flex;min-width:0;gap:0.5rem;padding:0 0.75rem 0.5rem 0.75rem}.heading{display:-webkit-box;overflow:hidden;white-space:normal;-webkit-box-orient:vertical;-webkit-line-clamp:2;max-height:2.5rem;font-size:0.875rem;--markdown-hyperlink-color:var(--mdc-theme-primary);--markdown-hyperlink-color--hovered:rgb(var(--color-teal-light))}.body{display:flex;flex-direction:column;gap:0.5rem}.body-text{display:-webkit-box;overflow:hidden;white-space:normal;-webkit-box-orient:vertical;-webkit-line-clamp:3;max-height:4.25rem;transition:opacity 0.2s ease;opacity:0.7}.icon{--icon-background-color:var(--limebb-feed-background-color);flex-shrink:0;width:1.5rem;padding:0.125rem}.author-avatar{border-radius:50%;width:2rem;height:2rem;object-fit:cover;margin-top:auto;margin-right:-0.25rem;margin-left:auto;box-shadow:0 0 0 1px rgb(var(--contrast-600))}.author{font-weight:bold;text-decoration:none;white-space:nowrap}a.author{position:relative;cursor:pointer;transition:color 0.2s ease;color:var(--mdc-theme-primary)}a.author:before{transition:opacity 0.2s ease, transform 0.3s ease-out;content:"";position:absolute;inset:auto 0 0 0;width:calc(100% - 0.5rem);margin:auto;height:0.125rem;border-radius:1rem;background-color:currentColor;opacity:0;transform:scale(0.6)}a.author:hover{color:rgb(var(--color-teal-light))}a.author:hover:before{opacity:0.3;transform:scale(1)}limel-chip-set{--button-shadow-normal:none;margin-left:-1rem;margin-bottom:-0.5rem}'}},[1,"limebb-notification-item",{platform:[16],context:[16],item:[16]}]);function l(){"undefined"!=typeof customElements&&["limebb-notification-item"].forEach((t=>{"limebb-notification-item"===t&&(customElements.get(n(t))||customElements.define(n(t),s))}))}export{s as N,l as d}
1
+ import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as r,Host as o,transformTag as n}from"@stencil/core/internal/client";import{n as a}from"./index.esm.js";const s=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.interact=i(this,"interact",7),this.handleClick=()=>{this.isItemClickable()&&this.handleNotificationListItemClick()},this.handleKeyDown=t=>{this.isItemClickable()&&"Enter"===t.key&&this.handleNotificationListItemClick()},this.renderHeading=()=>{if(!this.item.heading)return;if(!this.item.author)return r("limel-markdown",{value:this.translator.get(this.item.heading)});const t=this.getAuthorLink(),e=this.translator.get(this.item.heading,{author:t});return r("limel-markdown",{class:"heading",value:e})},this.createMenuItem=t=>{var e,i;return"separator"in t?t:{value:t,text:null!==(e=t.label)&&void 0!==e?e:"",secondaryText:t.description,disabled:t.disabled,icon:null!==(i=t.icon)&&void 0!==i?i:""}},this.handleMenuItemSelect=t=>{var e;t.stopPropagation();const i=null===(e=t.detail.value)||void 0===e?void 0:e.command;i&&this.commandbus.handle(i)},this.handleNotificationListItemClick=()=>{this.interact.emit(this.item)}}render(){var t,e;return r(o,{key:"478562eb1347b383b23e73f28f0143fceec96b7a",id:this.item.id,class:{"is-clickable":this.isItemClickable(),"is-read":!!(null===(t=this.item)||void 0===t?void 0:t.read),"is-selected":!!(null===(e=this.item)||void 0===e?void 0:e.selected)},onClick:this.handleClick,onKeyDown:this.handleKeyDown,tabindex:0},this.renderSource(),this.renderContent())}isItemClickable(){var t;return!!(null===(t=this.item)||void 0===t?void 0:t.clickable)}renderSource(){return r("div",{class:"header"},this.renderIcon(),this.renderCaption(),this.renderTimestamp(),this.renderUnpromotedActionsMenu())}renderIcon(){var t,e,i,o;if(this.item.icon)return r("limel-icon",{class:"icon",badge:!0,name:null!==(e=null===(t=this.item.icon)||void 0===t?void 0:t.name)&&void 0!==e?e:"dot_circle",style:{color:`${null===(i=this.item.icon)||void 0===i?void 0:i.color}`,"background-color":`${null===(o=this.item.icon)||void 0===o?void 0:o.backgroundColor}`}})}renderContent(){return r("div",{class:"content"},r("div",{class:"body"},this.renderHeadline(),this.renderValue()),this.renderAuthorPicture())}renderHeadline(){if(this.item.heading)return r("div",{class:"headline"},this.renderHeading())}getAuthorLink(){if(!this.item.author)return;if("string"==typeof this.item.author.name)return this.item.author.name;const{href:t,text:e}=this.item.author.name;return`[${e}](${t})`}renderAuthorPicture(){var t;if(null===(t=this.item.author)||void 0===t?void 0:t.picture)return r("img",{class:"author-avatar",loading:"lazy",src:this.item.author.picture})}renderCaption(){if(this.item.caption)return r("h2",{class:"caption"},this.item.caption)}renderValue(){if(this.item.value)return r("limel-markdown",{class:"body-text",value:this.item.value})}renderUnpromotedActionsMenu(){var t,e;if(!(null===(t=this.item.unpromotedActions)||void 0===t?void 0:t.length))return;const i=this.item.unpromotedActions.map(this.createMenuItem);return r("limel-menu",{class:"unpromoted-actions-menu",items:i,openDirection:"bottom-end",onSelect:this.handleMenuItemSelect},r("limel-icon-button",{icon:"menu_2",slot:"trigger",label:null===(e=this.translator)||void 0===e?void 0:e.get("webclient.more-actions")}))}renderTimestamp(){const t=this.item.timestamp;if(t)return r("span",{class:"timestamp"},this.dateTimeFormatter.format(t,"timeofday"))}get dateTimeFormatter(){return this.platform.get(a.DateTimeFormatter)}get translator(){var t;return null===(t=this.platform)||void 0===t?void 0:t.get(a.Translate)}get commandbus(){var t;return null===(t=this.platform)||void 0===t?void 0:t.get(a.CommandBus)}static get style(){return'@charset "UTF-8";*{box-sizing:border-box}:host(limebb-notification-item){isolation:isolate;position:relative;box-sizing:border-box;display:flex;flex-direction:column;gap:0.25rem;margin-left:0.5rem;border-radius:0.75rem;border:1px solid rgb(var(--contrast-500))}:host(limebb-notification-item):before{content:"";display:block;position:absolute;left:-1rem;top:0.85rem;border-radius:50%;height:0.5rem;width:0.5rem;transition:background-color 0.2s ease, scale 0.2s cubic-bezier(0.82, 0.3, 0.14, 1.36);scale:var(--limebb-notification-item-unread-badge-scale, 0.6);background-color:var(--limebb-notification-item-unread-badge-color, transparent)}:host(limebb-notification-item:hover) .timestamp{color:rgb(var(--contrast-1100))}:host(limebb-notification-item:hover) .body-text{opacity:1}.header{display:flex;align-items:center;gap:0.25rem;min-height:2rem;padding:0 0 0 0.25rem;margin-bottom:0.25rem}.header:not(:has(.icon)){padding-left:0.75rem}.header:not(:has(.unpromoted-actions-menu)){padding-right:0.5rem}.caption,.timestamp{font-size:0.75rem}.caption{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin:0;flex-grow:1;font-weight:600;color:rgb(var(--contrast-900))}.timestamp{flex-shrink:0;margin-left:auto;transition:color 0.4s ease, opacity 0.2s ease;color:rgb(var(--contrast-900))}.headline{display:flex;gap:0.25rem;align-items:center}.content{display:flex;min-width:0;gap:0.5rem;padding:0 0.75rem 0.5rem 0.75rem}.heading{display:-webkit-box;overflow:hidden;white-space:normal;-webkit-box-orient:vertical;-webkit-line-clamp:2;max-height:2.5rem;font-size:0.875rem;--markdown-hyperlink-color:var(--mdc-theme-primary);--markdown-hyperlink-color--hovered:rgb(var(--color-teal-light))}.body{display:flex;flex-direction:column;gap:0.5rem}.body-text{display:-webkit-box;overflow:hidden;white-space:normal;-webkit-box-orient:vertical;-webkit-line-clamp:3;max-height:4.25rem;transition:opacity 0.2s ease;opacity:0.7}.icon{--icon-background-color:var(--limebb-feed-background-color);flex-shrink:0;width:1.5rem;padding:0.125rem}.author-avatar{border-radius:50%;width:2rem;height:2rem;object-fit:cover;margin-top:auto;margin-right:-0.25rem;margin-left:auto;box-shadow:0 0 0 1px rgb(var(--contrast-600))}.author{font-weight:bold;text-decoration:none;white-space:nowrap}a.author{position:relative;cursor:pointer;transition:color 0.2s ease;color:var(--mdc-theme-primary)}a.author:before{transition:opacity 0.2s ease, transform 0.3s ease-out;content:"";position:absolute;inset:auto 0 0 0;width:calc(100% - 0.5rem);margin:auto;height:0.125rem;border-radius:1rem;background-color:currentColor;opacity:0;transform:scale(0.6)}a.author:hover{color:rgb(var(--color-teal-light))}a.author:hover:before{opacity:0.3;transform:scale(1)}limel-chip-set{--button-shadow-normal:none;margin-left:-1rem;margin-bottom:-0.5rem}'}},[1,"limebb-notification-item",{platform:[16],context:[16],item:[16]}]);function l(){"undefined"!=typeof customElements&&["limebb-notification-item"].forEach((t=>{"limebb-notification-item"===t&&(customElements.get(n(t))||customElements.define(n(t),s))}))}export{s as N,l as d}
@@ -1 +1 @@
1
- import{proxyCustomElement as e,HTMLElement as r,h as a,Host as l,transformTag as t}from"@stencil/core/internal/client";import{b as i}from"./index.esm.js";import{g as o,n as s}from"./normalize-value.js";const n=1e-4,c=e(class extends r{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.rangeMax=100,this.rangeMin=0,this.multiplier=1,this.reducePresence=!0,this.displayPercentageColors=!1,this.locale="en",this.labelId="label-"+crypto.randomUUID(),this.helperTextId="helper-text-"+crypto.randomUUID(),this.zeroPointId="zero-point-"+crypto.randomUUID(),this.renderHelperLine=()=>{if(this.hasHelperText())return a("limel-helper-line",{helperTextId:this.helperTextId,helperText:this.helperText,invalid:this.invalid})},this.hasHelperText=()=>null!=this.helperText}valueChanged(e){this.numValue=this.parseValue(e)}componentWillLoad(){try{this.locale=this.platform.get(i.UserPreferencesRepository).get("locale"),this.numberFormat=new Intl.NumberFormat(this.locale)}catch(e){console.warn(`Could not get user's locale (${this.locale}), falling back to 'en'.`),this.locale="en",this.numberFormat=new Intl.NumberFormat("en")}this.numValue=this.parseValue(this.value)}componentDidLoad(){this.triggerRangeWarning()}componentWillUpdate(){this.triggerRangeWarning()}triggerRangeWarning(){this.rangeMin>=this.rangeMax&&console.warn(`[limebb-percentage-visualizer] Invalid range: rangeMin (${this.rangeMin}) must be less than rangeMax (${this.rangeMax}). Visualization may not appear as expected.`)}render(){const e=this.getNormalizedValue(),r=this.getZeroPointPosition();return a(l,{key:"235b934d22f3b44c3cd1f15be75080e797367c8c",class:this.getContainerClassList(),style:{"--limebb-percentage-visualizer-zero-point-position":`${r}%`,"--limebb-percentage-visualizer-width":`${Math.abs(e)}%`,"--limebb-percentage-visualizer-rotate":e>=0?"0deg":"180deg"}},a("limel-notched-outline",{key:"29e9cb044645d10cc1892f72a032f9484726caff",tabIndex:0,role:"meter","aria-valuemin":this.rangeMin,"aria-valuemax":this.rangeMax,"aria-valuenow":this.numValue,"aria-labelledby":this.labelId,"aria-describedby":this.helperTextId,label:this.label,labelId:this.labelId,invalid:this.invalid,required:this.required,hasValue:!0,hasFloatingLabel:!0,"aria-controls":this.helperTextId},a("div",{key:"917a08e65845ec178c8cefbcfc4bb202b3b7fca0",slot:"content"},this.renderVisualization())),this.renderHelperLine())}renderVisualization(){if(!this.reducePresence||0!==this.numValue&&this.hasValue())return this.hasValue()?[a("div",{class:"percentage-bar"},a("div",{class:"percentage-fill"}),this.renderZeroPoint()),a("span",{class:"percentage-text"},this.formatValue(this.numValue),a("span",{class:"percent-sign"},"%"))]:a("span",{class:"no-value"},"–")}renderZeroPoint(){if(!(this.rangeMin>=0||this.rangeMax<=0))return[a("div",{id:this.zeroPointId,class:"zero-point"}),a("limel-tooltip",{elementId:this.zeroPointId,openDirection:"top",label:"0"})]}hasValue(){return null!=this.value&&""!==this.value}getContainerClassList(){if(!this.hasValue())return;const e=this.roundValue(this.multiplyByMultiplier(this.numValue)),r=o(e);return Object.assign({},r&&{[r]:!0})}getZeroPointPosition(){const e=this.rangeMax-this.rangeMin;return e<=0?0:(0-this.rangeMin)/e*100}getNormalizedValue(){const e=this.roundValue(this.multiplyByMultiplier(this.numValue)),r=this.rangeMax-this.rangeMin;if(r<=0)return 0;const a=(0-this.rangeMin)/r*100;return e>=0?e/Math.max(this.rangeMax,n)*(100-a):e/Math.max(Math.abs(this.rangeMin),n)*a}multiplyByMultiplier(e){return e*this.multiplier}roundValue(e){return Math.round(10*e)/10}unifyMinusSign(e){return e.replaceAll("−","-")}convertToUnicodeMinus(e){return e.replaceAll("-","−")}parseValue(e){return"string"==typeof e?Number.parseFloat(s(this.unifyMinusSign(e),this.locale)):e}formatValue(e){const r=this.roundValue(this.multiplyByMultiplier(e)),a=this.numberFormat.format(r);return r<0?this.convertToUnicodeMinus(a):a}static get watchers(){return{value:[{valueChanged:0}]}}static get style(){return'@charset "UTF-8";*,::before,::after{box-sizing:border-box}:host(limebb-percentage-visualizer){width:100%}limel-notched-outline:not([invalid]:not([invalid=false])) .limel-notched-outline--outlines{--limel-notched-outline-border-color:transparent}div[slot=content]:focus{outline:none}div[slot=content]:focus-visible{outline:none;box-shadow:var(--shadow-depth-8-focused)}div[slot=content]{display:flex;align-items:center;gap:0.5rem;border-radius:inherit;background-color:transparent !important}:host(limebb-percentage-visualizer[invalid]:not([invalid=false])) div[slot=content]{border-color:rgb(var(--color-red-default))}:host(limebb-percentage-visualizer):has(label) div[slot=content]{min-height:2.5rem;padding:0 0.375rem 0 1rem}.percentage-text{flex-shrink:0;min-width:2.5rem}:host([range-min^="-"]) .percentage-text{min-width:3.75rem}.percent-sign{opacity:0.4}.zero-point{content:"";position:absolute;transform:translateX(-50%);left:var(--limebb-percentage-visualizer-zero-point-position);height:0.25rem;width:0.25rem;border-radius:50%;box-shadow:0 0 0 0.125rem var(--limebb-percentage-visualizer-zero-point-color, rgb(var(--contrast-1200), 0.3));background-color:var(--limebb-percentage-visualizer-zero-point-color, rgb(var(--contrast-200), 0.9))}.percentage-bar{overflow:hidden;flex-grow:1;position:relative;display:flex;align-items:center;height:0.5rem;min-width:2rem;border-radius:0.5rem;background-color:rgb(var(--contrast-800), 0.6)}.percentage-fill{transition:width 0.2s ease;position:absolute;margin:auto;left:var(--limebb-percentage-visualizer-zero-point-position, 0);rotate:var(--limebb-percentage-visualizer-rotate, 0deg);transform-origin:left center;width:var(--limebb-percentage-visualizer-width);height:100%;border-radius:0.5rem}:host(limebb-percentage-visualizer:focus),:host(limebb-percentage-visualizer:focus-visible),:host(limebb-percentage-visualizer:focus-within){--limel-h-l-grid-template-rows-transition-speed:0.46s;--limel-h-l-grid-template-rows:1fr}:host(limebb-percentage-visualizer){--limel-h-l-grid-template-rows-transition-speed:0.3s;--limel-h-l-grid-template-rows:0fr}:host(limebb-percentage-visualizer:focus) limel-helper-line,:host(limebb-percentage-visualizer:focus-visible) limel-helper-line,:host(limebb-percentage-visualizer:focus-within) limel-helper-line,:host(limebb-percentage-visualizer:hover) limel-helper-line{will-change:grid-template-rows}.percentage-fill{background-color:var(--percentage-visualizer-color, var(--limebb-percentage-visualizer-color, var(--mdc-theme-primary)))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-200or-larger-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-red-darker))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-200to100-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-red-dark))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-100to90-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-red-dark))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-90to80-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-red-dark))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-80to70-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-red-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-70to60-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-red-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-60to50-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-coral-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-50to40-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-coral-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-40to30-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-orange-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-30to20-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-orange-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-20to10-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-amber-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-10to0-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-amber-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-0) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--contrast-800))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-0to10-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-yellow-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-10to20-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-yellow-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-20to30-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-grass-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-30to40-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-grass-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-40to50-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-lime-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-50to60-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-lime-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-60to70-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-teal-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-70to80-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-teal-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-80to90-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-teal-dark))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-90to100-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-teal-dark))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-100to200-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-teal-dark))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-200or-larger-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-teal-darker))}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-0) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--contrast-800))}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-0to10-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--0to10)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-10to20-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--10to20)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-20to30-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--20to30)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-30to40-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--30to40)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-40to50-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--40to50)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-50to60-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--50to60)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-60to70-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--60to70)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-70to80-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--70to80)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-80to90-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--80to90)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-90to100-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--90to100)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-100to200-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-teal-dark))}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-200or-larger-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-teal-darker))}'}},[1,"limebb-percentage-visualizer",{platform:[16],context:[16],value:[520],rangeMax:[514,"range-max"],rangeMin:[514,"range-min"],multiplier:[514],label:[513],invalid:[516],required:[516],helperText:[513,"helper-text"],reducePresence:[516,"reduce-presence"],displayPercentageColors:[516,"display-percentage-colors"]},void 0,{value:[{valueChanged:0}]}]);function p(){"undefined"!=typeof customElements&&["limebb-percentage-visualizer"].forEach((e=>{"limebb-percentage-visualizer"===e&&(customElements.get(t(e))||customElements.define(t(e),c))}))}export{c as P,p as d}
1
+ import{proxyCustomElement as e,HTMLElement as r,h as a,Host as l,transformTag as t}from"@stencil/core/internal/client";import{n as i}from"./index.esm.js";import{g as o,n as s}from"./normalize-value.js";const n=1e-4,c=e(class extends r{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.rangeMax=100,this.rangeMin=0,this.multiplier=1,this.reducePresence=!0,this.displayPercentageColors=!1,this.locale="en",this.labelId="label-"+crypto.randomUUID(),this.helperTextId="helper-text-"+crypto.randomUUID(),this.zeroPointId="zero-point-"+crypto.randomUUID(),this.renderHelperLine=()=>{if(this.hasHelperText())return a("limel-helper-line",{helperTextId:this.helperTextId,helperText:this.helperText,invalid:this.invalid})},this.hasHelperText=()=>null!=this.helperText}valueChanged(e){this.numValue=this.parseValue(e)}componentWillLoad(){try{this.locale=this.platform.get(i.UserPreferencesRepository).get("locale"),this.numberFormat=new Intl.NumberFormat(this.locale)}catch(e){console.warn(`Could not get user's locale (${this.locale}), falling back to 'en'.`),this.locale="en",this.numberFormat=new Intl.NumberFormat("en")}this.numValue=this.parseValue(this.value)}componentDidLoad(){this.triggerRangeWarning()}componentWillUpdate(){this.triggerRangeWarning()}triggerRangeWarning(){this.rangeMin>=this.rangeMax&&console.warn(`[limebb-percentage-visualizer] Invalid range: rangeMin (${this.rangeMin}) must be less than rangeMax (${this.rangeMax}). Visualization may not appear as expected.`)}render(){const e=this.getNormalizedValue(),r=this.getZeroPointPosition();return a(l,{key:"235b934d22f3b44c3cd1f15be75080e797367c8c",class:this.getContainerClassList(),style:{"--limebb-percentage-visualizer-zero-point-position":`${r}%`,"--limebb-percentage-visualizer-width":`${Math.abs(e)}%`,"--limebb-percentage-visualizer-rotate":e>=0?"0deg":"180deg"}},a("limel-notched-outline",{key:"29e9cb044645d10cc1892f72a032f9484726caff",tabIndex:0,role:"meter","aria-valuemin":this.rangeMin,"aria-valuemax":this.rangeMax,"aria-valuenow":this.numValue,"aria-labelledby":this.labelId,"aria-describedby":this.helperTextId,label:this.label,labelId:this.labelId,invalid:this.invalid,required:this.required,hasValue:!0,hasFloatingLabel:!0,"aria-controls":this.helperTextId},a("div",{key:"917a08e65845ec178c8cefbcfc4bb202b3b7fca0",slot:"content"},this.renderVisualization())),this.renderHelperLine())}renderVisualization(){if(!this.reducePresence||0!==this.numValue&&this.hasValue())return this.hasValue()?[a("div",{class:"percentage-bar"},a("div",{class:"percentage-fill"}),this.renderZeroPoint()),a("span",{class:"percentage-text"},this.formatValue(this.numValue),a("span",{class:"percent-sign"},"%"))]:a("span",{class:"no-value"},"–")}renderZeroPoint(){if(!(this.rangeMin>=0||this.rangeMax<=0))return[a("div",{id:this.zeroPointId,class:"zero-point"}),a("limel-tooltip",{elementId:this.zeroPointId,openDirection:"top",label:"0"})]}hasValue(){return null!=this.value&&""!==this.value}getContainerClassList(){if(!this.hasValue())return;const e=this.roundValue(this.multiplyByMultiplier(this.numValue)),r=o(e);return Object.assign({},r&&{[r]:!0})}getZeroPointPosition(){const e=this.rangeMax-this.rangeMin;return e<=0?0:(0-this.rangeMin)/e*100}getNormalizedValue(){const e=this.roundValue(this.multiplyByMultiplier(this.numValue)),r=this.rangeMax-this.rangeMin;if(r<=0)return 0;const a=(0-this.rangeMin)/r*100;return e>=0?e/Math.max(this.rangeMax,n)*(100-a):e/Math.max(Math.abs(this.rangeMin),n)*a}multiplyByMultiplier(e){return e*this.multiplier}roundValue(e){return Math.round(10*e)/10}unifyMinusSign(e){return e.replaceAll("−","-")}convertToUnicodeMinus(e){return e.replaceAll("-","−")}parseValue(e){return"string"==typeof e?Number.parseFloat(s(this.unifyMinusSign(e),this.locale)):e}formatValue(e){const r=this.roundValue(this.multiplyByMultiplier(e)),a=this.numberFormat.format(r);return r<0?this.convertToUnicodeMinus(a):a}static get watchers(){return{value:[{valueChanged:0}]}}static get style(){return'@charset "UTF-8";*,::before,::after{box-sizing:border-box}:host(limebb-percentage-visualizer){width:100%}limel-notched-outline:not([invalid]:not([invalid=false])) .limel-notched-outline--outlines{--limel-notched-outline-border-color:transparent}div[slot=content]:focus{outline:none}div[slot=content]:focus-visible{outline:none;box-shadow:var(--shadow-depth-8-focused)}div[slot=content]{display:flex;align-items:center;gap:0.5rem;border-radius:inherit;background-color:transparent !important}:host(limebb-percentage-visualizer[invalid]:not([invalid=false])) div[slot=content]{border-color:rgb(var(--color-red-default))}:host(limebb-percentage-visualizer):has(label) div[slot=content]{min-height:2.5rem;padding:0 0.375rem 0 1rem}.percentage-text{flex-shrink:0;min-width:2.5rem}:host([range-min^="-"]) .percentage-text{min-width:3.75rem}.percent-sign{opacity:0.4}.zero-point{content:"";position:absolute;transform:translateX(-50%);left:var(--limebb-percentage-visualizer-zero-point-position);height:0.25rem;width:0.25rem;border-radius:50%;box-shadow:0 0 0 0.125rem var(--limebb-percentage-visualizer-zero-point-color, rgb(var(--contrast-1200), 0.3));background-color:var(--limebb-percentage-visualizer-zero-point-color, rgb(var(--contrast-200), 0.9))}.percentage-bar{overflow:hidden;flex-grow:1;position:relative;display:flex;align-items:center;height:0.5rem;min-width:2rem;border-radius:0.5rem;background-color:rgb(var(--contrast-800), 0.6)}.percentage-fill{transition:width 0.2s ease;position:absolute;margin:auto;left:var(--limebb-percentage-visualizer-zero-point-position, 0);rotate:var(--limebb-percentage-visualizer-rotate, 0deg);transform-origin:left center;width:var(--limebb-percentage-visualizer-width);height:100%;border-radius:0.5rem}:host(limebb-percentage-visualizer:focus),:host(limebb-percentage-visualizer:focus-visible),:host(limebb-percentage-visualizer:focus-within){--limel-h-l-grid-template-rows-transition-speed:0.46s;--limel-h-l-grid-template-rows:1fr}:host(limebb-percentage-visualizer){--limel-h-l-grid-template-rows-transition-speed:0.3s;--limel-h-l-grid-template-rows:0fr}:host(limebb-percentage-visualizer:focus) limel-helper-line,:host(limebb-percentage-visualizer:focus-visible) limel-helper-line,:host(limebb-percentage-visualizer:focus-within) limel-helper-line,:host(limebb-percentage-visualizer:hover) limel-helper-line{will-change:grid-template-rows}.percentage-fill{background-color:var(--percentage-visualizer-color, var(--limebb-percentage-visualizer-color, var(--mdc-theme-primary)))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-200or-larger-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-red-darker))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-200to100-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-red-dark))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-100to90-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-red-dark))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-90to80-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-red-dark))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-80to70-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-red-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-70to60-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-red-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-60to50-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-coral-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-50to40-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-coral-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-40to30-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-orange-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-30to20-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-orange-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-20to10-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-amber-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-10to0-negative) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-amber-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-0) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--contrast-800))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-0to10-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-yellow-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-10to20-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-yellow-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-20to30-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-grass-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-30to40-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-grass-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-40to50-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-lime-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-50to60-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-lime-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-60to70-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-teal-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-70to80-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-teal-default))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-80to90-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-teal-dark))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-90to100-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-teal-dark))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-100to200-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-teal-dark))}:host([range-min^="-"][display-percentage-colors]:not([display-percentage-colors=false]).has-value-200or-larger-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-teal-darker))}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-0) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--contrast-800))}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-0to10-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--0to10)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-10to20-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--10to20)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-20to30-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--20to30)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-30to40-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--30to40)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-40to50-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--40to50)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-50to60-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--50to60)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-60to70-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--60to70)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-70to80-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--70to80)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-80to90-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--80to90)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-90to100-positive) .percentage-fill{--limebb-percentage-visualizer-color:var(--color-percent--90to100)}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-100to200-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-teal-dark))}:host([display-percentage-colors]:not([display-percentage-colors=false]).has-value-200or-larger-positive) .percentage-fill{--limebb-percentage-visualizer-color:rgb(var(--color-teal-darker))}'}},[1,"limebb-percentage-visualizer",{platform:[16],context:[16],value:[520],rangeMax:[514,"range-max"],rangeMin:[514,"range-min"],multiplier:[514],label:[513],invalid:[516],required:[516],helperText:[513,"helper-text"],reducePresence:[516,"reduce-presence"],displayPercentageColors:[516,"display-percentage-colors"]},void 0,{value:[{valueChanged:0}]}]);function p(){"undefined"!=typeof customElements&&["limebb-percentage-visualizer"].forEach((e=>{"limebb-percentage-visualizer"===e&&(customElements.get(t(e))||customElements.define(t(e),c))}))}export{c as P,p as d}
@@ -1 +1 @@
1
- import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as s,transformTag as r}from"@stencil/core/internal/client";import{L as o,b as n}from"./index.esm.js";import{g as l}from"./limetype.js";function h(t){if(!(null==t?void 0:t.properties))return{};const e=Object.assign({},t.properties),i={id:"_id",timestamp:"_timestamp",descriptive:"_descriptive",createduser:"_createduser",createdtime:"_createdtime",updateduser:"_updateduser"};for(const[t,s]of Object.entries(i)){const i=e[t];i&&(e[s]=i,delete e[t])}return e}function c(t,e,i){if(!i||!e||!t)return;const s=i.split(".");let r,o=t[e];for(const t of s){if(!o)return;if(r=h(o)[t],!r)return;r.relation&&(o=r.relation.getLimetype())}return r}function a(t,e,i){if(!i||!e||!t)return{property:void 0};const s=i.split(".");let r,o=t[e];for(let t=0;t<s.length;t++){const e=s[t];if(!o)return{property:void 0};if(r=h(o)[e],!r)return{property:void 0,error:`Property '${e}' does not exist on limetype '${o.name}'`};if("hasmany"===r.type||"hasandbelongstomany"===r.type)return{property:void 0,error:`Cannot filter on many-relation '${s.slice(0,t+1).join(".")}'. Use a related limetype's filter instead.`};r.relation&&(o=r.relation.getLimetype())}return{property:r}}const u=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.change=i(this,"change",7),this.label="Property",this.required=!1,this.isOpen=!1,this.navigationPath="",this.menuItems=[],this.handleChipSetWrapperClick=t=>{t.stopPropagation()},this.handleChipSetFocus=()=>{this.isOpen||(this.navigationPath=this.value||"",this.loadMenuItems(),this.isOpen=!0)},this.handleChipSetBlur=()=>{var t;const e=document.activeElement;(null===(t=null==e?void 0:e.tagName)||void 0===t?void 0:t.startsWith("LIMEL-MENU"))||(this.isOpen=!1,this.navigationPath="")},this.handleSelect=t=>{t.stopPropagation();const e=t.detail.value;if(!e)return;const i=c(this.limetypes,this.limetype,e);(null==i?void 0:i.relation)?this.navigationPath=e:(this.change.emit(e),this.isOpen=!1,this.navigationPath="")},this.handleNavigateMenu=t=>{var e;t.stopPropagation(),(null===(e=t.detail)||void 0===e?void 0:e.value)&&(this.navigationPath=t.detail.value)},this.handleCancel=()=>{this.isOpen=!1,this.navigationPath=""},this.handleChipSetChange=t=>{t.stopPropagation();const e=t.detail;if(!e)return this.change.emit(""),void(this.navigationPath="");const i=Array.isArray(e)?e:[e];if(0===i.length)this.change.emit(""),this.navigationPath="";else{const t=i.at(-1);t&&this.change.emit(t.value),this.navigationPath=""}}}componentWillLoad(){const t=this.platform.get(n.Application).getLanguage();this.collator=new Intl.Collator(t,{numeric:!0,sensitivity:"base"})}render(){if(!this.limetype||!this.limetypes)return null;const t=this.getChipsForPath(this.navigationPath||this.value||"");return s("limel-menu",{items:this.menuItems,open:this.isOpen,emptyResultMessage:"No available properties",surfaceWidth:"inherit-from-trigger",openDirection:"bottom-end",onSelect:this.handleSelect,onNavigateMenu:this.handleNavigateMenu,onCancel:this.handleCancel},s("div",{slot:"trigger"},s("div",{onClick:this.handleChipSetWrapperClick},s("limel-chip-set",{type:"input",label:this.label,value:t,required:this.required,helperText:this.helperText,delimiter:"›",maxItems:1,onChange:this.handleChipSetChange,onFocus:this.handleChipSetFocus,onStopEdit:this.handleChipSetBlur}))))}loadMenuItems(){const t=this.getCurrentLimetype();this.menuItems=t?this.createMenuItems(t,""):[]}getCurrentLimetype(){if(!this.navigationPath)return this.limetypes[this.limetype];const t=c(this.limetypes,this.limetype,this.navigationPath);return(null==t?void 0:t.relation)?t.relation.getLimetype():this.limetypes[this.limetype]}createMenuItems(t,e){const i=[];if(!t)return i;const s=h(t);for(const[t,r]of Object.entries(s)){if("hasmany"===r.type||"hasandbelongstomany"===r.type)continue;const s=e?`${e}.${t}`:t;let o;if(r.relation&&r.relation){const t=r.relation.getLimetype();t&&(o=async()=>this.createMenuItems(t,s))}i.push({text:r.localname||t,secondaryText:this.getSecondaryText(r),icon:this.getIconForProperty(r),value:s,items:o})}return i.sort(((t,e)=>{var i,s;return this.collator.compare(null!==(i=t.text)&&void 0!==i?i:"",null!==(s=e.text)&&void 0!==s?s:"")})),0===i.length?[{text:"No available properties",value:"",disabled:!0}]:i}getSecondaryText(t){var e;if(t.relation){const i=t.relation.getLimetype();return(null===(e=null==i?void 0:i.localname)||void 0===e?void 0:e.singular)||"Object"}return t.type.charAt(0).toUpperCase()+t.type.slice(1)}getIconForProperty(t){return t.relation?l(t.relation.getLimetype()):{name:"dot_circle",color:"rgb(var(--color-gray-default))"}}getChipsForPath(t){if(!t)return[];const e=t.split("."),i=[];let s=this.limetypes[this.limetype],r="";for(const t of e){r=r?`${r}.${t}`:t;const e=h(s)[t];e&&(i.push({id:r,text:e.localname||t,icon:this.getIconForProperty(e),value:r}),e.relation&&(s=e.relation.getLimetype()))}return i}static get delegatesFocus(){return!0}static get style(){return":host(limebb-property-selector){display:block}limel-menu{display:block;width:100%}"}},[17,"limebb-property-selector",{platform:[16],context:[16],limetype:[1],value:[1],label:[1],required:[4],helperText:[1,"helper-text"],limetypes:[32],isOpen:[32],navigationPath:[32]}]);function d(){"undefined"!=typeof customElements&&["limebb-property-selector"].forEach((t=>{"limebb-property-selector"===t&&(customElements.get(r(t))||customElements.define(r(t),u))}))}!function(t,e,i,s){var r,o=arguments.length,n=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var l=t.length-1;l>=0;l--)(r=t[l])&&(n=(o<3?r(n):o>3?r(e,i,n):r(e,i))||n);o>3&&n&&Object.defineProperty(e,i,n)}([o()],u.prototype,"limetypes",void 0);export{u as P,h as a,d,c as g,a as v}
1
+ import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as s,transformTag as r}from"@stencil/core/internal/client";import{I as o,n}from"./index.esm.js";import{g as l}from"./limetype.js";function h(t){if(!(null==t?void 0:t.properties))return{};const e=Object.assign({},t.properties),i={id:"_id",timestamp:"_timestamp",descriptive:"_descriptive",createduser:"_createduser",createdtime:"_createdtime",updateduser:"_updateduser"};for(const[t,s]of Object.entries(i)){const i=e[t];i&&(e[s]=i,delete e[t])}return e}function c(t,e,i){if(!i||!e||!t)return;const s=i.split(".");let r,o=t[e];for(const t of s){if(!o)return;if(r=h(o)[t],!r)return;r.relation&&(o=r.relation.getLimetype())}return r}function a(t,e,i){if(!i||!e||!t)return{property:void 0};const s=i.split(".");let r,o=t[e];for(let t=0;t<s.length;t++){const e=s[t];if(!o)return{property:void 0};if(r=h(o)[e],!r)return{property:void 0,error:`Property '${e}' does not exist on limetype '${o.name}'`};if("hasmany"===r.type||"hasandbelongstomany"===r.type)return{property:void 0,error:`Cannot filter on many-relation '${s.slice(0,t+1).join(".")}'. Use a related limetype's filter instead.`};r.relation&&(o=r.relation.getLimetype())}return{property:r}}const u=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.change=i(this,"change",7),this.label="Property",this.required=!1,this.isOpen=!1,this.navigationPath="",this.menuItems=[],this.handleChipSetWrapperClick=t=>{t.stopPropagation()},this.handleChipSetFocus=()=>{this.isOpen||(this.navigationPath=this.value||"",this.loadMenuItems(),this.isOpen=!0)},this.handleChipSetBlur=()=>{var t;const e=document.activeElement;(null===(t=null==e?void 0:e.tagName)||void 0===t?void 0:t.startsWith("LIMEL-MENU"))||(this.isOpen=!1,this.navigationPath="")},this.handleSelect=t=>{t.stopPropagation();const e=t.detail.value;if(!e)return;const i=c(this.limetypes,this.limetype,e);(null==i?void 0:i.relation)?this.navigationPath=e:(this.change.emit(e),this.isOpen=!1,this.navigationPath="")},this.handleNavigateMenu=t=>{var e;t.stopPropagation(),(null===(e=t.detail)||void 0===e?void 0:e.value)&&(this.navigationPath=t.detail.value)},this.handleCancel=()=>{this.isOpen=!1,this.navigationPath=""},this.handleChipSetChange=t=>{t.stopPropagation();const e=t.detail;if(!e)return this.change.emit(""),void(this.navigationPath="");const i=Array.isArray(e)?e:[e];if(0===i.length)this.change.emit(""),this.navigationPath="";else{const t=i.at(-1);t&&this.change.emit(t.value),this.navigationPath=""}}}componentWillLoad(){const t=this.platform.get(n.Application).getLanguage();this.collator=new Intl.Collator(t,{numeric:!0,sensitivity:"base"})}render(){if(!this.limetype||!this.limetypes)return null;const t=this.getChipsForPath(this.navigationPath||this.value||"");return s("limel-menu",{items:this.menuItems,open:this.isOpen,emptyResultMessage:"No available properties",surfaceWidth:"inherit-from-trigger",openDirection:"bottom-end",onSelect:this.handleSelect,onNavigateMenu:this.handleNavigateMenu,onCancel:this.handleCancel},s("div",{slot:"trigger"},s("div",{onClick:this.handleChipSetWrapperClick},s("limel-chip-set",{type:"input",label:this.label,value:t,required:this.required,helperText:this.helperText,delimiter:"›",maxItems:1,onChange:this.handleChipSetChange,onFocus:this.handleChipSetFocus,onStopEdit:this.handleChipSetBlur}))))}loadMenuItems(){const t=this.getCurrentLimetype();this.menuItems=t?this.createMenuItems(t,""):[]}getCurrentLimetype(){if(!this.navigationPath)return this.limetypes[this.limetype];const t=c(this.limetypes,this.limetype,this.navigationPath);return(null==t?void 0:t.relation)?t.relation.getLimetype():this.limetypes[this.limetype]}createMenuItems(t,e){const i=[];if(!t)return i;const s=h(t);for(const[t,r]of Object.entries(s)){if("hasmany"===r.type||"hasandbelongstomany"===r.type)continue;const s=e?`${e}.${t}`:t;let o;if(r.relation&&r.relation){const t=r.relation.getLimetype();t&&(o=async()=>this.createMenuItems(t,s))}i.push({text:r.localname||t,secondaryText:this.getSecondaryText(r),icon:this.getIconForProperty(r),value:s,items:o})}return i.sort(((t,e)=>{var i,s;return this.collator.compare(null!==(i=t.text)&&void 0!==i?i:"",null!==(s=e.text)&&void 0!==s?s:"")})),0===i.length?[{text:"No available properties",value:"",disabled:!0}]:i}getSecondaryText(t){var e;if(t.relation){const i=t.relation.getLimetype();return(null===(e=null==i?void 0:i.localname)||void 0===e?void 0:e.singular)||"Object"}return t.type.charAt(0).toUpperCase()+t.type.slice(1)}getIconForProperty(t){return t.relation?l(t.relation.getLimetype()):{name:"dot_circle",color:"rgb(var(--color-gray-default))"}}getChipsForPath(t){if(!t)return[];const e=t.split("."),i=[];let s=this.limetypes[this.limetype],r="";for(const t of e){r=r?`${r}.${t}`:t;const e=h(s)[t];e&&(i.push({id:r,text:e.localname||t,icon:this.getIconForProperty(e),value:r}),e.relation&&(s=e.relation.getLimetype()))}return i}static get delegatesFocus(){return!0}static get style(){return":host(limebb-property-selector){display:block}limel-menu{display:block;width:100%}"}},[17,"limebb-property-selector",{platform:[16],context:[16],limetype:[1],value:[1],label:[1],required:[4],helperText:[1,"helper-text"],limetypes:[32],isOpen:[32],navigationPath:[32]}]);function d(){"undefined"!=typeof customElements&&["limebb-property-selector"].forEach((t=>{"limebb-property-selector"===t&&(customElements.get(r(t))||customElements.define(r(t),u))}))}!function(t,e,i,s){var r,o=arguments.length,n=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var l=t.length-1;l>=0;l--)(r=t[l])&&(n=(o<3?r(n):o>3?r(e,i,n):r(e,i))||n);o>3&&n&&Object.defineProperty(e,i,n)}([o()],u.prototype,"limetypes",void 0);export{u as P,h as a,d,c as g,a as v}
@@ -1 +1 @@
1
- import{proxyCustomElement as e,HTMLElement as t,createEvent as o,h as i,transformTag as r}from"@stencil/core/internal/client";import{T as s,b as n}from"./index.esm.js";import{L as l}from"./web-component-template.js";const a=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.negate=o(this,"negate",7),this.updateArgs=o(this,"updateArgs",7),this.deleteChip=o(this,"deleteChip",7),this.isNegated=!1,this.readonly=!1,this.disabled=!1,this.isMutable=!0,this.focusOnOpen=!1,this.handleNegateChange=e=>{e.stopPropagation(),this.negate.emit(e.detail)},this.handleArgsChange=e=>{e.stopPropagation(),this.updateArgs.emit(e.detail)},this.handleDelete=()=>{this.deleteChip.emit()}}render(){return i("div",{key:"abb754c8d327cc82b5d4e7e44154e937c3aeb0d2",class:"popover"},this.renderHeader(),this.renderBody())}renderHeader(){var e,t,o,r;const s=(null===(e=this.metadata)||void 0===e?void 0:e.title)?this.translator.get(this.metadata.title):null!==(o=null===(t=this.refNode)||void 0===t?void 0:t.id)&&void 0!==o?o:"";return i("limel-header",{class:"popover__header is-narrow",heading:s,icon:null===(r=this.metadata)||void 0===r?void 0:r.icon},this.renderHeaderActions())}renderHeaderActions(){return this.isMutable?i("div",{slot:"actions",class:"popover__header-actions"},i("limel-switch",{class:"popover__negate-switch",label:this.translator.get("webclient.rule-editor.negate"),value:this.isNegated,onChange:this.handleNegateChange}),i("limel-icon-button",{class:"popover__delete-button",icon:"trash",label:this.translator.get("webclient.rule-editor.delete"),onClick:this.handleDelete})):null}get translator(){return this.platform.get(n.Translate)}renderBody(){var e,t;const o=null===(e=this.metadata)||void 0===e?void 0:e.configComponent;return o?i("div",{class:"popover__body"},i(l,{platform:this.platform,context:this.context,name:o.name,props:Object.assign(Object.assign({},o.props),{value:null===(t=this.refNode)||void 0===t?void 0:t.args,readonly:this.readonly,disabled:this.disabled,focusOnOpen:this.focusOnOpen,onChange:this.handleArgsChange})})):null}static get style(){return":host{display:block}.popover{display:flex;flex-direction:column;min-width:24rem;background-color:rgb(var(--contrast-100));border:1px solid rgb(var(--contrast-700));border-radius:0.5rem;box-shadow:0 0.25rem 0.75rem rgba(0, 0, 0, 0.15);overflow:hidden}.popover__header{--header-background-color:rgba(var(--contrast-300));padding-right:0.5rem;gap:1rem}.popover__header-actions{display:grid;grid-auto-flow:column;grid-gap:0.75rem;padding:0.25rem;align-items:center}.popover__delete-button{color:rgb(var(--contrast-1100))}.popover__body{padding:1rem}"}},[1,"limebb-rule-chip-popover",{platform:[16],context:[16],refNode:[16],isNegated:[4,"is-negated"],metadata:[16],readonly:[4],disabled:[4],isMutable:[4,"is-mutable"],focusOnOpen:[4,"focus-on-open"]}]);function d(){"undefined"!=typeof customElements&&["limebb-rule-chip-popover"].forEach((e=>{"limebb-rule-chip-popover"===e&&(customElements.get(r(e))||customElements.define(r(e),a))}))}!function(e,t,o,i){var r,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,o,i);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(n=(s<3?r(n):s>3?r(t,o,n):r(t,o))||n);s>3&&n&&Object.defineProperty(t,o,n)}([s("context")],a.prototype,"context",void 0);export{a as R,d}
1
+ import{proxyCustomElement as e,HTMLElement as t,createEvent as o,h as i,transformTag as r}from"@stencil/core/internal/client";import{k as s,n}from"./index.esm.js";import{L as l}from"./web-component-template.js";const a=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.negate=o(this,"negate",7),this.updateArgs=o(this,"updateArgs",7),this.deleteChip=o(this,"deleteChip",7),this.isNegated=!1,this.readonly=!1,this.disabled=!1,this.isMutable=!0,this.focusOnOpen=!1,this.handleNegateChange=e=>{e.stopPropagation(),this.negate.emit(e.detail)},this.handleArgsChange=e=>{e.stopPropagation(),this.updateArgs.emit(e.detail)},this.handleDelete=()=>{this.deleteChip.emit()}}render(){return i("div",{key:"abb754c8d327cc82b5d4e7e44154e937c3aeb0d2",class:"popover"},this.renderHeader(),this.renderBody())}renderHeader(){var e,t,o,r;const s=(null===(e=this.metadata)||void 0===e?void 0:e.title)?this.translator.get(this.metadata.title):null!==(o=null===(t=this.refNode)||void 0===t?void 0:t.id)&&void 0!==o?o:"";return i("limel-header",{class:"popover__header is-narrow",heading:s,icon:null===(r=this.metadata)||void 0===r?void 0:r.icon},this.renderHeaderActions())}renderHeaderActions(){return this.isMutable?i("div",{slot:"actions",class:"popover__header-actions"},i("limel-switch",{class:"popover__negate-switch",label:this.translator.get("webclient.rule-editor.negate"),value:this.isNegated,onChange:this.handleNegateChange}),i("limel-icon-button",{class:"popover__delete-button",icon:"trash",label:this.translator.get("webclient.rule-editor.delete"),onClick:this.handleDelete})):null}get translator(){return this.platform.get(n.Translate)}renderBody(){var e,t;const o=null===(e=this.metadata)||void 0===e?void 0:e.configComponent;return o?i("div",{class:"popover__body"},i(l,{platform:this.platform,context:this.context,name:o.name,props:Object.assign(Object.assign({},o.props),{value:null===(t=this.refNode)||void 0===t?void 0:t.args,readonly:this.readonly,disabled:this.disabled,focusOnOpen:this.focusOnOpen,onChange:this.handleArgsChange})})):null}static get style(){return":host{display:block}.popover{display:flex;flex-direction:column;min-width:24rem;background-color:rgb(var(--contrast-100));border:1px solid rgb(var(--contrast-700));border-radius:0.5rem;box-shadow:0 0.25rem 0.75rem rgba(0, 0, 0, 0.15);overflow:hidden}.popover__header{--header-background-color:rgba(var(--contrast-300));padding-right:0.5rem;gap:1rem}.popover__header-actions{display:grid;grid-auto-flow:column;grid-gap:0.75rem;padding:0.25rem;align-items:center}.popover__delete-button{color:rgb(var(--contrast-1100))}.popover__body{padding:1rem}"}},[1,"limebb-rule-chip-popover",{platform:[16],context:[16],refNode:[16],isNegated:[4,"is-negated"],metadata:[16],readonly:[4],disabled:[4],isMutable:[4,"is-mutable"],focusOnOpen:[4,"focus-on-open"]}]);function d(){"undefined"!=typeof customElements&&["limebb-rule-chip-popover"].forEach((e=>{"limebb-rule-chip-popover"===e&&(customElements.get(r(e))||customElements.define(r(e),a))}))}!function(e,t,o,i){var r,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,o,i);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(n=(s<3?r(n):s>3?r(t,o,n):r(t,o))||n);s>3&&n&&Object.defineProperty(t,o,n)}([s("context")],a.prototype,"context",void 0);export{a as R,d}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Builds the contents URL for a stored file, relative to the application base.
3
+ *
4
+ * @param appName - the current application name
5
+ * @param fileId - the id of the file
6
+ * @returns the file contents URL
7
+ */
8
+ function getFileContentsUrl(appName, fileId) {
9
+ return `/${encodeURIComponent(appName)}/api/v1/file/${encodeURIComponent(fileId)}/contents/`;
10
+ }
11
+
12
+ export { getFileContentsUrl as g };