solidus_backend 2.4.2 → 2.5.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_backend might be problematic. Click here for more details.

Files changed (505) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +7 -7
  3. data/Rakefile +19 -13
  4. data/app/assets/javascripts/spree/backend.js +5 -17
  5. data/app/assets/javascripts/spree/backend/adjustments.js +26 -0
  6. data/app/assets/javascripts/spree/backend/admin.js +14 -78
  7. data/app/assets/javascripts/spree/backend/backbone-overrides.js +25 -0
  8. data/app/assets/javascripts/spree/backend/calculator.js +1 -1
  9. data/app/assets/javascripts/spree/backend/checkouts/edit.js +1 -1
  10. data/app/assets/javascripts/spree/backend/collections/index.js +1 -0
  11. data/app/assets/javascripts/spree/backend/collections/shipments.js +6 -0
  12. data/app/assets/javascripts/spree/backend/components/editable_table.js +5 -0
  13. data/app/assets/javascripts/spree/backend/components/number_with_currency.js +1 -1
  14. data/app/assets/javascripts/spree/backend/components/sortable_table.js +29 -0
  15. data/app/assets/javascripts/spree/backend/components/tabs.js +67 -0
  16. data/app/assets/javascripts/spree/backend/components/tooltips.js +19 -24
  17. data/app/assets/javascripts/spree/backend/datepicker.js +55 -0
  18. data/app/assets/javascripts/spree/backend/flash.js +20 -0
  19. data/app/assets/javascripts/spree/backend/gateway.js +22 -0
  20. data/app/assets/javascripts/spree/backend/handlebars_extensions.js +8 -0
  21. data/app/assets/javascripts/spree/backend/images/index.js +8 -0
  22. data/app/assets/javascripts/spree/backend/models/index.js +3 -0
  23. data/app/assets/javascripts/spree/backend/models/line_item.js +4 -0
  24. data/app/assets/javascripts/spree/backend/models/order.js +2 -1
  25. data/app/assets/javascripts/spree/backend/models/payment.js +5 -0
  26. data/app/assets/javascripts/spree/backend/models/shipment.js +27 -0
  27. data/app/assets/javascripts/spree/backend/models/stock_item.js +6 -0
  28. data/app/assets/javascripts/spree/backend/namespaces.js +5 -1
  29. data/app/assets/javascripts/spree/backend/navigation.js +14 -0
  30. data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +1 -1
  31. data/app/assets/javascripts/spree/backend/option_value_picker.js +1 -0
  32. data/app/assets/javascripts/spree/backend/orders/cart.js +1 -1
  33. data/app/assets/javascripts/spree/backend/orders/edit.js +2 -2
  34. data/app/assets/javascripts/spree/backend/payments/edit.js +16 -0
  35. data/app/assets/javascripts/spree/backend/payments/new.js +1 -1
  36. data/app/assets/javascripts/spree/backend/product_picker.js +1 -1
  37. data/app/assets/javascripts/spree/backend/progress.js +9 -0
  38. data/app/assets/javascripts/spree/backend/promotions.js +35 -0
  39. data/app/assets/javascripts/spree/backend/promotions/activation.js +1 -1
  40. data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +1 -1
  41. data/app/assets/javascripts/spree/backend/routes.js +0 -12
  42. data/app/assets/javascripts/spree/backend/shipments.js +35 -68
  43. data/app/assets/javascripts/spree/backend/stock_location.js +23 -0
  44. data/app/assets/javascripts/spree/backend/stock_management.js +22 -0
  45. data/app/assets/javascripts/spree/backend/store_credits.js +25 -0
  46. data/app/assets/javascripts/spree/backend/style_guide.js +3 -0
  47. data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +1 -1
  48. data/app/assets/javascripts/spree/backend/taxonomy.js +121 -0
  49. data/app/assets/javascripts/spree/backend/taxons.js +75 -0
  50. data/app/assets/javascripts/spree/backend/templates/index.js +2 -2
  51. data/app/assets/javascripts/spree/backend/templates/orders/line_item.hbs +7 -5
  52. data/app/assets/javascripts/spree/backend/templates/orders/shipment_tracking.hbs +24 -0
  53. data/app/assets/javascripts/spree/backend/templates/orders/shipping_method.hbs +34 -0
  54. data/app/assets/javascripts/spree/backend/templates/promotions/calculators/fields/tiered_flat_rate.hbs +7 -3
  55. data/app/assets/javascripts/spree/backend/templates/promotions/calculators/fields/tiered_percent.hbs +6 -2
  56. data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +3 -1
  57. data/app/assets/javascripts/spree/backend/templates/variants/autocomplete_stock.hbs +10 -5
  58. data/app/assets/javascripts/spree/backend/templates/variants/split.hbs +5 -3
  59. data/app/assets/javascripts/spree/backend/translation.js +11 -0
  60. data/app/assets/javascripts/spree/backend/turbolinks-integration.js +21 -0
  61. data/app/assets/javascripts/spree/backend/user_picker.js +1 -1
  62. data/app/assets/javascripts/spree/backend/variant_autocomplete.js +60 -0
  63. data/app/assets/javascripts/spree/backend/views/calculators/tiered.js +54 -0
  64. data/app/assets/javascripts/spree/backend/views/cart/line_item_row.js +2 -1
  65. data/app/assets/javascripts/spree/backend/views/index.js +7 -0
  66. data/app/assets/javascripts/spree/backend/views/order/shipment_tracking.js +46 -0
  67. data/app/assets/javascripts/spree/backend/views/order/shipping_method.js +57 -0
  68. data/app/assets/javascripts/spree/backend/views/payment/payment_row.js +36 -0
  69. data/app/assets/javascripts/spree/backend/views/promotions/option_values_rule.js +79 -0
  70. data/app/assets/javascripts/spree/backend/views/state_select.js +6 -6
  71. data/app/assets/javascripts/spree/backend/views/stock/add_stock_item.js +63 -0
  72. data/app/assets/javascripts/spree/backend/views/stock/edit_stock_item_row.js +68 -0
  73. data/app/assets/javascripts/spree/backend/views/tables/editable_table.js +15 -0
  74. data/app/assets/javascripts/spree/backend/views/tables/editable_table_row.js +61 -0
  75. data/app/assets/javascripts/spree/backend/zone.js +1 -1
  76. data/app/assets/stylesheets/spree/backend.css +1 -2
  77. data/app/assets/stylesheets/spree/backend/components/_messages.scss +4 -1
  78. data/app/assets/stylesheets/spree/backend/components/_navigation.scss +4 -2
  79. data/app/assets/stylesheets/spree/backend/components/_number_with_currency.scss +8 -2
  80. data/app/assets/stylesheets/spree/backend/components/_progress.scss +4 -0
  81. data/app/assets/stylesheets/spree/backend/components/_tabs.scss +4 -2
  82. data/app/assets/stylesheets/spree/backend/globals/mixins/_line_through.scss +2 -1
  83. data/app/assets/stylesheets/spree/backend/plugins/_select2.scss +32 -7
  84. data/app/assets/stylesheets/spree/backend/plugins/_sortable.scss +3 -0
  85. data/app/assets/stylesheets/spree/backend/sections/_orders.scss +4 -20
  86. data/app/assets/stylesheets/spree/backend/sections/_products.scss +0 -1
  87. data/app/assets/stylesheets/spree/backend/sections/_promotions.scss +15 -7
  88. data/app/assets/stylesheets/spree/backend/sections/_store_credits.scss +17 -6
  89. data/app/assets/stylesheets/spree/backend/sections/_style_guide.scss +8 -4
  90. data/app/assets/stylesheets/spree/backend/sections/_taxonomies.scss +5 -19
  91. data/app/assets/stylesheets/spree/backend/sections/_variants.scss +5 -0
  92. data/app/assets/stylesheets/spree/backend/shared/_forms.scss +13 -17
  93. data/app/assets/stylesheets/spree/backend/shared/_layout.scss +9 -3
  94. data/app/assets/stylesheets/spree/backend/shared/_tables.scss +3 -27
  95. data/app/assets/stylesheets/spree/backend/spree_admin.scss +2 -6
  96. data/app/controllers/spree/admin/base_controller.rb +2 -3
  97. data/app/controllers/spree/admin/cancellations_controller.rb +3 -3
  98. data/app/controllers/spree/admin/images_controller.rb +1 -1
  99. data/app/controllers/spree/admin/option_types_controller.rb +1 -2
  100. data/app/controllers/spree/admin/orders/customer_details_controller.rb +2 -2
  101. data/app/controllers/spree/admin/orders_controller.rb +11 -11
  102. data/app/controllers/spree/admin/payment_methods_controller.rb +5 -6
  103. data/app/controllers/spree/admin/payments_controller.rb +5 -5
  104. data/app/controllers/spree/admin/products_controller.rb +4 -6
  105. data/app/controllers/spree/admin/promotion_actions_controller.rb +4 -4
  106. data/app/controllers/spree/admin/promotion_rules_controller.rb +3 -3
  107. data/app/controllers/spree/admin/promotions_controller.rb +5 -1
  108. data/app/controllers/spree/admin/reports_controller.rb +2 -2
  109. data/app/controllers/spree/admin/resource_controller.rb +17 -5
  110. data/app/controllers/spree/admin/return_authorizations_controller.rb +2 -2
  111. data/app/controllers/spree/admin/shipping_methods_controller.rb +1 -1
  112. data/app/controllers/spree/admin/stock_locations_controller.rb +1 -1
  113. data/app/controllers/spree/admin/store_credits_controller.rb +4 -4
  114. data/app/controllers/spree/admin/taxons_controller.rb +1 -1
  115. data/app/controllers/spree/admin/users_controller.rb +6 -6
  116. data/app/controllers/spree/admin/variants_controller.rb +0 -16
  117. data/app/helpers/spree/admin/adjustments_helper.rb +2 -2
  118. data/app/helpers/spree/admin/base_helper.rb +5 -11
  119. data/app/helpers/spree/admin/navigation_helper.rb +8 -8
  120. data/app/helpers/spree/admin/orders_helper.rb +2 -2
  121. data/app/helpers/spree/admin/products_helper.rb +0 -24
  122. data/app/helpers/spree/admin/store_credit_events_helper.rb +5 -5
  123. data/app/models/spree/backend_configuration.rb +1 -2
  124. data/app/views/spree/admin/adjustment_reasons/edit.html.erb +2 -2
  125. data/app/views/spree/admin/adjustment_reasons/index.html.erb +5 -5
  126. data/app/views/spree/admin/adjustment_reasons/new.html.erb +3 -3
  127. data/app/views/spree/admin/adjustments/_adjustments_table.html.erb +2 -2
  128. data/app/views/spree/admin/adjustments/_form.html.erb +1 -1
  129. data/app/views/spree/admin/adjustments/edit.html.erb +3 -3
  130. data/app/views/spree/admin/adjustments/index.html.erb +3 -3
  131. data/app/views/spree/admin/adjustments/new.html.erb +3 -3
  132. data/app/views/spree/admin/cancellations/index.html.erb +3 -3
  133. data/app/views/spree/admin/customer_returns/_reimbursements_table.html.erb +2 -2
  134. data/app/views/spree/admin/customer_returns/_return_item_decision.html.erb +7 -7
  135. data/app/views/spree/admin/customer_returns/_return_item_selection.html.erb +2 -2
  136. data/app/views/spree/admin/customer_returns/edit.html.erb +7 -7
  137. data/app/views/spree/admin/customer_returns/index.html.erb +4 -4
  138. data/app/views/spree/admin/customer_returns/new.html.erb +11 -11
  139. data/app/views/spree/admin/images/_image_row.html.erb +3 -3
  140. data/app/views/spree/admin/images/_new.html.erb +12 -0
  141. data/app/views/spree/admin/images/edit.html.erb +4 -4
  142. data/app/views/spree/admin/images/index.html.erb +7 -5
  143. data/app/views/spree/admin/images/new.html.erb +1 -12
  144. data/app/views/spree/admin/log_entries/index.html.erb +2 -2
  145. data/app/views/spree/admin/option_types/_option_value_fields.html.erb +1 -1
  146. data/app/views/spree/admin/option_types/edit.html.erb +1 -1
  147. data/app/views/spree/admin/option_types/index.html.erb +2 -2
  148. data/app/views/spree/admin/option_types/new.html.erb +1 -1
  149. data/app/views/spree/admin/orders/_add_product.html.erb +2 -2
  150. data/app/views/spree/admin/orders/_carton.html.erb +8 -8
  151. data/app/views/spree/admin/orders/_carton_manifest.html.erb +1 -1
  152. data/app/views/spree/admin/orders/_order_details.html.erb +4 -4
  153. data/app/views/spree/admin/orders/_risk_analysis.html.erb +10 -10
  154. data/app/views/spree/admin/orders/_shipment.html.erb +11 -69
  155. data/app/views/spree/admin/orders/_shipment_manifest.html.erb +3 -3
  156. data/app/views/spree/admin/orders/cart.html.erb +2 -2
  157. data/app/views/spree/admin/orders/confirm.html.erb +6 -6
  158. data/app/views/spree/admin/orders/confirm/_customer_details.html.erb +3 -3
  159. data/app/views/spree/admin/orders/confirm/_payments.html.erb +1 -1
  160. data/app/views/spree/admin/orders/confirm/_shipment.html.erb +2 -2
  161. data/app/views/spree/admin/orders/confirm/_shipment_manifest.html.erb +1 -1
  162. data/app/views/spree/admin/orders/confirm_advance.html.erb +3 -3
  163. data/app/views/spree/admin/orders/customer_details/_form.html.erb +19 -13
  164. data/app/views/spree/admin/orders/customer_details/edit.html.erb +2 -2
  165. data/app/views/spree/admin/orders/customer_details/show.html.erb +7 -7
  166. data/app/views/spree/admin/orders/edit.html.erb +2 -2
  167. data/app/views/spree/admin/orders/index.html.erb +30 -28
  168. data/app/views/spree/admin/payment_methods/_form.html.erb +24 -13
  169. data/app/views/spree/admin/payment_methods/edit.html.erb +2 -2
  170. data/app/views/spree/admin/payment_methods/index.html.erb +6 -6
  171. data/app/views/spree/admin/payment_methods/new.html.erb +3 -3
  172. data/app/views/spree/admin/payments/_capture_events.html.erb +2 -2
  173. data/app/views/spree/admin/payments/_list.html.erb +33 -13
  174. data/app/views/spree/admin/payments/credit.html.erb +1 -1
  175. data/app/views/spree/admin/payments/index.html.erb +3 -3
  176. data/app/views/spree/admin/payments/new.html.erb +4 -4
  177. data/app/views/spree/admin/payments/show.html.erb +2 -2
  178. data/app/views/spree/admin/payments/source_forms/_gateway.html.erb +22 -23
  179. data/app/views/spree/admin/payments/source_views/_gateway.html.erb +1 -1
  180. data/app/views/spree/admin/payments/source_views/_storecredit.html.erb +1 -1
  181. data/app/views/spree/admin/prices/_form.html.erb +1 -2
  182. data/app/views/spree/admin/prices/edit.html.erb +1 -1
  183. data/app/views/spree/admin/prices/index.html.erb +2 -2
  184. data/app/views/spree/admin/prices/new.html.erb +1 -1
  185. data/app/views/spree/admin/product_properties/_product_property_fields.html.erb +1 -1
  186. data/app/views/spree/admin/product_properties/index.html.erb +7 -14
  187. data/app/views/spree/admin/products/_form.html.erb +17 -14
  188. data/app/views/spree/admin/products/edit.html.erb +2 -2
  189. data/app/views/spree/admin/products/index.html.erb +6 -6
  190. data/app/views/spree/admin/products/new.html.erb +5 -59
  191. data/app/views/spree/admin/promotion_categories/index.html.erb +1 -1
  192. data/app/views/spree/admin/promotion_categories/new.html.erb +1 -1
  193. data/app/views/spree/admin/promotion_code_batches/index.html.erb +8 -8
  194. data/app/views/spree/admin/promotion_code_batches/new.html.erb +1 -1
  195. data/app/views/spree/admin/promotion_codes/index.html.erb +1 -1
  196. data/app/views/spree/admin/promotions/_actions.html.erb +6 -6
  197. data/app/views/spree/admin/promotions/_form.html.erb +13 -4
  198. data/app/views/spree/admin/promotions/_promotion_rule.html.erb +1 -1
  199. data/app/views/spree/admin/promotions/_rules.html.erb +8 -8
  200. data/app/views/spree/admin/promotions/actions/_create_quantity_adjustments.html.erb +4 -10
  201. data/app/views/spree/admin/promotions/actions/_promotion_calculators_with_custom_fields.html.erb +25 -29
  202. data/app/views/spree/admin/promotions/calculators/_default_fields.html.erb +5 -4
  203. data/app/views/spree/admin/promotions/calculators/distributed_amount/_fields.html.erb +6 -4
  204. data/app/views/spree/admin/promotions/calculators/flat_rate/_fields.html.erb +6 -4
  205. data/app/views/spree/admin/promotions/calculators/tiered_flat_rate/_fields.html.erb +5 -5
  206. data/app/views/spree/admin/promotions/calculators/tiered_percent/_fields.html.erb +5 -5
  207. data/app/views/spree/admin/promotions/edit.html.erb +1 -1
  208. data/app/views/spree/admin/promotions/index.html.erb +7 -7
  209. data/app/views/spree/admin/promotions/new.html.erb +1 -1
  210. data/app/views/spree/admin/promotions/rules/_item_total.html.erb +10 -12
  211. data/app/views/spree/admin/promotions/rules/_nth_order.html.erb +8 -10
  212. data/app/views/spree/admin/promotions/rules/_option_value.html.erb +10 -14
  213. data/app/views/spree/admin/promotions/rules/_product.html.erb +12 -10
  214. data/app/views/spree/admin/promotions/rules/_taxon.html.erb +9 -15
  215. data/app/views/spree/admin/promotions/rules/_user.html.erb +3 -5
  216. data/app/views/spree/admin/promotions/rules/_user_role.html.erb +3 -3
  217. data/app/views/spree/admin/properties/index.html.erb +5 -5
  218. data/app/views/spree/admin/properties/new.html.erb +1 -1
  219. data/app/views/spree/admin/refund_reasons/edit.html.erb +2 -2
  220. data/app/views/spree/admin/refund_reasons/index.html.erb +5 -5
  221. data/app/views/spree/admin/refund_reasons/new.html.erb +3 -3
  222. data/app/views/spree/admin/refund_reasons/shared/_form.html.erb +1 -1
  223. data/app/views/spree/admin/refunds/edit.html.erb +3 -3
  224. data/app/views/spree/admin/refunds/new.html.erb +4 -4
  225. data/app/views/spree/admin/reimbursement_types/index.html.erb +2 -2
  226. data/app/views/spree/admin/reimbursements/edit.html.erb +9 -9
  227. data/app/views/spree/admin/reimbursements/index.html.erb +4 -4
  228. data/app/views/spree/admin/reimbursements/show.html.erb +4 -4
  229. data/app/views/spree/admin/reports/index.html.erb +3 -3
  230. data/app/views/spree/admin/reports/sales_total.html.erb +7 -7
  231. data/app/views/spree/admin/return_authorizations/_form.html.erb +3 -3
  232. data/app/views/spree/admin/return_authorizations/edit.html.erb +5 -5
  233. data/app/views/spree/admin/return_authorizations/index.html.erb +4 -4
  234. data/app/views/spree/admin/return_authorizations/new.html.erb +3 -3
  235. data/app/views/spree/admin/return_reasons/edit.html.erb +2 -2
  236. data/app/views/spree/admin/return_reasons/index.html.erb +3 -3
  237. data/app/views/spree/admin/return_reasons/new.html.erb +3 -3
  238. data/app/views/spree/admin/shared/_address_form.html.erb +2 -0
  239. data/app/views/spree/admin/shared/_calculator_fields.html.erb +4 -3
  240. data/app/views/spree/admin/shared/_edit_resource_links.html.erb +2 -2
  241. data/app/views/spree/admin/shared/_head.html.erb +13 -5
  242. data/app/views/spree/admin/shared/_js_locale_data.html.erb +24 -32
  243. data/app/views/spree/admin/shared/_navigation_footer.html.erb +32 -2
  244. data/app/views/spree/admin/shared/_new_resource_links.html.erb +2 -2
  245. data/app/views/spree/admin/shared/_no_objects_found.html.erb +2 -2
  246. data/app/views/spree/admin/shared/_number_with_currency.html.erb +9 -5
  247. data/app/views/spree/admin/shared/_order_submenu.html.erb +6 -6
  248. data/app/views/spree/admin/shared/_order_summary.html.erb +5 -5
  249. data/app/views/spree/admin/shared/_order_tabs.html.erb +1 -1
  250. data/app/views/spree/admin/shared/_product_tabs.html.erb +3 -3
  251. data/app/views/spree/admin/shared/_rebuild_vat_prices_checkbox.html.erb +2 -2
  252. data/app/views/spree/admin/shared/_refunds.html.erb +2 -2
  253. data/app/views/spree/admin/shared/_report_order_criteria.html.erb +8 -6
  254. data/app/views/spree/admin/shared/_spinner.html.erb +1 -1
  255. data/app/views/spree/admin/shared/_variant_search.html.erb +3 -3
  256. data/app/views/spree/admin/shared/named_types/_form.html.erb +4 -2
  257. data/app/views/spree/admin/shared/named_types/_index.html.erb +4 -4
  258. data/app/views/spree/admin/shared/preference_fields/_boolean.html.erb +9 -8
  259. data/app/views/spree/admin/shipping_categories/edit.html.erb +3 -3
  260. data/app/views/spree/admin/shipping_categories/index.html.erb +5 -5
  261. data/app/views/spree/admin/shipping_categories/new.html.erb +3 -3
  262. data/app/views/spree/admin/shipping_methods/_form.html.erb +10 -8
  263. data/app/views/spree/admin/shipping_methods/edit.html.erb +2 -2
  264. data/app/views/spree/admin/shipping_methods/index.html.erb +5 -5
  265. data/app/views/spree/admin/shipping_methods/new.html.erb +3 -3
  266. data/app/views/spree/admin/stock_items/_stock_management.html.erb +7 -7
  267. data/app/views/spree/admin/stock_items/index.html.erb +4 -4
  268. data/app/views/spree/admin/stock_locations/_form.html.erb +105 -103
  269. data/app/views/spree/admin/stock_locations/edit.html.erb +4 -6
  270. data/app/views/spree/admin/stock_locations/index.html.erb +5 -11
  271. data/app/views/spree/admin/stock_locations/new.html.erb +5 -7
  272. data/app/views/spree/admin/stock_movements/index.html.erb +3 -3
  273. data/app/views/spree/admin/store_credits/_form.html.erb +3 -3
  274. data/app/views/spree/admin/store_credits/_update_reason_field.html.erb +7 -8
  275. data/app/views/spree/admin/store_credits/edit_amount.html.erb +10 -6
  276. data/app/views/spree/admin/store_credits/edit_validity.html.erb +7 -5
  277. data/app/views/spree/admin/store_credits/index.html.erb +13 -13
  278. data/app/views/spree/admin/store_credits/new.html.erb +2 -2
  279. data/app/views/spree/admin/store_credits/show.html.erb +24 -32
  280. data/app/views/spree/admin/stores/_form.html.erb +1 -1
  281. data/app/views/spree/admin/stores/edit.html.erb +1 -1
  282. data/app/views/spree/admin/stores/index.html.erb +1 -1
  283. data/app/views/spree/admin/stores/new.html.erb +1 -1
  284. data/app/views/spree/admin/style_guide/topics/forms/_building_forms.html.erb +5 -3
  285. data/app/views/spree/admin/style_guide/topics/messaging/_loading.html.erb +1 -1
  286. data/app/views/spree/admin/tax_categories/_form.html.erb +4 -2
  287. data/app/views/spree/admin/tax_categories/edit.html.erb +2 -2
  288. data/app/views/spree/admin/tax_categories/index.html.erb +5 -5
  289. data/app/views/spree/admin/tax_categories/new.html.erb +3 -3
  290. data/app/views/spree/admin/tax_rates/_form.html.erb +17 -11
  291. data/app/views/spree/admin/tax_rates/edit.html.erb +2 -2
  292. data/app/views/spree/admin/tax_rates/index.html.erb +8 -8
  293. data/app/views/spree/admin/tax_rates/new.html.erb +3 -3
  294. data/app/views/spree/admin/taxonomies/edit.erb +3 -3
  295. data/app/views/spree/admin/taxonomies/index.html.erb +2 -2
  296. data/app/views/spree/admin/taxonomies/new.html.erb +2 -2
  297. data/app/views/spree/admin/taxons/_form.html.erb +5 -1
  298. data/app/views/spree/admin/taxons/edit.html.erb +4 -4
  299. data/app/views/spree/admin/taxons/index.html.erb +7 -7
  300. data/app/views/spree/admin/users/_addresses_form.html.erb +2 -2
  301. data/app/views/spree/admin/users/_form.html.erb +10 -5
  302. data/app/views/spree/admin/users/_sidebar.html.erb +6 -6
  303. data/app/views/spree/admin/users/_tabs.html.erb +5 -5
  304. data/app/views/spree/admin/users/edit.html.erb +14 -15
  305. data/app/views/spree/admin/users/index.html.erb +14 -12
  306. data/app/views/spree/admin/users/items.html.erb +7 -7
  307. data/app/views/spree/admin/users/new.html.erb +1 -1
  308. data/app/views/spree/admin/users/orders.html.erb +7 -7
  309. data/app/views/spree/admin/variants/_form.html.erb +2 -2
  310. data/app/views/spree/admin/variants/_table.html.erb +2 -2
  311. data/app/views/spree/admin/variants/_table_filter.html.erb +5 -5
  312. data/app/views/spree/admin/variants/index.html.erb +8 -8
  313. data/app/views/spree/admin/variants/new.html.erb +1 -1
  314. data/app/views/spree/admin/zones/_form.html.erb +10 -6
  315. data/app/views/spree/admin/zones/edit.html.erb +1 -1
  316. data/app/views/spree/admin/zones/index.html.erb +3 -3
  317. data/app/views/spree/admin/zones/new.html.erb +2 -2
  318. data/app/views/spree/layouts/admin.html.erb +1 -1
  319. data/app/views/spree/layouts/admin_style_guide.html.erb +2 -2
  320. data/config/routes.rb +1 -11
  321. data/lib/spree/backend.rb +1 -2
  322. data/solidus_backend.gemspec +1 -3
  323. data/spec/controllers/spree/admin/cancellations_controller_spec.rb +3 -3
  324. data/spec/controllers/spree/admin/orders_controller_spec.rb +9 -9
  325. data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +1 -1
  326. data/spec/controllers/spree/admin/prices_controller_spec.rb +2 -2
  327. data/spec/controllers/spree/admin/products_controller_spec.rb +2 -1
  328. data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +1 -1
  329. data/spec/controllers/spree/admin/promotions_controller_spec.rb +7 -0
  330. data/spec/controllers/spree/admin/reports_controller_spec.rb +1 -1
  331. data/spec/controllers/spree/admin/resource_controller_spec.rb +2 -2
  332. data/spec/controllers/spree/admin/search_controller_spec.rb +1 -1
  333. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +4 -4
  334. data/spec/controllers/spree/admin/users_controller_spec.rb +1 -1
  335. data/spec/controllers/spree/admin/variants_controller_spec.rb +13 -3
  336. data/spec/features/admin/configuration/payment_methods_spec.rb +55 -16
  337. data/spec/features/admin/configuration/shipping_methods_spec.rb +40 -0
  338. data/spec/features/admin/homepage_spec.rb +25 -8
  339. data/spec/features/admin/orders/adjustments_spec.rb +2 -2
  340. data/spec/features/admin/orders/customer_details_spec.rb +24 -9
  341. data/spec/features/admin/orders/listing_spec.rb +6 -9
  342. data/spec/features/admin/orders/log_entries_spec.rb +0 -1
  343. data/spec/features/admin/orders/new_order_spec.rb +8 -2
  344. data/spec/features/admin/orders/order_details_spec.rb +116 -74
  345. data/spec/features/admin/orders/payments_spec.rb +7 -10
  346. data/spec/features/admin/orders/shipments_spec.rb +9 -5
  347. data/spec/features/admin/payments/store_credits_spec.rb +2 -2
  348. data/spec/features/admin/products/edit/images_spec.rb +0 -79
  349. data/spec/features/admin/products/products_spec.rb +3 -6
  350. data/spec/features/admin/products/variant_spec.rb +17 -0
  351. data/spec/features/admin/promotion_adjustments_spec.rb +105 -52
  352. data/spec/features/admin/promotions/option_value_rule_spec.rb +6 -3
  353. data/spec/features/admin/promotions/tiered_calculator_spec.rb +4 -2
  354. data/spec/features/admin/users_spec.rb +14 -11
  355. data/spec/javascripts/translation_spec.js +8 -0
  356. data/spec/javascripts/views/number_with_currency_spec.js +6 -6
  357. data/spec/spec_helper.rb +28 -37
  358. data/spec/teaspoon_env.rb +61 -14
  359. data/spec/views/spree/admin/shared/navigation_footer_spec.rb +41 -0
  360. data/vendor/assets/javascripts/solidus_admin/Sortable.js +1540 -0
  361. data/vendor/assets/javascripts/solidus_admin/bootstrap.js +1878 -1816
  362. data/vendor/assets/javascripts/solidus_admin/flatpickr/flatpickr.js +2218 -0
  363. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_es-MX.js +19 -0
  364. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_alert.scss +7 -4
  365. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_badge.scss +1 -2
  366. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_breadcrumb.scss +4 -4
  367. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_button-group.scss +32 -64
  368. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_buttons.scss +38 -36
  369. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_card.scss +78 -31
  370. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_carousel.scss +6 -0
  371. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_close.scss +8 -3
  372. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_code.scss +4 -12
  373. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_custom-forms.scss +132 -89
  374. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_dropdown.scss +46 -43
  375. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_forms.scss +47 -104
  376. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_functions.scss +8 -12
  377. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_grid.scss +0 -1
  378. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_images.scss +0 -1
  379. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_input-group.scss +103 -120
  380. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_list-group.scss +2 -1
  381. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_mixins.scss +1 -0
  382. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_modal.scss +36 -10
  383. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_nav.scss +7 -7
  384. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_navbar.scss +35 -8
  385. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_pagination.scss +33 -22
  386. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_popover.scss +106 -118
  387. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_print.scss +19 -6
  388. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_progress.scss +5 -4
  389. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_reboot.scss +39 -38
  390. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_root.scss +19 -0
  391. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_tables.scss +40 -28
  392. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_tooltip.scss +65 -57
  393. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_transitions.scss +2 -0
  394. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_type.scss +4 -2
  395. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_variables.scss +546 -489
  396. data/vendor/assets/stylesheets/solidus_admin/bootstrap/bootstrap-grid.scss +8 -13
  397. data/vendor/assets/stylesheets/solidus_admin/bootstrap/bootstrap-reboot.scss +7 -4
  398. data/vendor/assets/stylesheets/solidus_admin/bootstrap/bootstrap.scss +5 -4
  399. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_alert.scss +1 -1
  400. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_background-variant.scss +10 -1
  401. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_badge.scss +2 -2
  402. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_breakpoints.scss +25 -7
  403. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_buttons.scss +50 -24
  404. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_caret.scss +65 -0
  405. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_float.scss +2 -0
  406. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_forms.scss +72 -16
  407. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_gradients.scss +8 -0
  408. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_grid-framework.scss +15 -4
  409. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_grid.scss +10 -5
  410. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_hover.scss +25 -46
  411. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_image.scss +3 -3
  412. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_list-group.scss +10 -15
  413. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_navbar-align.scss +2 -1
  414. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_reset-text.scss +1 -2
  415. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_screen-reader.scss +3 -3
  416. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_text-emphasis.scss +2 -0
  417. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_text-hide.scss +1 -0
  418. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_visibility.scss +2 -0
  419. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_align.scss +2 -0
  420. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_background.scss +16 -3
  421. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_borders.scss +10 -3
  422. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_display.scss +13 -28
  423. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_flex.scss +2 -0
  424. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_position.scss +12 -1
  425. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_sizing.scss +2 -0
  426. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_spacing.scss +24 -14
  427. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_text.scss +7 -4
  428. data/vendor/assets/stylesheets/solidus_admin/flatpickr/flatpickr.css +857 -0
  429. metadata +57 -127
  430. data/Gemfile +0 -9
  431. data/app/assets/javascripts/spree/backend/address_states.js +0 -35
  432. data/app/assets/javascripts/spree/backend/adjustments.js.coffee +0 -17
  433. data/app/assets/javascripts/spree/backend/backbone-overrides.js.coffee +0 -23
  434. data/app/assets/javascripts/spree/backend/components/editable_table.js.coffee +0 -3
  435. data/app/assets/javascripts/spree/backend/components/tabs.coffee +0 -79
  436. data/app/assets/javascripts/spree/backend/flash.coffee +0 -17
  437. data/app/assets/javascripts/spree/backend/gateway.js.coffee +0 -21
  438. data/app/assets/javascripts/spree/backend/images/index.js.coffee +0 -13
  439. data/app/assets/javascripts/spree/backend/navigation.coffee +0 -10
  440. data/app/assets/javascripts/spree/backend/number_field_updater.coffee +0 -41
  441. data/app/assets/javascripts/spree/backend/payments/edit.js.coffee +0 -33
  442. data/app/assets/javascripts/spree/backend/progress.coffee +0 -7
  443. data/app/assets/javascripts/spree/backend/promotions.js.coffee +0 -99
  444. data/app/assets/javascripts/spree/backend/select_payments.js.coffee +0 -0
  445. data/app/assets/javascripts/spree/backend/states.coffee +0 -22
  446. data/app/assets/javascripts/spree/backend/stock_management/index_add_forms.coffee +0 -61
  447. data/app/assets/javascripts/spree/backend/stock_management/index_update_forms.coffee +0 -66
  448. data/app/assets/javascripts/spree/backend/stock_management/stock_item.coffee +0 -4
  449. data/app/assets/javascripts/spree/backend/stock_transfers/count_update_forms.coffee +0 -44
  450. data/app/assets/javascripts/spree/backend/stock_transfers/edit.coffee +0 -6
  451. data/app/assets/javascripts/spree/backend/stock_transfers/receive.coffee +0 -5
  452. data/app/assets/javascripts/spree/backend/stock_transfers/received_counter.coffee +0 -9
  453. data/app/assets/javascripts/spree/backend/stock_transfers/stock_transfer.coffee +0 -17
  454. data/app/assets/javascripts/spree/backend/stock_transfers/transfer_item.coffee +0 -48
  455. data/app/assets/javascripts/spree/backend/stock_transfers/transfer_item_deleting.coffee +0 -22
  456. data/app/assets/javascripts/spree/backend/stock_transfers/variant_form.coffee +0 -128
  457. data/app/assets/javascripts/spree/backend/store_credits.js.coffee +0 -40
  458. data/app/assets/javascripts/spree/backend/style_guide.coffee +0 -2
  459. data/app/assets/javascripts/spree/backend/taxonomy.js.coffee +0 -108
  460. data/app/assets/javascripts/spree/backend/taxons.js.coffee +0 -73
  461. data/app/assets/javascripts/spree/backend/templates/promotions/rules/option_values_select.hbs +0 -1
  462. data/app/assets/javascripts/spree/backend/templates/stock_transfers/transfer_item.hbs +0 -48
  463. data/app/assets/javascripts/spree/backend/variant_autocomplete.js.coffee +0 -39
  464. data/app/assets/javascripts/spree/backend/views/tables/editable_table.js.coffee +0 -14
  465. data/app/assets/javascripts/spree/backend/views/tables/editable_table_row.js.coffee +0 -45
  466. data/app/assets/stylesheets/spree/backend/components/_date-picker.scss +0 -154
  467. data/app/assets/stylesheets/spree/backend/components/_number_field_update.scss +0 -13
  468. data/app/assets/stylesheets/spree/backend/sections/_stock_transfers.scss +0 -7
  469. data/app/assets/stylesheets/spree/backend/sections/_transfer_items.scss +0 -49
  470. data/app/controllers/spree/admin/stock_transfers_controller.rb +0 -151
  471. data/app/helpers/spree/admin/general_settings_helper.rb +0 -13
  472. data/app/helpers/spree/admin/inventory_settings_helper.rb +0 -9
  473. data/app/helpers/spree/admin/stock_transfers_helper.rb +0 -35
  474. data/app/helpers/spree/admin/tables_helper.rb +0 -13
  475. data/app/helpers/spree/admin/taxons_helper.rb +0 -9
  476. data/app/views/spree/admin/products/new.js.erb +0 -4
  477. data/app/views/spree/admin/promotions/rules/_landing_page.html.erb +0 -7
  478. data/app/views/spree/admin/shared/_number_field_update_actions.html.erb +0 -5
  479. data/app/views/spree/admin/shared/_number_field_update_cell.html.erb +0 -4
  480. data/app/views/spree/admin/shared/_stock_sub_menu.html.erb +0 -8
  481. data/app/views/spree/admin/stock_transfers/_location.html.erb +0 -7
  482. data/app/views/spree/admin/stock_transfers/_transfer_item_actions.html.erb +0 -9
  483. data/app/views/spree/admin/stock_transfers/_transfer_item_table.html.erb +0 -72
  484. data/app/views/spree/admin/stock_transfers/edit.html.erb +0 -52
  485. data/app/views/spree/admin/stock_transfers/index.html.erb +0 -123
  486. data/app/views/spree/admin/stock_transfers/new.html.erb +0 -26
  487. data/app/views/spree/admin/stock_transfers/receive.html.erb +0 -38
  488. data/app/views/spree/admin/stock_transfers/show.html.erb +0 -50
  489. data/app/views/spree/admin/stock_transfers/tracking_info.html.erb +0 -46
  490. data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +0 -365
  491. data/spec/features/admin/stock_transfer_spec.rb +0 -115
  492. data/vendor/assets/images/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  493. data/vendor/assets/images/jquery-ui/ui-bg_flat_0_eeeeee_40x100.png +0 -0
  494. data/vendor/assets/images/jquery-ui/ui-bg_flat_55_ffffff_40x100.png +0 -0
  495. data/vendor/assets/images/jquery-ui/ui-bg_flat_75_ffffff_40x100.png +0 -0
  496. data/vendor/assets/images/jquery-ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
  497. data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_100_f6f6f6_1x100.png +0 -0
  498. data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_25_0073ea_1x100.png +0 -0
  499. data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_50_dddddd_1x100.png +0 -0
  500. data/vendor/assets/images/jquery-ui/ui-icons_0073ea_256x240.png +0 -0
  501. data/vendor/assets/images/jquery-ui/ui-icons_454545_256x240.png +0 -0
  502. data/vendor/assets/images/jquery-ui/ui-icons_666666_256x240.png +0 -0
  503. data/vendor/assets/images/jquery-ui/ui-icons_ff0084_256x240.png +0 -0
  504. data/vendor/assets/images/jquery-ui/ui-icons_ffffff_256x240.png +0 -0
  505. data/vendor/assets/stylesheets/jquery-ui.datepicker.css.erb +0 -357
