@gravitee/ui-components 3.25.3-typescript-8a53edf → 3.25.3-typescript-e7256ca

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 (370) hide show
  1. package/package.json +3 -4
  2. package/src/atoms/gv-autocomplete.d.ts +104 -0
  3. package/src/atoms/gv-autocomplete.js +1 -461
  4. package/src/atoms/gv-button.d.ts +109 -0
  5. package/src/atoms/gv-button.js +1 -410
  6. package/src/atoms/gv-checkbox.d.ts +114 -0
  7. package/src/atoms/gv-checkbox.js +1 -187
  8. package/src/atoms/gv-date-picker-calendar.d.ts +190 -0
  9. package/src/atoms/gv-date-picker-calendar.js +1 -894
  10. package/src/atoms/gv-date-picker-cell.d.ts +80 -0
  11. package/src/atoms/gv-date-picker-cell.js +1 -190
  12. package/src/atoms/gv-date-picker.d.ts +194 -0
  13. package/src/atoms/gv-date-picker.js +1 -671
  14. package/src/atoms/gv-file-upload.d.ts +64 -0
  15. package/src/atoms/gv-file-upload.js +1 -367
  16. package/src/atoms/gv-icon.d.ts +26 -0
  17. package/src/atoms/gv-icon.js +1 -103
  18. package/src/atoms/gv-image.d.ts +45 -0
  19. package/src/atoms/gv-image.js +1 -144
  20. package/src/atoms/gv-input-message.d.ts +20 -0
  21. package/src/atoms/gv-input-message.js +1 -84
  22. package/src/atoms/gv-input.d.ts +246 -0
  23. package/src/atoms/gv-input.js +1 -561
  24. package/src/atoms/gv-link.d.ts +67 -0
  25. package/src/atoms/gv-link.js +1 -210
  26. package/src/atoms/gv-message.d.ts +23 -0
  27. package/src/atoms/gv-message.js +1 -128
  28. package/src/atoms/gv-metric.d.ts +32 -0
  29. package/src/atoms/gv-metric.js +1 -117
  30. package/src/atoms/gv-relative-time.d.ts +45 -0
  31. package/src/atoms/gv-relative-time.js +1 -156
  32. package/src/atoms/gv-select-native.d.ts +174 -0
  33. package/src/atoms/gv-select-native.js +1 -388
  34. package/src/atoms/gv-select.d.ts +71 -0
  35. package/src/atoms/gv-select.js +1 -437
  36. package/src/atoms/gv-spinner.d.ts +10 -0
  37. package/src/atoms/gv-spinner.js +1 -57
  38. package/src/atoms/gv-state.d.ts +50 -0
  39. package/src/atoms/gv-state.js +1 -130
  40. package/src/atoms/gv-switch.d.ts +60 -0
  41. package/src/atoms/gv-switch.js +1 -243
  42. package/src/atoms/gv-tag.d.ts +69 -0
  43. package/src/atoms/gv-tag.js +1 -168
  44. package/src/atoms/gv-text.d.ts +110 -0
  45. package/src/atoms/gv-text.js +1 -168
  46. package/src/charts/gv-chart-bar.d.ts +50 -0
  47. package/src/charts/gv-chart-bar.js +1 -103
  48. package/src/charts/gv-chart-gauge.d.ts +58 -0
  49. package/src/charts/gv-chart-gauge.js +1 -100
  50. package/src/charts/gv-chart-histogram.d.ts +48 -0
  51. package/src/charts/gv-chart-histogram.js +1 -83
  52. package/src/charts/gv-chart-line.d.ts +52 -0
  53. package/src/charts/gv-chart-line.js +1 -224
  54. package/src/charts/gv-chart-map.d.ts +50 -0
  55. package/src/charts/gv-chart-map.js +1 -112
  56. package/src/charts/gv-chart-pie.d.ts +50 -0
  57. package/src/charts/gv-chart-pie.js +1 -91
  58. package/src/index.d.ts +77 -0
  59. package/src/index.js +1 -77
  60. package/src/lib/cron-expression.d.ts +1 -0
  61. package/src/lib/cron-expression.js +1 -205
  62. package/src/lib/date.d.ts +1 -0
  63. package/src/lib/date.js +1 -44
  64. package/src/lib/events.d.ts +1 -0
  65. package/src/lib/events.js +1 -26
  66. package/src/lib/http-client-schema-form.d.ts +68 -0
  67. package/src/lib/http-client-schema-form.js +1 -67
  68. package/src/lib/http.d.ts +222 -0
  69. package/src/lib/http.js +1 -237
  70. package/src/lib/i18n.d.ts +30 -0
  71. package/src/lib/i18n.js +1 -103
  72. package/src/lib/item.d.ts +12 -0
  73. package/src/lib/item.js +1 -118
  74. package/src/lib/properties.d.ts +42 -0
  75. package/src/lib/properties.js +1 -189
  76. package/src/lib/schema-form.d.ts +5 -0
  77. package/src/lib/schema-form.js +1 -44
  78. package/src/lib/studio.d.ts +2 -0
  79. package/src/lib/studio.js +1 -141
  80. package/src/lib/style.d.ts +6 -0
  81. package/src/lib/style.js +1 -41
  82. package/src/lib/text-format.d.ts +6 -0
  83. package/src/lib/text-format.js +1 -69
  84. package/src/lib/theme.d.ts +4 -0
  85. package/src/lib/theme.js +1 -63
  86. package/src/lib/utils.d.ts +9 -0
  87. package/src/lib/utils.js +1 -111
  88. package/src/mixins/chart-element.d.ts +39 -0
  89. package/src/mixins/chart-element.js +1 -165
  90. package/src/mixins/input-element.d.ts +64 -0
  91. package/src/mixins/input-element.js +1 -144
  92. package/src/mixins/item-resource.d.ts +56 -0
  93. package/src/mixins/item-resource.js +1 -120
  94. package/src/mixins/keyboard-element.d.ts +25 -0
  95. package/src/mixins/keyboard-element.js +1 -69
  96. package/src/mixins/update-after-browser.d.ts +11 -0
  97. package/src/mixins/update-after-browser.js +1 -30
  98. package/src/mixins/with-resize-observer.d.ts +12 -0
  99. package/src/mixins/with-resize-observer.js +1 -68
  100. package/src/mixins/with-skeleton-attribute.d.ts +35 -0
  101. package/src/mixins/with-skeleton-attribute.js +1 -112
  102. package/src/molecules/gv-card-full.d.ts +78 -0
  103. package/src/molecules/gv-card-full.js +1 -218
  104. package/src/molecules/gv-card-list.d.ts +33 -0
  105. package/src/molecules/gv-card-list.js +1 -113
  106. package/src/molecules/gv-card.d.ts +65 -0
  107. package/src/molecules/gv-card.js +1 -133
  108. package/src/molecules/gv-category-list.d.ts +17 -0
  109. package/src/molecules/gv-category-list.js +1 -60
  110. package/src/molecules/gv-category.d.ts +64 -0
  111. package/src/molecules/gv-category.js +1 -170
  112. package/src/molecules/gv-code.d.ts +192 -0
  113. package/src/molecules/gv-code.js +1 -359
  114. package/src/molecules/gv-confirm.d.ts +60 -0
  115. package/src/molecules/gv-confirm.js +1 -188
  116. package/src/molecules/gv-cron-editor.d.ts +115 -0
  117. package/src/molecules/gv-cron-editor.js +1 -710
  118. package/src/molecules/gv-dropdown-menu.d.ts +28 -0
  119. package/src/molecules/gv-dropdown-menu.js +1 -116
  120. package/src/molecules/gv-expandable.d.ts +37 -0
  121. package/src/molecules/gv-expandable.js +1 -122
  122. package/src/molecules/gv-expression-language.d.ts +150 -0
  123. package/src/molecules/gv-expression-language.js +1 -270
  124. package/src/molecules/gv-identity-picture.d.ts +44 -0
  125. package/src/molecules/gv-identity-picture.js +1 -148
  126. package/src/molecules/gv-list.d.ts +123 -0
  127. package/src/molecules/gv-list.js +1 -227
  128. package/src/molecules/gv-metrics.d.ts +65 -0
  129. package/src/molecules/gv-metrics.js +1 -162
  130. package/src/molecules/gv-modal.d.ts +64 -0
  131. package/src/molecules/gv-modal.js +1 -213
  132. package/src/molecules/gv-nav.d.ts +41 -0
  133. package/src/molecules/gv-nav.js +1 -196
  134. package/src/molecules/gv-option.d.ts +65 -0
  135. package/src/molecules/gv-option.js +1 -242
  136. package/src/molecules/gv-plans.d.ts +73 -0
  137. package/src/molecules/gv-plans.js +1 -429
  138. package/src/molecules/gv-popover.d.ts +91 -0
  139. package/src/molecules/gv-popover.js +1 -351
  140. package/src/molecules/gv-promote.d.ts +108 -0
  141. package/src/molecules/gv-promote.js +1 -209
  142. package/src/molecules/gv-rating-list.d.ts +77 -0
  143. package/src/molecules/gv-rating-list.js +1 -365
  144. package/src/molecules/gv-rating.d.ts +55 -0
  145. package/src/molecules/gv-rating.js +1 -253
  146. package/src/molecules/gv-row-expandable.d.ts +8 -0
  147. package/src/molecules/gv-row-expandable.js +1 -45
  148. package/src/molecules/gv-row.d.ts +37 -0
  149. package/src/molecules/gv-row.js +1 -210
  150. package/src/molecules/gv-stats.d.ts +53 -0
  151. package/src/molecules/gv-stats.js +1 -121
  152. package/src/molecules/gv-stepper.d.ts +46 -0
  153. package/src/molecules/gv-stepper.js +1 -288
  154. package/src/molecules/gv-table.d.ts +159 -0
  155. package/src/molecules/gv-table.js +1 -685
  156. package/src/molecules/gv-tree.d.ts +44 -0
  157. package/src/molecules/gv-tree.js +1 -250
  158. package/src/organisms/gv-documentation.d.ts +52 -0
  159. package/src/organisms/gv-documentation.js +1 -215
  160. package/src/organisms/gv-header.d.ts +60 -0
  161. package/src/organisms/gv-header.js +1 -288
  162. package/src/organisms/gv-http-client.d.ts +57 -0
  163. package/src/organisms/gv-http-client.js +1 -275
  164. package/src/organisms/gv-menu.d.ts +74 -0
  165. package/src/organisms/gv-menu.js +1 -263
  166. package/src/organisms/gv-newsletter-subscription.d.ts +82 -0
  167. package/src/organisms/gv-newsletter-subscription.js +1 -271
  168. package/src/organisms/gv-pagination.d.ts +63 -0
  169. package/src/organisms/gv-pagination.js +1 -198
  170. package/src/organisms/gv-properties.d.ts +229 -0
  171. package/src/organisms/gv-properties.js +1 -920
  172. package/src/organisms/gv-resizable-views.d.ts +33 -0
  173. package/src/organisms/gv-resizable-views.js +1 -396
  174. package/src/organisms/gv-resources.d.ts +125 -0
  175. package/src/organisms/gv-resources.js +1 -535
  176. package/src/organisms/gv-schema-form-array.d.ts +55 -0
  177. package/src/organisms/gv-schema-form-array.js +1 -250
  178. package/src/organisms/gv-schema-form-control-object.d.ts +64 -0
  179. package/src/organisms/gv-schema-form-control-object.js +1 -154
  180. package/src/organisms/gv-schema-form-control.d.ts +90 -0
  181. package/src/organisms/gv-schema-form-control.js +1 -443
  182. package/src/organisms/gv-schema-form.d.ts +156 -0
  183. package/src/organisms/gv-schema-form.js +1 -751
  184. package/src/organisms/gv-tabs.d.ts +56 -0
  185. package/src/organisms/gv-tabs.js +1 -210
  186. package/src/organisms/gv-user-menu.d.ts +56 -0
  187. package/src/organisms/gv-user-menu.js +1 -314
  188. package/src/organisms/gv-vertical-menu.d.ts +28 -0
  189. package/src/organisms/gv-vertical-menu.js +1 -123
  190. package/src/policy-studio/gv-flow-step.d.ts +142 -0
  191. package/src/policy-studio/gv-flow-step.js +1 -464
  192. package/src/policy-studio/gv-flow.d.ts +89 -0
  193. package/src/policy-studio/gv-flow.js +1 -621
  194. package/src/policy-studio/gv-policy-studio-menu.d.ts +94 -0
  195. package/src/policy-studio/gv-policy-studio-menu.js +1 -750
  196. package/src/policy-studio/gv-policy-studio.d.ts +464 -0
  197. package/src/policy-studio/gv-policy-studio.js +1 -1842
  198. package/src/styles/empty.d.ts +1 -0
  199. package/src/styles/empty.js +1 -36
  200. package/src/styles/input.d.ts +1 -0
  201. package/src/styles/input.js +1 -263
  202. package/src/styles/link.d.ts +1 -0
  203. package/src/styles/link.js +1 -32
  204. package/src/styles/shapes.d.ts +2 -0
  205. package/src/styles/shapes.js +1 -17
  206. package/src/styles/skeleton.d.ts +1 -0
  207. package/src/styles/skeleton.js +1 -53
  208. package/src/styles/zoom.d.ts +1 -0
  209. package/src/styles/zoom.js +1 -40
  210. package/src/theme/gv-theme.d.ts +81 -0
  211. package/src/theme/gv-theme.js +1 -203
  212. package/wc/gv-autocomplete.d.ts +1 -0
  213. package/wc/gv-autocomplete.js +1 -1
  214. package/wc/gv-button.d.ts +1 -0
  215. package/wc/gv-button.js +1 -1
  216. package/wc/gv-card-full.d.ts +1 -0
  217. package/wc/gv-card-full.js +1 -1
  218. package/wc/gv-card-list.d.ts +1 -0
  219. package/wc/gv-card-list.js +1 -1
  220. package/wc/gv-card.d.ts +1 -0
  221. package/wc/gv-card.js +1 -1
  222. package/wc/gv-category-list.d.ts +1 -0
  223. package/wc/gv-category-list.js +1 -1
  224. package/wc/gv-category.d.ts +1 -0
  225. package/wc/gv-category.js +1 -1
  226. package/wc/gv-chart-bar.d.ts +1 -0
  227. package/wc/gv-chart-bar.js +1 -1
  228. package/wc/gv-chart-gauge.d.ts +1 -0
  229. package/wc/gv-chart-gauge.js +1 -1
  230. package/wc/gv-chart-histogram.d.ts +1 -0
  231. package/wc/gv-chart-histogram.js +1 -1
  232. package/wc/gv-chart-line.d.ts +1 -0
  233. package/wc/gv-chart-line.js +1 -1
  234. package/wc/gv-chart-map.d.ts +1 -0
  235. package/wc/gv-chart-map.js +1 -1
  236. package/wc/gv-chart-pie.d.ts +1 -0
  237. package/wc/gv-chart-pie.js +1 -1
  238. package/wc/gv-checkbox.d.ts +1 -0
  239. package/wc/gv-checkbox.js +1 -1
  240. package/wc/gv-code.d.ts +1 -0
  241. package/wc/gv-code.js +1 -1
  242. package/wc/gv-confirm.d.ts +1 -0
  243. package/wc/gv-confirm.js +1 -1
  244. package/wc/gv-cron-editor.d.ts +1 -0
  245. package/wc/gv-cron-editor.js +1 -1
  246. package/wc/gv-date-picker-calendar.d.ts +1 -0
  247. package/wc/gv-date-picker-calendar.js +1 -1
  248. package/wc/gv-date-picker-cell.d.ts +1 -0
  249. package/wc/gv-date-picker-cell.js +1 -1
  250. package/wc/gv-date-picker.d.ts +1 -0
  251. package/wc/gv-date-picker.js +1 -1
  252. package/wc/gv-documentation.d.ts +1 -0
  253. package/wc/gv-documentation.js +1 -1
  254. package/wc/gv-dropdown-menu.d.ts +1 -0
  255. package/wc/gv-dropdown-menu.js +1 -1
  256. package/wc/gv-expandable.d.ts +1 -0
  257. package/wc/gv-expandable.js +1 -1
  258. package/wc/gv-expression-language.d.ts +1 -0
  259. package/wc/gv-expression-language.js +1 -1
  260. package/wc/gv-file-upload.d.ts +1 -0
  261. package/wc/gv-file-upload.js +1 -1
  262. package/wc/gv-flow-step.d.ts +1 -0
  263. package/wc/gv-flow-step.js +1 -1
  264. package/wc/gv-flow.d.ts +1 -0
  265. package/wc/gv-flow.js +1 -1
  266. package/wc/gv-header.d.ts +1 -0
  267. package/wc/gv-header.js +1 -1
  268. package/wc/gv-http-client.d.ts +1 -0
  269. package/wc/gv-http-client.js +1 -1
  270. package/wc/gv-icon.d.ts +1 -0
  271. package/wc/gv-icon.js +1 -1
  272. package/wc/gv-identity-picture.d.ts +1 -0
  273. package/wc/gv-identity-picture.js +1 -1
  274. package/wc/gv-image.d.ts +1 -0
  275. package/wc/gv-image.js +1 -1
  276. package/wc/gv-input-message.d.ts +1 -0
  277. package/wc/gv-input-message.js +1 -1
  278. package/wc/gv-input.d.ts +1 -0
  279. package/wc/gv-input.js +1 -1
  280. package/wc/gv-link.d.ts +1 -0
  281. package/wc/gv-link.js +1 -1
  282. package/wc/gv-list.d.ts +1 -0
  283. package/wc/gv-list.js +1 -1
  284. package/wc/gv-menu.d.ts +1 -0
  285. package/wc/gv-menu.js +1 -1
  286. package/wc/gv-message.d.ts +1 -0
  287. package/wc/gv-message.js +1 -1
  288. package/wc/gv-metric.d.ts +1 -0
  289. package/wc/gv-metric.js +1 -1
  290. package/wc/gv-metrics.d.ts +1 -0
  291. package/wc/gv-metrics.js +1 -1
  292. package/wc/gv-modal.d.ts +1 -0
  293. package/wc/gv-modal.js +1 -1
  294. package/wc/gv-nav.d.ts +1 -0
  295. package/wc/gv-nav.js +1 -1
  296. package/wc/gv-newsletter-subscription.d.ts +1 -0
  297. package/wc/gv-newsletter-subscription.js +1 -1
  298. package/wc/gv-option.d.ts +1 -0
  299. package/wc/gv-option.js +1 -1
  300. package/wc/gv-pagination.d.ts +1 -0
  301. package/wc/gv-pagination.js +1 -1
  302. package/wc/gv-plans.d.ts +1 -0
  303. package/wc/gv-plans.js +1 -1
  304. package/wc/gv-policy-studio-menu.d.ts +1 -0
  305. package/wc/gv-policy-studio-menu.js +1 -1
  306. package/wc/gv-policy-studio.d.ts +1 -0
  307. package/wc/gv-policy-studio.js +1 -1
  308. package/wc/gv-popover.d.ts +1 -0
  309. package/wc/gv-popover.js +1 -1
  310. package/wc/gv-promote.d.ts +1 -0
  311. package/wc/gv-promote.js +1 -1
  312. package/wc/gv-properties.d.ts +1 -0
  313. package/wc/gv-properties.js +1 -1
  314. package/wc/gv-rating-list.d.ts +1 -0
  315. package/wc/gv-rating-list.js +1 -1
  316. package/wc/gv-rating.d.ts +1 -0
  317. package/wc/gv-rating.js +1 -1
  318. package/wc/gv-relative-time.d.ts +1 -0
  319. package/wc/gv-relative-time.js +1 -1
  320. package/wc/gv-resizable-views.d.ts +1 -0
  321. package/wc/gv-resizable-views.js +1 -1
  322. package/wc/gv-resources.d.ts +1 -0
  323. package/wc/gv-resources.js +1 -1
  324. package/wc/gv-row-expandable.d.ts +1 -0
  325. package/wc/gv-row-expandable.js +1 -1
  326. package/wc/gv-row.d.ts +1 -0
  327. package/wc/gv-row.js +1 -1
  328. package/wc/gv-schema-form-array.d.ts +1 -0
  329. package/wc/gv-schema-form-array.js +1 -1
  330. package/wc/gv-schema-form-control-object.d.ts +1 -0
  331. package/wc/gv-schema-form-control-object.js +1 -1
  332. package/wc/gv-schema-form-control.d.ts +1 -0
  333. package/wc/gv-schema-form-control.js +1 -1
  334. package/wc/gv-schema-form.d.ts +1 -0
  335. package/wc/gv-schema-form.js +1 -1
  336. package/wc/gv-select-native.d.ts +1 -0
  337. package/wc/gv-select-native.js +1 -1
  338. package/wc/gv-select.d.ts +1 -0
  339. package/wc/gv-select.js +1 -1
  340. package/wc/gv-spinner.d.ts +1 -0
  341. package/wc/gv-spinner.js +1 -1
  342. package/wc/gv-state.d.ts +1 -0
  343. package/wc/gv-state.js +1 -1
  344. package/wc/gv-stats.d.ts +1 -0
  345. package/wc/gv-stats.js +1 -1
  346. package/wc/gv-stepper.d.ts +1 -0
  347. package/wc/gv-stepper.js +1 -1
  348. package/wc/gv-switch.d.ts +1 -0
  349. package/wc/gv-switch.js +1 -1
  350. package/wc/gv-table.d.ts +1 -0
  351. package/wc/gv-table.js +1 -1
  352. package/wc/gv-tabs.d.ts +1 -0
  353. package/wc/gv-tabs.js +1 -1
  354. package/wc/gv-tag.d.ts +1 -0
  355. package/wc/gv-tag.js +1 -1
  356. package/wc/gv-text.d.ts +1 -0
  357. package/wc/gv-text.js +1 -1
  358. package/wc/gv-theme.d.ts +1 -0
  359. package/wc/gv-theme.js +1 -1
  360. package/wc/gv-tree.d.ts +1 -0
  361. package/wc/gv-tree.js +1 -1
  362. package/wc/gv-user-menu.d.ts +1 -0
  363. package/wc/gv-user-menu.js +1 -1
  364. package/wc/gv-vertical-menu.d.ts +1 -0
  365. package/wc/gv-vertical-menu.js +1 -1
  366. package/CHANGELOG.md +0 -1292
  367. package/LICENSE.txt +0 -202
  368. package/README.md +0 -195
  369. package/src/.eslintrc.js +0 -19
  370. package/src/theme/definition.json +0 -1762
