solidus_backend_devise_token_auth 2.8.0.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (801) hide show
  1. checksums.yaml +7 -0
  2. data/.eslintrc +21 -0
  3. data/README.md +42 -0
  4. data/Rakefile +52 -0
  5. data/app/assets/config/solidus_backend_manifest.js +6 -0
  6. data/app/assets/images/solidus-style-guide-logo.png +0 -0
  7. data/app/assets/javascripts/spree/backend/addresses.js +23 -0
  8. data/app/assets/javascripts/spree/backend/adjustments.js +25 -0
  9. data/app/assets/javascripts/spree/backend/admin.js +136 -0
  10. data/app/assets/javascripts/spree/backend/backbone-overrides.js +25 -0
  11. data/app/assets/javascripts/spree/backend/calculator.js +26 -0
  12. data/app/assets/javascripts/spree/backend/checkouts/edit.js +12 -0
  13. data/app/assets/javascripts/spree/backend/collections/index.js +3 -0
  14. data/app/assets/javascripts/spree/backend/collections/line_items.js +9 -0
  15. data/app/assets/javascripts/spree/backend/collections/shipments.js +6 -0
  16. data/app/assets/javascripts/spree/backend/collections/states.js +13 -0
  17. data/app/assets/javascripts/spree/backend/components/editable_table.js +5 -0
  18. data/app/assets/javascripts/spree/backend/components/number_with_currency.js +12 -0
  19. data/app/assets/javascripts/spree/backend/components/sortable_table.js +29 -0
  20. data/app/assets/javascripts/spree/backend/components/tabs.js +67 -0
  21. data/app/assets/javascripts/spree/backend/components/tooltips.js +33 -0
  22. data/app/assets/javascripts/spree/backend/datepicker.js +55 -0
  23. data/app/assets/javascripts/spree/backend/devise_token_auth.js +37 -0
  24. data/app/assets/javascripts/spree/backend/flash.js +20 -0
  25. data/app/assets/javascripts/spree/backend/format_money.js +11 -0
  26. data/app/assets/javascripts/spree/backend/gateway.js +22 -0
  27. data/app/assets/javascripts/spree/backend/handlebars_extensions.js +26 -0
  28. data/app/assets/javascripts/spree/backend/highlight_negative_numbers.js +14 -0
  29. data/app/assets/javascripts/spree/backend/images/index.js +8 -0
  30. data/app/assets/javascripts/spree/backend/images/upload.js +27 -0
  31. data/app/assets/javascripts/spree/backend/locale_selection.js +18 -0
  32. data/app/assets/javascripts/spree/backend/models/address.js +2 -0
  33. data/app/assets/javascripts/spree/backend/models/image_upload.js +76 -0
  34. data/app/assets/javascripts/spree/backend/models/index.js +7 -0
  35. data/app/assets/javascripts/spree/backend/models/line_item.js +11 -0
  36. data/app/assets/javascripts/spree/backend/models/order.js +38 -0
  37. data/app/assets/javascripts/spree/backend/models/payment.js +5 -0
  38. data/app/assets/javascripts/spree/backend/models/shipment.js +27 -0
  39. data/app/assets/javascripts/spree/backend/models/stock_item.js +6 -0
  40. data/app/assets/javascripts/spree/backend/models/taxonomy.js +3 -0
  41. data/app/assets/javascripts/spree/backend/namespaces.js +15 -0
  42. data/app/assets/javascripts/spree/backend/navigation.js +14 -0
  43. data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +41 -0
  44. data/app/assets/javascripts/spree/backend/option_value_picker.js +43 -0
  45. data/app/assets/javascripts/spree/backend/orders/cart.js +55 -0
  46. data/app/assets/javascripts/spree/backend/orders/edit.js +6 -0
  47. data/app/assets/javascripts/spree/backend/orders/index.js +2 -0
  48. data/app/assets/javascripts/spree/backend/payments/edit.js +16 -0
  49. data/app/assets/javascripts/spree/backend/payments/new.js +11 -0
  50. data/app/assets/javascripts/spree/backend/product_picker.js +50 -0
  51. data/app/assets/javascripts/spree/backend/progress.js +10 -0
  52. data/app/assets/javascripts/spree/backend/promotions/activation.js +26 -0
  53. data/app/assets/javascripts/spree/backend/promotions.js +35 -0
  54. data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +35 -0
  55. data/app/assets/javascripts/spree/backend/routes.js +27 -0
  56. data/app/assets/javascripts/spree/backend/shipments.js +317 -0
  57. data/app/assets/javascripts/spree/backend/spree-select2.js +9 -0
  58. data/app/assets/javascripts/spree/backend/stock_management.js +22 -0
  59. data/app/assets/javascripts/spree/backend/store_credits.js +25 -0
  60. data/app/assets/javascripts/spree/backend/style_guide.js +3 -0
  61. data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +56 -0
  62. data/app/assets/javascripts/spree/backend/taxonomy.js +121 -0
  63. data/app/assets/javascripts/spree/backend/taxons.js +70 -0
  64. data/app/assets/javascripts/spree/backend/templates/_image.hbs +5 -0
  65. data/app/assets/javascripts/spree/backend/templates/index.js +18 -0
  66. data/app/assets/javascripts/spree/backend/templates/orders/customer_details/autocomplete.hbs +17 -0
  67. data/app/assets/javascripts/spree/backend/templates/orders/details_adjustment_row.hbs +4 -0
  68. data/app/assets/javascripts/spree/backend/templates/orders/line_item.hbs +44 -0
  69. data/app/assets/javascripts/spree/backend/templates/orders/shipment_tracking.hbs +24 -0
  70. data/app/assets/javascripts/spree/backend/templates/orders/shipping_method.hbs +34 -0
  71. data/app/assets/javascripts/spree/backend/templates/products/sortable.hbs +5 -0
  72. data/app/assets/javascripts/spree/backend/templates/products/upload_progress.hbs +14 -0
  73. data/app/assets/javascripts/spree/backend/templates/promotions/calculators/fields/tiered_flat_rate.hbs +23 -0
  74. data/app/assets/javascripts/spree/backend/templates/promotions/calculators/fields/tiered_percent.hbs +23 -0
  75. data/app/assets/javascripts/spree/backend/templates/promotions/rules/option_values.hbs +12 -0
  76. data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +35 -0
  77. data/app/assets/javascripts/spree/backend/templates/taxons/_tree.hbs +22 -0
  78. data/app/assets/javascripts/spree/backend/templates/taxons/tree.hbs +1 -0
  79. data/app/assets/javascripts/spree/backend/templates/variants/autocomplete.hbs +19 -0
  80. data/app/assets/javascripts/spree/backend/templates/variants/autocomplete_stock.hbs +56 -0
  81. data/app/assets/javascripts/spree/backend/templates/variants/line_items_autocomplete_stock.hbs +26 -0
  82. data/app/assets/javascripts/spree/backend/templates/variants/split.hbs +27 -0
  83. data/app/assets/javascripts/spree/backend/translation.js +40 -0
  84. data/app/assets/javascripts/spree/backend/turbolinks-integration.js +21 -0
  85. data/app/assets/javascripts/spree/backend/user_picker.js +49 -0
  86. data/app/assets/javascripts/spree/backend/variant_autocomplete.js +54 -0
  87. data/app/assets/javascripts/spree/backend/views/calculators/tiered.js +54 -0
  88. data/app/assets/javascripts/spree/backend/views/cart/add_line_item_button.js +19 -0
  89. data/app/assets/javascripts/spree/backend/views/cart/line_item_row.js +89 -0
  90. data/app/assets/javascripts/spree/backend/views/cart/line_item_table.js +11 -0
  91. data/app/assets/javascripts/spree/backend/views/images/upload_progress.js +48 -0
  92. data/app/assets/javascripts/spree/backend/views/images/upload_zone.js +39 -0
  93. data/app/assets/javascripts/spree/backend/views/index.js +25 -0
  94. data/app/assets/javascripts/spree/backend/views/number_with_currency.js +31 -0
  95. data/app/assets/javascripts/spree/backend/views/order/address.js +48 -0
  96. data/app/assets/javascripts/spree/backend/views/order/customer_details.js +67 -0
  97. data/app/assets/javascripts/spree/backend/views/order/customer_select.js +54 -0
  98. data/app/assets/javascripts/spree/backend/views/order/details_adjustments.js +39 -0
  99. data/app/assets/javascripts/spree/backend/views/order/details_total.js +12 -0
  100. data/app/assets/javascripts/spree/backend/views/order/shipment_tracking.js +46 -0
  101. data/app/assets/javascripts/spree/backend/views/order/shipping_method.js +57 -0
  102. data/app/assets/javascripts/spree/backend/views/order/summary.js +36 -0
  103. data/app/assets/javascripts/spree/backend/views/payment/edit_credit_card.js +23 -0
  104. data/app/assets/javascripts/spree/backend/views/payment/new.js +25 -0
  105. data/app/assets/javascripts/spree/backend/views/payment/payment_row.js +36 -0
  106. data/app/assets/javascripts/spree/backend/views/promotions/option_values_rule.js +79 -0
  107. data/app/assets/javascripts/spree/backend/views/state_select.js +71 -0
  108. data/app/assets/javascripts/spree/backend/views/stock/add_stock_item.js +74 -0
  109. data/app/assets/javascripts/spree/backend/views/stock/edit_stock_item_row.js +90 -0
  110. data/app/assets/javascripts/spree/backend/views/tables/editable_table.js +15 -0
  111. data/app/assets/javascripts/spree/backend/views/tables/editable_table_row.js +61 -0
  112. data/app/assets/javascripts/spree/backend/views/zones/form.js +16 -0
  113. data/app/assets/javascripts/spree/backend/zone.js +8 -0
  114. data/app/assets/javascripts/spree/backend.js +66 -0
  115. data/app/assets/stylesheets/spree/backend/_bootstrap_custom.scss +83 -0
  116. data/app/assets/stylesheets/spree/backend/components/_actions.scss +29 -0
  117. data/app/assets/stylesheets/spree/backend/components/_breadcrumb.scss +4 -0
  118. data/app/assets/stylesheets/spree/backend/components/_editable_table.scss +36 -0
  119. data/app/assets/stylesheets/spree/backend/components/_hint.scss +3 -0
  120. data/app/assets/stylesheets/spree/backend/components/_image_placeholder.scss +24 -0
  121. data/app/assets/stylesheets/spree/backend/components/_list_group.scss +26 -0
  122. data/app/assets/stylesheets/spree/backend/components/_messages.scss +57 -0
  123. data/app/assets/stylesheets/spree/backend/components/_navigation.scss +195 -0
  124. data/app/assets/stylesheets/spree/backend/components/_number_with_currency.scss +45 -0
  125. data/app/assets/stylesheets/spree/backend/components/_pills.scss +92 -0
  126. data/app/assets/stylesheets/spree/backend/components/_progress.scss +58 -0
  127. data/app/assets/stylesheets/spree/backend/components/_sidebar.scss +18 -0
  128. data/app/assets/stylesheets/spree/backend/components/_states.scss +11 -0
  129. data/app/assets/stylesheets/spree/backend/components/_stock_table.scss +29 -0
  130. data/app/assets/stylesheets/spree/backend/components/_table-filter.scss +20 -0
  131. data/app/assets/stylesheets/spree/backend/components/_tabs.scss +112 -0
  132. data/app/assets/stylesheets/spree/backend/globals/_deprecation.scss +17 -0
  133. data/app/assets/stylesheets/spree/backend/globals/_functions.scss +25 -0
  134. data/app/assets/stylesheets/spree/backend/globals/_mixins.css +2 -0
  135. data/app/assets/stylesheets/spree/backend/globals/_variables.scss +148 -0
  136. data/app/assets/stylesheets/spree/backend/globals/_variables_override.scss +7 -0
  137. data/app/assets/stylesheets/spree/backend/globals/mixins/_caret.scss +35 -0
  138. data/app/assets/stylesheets/spree/backend/globals/mixins/_line_through.scss +23 -0
  139. data/app/assets/stylesheets/spree/backend/plugins/_bootstrap_tooltip.scss +43 -0
  140. data/app/assets/stylesheets/spree/backend/plugins/_select2.scss +119 -0
  141. data/app/assets/stylesheets/spree/backend/plugins/_sortable.scss +3 -0
  142. data/app/assets/stylesheets/spree/backend/sections/_adjustments.scss +3 -0
  143. data/app/assets/stylesheets/spree/backend/sections/_bulk_transfer.scss +8 -0
  144. data/app/assets/stylesheets/spree/backend/sections/_image_settings.scss +3 -0
  145. data/app/assets/stylesheets/spree/backend/sections/_log_entries.scss +17 -0
  146. data/app/assets/stylesheets/spree/backend/sections/_orders.scss +77 -0
  147. data/app/assets/stylesheets/spree/backend/sections/_products.scss +61 -0
  148. data/app/assets/stylesheets/spree/backend/sections/_promotions.scss +149 -0
  149. data/app/assets/stylesheets/spree/backend/sections/_return_authorizations.scss +12 -0
  150. data/app/assets/stylesheets/spree/backend/sections/_stock_management.scss +92 -0
  151. data/app/assets/stylesheets/spree/backend/sections/_store_credits.scss +29 -0
  152. data/app/assets/stylesheets/spree/backend/sections/_style_guide.scss +141 -0
  153. data/app/assets/stylesheets/spree/backend/sections/_taxonomies.scss +37 -0
  154. data/app/assets/stylesheets/spree/backend/sections/_taxons.scss +5 -0
  155. data/app/assets/stylesheets/spree/backend/sections/_users.scss +5 -0
  156. data/app/assets/stylesheets/spree/backend/sections/_variants.scss +5 -0
  157. data/app/assets/stylesheets/spree/backend/shared/_forms.scss +215 -0
  158. data/app/assets/stylesheets/spree/backend/shared/_header.scss +32 -0
  159. data/app/assets/stylesheets/spree/backend/shared/_icons.scss +55 -0
  160. data/app/assets/stylesheets/spree/backend/shared/_images.scss +7 -0
  161. data/app/assets/stylesheets/spree/backend/shared/_layout.scss +40 -0
  162. data/app/assets/stylesheets/spree/backend/shared/_tables.scss +126 -0
  163. data/app/assets/stylesheets/spree/backend/shared/_typography.scss +109 -0
  164. data/app/assets/stylesheets/spree/backend/shared/_utilities.scss +47 -0
  165. data/app/assets/stylesheets/spree/backend/spree_admin.scss +54 -0
  166. data/app/assets/stylesheets/spree/backend/themes/blue_steel/globals/_variables_override.scss +25 -0
  167. data/app/assets/stylesheets/spree/backend.css +11 -0
  168. data/app/controllers/spree/admin/adjustment_reasons_controller.rb +8 -0
  169. data/app/controllers/spree/admin/adjustments_controller.rb +47 -0
  170. data/app/controllers/spree/admin/base_controller.rb +59 -0
  171. data/app/controllers/spree/admin/cancellations_controller.rb +46 -0
  172. data/app/controllers/spree/admin/customer_returns_controller.rb +76 -0
  173. data/app/controllers/spree/admin/dashboards_controller.rb +8 -0
  174. data/app/controllers/spree/admin/general_settings_controller.rb +11 -0
  175. data/app/controllers/spree/admin/images_controller.rb +35 -0
  176. data/app/controllers/spree/admin/locale_controller.rb +24 -0
  177. data/app/controllers/spree/admin/log_entries_controller.rb +20 -0
  178. data/app/controllers/spree/admin/option_types_controller.rb +41 -0
  179. data/app/controllers/spree/admin/option_values_controller.rb +13 -0
  180. data/app/controllers/spree/admin/orders/customer_details_controller.rb +74 -0
  181. data/app/controllers/spree/admin/orders_controller.rb +192 -0
  182. data/app/controllers/spree/admin/payment_methods_controller.rb +86 -0
  183. data/app/controllers/spree/admin/payments_controller.rb +123 -0
  184. data/app/controllers/spree/admin/prices_controller.rb +28 -0
  185. data/app/controllers/spree/admin/product_properties_controller.rb +29 -0
  186. data/app/controllers/spree/admin/products_controller.rb +143 -0
  187. data/app/controllers/spree/admin/promotion_actions_controller.rb +51 -0
  188. data/app/controllers/spree/admin/promotion_categories_controller.rb +8 -0
  189. data/app/controllers/spree/admin/promotion_code_batches_controller.rb +30 -0
  190. data/app/controllers/spree/admin/promotion_codes_controller.rb +25 -0
  191. data/app/controllers/spree/admin/promotion_rules_controller.rb +61 -0
  192. data/app/controllers/spree/admin/promotions_controller.rb +67 -0
  193. data/app/controllers/spree/admin/properties_controller.rb +27 -0
  194. data/app/controllers/spree/admin/refund_reasons_controller.rb +8 -0
  195. data/app/controllers/spree/admin/refunds_controller.rb +40 -0
  196. data/app/controllers/spree/admin/reimbursement_types_controller.rb +8 -0
  197. data/app/controllers/spree/admin/reimbursements_controller.rb +69 -0
  198. data/app/controllers/spree/admin/resource_controller.rb +292 -0
  199. data/app/controllers/spree/admin/return_authorizations_controller.rb +62 -0
  200. data/app/controllers/spree/admin/return_items_controller.rb +18 -0
  201. data/app/controllers/spree/admin/return_reasons_controller.rb +8 -0
  202. data/app/controllers/spree/admin/root_controller.rb +31 -0
  203. data/app/controllers/spree/admin/search_controller.rb +39 -0
  204. data/app/controllers/spree/admin/shipping_categories_controller.rb +8 -0
  205. data/app/controllers/spree/admin/shipping_methods_controller.rb +48 -0
  206. data/app/controllers/spree/admin/stock_items_controller.rb +63 -0
  207. data/app/controllers/spree/admin/stock_locations_controller.rb +18 -0
  208. data/app/controllers/spree/admin/stock_movements_controller.rb +23 -0
  209. data/app/controllers/spree/admin/store_credits_controller.rb +118 -0
  210. data/app/controllers/spree/admin/stores_controller.rb +25 -0
  211. data/app/controllers/spree/admin/style_guide_controller.rb +43 -0
  212. data/app/controllers/spree/admin/tax_categories_controller.rb +8 -0
  213. data/app/controllers/spree/admin/tax_rates_controller.rb +17 -0
  214. data/app/controllers/spree/admin/taxonomies_controller.rb +17 -0
  215. data/app/controllers/spree/admin/taxons_controller.rb +82 -0
  216. data/app/controllers/spree/admin/users_controller.rb +156 -0
  217. data/app/controllers/spree/admin/variant_property_rule_values_controller.rb +9 -0
  218. data/app/controllers/spree/admin/variants_controller.rb +51 -0
  219. data/app/controllers/spree/admin/variants_including_master_controller.rb +15 -0
  220. data/app/controllers/spree/admin/zones_controller.rb +28 -0
  221. data/app/helpers/spree/admin/adjustments_helper.rb +46 -0
  222. data/app/helpers/spree/admin/base_helper.rb +138 -0
  223. data/app/helpers/spree/admin/customer_returns_helper.rb +11 -0
  224. data/app/helpers/spree/admin/navigation_helper.rb +191 -0
  225. data/app/helpers/spree/admin/orders_helper.rb +65 -0
  226. data/app/helpers/spree/admin/payments_helper.rb +12 -0
  227. data/app/helpers/spree/admin/products_helper.rb +11 -0
  228. data/app/helpers/spree/admin/reimbursement_type_helper.rb +11 -0
  229. data/app/helpers/spree/admin/stock_locations_helper.rb +13 -0
  230. data/app/helpers/spree/admin/stock_movements_helper.rb +26 -0
  231. data/app/helpers/spree/admin/store_credit_events_helper.rb +86 -0
  232. data/app/helpers/spree/promotion_rules_helper.rb +12 -0
  233. data/app/models/spree/backend_configuration.rb +118 -0
  234. data/app/views/kaminari/solidus_admin/_first_page.html.erb +3 -0
  235. data/app/views/kaminari/solidus_admin/_gap.html.erb +3 -0
  236. data/app/views/kaminari/solidus_admin/_last_page.html.erb +3 -0
  237. data/app/views/kaminari/solidus_admin/_next_page.html.erb +3 -0
  238. data/app/views/kaminari/solidus_admin/_page.html.erb +9 -0
  239. data/app/views/kaminari/solidus_admin/_paginator.html.erb +15 -0
  240. data/app/views/kaminari/solidus_admin/_prev_page.html.erb +3 -0
  241. data/app/views/spree/admin/adjustment_reasons/edit.html.erb +15 -0
  242. data/app/views/spree/admin/adjustment_reasons/index.html.erb +53 -0
  243. data/app/views/spree/admin/adjustment_reasons/new.html.erb +18 -0
  244. data/app/views/spree/admin/adjustment_reasons/shared/_form.html.erb +20 -0
  245. data/app/views/spree/admin/adjustments/_adjustment.html.erb +24 -0
  246. data/app/views/spree/admin/adjustments/_adjustments_table.html.erb +27 -0
  247. data/app/views/spree/admin/adjustments/_form.html.erb +28 -0
  248. data/app/views/spree/admin/adjustments/edit.html.erb +19 -0
  249. data/app/views/spree/admin/adjustments/index.html.erb +23 -0
  250. data/app/views/spree/admin/adjustments/new.html.erb +21 -0
  251. data/app/views/spree/admin/cancellations/index.html.erb +57 -0
  252. data/app/views/spree/admin/customer_returns/_reimbursements_table.html.erb +39 -0
  253. data/app/views/spree/admin/customer_returns/_return_item_decision.html.erb +70 -0
  254. data/app/views/spree/admin/customer_returns/_return_item_selection.html.erb +63 -0
  255. data/app/views/spree/admin/customer_returns/edit.html.erb +63 -0
  256. data/app/views/spree/admin/customer_returns/index.html.erb +52 -0
  257. data/app/views/spree/admin/customer_returns/new.html.erb +56 -0
  258. data/app/views/spree/admin/dashboards/home.html.erb +1 -0
  259. data/app/views/spree/admin/images/_form.html.erb +20 -0
  260. data/app/views/spree/admin/images/_image_row.html.erb +52 -0
  261. data/app/views/spree/admin/images/_new.html.erb +12 -0
  262. data/app/views/spree/admin/images/create.js.erb +12 -0
  263. data/app/views/spree/admin/images/edit.html.erb +33 -0
  264. data/app/views/spree/admin/images/index.html.erb +74 -0
  265. data/app/views/spree/admin/images/new.html.erb +1 -0
  266. data/app/views/spree/admin/log_entries/index.html.erb +29 -0
  267. data/app/views/spree/admin/option_types/_form.html.erb +17 -0
  268. data/app/views/spree/admin/option_types/_option_value_fields.html.erb +11 -0
  269. data/app/views/spree/admin/option_types/edit.html.erb +42 -0
  270. data/app/views/spree/admin/option_types/index.html.erb +55 -0
  271. data/app/views/spree/admin/option_types/new.html.erb +9 -0
  272. data/app/views/spree/admin/option_types/new.js.erb +2 -0
  273. data/app/views/spree/admin/orders/_add_product.html.erb +12 -0
  274. data/app/views/spree/admin/orders/_adjustments.html.erb +19 -0
  275. data/app/views/spree/admin/orders/_carton.html.erb +97 -0
  276. data/app/views/spree/admin/orders/_carton_manifest.html.erb +23 -0
  277. data/app/views/spree/admin/orders/_form.html.erb +19 -0
  278. data/app/views/spree/admin/orders/_line_items.html.erb +24 -0
  279. data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +13 -0
  280. data/app/views/spree/admin/orders/_order_details.html.erb +32 -0
  281. data/app/views/spree/admin/orders/_risk_analysis.html.erb +50 -0
  282. data/app/views/spree/admin/orders/_shipment.html.erb +68 -0
  283. data/app/views/spree/admin/orders/_shipment_manifest.html.erb +32 -0
  284. data/app/views/spree/admin/orders/cart.html.erb +27 -0
  285. data/app/views/spree/admin/orders/confirm/_customer_details.html.erb +26 -0
  286. data/app/views/spree/admin/orders/confirm/_line_items.html.erb +33 -0
  287. data/app/views/spree/admin/orders/confirm/_payments.html.erb +41 -0
  288. data/app/views/spree/admin/orders/confirm/_shipment.html.erb +56 -0
  289. data/app/views/spree/admin/orders/confirm/_shipment_manifest.html.erb +22 -0
  290. data/app/views/spree/admin/orders/confirm.html.erb +60 -0
  291. data/app/views/spree/admin/orders/confirm_advance.html.erb +11 -0
  292. data/app/views/spree/admin/orders/customer_details/_form.html.erb +85 -0
  293. data/app/views/spree/admin/orders/customer_details/edit.html.erb +22 -0
  294. data/app/views/spree/admin/orders/customer_details/show.html.erb +27 -0
  295. data/app/views/spree/admin/orders/edit.html.erb +35 -0
  296. data/app/views/spree/admin/orders/index.html.erb +199 -0
  297. data/app/views/spree/admin/payment_methods/_form.html.erb +74 -0
  298. data/app/views/spree/admin/payment_methods/edit.html.erb +21 -0
  299. data/app/views/spree/admin/payment_methods/index.html.erb +69 -0
  300. data/app/views/spree/admin/payment_methods/new.html.erb +21 -0
  301. data/app/views/spree/admin/payments/_capture_events.html.erb +19 -0
  302. data/app/views/spree/admin/payments/_form.html.erb +38 -0
  303. data/app/views/spree/admin/payments/_list.html.erb +73 -0
  304. data/app/views/spree/admin/payments/credit.html.erb +18 -0
  305. data/app/views/spree/admin/payments/index.html.erb +33 -0
  306. data/app/views/spree/admin/payments/new.html.erb +25 -0
  307. data/app/views/spree/admin/payments/show.html.erb +22 -0
  308. data/app/views/spree/admin/payments/source_forms/_check.html.erb +0 -0
  309. data/app/views/spree/admin/payments/source_forms/_gateway.html.erb +57 -0
  310. data/app/views/spree/admin/payments/source_forms/_storecredit.html.erb +1 -0
  311. data/app/views/spree/admin/payments/source_views/_check.html.erb +0 -0
  312. data/app/views/spree/admin/payments/source_views/_gateway.html.erb +24 -0
  313. data/app/views/spree/admin/payments/source_views/_storecredit.html.erb +28 -0
  314. data/app/views/spree/admin/prices/_form.html.erb +36 -0
  315. data/app/views/spree/admin/prices/_master_variant_table.html.erb +41 -0
  316. data/app/views/spree/admin/prices/_table.html.erb +37 -0
  317. data/app/views/spree/admin/prices/edit.html.erb +14 -0
  318. data/app/views/spree/admin/prices/index.html.erb +76 -0
  319. data/app/views/spree/admin/prices/new.html.erb +11 -0
  320. data/app/views/spree/admin/product_properties/_product_property_fields.html.erb +19 -0
  321. data/app/views/spree/admin/product_properties/index.html.erb +96 -0
  322. data/app/views/spree/admin/products/_form.html.erb +195 -0
  323. data/app/views/spree/admin/products/edit.html.erb +21 -0
  324. data/app/views/spree/admin/products/index.html.erb +101 -0
  325. data/app/views/spree/admin/products/new.html.erb +14 -0
  326. data/app/views/spree/admin/promotion_actions/create.js.erb +10 -0
  327. data/app/views/spree/admin/promotion_actions/destroy.js.erb +1 -0
  328. data/app/views/spree/admin/promotion_categories/_form.html.erb +14 -0
  329. data/app/views/spree/admin/promotion_categories/edit.html.erb +11 -0
  330. data/app/views/spree/admin/promotion_categories/index.html.erb +48 -0
  331. data/app/views/spree/admin/promotion_categories/new.html.erb +11 -0
  332. data/app/views/spree/admin/promotion_code_batches/download.csv.ruby +8 -0
  333. data/app/views/spree/admin/promotion_code_batches/index.html.erb +65 -0
  334. data/app/views/spree/admin/promotion_code_batches/new.html.erb +28 -0
  335. data/app/views/spree/admin/promotion_codes/index.csv.ruby +8 -0
  336. data/app/views/spree/admin/promotion_codes/index.html.erb +28 -0
  337. data/app/views/spree/admin/promotion_rules/create.js.erb +8 -0
  338. data/app/views/spree/admin/promotion_rules/destroy.js.erb +3 -0
  339. data/app/views/spree/admin/promotions/_actions.html.erb +36 -0
  340. data/app/views/spree/admin/promotions/_activations_edit.html.erb +22 -0
  341. data/app/views/spree/admin/promotions/_activations_new.html.erb +58 -0
  342. data/app/views/spree/admin/promotions/_form.html.erb +67 -0
  343. data/app/views/spree/admin/promotions/_promotion_action.html.erb +13 -0
  344. data/app/views/spree/admin/promotions/_promotion_rule.html.erb +12 -0
  345. data/app/views/spree/admin/promotions/_rules.html.erb +51 -0
  346. data/app/views/spree/admin/promotions/actions/_create_adjustment.html.erb +2 -0
  347. data/app/views/spree/admin/promotions/actions/_create_item_adjustments.html.erb +6 -0
  348. data/app/views/spree/admin/promotions/actions/_create_quantity_adjustments.html.erb +11 -0
  349. data/app/views/spree/admin/promotions/actions/_free_shipping.html.erb +0 -0
  350. data/app/views/spree/admin/promotions/actions/_promotion_calculators_with_custom_fields.html.erb +29 -0
  351. data/app/views/spree/admin/promotions/calculators/_default_fields.html.erb +6 -0
  352. data/app/views/spree/admin/promotions/calculators/distributed_amount/_fields.html.erb +56 -0
  353. data/app/views/spree/admin/promotions/calculators/flat_rate/_fields.html.erb +6 -0
  354. data/app/views/spree/admin/promotions/calculators/tiered_flat_rate/_fields.html.erb +30 -0
  355. data/app/views/spree/admin/promotions/calculators/tiered_percent/_fields.html.erb +30 -0
  356. data/app/views/spree/admin/promotions/edit.html.erb +33 -0
  357. data/app/views/spree/admin/promotions/index.html.erb +118 -0
  358. data/app/views/spree/admin/promotions/new.html.erb +9 -0
  359. data/app/views/spree/admin/promotions/rules/_first_order.html.erb +0 -0
  360. data/app/views/spree/admin/promotions/rules/_first_repeat_purchase_since.html.erb +13 -0
  361. data/app/views/spree/admin/promotions/rules/_item_total.html.erb +14 -0
  362. data/app/views/spree/admin/promotions/rules/_nth_order.html.erb +12 -0
  363. data/app/views/spree/admin/promotions/rules/_one_use_per_user.html.erb +0 -0
  364. data/app/views/spree/admin/promotions/rules/_option_value.html.erb +13 -0
  365. data/app/views/spree/admin/promotions/rules/_product.html.erb +15 -0
  366. data/app/views/spree/admin/promotions/rules/_store.html.erb +6 -0
  367. data/app/views/spree/admin/promotions/rules/_taxon.html.erb +9 -0
  368. data/app/views/spree/admin/promotions/rules/_user.html.erb +4 -0
  369. data/app/views/spree/admin/promotions/rules/_user_logged_in.html.erb +0 -0
  370. data/app/views/spree/admin/promotions/rules/_user_role.html.erb +12 -0
  371. data/app/views/spree/admin/properties/_form.html.erb +16 -0
  372. data/app/views/spree/admin/properties/edit.html.erb +13 -0
  373. data/app/views/spree/admin/properties/filtered.html.erb +1 -0
  374. data/app/views/spree/admin/properties/index.html.erb +85 -0
  375. data/app/views/spree/admin/properties/new.html.erb +11 -0
  376. data/app/views/spree/admin/properties/new.js.erb +2 -0
  377. data/app/views/spree/admin/refund_reasons/edit.html.erb +18 -0
  378. data/app/views/spree/admin/refund_reasons/index.html.erb +58 -0
  379. data/app/views/spree/admin/refund_reasons/new.html.erb +19 -0
  380. data/app/views/spree/admin/refund_reasons/shared/_form.html.erb +20 -0
  381. data/app/views/spree/admin/refunds/edit.html.erb +29 -0
  382. data/app/views/spree/admin/refunds/new.html.erb +42 -0
  383. data/app/views/spree/admin/reimbursement_types/index.html.erb +27 -0
  384. data/app/views/spree/admin/reimbursements/edit.html.erb +106 -0
  385. data/app/views/spree/admin/reimbursements/index.html.erb +37 -0
  386. data/app/views/spree/admin/reimbursements/show.html.erb +93 -0
  387. data/app/views/spree/admin/return_authorizations/_form.html.erb +93 -0
  388. data/app/views/spree/admin/return_authorizations/edit.html.erb +35 -0
  389. data/app/views/spree/admin/return_authorizations/index.html.erb +57 -0
  390. data/app/views/spree/admin/return_authorizations/new.html.erb +20 -0
  391. data/app/views/spree/admin/return_reasons/edit.html.erb +5 -0
  392. data/app/views/spree/admin/return_reasons/index.html.erb +7 -0
  393. data/app/views/spree/admin/return_reasons/new.html.erb +6 -0
  394. data/app/views/spree/admin/search/products.json.jbuilder +12 -0
  395. data/app/views/spree/admin/search/users.json.jbuilder +39 -0
  396. data/app/views/spree/admin/shared/_address.html.erb +8 -0
  397. data/app/views/spree/admin/shared/_address_form.html.erb +64 -0
  398. data/app/views/spree/admin/shared/_calculator_fields.html.erb +23 -0
  399. data/app/views/spree/admin/shared/_configuration_menu.html.erb +12 -0
  400. data/app/views/spree/admin/shared/_datepicker.html.erb +8 -0
  401. data/app/views/spree/admin/shared/_destroy.js.erb +4 -0
  402. data/app/views/spree/admin/shared/_edit_resource_links.html.erb +4 -0
  403. data/app/views/spree/admin/shared/_flash.html.erb +11 -0
  404. data/app/views/spree/admin/shared/_general_tabs.html.erb +2 -0
  405. data/app/views/spree/admin/shared/_head.html.erb +56 -0
  406. data/app/views/spree/admin/shared/_header.html.erb +9 -0
  407. data/app/views/spree/admin/shared/_image.html.erb +7 -0
  408. data/app/views/spree/admin/shared/_js_locale_data.html.erb +39 -0
  409. data/app/views/spree/admin/shared/_locale_selection.html.erb +15 -0
  410. data/app/views/spree/admin/shared/_menu.html.erb +5 -0
  411. data/app/views/spree/admin/shared/_modal.html.erb +18 -0
  412. data/app/views/spree/admin/shared/_navigation.html.erb +10 -0
  413. data/app/views/spree/admin/shared/_navigation_footer.html.erb +40 -0
  414. data/app/views/spree/admin/shared/_navigation_header.html.erb +5 -0
  415. data/app/views/spree/admin/shared/_new_resource_links.html.erb +4 -0
  416. data/app/views/spree/admin/shared/_no_objects_found.html.erb +4 -0
  417. data/app/views/spree/admin/shared/_number_with_currency.html.erb +20 -0
  418. data/app/views/spree/admin/shared/_order_submenu.html.erb +63 -0
  419. data/app/views/spree/admin/shared/_order_summary.html.erb +69 -0
  420. data/app/views/spree/admin/shared/_order_tabs.html.erb +15 -0
  421. data/app/views/spree/admin/shared/_payments_tabs.html.erb +9 -0
  422. data/app/views/spree/admin/shared/_product_sub_menu.html.erb +17 -0
  423. data/app/views/spree/admin/shared/_product_tabs.html.erb +27 -0
  424. data/app/views/spree/admin/shared/_promotion_sub_menu.html.erb +8 -0
  425. data/app/views/spree/admin/shared/_rebuild_vat_prices_checkbox.html.erb +12 -0
  426. data/app/views/spree/admin/shared/_refunds.html.erb +32 -0
  427. data/app/views/spree/admin/shared/_settings_checkout_tabs.html.erb +21 -0
  428. data/app/views/spree/admin/shared/_settings_sub_menu.html.erb +26 -0
  429. data/app/views/spree/admin/shared/_shipping_tabs.html.erb +18 -0
  430. data/app/views/spree/admin/shared/_sidebar.html.erb +10 -0
  431. data/app/views/spree/admin/shared/_spinner.html.erb +6 -0
  432. data/app/views/spree/admin/shared/_table_filter.html.erb +8 -0
  433. data/app/views/spree/admin/shared/_tabs.html.erb +14 -0
  434. data/app/views/spree/admin/shared/_taxes_tabs.html.erb +13 -0
  435. data/app/views/spree/admin/shared/_variant_search.html.erb +26 -0
  436. data/app/views/spree/admin/shared/named_types/_edit.html.erb +19 -0
  437. data/app/views/spree/admin/shared/named_types/_form.html.erb +14 -0
  438. data/app/views/spree/admin/shared/named_types/_index.html.erb +58 -0
  439. data/app/views/spree/admin/shared/named_types/_new.html.erb +19 -0
  440. data/app/views/spree/admin/shared/preference_fields/_boolean.html.erb +14 -0
  441. data/app/views/spree/admin/shared/preference_fields/_decimal.html.erb +12 -0
  442. data/app/views/spree/admin/shared/preference_fields/_integer.html.erb +12 -0
  443. data/app/views/spree/admin/shared/preference_fields/_password.html.erb +12 -0
  444. data/app/views/spree/admin/shared/preference_fields/_string.html.erb +12 -0
  445. data/app/views/spree/admin/shared/preference_fields/_text.html.erb +12 -0
  446. data/app/views/spree/admin/shipping_categories/_form.html.erb +6 -0
  447. data/app/views/spree/admin/shipping_categories/edit.html.erb +19 -0
  448. data/app/views/spree/admin/shipping_categories/index.html.erb +51 -0
  449. data/app/views/spree/admin/shipping_categories/new.html.erb +19 -0
  450. data/app/views/spree/admin/shipping_methods/_form.html.erb +115 -0
  451. data/app/views/spree/admin/shipping_methods/edit.html.erb +28 -0
  452. data/app/views/spree/admin/shipping_methods/index.html.erb +60 -0
  453. data/app/views/spree/admin/shipping_methods/new.html.erb +28 -0
  454. data/app/views/spree/admin/stock_items/_stock_management.html.erb +107 -0
  455. data/app/views/spree/admin/stock_items/destroy.js.erb +1 -0
  456. data/app/views/spree/admin/stock_items/index.html.erb +27 -0
  457. data/app/views/spree/admin/stock_locations/_form.html.erb +134 -0
  458. data/app/views/spree/admin/stock_locations/edit.html.erb +26 -0
  459. data/app/views/spree/admin/stock_locations/index.html.erb +78 -0
  460. data/app/views/spree/admin/stock_locations/new.html.erb +17 -0
  461. data/app/views/spree/admin/stock_movements/index.html.erb +48 -0
  462. data/app/views/spree/admin/store_credits/_form.html.erb +25 -0
  463. data/app/views/spree/admin/store_credits/_update_reason_field.html.erb +7 -0
  464. data/app/views/spree/admin/store_credits/edit_amount.html.erb +32 -0
  465. data/app/views/spree/admin/store_credits/edit_validity.html.erb +26 -0
  466. data/app/views/spree/admin/store_credits/index.html.erb +75 -0
  467. data/app/views/spree/admin/store_credits/new.html.erb +18 -0
  468. data/app/views/spree/admin/store_credits/show.html.erb +106 -0
  469. data/app/views/spree/admin/stores/_form.html.erb +77 -0
  470. data/app/views/spree/admin/stores/edit.html.erb +19 -0
  471. data/app/views/spree/admin/stores/index.html.erb +41 -0
  472. data/app/views/spree/admin/stores/new.html.erb +15 -0
  473. data/app/views/spree/admin/style_guide/index.html.erb +5 -0
  474. data/app/views/spree/admin/style_guide/topics/components/_modals.html.erb +50 -0
  475. data/app/views/spree/admin/style_guide/topics/components/_pills.html.erb +101 -0
  476. data/app/views/spree/admin/style_guide/topics/components/_tabs.html.erb +17 -0
  477. data/app/views/spree/admin/style_guide/topics/forms/_building_forms.html.erb +81 -0
  478. data/app/views/spree/admin/style_guide/topics/forms/_buttons.html.erb +6 -0
  479. data/app/views/spree/admin/style_guide/topics/forms/_helper_text.html.erb +13 -0
  480. data/app/views/spree/admin/style_guide/topics/forms/_inputs.html.erb +96 -0
  481. data/app/views/spree/admin/style_guide/topics/forms/_labels.html.erb +6 -0
  482. data/app/views/spree/admin/style_guide/topics/forms/_validation.html.erb +21 -0
  483. data/app/views/spree/admin/style_guide/topics/layout/_full_width_table_layout.html.erb +10 -0
  484. data/app/views/spree/admin/style_guide/topics/layout/_helpful_layout.html.erb +0 -0
  485. data/app/views/spree/admin/style_guide/topics/layout/_sidebar_layout.html.erb +4 -0
  486. data/app/views/spree/admin/style_guide/topics/messaging/_flashes.html.erb +19 -0
  487. data/app/views/spree/admin/style_guide/topics/messaging/_loading.html.erb +30 -0
  488. data/app/views/spree/admin/style_guide/topics/messaging/_tooltips.html.erb +61 -0
  489. data/app/views/spree/admin/style_guide/topics/tables/_building_tables.html.erb +63 -0
  490. data/app/views/spree/admin/style_guide/topics/tables/_forms_in_tables.html.erb +4 -0
  491. data/app/views/spree/admin/style_guide/topics/tables/_pagination.html.erb +11 -0
  492. data/app/views/spree/admin/style_guide/topics/typography/_colors.html.erb +64 -0
  493. data/app/views/spree/admin/style_guide/topics/typography/_fonts.html.erb +19 -0
  494. data/app/views/spree/admin/style_guide/topics/typography/_icons.html.erb +13 -0
  495. data/app/views/spree/admin/style_guide/topics/typography/_lists.html.erb +25 -0
  496. data/app/views/spree/admin/tax_categories/_form.html.erb +31 -0
  497. data/app/views/spree/admin/tax_categories/edit.html.erb +19 -0
  498. data/app/views/spree/admin/tax_categories/index.html.erb +63 -0
  499. data/app/views/spree/admin/tax_categories/new.html.erb +20 -0
  500. data/app/views/spree/admin/tax_categories/show.html.erb +1 -0
  501. data/app/views/spree/admin/tax_rates/_form.html.erb +62 -0
  502. data/app/views/spree/admin/tax_rates/edit.html.erb +20 -0
  503. data/app/views/spree/admin/tax_rates/index.html.erb +77 -0
  504. data/app/views/spree/admin/tax_rates/new.html.erb +24 -0
  505. data/app/views/spree/admin/taxonomies/_form.html.erb +7 -0
  506. data/app/views/spree/admin/taxonomies/_list.html.erb +34 -0
  507. data/app/views/spree/admin/taxonomies/_taxon.html.erb +12 -0
  508. data/app/views/spree/admin/taxonomies/edit.html.erb +23 -0
  509. data/app/views/spree/admin/taxonomies/index.html.erb +23 -0
  510. data/app/views/spree/admin/taxonomies/new.html.erb +18 -0
  511. data/app/views/spree/admin/taxons/_form.html.erb +53 -0
  512. data/app/views/spree/admin/taxons/edit.html.erb +19 -0
  513. data/app/views/spree/admin/taxons/index.html.erb +16 -0
  514. data/app/views/spree/admin/taxons/search.json.jbuilder +7 -0
  515. data/app/views/spree/admin/users/_addresses_form.html.erb +21 -0
  516. data/app/views/spree/admin/users/_form.html.erb +78 -0
  517. data/app/views/spree/admin/users/_sidebar.html.erb +20 -0
  518. data/app/views/spree/admin/users/_tabs.html.erb +29 -0
  519. data/app/views/spree/admin/users/_user_page_actions.html.erb +7 -0
  520. data/app/views/spree/admin/users/addresses.html.erb +28 -0
  521. data/app/views/spree/admin/users/edit.html.erb +27 -0
  522. data/app/views/spree/admin/users/index.html.erb +101 -0
  523. data/app/views/spree/admin/users/items.html.erb +81 -0
  524. data/app/views/spree/admin/users/new.html.erb +16 -0
  525. data/app/views/spree/admin/users/orders.html.erb +82 -0
  526. data/app/views/spree/admin/variants/_form.html.erb +103 -0
  527. data/app/views/spree/admin/variants/_table.html.erb +48 -0
  528. data/app/views/spree/admin/variants/_table_filter.html.erb +29 -0
  529. data/app/views/spree/admin/variants/edit.html.erb +21 -0
  530. data/app/views/spree/admin/variants/index.html.erb +43 -0
  531. data/app/views/spree/admin/variants/new.html.erb +12 -0
  532. data/app/views/spree/admin/variants/update.js.erb +1 -0
  533. data/app/views/spree/admin/zones/_country_members.html.erb +10 -0
  534. data/app/views/spree/admin/zones/_form.html.erb +44 -0
  535. data/app/views/spree/admin/zones/_state_members.html.erb +10 -0
  536. data/app/views/spree/admin/zones/edit.html.erb +15 -0
  537. data/app/views/spree/admin/zones/index.html.erb +56 -0
  538. data/app/views/spree/admin/zones/new.html.erb +17 -0
  539. data/app/views/spree/layouts/admin.html.erb +27 -0
  540. data/app/views/spree/layouts/admin_style_guide.html.erb +58 -0
  541. data/config/initializers/assets.rb +3 -0
  542. data/config/initializers/form_builder.rb +22 -0
  543. data/config/routes.rb +190 -0
  544. data/lib/solidus_backend.rb +3 -0
  545. data/lib/spree/backend/action_callbacks.rb +27 -0
  546. data/lib/spree/backend/callbacks.rb +52 -0
  547. data/lib/spree/backend/engine.rb +13 -0
  548. data/lib/spree/backend.rb +18 -0
  549. data/lib/spree_backend.rb +3 -0
  550. data/script/rails +10 -0
  551. data/solidus_backend.gemspec +38 -0
  552. data/spec/controllers/spree/admin/base_controller_spec.rb +26 -0
  553. data/spec/controllers/spree/admin/cancellations_controller_spec.rb +79 -0
  554. data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +235 -0
  555. data/spec/controllers/spree/admin/missing_products_controller_spec.rb +18 -0
  556. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +80 -0
  557. data/spec/controllers/spree/admin/orders_controller_spec.rb +408 -0
  558. data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +95 -0
  559. data/spec/controllers/spree/admin/payments_controller_spec.rb +194 -0
  560. data/spec/controllers/spree/admin/prices_controller_spec.rb +45 -0
  561. data/spec/controllers/spree/admin/product_properties_controller_spec.rb +71 -0
  562. data/spec/controllers/spree/admin/products_controller_spec.rb +270 -0
  563. data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +23 -0
  564. data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +20 -0
  565. data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +36 -0
  566. data/spec/controllers/spree/admin/promotions_controller_spec.rb +122 -0
  567. data/spec/controllers/spree/admin/refunds_controller_spec.rb +35 -0
  568. data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +126 -0
  569. data/spec/controllers/spree/admin/resource_controller_spec.rb +168 -0
  570. data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +291 -0
  571. data/spec/controllers/spree/admin/return_items_controller_spec.rb +29 -0
  572. data/spec/controllers/spree/admin/root_controller_spec.rb +43 -0
  573. data/spec/controllers/spree/admin/search_controller_spec.rb +106 -0
  574. data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +16 -0
  575. data/spec/controllers/spree/admin/stock_items_controller_spec.rb +52 -0
  576. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +44 -0
  577. data/spec/controllers/spree/admin/store_credits_controller_spec.rb +311 -0
  578. data/spec/controllers/spree/admin/users_controller_spec.rb +249 -0
  579. data/spec/controllers/spree/admin/variants_controller_spec.rb +71 -0
  580. data/spec/features/admin/configuration/payment_methods_spec.rb +167 -0
  581. data/spec/features/admin/configuration/shipping_methods_spec.rb +114 -0
  582. data/spec/features/admin/configuration/stock_locations_spec.rb +54 -0
  583. data/spec/features/admin/configuration/store_spec.rb +62 -0
  584. data/spec/features/admin/configuration/tax_categories_spec.rb +58 -0
  585. data/spec/features/admin/configuration/tax_rates_spec.rb +31 -0
  586. data/spec/features/admin/configuration/taxonomies_spec.rb +54 -0
  587. data/spec/features/admin/configuration/zones_spec.rb +41 -0
  588. data/spec/features/admin/homepage_spec.rb +86 -0
  589. data/spec/features/admin/javascript_format_money_spec.rb +22 -0
  590. data/spec/features/admin/locale_spec.rb +35 -0
  591. data/spec/features/admin/orders/adjustments_promotions_spec.rb +55 -0
  592. data/spec/features/admin/orders/adjustments_spec.rb +130 -0
  593. data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +46 -0
  594. data/spec/features/admin/orders/cancelling_inventory_spec.rb +50 -0
  595. data/spec/features/admin/orders/customer_details_spec.rb +206 -0
  596. data/spec/features/admin/orders/line_items_spec.rb +52 -0
  597. data/spec/features/admin/orders/listing_spec.rb +191 -0
  598. data/spec/features/admin/orders/log_entries_spec.rb +56 -0
  599. data/spec/features/admin/orders/new_order_spec.rb +216 -0
  600. data/spec/features/admin/orders/order_details_spec.rb +572 -0
  601. data/spec/features/admin/orders/payments_spec.rb +289 -0
  602. data/spec/features/admin/orders/return_authorizations_spec.rb +27 -0
  603. data/spec/features/admin/orders/return_payment_state_spec.rb +62 -0
  604. data/spec/features/admin/orders/risk_analysis_spec.rb +49 -0
  605. data/spec/features/admin/orders/shipments_spec.rb +145 -0
  606. data/spec/features/admin/payments/store_credits_spec.rb +23 -0
  607. data/spec/features/admin/products/edit/images_spec.rb +76 -0
  608. data/spec/features/admin/products/edit/products_spec.rb +67 -0
  609. data/spec/features/admin/products/edit/taxons_spec.rb +47 -0
  610. data/spec/features/admin/products/edit/variants_spec.rb +63 -0
  611. data/spec/features/admin/products/option_types_spec.rb +116 -0
  612. data/spec/features/admin/products/pricing_spec.rb +109 -0
  613. data/spec/features/admin/products/products_spec.rb +336 -0
  614. data/spec/features/admin/products/properties_spec.rb +141 -0
  615. data/spec/features/admin/products/stock_management_spec.rb +84 -0
  616. data/spec/features/admin/products/variant_spec.rb +89 -0
  617. data/spec/features/admin/promotion_adjustments_spec.rb +277 -0
  618. data/spec/features/admin/promotions/option_value_rule_spec.rb +97 -0
  619. data/spec/features/admin/promotions/product_rule_spec.rb +35 -0
  620. data/spec/features/admin/promotions/promotion_categories_spec.rb +83 -0
  621. data/spec/features/admin/promotions/tiered_calculator_spec.rb +76 -0
  622. data/spec/features/admin/promotions/user_rule_spec.rb +44 -0
  623. data/spec/features/admin/reimbursements_spec.rb +18 -0
  624. data/spec/features/admin/store_credits_spec.rb +83 -0
  625. data/spec/features/admin/stores_spec.rb +37 -0
  626. data/spec/features/admin/style_guide_spec.rb +14 -0
  627. data/spec/features/admin/taxons_spec.rb +78 -0
  628. data/spec/features/admin/users_spec.rb +338 -0
  629. data/spec/helpers/admin/base_helper_spec.rb +49 -0
  630. data/spec/helpers/admin/navigation_helper_spec.rb +137 -0
  631. data/spec/helpers/admin/stock_movements_helper_spec.rb +29 -0
  632. data/spec/helpers/admin/store_credit_events_helper_spec.rb +97 -0
  633. data/spec/helpers/promotion_rules_helper_spec.rb +14 -0
  634. data/spec/javascripts/fixtures/_boot.html.erb +8 -0
  635. data/spec/javascripts/fixtures/number_with_currency/with_currency_select.html.erb +3 -0
  636. data/spec/javascripts/fixtures/number_with_currency/without_select.html.erb +3 -0
  637. data/spec/javascripts/format_money_spec.js +48 -0
  638. data/spec/javascripts/spec_helper.js +11 -0
  639. data/spec/javascripts/support/show_errors.js +8 -0
  640. data/spec/javascripts/support/with_translations.js +11 -0
  641. data/spec/javascripts/translation_spec.js +58 -0
  642. data/spec/javascripts/views/number_with_currency_spec.js +72 -0
  643. data/spec/spec_helper.rb +123 -0
  644. data/spec/support/appear_before_matcher.rb +10 -0
  645. data/spec/support/feature/base_feature_helper.rb +12 -0
  646. data/spec/support/feature/order_feature_helper.rb +27 -0
  647. data/spec/support/ror_ringer.jpeg +0 -0
  648. data/spec/teaspoon_env.rb +66 -0
  649. data/spec/test_views/spree/admin/widgets/edit.html.erb +1 -0
  650. data/spec/test_views/spree/admin/widgets/new.html.erb +1 -0
  651. data/spec/views/spree/admin/shared/navigation_footer_spec.rb +67 -0
  652. data/vendor/assets/images/solidus_admin/select2-spinner.gif +0 -0
  653. data/vendor/assets/images/solidus_admin/select2.png +0 -0
  654. data/vendor/assets/images/solidus_admin/select2x2.png +0 -0
  655. data/vendor/assets/javascripts/jquery.sticky-kit.min.js +10 -0
  656. data/vendor/assets/javascripts/prism.js +7 -0
  657. data/vendor/assets/javascripts/solidus_admin/Sortable.js +1540 -0
  658. data/vendor/assets/javascripts/solidus_admin/accounting.js +4 -0
  659. data/vendor/assets/javascripts/solidus_admin/backbone-nested-models.js +193 -0
  660. data/vendor/assets/javascripts/solidus_admin/backbone.js +1920 -0
  661. data/vendor/assets/javascripts/solidus_admin/bind-polyfill.js +28 -0
  662. data/vendor/assets/javascripts/solidus_admin/bootstrap.js +3893 -0
  663. data/vendor/assets/javascripts/solidus_admin/flatpickr/flatpickr.js +2218 -0
  664. data/vendor/assets/javascripts/solidus_admin/popover.js +4 -0
  665. data/vendor/assets/javascripts/solidus_admin/select2.js +3729 -0
  666. data/vendor/assets/javascripts/solidus_admin/select2_locales/index.js +1 -0
  667. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_ar.js +19 -0
  668. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_az.js +20 -0
  669. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_bg.js +20 -0
  670. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_ca.js +19 -0
  671. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_cs.js +51 -0
  672. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_da.js +19 -0
  673. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_de.js +18 -0
  674. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_el.js +19 -0
  675. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_en-US.js +10 -0
  676. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_es-MX.js +19 -0
  677. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_es.js +19 -0
  678. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_et.js +19 -0
  679. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_eu.js +45 -0
  680. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_fa.js +21 -0
  681. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_fi.js +30 -0
  682. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_fr.js +18 -0
  683. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_gl.js +45 -0
  684. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_he.js +19 -0
  685. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_hr.js +24 -0
  686. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_hu.js +17 -0
  687. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_id.js +21 -0
  688. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_is.js +17 -0
  689. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_it.js +17 -0
  690. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_ja.js +17 -0
  691. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_ka.js +19 -0
  692. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_ko.js +19 -0
  693. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_lt.js +26 -0
  694. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_lv.js +19 -0
  695. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_mk.js +19 -0
  696. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_ms.js +21 -0
  697. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_nb.js +22 -0
  698. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_nl.js +17 -0
  699. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_pl.js +54 -0
  700. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_pt-BR.js +18 -0
  701. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_pt-PT.js +17 -0
  702. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_ro.js +17 -0
  703. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_rs.js +19 -0
  704. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_ru.js +23 -0
  705. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_sk.js +50 -0
  706. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_sv.js +19 -0
  707. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_th.js +19 -0
  708. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_tr.js +20 -0
  709. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_ug-CN.js +16 -0
  710. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_uk.js +25 -0
  711. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_vi.js +20 -0
  712. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_zh-CN.js +16 -0
  713. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_zh-TW.js +16 -0
  714. data/vendor/assets/javascripts/solidus_admin/underscore.js +1548 -0
  715. data/vendor/assets/stylesheets/prism.css +139 -0
  716. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_alert.scss +51 -0
  717. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_badge.scss +47 -0
  718. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_breadcrumb.scss +38 -0
  719. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_button-group.scss +166 -0
  720. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_buttons.scss +143 -0
  721. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_card.scss +270 -0
  722. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_carousel.scss +191 -0
  723. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_close.scss +34 -0
  724. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_code.scss +56 -0
  725. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_custom-forms.scss +297 -0
  726. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_dropdown.scss +131 -0
  727. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_forms.scss +333 -0
  728. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_functions.scss +86 -0
  729. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_grid.scss +52 -0
  730. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_images.scss +42 -0
  731. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_input-group.scss +159 -0
  732. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_jumbotron.scss +16 -0
  733. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_list-group.scss +115 -0
  734. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_media.scss +8 -0
  735. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_mixins.scss +42 -0
  736. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_modal.scss +168 -0
  737. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_nav.scss +118 -0
  738. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_navbar.scss +311 -0
  739. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_pagination.scss +77 -0
  740. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_popover.scss +183 -0
  741. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_print.scss +124 -0
  742. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_progress.scss +33 -0
  743. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_reboot.scss +482 -0
  744. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_root.scss +19 -0
  745. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_tables.scss +180 -0
  746. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_tooltip.scss +115 -0
  747. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_transitions.scss +36 -0
  748. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_type.scss +125 -0
  749. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_utilities.scss +14 -0
  750. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_variables.scss +894 -0
  751. data/vendor/assets/stylesheets/solidus_admin/bootstrap/bootstrap-grid.scss +32 -0
  752. data/vendor/assets/stylesheets/solidus_admin/bootstrap/bootstrap-reboot.scss +12 -0
  753. data/vendor/assets/stylesheets/solidus_admin/bootstrap/bootstrap.scss +42 -0
  754. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_alert.scss +13 -0
  755. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_background-variant.scss +21 -0
  756. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_badge.scss +12 -0
  757. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_border-radius.scss +35 -0
  758. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_box-shadow.scss +5 -0
  759. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_breakpoints.scss +123 -0
  760. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_buttons.scss +109 -0
  761. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_caret.scss +65 -0
  762. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_clearfix.scss +7 -0
  763. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_float.scss +11 -0
  764. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_forms.scss +137 -0
  765. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_gradients.scss +45 -0
  766. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_grid-framework.scss +67 -0
  767. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_grid.scss +52 -0
  768. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_hover.scss +39 -0
  769. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_image.scss +36 -0
  770. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_list-group.scss +21 -0
  771. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_lists.scss +7 -0
  772. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_nav-divider.scss +10 -0
  773. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_navbar-align.scss +10 -0
  774. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_pagination.scss +22 -0
  775. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_reset-text.scss +17 -0
  776. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_resize.scss +6 -0
  777. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_screen-reader.scss +35 -0
  778. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_size.scss +6 -0
  779. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_table-row.scss +30 -0
  780. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_text-emphasis.scss +14 -0
  781. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_text-hide.scss +9 -0
  782. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_text-truncate.scss +8 -0
  783. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_transition.scss +9 -0
  784. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_visibility.scss +7 -0
  785. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_align.scss +8 -0
  786. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_background.scss +19 -0
  787. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_borders.scss +59 -0
  788. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_clearfix.scss +3 -0
  789. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_display.scss +38 -0
  790. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_embed.scss +52 -0
  791. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_flex.scss +46 -0
  792. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_float.scss +9 -0
  793. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_position.scss +36 -0
  794. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_screenreaders.scss +11 -0
  795. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_sizing.scss +12 -0
  796. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_spacing.scss +51 -0
  797. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_text.scss +52 -0
  798. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_visibility.scss +11 -0
  799. data/vendor/assets/stylesheets/solidus_admin/flatpickr/flatpickr.css +857 -0
  800. data/vendor/assets/stylesheets/solidus_admin/select2.scss +692 -0
  801. metadata +998 -0
@@ -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
+ })));