@@ -0,0 +1,2218 @@
1
+ /* flatpickr v4.2.3, @license MIT */
2
+ (function (global, factory) {
3
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
4
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
5
+ (factory((global.flatpickr = {})));
6
+ }(this, (function (exports) { 'use strict';
7
+
8
+ /*! *****************************************************************************
9
+ Copyright (c) Microsoft Corporation. All rights reserved.
10
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
11
+ this file except in compliance with the License. You may obtain a copy of the
12
+ License at http://www.apache.org/licenses/LICENSE-2.0
13
+
14
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17
+ MERCHANTABLITY OR NON-INFRINGEMENT.
18
+
19
+ See the Apache Version 2.0 License for specific language governing permissions
20
+ and limitations under the License.
21
+ ***************************************************************************** */
22
+ /* global Reflect, Promise */
23
+
24
+
25
+
26
+ var __assign = Object.assign || function __assign(t) {
27
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
28
+ s = arguments[i];
29
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
30
+ }
31
+ return t;
32
+ };
33
+
34
+ var pad = function (number) { return ("0" + number).slice(-2); };
35
+ var int = function (bool) { return (bool === true ? 1 : 0); };
36
+ function debounce(func, wait, immediate) {
37
+ if (immediate === void 0) { immediate = false; }
38
+ var timeout;
39
+ return function () {
40
+ var context = this, args = arguments;
41
+ timeout !== null && clearTimeout(timeout);
42
+ timeout = window.setTimeout(function () {
43
+ timeout = null;
44
+ if (!immediate)
45
+ func.apply(context, args);
46
+ }, wait);
47
+ if (immediate && !timeout)
48
+ func.apply(context, args);
49
+ };
50
+ }
51
+ var arrayify = function (obj) {
52
+ return obj instanceof Array ? obj : [obj];
53
+ };
54
+ function mouseDelta(e) {
55
+ var delta = e.wheelDelta || -e.deltaY;
56
+ return delta >= 0 ? 1 : -1;
57
+ }
58
+
59
+ var do_nothing = function () { return undefined; };
60
+ var revFormat = {
61
+ D: do_nothing,
62
+ F: function (dateObj, monthName, locale) {
63
+ dateObj.setMonth(locale.months.longhand.indexOf(monthName));
64
+ },
65
+ G: function (dateObj, hour) {
66
+ dateObj.setHours(parseFloat(hour));
67
+ },
68
+ H: function (dateObj, hour) {
69
+ dateObj.setHours(parseFloat(hour));
70
+ },
71
+ J: function (dateObj, day) {
72
+ dateObj.setDate(parseFloat(day));
73
+ },
74
+ K: function (dateObj, amPM, locale) {
75
+ dateObj.setHours(dateObj.getHours() % 12 +
76
+ 12 * int(new RegExp(locale.amPM[1], "i").test(amPM)));
77
+ },
78
+ M: function (dateObj, shortMonth, locale) {
79
+ dateObj.setMonth(locale.months.shorthand.indexOf(shortMonth));
80
+ },
81
+ S: function (dateObj, seconds) {
82
+ dateObj.setSeconds(parseFloat(seconds));
83
+ },
84
+ U: function (_, unixSeconds) { return new Date(parseFloat(unixSeconds) * 1000); },
85
+ W: function (dateObj, weekNum) {
86
+ var weekNumber = parseInt(weekNum);
87
+ return new Date(dateObj.getFullYear(), 0, 2 + (weekNumber - 1) * 7, 0, 0, 0, 0);
88
+ },
89
+ Y: function (dateObj, year) {
90
+ dateObj.setFullYear(parseFloat(year));
91
+ },
92
+ Z: function (_, ISODate) { return new Date(ISODate); },
93
+ d: function (dateObj, day) {
94
+ dateObj.setDate(parseFloat(day));
95
+ },
96
+ h: function (dateObj, hour) {
97
+ dateObj.setHours(parseFloat(hour));
98
+ },
99
+ i: function (dateObj, minutes) {
100
+ dateObj.setMinutes(parseFloat(minutes));
101
+ },
102
+ j: function (dateObj, day) {
103
+ dateObj.setDate(parseFloat(day));
104
+ },
105
+ l: do_nothing,
106
+ m: function (dateObj, month) {
107
+ dateObj.setMonth(parseFloat(month) - 1);
108
+ },
109
+ n: function (dateObj, month) {
110
+ dateObj.setMonth(parseFloat(month) - 1);
111
+ },
112
+ s: function (dateObj, seconds) {
113
+ dateObj.setSeconds(parseFloat(seconds));
114
+ },
115
+ w: do_nothing,
116
+ y: function (dateObj, year) {
117
+ dateObj.setFullYear(2000 + parseFloat(year));
118
+ },
119
+ };
120
+ var tokenRegex = {
121
+ D: "(\\w+)",
122
+ F: "(\\w+)",
123
+ G: "(\\d\\d|\\d)",
124
+ H: "(\\d\\d|\\d)",
125
+ J: "(\\d\\d|\\d)\\w+",
126
+ K: "",
127
+ M: "(\\w+)",
128
+ S: "(\\d\\d|\\d)",
129
+ U: "(.+)",
130
+ W: "(\\d\\d|\\d)",
131
+ Y: "(\\d{4})",
132
+ Z: "(.+)",
133
+ d: "(\\d\\d|\\d)",
134
+ h: "(\\d\\d|\\d)",
135
+ i: "(\\d\\d|\\d)",
136
+ j: "(\\d\\d|\\d)",
137
+ l: "(\\w+)",
138
+ m: "(\\d\\d|\\d)",
139
+ n: "(\\d\\d|\\d)",
140
+ s: "(\\d\\d|\\d)",
141
+ w: "(\\d\\d|\\d)",
142
+ y: "(\\d{2})",
143
+ };
144
+ var formats = {
145
+ Z: function (date) { return date.toISOString(); },
146
+ D: function (date, locale, options) {
147
+ return locale.weekdays.shorthand[formats.w(date, locale, options)];
148
+ },
149
+ F: function (date, locale, options) {
150
+ return monthToStr(formats.n(date, locale, options) - 1, false, locale);
151
+ },
152
+ G: function (date, locale, options) {
153
+ return pad(formats.h(date, locale, options));
154
+ },
155
+ H: function (date) { return pad(date.getHours()); },
156
+ J: function (date, locale) {
157
+ return locale.ordinal !== undefined
158
+ ? date.getDate() + locale.ordinal(date.getDate())
159
+ : date.getDate();
160
+ },
161
+ K: function (date, locale) { return locale.amPM[int(date.getHours() > 11)]; },
162
+ M: function (date, locale) {
163
+ return monthToStr(date.getMonth(), true, locale);
164
+ },
165
+ S: function (date) { return pad(date.getSeconds()); },
166
+ U: function (date) { return date.getTime() / 1000; },
167
+ W: function (date, _, options) {
168
+ return options.getWeek(date);
169
+ },
170
+ Y: function (date) { return date.getFullYear(); },
171
+ d: function (date) { return pad(date.getDate()); },
172
+ h: function (date) { return (date.getHours() % 12 ? date.getHours() % 12 : 12); },
173
+ i: function (date) { return pad(date.getMinutes()); },
174
+ j: function (date) { return date.getDate(); },
175
+ l: function (date, locale) {
176
+ return locale.weekdays.longhand[date.getDay()];
177
+ },
178
+ m: function (date) { return pad(date.getMonth() + 1); },
179
+ n: function (date) { return date.getMonth() + 1; },
180
+ s: function (date) { return date.getSeconds(); },
181
+ w: function (date) { return date.getDay(); },
182
+ y: function (date) { return String(date.getFullYear()).substring(2); },
183
+ };
184
+
185
+ var english = {
186
+ weekdays: {
187
+ shorthand: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
188
+ longhand: [
189
+ "Sunday",
190
+ "Monday",
191
+ "Tuesday",
192
+ "Wednesday",
193
+ "Thursday",
194
+ "Friday",
195
+ "Saturday",
196
+ ],
197
+ },
198
+ months: {
199
+ shorthand: [
200
+ "Jan",
201
+ "Feb",
202
+ "Mar",
203
+ "Apr",
204
+ "May",
205
+ "Jun",
206
+ "Jul",
207
+ "Aug",
208
+ "Sep",
209
+ "Oct",
210
+ "Nov",
211
+ "Dec",
212
+ ],
213
+ longhand: [
214
+ "January",
215
+ "February",
216
+ "March",
217
+ "April",
218
+ "May",
219
+ "June",
220
+ "July",
221
+ "August",
222
+ "September",
223
+ "October",
224
+ "November",
225
+ "December",
226
+ ],
227
+ },
228
+ daysInMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
229
+ firstDayOfWeek: 0,
230
+ ordinal: function (nth) {
231
+ var s = nth % 100;
232
+ if (s > 3 && s < 21)
233
+ return "th";
234
+ switch (s % 10) {
235
+ case 1:
236
+ return "st";
237
+ case 2:
238
+ return "nd";
239
+ case 3:
240
+ return "rd";
241
+ default:
242
+ return "th";
243
+ }
244
+ },
245
+ rangeSeparator: " to ",
246
+ weekAbbreviation: "Wk",
247
+ scrollTitle: "Scroll to increment",
248
+ toggleTitle: "Click to toggle",
249
+ amPM: ["AM", "PM"],
250
+ };
251
+
252
+ var createDateFormatter = function (_a) {
253
+ var _b = _a.config, config = _b === void 0 ? defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c;
254
+ return function (dateObj, frmt) {
255
+ if (config.formatDate !== undefined)
256
+ return config.formatDate(dateObj, frmt);
257
+ return frmt
258
+ .split("")
259
+ .map(function (c, i, arr) {
260
+ return formats[c] && arr[i - 1] !== "\\"
261
+ ? formats[c](dateObj, l10n, config)
262
+ : c !== "\\" ? c : "";
263
+ })
264
+ .join("");
265
+ };
266
+ };
267
+ var createDateParser = function (_a) {
268
+ var _b = _a.config, config = _b === void 0 ? defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c;
269
+ return function (date, givenFormat, timeless) {
270
+ if (date !== 0 && !date)
271
+ return undefined;
272
+ var parsedDate;
273
+ var date_orig = date;
274
+ if (date instanceof Date)
275
+ parsedDate = new Date(date.getTime());
276
+ else if (typeof date !== "string" &&
277
+ date.toFixed !== undefined)
278
+ parsedDate = new Date(date);
279
+ else if (typeof date === "string") {
280
+ var format = givenFormat || (config || defaults).dateFormat;
281
+ var datestr = String(date).trim();
282
+ if (datestr === "today") {
283
+ parsedDate = new Date();
284
+ timeless = true;
285
+ }
286
+ else if (/Z$/.test(datestr) ||
287
+ /GMT$/.test(datestr))
288
+ parsedDate = new Date(date);
289
+ else if (config && config.parseDate)
290
+ parsedDate = config.parseDate(date, format);
291
+ else {
292
+ parsedDate =
293
+ !config || !config.noCalendar
294
+ ? new Date(new Date().getFullYear(), 0, 1, 0, 0, 0, 0)
295
+ : new Date(new Date().setHours(0, 0, 0, 0));
296
+ var matched = void 0, ops = [];
297
+ for (var i = 0, matchIndex = 0, regexStr = ""; i < format.length; i++) {
298
+ var token = format[i];
299
+ var isBackSlash = token === "\\";
300
+ var escaped = format[i - 1] === "\\" || isBackSlash;
301
+ if (tokenRegex[token] && !escaped) {
302
+ regexStr += tokenRegex[token];
303
+ var match = new RegExp(regexStr).exec(date);
304
+ if (match && (matched = true)) {
305
+ ops[token !== "Y" ? "push" : "unshift"]({
306
+ fn: revFormat[token],
307
+ val: match[++matchIndex],
308
+ });
309
+ }
310
+ }
311
+ else if (!isBackSlash)
312
+ regexStr += ".";
313
+ ops.forEach(function (_a) {
314
+ var fn = _a.fn, val = _a.val;
315
+ return (parsedDate = fn(parsedDate, val, l10n) || parsedDate);
316
+ });
317
+ }
318
+ parsedDate = matched ? parsedDate : undefined;
319
+ }
320
+ }
321
+ if (!(parsedDate instanceof Date)) {
322
+ config.errorHandler(new Error("Invalid date provided: " + date_orig));
323
+ return undefined;
324
+ }
325
+ if (timeless === true)
326
+ parsedDate.setHours(0, 0, 0, 0);
327
+ return parsedDate;
328
+ };
329
+ };
330
+ function compareDates(date1, date2, timeless) {
331
+ if (timeless === void 0) { timeless = true; }
332
+ if (timeless !== false) {
333
+ return (new Date(date1.getTime()).setHours(0, 0, 0, 0) -
334
+ new Date(date2.getTime()).setHours(0, 0, 0, 0));
335
+ }
336
+ return date1.getTime() - date2.getTime();
337
+ }
338
+
339
+ var monthToStr = function (monthNumber, shorthand, locale) { return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber]; };
340
+ var getWeek = function (givenDate) {
341
+ var date = new Date(givenDate.getTime());
342
+ date.setHours(0, 0, 0, 0);
343
+ date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
344
+ var week1 = new Date(date.getFullYear(), 0, 4);
345
+ return (1 +
346
+ Math.round(((date.getTime() - week1.getTime()) / 86400000 -
347
+ 3 +
348
+ (week1.getDay() + 6) % 7) /
349
+ 7));
350
+ };
351
+ var duration = {
352
+ DAY: 86400000,
353
+ };
354
+
355
+ var defaults = {
356
+ _disable: [],
357
+ _enable: [],
358
+ allowInput: false,
359
+ altFormat: "F j, Y",
360
+ altInput: false,
361
+ altInputClass: "form-control input",
362
+ animate: typeof window === "object" &&
363
+ window.navigator.userAgent.indexOf("MSIE") === -1,
364
+ ariaDateFormat: "F j, Y",
365
+ clickOpens: true,
366
+ closeOnSelect: true,
367
+ conjunction: ", ",
368
+ dateFormat: "Y-m-d",
369
+ defaultHour: 12,
370
+ defaultMinute: 0,
371
+ defaultSeconds: 0,
372
+ disable: [],
373
+ disableMobile: false,
374
+ enable: [],
375
+ enableSeconds: false,
376
+ enableTime: false,
377
+ errorHandler: console.warn,
378
+ getWeek: getWeek,
379
+ hourIncrement: 1,
380
+ ignoredFocusElements: [],
381
+ inline: false,
382
+ locale: "default",
383
+ minuteIncrement: 5,
384
+ mode: "single",
385
+ nextArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M13.207 8.472l-7.854 7.854-0.707-0.707 7.146-7.146-7.146-7.148 0.707-0.707 7.854 7.854z' /></svg>",
386
+ noCalendar: false,
387
+ onChange: [],
388
+ onClose: [],
389
+ onDayCreate: [],
390
+ onDestroy: [],
391
+ onKeyDown: [],
392
+ onMonthChange: [],
393
+ onOpen: [],
394
+ onParseConfig: [],
395
+ onReady: [],
396
+ onValueUpdate: [],
397
+ onYearChange: [],
398
+ onPreCalendarPosition: [],
399
+ plugins: [],
400
+ position: "auto",
401
+ positionElement: undefined,
402
+ prevArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M5.207 8.471l7.146 7.147-0.707 0.707-7.853-7.854 7.854-7.853 0.707 0.707-7.147 7.146z' /></svg>",
403
+ shorthandCurrentMonth: false,
404
+ static: false,
405
+ time_24hr: false,
406
+ weekNumbers: false,
407
+ wrap: false,
408
+ };
409
+
410
+ function toggleClass(elem, className, bool) {
411
+ if (bool === true)
412
+ return elem.classList.add(className);
413
+ elem.classList.remove(className);
414
+ }
415
+ function createElement(tag, className, content) {
416
+ var e = window.document.createElement(tag);
417
+ className = className || "";
418
+ content = content || "";
419
+ e.className = className;
420
+ if (content !== undefined)
421
+ e.textContent = content;
422
+ return e;
423
+ }
424
+ function clearNode(node) {
425
+ while (node.firstChild)
426
+ node.removeChild(node.firstChild);
427
+ }
428
+ function findParent(node, condition) {
429
+ if (condition(node))
430
+ return node;
431
+ else if (node.parentNode)
432
+ return findParent(node.parentNode, condition);
433
+ return undefined;
434
+ }
435
+ function createNumberInput(inputClassName, opts) {
436
+ var wrapper = createElement("div", "numInputWrapper"), numInput = createElement("input", "numInput " + inputClassName), arrowUp = createElement("span", "arrowUp"), arrowDown = createElement("span", "arrowDown");
437
+ numInput.type = "text";
438
+ numInput.pattern = "\\d*";
439
+ if (opts !== undefined)
440
+ for (var key in opts)
441
+ numInput.setAttribute(key, opts[key]);
442
+ wrapper.appendChild(numInput);
443
+ wrapper.appendChild(arrowUp);
444
+ wrapper.appendChild(arrowDown);
445
+ return wrapper;
446
+ }
447
+
448
+ if (typeof Object.assign !== "function") {
449
+ Object.assign = function (target) {
450
+ var args = [];
451
+ for (var _i = 1; _i < arguments.length; _i++) {
452
+ args[_i - 1] = arguments[_i];
453
+ }
454
+ if (!target) {
455
+ throw TypeError("Cannot convert undefined or null to object");
456
+ }
457
+ var _loop_1 = function (source) {
458
+ if (source) {
459
+ Object.keys(source).forEach(function (key) { return (target[key] = source[key]); });
460
+ }
461
+ };
462
+ for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
463
+ var source = args_1[_a];
464
+ _loop_1(source);
465
+ }
466
+ return target;
467
+ };
468
+ }
469
+
470
+ var DEBOUNCED_CHANGE_MS = 300;
471
+ function FlatpickrInstance(element, instanceConfig) {
472
+ var self = {};
473
+ self.parseDate = createDateParser(self);
474
+ self._animationLoop = [];
475
+ self._handlers = [];
476
+ self._bind = bind;
477
+ self._setHoursFromDate = setHoursFromDate;
478
+ self.changeMonth = changeMonth;
479
+ self.changeYear = changeYear;
480
+ self.clear = clear;
481
+ self.close = close;
482
+ self._createElement = createElement;
483
+ self.destroy = destroy;
484
+ self.isEnabled = isEnabled;
485
+ self.jumpToDate = jumpToDate;
486
+ self.open = open;
487
+ self.redraw = redraw;
488
+ self.set = set;
489
+ self.setDate = setDate;
490
+ self.toggle = toggle;
491
+ function setupHelperFunctions() {
492
+ self.utils = {
493
+ getDaysInMonth: function (month, yr) {
494
+ if (month === void 0) { month = self.currentMonth; }
495
+ if (yr === void 0) { yr = self.currentYear; }
496
+ if (month === 1 && ((yr % 4 === 0 && yr % 100 !== 0) || yr % 400 === 0))
497
+ return 29;
498
+ return self.l10n.daysInMonth[month];
499
+ },
500
+ };
501
+ }
502
+ function init() {
503
+ self.element = self.input = element;
504
+ self.isOpen = false;
505
+ parseConfig();
506
+ setupLocale();
507
+ setupInputs();
508
+ setupDates();
509
+ setupHelperFunctions();
510
+ if (!self.isMobile)
511
+ build();
512
+ bindEvents();
513
+ if (self.selectedDates.length || self.config.noCalendar) {
514
+ if (self.config.enableTime) {
515
+ setHoursFromDate(self.config.noCalendar
516
+ ? self.latestSelectedDateObj || self.config.minDate
517
+ : undefined);
518
+ }
519
+ updateValue(false);
520
+ }
521
+ self.showTimeInput =
522
+ self.selectedDates.length > 0 || self.config.noCalendar;
523
+ if (self.weekWrapper !== undefined && self.daysContainer !== undefined) {
524
+ self.calendarContainer.style.width =
525
+ self.daysContainer.offsetWidth + self.weekWrapper.offsetWidth + "px";
526
+ }
527
+ var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
528
+ if (!self.isMobile && isSafari) {
529
+ positionCalendar();
530
+ }
531
+ triggerEvent("onReady");
532
+ }
533
+ function bindToInstance(fn) {
534
+ return fn.bind(self);
535
+ }
536
+ function updateTime(e) {
537
+ if (self.config.noCalendar && self.selectedDates.length === 0) {
538
+ self.setDate(self.config.minDate !== undefined
539
+ ? new Date(self.config.minDate.getTime())
540
+ : new Date().setHours(self.config.defaultHour, self.config.defaultMinute, self.config.defaultSeconds, 0), false);
541
+ setHoursFromInputs();
542
+ updateValue();
543
+ }
544
+ timeWrapper(e);
545
+ if (self.selectedDates.length === 0)
546
+ return;
547
+ if (e.type !== "input") {
548
+ setHoursFromInputs();
549
+ updateValue();
550
+ }
551
+ else {
552
+ setTimeout(function () {
553
+ setHoursFromInputs();
554
+ updateValue();
555
+ }, DEBOUNCED_CHANGE_MS);
556
+ }
557
+ }
558
+ function ampm2military(hour, amPM) {
559
+ return hour % 12 + 12 * int(amPM === self.l10n.amPM[1]);
560
+ }
561
+ function military2ampm(hour) {
562
+ switch (hour % 24) {
563
+ case 0:
564
+ case 12:
565
+ return 12;
566
+ default:
567
+ return hour % 12;
568
+ }
569
+ }
570
+ function setHoursFromInputs() {
571
+ if (self.hourElement === undefined || self.minuteElement === undefined)
572
+ return;
573
+ var hours = (parseInt(self.hourElement.value.slice(-2), 10) || 0) % 24, minutes = (parseInt(self.minuteElement.value, 10) || 0) % 60, seconds = self.secondElement !== undefined
574
+ ? (parseInt(self.secondElement.value, 10) || 0) % 60
575
+ : 0;
576
+ if (self.amPM !== undefined)
577
+ hours = ampm2military(hours, self.amPM.textContent);
578
+ var limitMinHours = self.config.minTime !== undefined ||
579
+ (self.config.minDate &&
580
+ self.minDateHasTime &&
581
+ self.latestSelectedDateObj &&
582
+ compareDates(self.latestSelectedDateObj, self.config.minDate, true) ===
583
+ 0);
584
+ var limitMaxHours = self.config.maxTime !== undefined ||
585
+ (self.config.maxDate &&
586
+ self.maxDateHasTime &&
587
+ self.latestSelectedDateObj &&
588
+ compareDates(self.latestSelectedDateObj, self.config.maxDate, true) ===
589
+ 0);
590
+ if (limitMaxHours) {
591
+ var maxTime = self.config.maxTime !== undefined
592
+ ? self.config.maxTime
593
+ : self.config.maxDate;
594
+ hours = Math.min(hours, maxTime.getHours());
595
+ if (hours === maxTime.getHours())
596
+ minutes = Math.min(minutes, maxTime.getMinutes());
597
+ }
598
+ if (limitMinHours) {
599
+ var minTime = self.config.minTime !== undefined
600
+ ? self.config.minTime
601
+ : self.config.minDate;
602
+ hours = Math.max(hours, minTime.getHours());
603
+ if (hours === minTime.getHours())
604
+ minutes = Math.max(minutes, minTime.getMinutes());
605
+ }
606
+ setHours(hours, minutes, seconds);
607
+ }
608
+ function setHoursFromDate(dateObj) {
609
+ var date = dateObj || self.latestSelectedDateObj;
610
+ if (date)
611
+ setHours(date.getHours(), date.getMinutes(), date.getSeconds());
612
+ }
613
+ function setHours(hours, minutes, seconds) {
614
+ if (self.latestSelectedDateObj !== undefined) {
615
+ self.latestSelectedDateObj.setHours(hours % 24, minutes, seconds || 0, 0);
616
+ }
617
+ if (!self.hourElement || !self.minuteElement || self.isMobile)
618
+ return;
619
+ self.hourElement.value = pad(!self.config.time_24hr
620
+ ? (12 + hours) % 12 + 12 * int(hours % 12 === 0)
621
+ : hours);
622
+ self.minuteElement.value = pad(minutes);
623
+ if (self.amPM !== undefined)
624
+ self.amPM.textContent = self.l10n.amPM[int(hours >= 12)];
625
+ if (self.secondElement !== undefined)
626
+ self.secondElement.value = pad(seconds);
627
+ }
628
+ function onYearInput(event) {
629
+ var year = parseInt(event.target.value) + (event.delta || 0);
630
+ if (year.toString().length === 4 || event.key === "Enter") {
631
+ self.currentYearElement.blur();
632
+ if (!/[^\d]/.test(year.toString()))
633
+ changeYear(year);
634
+ }
635
+ }
636
+ function bind(element, event, handler, options) {
637
+ if (event instanceof Array)
638
+ return event.forEach(function (ev) { return bind(element, ev, handler, options); });
639
+ if (element instanceof Array)
640
+ return element.forEach(function (el) { return bind(el, event, handler, options); });
641
+ element.addEventListener(event, handler, options);
642
+ self._handlers.push({ element: element, event: event, handler: handler });
643
+ }
644
+ function onClick(handler) {
645
+ return function (evt) {
646
+ evt.which === 1 && handler(evt);
647
+ };
648
+ }
649
+ function triggerChange() {
650
+ triggerEvent("onChange");
651
+ }
652
+ function bindEvents() {
653
+ if (self.config.wrap) {
654
+ ["open", "close", "toggle", "clear"].forEach(function (evt) {
655
+ Array.prototype.forEach.call(self.element.querySelectorAll("[data-" + evt + "]"), function (el) {
656
+ return bind(el, "click", self[evt]);
657
+ });
658
+ });
659
+ }
660
+ if (self.isMobile) {
661
+ setupMobile();
662
+ return;
663
+ }
664
+ var debouncedResize = debounce(onResize, 50);
665
+ self._debouncedChange = debounce(triggerChange, DEBOUNCED_CHANGE_MS);
666
+ if (self.config.mode === "range" &&
667
+ self.daysContainer &&
668
+ !/iPhone|iPad|iPod/i.test(navigator.userAgent))
669
+ bind(self.daysContainer, "mouseover", function (e) {
670
+ return onMouseOver(e.target);
671
+ });
672
+ bind(window.document.body, "keydown", onKeyDown);
673
+ if (!self.config.static)
674
+ bind(self._input, "keydown", onKeyDown);
675
+ if (!self.config.inline && !self.config.static)
676
+ bind(window, "resize", debouncedResize);
677
+ if (window.ontouchstart !== undefined)
678
+ bind(window.document.body, "touchstart", documentClick);
679
+ bind(window.document.body, "mousedown", onClick(documentClick));
680
+ bind(window.document.body, "focus", documentClick, { capture: true });
681
+ if (self.config.clickOpens === true) {
682
+ bind(self._input, "focus", self.open);
683
+ bind(self._input, "mousedown", onClick(self.open));
684
+ }
685
+ if (self.daysContainer !== undefined) {
686
+ bind(self.monthNav, "wheel", onMonthNavScroll);
687
+ bind(self.monthNav, "mousedown", onClick(onMonthNavClick));
688
+ bind(self.monthNav, ["keyup", "increment"], onYearInput);
689
+ bind(self.daysContainer, "mousedown", onClick(selectDate));
690
+ if (self.config.animate) {
691
+ bind(self.daysContainer, ["webkitAnimationEnd", "animationend"], animateDays);
692
+ bind(self.monthNav, ["webkitAnimationEnd", "animationend"], animateMonths);
693
+ }
694
+ }
695
+ if (self.timeContainer !== undefined &&
696
+ self.minuteElement !== undefined &&
697
+ self.hourElement !== undefined) {
698
+ var selText = function (e) {
699
+ return e.target.select();
700
+ };
701
+ bind(self.timeContainer, ["wheel", "input", "increment"], updateTime);
702
+ bind(self.timeContainer, "mousedown", onClick(timeIncrement));
703
+ bind(self.timeContainer, ["wheel", "input", "increment"], self._debouncedChange, { passive: true });
704
+ bind([self.hourElement, self.minuteElement], ["focus", "click"], selText);
705
+ if (self.secondElement !== undefined)
706
+ bind(self.secondElement, "focus", function () { return self.secondElement && self.secondElement.select(); });
707
+ if (self.amPM !== undefined) {
708
+ bind(self.amPM, "mousedown", onClick(function (e) {
709
+ updateTime(e);
710
+ triggerChange();
711
+ }));
712
+ }
713
+ }
714
+ }
715
+ function processPostDayAnimation() {
716
+ self._animationLoop.forEach(function (f) { return f(); });
717
+ self._animationLoop = [];
718
+ }
719
+ function animateDays(e) {
720
+ if (self.daysContainer && self.daysContainer.childNodes.length > 1) {
721
+ switch (e.animationName) {
722
+ case "fpSlideLeft":
723
+ self.daysContainer.lastChild &&
724
+ self.daysContainer.lastChild.classList.remove("slideLeftNew");
725
+ self.daysContainer.removeChild(self.daysContainer
726
+ .firstChild);
727
+ self.days = self.daysContainer.firstChild;
728
+ processPostDayAnimation();
729
+ break;
730
+ case "fpSlideRight":
731
+ self.daysContainer.firstChild &&
732
+ self.daysContainer.firstChild.classList.remove("slideRightNew");
733
+ self.daysContainer.removeChild(self.daysContainer
734
+ .lastChild);
735
+ self.days = self.daysContainer.firstChild;
736
+ processPostDayAnimation();
737
+ break;
738
+ default:
739
+ break;
740
+ }
741
+ }
742
+ }
743
+ function animateMonths(e) {
744
+ switch (e.animationName) {
745
+ case "fpSlideLeftNew":
746
+ case "fpSlideRightNew":
747
+ self.navigationCurrentMonth.classList.remove("slideLeftNew");
748
+ self.navigationCurrentMonth.classList.remove("slideRightNew");
749
+ var nav = self.navigationCurrentMonth;
750
+ while (nav.nextSibling &&
751
+ /curr/.test(nav.nextSibling.className))
752
+ self.monthNav.removeChild(nav.nextSibling);
753
+ while (nav.previousSibling &&
754
+ /curr/.test(nav.previousSibling.className))
755
+ self.monthNav.removeChild(nav.previousSibling);
756
+ self.oldCurMonth = undefined;
757
+ break;
758
+ }
759
+ }
760
+ function jumpToDate(jumpDate) {
761
+ var jumpTo = jumpDate !== undefined
762
+ ? self.parseDate(jumpDate)
763
+ : self.latestSelectedDateObj ||
764
+ (self.config.minDate && self.config.minDate > self.now
765
+ ? self.config.minDate
766
+ : self.config.maxDate && self.config.maxDate < self.now
767
+ ? self.config.maxDate
768
+ : self.now);
769
+ try {
770
+ if (jumpTo !== undefined) {
771
+ self.currentYear = jumpTo.getFullYear();
772
+ self.currentMonth = jumpTo.getMonth();
773
+ }
774
+ }
775
+ catch (e) {
776
+ e.message = "Invalid date supplied: " + jumpTo;
777
+ self.config.errorHandler(e);
778
+ }
779
+ self.redraw();
780
+ }
781
+ function timeIncrement(e) {
782
+ if (~e.target.className.indexOf("arrow"))
783
+ incrementNumInput(e, e.target.classList.contains("arrowUp") ? 1 : -1);
784
+ }
785
+ function incrementNumInput(e, delta, inputElem) {
786
+ var target = e && e.target;
787
+ var input = inputElem ||
788
+ (target && target.parentNode && target.parentNode.firstChild);
789
+ var event = createEvent("increment");
790
+ event.delta = delta;
791
+ input && input.dispatchEvent(event);
792
+ }
793
+ function build() {
794
+ var fragment = window.document.createDocumentFragment();
795
+ self.calendarContainer = createElement("div", "flatpickr-calendar");
796
+ self.calendarContainer.tabIndex = -1;
797
+ if (!self.config.noCalendar) {
798
+ fragment.appendChild(buildMonthNav());
799
+ self.innerContainer = createElement("div", "flatpickr-innerContainer");
800
+ if (self.config.weekNumbers) {
801
+ var _a = buildWeeks(), weekWrapper = _a.weekWrapper, weekNumbers = _a.weekNumbers;
802
+ self.innerContainer.appendChild(weekWrapper);
803
+ self.weekNumbers = weekNumbers;
804
+ self.weekWrapper = weekWrapper;
805
+ }
806
+ self.rContainer = createElement("div", "flatpickr-rContainer");
807
+ self.rContainer.appendChild(buildWeekdays());
808
+ if (!self.daysContainer) {
809
+ self.daysContainer = createElement("div", "flatpickr-days");
810
+ self.daysContainer.tabIndex = -1;
811
+ }
812
+ buildDays();
813
+ self.rContainer.appendChild(self.daysContainer);
814
+ self.innerContainer.appendChild(self.rContainer);
815
+ fragment.appendChild(self.innerContainer);
816
+ }
817
+ if (self.config.enableTime) {
818
+ fragment.appendChild(buildTime());
819
+ }
820
+ toggleClass(self.calendarContainer, "rangeMode", self.config.mode === "range");
821
+ toggleClass(self.calendarContainer, "animate", self.config.animate);
822
+ self.calendarContainer.appendChild(fragment);
823
+ var customAppend = self.config.appendTo !== undefined && self.config.appendTo.nodeType;
824
+ if (self.config.inline || self.config.static) {
825
+ self.calendarContainer.classList.add(self.config.inline ? "inline" : "static");
826
+ if (self.config.inline) {
827
+ if (!customAppend && self.element.parentNode)
828
+ self.element.parentNode.insertBefore(self.calendarContainer, self._input.nextSibling);
829
+ else if (self.config.appendTo !== undefined)
830
+ self.config.appendTo.appendChild(self.calendarContainer);
831
+ }
832
+ if (self.config.static) {
833
+ var wrapper = createElement("div", "flatpickr-wrapper");
834
+ if (self.element.parentNode)
835
+ self.element.parentNode.insertBefore(wrapper, self.element);
836
+ wrapper.appendChild(self.element);
837
+ if (self.altInput)
838
+ wrapper.appendChild(self.altInput);
839
+ wrapper.appendChild(self.calendarContainer);
840
+ }
841
+ }
842
+ if (!self.config.static && !self.config.inline)
843
+ (self.config.appendTo !== undefined
844
+ ? self.config.appendTo
845
+ : window.document.body).appendChild(self.calendarContainer);
846
+ }
847
+ function createDay(className, date, dayNumber, i) {
848
+ var dateIsEnabled = isEnabled(date, true), dayElement = createElement("span", "flatpickr-day " + className, date.getDate().toString());
849
+ dayElement.dateObj = date;
850
+ dayElement.$i = i;
851
+ dayElement.setAttribute("aria-label", self.formatDate(date, self.config.ariaDateFormat));
852
+ if (compareDates(date, self.now) === 0) {
853
+ self.todayDateElem = dayElement;
854
+ dayElement.classList.add("today");
855
+ }
856
+ if (dateIsEnabled) {
857
+ dayElement.tabIndex = -1;
858
+ if (isDateSelected(date)) {
859
+ dayElement.classList.add("selected");
860
+ self.selectedDateElem = dayElement;
861
+ if (self.config.mode === "range") {
862
+ toggleClass(dayElement, "startRange", self.selectedDates[0] &&
863
+ compareDates(date, self.selectedDates[0]) === 0);
864
+ toggleClass(dayElement, "endRange", self.selectedDates[1] &&
865
+ compareDates(date, self.selectedDates[1]) === 0);
866
+ }
867
+ }
868
+ }
869
+ else {
870
+ dayElement.classList.add("disabled");
871
+ if (self.selectedDates[0] &&
872
+ self.minRangeDate &&
873
+ date > self.minRangeDate &&
874
+ date < self.selectedDates[0])
875
+ self.minRangeDate = date;
876
+ else if (self.selectedDates[0] &&
877
+ self.maxRangeDate &&
878
+ date < self.maxRangeDate &&
879
+ date > self.selectedDates[0])
880
+ self.maxRangeDate = date;
881
+ }
882
+ if (self.config.mode === "range") {
883
+ if (isDateInRange(date) && !isDateSelected(date))
884
+ dayElement.classList.add("inRange");
885
+ if (self.selectedDates.length === 1 &&
886
+ self.minRangeDate !== undefined &&
887
+ self.maxRangeDate !== undefined &&
888
+ (date < self.minRangeDate || date > self.maxRangeDate))
889
+ dayElement.classList.add("notAllowed");
890
+ }
891
+ if (self.weekNumbers &&
892
+ className !== "prevMonthDay" &&
893
+ dayNumber % 7 === 1) {
894
+ self.weekNumbers.insertAdjacentHTML("beforeend", "<span class='flatpickr-day'>" + self.config.getWeek(date) + "</span>");
895
+ }
896
+ triggerEvent("onDayCreate", dayElement);
897
+ return dayElement;
898
+ }
899
+ function focusOnDay(currentIndex, offset) {
900
+ var newIndex = currentIndex + offset || 0, targetNode = (currentIndex !== undefined
901
+ ? self.days.childNodes[newIndex]
902
+ : self.selectedDateElem ||
903
+ self.todayDateElem ||
904
+ self.days.childNodes[0]);
905
+ var focus = function () {
906
+ targetNode = targetNode || self.days.childNodes[newIndex];
907
+ targetNode.focus();
908
+ if (self.config.mode === "range")
909
+ onMouseOver(targetNode);
910
+ };
911
+ if (targetNode === undefined && offset !== 0) {
912
+ if (offset > 0) {
913
+ self.changeMonth(1, true, undefined, true);
914
+ newIndex = newIndex % 42;
915
+ }
916
+ else if (offset < 0) {
917
+ self.changeMonth(-1, true, undefined, true);
918
+ newIndex += 42;
919
+ }
920
+ return afterDayAnim(focus);
921
+ }
922
+ focus();
923
+ }
924
+ function afterDayAnim(fn) {
925
+ self.config.animate === true ? self._animationLoop.push(fn) : fn();
926
+ }
927
+ function buildDays(delta) {
928
+ if (self.daysContainer === undefined) {
929
+ return;
930
+ }
931
+ var firstOfMonth = (new Date(self.currentYear, self.currentMonth, 1).getDay() -
932
+ self.l10n.firstDayOfWeek +
933
+ 7) %
934
+ 7, isRangeMode = self.config.mode === "range";
935
+ var prevMonthDays = self.utils.getDaysInMonth((self.currentMonth - 1 + 12) % 12);
936
+ var daysInMonth = self.utils.getDaysInMonth(), days = window.document.createDocumentFragment();
937
+ var dayNumber = prevMonthDays + 1 - firstOfMonth, dayIndex = 0;
938
+ if (self.weekNumbers && self.weekNumbers.firstChild)
939
+ self.weekNumbers.textContent = "";
940
+ if (isRangeMode) {
941
+ self.minRangeDate = new Date(self.currentYear, self.currentMonth - 1, dayNumber);
942
+ self.maxRangeDate = new Date(self.currentYear, self.currentMonth + 1, (42 - firstOfMonth) % daysInMonth);
943
+ }
944
+ for (; dayNumber <= prevMonthDays; dayNumber++, dayIndex++) {
945
+ days.appendChild(createDay("prevMonthDay", new Date(self.currentYear, self.currentMonth - 1, dayNumber), dayNumber, dayIndex));
946
+ }
947
+ for (dayNumber = 1; dayNumber <= daysInMonth; dayNumber++, dayIndex++) {
948
+ days.appendChild(createDay("", new Date(self.currentYear, self.currentMonth, dayNumber), dayNumber, dayIndex));
949
+ }
950
+ for (var dayNum = daysInMonth + 1; dayNum <= 42 - firstOfMonth; dayNum++, dayIndex++) {
951
+ days.appendChild(createDay("nextMonthDay", new Date(self.currentYear, self.currentMonth + 1, dayNum % daysInMonth), dayNum, dayIndex));
952
+ }
953
+ if (isRangeMode && self.selectedDates.length === 1 && days.childNodes[0]) {
954
+ self._hidePrevMonthArrow =
955
+ self._hidePrevMonthArrow ||
956
+ (!!self.minRangeDate &&
957
+ self.minRangeDate > days.childNodes[0].dateObj);
958
+ self._hideNextMonthArrow =
959
+ self._hideNextMonthArrow ||
960
+ (!!self.maxRangeDate &&
961
+ self.maxRangeDate <
962
+ new Date(self.currentYear, self.currentMonth + 1, 1));
963
+ }
964
+ else
965
+ updateNavigationCurrentMonth();
966
+ var dayContainer = createElement("div", "dayContainer");
967
+ dayContainer.appendChild(days);
968
+ if (!self.config.animate || delta === undefined)
969
+ clearNode(self.daysContainer);
970
+ else {
971
+ while (self.daysContainer.childNodes.length > 1)
972
+ self.daysContainer.removeChild(self.daysContainer.firstChild);
973
+ }
974
+ if (delta && delta >= 0)
975
+ self.daysContainer.appendChild(dayContainer);
976
+ else
977
+ self.daysContainer.insertBefore(dayContainer, self.daysContainer.firstChild);
978
+ self.days = self.daysContainer.childNodes[0];
979
+ }
980
+ function buildMonthNav() {
981
+ var monthNavFragment = window.document.createDocumentFragment();
982
+ self.monthNav = createElement("div", "flatpickr-month");
983
+ self.prevMonthNav = createElement("span", "flatpickr-prev-month");
984
+ self.prevMonthNav.innerHTML = self.config.prevArrow;
985
+ self.currentMonthElement = createElement("span", "cur-month");
986
+ self.currentMonthElement.title = self.l10n.scrollTitle;
987
+ var yearInput = createNumberInput("cur-year", { tabindex: "-1" });
988
+ self.currentYearElement = yearInput.childNodes[0];
989
+ self.currentYearElement.title = self.l10n.scrollTitle;
990
+ if (self.config.minDate)
991
+ self.currentYearElement.setAttribute("data-min", self.config.minDate.getFullYear().toString());
992
+ if (self.config.maxDate) {
993
+ self.currentYearElement.setAttribute("data-max", self.config.maxDate.getFullYear().toString());
994
+ self.currentYearElement.disabled =
995
+ !!self.config.minDate &&
996
+ self.config.minDate.getFullYear() === self.config.maxDate.getFullYear();
997
+ }
998
+ self.nextMonthNav = createElement("span", "flatpickr-next-month");
999
+ self.nextMonthNav.innerHTML = self.config.nextArrow;
1000
+ self.navigationCurrentMonth = createElement("div", "flatpickr-current-month");
1001
+ self.navigationCurrentMonth.appendChild(self.currentMonthElement);
1002
+ self.navigationCurrentMonth.appendChild(yearInput);
1003
+ monthNavFragment.appendChild(self.prevMonthNav);
1004
+ monthNavFragment.appendChild(self.navigationCurrentMonth);
1005
+ monthNavFragment.appendChild(self.nextMonthNav);
1006
+ self.monthNav.appendChild(monthNavFragment);
1007
+ Object.defineProperty(self, "_hidePrevMonthArrow", {
1008
+ get: function () { return self.__hidePrevMonthArrow; },
1009
+ set: function (bool) {
1010
+ if (self.__hidePrevMonthArrow !== bool)
1011
+ self.prevMonthNav.style.display = bool ? "none" : "block";
1012
+ self.__hidePrevMonthArrow = bool;
1013
+ },
1014
+ });
1015
+ Object.defineProperty(self, "_hideNextMonthArrow", {
1016
+ get: function () { return self.__hideNextMonthArrow; },
1017
+ set: function (bool) {
1018
+ if (self.__hideNextMonthArrow !== bool)
1019
+ self.nextMonthNav.style.display = bool ? "none" : "block";
1020
+ self.__hideNextMonthArrow = bool;
1021
+ },
1022
+ });
1023
+ updateNavigationCurrentMonth();
1024
+ return self.monthNav;
1025
+ }
1026
+ function buildTime() {
1027
+ self.calendarContainer.classList.add("hasTime");
1028
+ if (self.config.noCalendar)
1029
+ self.calendarContainer.classList.add("noCalendar");
1030
+ self.timeContainer = createElement("div", "flatpickr-time");
1031
+ self.timeContainer.tabIndex = -1;
1032
+ var separator = createElement("span", "flatpickr-time-separator", ":");
1033
+ var hourInput = createNumberInput("flatpickr-hour");
1034
+ self.hourElement = hourInput.childNodes[0];
1035
+ var minuteInput = createNumberInput("flatpickr-minute");
1036
+ self.minuteElement = minuteInput.childNodes[0];
1037
+ self.hourElement.tabIndex = self.minuteElement.tabIndex = -1;
1038
+ self.hourElement.value = pad(self.latestSelectedDateObj
1039
+ ? self.latestSelectedDateObj.getHours()
1040
+ : self.config.time_24hr
1041
+ ? self.config.defaultHour
1042
+ : military2ampm(self.config.defaultHour));
1043
+ self.minuteElement.value = pad(self.latestSelectedDateObj
1044
+ ? self.latestSelectedDateObj.getMinutes()
1045
+ : self.config.defaultMinute);
1046
+ self.hourElement.setAttribute("data-step", self.config.hourIncrement.toString());
1047
+ self.minuteElement.setAttribute("data-step", self.config.minuteIncrement.toString());
1048
+ self.hourElement.setAttribute("data-min", self.config.time_24hr ? "0" : "1");
1049
+ self.hourElement.setAttribute("data-max", self.config.time_24hr ? "23" : "12");
1050
+ self.minuteElement.setAttribute("data-min", "0");
1051
+ self.minuteElement.setAttribute("data-max", "59");
1052
+ self.hourElement.title = self.minuteElement.title = self.l10n.scrollTitle;
1053
+ self.timeContainer.appendChild(hourInput);
1054
+ self.timeContainer.appendChild(separator);
1055
+ self.timeContainer.appendChild(minuteInput);
1056
+ if (self.config.time_24hr)
1057
+ self.timeContainer.classList.add("time24hr");
1058
+ if (self.config.enableSeconds) {
1059
+ self.timeContainer.classList.add("hasSeconds");
1060
+ var secondInput = createNumberInput("flatpickr-second");
1061
+ self.secondElement = secondInput.childNodes[0];
1062
+ self.secondElement.value = pad(self.latestSelectedDateObj
1063
+ ? self.latestSelectedDateObj.getSeconds()
1064
+ : self.config.defaultSeconds);
1065
+ self.secondElement.setAttribute("data-step", self.minuteElement.getAttribute("data-step"));
1066
+ self.secondElement.setAttribute("data-min", self.minuteElement.getAttribute("data-min"));
1067
+ self.secondElement.setAttribute("data-max", self.minuteElement.getAttribute("data-max"));
1068
+ self.timeContainer.appendChild(createElement("span", "flatpickr-time-separator", ":"));
1069
+ self.timeContainer.appendChild(secondInput);
1070
+ }
1071
+ if (!self.config.time_24hr) {
1072
+ self.amPM = createElement("span", "flatpickr-am-pm", self.l10n.amPM[int((self.latestSelectedDateObj
1073
+ ? self.hourElement.value
1074
+ : self.config.defaultHour) > 11)]);
1075
+ self.amPM.title = self.l10n.toggleTitle;
1076
+ self.amPM.tabIndex = -1;
1077
+ self.timeContainer.appendChild(self.amPM);
1078
+ }
1079
+ return self.timeContainer;
1080
+ }
1081
+ function buildWeekdays() {
1082
+ if (!self.weekdayContainer)
1083
+ self.weekdayContainer = createElement("div", "flatpickr-weekdays");
1084
+ var firstDayOfWeek = self.l10n.firstDayOfWeek;
1085
+ var weekdays = self.l10n.weekdays.shorthand.slice();
1086
+ if (firstDayOfWeek > 0 && firstDayOfWeek < weekdays.length) {
1087
+ weekdays = weekdays.splice(firstDayOfWeek, weekdays.length).concat(weekdays.splice(0, firstDayOfWeek));
1088
+ }
1089
+ self.weekdayContainer.innerHTML = "\n <span class=flatpickr-weekday>\n " + weekdays.join("</span><span class=flatpickr-weekday>") + "\n </span>\n ";
1090
+ return self.weekdayContainer;
1091
+ }
1092
+ function buildWeeks() {
1093
+ self.calendarContainer.classList.add("hasWeeks");
1094
+ var weekWrapper = createElement("div", "flatpickr-weekwrapper");
1095
+ weekWrapper.appendChild(createElement("span", "flatpickr-weekday", self.l10n.weekAbbreviation));
1096
+ var weekNumbers = createElement("div", "flatpickr-weeks");
1097
+ weekWrapper.appendChild(weekNumbers);
1098
+ return {
1099
+ weekWrapper: weekWrapper,
1100
+ weekNumbers: weekNumbers,
1101
+ };
1102
+ }
1103
+ function changeMonth(value, is_offset, animate, from_keyboard) {
1104
+ if (is_offset === void 0) { is_offset = true; }
1105
+ if (animate === void 0) { animate = self.config.animate; }
1106
+ if (from_keyboard === void 0) { from_keyboard = false; }
1107
+ var delta = is_offset ? value : value - self.currentMonth;
1108
+ if ((delta < 0 && self._hidePrevMonthArrow) ||
1109
+ (delta > 0 && self._hideNextMonthArrow))
1110
+ return;
1111
+ self.currentMonth += delta;
1112
+ if (self.currentMonth < 0 || self.currentMonth > 11) {
1113
+ self.currentYear += self.currentMonth > 11 ? 1 : -1;
1114
+ self.currentMonth = (self.currentMonth + 12) % 12;
1115
+ triggerEvent("onYearChange");
1116
+ }
1117
+ buildDays(animate ? delta : undefined);
1118
+ if (!animate) {
1119
+ triggerEvent("onMonthChange");
1120
+ return updateNavigationCurrentMonth();
1121
+ }
1122
+ var nav = self.navigationCurrentMonth;
1123
+ if (delta < 0) {
1124
+ while (nav.nextSibling &&
1125
+ /curr/.test(nav.nextSibling.className))
1126
+ self.monthNav.removeChild(nav.nextSibling);
1127
+ }
1128
+ else if (delta > 0) {
1129
+ while (nav.previousSibling &&
1130
+ /curr/.test(nav.previousSibling.className))
1131
+ self.monthNav.removeChild(nav.previousSibling);
1132
+ }
1133
+ self.oldCurMonth = self.navigationCurrentMonth;
1134
+ self.navigationCurrentMonth = self.monthNav.insertBefore(self.oldCurMonth.cloneNode(true), delta > 0 ? self.oldCurMonth.nextSibling : self.oldCurMonth);
1135
+ var daysContainer = self.daysContainer;
1136
+ if (daysContainer.firstChild && daysContainer.lastChild) {
1137
+ if (delta > 0) {
1138
+ daysContainer.firstChild.classList.add("slideLeft");
1139
+ daysContainer.lastChild.classList.add("slideLeftNew");
1140
+ self.oldCurMonth.classList.add("slideLeft");
1141
+ self.navigationCurrentMonth.classList.add("slideLeftNew");
1142
+ }
1143
+ else if (delta < 0) {
1144
+ daysContainer.firstChild.classList.add("slideRightNew");
1145
+ daysContainer.lastChild.classList.add("slideRight");
1146
+ self.oldCurMonth.classList.add("slideRight");
1147
+ self.navigationCurrentMonth.classList.add("slideRightNew");
1148
+ }
1149
+ }
1150
+ self.currentMonthElement = self.navigationCurrentMonth
1151
+ .firstChild;
1152
+ self.currentYearElement = self.navigationCurrentMonth.lastChild
1153
+ .childNodes[0];
1154
+ updateNavigationCurrentMonth();
1155
+ if (self.oldCurMonth.firstChild)
1156
+ self.oldCurMonth.firstChild.textContent = monthToStr(self.currentMonth - delta, self.config.shorthandCurrentMonth, self.l10n);
1157
+ afterDayAnim(function () { return triggerEvent("onMonthChange"); });
1158
+ if (from_keyboard &&
1159
+ document.activeElement &&
1160
+ document.activeElement.$i) {
1161
+ var index_1 = document.activeElement.$i;
1162
+ afterDayAnim(function () {
1163
+ focusOnDay(index_1, 0);
1164
+ });
1165
+ }
1166
+ }
1167
+ function clear(triggerChangeEvent) {
1168
+ if (triggerChangeEvent === void 0) { triggerChangeEvent = true; }
1169
+ self.input.value = "";
1170
+ if (self.altInput)
1171
+ self.altInput.value = "";
1172
+ if (self.mobileInput)
1173
+ self.mobileInput.value = "";
1174
+ self.selectedDates = [];
1175
+ self.latestSelectedDateObj = undefined;
1176
+ self.showTimeInput = false;
1177
+ if (self.config.enableTime) {
1178
+ if (self.config.minDate !== undefined)
1179
+ setHoursFromDate(self.config.minDate);
1180
+ else
1181
+ setHours(self.config.defaultHour, self.config.defaultMinute, self.config.defaultSeconds);
1182
+ }
1183
+ self.redraw();
1184
+ if (triggerChangeEvent)
1185
+ triggerEvent("onChange");
1186
+ }
1187
+ function close() {
1188
+ self.isOpen = false;
1189
+ if (!self.isMobile) {
1190
+ self.calendarContainer.classList.remove("open");
1191
+ self._input.classList.remove("active");
1192
+ }
1193
+ triggerEvent("onClose");
1194
+ }
1195
+ function destroy() {
1196
+ if (self.config !== undefined)
1197
+ triggerEvent("onDestroy");
1198
+ for (var i = self._handlers.length; i--;) {
1199
+ var h = self._handlers[i];
1200
+ h.element.removeEventListener(h.event, h.handler);
1201
+ }
1202
+ self._handlers = [];
1203
+ if (self.mobileInput) {
1204
+ if (self.mobileInput.parentNode)
1205
+ self.mobileInput.parentNode.removeChild(self.mobileInput);
1206
+ self.mobileInput = undefined;
1207
+ }
1208
+ else if (self.calendarContainer && self.calendarContainer.parentNode)
1209
+ self.calendarContainer.parentNode.removeChild(self.calendarContainer);
1210
+ if (self.altInput) {
1211
+ self.input.type = "text";
1212
+ if (self.altInput.parentNode)
1213
+ self.altInput.parentNode.removeChild(self.altInput);
1214
+ delete self.altInput;
1215
+ }
1216
+ if (self.input) {
1217
+ self.input.type = self.input._type;
1218
+ self.input.classList.remove("flatpickr-input");
1219
+ self.input.removeAttribute("readonly");
1220
+ self.input.value = "";
1221
+ }
1222
+ [
1223
+ "_showTimeInput",
1224
+ "latestSelectedDateObj",
1225
+ "_hideNextMonthArrow",
1226
+ "_hidePrevMonthArrow",
1227
+ "__hideNextMonthArrow",
1228
+ "__hidePrevMonthArrow",
1229
+ "isMobile",
1230
+ "isOpen",
1231
+ "selectedDateElem",
1232
+ "minDateHasTime",
1233
+ "maxDateHasTime",
1234
+ "days",
1235
+ "daysContainer",
1236
+ "_input",
1237
+ "_positionElement",
1238
+ "innerContainer",
1239
+ "rContainer",
1240
+ "monthNav",
1241
+ "todayDateElem",
1242
+ "calendarContainer",
1243
+ "weekdayContainer",
1244
+ "prevMonthNav",
1245
+ "nextMonthNav",
1246
+ "currentMonthElement",
1247
+ "currentYearElement",
1248
+ "navigationCurrentMonth",
1249
+ "selectedDateElem",
1250
+ "config",
1251
+ ].forEach(function (k) {
1252
+ try {
1253
+ delete self[k];
1254
+ }
1255
+ catch (_) { }
1256
+ });
1257
+ }
1258
+ function isCalendarElem(elem) {
1259
+ if (self.config.appendTo && self.config.appendTo.contains(elem))
1260
+ return true;
1261
+ return self.calendarContainer.contains(elem);
1262
+ }
1263
+ function documentClick(e) {
1264
+ if (self.isOpen && !self.config.inline) {
1265
+ var isCalendarElement = isCalendarElem(e.target);
1266
+ var isInput = e.target === self.input ||
1267
+ e.target === self.altInput ||
1268
+ self.element.contains(e.target) ||
1269
+ (e.path &&
1270
+ e.path.indexOf &&
1271
+ (~e.path.indexOf(self.input) ||
1272
+ ~e.path.indexOf(self.altInput)));
1273
+ var lostFocus = e.type === "blur"
1274
+ ? isInput &&
1275
+ e.relatedTarget &&
1276
+ !isCalendarElem(e.relatedTarget)
1277
+ : !isInput && !isCalendarElement;
1278
+ var isIgnored = !self.config.ignoredFocusElements.some(function (elem) {
1279
+ return elem.contains(e.target);
1280
+ });
1281
+ if (lostFocus && isIgnored) {
1282
+ self.close();
1283
+ if (self.config.mode === "range" && self.selectedDates.length === 1) {
1284
+ self.clear(false);
1285
+ self.redraw();
1286
+ }
1287
+ }
1288
+ }
1289
+ }
1290
+ function changeYear(newYear) {
1291
+ if (!newYear ||
1292
+ (self.currentYearElement.getAttribute("data-min") &&
1293
+ newYear <
1294
+ parseInt(self.currentYearElement.getAttribute("data-min"))) ||
1295
+ (self.currentYearElement.getAttribute("data-max") &&
1296
+ newYear >
1297
+ parseInt(self.currentYearElement.getAttribute("data-max"))))
1298
+ return;
1299
+ var newYearNum = newYear, isNewYear = self.currentYear !== newYearNum;
1300
+ self.currentYear = newYearNum || self.currentYear;
1301
+ if (self.config.maxDate &&
1302
+ self.currentYear === self.config.maxDate.getFullYear()) {
1303
+ self.currentMonth = Math.min(self.config.maxDate.getMonth(), self.currentMonth);
1304
+ }
1305
+ else if (self.config.minDate &&
1306
+ self.currentYear === self.config.minDate.getFullYear()) {
1307
+ self.currentMonth = Math.max(self.config.minDate.getMonth(), self.currentMonth);
1308
+ }
1309
+ if (isNewYear) {
1310
+ self.redraw();
1311
+ triggerEvent("onYearChange");
1312
+ }
1313
+ }
1314
+ function isEnabled(date, timeless) {
1315
+ if (timeless === void 0) { timeless = true; }
1316
+ var dateToCheck = self.parseDate(date, undefined, timeless);
1317
+ if ((self.config.minDate &&
1318
+ dateToCheck &&
1319
+ compareDates(dateToCheck, self.config.minDate, timeless !== undefined ? timeless : !self.minDateHasTime) < 0) ||
1320
+ (self.config.maxDate &&
1321
+ dateToCheck &&
1322
+ compareDates(dateToCheck, self.config.maxDate, timeless !== undefined ? timeless : !self.maxDateHasTime) > 0))
1323
+ return false;
1324
+ if (!self.config.enable.length && !self.config.disable.length)
1325
+ return true;
1326
+ if (dateToCheck === undefined)
1327
+ return false;
1328
+ var bool = self.config.enable.length > 0, array = bool ? self.config.enable : self.config.disable;
1329
+ for (var i = 0, d = void 0; i < array.length; i++) {
1330
+ d = array[i];
1331
+ if (typeof d === "function" &&
1332
+ d(dateToCheck))
1333
+ return bool;
1334
+ else if (d instanceof Date &&
1335
+ dateToCheck !== undefined &&
1336
+ d.getTime() === dateToCheck.getTime())
1337
+ return bool;
1338
+ else if (typeof d === "string" && dateToCheck !== undefined) {
1339
+ var parsed = self.parseDate(d, undefined, true);
1340
+ return parsed && parsed.getTime() === dateToCheck.getTime()
1341
+ ? bool
1342
+ : !bool;
1343
+ }
1344
+ else if (typeof d === "object" &&
1345
+ dateToCheck !== undefined &&
1346
+ d.from &&
1347
+ d.to &&
1348
+ dateToCheck.getTime() >= d.from.getTime() &&
1349
+ dateToCheck.getTime() <= d.to.getTime())
1350
+ return bool;
1351
+ }
1352
+ return !bool;
1353
+ }
1354
+ function onKeyDown(e) {
1355
+ var isInput = e.target === self._input;
1356
+ var calendarElem = isCalendarElem(e.target);
1357
+ var allowInput = self.config.allowInput;
1358
+ var allowKeydown = self.isOpen && (!allowInput || !isInput);
1359
+ var allowInlineKeydown = self.config.inline && isInput && !allowInput;
1360
+ if (e.keyCode === 13 && isInput) {
1361
+ if (allowInput) {
1362
+ self.setDate(self._input.value, true, e.target === self.altInput
1363
+ ? self.config.altFormat
1364
+ : self.config.dateFormat);
1365
+ return e.target.blur();
1366
+ }
1367
+ else
1368
+ self.open();
1369
+ }
1370
+ else if (calendarElem || allowKeydown || allowInlineKeydown) {
1371
+ var isTimeObj = !!self.timeContainer &&
1372
+ self.timeContainer.contains(e.target);
1373
+ switch (e.keyCode) {
1374
+ case 13:
1375
+ if (isTimeObj)
1376
+ updateValue();
1377
+ else
1378
+ selectDate(e);
1379
+ break;
1380
+ case 27:
1381
+ e.preventDefault();
1382
+ self.close();
1383
+ break;
1384
+ case 8:
1385
+ case 46:
1386
+ if (isInput && !self.config.allowInput)
1387
+ self.clear();
1388
+ break;
1389
+ case 37:
1390
+ case 39:
1391
+ if (!isTimeObj) {
1392
+ e.preventDefault();
1393
+ if (self.daysContainer) {
1394
+ var delta_1 = e.keyCode === 39 ? 1 : -1;
1395
+ if (!e.ctrlKey)
1396
+ focusOnDay(e.target.$i, delta_1);
1397
+ else
1398
+ changeMonth(delta_1, true, undefined, true);
1399
+ }
1400
+ }
1401
+ else if (self.hourElement)
1402
+ self.hourElement.focus();
1403
+ break;
1404
+ case 38:
1405
+ case 40:
1406
+ e.preventDefault();
1407
+ var delta = e.keyCode === 40 ? 1 : -1;
1408
+ if (self.daysContainer && e.target.$i !== undefined) {
1409
+ if (e.ctrlKey) {
1410
+ changeYear(self.currentYear - delta);
1411
+ focusOnDay(e.target.$i, 0);
1412
+ }
1413
+ else if (!isTimeObj)
1414
+ focusOnDay(e.target.$i, delta * 7);
1415
+ }
1416
+ else if (self.config.enableTime) {
1417
+ if (!isTimeObj && self.hourElement)
1418
+ self.hourElement.focus();
1419
+ updateTime(e);
1420
+ self._debouncedChange();
1421
+ }
1422
+ break;
1423
+ case 9:
1424
+ if (e.target === self.hourElement) {
1425
+ e.preventDefault();
1426
+ self.minuteElement.select();
1427
+ }
1428
+ else if (e.target === self.minuteElement &&
1429
+ (self.secondElement || self.amPM)) {
1430
+ e.preventDefault();
1431
+ if (self.secondElement !== undefined)
1432
+ self.secondElement.focus();
1433
+ else if (self.amPM !== undefined)
1434
+ self.amPM.focus();
1435
+ }
1436
+ else if (e.target === self.secondElement && self.amPM) {
1437
+ e.preventDefault();
1438
+ self.amPM.focus();
1439
+ }
1440
+ break;
1441
+ default:
1442
+ break;
1443
+ }
1444
+ switch (e.key) {
1445
+ case self.l10n.amPM[0].charAt(0):
1446
+ if (self.amPM !== undefined && e.target === self.amPM) {
1447
+ self.amPM.textContent = self.l10n.amPM[0];
1448
+ setHoursFromInputs();
1449
+ updateValue();
1450
+ }
1451
+ break;
1452
+ case self.l10n.amPM[1].charAt(0):
1453
+ if (self.amPM !== undefined && e.target === self.amPM) {
1454
+ self.amPM.textContent = self.l10n.amPM[1];
1455
+ setHoursFromInputs();
1456
+ updateValue();
1457
+ }
1458
+ break;
1459
+ default:
1460
+ break;
1461
+ }
1462
+ triggerEvent("onKeyDown", e);
1463
+ }
1464
+ }
1465
+ function onMouseOver(elem) {
1466
+ if (self.selectedDates.length !== 1 ||
1467
+ !elem.classList.contains("flatpickr-day") ||
1468
+ elem.classList.contains("disabled") ||
1469
+ self.minRangeDate === undefined ||
1470
+ self.maxRangeDate === undefined)
1471
+ return;
1472
+ var hoverDate = elem.dateObj, initialDate = self.parseDate(self.selectedDates[0], undefined, true), rangeStartDate = Math.min(hoverDate.getTime(), self.selectedDates[0].getTime()), rangeEndDate = Math.max(hoverDate.getTime(), self.selectedDates[0].getTime()), containsDisabled = false;
1473
+ for (var t = rangeStartDate; t < rangeEndDate; t += duration.DAY) {
1474
+ if (!isEnabled(new Date(t))) {
1475
+ containsDisabled = true;
1476
+ break;
1477
+ }
1478
+ }
1479
+ var _loop_1 = function (i, date) {
1480
+ var timestamp = date.getTime();
1481
+ var outOfRange = timestamp < self.minRangeDate.getTime() ||
1482
+ timestamp > self.maxRangeDate.getTime(), dayElem = self.days.childNodes[i];
1483
+ if (outOfRange) {
1484
+ dayElem.classList.add("notAllowed");
1485
+ ["inRange", "startRange", "endRange"].forEach(function (c) {
1486
+ dayElem.classList.remove(c);
1487
+ });
1488
+ return "continue";
1489
+ }
1490
+ else if (containsDisabled && !outOfRange)
1491
+ return "continue";
1492
+ ["startRange", "inRange", "endRange", "notAllowed"].forEach(function (c) {
1493
+ dayElem.classList.remove(c);
1494
+ });
1495
+ var minRangeDate = Math.max(self.minRangeDate.getTime(), rangeStartDate), maxRangeDate = Math.min(self.maxRangeDate.getTime(), rangeEndDate);
1496
+ elem.classList.add(hoverDate < self.selectedDates[0] ? "startRange" : "endRange");
1497
+ if (initialDate < hoverDate && timestamp === initialDate.getTime())
1498
+ dayElem.classList.add("startRange");
1499
+ else if (initialDate > hoverDate && timestamp === initialDate.getTime())
1500
+ dayElem.classList.add("endRange");
1501
+ if (timestamp >= minRangeDate && timestamp <= maxRangeDate)
1502
+ dayElem.classList.add("inRange");
1503
+ };
1504
+ for (var i = 0, date = self.days.childNodes[i].dateObj; i < 42; i++, date =
1505
+ self.days.childNodes[i] &&
1506
+ self.days.childNodes[i].dateObj) {
1507
+ _loop_1(i, date);
1508
+ }
1509
+ }
1510
+ function onResize() {
1511
+ if (self.isOpen && !self.config.static && !self.config.inline)
1512
+ positionCalendar();
1513
+ }
1514
+ function open(e, positionElement) {
1515
+ if (positionElement === void 0) { positionElement = self._input; }
1516
+ if (self.isMobile) {
1517
+ if (e) {
1518
+ e.preventDefault();
1519
+ e.target && e.target.blur();
1520
+ }
1521
+ setTimeout(function () {
1522
+ self.mobileInput !== undefined && self.mobileInput.click();
1523
+ }, 0);
1524
+ triggerEvent("onOpen");
1525
+ return;
1526
+ }
1527
+ if (self._input.disabled || self.config.inline)
1528
+ return;
1529
+ var wasOpen = self.isOpen;
1530
+ self.isOpen = true;
1531
+ if (!wasOpen) {
1532
+ self.calendarContainer.classList.add("open");
1533
+ self._input.classList.add("active");
1534
+ triggerEvent("onOpen");
1535
+ positionCalendar(positionElement);
1536
+ }
1537
+ }
1538
+ function minMaxDateSetter(type) {
1539
+ return function (date) {
1540
+ var dateObj = (self.config["_" + type + "Date"] = self.parseDate(date, self.config.dateFormat));
1541
+ var inverseDateObj = self.config["_" + (type === "min" ? "max" : "min") + "Date"];
1542
+ if (dateObj !== undefined) {
1543
+ self[type === "min" ? "minDateHasTime" : "maxDateHasTime"] =
1544
+ dateObj.getHours() > 0 ||
1545
+ dateObj.getMinutes() > 0 ||
1546
+ dateObj.getSeconds() > 0;
1547
+ }
1548
+ if (self.selectedDates) {
1549
+ self.selectedDates = self.selectedDates.filter(function (d) { return isEnabled(d); });
1550
+ if (!self.selectedDates.length && type === "min")
1551
+ setHoursFromDate(dateObj);
1552
+ updateValue();
1553
+ }
1554
+ if (self.daysContainer) {
1555
+ redraw();
1556
+ if (dateObj !== undefined)
1557
+ self.currentYearElement[type] = dateObj.getFullYear().toString();
1558
+ else
1559
+ self.currentYearElement.removeAttribute(type);
1560
+ self.currentYearElement.disabled =
1561
+ !!inverseDateObj &&
1562
+ dateObj !== undefined &&
1563
+ inverseDateObj.getFullYear() === dateObj.getFullYear();
1564
+ }
1565
+ };
1566
+ }
1567
+ function parseConfig() {
1568
+ var boolOpts = [
1569
+ "wrap",
1570
+ "weekNumbers",
1571
+ "allowInput",
1572
+ "clickOpens",
1573
+ "time_24hr",
1574
+ "enableTime",
1575
+ "noCalendar",
1576
+ "altInput",
1577
+ "shorthandCurrentMonth",
1578
+ "inline",
1579
+ "static",
1580
+ "enableSeconds",
1581
+ "disableMobile",
1582
+ ];
1583
+ var hooks = [
1584
+ "onChange",
1585
+ "onClose",
1586
+ "onDayCreate",
1587
+ "onDestroy",
1588
+ "onKeyDown",
1589
+ "onMonthChange",
1590
+ "onOpen",
1591
+ "onParseConfig",
1592
+ "onReady",
1593
+ "onValueUpdate",
1594
+ "onYearChange",
1595
+ "onPreCalendarPosition",
1596
+ ];
1597
+ self.config = __assign({}, flatpickr.defaultConfig);
1598
+ var userConfig = __assign({}, instanceConfig, JSON.parse(JSON.stringify(element.dataset || {})));
1599
+ var formats$$1 = {};
1600
+ self.config.parseDate = userConfig.parseDate;
1601
+ self.config.formatDate = userConfig.formatDate;
1602
+ Object.defineProperty(self.config, "enable", {
1603
+ get: function () { return self.config._enable || []; },
1604
+ set: function (dates) {
1605
+ self.config._enable = parseDateRules(dates);
1606
+ },
1607
+ });
1608
+ Object.defineProperty(self.config, "disable", {
1609
+ get: function () { return self.config._disable || []; },
1610
+ set: function (dates) {
1611
+ self.config._disable = parseDateRules(dates);
1612
+ },
1613
+ });
1614
+ if (!userConfig.dateFormat && userConfig.enableTime) {
1615
+ formats$$1.dateFormat = userConfig.noCalendar
1616
+ ? "H:i" + (userConfig.enableSeconds ? ":S" : "")
1617
+ : flatpickr.defaultConfig.dateFormat +
1618
+ " H:i" +
1619
+ (userConfig.enableSeconds ? ":S" : "");
1620
+ }
1621
+ if (userConfig.altInput && userConfig.enableTime && !userConfig.altFormat) {
1622
+ formats$$1.altFormat = userConfig.noCalendar
1623
+ ? "h:i" + (userConfig.enableSeconds ? ":S K" : " K")
1624
+ : flatpickr.defaultConfig.altFormat +
1625
+ (" h:i" + (userConfig.enableSeconds ? ":S" : "") + " K");
1626
+ }
1627
+ Object.defineProperty(self.config, "minDate", {
1628
+ get: function () { return self.config._minDate; },
1629
+ set: minMaxDateSetter("min"),
1630
+ });
1631
+ Object.defineProperty(self.config, "maxDate", {
1632
+ get: function () { return self.config._maxDate; },
1633
+ set: minMaxDateSetter("max"),
1634
+ });
1635
+ var minMaxTimeSetter = function (type) { return function (val) {
1636
+ self.config[type === "min" ? "_minTime" : "_maxTime"] = self.parseDate(val, "H:i");
1637
+ }; };
1638
+ Object.defineProperty(self.config, "minTime", {
1639
+ get: function () { return self.config._minTime; },
1640
+ set: minMaxTimeSetter("min"),
1641
+ });
1642
+ Object.defineProperty(self.config, "maxTime", {
1643
+ get: function () { return self.config._maxTime; },
1644
+ set: minMaxTimeSetter("max"),
1645
+ });
1646
+ Object.assign(self.config, formats$$1, userConfig);
1647
+ for (var i = 0; i < boolOpts.length; i++)
1648
+ self.config[boolOpts[i]] =
1649
+ self.config[boolOpts[i]] === true ||
1650
+ self.config[boolOpts[i]] === "true";
1651
+ for (var i = hooks.length; i--;) {
1652
+ if (self.config[hooks[i]] !== undefined) {
1653
+ self.config[hooks[i]] = arrayify(self.config[hooks[i]] || []).map(bindToInstance);
1654
+ }
1655
+ }
1656
+ for (var i = 0; i < self.config.plugins.length; i++) {
1657
+ var pluginConf = self.config.plugins[i](self) || {};
1658
+ for (var key in pluginConf) {
1659
+ if (~hooks.indexOf(key)) {
1660
+ self.config[key] = arrayify(pluginConf[key])
1661
+ .map(bindToInstance)
1662
+ .concat(self.config[key]);
1663
+ }
1664
+ else if (typeof userConfig[key] === "undefined")
1665
+ self.config[key] = pluginConf[key];
1666
+ }
1667
+ }
1668
+ self.isMobile =
1669
+ !self.config.disableMobile &&
1670
+ !self.config.inline &&
1671
+ self.config.mode === "single" &&
1672
+ !self.config.disable.length &&
1673
+ !self.config.enable.length &&
1674
+ !self.config.weekNumbers &&
1675
+ /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
1676
+ triggerEvent("onParseConfig");
1677
+ }
1678
+ function setupLocale() {
1679
+ if (typeof self.config.locale !== "object" &&
1680
+ typeof flatpickr.l10ns[self.config.locale] === "undefined")
1681
+ self.config.errorHandler(new Error("flatpickr: invalid locale " + self.config.locale));
1682
+ self.l10n = __assign({}, flatpickr.l10ns.default, typeof self.config.locale === "object"
1683
+ ? self.config.locale
1684
+ : self.config.locale !== "default"
1685
+ ? flatpickr.l10ns[self.config.locale]
1686
+ : undefined);
1687
+ tokenRegex.K = "(" + self.l10n.amPM[0] + "|" + self.l10n.amPM[1] + "|" + self.l10n.amPM[0].toLowerCase() + "|" + self.l10n.amPM[1].toLowerCase() + ")";
1688
+ self.formatDate = createDateFormatter(self);
1689
+ }
1690
+ function positionCalendar(customPositionElement) {
1691
+ if (self.calendarContainer === undefined)
1692
+ return;
1693
+ triggerEvent("onPreCalendarPosition");
1694
+ var positionElement = customPositionElement || self._positionElement;
1695
+ var calendarHeight = Array.prototype.reduce.call(self.calendarContainer.children, function (acc, child) { return acc + child.offsetHeight; }, 0), calendarWidth = self.calendarContainer.offsetWidth, configPos = self.config.position, inputBounds = positionElement.getBoundingClientRect(), distanceFromBottom = window.innerHeight - inputBounds.bottom, showOnTop = configPos === "above" ||
1696
+ (configPos !== "below" &&
1697
+ distanceFromBottom < calendarHeight &&
1698
+ inputBounds.top > calendarHeight);
1699
+ var top = window.pageYOffset +
1700
+ inputBounds.top +
1701
+ (!showOnTop ? positionElement.offsetHeight + 2 : -calendarHeight - 2);
1702
+ toggleClass(self.calendarContainer, "arrowTop", !showOnTop);
1703
+ toggleClass(self.calendarContainer, "arrowBottom", showOnTop);
1704
+ if (self.config.inline)
1705
+ return;
1706
+ var left = window.pageXOffset + inputBounds.left;
1707
+ var right = window.document.body.offsetWidth - inputBounds.right;
1708
+ var rightMost = left + calendarWidth > window.document.body.offsetWidth;
1709
+ toggleClass(self.calendarContainer, "rightMost", rightMost);
1710
+ if (self.config.static)
1711
+ return;
1712
+ self.calendarContainer.style.top = top + "px";
1713
+ if (!rightMost) {
1714
+ self.calendarContainer.style.left = left + "px";
1715
+ self.calendarContainer.style.right = "auto";
1716
+ }
1717
+ else {
1718
+ self.calendarContainer.style.left = "auto";
1719
+ self.calendarContainer.style.right = right + "px";
1720
+ }
1721
+ }
1722
+ function redraw() {
1723
+ if (self.config.noCalendar || self.isMobile)
1724
+ return;
1725
+ buildWeekdays();
1726
+ updateNavigationCurrentMonth();
1727
+ buildDays();
1728
+ }
1729
+ function focusAndClose() {
1730
+ self._input.focus();
1731
+ if (window.navigator.userAgent.indexOf("MSIE") === -1)
1732
+ self.close();
1733
+ else
1734
+ setTimeout(self.close, 0);
1735
+ }
1736
+ function selectDate(e) {
1737
+ e.preventDefault();
1738
+ e.stopPropagation();
1739
+ var isSelectable = function (day) {
1740
+ return day.classList &&
1741
+ day.classList.contains("flatpickr-day") &&
1742
+ !day.classList.contains("disabled") &&
1743
+ !day.classList.contains("notAllowed");
1744
+ };
1745
+ var t = findParent(e.target, isSelectable);
1746
+ if (t === undefined)
1747
+ return;
1748
+ var target = t;
1749
+ var selectedDate = (self.latestSelectedDateObj = new Date(target.dateObj.getTime()));
1750
+ var shouldChangeMonth = selectedDate.getMonth() !== self.currentMonth &&
1751
+ self.config.mode !== "range";
1752
+ self.selectedDateElem = target;
1753
+ if (self.config.mode === "single")
1754
+ self.selectedDates = [selectedDate];
1755
+ else if (self.config.mode === "multiple") {
1756
+ var selectedIndex = isDateSelected(selectedDate);
1757
+ if (selectedIndex)
1758
+ self.selectedDates.splice(parseInt(selectedIndex), 1);
1759
+ else
1760
+ self.selectedDates.push(selectedDate);
1761
+ }
1762
+ else if (self.config.mode === "range") {
1763
+ if (self.selectedDates.length === 2)
1764
+ self.clear();
1765
+ self.selectedDates.push(selectedDate);
1766
+ if (compareDates(selectedDate, self.selectedDates[0], true) !== 0)
1767
+ self.selectedDates.sort(function (a, b) { return a.getTime() - b.getTime(); });
1768
+ }
1769
+ setHoursFromInputs();
1770
+ if (shouldChangeMonth) {
1771
+ var isNewYear = self.currentYear !== selectedDate.getFullYear();
1772
+ self.currentYear = selectedDate.getFullYear();
1773
+ self.currentMonth = selectedDate.getMonth();
1774
+ if (isNewYear)
1775
+ triggerEvent("onYearChange");
1776
+ triggerEvent("onMonthChange");
1777
+ }
1778
+ buildDays();
1779
+ if (self.config.minDate &&
1780
+ self.minDateHasTime &&
1781
+ self.config.enableTime &&
1782
+ compareDates(selectedDate, self.config.minDate) === 0)
1783
+ setHoursFromDate(self.config.minDate);
1784
+ updateValue();
1785
+ if (self.config.enableTime)
1786
+ setTimeout(function () { return (self.showTimeInput = true); }, 50);
1787
+ if (self.config.mode === "range") {
1788
+ if (self.selectedDates.length === 1) {
1789
+ onMouseOver(target);
1790
+ self._hidePrevMonthArrow =
1791
+ self._hidePrevMonthArrow ||
1792
+ (self.minRangeDate !== undefined &&
1793
+ self.minRangeDate >
1794
+ self.days.childNodes[0].dateObj);
1795
+ self._hideNextMonthArrow =
1796
+ self._hideNextMonthArrow ||
1797
+ (self.maxRangeDate !== undefined &&
1798
+ self.maxRangeDate <
1799
+ new Date(self.currentYear, self.currentMonth + 1, 1));
1800
+ }
1801
+ else
1802
+ updateNavigationCurrentMonth();
1803
+ }
1804
+ if (!shouldChangeMonth)
1805
+ focusOnDay(target.$i, 0);
1806
+ else
1807
+ afterDayAnim(function () { return self.selectedDateElem && self.selectedDateElem.focus(); });
1808
+ if (self.hourElement !== undefined)
1809
+ setTimeout(function () { return self.hourElement !== undefined && self.hourElement.select(); }, 451);
1810
+ if (self.config.closeOnSelect) {
1811
+ var single = self.config.mode === "single" && !self.config.enableTime;
1812
+ var range = self.config.mode === "range" &&
1813
+ self.selectedDates.length === 2 &&
1814
+ !self.config.enableTime;
1815
+ if (single || range) {
1816
+ focusAndClose();
1817
+ }
1818
+ }
1819
+ triggerChange();
1820
+ }
1821
+ var CALLBACKS = {
1822
+ locale: [setupLocale],
1823
+ };
1824
+ function set(option, value) {
1825
+ if (option !== null && typeof option === "object")
1826
+ Object.assign(self.config, option);
1827
+ else {
1828
+ self.config[option] = value;
1829
+ if (CALLBACKS[option] !== undefined)
1830
+ CALLBACKS[option].forEach(function (x) { return x(); });
1831
+ }
1832
+ self.redraw();
1833
+ jumpToDate();
1834
+ }
1835
+ function setSelectedDate(inputDate, format) {
1836
+ var dates = [];
1837
+ if (inputDate instanceof Array)
1838
+ dates = inputDate.map(function (d) { return self.parseDate(d, format); });
1839
+ else if (inputDate instanceof Date || typeof inputDate === "number")
1840
+ dates = [self.parseDate(inputDate, format)];
1841
+ else if (typeof inputDate === "string") {
1842
+ switch (self.config.mode) {
1843
+ case "single":
1844
+ dates = [self.parseDate(inputDate, format)];
1845
+ break;
1846
+ case "multiple":
1847
+ dates = inputDate
1848
+ .split(self.config.conjunction)
1849
+ .map(function (date) { return self.parseDate(date, format); });
1850
+ break;
1851
+ case "range":
1852
+ dates = inputDate
1853
+ .split(self.l10n.rangeSeparator)
1854
+ .map(function (date) { return self.parseDate(date, format); });
1855
+ break;
1856
+ default:
1857
+ break;
1858
+ }
1859
+ }
1860
+ else
1861
+ self.config.errorHandler(new Error("Invalid date supplied: " + JSON.stringify(inputDate)));
1862
+ self.selectedDates = dates.filter(function (d) { return d instanceof Date && isEnabled(d, false); });
1863
+ self.selectedDates.sort(function (a, b) { return a.getTime() - b.getTime(); });
1864
+ }
1865
+ function setDate(date, triggerChange, format) {
1866
+ if (triggerChange === void 0) { triggerChange = false; }
1867
+ if (format === void 0) { format = self.config.dateFormat; }
1868
+ if (date !== 0 && !date)
1869
+ return self.clear(triggerChange);
1870
+ setSelectedDate(date, format);
1871
+ self.showTimeInput = self.selectedDates.length > 0;
1872
+ self.latestSelectedDateObj = self.selectedDates[0];
1873
+ self.redraw();
1874
+ jumpToDate();
1875
+ setHoursFromDate();
1876
+ updateValue(triggerChange);
1877
+ if (triggerChange)
1878
+ triggerEvent("onChange");
1879
+ }
1880
+ function parseDateRules(arr) {
1881
+ return arr
1882
+ .map(function (rule) {
1883
+ if (typeof rule === "string" ||
1884
+ typeof rule === "number" ||
1885
+ rule instanceof Date) {
1886
+ return self.parseDate(rule, undefined, true);
1887
+ }
1888
+ else if (rule &&
1889
+ typeof rule === "object" &&
1890
+ rule.from &&
1891
+ rule.to)
1892
+ return {
1893
+ from: self.parseDate(rule.from, undefined),
1894
+ to: self.parseDate(rule.to, undefined),
1895
+ };
1896
+ return rule;
1897
+ })
1898
+ .filter(function (x) { return x; });
1899
+ }
1900
+ function setupDates() {
1901
+ self.selectedDates = [];
1902
+ self.now = new Date();
1903
+ var preloadedDate = self.config.defaultDate || self.input.value;
1904
+ if (preloadedDate)
1905
+ setSelectedDate(preloadedDate, self.config.dateFormat);
1906
+ var initialDate = self.selectedDates.length
1907
+ ? self.selectedDates[0]
1908
+ : self.config.minDate &&
1909
+ self.config.minDate.getTime() > self.now.getTime()
1910
+ ? self.config.minDate
1911
+ : self.config.maxDate &&
1912
+ self.config.maxDate.getTime() < self.now.getTime()
1913
+ ? self.config.maxDate
1914
+ : self.now;
1915
+ self.currentYear = initialDate.getFullYear();
1916
+ self.currentMonth = initialDate.getMonth();
1917
+ if (self.selectedDates.length)
1918
+ self.latestSelectedDateObj = self.selectedDates[0];
1919
+ if (self.config.minTime !== undefined)
1920
+ self.config.minTime = self.parseDate(self.config.minTime, "H:i");
1921
+ if (self.config.maxTime !== undefined)
1922
+ self.config.maxTime = self.parseDate(self.config.maxTime, "H:i");
1923
+ self.minDateHasTime =
1924
+ !!self.config.minDate &&
1925
+ (self.config.minDate.getHours() > 0 ||
1926
+ self.config.minDate.getMinutes() > 0 ||
1927
+ self.config.minDate.getSeconds() > 0);
1928
+ self.maxDateHasTime =
1929
+ !!self.config.maxDate &&
1930
+ (self.config.maxDate.getHours() > 0 ||
1931
+ self.config.maxDate.getMinutes() > 0 ||
1932
+ self.config.maxDate.getSeconds() > 0);
1933
+ Object.defineProperty(self, "showTimeInput", {
1934
+ get: function () { return self._showTimeInput; },
1935
+ set: function (bool) {
1936
+ self._showTimeInput = bool;
1937
+ if (self.calendarContainer)
1938
+ toggleClass(self.calendarContainer, "showTimeInput", bool);
1939
+ self.isOpen && positionCalendar();
1940
+ },
1941
+ });
1942
+ }
1943
+ function setupInputs() {
1944
+ self.input = self.config.wrap
1945
+ ? element.querySelector("[data-input]")
1946
+ : element;
1947
+ if (!self.input) {
1948
+ self.config.errorHandler(new Error("Invalid input element specified"));
1949
+ return;
1950
+ }
1951
+ self.input._type = self.input.type;
1952
+ self.input.type = "text";
1953
+ self.input.classList.add("flatpickr-input");
1954
+ self._input = self.input;
1955
+ if (self.config.altInput) {
1956
+ self.altInput = createElement(self.input.nodeName, self.input.className + " " + self.config.altInputClass);
1957
+ self._input = self.altInput;
1958
+ self.altInput.placeholder = self.input.placeholder;
1959
+ self.altInput.disabled = self.input.disabled;
1960
+ self.altInput.required = self.input.required;
1961
+ self.altInput.type = "text";
1962
+ self.input.type = "hidden";
1963
+ if (!self.config.static && self.input.parentNode)
1964
+ self.input.parentNode.insertBefore(self.altInput, self.input.nextSibling);
1965
+ }
1966
+ if (!self.config.allowInput)
1967
+ self._input.setAttribute("readonly", "readonly");
1968
+ self._positionElement = self.config.positionElement || self._input;
1969
+ }
1970
+ function setupMobile() {
1971
+ var inputType = self.config.enableTime
1972
+ ? self.config.noCalendar ? "time" : "datetime-local"
1973
+ : "date";
1974
+ self.mobileInput = createElement("input", self.input.className + " flatpickr-mobile");
1975
+ self.mobileInput.step = self.input.getAttribute("step") || "any";
1976
+ self.mobileInput.tabIndex = 1;
1977
+ self.mobileInput.type = inputType;
1978
+ self.mobileInput.disabled = self.input.disabled;
1979
+ self.mobileInput.placeholder = self.input.placeholder;
1980
+ self.mobileFormatStr =
1981
+ inputType === "datetime-local"
1982
+ ? "Y-m-d\\TH:i:S"
1983
+ : inputType === "date" ? "Y-m-d" : "H:i:S";
1984
+ if (self.selectedDates.length) {
1985
+ self.mobileInput.defaultValue = self.mobileInput.value = self.formatDate(self.selectedDates[0], self.mobileFormatStr);
1986
+ }
1987
+ if (self.config.minDate)
1988
+ self.mobileInput.min = self.formatDate(self.config.minDate, "Y-m-d");
1989
+ if (self.config.maxDate)
1990
+ self.mobileInput.max = self.formatDate(self.config.maxDate, "Y-m-d");
1991
+ self.input.type = "hidden";
1992
+ if (self.altInput !== undefined)
1993
+ self.altInput.type = "hidden";
1994
+ try {
1995
+ if (self.input.parentNode)
1996
+ self.input.parentNode.insertBefore(self.mobileInput, self.input.nextSibling);
1997
+ }
1998
+ catch (_a) { }
1999
+ bind(self.mobileInput, "change", function (e) {
2000
+ self.setDate(e.target.value, false, self.mobileFormatStr);
2001
+ triggerEvent("onChange");
2002
+ triggerEvent("onClose");
2003
+ });
2004
+ }
2005
+ function toggle() {
2006
+ if (self.isOpen)
2007
+ return self.close();
2008
+ self.open();
2009
+ }
2010
+ function triggerEvent(event, data) {
2011
+ var hooks = self.config[event];
2012
+ if (hooks !== undefined && hooks.length > 0) {
2013
+ for (var i = 0; hooks[i] && i < hooks.length; i++)
2014
+ hooks[i](self.selectedDates, self.input.value, self, data);
2015
+ }
2016
+ if (event === "onChange") {
2017
+ self.input.dispatchEvent(createEvent("change"));
2018
+ self.input.dispatchEvent(createEvent("input"));
2019
+ }
2020
+ }
2021
+ function createEvent(name) {
2022
+ var e = document.createEvent("Event");
2023
+ e.initEvent(name, true, true);
2024
+ return e;
2025
+ }
2026
+ function isDateSelected(date) {
2027
+ for (var i = 0; i < self.selectedDates.length; i++) {
2028
+ if (compareDates(self.selectedDates[i], date) === 0)
2029
+ return "" + i;
2030
+ }
2031
+ return false;
2032
+ }
2033
+ function isDateInRange(date) {
2034
+ if (self.config.mode !== "range" || self.selectedDates.length < 2)
2035
+ return false;
2036
+ return (compareDates(date, self.selectedDates[0]) >= 0 &&
2037
+ compareDates(date, self.selectedDates[1]) <= 0);
2038
+ }
2039
+ function updateNavigationCurrentMonth() {
2040
+ if (self.config.noCalendar || self.isMobile || !self.monthNav)
2041
+ return;
2042
+ self.currentMonthElement.textContent =
2043
+ monthToStr(self.currentMonth, self.config.shorthandCurrentMonth, self.l10n) + " ";
2044
+ self.currentYearElement.value = self.currentYear.toString();
2045
+ self._hidePrevMonthArrow =
2046
+ self.config.minDate !== undefined &&
2047
+ (self.currentYear === self.config.minDate.getFullYear()
2048
+ ? self.currentMonth <= self.config.minDate.getMonth()
2049
+ : self.currentYear < self.config.minDate.getFullYear());
2050
+ self._hideNextMonthArrow =
2051
+ self.config.maxDate !== undefined &&
2052
+ (self.currentYear === self.config.maxDate.getFullYear()
2053
+ ? self.currentMonth + 1 > self.config.maxDate.getMonth()
2054
+ : self.currentYear > self.config.maxDate.getFullYear());
2055
+ }
2056
+ function updateValue(triggerChange) {
2057
+ if (triggerChange === void 0) { triggerChange = true; }
2058
+ if (!self.selectedDates.length)
2059
+ return self.clear(triggerChange);
2060
+ if (self.mobileInput !== undefined && self.mobileFormatStr) {
2061
+ self.mobileInput.value =
2062
+ self.latestSelectedDateObj !== undefined
2063
+ ? self.formatDate(self.latestSelectedDateObj, self.mobileFormatStr)
2064
+ : "";
2065
+ }
2066
+ var joinChar = self.config.mode !== "range"
2067
+ ? self.config.conjunction
2068
+ : self.l10n.rangeSeparator;
2069
+ self.input.value = self.selectedDates
2070
+ .map(function (dObj) { return self.formatDate(dObj, self.config.dateFormat); })
2071
+ .join(joinChar);
2072
+ if (self.altInput !== undefined) {
2073
+ self.altInput.value = self.selectedDates
2074
+ .map(function (dObj) { return self.formatDate(dObj, self.config.altFormat); })
2075
+ .join(joinChar);
2076
+ }
2077
+ if (triggerChange !== false)
2078
+ triggerEvent("onValueUpdate");
2079
+ }
2080
+ function onMonthNavScroll(e) {
2081
+ e.preventDefault();
2082
+ var isYear = self.currentYearElement.parentNode &&
2083
+ self.currentYearElement.parentNode.contains(e.target);
2084
+ if (e.target === self.currentMonthElement || isYear) {
2085
+ var delta = mouseDelta(e);
2086
+ if (isYear) {
2087
+ changeYear(self.currentYear + delta);
2088
+ e.target.value = self.currentYear.toString();
2089
+ }
2090
+ else
2091
+ self.changeMonth(delta, true, false);
2092
+ }
2093
+ }
2094
+ function onMonthNavClick(e) {
2095
+ var isPrevMonth = self.prevMonthNav.contains(e.target);
2096
+ var isNextMonth = self.nextMonthNav.contains(e.target);
2097
+ if (isPrevMonth || isNextMonth)
2098
+ changeMonth(isPrevMonth ? -1 : 1);
2099
+ else if (e.target === self.currentYearElement) {
2100
+ e.preventDefault();
2101
+ self.currentYearElement.select();
2102
+ }
2103
+ else if (e.target.className === "arrowUp")
2104
+ self.changeYear(self.currentYear + 1);
2105
+ else if (e.target.className === "arrowDown")
2106
+ self.changeYear(self.currentYear - 1);
2107
+ }
2108
+ function timeWrapper(e) {
2109
+ e.preventDefault();
2110
+ var isKeyDown = e.type === "keydown", input = e.target;
2111
+ if (self.amPM !== undefined && e.target === self.amPM) {
2112
+ self.amPM.textContent =
2113
+ self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])];
2114
+ }
2115
+ var min = parseFloat(input.getAttribute("data-min")), max = parseFloat(input.getAttribute("data-max")), step = parseFloat(input.getAttribute("data-step")), curValue = parseInt(input.value, 10), delta = e.delta ||
2116
+ (isKeyDown
2117
+ ? e.which === 38 ? 1 : -1
2118
+ : Math.max(-1, Math.min(1, e.wheelDelta || -e.deltaY)) || 0);
2119
+ var newValue = curValue + step * delta;
2120
+ if (typeof input.value !== "undefined" && input.value.length === 2) {
2121
+ var isHourElem = input === self.hourElement, isMinuteElem = input === self.minuteElement;
2122
+ if (newValue < min) {
2123
+ newValue =
2124
+ max +
2125
+ newValue +
2126
+ int(!isHourElem) +
2127
+ (int(isHourElem) && int(!self.amPM));
2128
+ if (isMinuteElem)
2129
+ incrementNumInput(undefined, -1, self.hourElement);
2130
+ }
2131
+ else if (newValue > max) {
2132
+ newValue =
2133
+ input === self.hourElement ? newValue - max - int(!self.amPM) : min;
2134
+ if (isMinuteElem)
2135
+ incrementNumInput(undefined, 1, self.hourElement);
2136
+ }
2137
+ if (self.amPM &&
2138
+ isHourElem &&
2139
+ (step === 1
2140
+ ? newValue + curValue === 23
2141
+ : Math.abs(newValue - curValue) > step)) {
2142
+ self.amPM.textContent =
2143
+ self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])];
2144
+ }
2145
+ input.value = pad(newValue);
2146
+ }
2147
+ }
2148
+ init();
2149
+ return self;
2150
+ }
2151
+ function _flatpickr(nodeList, config) {
2152
+ var nodes = Array.prototype.slice.call(nodeList);
2153
+ var instances = [];
2154
+ for (var i = 0; i < nodes.length; i++) {
2155
+ var node = nodes[i];
2156
+ try {
2157
+ if (node.getAttribute("data-fp-omit") !== null)
2158
+ continue;
2159
+ if (node._flatpickr !== undefined) {
2160
+ node._flatpickr.destroy();
2161
+ node._flatpickr = undefined;
2162
+ }
2163
+ node._flatpickr = FlatpickrInstance(node, config || {});
2164
+ instances.push(node._flatpickr);
2165
+ }
2166
+ catch (e) {
2167
+ console.error(e);
2168
+ }
2169
+ }
2170
+ return instances.length === 1 ? instances[0] : instances;
2171
+ }
2172
+ if (typeof HTMLElement !== "undefined") {
2173
+ HTMLCollection.prototype.flatpickr = NodeList.prototype.flatpickr = function (config) {
2174
+ return _flatpickr(this, config);
2175
+ };
2176
+ HTMLElement.prototype.flatpickr = function (config) {
2177
+ return _flatpickr([this], config);
2178
+ };
2179
+ }
2180
+ var flatpickr;
2181
+ flatpickr = function (selector, config) {
2182
+ if (selector instanceof NodeList)
2183
+ return _flatpickr(selector, config);
2184
+ else if (typeof selector === "string")
2185
+ return _flatpickr(window.document.querySelectorAll(selector), config);
2186
+ return _flatpickr([selector], config);
2187
+ };
2188
+ if (typeof window === "object")
2189
+ window.flatpickr = flatpickr;
2190
+ flatpickr.defaultConfig = defaults;
2191
+ flatpickr.l10ns = {
2192
+ en: __assign({}, english),
2193
+ default: __assign({}, english),
2194
+ };
2195
+ flatpickr.localize = function (l10n) {
2196
+ flatpickr.l10ns.default = __assign({}, flatpickr.l10ns.default, l10n);
2197
+ };
2198
+ flatpickr.setDefaults = function (config) {
2199
+ flatpickr.defaultConfig = __assign({}, flatpickr.defaultConfig, config);
2200
+ };
2201
+ flatpickr.parseDate = createDateParser({});
2202
+ flatpickr.formatDate = createDateFormatter({});
2203
+ flatpickr.compareDates = compareDates;
2204
+ if (typeof jQuery !== "undefined") {
2205
+ jQuery.fn.flatpickr = function (config) {
2206
+ return _flatpickr(this, config);
2207
+ };
2208
+ }
2209
+ Date.prototype.fp_incr = function (days) {
2210
+ return new Date(this.getFullYear(), this.getMonth(), this.getDate() + (typeof days === "string" ? parseInt(days, 10) : days));
2211
+ };
2212
+ var flatpickr$1 = flatpickr;
2213
+
2214
+ exports['default'] = flatpickr$1;
2215
+
2216
+ Object.defineProperty(exports, '__esModule', { value: true });
2217
+
2218
+ })));