@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,751 +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 { LitElement, html, css } from 'lit';
17
- import { get, set, del } from 'object-path';
18
- import { dispatchCustomEvent } from '../lib/events';
19
- import { deepClone, deepEqual } from '../lib/utils';
20
- import { classMap } from 'lit/directives/class-map';
21
- import { repeat } from 'lit/directives/repeat';
22
- import { Validator } from 'jsonschema';
23
- import { empty } from '../styles/empty';
24
- import './gv-schema-form-control';
25
-
26
- /**
27
- * Schema form component
28
- *
29
- * @fires gv-schema-form:submit - event when user submit valid form
30
- * @fires gv-schema-form:error - event when user submit invalid form
31
- * @fires gv-schema-form:change - event when when form change
32
- * @fires gv-schema-form:cancel - event when user cancel form
33
- *
34
- * @attr {Object} schema - the schema form configuration
35
- * @attr {Object} values - the values of fields
36
- * @attr {Object} errors - the map of errors by input key
37
- * @attr {Boolean} validate - to force validation on first render
38
- * @attr {Boolean} readonly - true if readonly
39
- * @attr {Boolean} scrollable - useful for making content scrollable with fixed headers / footers
40
- *
41
- * @cssprop {Color} [--gv-schema-form--bgc=#ffffff] - Background color
42
- * @cssprop {Length} [--gv-schema-form-control--m=0.4rem] - Control margin
43
- */
44
- export class GvSchemaForm extends LitElement {
45
- static get properties() {
46
- return {
47
- schema: { type: Object },
48
- errors: { type: Object },
49
- values: { type: Object },
50
- submitLabel: { type: String },
51
- hasFooter: { type: Boolean, attribute: 'has-footer' },
52
- hasHeader: { type: Boolean, attribute: 'has-header' },
53
- _confirm: { type: Object },
54
- _values: { type: Object, attribute: false },
55
- dirty: { type: Boolean, reflect: true },
56
- hideDeprecated: { type: Boolean, attribute: 'hide-deprecated' },
57
- validateOnRender: { type: Boolean, attribute: 'validate-on-render' },
58
- _validatorResults: { type: Object },
59
- skeleton: { type: Boolean, reflect: true },
60
- _touch: { type: Boolean },
61
- readonly: { type: Boolean, reflect: true },
62
- scrollable: { type: Boolean, reflect: true },
63
- groups: { type: Array },
64
- };
65
- }
66
-
67
- constructor() {
68
- super();
69
- this.hideDeprecated = false;
70
- this._values = {};
71
- this.submitLabel = 'Ok';
72
- this.hasHeader = false;
73
- this.hasFooter = false;
74
- this._touch = false;
75
- this._validator = new Validator();
76
- this._validatorResults = {};
77
- this._ignoreProperties = [];
78
- this._dynamicControls = [];
79
- this._dynamicAttributes = ['disabled', 'required', 'hidden'];
80
- this.groups = null;
81
- this.addEventListener('gv-schema-form-control:default-value', this._onDefaultValue.bind(this));
82
- this.addEventListener('gv-schema-form-control:change', this._onChange.bind(this));
83
- this.addEventListener('gv-schema-form-control:control-ready', this._onControlReady.bind(this));
84
- }
85
-
86
- set values(values) {
87
- if (!deepEqual(this._values, values)) {
88
- if (values) {
89
- this._initialValues = { ...values };
90
- } else {
91
- this._initialValues = {};
92
- }
93
- this._values = deepClone(this._initialValues);
94
- }
95
- }
96
-
97
- get values() {
98
- return this._values;
99
- }
100
-
101
- reset(values = null) {
102
- this._values = deepClone(values || this._initialValues);
103
- this._touch = false;
104
- this._setDirty(false);
105
- this.getControls().forEach((s) => {
106
- s.requestUpdate();
107
- });
108
- }
109
-
110
- _onReset() {
111
- this.reset();
112
- dispatchCustomEvent(this, 'reset');
113
- }
114
-
115
- requestValidation() {
116
- clearTimeout(this._validateTimeout);
117
- this._validateTimeout = setTimeout(() => {
118
- this.validate();
119
- this._updateActions();
120
- }, 350);
121
- }
122
-
123
- submit() {
124
- this._onSubmit();
125
- }
126
-
127
- _onSubmit() {
128
- const validatorResults = this.validate();
129
- if (this.isValid()) {
130
- this._initialValues = deepClone(this._values);
131
- this.dirty = false;
132
- this._touch = false;
133
- dispatchCustomEvent(this, 'submit', { values: this._values, validatorResults });
134
- } else {
135
- dispatchCustomEvent(this, 'error', { values: this._values, validatorResults });
136
- }
137
- }
138
-
139
- _setDirty(dirty = true) {
140
- this.dirty = !!dirty;
141
- }
142
-
143
- _setTouch(touch = true) {
144
- this._touch = !!touch;
145
- }
146
-
147
- confirm() {
148
- if (this.isTouch()) {
149
- if (this._confirm && this._confirm.promise) {
150
- return this._confirm.promise;
151
- }
152
- const promise = new Promise((resolve, reject) => (this._confirm = { resolve, reject }));
153
- this._confirm.promise = promise;
154
- return promise;
155
- }
156
- return Promise.resolve();
157
- }
158
-
159
- _onConfirmReset() {
160
- const { resolve } = this._confirm;
161
- this._confirm = null;
162
- this._onReset();
163
- this.requestUpdate();
164
- this.updateComplete.then(() => {
165
- resolve(this);
166
- });
167
- }
168
-
169
- _onConfirmEdit() {
170
- this._confirm.reject(this);
171
- this._confirm = null;
172
- this._updateChildren(this.validateOnRender);
173
- }
174
-
175
- _getSubmitBtn() {
176
- return this.shadowRoot.querySelector('#submit');
177
- }
178
-
179
- _getResetBtn() {
180
- return this.shadowRoot.querySelector('#reset');
181
- }
182
-
183
- _dispatchChange() {
184
- clearTimeout(this._changeTimeout);
185
- this._changeTimeout = setTimeout(() => {
186
- dispatchCustomEvent(this, 'change', { target: this, values: this._values, validation: this._validatorResults });
187
- }, 50);
188
- }
189
-
190
- _onDefaultValue({ detail: { currentTarget, value, control } }) {
191
- if (control.type === 'integer' && value != null && ((value.trim && value.length > 0) || value.length > 0)) {
192
- value = parseInt(value, 10);
193
- }
194
- set(this._values, currentTarget.id, value);
195
- }
196
-
197
- _onChange({ detail: { currentTarget, value, control } }) {
198
- this._setTouch(true);
199
- if (control.type === 'integer') {
200
- if (typeof value === 'string' && value.trim().length === 0) {
201
- value = null;
202
- } else {
203
- const intValue = Number(value).valueOf();
204
- if (!isNaN(intValue)) {
205
- value = intValue;
206
- } else {
207
- value = null;
208
- }
209
- }
210
- } else if (control.type === 'array' && value.length === 0) {
211
- value = null;
212
- } else if (control.type === 'string' && value.trim().length === 0 && !control.enum) {
213
- value = null;
214
- } else if (control.type === 'object') {
215
- if (Object.keys(value).length === 0) {
216
- value = null;
217
- }
218
- }
219
- if (value == null) {
220
- del(this._values, currentTarget.id);
221
- } else {
222
- set(this._values, currentTarget.id, value);
223
- }
224
-
225
- this._updateDynamicControls();
226
- this._validatorResults = this.validate();
227
- this.dirty = true;
228
- this._updateActions();
229
- this._dispatchChange();
230
- }
231
-
232
- _onControlReady(e) {
233
- e.stopPropagation();
234
- e.preventDefault();
235
- const controlElement = e.detail.control;
236
- const control = controlElement.control;
237
- if (control['x-schema-form']) {
238
- if (control['x-schema-form'].event) {
239
- const event = control['x-schema-form'].event;
240
- dispatchCustomEvent(this, event.name, { ...event, ...e.detail });
241
- } else if (this._hasCondition(control)) {
242
- this._dynamicControls.push(controlElement);
243
- this._updateDynamicControl(controlElement);
244
- }
245
- }
246
- }
247
-
248
- _updateDynamicControls() {
249
- this._ignoreProperties = [];
250
- this._dynamicControls.forEach((controlElement) => {
251
- this._updateDynamicControl(controlElement);
252
- });
253
- }
254
-
255
- _updateDynamicControl(controlElement) {
256
- const control = controlElement.control;
257
- if (control['x-schema-form']) {
258
- this._dynamicAttributes.forEach((attribute) => {
259
- const is = this._evaluateCondition(control, attribute);
260
- if (is) {
261
- controlElement.setAttribute(attribute, '');
262
- if (attribute === 'hidden') {
263
- this._ignoreProperties.push(controlElement.id);
264
- }
265
- } else {
266
- controlElement.removeAttribute(attribute);
267
- }
268
- });
269
- }
270
- return null;
271
- }
272
-
273
- async performUpdate() {
274
- await Promise.all(this.getControls().map((e) => e.updateComplete));
275
- this.getControls().forEach((s) => {
276
- s.requestUpdate();
277
- });
278
- super.performUpdate();
279
- }
280
-
281
- _renderControl(key) {
282
- // This is require to clean cache of <gv-schema-form-control>
283
- const control = { ...this.schema.properties[key] };
284
- const isRequired = (this.schema.required && this.schema.required.includes(key)) || this._evaluateCondition(control, 'required');
285
- const isDisabled = (this.schema.disabled && this.schema.disabled.includes(key)) || this._evaluateCondition(control, 'disabled');
286
- const isHidden = this._evaluateCondition(control, 'hidden');
287
- if (isHidden) {
288
- this._ignoreProperties.push(key);
289
- }
290
- const isReadonly = this.readonly || control.readOnly === true;
291
- const isWriteOnly = control.writeOnly === true;
292
- const value = get(this._values, key);
293
- return html`<gv-schema-form-control
294
- .id="${key}"
295
- .errors="${this.errors}"
296
- .control="${control}"
297
- .skeleton="${this.skeleton}"
298
- .value="${value}"
299
- ?readonly="${isReadonly}"
300
- ?writeonly="${isWriteOnly}"
301
- ?required="${isRequired}"
302
- ?disabled="${isDisabled}"
303
- ?hidden="${isHidden}"
304
- ></gv-schema-form-control>`;
305
- }
306
-
307
- _hasCondition(control) {
308
- if (control['x-schema-form']) {
309
- return this._dynamicAttributes.find((condition) => control['x-schema-form'][condition] != null) != null;
310
- }
311
- return false;
312
- }
313
-
314
- _evaluateCondition(control, conditionKey) {
315
- if (control['x-schema-form'] == null || control['x-schema-form'][conditionKey] == null) {
316
- return false;
317
- }
318
- const condition = control['x-schema-form'][conditionKey];
319
- if (typeof condition === 'boolean') {
320
- return condition;
321
- }
322
- if (!Array.isArray(condition)) {
323
- // condition isn't an array, ignore the condition
324
- console.warn(`'${conditionKey}' attribute of 'x-schema-form' should be an array`);
325
- return false;
326
- }
327
-
328
- let result = true;
329
- for (const operation of condition) {
330
- // operation only have one operator with a single object containing operand values
331
- const operator = Object.keys(operation)[0];
332
-
333
- switch (operator) {
334
- case '$neq':
335
- result = result && this._evaluateNotEqualsCondition(control, operation);
336
- break;
337
- case '$eq':
338
- result = result && this._evaluateEqualsCondition(control, operation);
339
- break;
340
- case '$nodef':
341
- result = result && this._evaluateNotDefCondition(control, operation);
342
- break;
343
- case '$def':
344
- result = result && this._evaluateDefCondition(control, operation);
345
- break;
346
- default:
347
- console.warn(`Unsupported operator '${operator}' on disable condition`);
348
- result = false;
349
- break;
350
- }
351
- }
352
-
353
- return result;
354
- }
355
-
356
- _evaluateNotEqualsCondition(control, condition) {
357
- return !this._evaluateEqualsCondition(control, condition);
358
- }
359
-
360
- _evaluateEqualsCondition(control, condition) {
361
- const operator = Object.keys(condition)[0];
362
- const operands = condition[operator];
363
- const modelAttributes = Object.keys(operands);
364
- return modelAttributes
365
- .map((modelAttribute) => {
366
- const testValue = operands[modelAttribute];
367
- let value = get(this._values, modelAttribute);
368
- if (value == null && control.type === 'string') {
369
- value = '';
370
- }
371
- if (Array.isArray(testValue)) {
372
- return testValue.includes(value);
373
- }
374
- return value === testValue;
375
- })
376
- .reduce((acc, current) => acc || current);
377
- }
378
-
379
- _evaluateNotDefCondition(control, condition) {
380
- const operator = Object.keys(condition)[0];
381
- const modelAttribute = condition[operator];
382
- return get(this._values, modelAttribute) === undefined || get(this._values, modelAttribute) === null;
383
- }
384
-
385
- _evaluateDefCondition(control, condition) {
386
- return !this._evaluateNotDefCondition(control, condition);
387
- }
388
-
389
- _renderPart() {
390
- if (this._confirm) {
391
- return html`<div class="confirm-box">
392
- <div class="error">The configuration is not valid and cannot be saved.</div>
393
- <div class="confirm-box_actions">
394
- <gv-button @gv-button:click="${this._onConfirmReset}" outlined icon="general:update" danger>Lose changes</gv-button>
395
- <gv-button @gv-button:click="${this._onConfirmEdit}" icon="design:edit">Edit</gv-button>
396
- </div>
397
- </div>`;
398
- }
399
- const keys = this.schema.properties ? Object.keys(this.schema.properties) : [];
400
- this._ignoreProperties = [];
401
-
402
- if (this.groups) {
403
- // Remove undefined group items
404
- const groupsCleaned = this.groups.reduce((prev, group) => {
405
- const itemsExistingInSchemaKeys = keys.filter((key) => [...(group.items || [])].includes(key));
406
- prev.push({
407
- ...group,
408
- items: itemsExistingInSchemaKeys || [],
409
- });
410
- return prev;
411
- }, []);
412
-
413
- // Add non grouped items inside default group
414
- const defaultGroup = groupsCleaned.find((g) => g.default) || { default: true, items: [] };
415
- const zipGroupedItems = groupsCleaned.reduce((prev, group) => [...prev, ...group.items], []);
416
- defaultGroup.items = keys.filter((key) => !zipGroupedItems.includes(key));
417
-
418
- return repeat(
419
- groupsCleaned,
420
- (group) =>
421
- html`${group.name
422
- ? html`<h2 class="group-title">${group.name}</h2>
423
- ${repeat(group.items, (key) => this._renderControl(key))}`
424
- : repeat(group.items, (key) => this._renderControl(key))} `,
425
- );
426
- }
427
-
428
- return html`${repeat([1], () =>
429
- repeat(
430
- keys,
431
- (key) => key,
432
- (key) => this._renderControl(key),
433
- ),
434
- )}`;
435
- }
436
-
437
- getControls() {
438
- return Array.from(this.shadowRoot.querySelectorAll('gv-schema-form-control'));
439
- }
440
-
441
- getControl(id) {
442
- return this.shadowRoot.querySelector(`[id="${id}"]`);
443
- }
444
-
445
- _getErrors() {
446
- return (this._validatorResults.errors || []).filter((error) => {
447
- let id = `${error.property.replace('instance.', '')}`;
448
- if (!Array.isArray(error.argument)) {
449
- id = `${id}.${error.argument}`;
450
- }
451
-
452
- const errorKey = `x-schema-form.errors.${id}.${error.name}`;
453
- const errorMessage = get(this.schema, errorKey);
454
- if (errorMessage) {
455
- error.message = errorMessage;
456
- }
457
- return !this._ignoreProperties.includes(id);
458
- });
459
- }
460
-
461
- validate() {
462
- if (this.schema) {
463
- // Additional properties should not block the validation of the form
464
- this._validatorResults = this._validator.validate(this._values, { ...this.schema, additionalProperties: {} });
465
- this.errors = this._getErrors();
466
- }
467
- return this._validatorResults;
468
- }
469
-
470
- isValid() {
471
- if (this._validatorResults.valid) {
472
- return true;
473
- }
474
- return this._getErrors() === 0;
475
- }
476
-
477
- isTouch() {
478
- return this._touch || (this.dirty && this.validateOnRender);
479
- }
480
-
481
- canSubmit() {
482
- return this.isTouch() && this.isValid();
483
- }
484
-
485
- _updateActions() {
486
- const submitBtn = this._getSubmitBtn();
487
- if (submitBtn != null) {
488
- if (this.canSubmit()) {
489
- this._getSubmitBtn().removeAttribute('disabled');
490
- } else {
491
- this._getSubmitBtn().setAttribute('disabled', true);
492
- }
493
- }
494
- const resetBtn = this._getResetBtn();
495
- if (resetBtn != null) {
496
- if (this.dirty) {
497
- resetBtn.removeAttribute('disabled');
498
- } else {
499
- resetBtn.setAttribute('disabled', true);
500
- }
501
- }
502
- }
503
-
504
- _updateChildren(withValidation) {
505
- if (withValidation) {
506
- this._validatorResults = {};
507
- this.errors = null;
508
- this.requestValidation();
509
- } else {
510
- this._updateActionsTimeout = setTimeout(() => this._updateActions(), 0);
511
- }
512
- }
513
-
514
- async updated(changedProperties) {
515
- clearTimeout(this._updateActionsTimeout);
516
- if (changedProperties.has('_values')) {
517
- this.getControls().forEach((control) => {
518
- control.value = get(this._values, control.id);
519
- });
520
- }
521
- this._updateChildren(this.validateOnRender && (changedProperties.has('_values') || changedProperties.has('schema')));
522
- }
523
-
524
- async getUpdateComplete() {
525
- const result = await super.getUpdateComplete();
526
- await Promise.all(this.getControls().map((e) => e.updateComplete));
527
- return result;
528
- }
529
-
530
- render() {
531
- return html`<form class="${classMap({ scrollable: this.scrollable })}">
532
- <div class="${classMap({ container: true, confirm: this._confirm })}">
533
- ${this.hasHeader === true
534
- ? html`
535
- <div class="header">
536
- <div class="${classMap({ title: true, center: this.hasHeader && !this.hasFooter })}">
537
- <slot name="title"></slot>
538
- </div>
539
- <div class="left">
540
- <slot name="header-left"></slot>
541
- </div>
542
- ${this.readonly === true || this.hasFooter === true
543
- ? ''
544
- : html`<div class="right">
545
- <gv-button
546
- id="reset"
547
- outlined
548
- small
549
- @gv-button:click="${this._onReset}"
550
- icon="general:update"
551
- title="Reset"
552
- ></gv-button>
553
- <gv-button
554
- id="submit"
555
- small
556
- @gv-button:click="${this._onSubmit}"
557
- icon="code:check"
558
- .title="${this.submitLabel}"
559
- ></gv-button>
560
- </div> `}
561
- </div>
562
- `
563
- : ''}
564
- <div class="content">${this.schema != null ? this._renderPart() : html``}</div>
565
- ${this.hasFooter === true && this.readonly !== true
566
- ? html`
567
- <div class="footer">
568
- <div class="left"></div>
569
- <div class="right">
570
- <gv-button id="reset" outlined @gv-button:click="${this._onReset}" icon="general:update" title="Reset">Reset</gv-button>
571
- <gv-button id="submit" @gv-button:click="${this._onSubmit}" icon="code:check" .title="${this.submitLabel}"
572
- >${this.submitLabel}</gv-button
573
- >
574
- </div>
575
- </div>
576
- `
577
- : ''}
578
- </div>
579
- </form>`;
580
- }
581
-
582
- static get styles() {
583
- return [
584
- empty,
585
- // language=CSS
586
- css`
587
- :host {
588
- box-sizing: border-box;
589
- margin: 0.2rem;
590
- --bgc: var(--gv-schema-form--bgc, #ffffff);
591
- }
592
-
593
- form {
594
- display: flex;
595
- flex-direction: column;
596
- }
597
-
598
- form.scrollable {
599
- position: absolute;
600
- width: 100%;
601
- top: 0;
602
- bottom: 0;
603
- left: 0;
604
- }
605
-
606
- .container {
607
- flex-grow: 1;
608
-
609
- background-color: var(--bgc);
610
- display: flex;
611
- flex-direction: column;
612
-
613
- /* for Firefox */
614
- min-height: 0;
615
- }
616
-
617
- .header,
618
- .footer,
619
- .content {
620
- background-color: var(--bgc);
621
- }
622
-
623
- .content {
624
- flex-grow: 1;
625
- display: flex;
626
- flex-direction: column;
627
- align-self: center;
628
- width: 100%;
629
-
630
- /* for Firefox */
631
- min-height: 0;
632
- }
633
-
634
- .content > gv-schema-form-control {
635
- align-self: center;
636
- width: 100%;
637
- }
638
-
639
- form.scrollable .content {
640
- overflow: auto;
641
- }
642
-
643
- form.scrollable .content > gv-schema-form-control,
644
- form.scrollable .content > .group-title {
645
- max-width: 775px;
646
- width: 95%;
647
- }
648
-
649
- .header,
650
- .footer {
651
- display: flex;
652
- box-sizing: border-box;
653
- min-height: 45px;
654
- --gv-icon--s: 26px;
655
- --gv-icon--c: #bfbfbf;
656
- align-items: center;
657
- padding: 0 0.5rem;
658
- position: relative;
659
- }
660
-
661
- .header {
662
- border-bottom: 1px solid #d9d9d9;
663
- }
664
-
665
- .footer {
666
- display: flex;
667
- justify-content: space-between;
668
- padding: 1rem;
669
- border-top: 1px solid #d9d9d9;
670
- }
671
-
672
- form.scrollable .footer {
673
- justify-content: center;
674
- }
675
-
676
- .footer .left,
677
- .footer .right {
678
- max-width: 400px;
679
- }
680
-
681
- .header .left,
682
- .footer .left,
683
- .header .right,
684
- .footer .right {
685
- display: flex;
686
- flex: 1;
687
- z-index: 10;
688
- align-items: center;
689
- }
690
-
691
- .header .right,
692
- .footer .right {
693
- justify-content: flex-end;
694
- }
695
-
696
- .header .title {
697
- color: #28444f;
698
- font-size: 18px;
699
- display: flex;
700
- width: 100%;
701
- align-items: center;
702
- }
703
-
704
- .header .title.center {
705
- position: absolute;
706
- top: 0;
707
- left: 0;
708
- bottom: 0;
709
- justify-content: center;
710
- }
711
-
712
- .confirm-box {
713
- height: 100%;
714
- padding: 1rem;
715
- font-style: italic;
716
- display: flex;
717
- flex-direction: column;
718
-
719
- justify-content: center;
720
- align-items: center;
721
- text-align: center;
722
- }
723
-
724
- .confirm-box_actions {
725
- padding: 1rem 0;
726
- }
727
-
728
- .confirm .header .left,
729
- .confirm .header .right,
730
- .confirm .footer .left,
731
- .confirm .footer .right {
732
- display: none;
733
- }
734
-
735
- .group-title {
736
- align-self: center;
737
- width: 100%;
738
- color: var(--gv-theme-font-color-dark);
739
- font-size: 21px;
740
- font-weight: 600;
741
- padding-bottom: 0.3em;
742
- border-bottom: 1px solid var(--gv-theme-font-color-dark);
743
- margin-top: 24px;
744
- margin-bottom: 16px;
745
- }
746
- `,
747
- ];
748
- }
749
- }
750
-
751
- window.customElements.define('gv-schema-form', GvSchemaForm);
1
+ Object.defineProperty(exports,"__esModule",{value:!0}),exports.GvSchemaForm=void 0;const t=require("lit"),e=require("object-path"),i=require("../lib/events"),s=require("../lib/utils"),o=require("lit/directives/class-map"),r=require("lit/directives/repeat"),a=require("jsonschema"),n=require("../styles/empty");require("./gv-schema-form-control");class l extends t.LitElement{static get properties(){return{schema:{type:Object},errors:{type:Object},values:{type:Object},submitLabel:{type:String},hasFooter:{type:Boolean,attribute:"has-footer"},hasHeader:{type:Boolean,attribute:"has-header"},_confirm:{type:Object},_values:{type:Object,attribute:!1},dirty:{type:Boolean,reflect:!0},hideDeprecated:{type:Boolean,attribute:"hide-deprecated"},validateOnRender:{type:Boolean,attribute:"validate-on-render"},_validatorResults:{type:Object},skeleton:{type:Boolean,reflect:!0},_touch:{type:Boolean},readonly:{type:Boolean,reflect:!0},scrollable:{type:Boolean,reflect:!0},groups:{type:Array}}}constructor(){super(),this.hideDeprecated=!1,this._values={},this.submitLabel="Ok",this.hasHeader=!1,this.hasFooter=!1,this._touch=!1,this._validator=new a.Validator,this._validatorResults={},this._ignoreProperties=[],this._dynamicControls=[],this._dynamicAttributes=["disabled","required","hidden"],this.groups=null,this.addEventListener("gv-schema-form-control:default-value",this._onDefaultValue.bind(this)),this.addEventListener("gv-schema-form-control:change",this._onChange.bind(this)),this.addEventListener("gv-schema-form-control:control-ready",this._onControlReady.bind(this))}set values(t){(0,s.deepEqual)(this._values,t)||(this._initialValues=t?{...t}:{},this._values=(0,s.deepClone)(this._initialValues))}get values(){return this._values}reset(t=null){this._values=(0,s.deepClone)(t||this._initialValues),this._touch=!1,this._setDirty(!1),this.getControls().forEach((t=>{t.requestUpdate()}))}_onReset(){this.reset(),(0,i.dispatchCustomEvent)(this,"reset")}requestValidation(){clearTimeout(this._validateTimeout),this._validateTimeout=setTimeout((()=>{this.validate(),this._updateActions()}),350)}submit(){this._onSubmit()}_onSubmit(){const t=this.validate();this.isValid()?(this._initialValues=(0,s.deepClone)(this._values),this.dirty=!1,this._touch=!1,(0,i.dispatchCustomEvent)(this,"submit",{values:this._values,validatorResults:t})):(0,i.dispatchCustomEvent)(this,"error",{values:this._values,validatorResults:t})}_setDirty(t=!0){this.dirty=!!t}_setTouch(t=!0){this._touch=!!t}confirm(){if(this.isTouch()){if(this._confirm&&this._confirm.promise)return this._confirm.promise;const t=new Promise(((t,e)=>this._confirm={resolve:t,reject:e}));return this._confirm.promise=t,t}return Promise.resolve()}_onConfirmReset(){const{resolve:t}=this._confirm;this._confirm=null,this._onReset(),this.requestUpdate(),this.updateComplete.then((()=>{t(this)}))}_onConfirmEdit(){this._confirm.reject(this),this._confirm=null,this._updateChildren(this.validateOnRender)}_getSubmitBtn(){return this.shadowRoot.querySelector("#submit")}_getResetBtn(){return this.shadowRoot.querySelector("#reset")}_dispatchChange(){clearTimeout(this._changeTimeout),this._changeTimeout=setTimeout((()=>{(0,i.dispatchCustomEvent)(this,"change",{target:this,values:this._values,validation:this._validatorResults})}),50)}_onDefaultValue({detail:{currentTarget:t,value:i,control:s}}){"integer"===s.type&&null!=i&&(i.trim&&i.length>0||i.length>0)&&(i=parseInt(i,10)),(0,e.set)(this._values,t.id,i)}_onChange({detail:{currentTarget:t,value:i,control:s}}){if(this._setTouch(!0),"integer"===s.type)if("string"==typeof i&&0===i.trim().length)i=null;else{const t=Number(i).valueOf();i=isNaN(t)?null:t}else"array"===s.type&&0===i.length?i=null:"string"!==s.type||0!==i.trim().length||s.enum?"object"===s.type&&0===Object.keys(i).length&&(i=null):i=null;null==i?(0,e.del)(this._values,t.id):(0,e.set)(this._values,t.id,i),this._updateDynamicControls(),this._validatorResults=this.validate(),this.dirty=!0,this._updateActions(),this._dispatchChange()}_onControlReady(t){t.stopPropagation(),t.preventDefault();const e=t.detail.control,s=e.control;if(s["x-schema-form"])if(s["x-schema-form"].event){const e=s["x-schema-form"].event;(0,i.dispatchCustomEvent)(this,e.name,{...e,...t.detail})}else this._hasCondition(s)&&(this._dynamicControls.push(e),this._updateDynamicControl(e))}_updateDynamicControls(){this._ignoreProperties=[],this._dynamicControls.forEach((t=>{this._updateDynamicControl(t)}))}_updateDynamicControl(t){const e=t.control;return e["x-schema-form"]&&this._dynamicAttributes.forEach((i=>{this._evaluateCondition(e,i)?(t.setAttribute(i,""),"hidden"===i&&this._ignoreProperties.push(t.id)):t.removeAttribute(i)})),null}async performUpdate(){await Promise.all(this.getControls().map((t=>t.updateComplete))),this.getControls().forEach((t=>{t.requestUpdate()})),super.performUpdate()}_renderControl(i){const s={...this.schema.properties[i]},o=this.schema.required&&this.schema.required.includes(i)||this._evaluateCondition(s,"required"),r=this.schema.disabled&&this.schema.disabled.includes(i)||this._evaluateCondition(s,"disabled"),a=this._evaluateCondition(s,"hidden");a&&this._ignoreProperties.push(i);const n=this.readonly||!0===s.readOnly,l=!0===s.writeOnly,h=(0,e.get)(this._values,i);return t.html`<gv-schema-form-control .id="${i}" .errors="${this.errors}" .control="${s}" .skeleton="${this.skeleton}" .value="${h}" ?readonly="${n}" ?writeonly="${l}" ?required="${o}" ?disabled="${r}" ?hidden="${a}"></gv-schema-form-control>`}_hasCondition(t){return!!t["x-schema-form"]&&null!=this._dynamicAttributes.find((e=>null!=t["x-schema-form"][e]))}_evaluateCondition(t,e){if(null==t["x-schema-form"]||null==t["x-schema-form"][e])return!1;const i=t["x-schema-form"][e];if("boolean"==typeof i)return i;if(!Array.isArray(i))return console.warn(`'${e}' attribute of 'x-schema-form' should be an array`),!1;let s=!0;for(const e of i){const i=Object.keys(e)[0];switch(i){case"$neq":s=s&&this._evaluateNotEqualsCondition(t,e);break;case"$eq":s=s&&this._evaluateEqualsCondition(t,e);break;case"$nodef":s=s&&this._evaluateNotDefCondition(t,e);break;case"$def":s=s&&this._evaluateDefCondition(t,e);break;default:console.warn(`Unsupported operator '${i}' on disable condition`),s=!1}}return s}_evaluateNotEqualsCondition(t,e){return!this._evaluateEqualsCondition(t,e)}_evaluateEqualsCondition(t,i){const s=i[Object.keys(i)[0]];return Object.keys(s).map((i=>{const o=s[i];let r=(0,e.get)(this._values,i);return null==r&&"string"===t.type&&(r=""),Array.isArray(o)?o.includes(r):r===o})).reduce(((t,e)=>t||e))}_evaluateNotDefCondition(t,i){const s=i[Object.keys(i)[0]];return void 0===(0,e.get)(this._values,s)||null===(0,e.get)(this._values,s)}_evaluateDefCondition(t,e){return!this._evaluateNotDefCondition(t,e)}_renderPart(){if(this._confirm)return t.html`<div class="confirm-box"><div class="error">The configuration is not valid and cannot be saved.</div><div class="confirm-box_actions"><gv-button @gv-button:click="${this._onConfirmReset}" outlined icon="general:update" danger>Lose changes</gv-button><gv-button @gv-button:click="${this._onConfirmEdit}" icon="design:edit">Edit</gv-button></div></div>`;const e=this.schema.properties?Object.keys(this.schema.properties):[];if(this._ignoreProperties=[],this.groups){const i=this.groups.reduce(((t,i)=>{const s=e.filter((t=>[...i.items||[]].includes(t)));return t.push({...i,items:s||[]}),t}),[]),s=i.find((t=>t.default))||{default:!0,items:[]},o=i.reduce(((t,e)=>[...t,...e.items]),[]);return s.items=e.filter((t=>!o.includes(t))),(0,r.repeat)(i,(e=>t.html`${e.name?t.html`<h2 class="group-title">${e.name}</h2>${(0,r.repeat)(e.items,(t=>this._renderControl(t)))}`:(0,r.repeat)(e.items,(t=>this._renderControl(t)))}`))}return t.html`${(0,r.repeat)([1],(()=>(0,r.repeat)(e,(t=>t),(t=>this._renderControl(t)))))}`}getControls(){return Array.from(this.shadowRoot.querySelectorAll("gv-schema-form-control"))}getControl(t){return this.shadowRoot.querySelector(`[id="${t}"]`)}_getErrors(){return(this._validatorResults.errors||[]).filter((t=>{let i=`${t.property.replace("instance.","")}`;Array.isArray(t.argument)||(i=`${i}.${t.argument}`);const s=`x-schema-form.errors.${i}.${t.name}`,o=(0,e.get)(this.schema,s);return o&&(t.message=o),!this._ignoreProperties.includes(i)}))}validate(){return this.schema&&(this._validatorResults=this._validator.validate(this._values,{...this.schema,additionalProperties:{}}),this.errors=this._getErrors()),this._validatorResults}isValid(){return!!this._validatorResults.valid||0===this._getErrors()}isTouch(){return this._touch||this.dirty&&this.validateOnRender}canSubmit(){return this.isTouch()&&this.isValid()}_updateActions(){null!=this._getSubmitBtn()&&(this.canSubmit()?this._getSubmitBtn().removeAttribute("disabled"):this._getSubmitBtn().setAttribute("disabled",!0));const t=this._getResetBtn();null!=t&&(this.dirty?t.removeAttribute("disabled"):t.setAttribute("disabled",!0))}_updateChildren(t){t?(this._validatorResults={},this.errors=null,this.requestValidation()):this._updateActionsTimeout=setTimeout((()=>this._updateActions()),0)}async updated(t){clearTimeout(this._updateActionsTimeout),t.has("_values")&&this.getControls().forEach((t=>{t.value=(0,e.get)(this._values,t.id)})),this._updateChildren(this.validateOnRender&&(t.has("_values")||t.has("schema")))}async getUpdateComplete(){const t=await super.getUpdateComplete();return await Promise.all(this.getControls().map((t=>t.updateComplete))),t}render(){return t.html`<form class="${(0,o.classMap)({scrollable:this.scrollable})}"><div class="${(0,o.classMap)({container:!0,confirm:this._confirm})}">${!0===this.hasHeader?t.html`<div class="header"><div class="${(0,o.classMap)({title:!0,center:this.hasHeader&&!this.hasFooter})}"><slot name="title"></slot></div><div class="left"><slot name="header-left"></slot></div>${!0===this.readonly||!0===this.hasFooter?"":t.html`<div class="right"><gv-button id="reset" outlined small @gv-button:click="${this._onReset}" icon="general:update" title="Reset"></gv-button><gv-button id="submit" small @gv-button:click="${this._onSubmit}" icon="code:check" .title="${this.submitLabel}"></gv-button></div>`}</div>`:""}<div class="content">${null!=this.schema?this._renderPart():t.html``}</div>${!0===this.hasFooter&&!0!==this.readonly?t.html`<div class="footer"><div class="left"></div><div class="right"><gv-button id="reset" outlined @gv-button:click="${this._onReset}" icon="general:update" title="Reset">Reset</gv-button><gv-button id="submit" @gv-button:click="${this._onSubmit}" icon="code:check" .title="${this.submitLabel}">${this.submitLabel}</gv-button></div></div>`:""}</div></form>`}static get styles(){return[n.empty,t.css`:host{box-sizing:border-box;margin:.2rem;--bgc:var(--gv-schema-form--bgc, #ffffff)}form{display:flex;flex-direction:column}form.scrollable{position:absolute;width:100%;top:0;bottom:0;left:0}.container{flex-grow:1;background-color:var(--bgc);display:flex;flex-direction:column;min-height:0}.content,.footer,.header{background-color:var(--bgc)}.content{flex-grow:1;display:flex;flex-direction:column;align-self:center;width:100%;min-height:0}.content>gv-schema-form-control{align-self:center;width:100%}form.scrollable .content{overflow:auto}form.scrollable .content>.group-title,form.scrollable .content>gv-schema-form-control{max-width:775px;width:95%}.footer,.header{display:flex;box-sizing:border-box;min-height:45px;--gv-icon--s:26px;--gv-icon--c:#bfbfbf;align-items:center;padding:0 .5rem;position:relative}.header{border-bottom:1px solid #d9d9d9}.footer{display:flex;justify-content:space-between;padding:1rem;border-top:1px solid #d9d9d9}form.scrollable .footer{justify-content:center}.footer .left,.footer .right{max-width:400px}.footer .left,.footer .right,.header .left,.header .right{display:flex;flex:1;z-index:10;align-items:center}.footer .right,.header .right{justify-content:flex-end}.header .title{color:#28444f;font-size:18px;display:flex;width:100%;align-items:center}.header .title.center{position:absolute;top:0;left:0;bottom:0;justify-content:center}.confirm-box{height:100%;padding:1rem;font-style:italic;display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center}.confirm-box_actions{padding:1rem 0}.confirm .footer .left,.confirm .footer .right,.confirm .header .left,.confirm .header .right{display:none}.group-title{align-self:center;width:100%;color:var(--gv-theme-font-color-dark);font-size:21px;font-weight:600;padding-bottom:.3em;border-bottom:1px solid var(--gv-theme-font-color-dark);margin-top:24px;margin-bottom:16px}`]}}exports.GvSchemaForm=l,window.customElements.define("gv-schema-form",l);