@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,710 +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 '../atoms/gv-date-picker';
17
- import '../organisms/gv-tabs';
18
- import '../atoms/gv-input';
19
- import '../atoms/gv-tag';
20
- import { css, LitElement, html } from 'lit';
21
- import { skeleton } from '../styles/skeleton';
22
- import { InputElement } from '../mixins/input-element';
23
- import { set } from 'object-path';
24
- import { repeat } from 'lit/directives/repeat';
25
- import { withResizeObserver } from '../mixins/with-resize-observer';
26
- import { isValidCron } from '../lib/cron-expression';
27
- import { dispatchCustomEvent } from '../lib/events';
28
-
29
- /**
30
- * Cron editor component
31
- *
32
- * ## Details
33
- *
34
- * @fires gv-cron-editor:input - input events with the `value` on `detail`
35
- *
36
- * @attr {String} label - cron editor label
37
- * @attr {String} value - cron expression
38
- * @attr {String} mode - the opened mode (if no value is set, the pro mode will be opened)
39
- *
40
- * @attr {Boolean} [clipboard=false]- true if field has clipboard button
41
- * @attr {Boolean} [autofocus=false] - true to put the focus on the input
42
- * @attr {Boolean} [readonly=false] - true if field is readonly mode
43
- */
44
- export class GvCronEditor extends withResizeObserver(InputElement(LitElement)) {
45
- static get properties() {
46
- return {
47
- ...super.properties,
48
- mode: { type: String },
49
- _value: { type: String, attribute: false },
50
- _currentDocumentationId: { type: String, attribute: false },
51
- _small: { type: Boolean },
52
- _truncateTabs: { type: Boolean },
53
- };
54
- }
55
-
56
- constructor() {
57
- super();
58
- this._value = '';
59
- this.readonly = false;
60
- this.autofocus = false;
61
- this.clipboard = false;
62
- this._modes = ['seconds', 'minutes', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'pro'];
63
- this._timeRange = [...Array(60).keys()];
64
- this._days = [
65
- { value: 'MON', label: 'Monday' },
66
- { value: 'TUE', label: 'Tuesday' },
67
- { value: 'WED', label: 'Wednesday' },
68
- { value: 'THU', label: 'Thursday' },
69
- { value: 'FRI', label: 'Friday' },
70
- { value: 'SAT', label: 'Saturday' },
71
- { value: 'SUN', label: 'Sunday' },
72
- ];
73
- this._months = [
74
- 'January',
75
- 'February',
76
- 'March',
77
- 'April',
78
- 'May',
79
- 'June',
80
- 'July',
81
- 'August',
82
- 'September',
83
- 'October',
84
- 'November',
85
- 'December',
86
- ];
87
- this._state = {
88
- seconds: {
89
- seconds: 1,
90
- },
91
- minutes: {
92
- minutes: 1,
93
- seconds: 0,
94
- },
95
- hourly: {
96
- hours: 1,
97
- minutes: 0,
98
- seconds: 0,
99
- },
100
- daily: {
101
- days: 1,
102
- time: 0,
103
- weekdays: false,
104
- },
105
- weekly: {
106
- days: [],
107
- time: 0,
108
- },
109
- monthly: {
110
- day: 1,
111
- month: 1,
112
- time: 0,
113
- },
114
- yearly: {
115
- day: 1,
116
- month: 1,
117
- time: 0,
118
- },
119
- pro: {
120
- value: '',
121
- displayDetails: false,
122
- },
123
- };
124
-
125
- this._docs = [
126
- { id: 'second', label: 'Second' },
127
- { id: 'minute', label: 'Minute' },
128
- { id: 'hour', label: 'Hour' },
129
- { id: 'day-month', label: 'Day (month)' },
130
- { id: 'month', label: 'Month' },
131
- { id: 'day-week', label: 'Day (week)' },
132
- ];
133
-
134
- this._currentDocumentationId = this._docs[0].id;
135
- this._handleChange = this._onChange.bind(this);
136
- this._small = false;
137
- }
138
-
139
- tryToComputeAndInitModeFromValue() {
140
- if (!this.value || this.mode) {
141
- this.mode = this.mode || 'pro';
142
- return;
143
- }
144
- const [seconds, minutes, hours] = this.value.split(' ');
145
-
146
- if (/\d+ \d+ \*\/\d+ \* \* \*/.test(this.value)) {
147
- // Match: `1 42 */15 * * *`
148
- this.mode = 'hourly';
149
- this._state.hourly.hours = Number(hours.replace('*/', ''));
150
- this._state.hourly.minutes = Number(minutes);
151
- this._state.hourly.seconds = Number(seconds);
152
- } else if (/\d+ \*\/\d+ \* \* \* \*/.test(this.value)) {
153
- // Match: `1 */15 * * * *`
154
- this.mode = 'minutes';
155
- this._state.minutes.minutes = Number(minutes.replace('*/', ''));
156
- this._state.minutes.seconds = Number(seconds);
157
- } else if (/\*\/\d+ \* \* \* \* \*/.test(this.value)) {
158
- // Match: `*/15 * * * * *`
159
- this.mode = 'seconds';
160
- this._state.seconds.seconds = Number(seconds.replace('*/', ''));
161
- } else {
162
- this.mode = 'pro';
163
- }
164
- }
165
-
166
- onResize({ width }) {
167
- this._truncateTabs = width < 750;
168
- this._small = width < 449;
169
- }
170
-
171
- set value(value) {
172
- if (isValidCron(value, { seconds: true, alias: true })) {
173
- this._value = value;
174
- if (this._state.pro.value === '') {
175
- this._state.pro.value = value;
176
- }
177
- }
178
- }
179
-
180
- get value() {
181
- if (this.mode === 'pro') {
182
- return this._state.pro.value;
183
- }
184
- return this._value;
185
- }
186
-
187
- async firstUpdated() {
188
- this.tryToComputeAndInitModeFromValue();
189
-
190
- // Give the browser a chance to paint
191
- // eslint-disable-next-line promise/param-names
192
- await new Promise((r) => setTimeout(r, 0));
193
-
194
- this.shadowRoot.querySelectorAll('gv-input, gv-date-picker, gv-checkbox, gv-select').forEach((element) => {
195
- element.addEventListener(`${element.tagName.toLowerCase()}:input`, this._handleChange);
196
- });
197
- }
198
-
199
- _onOpenDocumentation(docId) {
200
- this._currentDocumentationId = docId;
201
- }
202
-
203
- _onChange({ target, detail }) {
204
- if (target.id === 'cron-input' && this.mode !== 'pro') {
205
- this.mode = 'pro';
206
- }
207
- if (target.valid) {
208
- if (target.name == null) {
209
- throw new Error('Field target must have a name to update the state');
210
- }
211
- const tagName = target.tagName.toLowerCase();
212
- let value = detail;
213
- if (tagName === 'gv-date-picker') {
214
- value = new Date(detail);
215
- } else if (target.type === 'number') {
216
- value = Number(detail).valueOf();
217
- }
218
- set(this._state, target.name, value);
219
- this.generate();
220
- if (target.classList.contains('request-update')) {
221
- this.requestUpdate();
222
- }
223
- }
224
- }
225
-
226
- _onChangeTab(event) {
227
- event.preventDefault();
228
- event.stopPropagation();
229
- const {
230
- detail: { to },
231
- } = event;
232
- if (to === 'pro') {
233
- // Needs to be done first otherwise `value` is overridden before using it
234
- this._state.pro.value = this.value;
235
- }
236
- this.mode = to;
237
- this.generate();
238
- if (this.mode === 'pro') {
239
- this.shadowRoot.querySelector('#cron-input').focus();
240
- }
241
- }
242
-
243
- _getTimeExpression(date) {
244
- if (date) {
245
- return `${date.getSeconds()} ${date.getMinutes()} ${date.getHours()}`;
246
- }
247
- return '* * *';
248
- }
249
-
250
- generate() {
251
- let tmpValue = '';
252
- switch (this.mode) {
253
- case 'seconds':
254
- if (this._state.seconds.seconds) {
255
- tmpValue = `*/${this._state.seconds.seconds} * * * * *`;
256
- } else {
257
- tmpValue = `* * * * * *`;
258
- }
259
- break;
260
- case 'minutes':
261
- if (this._state.minutes.minutes) {
262
- tmpValue = `${this._state.minutes.seconds} */${this._state.minutes.minutes} * * * *`;
263
- } else {
264
- tmpValue = `${this._state.minutes.seconds} * * * * *`;
265
- }
266
- break;
267
- case 'hourly':
268
- if (this._state.hourly.hours) {
269
- tmpValue = `${this._state.hourly.seconds} ${this._state.hourly.minutes} */${this._state.hourly.hours} * * *`;
270
- } else {
271
- tmpValue = `${this._state.minutes.seconds} ${this._state.hourly.minutes} * * * *`;
272
- }
273
- break;
274
- case 'daily':
275
- if (this._state.daily.weekdays === false) {
276
- tmpValue = `${this._getTimeExpression(this._state.daily.time)} ${this._state.daily.days} * *`;
277
- } else {
278
- tmpValue = `${this._getTimeExpression(this._state.daily.time)} * * MON-FRI`;
279
- }
280
- break;
281
- case 'weekly':
282
- if (this._state.weekly.days.length === 0) {
283
- tmpValue = `${this._getTimeExpression(this._state.weekly.time)} * * *`;
284
- } else {
285
- tmpValue = `${this._getTimeExpression(this._state.weekly.time)} * * ${this._state.weekly.days.join(',')}`;
286
- }
287
- break;
288
- case 'monthly':
289
- tmpValue = `${this._getTimeExpression(this._state.monthly.time)} ${this._state.monthly.day} ${this._state.monthly.month} *`;
290
- break;
291
- case 'yearly':
292
- tmpValue = `${this._getTimeExpression(this._state.yearly.time)} ${this._state.yearly.day} */${
293
- this._months.indexOf(this._state.yearly.month) + 1
294
- } *`;
295
- break;
296
- case 'pro':
297
- tmpValue = this._state.pro.value;
298
- break;
299
- default:
300
- throw new Error('Invalid cron active tab selection');
301
- }
302
-
303
- this.updateState(tmpValue);
304
- if (this.valid) {
305
- this._value = tmpValue;
306
- this.dispatchEvent(new Event('input', { bubbles: true, cancelable: true }));
307
- dispatchCustomEvent(this, 'input', this.value);
308
- }
309
- }
310
-
311
- updateState(value) {
312
- super.updateState(value);
313
- if (this.valid) {
314
- if (isValidCron(value, { seconds: true, alias: true })) {
315
- this.setValidity();
316
- } else {
317
- this.setValidity(true, 'field is not valid cron expression');
318
- }
319
- }
320
- }
321
-
322
- renderLabel() {
323
- if (this.label) {
324
- return html`<label for=${this.id} title="${this.label}">${this.label}</label>`;
325
- }
326
- return '';
327
- }
328
-
329
- displayProDetails() {
330
- this._state.pro.displayDetails = !this._state.pro.displayDetails;
331
- this.requestUpdate();
332
- }
333
-
334
- renderProDetails() {
335
- if (this._state.pro.displayDetails) {
336
- return html`<div class="tab-content_pro-pane_container">
337
- <div class="tab-content_pro-pane">
338
- <div>Rules for:</div>
339
- <div>
340
- ${repeat(
341
- this._docs,
342
- (doc) => doc.id,
343
- (doc) => {
344
- const isCurrent = doc.id === this._currentDocumentationId;
345
- return html` <gv-tag
346
- @gv-tag:click="${this._onOpenDocumentation.bind(this, doc.id)}"
347
- ?clickable="${!isCurrent}"
348
- ?major="${isCurrent}"
349
- ?minor="${!isCurrent}"
350
- >${doc.label}</gv-tag
351
- >`;
352
- },
353
- )}
354
- </div>
355
- <ul class="help">
356
- <li>
357
- <small>Allowed characters: <code>${this.allowedChar}</code></small>
358
- </li>
359
- <li>
360
- <small>Allowed values: <code>${this.allowedValues}</code></small>
361
- </li>
362
- </ul>
363
- </div>
364
- <div class="tab-content_pro-pane">
365
- <div>Examples:</div>
366
- <ul class="help">
367
- <li>
368
- <small><code>*</code>: for each unit (0, 1, 2, 3...)</small>
369
- </li>
370
- <li>
371
- <small><code>5,8</code>: units 5 and 8</small>
372
- </li>
373
- <li>
374
- <small><code>2-5</code>: units from 2 to 5 (2, 3, 4, 5)</small>
375
- </li>
376
- <li>
377
- <small><code>*/3</code>: every 3 units (0, 3, 6, 9...)</small>
378
- </li>
379
- <li>
380
- <small><code>10-20/3</code>: every 3 units, between the tenth and the twentieth (10, 13, 16, 19)</small>
381
- </li>
382
- </ul>
383
- </div>
384
- </div>`;
385
- }
386
-
387
- return '';
388
- }
389
-
390
- render() {
391
- return html`<div>
392
- ${this.renderLabel()}
393
- <div class="box">
394
- <gv-tabs
395
- .value="${this.mode}"
396
- .options="${this._modes}"
397
- .disabled="${this.disabled}"
398
- ?small="${this._small}"
399
- ?truncate="${this._truncateTabs}"
400
- @gv-tabs:change="${this._onChangeTab.bind(this)}"
401
- >
402
- <div slot="title" class="generated-expression">
403
- <gv-input
404
- name="pro.value"
405
- .autofocus="${this.autofocus}"
406
- .value="${this.value}"
407
- id="cron-input"
408
- placeholder="* */30 * * * * (Every 30 min)"
409
- ></gv-input>
410
- </div>
411
-
412
- <div slot="content" id="seconds" class="tab-content">
413
- <span>Every</span>
414
- <gv-input small type="number" min="1" name="seconds.seconds" .value="${this._state.seconds.seconds}"></gv-input>
415
- <span>second(s)</span>
416
- </div>
417
-
418
- <div slot="content" id="minutes" class="tab-content">
419
- <span>Every</span>
420
- <gv-input small type="number" min="1" name="minutes.minutes" .value="${this._state.minutes.minutes}"></gv-input>
421
- <span>minute(s) on second</span>
422
- <gv-input small type="number" min="0" max="59" name="minutes.seconds" .value="${this._state.minutes.seconds}"></gv-input>
423
- </div>
424
-
425
- <div slot="content" id="hourly" class="tab-content">
426
- <span>Every</span>
427
- <gv-input small type="number" min="1" name="hourly.hours" .value="${this._state.hourly.hours}"></gv-input>
428
- <span>hour(s) on minute</span>
429
- <gv-input small type="number" min="0" max="59" name="hourly.minutes" .value="${this._state.hourly.minutes}"></gv-input>
430
- <span>and second</span>
431
- <gv-input small type="number" min="0" max="59" name="hourly.seconds" .value="${this._state.hourly.seconds}"></gv-input>
432
- </div>
433
-
434
- <div slot="content" id="daily" class="tab-content">
435
- <span>Every</span>
436
- <gv-input
437
- small
438
- type="number"
439
- min="1"
440
- max="31"
441
- name="daily.days"
442
- ?disabled="${this._state.daily.weekdays}"
443
- .value="${this._state.daily.days}"
444
- ></gv-input>
445
- <span class="line">
446
- day(s)
447
- <gv-checkbox
448
- class="request-update"
449
- label="of week"
450
- name="daily.weekdays"
451
- ?checked="${this._state.daily.weekdays}"
452
- ></gv-checkbox>
453
- at</span
454
- >
455
- <gv-date-picker small time strict name="daily.time" .value="${this._state.daily.time}"></gv-date-picker>
456
- </div>
457
-
458
- <div slot="content" id="weekly" class="tab-content tab-content_weekly">
459
- <span>Every</span>
460
- <gv-select small multiple name="weekly.days" .options="${this._days}" .value="${this._state.weekly.days}"></gv-select>
461
- <span>day(s) at</span>
462
- <gv-date-picker small time strict name="weekly.time" .value="${this._state.weekly.time}"></gv-date-picker>
463
- </div>
464
-
465
- <div slot="content" id="monthly" class="tab-content">
466
- <span>On the</span>
467
- <gv-input
468
- small
469
- type="number"
470
- min="1"
471
- max="31"
472
- name="monthly.day"
473
- class="request-update"
474
- .value="${this._state.monthly.day}"
475
- ></gv-input>
476
- <span><sup>${this._getDaySuffix(this._state.monthly.day)}</sup> </span>
477
- <span>day of every</span>
478
- <gv-input small type="number" min="1" max="12" name="monthly.month" .value="${this._state.monthly.month}"></gv-input>
479
- <span>month(s) at</span>
480
- <gv-date-picker small time strict name="monthly.time" .value="${this._state.monthly.time}"></gv-date-picker>
481
- </div>
482
-
483
- <div slot="content" id="yearly" class="tab-content">
484
- <span>Every</span>
485
- <gv-select small name="yearly.month" .options="${this._months}" .value="${this._state.yearly.month}"></gv-select>
486
- <span>on the</span>
487
- <gv-input
488
- small
489
- type="number"
490
- min="1"
491
- max="31"
492
- name="yearly.day"
493
- class="request-update"
494
- .value="${this._state.yearly.day}"
495
- ></gv-input>
496
- <span><sup>${this._getDaySuffix(this._state.yearly.day)}</sup></span>
497
- <span>day</span>
498
- <gv-date-picker small time strict name="yearly.time" .value="${this._state.yearly.time}"></gv-date-picker>
499
- </div>
500
-
501
- <div slot="content" id="pro" class="tab-content tab-content_pro">
502
- <gv-button link small class="tab-content_pro-details_btn" @click="${this.displayProDetails}">
503
- ${this._state.pro.displayDetails
504
- ? 'Hide information about cron rules and examples'
505
- : 'Display information about cron rules and examples'}
506
- </gv-button>
507
- ${this.renderProDetails()}
508
- </div>
509
- </gv-tabs>
510
- </div>
511
- </div>`;
512
- }
513
-
514
- get allowedValues() {
515
- if (this.mode === 'pro') {
516
- switch (this._currentDocumentationId) {
517
- case 'hour':
518
- return '0-23';
519
- case 'day-month':
520
- return '1-31';
521
- case 'month':
522
- return '1-12 or JAN-DEC';
523
- case 'day-week':
524
- return '1-7 or SUN-SAT';
525
- default:
526
- return '0-59';
527
- }
528
- }
529
- return '';
530
- }
531
-
532
- get allowedChar() {
533
- if (this.mode === 'pro') {
534
- return ',-*/';
535
- }
536
- return '';
537
- }
538
-
539
- _getDaySuffix(day = 1) {
540
- if (day) {
541
- if (day.toString().endsWith('1')) {
542
- return 'st';
543
- } else if (day.toString().endsWith('2')) {
544
- return 'nd';
545
- } else if (day.toString().endsWith('3')) {
546
- return 'rd';
547
- }
548
- return 'th';
549
- }
550
- return '';
551
- }
552
-
553
- static get styles() {
554
- return [
555
- skeleton,
556
- // language=CSS
557
- css`
558
- :host {
559
- box-sizing: border-box;
560
- display: block;
561
- margin: 0.2rem;
562
- }
563
-
564
- :host([invalid]) .box {
565
- border-left-color: var(--gv-theme-color-error-dark, #d32f2f);
566
- border-left-width: 3px;
567
- }
568
-
569
- .box {
570
- border: 1px solid var(--gv-theme-neutral-color-dark, #bfbfbf);
571
- border-radius: 4px;
572
- }
573
-
574
- .generated-expression {
575
- display: flex;
576
- align-items: center;
577
- flex: 1;
578
- }
579
-
580
- .generated-expression > span,
581
- .generated-expression > code {
582
- margin: 0.4rem;
583
- }
584
-
585
- .generated-expression gv-input,
586
- .generated-expression code {
587
- --input-small--fz: 16px;
588
- font-size: 16px;
589
- }
590
-
591
- .generated-expression gv-input {
592
- --gv-input--bdc: transparent;
593
- margin: 0;
594
- min-width: 190px;
595
- }
596
-
597
- .tab-content {
598
- display: flex;
599
- align-items: center;
600
- background-color: var(--gv-theme-neutral-color, #f5f5f5);
601
- font-style: italic;
602
- font-size: var(--gv-theme-font-size-s, 12px);
603
- padding: 0.2rem;
604
- }
605
-
606
- .tab-content > * {
607
- margin: 0.2rem;
608
- }
609
-
610
- .tab-content gv-input[type='number'] {
611
- width: 50px;
612
- }
613
-
614
- .tab-content_weekly gv-select {
615
- width: auto;
616
- }
617
-
618
- .tab-content_pro code {
619
- font-size: 14px;
620
- font-weight: bold;
621
- font-style: normal;
622
- }
623
-
624
- .tab-content_pro {
625
- display: flex;
626
- flex-direction: column;
627
- align-items: normal;
628
- --gv-icon--s: 18px;
629
- padding: 0.2rem;
630
- }
631
-
632
- .tab-content_pro-details_btn {
633
- --gv-button--fz: 12px;
634
- }
635
-
636
- .tab-content_pro-pane_container {
637
- display: flex;
638
- flex-direction: row;
639
- }
640
-
641
- .tab-content_pro-pane {
642
- flex: auto;
643
- }
644
-
645
- .tab-content_pro > * {
646
- margin: 0.2rem;
647
- }
648
-
649
- .tab-content_pro small,
650
- .tab-content_pro gv-icon {
651
- margin: 0 0.2rem;
652
- }
653
-
654
- gv-tabs {
655
- --gv-tabs-options--m: auto 0.2rem auto 0;
656
- }
657
-
658
- gv-tabs[small] {
659
- --gv-tabs-options--m: auto 0;
660
- }
661
-
662
- gv-tabs[small] .tab-content {
663
- padding: 0;
664
- }
665
-
666
- .line {
667
- display: flex;
668
- align-items: center;
669
- margin: 0;
670
- }
671
-
672
- .line > * {
673
- margin: 0 0.3rem;
674
- }
675
-
676
- gv-checkbox {
677
- text-decoration: line-through;
678
- font-weight: normal;
679
- }
680
-
681
- gv-checkbox[checked] {
682
- text-decoration: none;
683
- }
684
-
685
- sup {
686
- display: inline-block;
687
- font-size: var(--gv-theme-font-size-s, 12px);
688
- }
689
-
690
- ul {
691
- list-style: none;
692
- margin: 0.5rem 1rem;
693
- padding: 0;
694
- }
695
-
696
- ul.help {
697
- padding-left: 0.2rem;
698
- margin-left: 0.4rem;
699
- border-left: 2px dotted var(--gv-theme-neutral-color-dark, #bfbfbf);
700
- }
701
-
702
- small {
703
- font-size: var(--gv-theme-font-size-s, 12px);
704
- }
705
- `,
706
- ];
707
- }
708
- }
709
-
710
- window.customElements.define('gv-cron-editor', GvCronEditor);
1
+ Object.defineProperty(exports,"__esModule",{value:!0}),exports.GvCronEditor=void 0,require("../atoms/gv-date-picker"),require("../organisms/gv-tabs"),require("../atoms/gv-input"),require("../atoms/gv-tag");const e=require("lit"),t=require("../styles/skeleton"),s=require("../mixins/input-element"),a=require("object-path"),i=require("lit/directives/repeat"),n=require("../mixins/with-resize-observer"),l=require("../lib/cron-expression"),o=require("../lib/events");class r extends((0,n.withResizeObserver)((0,s.InputElement)(e.LitElement))){static get properties(){return{...super.properties,mode:{type:String},_value:{type:String,attribute:!1},_currentDocumentationId:{type:String,attribute:!1},_small:{type:Boolean},_truncateTabs:{type:Boolean}}}constructor(){super(),this._value="",this.readonly=!1,this.autofocus=!1,this.clipboard=!1,this._modes=["seconds","minutes","hourly","daily","weekly","monthly","yearly","pro"],this._timeRange=[...Array(60).keys()],this._days=[{value:"MON",label:"Monday"},{value:"TUE",label:"Tuesday"},{value:"WED",label:"Wednesday"},{value:"THU",label:"Thursday"},{value:"FRI",label:"Friday"},{value:"SAT",label:"Saturday"},{value:"SUN",label:"Sunday"}],this._months=["January","February","March","April","May","June","July","August","September","October","November","December"],this._state={seconds:{seconds:1},minutes:{minutes:1,seconds:0},hourly:{hours:1,minutes:0,seconds:0},daily:{days:1,time:0,weekdays:!1},weekly:{days:[],time:0},monthly:{day:1,month:1,time:0},yearly:{day:1,month:1,time:0},pro:{value:"",displayDetails:!1}},this._docs=[{id:"second",label:"Second"},{id:"minute",label:"Minute"},{id:"hour",label:"Hour"},{id:"day-month",label:"Day (month)"},{id:"month",label:"Month"},{id:"day-week",label:"Day (week)"}],this._currentDocumentationId=this._docs[0].id,this._handleChange=this._onChange.bind(this),this._small=!1}tryToComputeAndInitModeFromValue(){if(!this.value||this.mode)return void(this.mode=this.mode||"pro");const[e,t,s]=this.value.split(" ");/\d+ \d+ \*\/\d+ \* \* \*/.test(this.value)?(this.mode="hourly",this._state.hourly.hours=Number(s.replace("*/","")),this._state.hourly.minutes=Number(t),this._state.hourly.seconds=Number(e)):/\d+ \*\/\d+ \* \* \* \*/.test(this.value)?(this.mode="minutes",this._state.minutes.minutes=Number(t.replace("*/","")),this._state.minutes.seconds=Number(e)):/\*\/\d+ \* \* \* \* \*/.test(this.value)?(this.mode="seconds",this._state.seconds.seconds=Number(e.replace("*/",""))):this.mode="pro"}onResize({width:e}){this._truncateTabs=e<750,this._small=e<449}set value(e){(0,l.isValidCron)(e,{seconds:!0,alias:!0})&&(this._value=e,""===this._state.pro.value&&(this._state.pro.value=e))}get value(){return"pro"===this.mode?this._state.pro.value:this._value}async firstUpdated(){this.tryToComputeAndInitModeFromValue(),await new Promise((e=>setTimeout(e,0))),this.shadowRoot.querySelectorAll("gv-input, gv-date-picker, gv-checkbox, gv-select").forEach((e=>{e.addEventListener(`${e.tagName.toLowerCase()}:input`,this._handleChange)}))}_onOpenDocumentation(e){this._currentDocumentationId=e}_onChange({target:e,detail:t}){if("cron-input"===e.id&&"pro"!==this.mode&&(this.mode="pro"),e.valid){if(null==e.name)throw new Error("Field target must have a name to update the state");let s=t;"gv-date-picker"===e.tagName.toLowerCase()?s=new Date(t):"number"===e.type&&(s=Number(t).valueOf()),(0,a.set)(this._state,e.name,s),this.generate(),e.classList.contains("request-update")&&this.requestUpdate()}}_onChangeTab(e){e.preventDefault(),e.stopPropagation();const{detail:{to:t}}=e;"pro"===t&&(this._state.pro.value=this.value),this.mode=t,this.generate(),"pro"===this.mode&&this.shadowRoot.querySelector("#cron-input").focus()}_getTimeExpression(e){return e?`${e.getSeconds()} ${e.getMinutes()} ${e.getHours()}`:"* * *"}generate(){let e="";switch(this.mode){case"seconds":e=this._state.seconds.seconds?`*/${this._state.seconds.seconds} * * * * *`:"* * * * * *";break;case"minutes":e=this._state.minutes.minutes?`${this._state.minutes.seconds} */${this._state.minutes.minutes} * * * *`:`${this._state.minutes.seconds} * * * * *`;break;case"hourly":e=this._state.hourly.hours?`${this._state.hourly.seconds} ${this._state.hourly.minutes} */${this._state.hourly.hours} * * *`:`${this._state.minutes.seconds} ${this._state.hourly.minutes} * * * *`;break;case"daily":e=!1===this._state.daily.weekdays?`${this._getTimeExpression(this._state.daily.time)} ${this._state.daily.days} * *`:`${this._getTimeExpression(this._state.daily.time)} * * MON-FRI`;break;case"weekly":e=0===this._state.weekly.days.length?`${this._getTimeExpression(this._state.weekly.time)} * * *`:`${this._getTimeExpression(this._state.weekly.time)} * * ${this._state.weekly.days.join(",")}`;break;case"monthly":e=`${this._getTimeExpression(this._state.monthly.time)} ${this._state.monthly.day} ${this._state.monthly.month} *`;break;case"yearly":e=`${this._getTimeExpression(this._state.yearly.time)} ${this._state.yearly.day} */${this._months.indexOf(this._state.yearly.month)+1} *`;break;case"pro":e=this._state.pro.value;break;default:throw new Error("Invalid cron active tab selection")}this.updateState(e),this.valid&&(this._value=e,this.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),(0,o.dispatchCustomEvent)(this,"input",this.value))}updateState(e){super.updateState(e),this.valid&&((0,l.isValidCron)(e,{seconds:!0,alias:!0})?this.setValidity():this.setValidity(!0,"field is not valid cron expression"))}renderLabel(){return this.label?e.html`<label for="${this.id}" title="${this.label}">${this.label}</label>`:""}displayProDetails(){this._state.pro.displayDetails=!this._state.pro.displayDetails,this.requestUpdate()}renderProDetails(){return this._state.pro.displayDetails?e.html`<div class="tab-content_pro-pane_container"><div class="tab-content_pro-pane"><div>Rules for:</div><div>${(0,i.repeat)(this._docs,(e=>e.id),(t=>{const s=t.id===this._currentDocumentationId;return e.html`<gv-tag @gv-tag:click="${this._onOpenDocumentation.bind(this,t.id)}" ?clickable="${!s}" ?major="${s}" ?minor="${!s}">${t.label}</gv-tag>`}))}</div><ul class="help"><li><small>Allowed characters: <code>${this.allowedChar}</code></small></li><li><small>Allowed values: <code>${this.allowedValues}</code></small></li></ul></div><div class="tab-content_pro-pane"><div>Examples:</div><ul class="help"><li><small><code>*</code>: for each unit (0, 1, 2, 3...)</small></li><li><small><code>5,8</code>: units 5 and 8</small></li><li><small><code>2-5</code>: units from 2 to 5 (2, 3, 4, 5)</small></li><li><small><code>*/3</code>: every 3 units (0, 3, 6, 9...)</small></li><li><small><code>10-20/3</code>: every 3 units, between the tenth and the twentieth (10, 13, 16, 19)</small></li></ul></div></div>`:""}render(){return e.html`<div>${this.renderLabel()}<div class="box"><gv-tabs .value="${this.mode}" .options="${this._modes}" .disabled="${this.disabled}" ?small="${this._small}" ?truncate="${this._truncateTabs}" @gv-tabs:change="${this._onChangeTab.bind(this)}"><div slot="title" class="generated-expression"><gv-input name="pro.value" .autofocus="${this.autofocus}" .value="${this.value}" id="cron-input" placeholder="* */30 * * * * (Every 30 min)"></gv-input></div><div slot="content" id="seconds" class="tab-content"><span>Every</span><gv-input small type="number" min="1" name="seconds.seconds" .value="${this._state.seconds.seconds}"></gv-input><span>second(s)</span></div><div slot="content" id="minutes" class="tab-content"><span>Every</span><gv-input small type="number" min="1" name="minutes.minutes" .value="${this._state.minutes.minutes}"></gv-input><span>minute(s) on second</span><gv-input small type="number" min="0" max="59" name="minutes.seconds" .value="${this._state.minutes.seconds}"></gv-input></div><div slot="content" id="hourly" class="tab-content"><span>Every</span><gv-input small type="number" min="1" name="hourly.hours" .value="${this._state.hourly.hours}"></gv-input><span>hour(s) on minute</span><gv-input small type="number" min="0" max="59" name="hourly.minutes" .value="${this._state.hourly.minutes}"></gv-input><span>and second</span><gv-input small type="number" min="0" max="59" name="hourly.seconds" .value="${this._state.hourly.seconds}"></gv-input></div><div slot="content" id="daily" class="tab-content"><span>Every</span><gv-input small type="number" min="1" max="31" name="daily.days" ?disabled="${this._state.daily.weekdays}" .value="${this._state.daily.days}"></gv-input><span class="line">day(s)<gv-checkbox class="request-update" label="of week" name="daily.weekdays" ?checked="${this._state.daily.weekdays}"></gv-checkbox>at</span><gv-date-picker small time strict name="daily.time" .value="${this._state.daily.time}"></gv-date-picker></div><div slot="content" id="weekly" class="tab-content tab-content_weekly"><span>Every</span><gv-select small multiple="multiple" name="weekly.days" .options="${this._days}" .value="${this._state.weekly.days}"></gv-select><span>day(s) at</span><gv-date-picker small time strict name="weekly.time" .value="${this._state.weekly.time}"></gv-date-picker></div><div slot="content" id="monthly" class="tab-content"><span>On the</span><gv-input small type="number" min="1" max="31" name="monthly.day" class="request-update" .value="${this._state.monthly.day}"></gv-input><span><sup>${this._getDaySuffix(this._state.monthly.day)}</sup> </span><span>day of every</span><gv-input small type="number" min="1" max="12" name="monthly.month" .value="${this._state.monthly.month}"></gv-input><span>month(s) at</span><gv-date-picker small time strict name="monthly.time" .value="${this._state.monthly.time}"></gv-date-picker></div><div slot="content" id="yearly" class="tab-content"><span>Every</span><gv-select small name="yearly.month" .options="${this._months}" .value="${this._state.yearly.month}"></gv-select><span>on the</span><gv-input small type="number" min="1" max="31" name="yearly.day" class="request-update" .value="${this._state.yearly.day}"></gv-input><span><sup>${this._getDaySuffix(this._state.yearly.day)}</sup></span> <span>day</span><gv-date-picker small time strict name="yearly.time" .value="${this._state.yearly.time}"></gv-date-picker></div><div slot="content" id="pro" class="tab-content tab-content_pro"><gv-button link small class="tab-content_pro-details_btn" @click="${this.displayProDetails}">${this._state.pro.displayDetails?"Hide information about cron rules and examples":"Display information about cron rules and examples"}</gv-button>${this.renderProDetails()}</div></gv-tabs></div></div>`}get allowedValues(){if("pro"===this.mode)switch(this._currentDocumentationId){case"hour":return"0-23";case"day-month":return"1-31";case"month":return"1-12 or JAN-DEC";case"day-week":return"1-7 or SUN-SAT";default:return"0-59"}return""}get allowedChar(){return"pro"===this.mode?",-*/":""}_getDaySuffix(e=1){return e?e.toString().endsWith("1")?"st":e.toString().endsWith("2")?"nd":e.toString().endsWith("3")?"rd":"th":""}static get styles(){return[t.skeleton,e.css`:host{box-sizing:border-box;display:block;margin:.2rem}:host([invalid]) .box{border-left-color:var(--gv-theme-color-error-dark,#d32f2f);border-left-width:3px}.box{border:1px solid var(--gv-theme-neutral-color-dark,#bfbfbf);border-radius:4px}.generated-expression{display:flex;align-items:center;flex:1}.generated-expression>code,.generated-expression>span{margin:.4rem}.generated-expression code,.generated-expression gv-input{--input-small--fz:16px;font-size:16px}.generated-expression gv-input{--gv-input--bdc:transparent;margin:0;min-width:190px}.tab-content{display:flex;align-items:center;background-color:var(--gv-theme-neutral-color,#f5f5f5);font-style:italic;font-size:var(--gv-theme-font-size-s,12px);padding:.2rem}.tab-content>*{margin:.2rem}.tab-content gv-input[type=number]{width:50px}.tab-content_weekly gv-select{width:auto}.tab-content_pro code{font-size:14px;font-weight:700;font-style:normal}.tab-content_pro{display:flex;flex-direction:column;align-items:normal;--gv-icon--s:18px;padding:.2rem}.tab-content_pro-details_btn{--gv-button--fz:12px}.tab-content_pro-pane_container{display:flex;flex-direction:row}.tab-content_pro-pane{flex:auto}.tab-content_pro>*{margin:.2rem}.tab-content_pro gv-icon,.tab-content_pro small{margin:0 .2rem}gv-tabs{--gv-tabs-options--m:auto 0.2rem auto 0}gv-tabs[small]{--gv-tabs-options--m:auto 0}gv-tabs[small] .tab-content{padding:0}.line{display:flex;align-items:center;margin:0}.line>*{margin:0 .3rem}gv-checkbox{text-decoration:line-through;font-weight:400}gv-checkbox[checked]{text-decoration:none}sup{display:inline-block;font-size:var(--gv-theme-font-size-s,12px)}ul{list-style:none;margin:.5rem 1rem;padding:0}ul.help{padding-left:.2rem;margin-left:.4rem;border-left:2px dotted var(--gv-theme-neutral-color-dark,#bfbfbf)}small{font-size:var(--gv-theme-font-size-s,12px)}`]}}exports.GvCronEditor=r,window.customElements.define("gv-cron-editor",r);