@@ -1,920 +1 @@
1
- /*
2
- * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { css, html, LitElement } from 'lit';
17
-
18
- import './gv-schema-form';
19
- import './gv-resizable-views';
20
- import '../molecules/gv-table';
21
- import '../atoms/gv-button';
22
- import '../atoms/gv-input';
23
- import '../atoms/gv-icon';
24
- import '../atoms/gv-text';
25
- import '../atoms/gv-input-message';
26
- import '../atoms/gv-select';
27
- import { dispatchCustomEvent } from '../lib/events';
28
- import { ERROR_TYPES, parseRaw, toNameEqualsValueString } from '../lib/properties';
29
- import { i18n } from '../lib/i18n';
30
- import { classMap } from 'lit/directives/class-map';
31
- import { KeyboardElement, KEYS } from '../mixins/keyboard-element';
32
- import { empty } from '../styles/empty';
33
-
34
- /**
35
- * A component to manage properties
36
- *
37
- * @fires gv-properties:change - When list of properties change
38
- * @fires gv-properties:save-provider - When user validates provider configuration
39
- * @fires gv-properties:switch-encrypted - When user switches encryption toggle
40
- *
41
- * @attr {Array} properties - Array of Properties {key, value, dynamic?}
42
- * @attr {Object} provider - Configuration of provider
43
- * @attr {Array} providers - List of available providers (only http for the moment)
44
- * @attr {Boolean} expert - For display expert mode by default
45
- * @attr {Boolean} encryptable - To display the 'encrypted' toggle on each property
46
- *
47
- * @cssprop {Length} [--gv-properties-table--colmg=0.2rem] - Table cells margin
48
- */
49
- export class GvProperties extends KeyboardElement(LitElement) {
50
- static get properties() {
51
- return {
52
- dynamicPropertySchema: { type: Object },
53
- properties: { type: Array },
54
- _properties: { type: Array, attribute: false },
55
- provider: { type: Object },
56
- providers: { type: Array },
57
- _propertySchemaForm: { type: Object, attribute: false },
58
- expert: { type: Boolean },
59
- _formattedErrors: { type: Array, attributes: false },
60
- _filter: { type: String },
61
- _paginationData: { type: Object, attribute: false },
62
- _pageSize: { type: Number, attribute: false },
63
- _newItem: { type: Object, attribute: false },
64
- _providerDocumentation: { type: Boolean, attribute: false },
65
- _showDocumentation: { type: Boolean, attribute: false },
66
- _textRows: { type: Number, attribute: false },
67
- readonly: { type: Boolean, reflect: true },
68
- encryptable: { type: Boolean, reflect: true },
69
- };
70
- }
71
-
72
- constructor() {
73
- super();
74
- this.properties = [];
75
- this.types = [];
76
- this.provider = {};
77
- this._currentResource = null;
78
- this._formattedErrors = [];
79
- this._showDocumentation = true;
80
- this._newItem = { key: '', value: '', _new: true };
81
- this._pageSize = 10;
82
- this._textRows = 10;
83
- this._pageSizes = [5, 10, 25, 50, 100];
84
- this._errors = [];
85
- }
86
-
87
- onKeyboard() {
88
- if (this.isPressed(KEYS.Esc)) {
89
- this._onClosePropertySchemaForm();
90
- }
91
- if (this.isPressed(KEYS.Shift, KEYS.Ctrl, KEYS.Space)) {
92
- const search = this.shadowRoot.querySelector('#search-property');
93
- if (search) {
94
- search.focus();
95
- }
96
- }
97
- }
98
-
99
- set properties(properties) {
100
- this._properties = properties
101
- .sort((a, b) => a.key.localeCompare(b.key))
102
- .map((property) => {
103
- if (property.encrypted) {
104
- property.encryptable = true;
105
- }
106
- return property;
107
- });
108
- }
109
-
110
- get properties() {
111
- return this._properties;
112
- }
113
-
114
- _getResizableViews() {
115
- return this.shadowRoot.querySelector('gv-resizable-views');
116
- }
117
-
118
- _maximizeTopView() {
119
- const views = this._getResizableViews();
120
- if (views) {
121
- views.maximizeTop(95, 5);
122
- }
123
- }
124
-
125
- _maximizeBottomView() {
126
- const views = this._getResizableViews();
127
- if (views) {
128
- views.resize(30, 70);
129
- }
130
- }
131
-
132
- _splitMainViews() {
133
- const views = this._getResizableViews();
134
- if (views) {
135
- views.split();
136
- }
137
- }
138
-
139
- _isNewLineTable(line) {
140
- return line._new === true;
141
- }
142
-
143
- _onInputNew(name, event) {
144
- const target = event.target;
145
- this._newItem[name] = event.detail;
146
- const { errors } = parseRaw(toNameEqualsValueString([...this.properties, this._newItem]));
147
- this._errors = errors;
148
- setTimeout(() => {
149
- const btn = this.shadowRoot.querySelector('gv-button#add-property');
150
- if (errors.length > 0 || this._disabledNewLine(this._newItem)) {
151
- btn.setAttribute('disabled', true);
152
- } else {
153
- btn.removeAttribute('disabled');
154
- }
155
- if (name === 'key') {
156
- if (errors.length === 0) {
157
- target.removeAttribute('invalid');
158
- target.setAttribute('valid', true);
159
- } else {
160
- target.removeAttribute('valid');
161
- target.setAttribute('invalid', true);
162
- }
163
- }
164
- }, 0);
165
- }
166
-
167
- _onInput() {
168
- dispatchCustomEvent(this, 'change', { properties: this.properties });
169
- }
170
-
171
- _onSwitchEncrypted(item) {
172
- if (item.encrypted === true) {
173
- item.value = '';
174
- item.encrypted = false;
175
- item.encryptionWarning = i18n('gv-properties.infos.overwrite-encryption');
176
- this.requestUpdate();
177
- }
178
- dispatchCustomEvent(this, 'switch-encrypted', { properties: this.properties });
179
- }
180
-
181
- _addProperty(item) {
182
- delete item._new;
183
- this.properties = [item, ...this._properties];
184
- this._newItem = { key: '', value: '', _new: true, encryptable: false, encrypted: false };
185
- dispatchCustomEvent(this, 'change', { properties: this.properties });
186
- }
187
-
188
- _removeProperty(item) {
189
- this._properties = this._properties.filter((property) => property.key !== item.key);
190
- dispatchCustomEvent(this, 'change', { properties: this.properties });
191
- }
192
-
193
- _disabledNewLine(item) {
194
- return item.key == null || item.value == null || item.key.trim() === '' || item.value.trim() === '';
195
- }
196
-
197
- _submitExpertMode() {
198
- if (this.expert) {
199
- this.properties = this._handleExpertModeInput(this.shadowRoot.querySelector('#expert-input').value);
200
- }
201
- }
202
-
203
- _onExpertModeTextInput({ detail }) {
204
- this._handleExpertModeInput(detail);
205
- }
206
-
207
- _handleExpertModeInput(expertModeInputString) {
208
- let allProperties = this._properties;
209
- const providerEnabled = this.provider && this.provider.enabled;
210
- const dynamicProperties = allProperties.filter((prop) => providerEnabled && prop.dynamic);
211
- const encryptedProperties = allProperties.filter((prop) => prop.encrypted);
212
-
213
- const allPropertiesString = `${expertModeInputString}\n${toNameEqualsValueString(dynamicProperties)}\n${toNameEqualsValueString(
214
- encryptedProperties,
215
- )}`;
216
- const { errors } = parseRaw(allPropertiesString);
217
- this._errors = errors;
218
- if (errors.length === 0) {
219
- const { variables } = parseRaw(expertModeInputString);
220
- allProperties = [...variables, ...dynamicProperties, ...encryptedProperties];
221
- dispatchCustomEvent(this, 'change', { properties: allProperties });
222
- }
223
-
224
- return allProperties;
225
- }
226
-
227
- _onSubmitPropertyForm({ detail }) {
228
- const provider = detail.values;
229
- dispatchCustomEvent(this, 'save-provider', { provider });
230
- this.requestUpdate();
231
- }
232
-
233
- submit() {
234
- if (this.expert) {
235
- this._submitExpertMode();
236
- } else {
237
- this._onSubmit();
238
- }
239
- }
240
-
241
- _onSubmit() {
242
- const invalidControls = [...this.shadowRoot.querySelectorAll('form .control')].find((control) => control.invalid);
243
- if (invalidControls == null) {
244
- this._addProperty(this._newItem);
245
- }
246
- }
247
-
248
- _onConfigureDynamicProperties() {
249
- if (this.dynamicPropertySchema == null) {
250
- // dynamicPropertySchema has been introduced to ensure backward compatibility with old versions. If no schema is provided a default schema will be used.
251
- const providersTitleMap = this.providers.reduce((map, provider) => {
252
- map[provider.id] = provider.key;
253
- return map;
254
- }, {});
255
-
256
- const providersEnum = Object.keys(providersTitleMap);
257
- this.dynamicPropertySchema = {
258
- properties: {
259
- enabled: {
260
- type: 'boolean',
261
- title: 'Enabled',
262
- description: ' This service is requiring an API deployment. Do not forget to deploy API to start dynamic-properties service.',
263
- },
264
- schedule: {
265
- type: 'string',
266
- title: 'Schedule',
267
- 'x-schema-form': {
268
- 'cron-expression': true,
269
- },
270
- },
271
- provider: {
272
- type: 'string',
273
- title: 'Provider type',
274
- enum: providersEnum,
275
- default: providersEnum[0],
276
- 'x-schema-form': {
277
- titleMap: providersTitleMap,
278
- },
279
- },
280
- },
281
- required: ['schedule', 'provider'],
282
- };
283
- }
284
-
285
- const defaultProvider = this.providers[0];
286
-
287
- this._propertySchemaForm = {
288
- properties: { ...this.dynamicPropertySchema.properties, configuration: defaultProvider.schema },
289
- required: this.dynamicPropertySchema.required,
290
- };
291
- this._providerDocumentation = defaultProvider.documentation;
292
- this._maximizeBottomView();
293
- }
294
-
295
- _onClosePropertySchemaForm() {
296
- this._propertySchemaForm = null;
297
- this._maximizeTopView();
298
- }
299
-
300
- _onSearchProperty({ detail }) {
301
- this._filter = detail;
302
- this._onClosePropertySchemaForm();
303
- }
304
-
305
- _onClearProperty() {
306
- this._filter = null;
307
- this._onClosePropertySchemaForm();
308
- }
309
-
310
- get _errors() {
311
- return this._formattedErrors;
312
- }
313
-
314
- set _errors(rawErrors) {
315
- this._formattedErrors = rawErrors.map(({ type, key, pos }) => {
316
- if (type === ERROR_TYPES.INVALID_NAME) {
317
- return {
318
- line: pos.line,
319
- msg: i18n('gv-properties.errors.invalid-key', { key }),
320
- };
321
- }
322
- if (type === ERROR_TYPES.DUPLICATED_NAME) {
323
- return {
324
- line: pos.line,
325
- msg: i18n('gv-properties.errors.duplicated-key', { key }),
326
- };
327
- }
328
- if (type === ERROR_TYPES.INVALID_LINE) {
329
- return {
330
- line: pos.line,
331
- msg: i18n('gv-properties.errors.invalid-line'),
332
- };
333
- }
334
- if (type === ERROR_TYPES.INVALID_VALUE) {
335
- return {
336
- line: pos.line,
337
- msg: i18n('gv-properties.errors.invalid-value'),
338
- };
339
- }
340
- return { line: '?', msg: i18n('gv-properties.errors.unknown') };
341
- });
342
- }
343
-
344
- _renderErrors(withLine = false) {
345
- if (this._formattedErrors.length > 0) {
346
- return html`<div class="${classMap({ 'add-form-error': true, 'add-form-error_expert': this.expert })}">
347
- <div></div>
348
- <div class="error-list">
349
- ${this._formattedErrors.map(
350
- ({ line, msg }) => html`
351
- <gv-input-message
352
- >${withLine ? html`<strong .innerHTML="${i18n('gv-properties.errors.line')} ${line}:&nbsp;"></strong>` : ''}
353
- <span .innerHTML="${msg}"></span
354
- ></gv-input-message>
355
- `,
356
- )}
357
- </div>
358
- </div>`;
359
- }
360
- return html``;
361
- }
362
-
363
- _renderTable() {
364
- const providerEnabled = this.provider && this.provider.enabled;
365
- if (this.expert) {
366
- this._computeTextRows();
367
-
368
- const staticProperties = providerEnabled ? this._properties.filter((prop) => !(providerEnabled && prop.dynamic)) : this._properties;
369
- const expertProperties = staticProperties.filter((prop) => !prop.encrypted);
370
- const content = expertProperties.map((prop) => `${prop.key}="${prop.value}"`).join('\n');
371
-
372
- return html`<gv-text
373
- id="expert-input"
374
- placeholder="${i18n('gv-properties.placeholder.input')}"
375
- @gv-text:input="${this._onExpertModeTextInput}"
376
- .value="${content}"
377
- ?readonly="${this.readonly}"
378
- .rows="${this._textRows}"
379
- ></gv-text>
380
- ${this._renderErrors(true)}`;
381
- } else {
382
- const options = {
383
- data: [
384
- {
385
- field: 'dynamic',
386
- label: 'Dynamic',
387
- width: '40px',
388
- type: (item) => (item.dynamic && providerEnabled ? 'gv-icon' : 'div'),
389
- attributes: {
390
- shape: (item) => (item.dynamic && providerEnabled ? 'code:time-schedule' : ''),
391
- title: (item) => (item.dynamic && providerEnabled ? 'Dynamic properties service is actually in running' : ''),
392
- style: 'justify-content: center; align-items: center; height: 100%;',
393
- },
394
- },
395
- {
396
- field: 'key',
397
- label: 'Key',
398
- type: 'gv-input',
399
- attributes: {
400
- clipboard: true,
401
- placeholder: i18n('gv-properties.placeholder.key'),
402
- name: 'key',
403
- required: true,
404
- readonly: this.readonly,
405
- },
406
- },
407
- {
408
- field: 'value',
409
- label: 'Value',
410
- type: 'gv-input',
411
- attributes: {
412
- name: 'value',
413
- placeholder: 'Property value',
414
- required: true,
415
- readonly: this.readonly,
416
- disabled: (item) => (item.dynamic && providerEnabled) || item.encrypted,
417
- type: (item) => (item.encrypted ? 'password' : 'text'),
418
- title: (item) => (item.encrypted ? i18n('gv-properties.infos.encrypted-value') : ''),
419
- description: (item) => item.encryptionWarning,
420
- icon: null,
421
- 'ongv-input:input': this._onInput.bind(this),
422
- },
423
- },
424
- ],
425
- };
426
-
427
- if (this.encryptable === true) {
428
- options.data.push({
429
- field: 'encryptable',
430
- type: 'gv-switch',
431
- style: '--gv-switch--ta: right;',
432
- width: '105px',
433
- attributes: {
434
- description: i18n('gv-properties.encrypted-toggle'),
435
- required: true,
436
- readonly: this.readonly,
437
- disabled: (item) => item.dynamic && providerEnabled,
438
- 'ongv-switch:input': this._onSwitchEncrypted.bind(this),
439
- style: 'display: inline-flex; font-size: 12px; height: 40px;',
440
- },
441
- });
442
- }
443
-
444
- if (this.readonly !== true) {
445
- options.data.push({
446
- type: 'gv-button',
447
- width: '40px',
448
- attributes: {
449
- 'ongv-button:click': (item, event, target) => this._removeProperty(item, target),
450
- title: 'Remove',
451
- disabled: (item) => item.dynamic && providerEnabled,
452
- danger: true,
453
- outlined: true,
454
- icon: 'home:trash',
455
- },
456
- });
457
- }
458
-
459
- const filteredProperties =
460
- this._filter != null
461
- ? this._properties.filter((prop) => {
462
- return (prop.key.toLowerCase() + prop.value.toLowerCase()).includes(this._filter);
463
- })
464
- : this._properties;
465
- let properties = [...filteredProperties];
466
- if (this._paginationData) {
467
- this._paginationData.last = Math.ceil(filteredProperties.length / this._pageSize);
468
- this._paginationData.total = filteredProperties.length;
469
- this._paginationData.total_pages = Math.ceil(filteredProperties.length / this._pageSize);
470
- const index = (this._paginationData.current_page - 1) * this._pageSize;
471
- properties = [...filteredProperties].splice(index, this._pageSize);
472
- }
473
-
474
- const addPropertyFormGridClass = this.encryptable ? 'add-form-grid-with-encrypted-toggle' : 'add-form-grid';
475
-
476
- const addPropertyForm =
477
- this.readonly !== true
478
- ? html`<form id="add-property-form" class="add-form ${addPropertyFormGridClass}" @submit="${this._onSubmit}">
479
- <div></div>
480
- <gv-input
481
- class="control"
482
- placeholder="${i18n('gv-properties.placeholder.key')}"
483
- required
484
- @gv-input:input="${this._onInputNew.bind(this, 'key')}"
485
- value="${this._newItem.key}"
486
- ></gv-input>
487
- <gv-input
488
- class="control"
489
- placeholder="${i18n('gv-properties.placeholder.value')}"
490
- required
491
- @gv-input:input="${this._onInputNew.bind(this, 'value')}"
492
- .value="${this._newItem.value}"
493
- ></gv-input>
494
- ${this.encryptable
495
- ? html` <gv-switch
496
- class="control"
497
- required
498
- description="${i18n('gv-properties.encrypted-toggle')}"
499
- @gv-switch:input="${this._onInputNew.bind(this, 'encryptable')}"
500
- .value="${this._newItem.encryptable}"
501
- ></gv-switch>`
502
- : ''}
503
- <gv-button
504
- id="add-property"
505
- icon="code:plus"
506
- outlined
507
- disabled
508
- @gv-button:click="${this._addProperty.bind(this, this._newItem)}"
509
- title="${i18n('gv-properties.add')}"
510
- ></gv-button>
511
- </form>
512
- ${this._renderErrors()}
513
- <hr />`
514
- : '';
515
-
516
- return html` ${addPropertyForm}
517
- <gv-table .options="${options}" .items="${properties}" noheader nosort order="key" rowheight="57px"></gv-table>`;
518
- }
519
- }
520
-
521
- _onChangeMode({ detail }) {
522
- this._submitExpertMode();
523
- this.expert = detail;
524
- this._errors = [];
525
- this._newItem = { key: '', value: '', _new: true };
526
- this._onClosePropertySchemaForm();
527
- }
528
-
529
- _onPaginate({ detail }) {
530
- this._paginationData.current_page = detail.page;
531
- this._onClosePropertySchemaForm();
532
- this.requestUpdate();
533
- }
534
-
535
- updated(props) {
536
- if (props.has('_properties') || props.has('_pageSize')) {
537
- this._paginationData = {
538
- first: 1,
539
- last: Math.ceil(this._properties.length / this._pageSize),
540
- total: this._properties.length,
541
- current_page: 1,
542
- total_pages: Math.ceil(this._properties.length / this._pageSize),
543
- };
544
- }
545
- }
546
-
547
- _onChangePageSize({ detail }) {
548
- this._pageSize = Number(detail).valueOf();
549
- this._onClosePropertySchemaForm();
550
- }
551
-
552
- _renderTableForm() {
553
- return html`<div class="container">
554
- <div class="header">
555
- <div class="title">Manage global properties <span>(${this._properties ? this._properties.length : 0})</span></div>
556
- <gv-switch
557
- small
558
- .description="${this.expert ? 'Expert' : 'Simple'}"
559
- .value="${this.expert}"
560
- @gv-switch:input="${this._onChangeMode}"
561
- ></gv-switch>
562
- <gv-input
563
- id="search-property"
564
- placeholder="Filter properties (Shift + Ctrl + Space)"
565
- type="search"
566
- small
567
- class="search-input"
568
- .disabled="${this.expert}"
569
- @gv-input:input="${this._onSearchProperty}"
570
- @gv-input:clear="${this._onClearProperty}"
571
- ></gv-input>
572
- <gv-select
573
- class="page-size__select"
574
- @gv-select:input="${this._onChangePageSize}"
575
- small
576
- .options="${this._pageSizes}"
577
- .value="${this._pageSize}"
578
- .disabled="${this.expert || this._paginationData == null}"
579
- ></gv-select>
580
- <gv-pagination
581
- @gv-pagination:paginate="${this._onPaginate}"
582
- .disabled="${this.expert || this._paginationData == null}"
583
- .data="${this._paginationData}"
584
- widget
585
- ></gv-pagination>
586
- </div>
587
- <div class="content"><div class="form-content">${this._renderTable()}</div></div>
588
- </div>`;
589
- }
590
-
591
- _fetchDocumentation() {
592
- this._showDocumentation = true;
593
- }
594
-
595
- _hideDocumentation() {
596
- this._showDocumentation = false;
597
- }
598
-
599
- get dirty() {
600
- const form = this.shadowRoot.querySelector('gv-schema-form');
601
- return form && form.dirty;
602
- }
603
-
604
- confirm() {
605
- const form = this.shadowRoot.querySelector('gv-schema-form');
606
- if (form) {
607
- return form.confirm().then(() => this._onClosePropertySchemaForm());
608
- }
609
- return Promise.resolve();
610
- }
611
-
612
- _renderForm() {
613
- return html`<gv-schema-form
614
- slot="top"
615
- scrollable
616
- .schema="${this._propertySchemaForm}"
617
- .values="${this.provider}"
618
- .icon="design:edit"
619
- has-header
620
- ?readonly="${this.readonly}"
621
- @gv-schema-form:submit="${this._onSubmitPropertyForm}"
622
- >
623
- <div slot="title" class="properties-title">Configure dynamic properties</div>
624
- <gv-button
625
- slot="header-left"
626
- icon="general:close"
627
- outlined
628
- small
629
- @gv-button:click="${this._onClosePropertySchemaForm}"
630
- title="Close (esc)"
631
- ></gv-button>
632
- <gv-button
633
- slot="header-left"
634
- icon="home:book"
635
- ?disabled="${this._showDocumentation}"
636
- outlined
637
- small
638
- @gv-button:click="${this._fetchDocumentation}"
639
- title="Open documentation"
640
- ></gv-button>
641
- </gv-schema-form>`;
642
- }
643
-
644
- _renderBottom() {
645
- if (this._propertySchemaForm && this._showDocumentation) {
646
- return html`<gv-resizable-views no-overflow direction="horizontal">
647
- ${this._renderForm()}
648
- <gv-documentation
649
- slot="bottom"
650
- .text="${this._providerDocumentation}"
651
- @gv-documentation:close="${this._hideDocumentation}"
652
- ></gv-documentation>
653
- </gv-resizable-views>`;
654
- } else if (this._propertySchemaForm) {
655
- return this._renderForm();
656
- } else {
657
- return html`<div class="properties-bottom-container">${this._renderDynamicConfiguration()}</div>`;
658
- }
659
- }
660
-
661
- _renderDynamicConfiguration() {
662
- const hasDynamicConfiguration = this.provider && this.provider.enabled;
663
-
664
- let configureAction = '';
665
- if (hasDynamicConfiguration || this.readonly !== true) {
666
- configureAction = html`<gv-button
667
- icon="tools:tools"
668
- @gv-button:click="${this._onConfigureDynamicProperties}"
669
- outlined
670
- .disabled="${this.expert}"
671
- >Configure dynamic properties</gv-button
672
- >`;
673
- }
674
-
675
- if (hasDynamicConfiguration) {
676
- return html`<div class="properties-message">
677
- Dynamic properties service is actually in <code>running</code> state and run with cron expression
678
- <code>${this.provider.schedule}</code> using <code>${this.provider.provider}</code> provider.
679
- </div>
680
- ${configureAction}`;
681
- } else if (this.readonly) {
682
- return html`<div class="empty">No dynamic properties service configured</div>`;
683
- } else {
684
- return configureAction;
685
- }
686
- }
687
-
688
- _onMove() {
689
- this._computeTextRows();
690
- }
691
-
692
- _computeTextRows() {
693
- const parent = this.shadowRoot.querySelector('.content');
694
- if (parent) {
695
- const { height } = parent.getBoundingClientRect();
696
- // --gv-text--lh=30px
697
- this._textRows = Math.round(Math.round(height - 20) / 30) - 2;
698
- }
699
- }
700
-
701
- render() {
702
- if (this.providers && this.providers.length > 0) {
703
- return html`<div class="properties">
704
- <gv-resizable-views no-overflow @gv-resizable-views:move="${this._onMove}" @gv-resizable-views:resize="${this._onMove}">
705
- <div slot="top" class="box">${this._renderTableForm()}</div>
706
- <div slot="bottom">${this._renderBottom()}</div>
707
- </gv-resizable-views>
708
- </div>`;
709
- } else {
710
- return html`<div class="properties">
711
- <div class="table-box">${this._renderTableForm()}</div>
712
- </div>`;
713
- }
714
- }
715
-
716
- static get styles() {
717
- return [
718
- empty,
719
- // language=CSS
720
- css`
721
- :host {
722
- box-sizing: border-box;
723
- height: 100%;
724
- width: 100%;
725
- display: block;
726
- }
727
-
728
- .properties {
729
- display: flex;
730
- height: 100%;
731
- width: 100%;
732
- }
733
-
734
- gv-resizable-views {
735
- height: 100%;
736
- width: 100%;
737
- }
738
-
739
- gv-schema-form {
740
- margin: 0;
741
- }
742
-
743
- .table-box {
744
- width: 100%;
745
- border-left: 1px solid #bfbfbf;
746
- display: flex;
747
- }
748
-
749
- gv-table {
750
- height: auto;
751
- flex: 1;
752
- margin-top: 10px;
753
- margin-right: 50px;
754
- --gv-table-rows--ov: none;
755
- --gv-table--colmg: var(--gv-properties-table--colmg, 0.2rem);
756
- --gv-table-cell--d: inline;
757
- --gv-table-row--ai: flex-start;
758
- --gv-table-row--ac: flex-start;
759
- --gv-table-hover--bgc: var(--gv-theme-neutral-color-lightest);
760
- }
761
-
762
- .properties-title {
763
- text-transform: uppercase;
764
- letter-spacing: 0.2rem;
765
- }
766
-
767
- .properties-bottom-container {
768
- display: flex;
769
- justify-content: center;
770
- align-items: center;
771
- height: 100%;
772
- flex-direction: column;
773
- }
774
-
775
- .header {
776
- border-bottom: 1px solid #d9d9d9;
777
- display: flex;
778
- min-height: 45px;
779
- align-items: center;
780
- margin-bottom: 0.5rem;
781
- padding: 0 0.5rem;
782
- }
783
-
784
- .header .title {
785
- color: #28444f;
786
- font-size: 18px;
787
- display: flex;
788
- align-items: flex-end;
789
- flex: 1;
790
- }
791
-
792
- .header .title span {
793
- font-size: 12px;
794
- margin-left: 8px;
795
- opacity: 0.7;
796
- }
797
-
798
- .box {
799
- position: absolute;
800
- display: flex;
801
- flex-direction: column;
802
- width: 100%;
803
- top: 0;
804
- bottom: 0;
805
- left: 0;
806
- }
807
-
808
- .container {
809
- flex-grow: 1;
810
-
811
- display: flex;
812
- flex-direction: column;
813
-
814
- /* for Firefox */
815
- min-height: 0;
816
- height: 100%;
817
- }
818
-
819
- .content {
820
- background: white;
821
- flex-grow: 1;
822
-
823
- overflow: auto;
824
-
825
- /* for Firefox */
826
- min-height: 0;
827
- padding: 0.5rem;
828
-
829
- display: flex;
830
- flex-direction: column;
831
- align-items: center;
832
- }
833
-
834
- gv-text {
835
- --gv-text--fz: 20px;
836
- --gv-text--lh: 25px;
837
- }
838
-
839
- gv-switch {
840
- --gv-switch--ta: right;
841
- }
842
-
843
- .header gv-input {
844
- margin: 0 1rem;
845
- }
846
-
847
- .add-form,
848
- .add-form-error {
849
- display: grid;
850
- margin: auto 50px auto 0;
851
- box-sizing: border-box;
852
- }
853
-
854
- .add-form {
855
- column-gap: var(--gv-properties-table--colmg, 0.2rem);
856
- border-right: solid thick transparent;
857
- height: 50px;
858
- }
859
-
860
- .add-form gv-input,
861
- gv-button,
862
- gv-switch {
863
- margin: auto 0;
864
- }
865
-
866
- .add-form gv-switch {
867
- font-size: 12px;
868
- }
869
-
870
- .add-form-grid {
871
- grid-template-columns: 40px auto auto 40px;
872
- }
873
-
874
- .add-form-grid-with-encrypted-toggle {
875
- grid-template-columns: 40px auto auto 105px 40px;
876
- }
877
-
878
- .add-form-error_expert {
879
- display: flex;
880
- }
881
-
882
- .add-form-error {
883
- grid-template-columns: 40px 1fr;
884
- }
885
-
886
- code {
887
- color: var(--gv-theme-color-warning-dark, #f57c00);
888
- }
889
-
890
- .form-content {
891
- display: flex;
892
- flex-direction: column;
893
- width: 100%;
894
- }
895
-
896
- .properties-message {
897
- margin-bottom: 0.5rem;
898
- font-size: 14px;
899
- }
900
-
901
- .page-size__select {
902
- max-width: 50px;
903
- }
904
-
905
- .search-input {
906
- width: 300px;
907
- }
908
-
909
- hr {
910
- background-color: var(--gv-theme-neutral-color);
911
- border: 0;
912
- width: 100%;
913
- height: 2px;
914
- }
915
- `,
916
- ];
917
- }
918
- }
919
-
920
- window.customElements.define('gv-properties', GvProperties);
1
+ Object.defineProperty(exports,"__esModule",{value:!0}),exports.GvProperties=void 0;const e=require("lit");require("./gv-schema-form"),require("./gv-resizable-views"),require("../molecules/gv-table"),require("../atoms/gv-button"),require("../atoms/gv-input"),require("../atoms/gv-icon"),require("../atoms/gv-text"),require("../atoms/gv-input-message"),require("../atoms/gv-select");const t=require("../lib/events"),i=require("../lib/properties"),r=require("../lib/i18n"),o=require("lit/directives/class-map"),s=require("../mixins/keyboard-element"),n=require("../styles/empty");class a extends((0,s.KeyboardElement)(e.LitElement)){static get properties(){return{dynamicPropertySchema:{type:Object},properties:{type:Array},_properties:{type:Array,attribute:!1},provider:{type:Object},providers:{type:Array},_propertySchemaForm:{type:Object,attribute:!1},expert:{type:Boolean},_formattedErrors:{type:Array,attributes:!1},_filter:{type:String},_paginationData:{type:Object,attribute:!1},_pageSize:{type:Number,attribute:!1},_newItem:{type:Object,attribute:!1},_providerDocumentation:{type:Boolean,attribute:!1},_showDocumentation:{type:Boolean,attribute:!1},_textRows:{type:Number,attribute:!1},readonly:{type:Boolean,reflect:!0},encryptable:{type:Boolean,reflect:!0}}}constructor(){super(),this.properties=[],this.types=[],this.provider={},this._currentResource=null,this._formattedErrors=[],this._showDocumentation=!0,this._newItem={key:"",value:"",_new:!0},this._pageSize=10,this._textRows=10,this._pageSizes=[5,10,25,50,100],this._errors=[]}onKeyboard(){if(this.isPressed(s.KEYS.Esc)&&this._onClosePropertySchemaForm(),this.isPressed(s.KEYS.Shift,s.KEYS.Ctrl,s.KEYS.Space)){const e=this.shadowRoot.querySelector("#search-property");e&&e.focus()}}set properties(e){this._properties=e.sort(((e,t)=>e.key.localeCompare(t.key))).map((e=>(e.encrypted&&(e.encryptable=!0),e)))}get properties(){return this._properties}_getResizableViews(){return this.shadowRoot.querySelector("gv-resizable-views")}_maximizeTopView(){const e=this._getResizableViews();e&&e.maximizeTop(95,5)}_maximizeBottomView(){const e=this._getResizableViews();e&&e.resize(30,70)}_splitMainViews(){const e=this._getResizableViews();e&&e.split()}_isNewLineTable(e){return!0===e._new}_onInputNew(e,t){const r=t.target;this._newItem[e]=t.detail;const{errors:o}=(0,i.parseRaw)((0,i.toNameEqualsValueString)([...this.properties,this._newItem]));this._errors=o,setTimeout((()=>{const t=this.shadowRoot.querySelector("gv-button#add-property");o.length>0||this._disabledNewLine(this._newItem)?t.setAttribute("disabled",!0):t.removeAttribute("disabled"),"key"===e&&(0===o.length?(r.removeAttribute("invalid"),r.setAttribute("valid",!0)):(r.removeAttribute("valid"),r.setAttribute("invalid",!0)))}),0)}_onInput(){(0,t.dispatchCustomEvent)(this,"change",{properties:this.properties})}_onSwitchEncrypted(e){!0===e.encrypted&&(e.value="",e.encrypted=!1,e.encryptionWarning=(0,r.i18n)("gv-properties.infos.overwrite-encryption"),this.requestUpdate()),(0,t.dispatchCustomEvent)(this,"switch-encrypted",{properties:this.properties})}_addProperty(e){delete e._new,this.properties=[e,...this._properties],this._newItem={key:"",value:"",_new:!0,encryptable:!1,encrypted:!1},(0,t.dispatchCustomEvent)(this,"change",{properties:this.properties})}_removeProperty(e){this._properties=this._properties.filter((t=>t.key!==e.key)),(0,t.dispatchCustomEvent)(this,"change",{properties:this.properties})}_disabledNewLine(e){return null==e.key||null==e.value||""===e.key.trim()||""===e.value.trim()}_submitExpertMode(){this.expert&&(this.properties=this._handleExpertModeInput(this.shadowRoot.querySelector("#expert-input").value))}_onExpertModeTextInput({detail:e}){this._handleExpertModeInput(e)}_handleExpertModeInput(e){let r=this._properties;const o=this.provider&&this.provider.enabled,s=r.filter((e=>o&&e.dynamic)),n=r.filter((e=>e.encrypted)),a=`${e}\n${(0,i.toNameEqualsValueString)(s)}\n${(0,i.toNameEqualsValueString)(n)}`,{errors:p}=(0,i.parseRaw)(a);if(this._errors=p,0===p.length){const{variables:o}=(0,i.parseRaw)(e);r=[...o,...s,...n],(0,t.dispatchCustomEvent)(this,"change",{properties:r})}return r}_onSubmitPropertyForm({detail:e}){const i=e.values;(0,t.dispatchCustomEvent)(this,"save-provider",{provider:i}),this.requestUpdate()}submit(){this.expert?this._submitExpertMode():this._onSubmit()}_onSubmit(){null==[...this.shadowRoot.querySelectorAll("form .control")].find((e=>e.invalid))&&this._addProperty(this._newItem)}_onConfigureDynamicProperties(){if(null==this.dynamicPropertySchema){const e=this.providers.reduce(((e,t)=>(e[t.id]=t.key,e)),{}),t=Object.keys(e);this.dynamicPropertySchema={properties:{enabled:{type:"boolean",title:"Enabled",description:" This service is requiring an API deployment. Do not forget to deploy API to start dynamic-properties service."},schedule:{type:"string",title:"Schedule","x-schema-form":{"cron-expression":!0}},provider:{type:"string",title:"Provider type",enum:t,default:t[0],"x-schema-form":{titleMap:e}}},required:["schedule","provider"]}}const e=this.providers[0];this._propertySchemaForm={properties:{...this.dynamicPropertySchema.properties,configuration:e.schema},required:this.dynamicPropertySchema.required},this._providerDocumentation=e.documentation,this._maximizeBottomView()}_onClosePropertySchemaForm(){this._propertySchemaForm=null,this._maximizeTopView()}_onSearchProperty({detail:e}){this._filter=e,this._onClosePropertySchemaForm()}_onClearProperty(){this._filter=null,this._onClosePropertySchemaForm()}get _errors(){return this._formattedErrors}set _errors(e){this._formattedErrors=e.map((({type:e,key:t,pos:o})=>e===i.ERROR_TYPES.INVALID_NAME?{line:o.line,msg:(0,r.i18n)("gv-properties.errors.invalid-key",{key:t})}:e===i.ERROR_TYPES.DUPLICATED_NAME?{line:o.line,msg:(0,r.i18n)("gv-properties.errors.duplicated-key",{key:t})}:e===i.ERROR_TYPES.INVALID_LINE?{line:o.line,msg:(0,r.i18n)("gv-properties.errors.invalid-line")}:e===i.ERROR_TYPES.INVALID_VALUE?{line:o.line,msg:(0,r.i18n)("gv-properties.errors.invalid-value")}:{line:"?",msg:(0,r.i18n)("gv-properties.errors.unknown")}))}_renderErrors(t=!1){return this._formattedErrors.length>0?e.html`<div class="${(0,o.classMap)({"add-form-error":!0,"add-form-error_expert":this.expert})}"><div></div><div class="error-list">${this._formattedErrors.map((({line:i,msg:o})=>e.html`<gv-input-message>${t?e.html`<strong .innerHTML="${(0,r.i18n)("gv-properties.errors.line")} ${i}: "></strong>`:""} <span .innerHTML="${o}"></span></gv-input-message>`))}</div></div>`:e.html``}_renderTable(){const t=this.provider&&this.provider.enabled;if(this.expert){this._computeTextRows();const i=(t?this._properties.filter((e=>!(t&&e.dynamic))):this._properties).filter((e=>!e.encrypted)).map((e=>`${e.key}="${e.value}"`)).join("\n");return e.html`<gv-text id="expert-input" placeholder="${(0,r.i18n)("gv-properties.placeholder.input")}" @gv-text:input="${this._onExpertModeTextInput}" .value="${i}" ?readonly="${this.readonly}" .rows="${this._textRows}"></gv-text>${this._renderErrors(!0)}`}{const i={data:[{field:"dynamic",label:"Dynamic",width:"40px",type:e=>e.dynamic&&t?"gv-icon":"div",attributes:{shape:e=>e.dynamic&&t?"code:time-schedule":"",title:e=>e.dynamic&&t?"Dynamic properties service is actually in running":"",style:"justify-content: center; align-items: center; height: 100%;"}},{field:"key",label:"Key",type:"gv-input",attributes:{clipboard:!0,placeholder:(0,r.i18n)("gv-properties.placeholder.key"),name:"key",required:!0,readonly:this.readonly}},{field:"value",label:"Value",type:"gv-input",attributes:{name:"value",placeholder:"Property value",required:!0,readonly:this.readonly,disabled:e=>e.dynamic&&t||e.encrypted,type:e=>e.encrypted?"password":"text",title:e=>e.encrypted?(0,r.i18n)("gv-properties.infos.encrypted-value"):"",description:e=>e.encryptionWarning,icon:null,"ongv-input:input":this._onInput.bind(this)}}]};!0===this.encryptable&&i.data.push({field:"encryptable",type:"gv-switch",style:"--gv-switch--ta: right;",width:"105px",attributes:{description:(0,r.i18n)("gv-properties.encrypted-toggle"),required:!0,readonly:this.readonly,disabled:e=>e.dynamic&&t,"ongv-switch:input":this._onSwitchEncrypted.bind(this),style:"display: inline-flex; font-size: 12px; height: 40px;"}}),!0!==this.readonly&&i.data.push({type:"gv-button",width:"40px",attributes:{"ongv-button:click":(e,t,i)=>this._removeProperty(e,i),title:"Remove",disabled:e=>e.dynamic&&t,danger:!0,outlined:!0,icon:"home:trash"}});const o=null!=this._filter?this._properties.filter((e=>(e.key.toLowerCase()+e.value.toLowerCase()).includes(this._filter))):this._properties;let s=[...o];if(this._paginationData){this._paginationData.last=Math.ceil(o.length/this._pageSize),this._paginationData.total=o.length,this._paginationData.total_pages=Math.ceil(o.length/this._pageSize);const e=(this._paginationData.current_page-1)*this._pageSize;s=[...o].splice(e,this._pageSize)}const n=this.encryptable?"add-form-grid-with-encrypted-toggle":"add-form-grid",a=!0!==this.readonly?e.html`<form id="add-property-form" class="add-form ${n}" @submit="${this._onSubmit}"><div></div><gv-input class="control" placeholder="${(0,r.i18n)("gv-properties.placeholder.key")}" required @gv-input:input="${this._onInputNew.bind(this,"key")}" value="${this._newItem.key}"></gv-input><gv-input class="control" placeholder="${(0,r.i18n)("gv-properties.placeholder.value")}" required @gv-input:input="${this._onInputNew.bind(this,"value")}" .value="${this._newItem.value}"></gv-input>${this.encryptable?e.html`<gv-switch class="control" required description="${(0,r.i18n)("gv-properties.encrypted-toggle")}" @gv-switch:input="${this._onInputNew.bind(this,"encryptable")}" .value="${this._newItem.encryptable}"></gv-switch>`:""}<gv-button id="add-property" icon="code:plus" outlined disabled="disabled" @gv-button:click="${this._addProperty.bind(this,this._newItem)}" title="${(0,r.i18n)("gv-properties.add")}"></gv-button></form>${this._renderErrors()}<hr>`:"";return e.html`${a}<gv-table .options="${i}" .items="${s}" noheader nosort order="key" rowheight="57px"></gv-table>`}}_onChangeMode({detail:e}){this._submitExpertMode(),this.expert=e,this._errors=[],this._newItem={key:"",value:"",_new:!0},this._onClosePropertySchemaForm()}_onPaginate({detail:e}){this._paginationData.current_page=e.page,this._onClosePropertySchemaForm(),this.requestUpdate()}updated(e){(e.has("_properties")||e.has("_pageSize"))&&(this._paginationData={first:1,last:Math.ceil(this._properties.length/this._pageSize),total:this._properties.length,current_page:1,total_pages:Math.ceil(this._properties.length/this._pageSize)})}_onChangePageSize({detail:e}){this._pageSize=Number(e).valueOf(),this._onClosePropertySchemaForm()}_renderTableForm(){return e.html`<div class="container"><div class="header"><div class="title">Manage global properties <span>(${this._properties?this._properties.length:0})</span></div><gv-switch small .description="${this.expert?"Expert":"Simple"}" .value="${this.expert}" @gv-switch:input="${this._onChangeMode}"></gv-switch><gv-input id="search-property" placeholder="Filter properties (Shift + Ctrl + Space)" type="search" small class="search-input" .disabled="${this.expert}" @gv-input:input="${this._onSearchProperty}" @gv-input:clear="${this._onClearProperty}"></gv-input><gv-select class="page-size__select" @gv-select:input="${this._onChangePageSize}" small .options="${this._pageSizes}" .value="${this._pageSize}" .disabled="${this.expert||null==this._paginationData}"></gv-select><gv-pagination @gv-pagination:paginate="${this._onPaginate}" .disabled="${this.expert||null==this._paginationData}" .data="${this._paginationData}" widget></gv-pagination></div><div class="content"><div class="form-content">${this._renderTable()}</div></div></div>`}_fetchDocumentation(){this._showDocumentation=!0}_hideDocumentation(){this._showDocumentation=!1}get dirty(){const e=this.shadowRoot.querySelector("gv-schema-form");return e&&e.dirty}confirm(){const e=this.shadowRoot.querySelector("gv-schema-form");return e?e.confirm().then((()=>this._onClosePropertySchemaForm())):Promise.resolve()}_renderForm(){return e.html`<gv-schema-form slot="top" scrollable .schema="${this._propertySchemaForm}" .values="${this.provider}" .icon="design:edit" has-header ?readonly="${this.readonly}" @gv-schema-form:submit="${this._onSubmitPropertyForm}"><div slot="title" class="properties-title">Configure dynamic properties</div><gv-button slot="header-left" icon="general:close" outlined small @gv-button:click="${this._onClosePropertySchemaForm}" title="Close (esc)"></gv-button><gv-button slot="header-left" icon="home:book" ?disabled="${this._showDocumentation}" outlined small @gv-button:click="${this._fetchDocumentation}" title="Open documentation"></gv-button></gv-schema-form>`}_renderBottom(){return this._propertySchemaForm&&this._showDocumentation?e.html`<gv-resizable-views no-overflow direction="horizontal">${this._renderForm()}<gv-documentation slot="bottom" .text="${this._providerDocumentation}" @gv-documentation:close="${this._hideDocumentation}"></gv-documentation></gv-resizable-views>`:this._propertySchemaForm?this._renderForm():e.html`<div class="properties-bottom-container">${this._renderDynamicConfiguration()}</div>`}_renderDynamicConfiguration(){const t=this.provider&&this.provider.enabled;let i="";return(t||!0!==this.readonly)&&(i=e.html`<gv-button icon="tools:tools" @gv-button:click="${this._onConfigureDynamicProperties}" outlined .disabled="${this.expert}">Configure dynamic properties</gv-button>`),t?e.html`<div class="properties-message">Dynamic properties service is actually in <code>running</code> state and run with cron expression <code>${this.provider.schedule}</code> using <code>${this.provider.provider}</code> provider.</div>${i}`:this.readonly?e.html`<div class="empty">No dynamic properties service configured</div>`:i}_onMove(){this._computeTextRows()}_computeTextRows(){const e=this.shadowRoot.querySelector(".content");if(e){const{height:t}=e.getBoundingClientRect();this._textRows=Math.round(Math.round(t-20)/30)-2}}render(){return this.providers&&this.providers.length>0?e.html`<div class="properties"><gv-resizable-views no-overflow @gv-resizable-views:move="${this._onMove}" @gv-resizable-views:resize="${this._onMove}"><div slot="top" class="box">${this._renderTableForm()}</div><div slot="bottom">${this._renderBottom()}</div></gv-resizable-views></div>`:e.html`<div class="properties"><div class="table-box">${this._renderTableForm()}</div></div>`}static get styles(){return[n.empty,e.css`:host{box-sizing:border-box;height:100%;width:100%;display:block}.properties{display:flex;height:100%;width:100%}gv-resizable-views{height:100%;width:100%}gv-schema-form{margin:0}.table-box{width:100%;border-left:1px solid #bfbfbf;display:flex}gv-table{height:auto;flex:1;margin-top:10px;margin-right:50px;--gv-table-rows--ov:none;--gv-table--colmg:var(--gv-properties-table--colmg, 0.2rem);--gv-table-cell--d:inline;--gv-table-row--ai:flex-start;--gv-table-row--ac:flex-start;--gv-table-hover--bgc:var(--gv-theme-neutral-color-lightest)}.properties-title{text-transform:uppercase;letter-spacing:.2rem}.properties-bottom-container{display:flex;justify-content:center;align-items:center;height:100%;flex-direction:column}.header{border-bottom:1px solid #d9d9d9;display:flex;min-height:45px;align-items:center;margin-bottom:.5rem;padding:0 .5rem}.header .title{color:#28444f;font-size:18px;display:flex;align-items:flex-end;flex:1}.header .title span{font-size:12px;margin-left:8px;opacity:.7}.box{position:absolute;display:flex;flex-direction:column;width:100%;top:0;bottom:0;left:0}.container{flex-grow:1;display:flex;flex-direction:column;min-height:0;height:100%}.content{background:#fff;flex-grow:1;overflow:auto;min-height:0;padding:.5rem;display:flex;flex-direction:column;align-items:center}gv-text{--gv-text--fz:20px;--gv-text--lh:25px}gv-switch{--gv-switch--ta:right}.header gv-input{margin:0 1rem}.add-form,.add-form-error{display:grid;margin:auto 50px auto 0;box-sizing:border-box}.add-form{column-gap:var(--gv-properties-table--colmg,.2rem);border-right:solid thick transparent;height:50px}.add-form gv-input,gv-button,gv-switch{margin:auto 0}.add-form gv-switch{font-size:12px}.add-form-grid{grid-template-columns:40px auto auto 40px}.add-form-grid-with-encrypted-toggle{grid-template-columns:40px auto auto 105px 40px}.add-form-error_expert{display:flex}.add-form-error{grid-template-columns:40px 1fr}code{color:var(--gv-theme-color-warning-dark,#f57c00)}.form-content{display:flex;flex-direction:column;width:100%}.properties-message{margin-bottom:.5rem;font-size:14px}.page-size__select{max-width:50px}.search-input{width:300px}hr{background-color:var(--gv-theme-neutral-color);border:0;width:100%;height:2px}`]}}exports.GvProperties=a,window.customElements.define("gv-properties",a);