@justifi/webcomponents 5.7.6-rc-21 → 5.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{Api-CPuq_15r.js → Api-DLhABIj9.js} +2 -2
- package/dist/cjs/Checkout-BbhldGDh.js +103 -0
- package/dist/cjs/{ComponentError-D4OLnOkg.js → ComponentError-C4MdBBMe.js} +0 -10
- package/dist/cjs/Payment-D6XuQ4Ve.js +151 -0
- package/dist/cjs/{Refund-CqWNG8sx.js → Refund-1bG6RRPO.js} +1 -245
- package/dist/cjs/additional-questions-details_5.cjs.entry.js +3 -4
- package/dist/cjs/{badge-CMmPvqtE.js → badge-CcJ9H85-.js} +1 -1
- package/dist/cjs/bank-account-document-form-inputs_4.cjs.entry.js +14 -13
- package/dist/cjs/bank-account-form_9.cjs.entry.js +544 -0
- package/dist/cjs/business-details-core.cjs.entry.js +4 -4
- package/dist/cjs/{business.service-C3BdUPlm.js → business.service-CaCyLLFW.js} +5 -3
- package/dist/cjs/{button-CfVQSysQ.js → button-DsHDMHaa.js} +1 -1
- package/dist/cjs/{check-pkg-version-BzCIWkkG.js → check-pkg-version-D6Kztnv7.js} +6 -4
- package/dist/cjs/{checkout.service-B0ZmvWwI.js → checkout.service-DgD37tJv.js} +5 -3
- package/dist/cjs/checkouts-list-core.cjs.entry.js +14 -13
- package/dist/cjs/{payments-list-params-state-BNbT1fuJ.js → checkouts-list-params-state-Cewmin_p.js} +1 -1
- package/dist/cjs/{checkouts-table-UN5gPpQ_.js → checkouts-table-Bzpqcsu0.js} +3 -3
- package/dist/cjs/{config-state-5xZf-jax.js → config-state-BBOZIS8x.js} +1 -1
- package/dist/cjs/{custom-popper_2.cjs.entry.js → custom-popper.cjs.entry.js} +3 -23
- package/dist/cjs/{dispute.service-DsPEAcDn.js → dispute.service-C0w_4Agq.js} +5 -3
- package/dist/cjs/form-alert_5.cjs.entry.js +5 -5
- package/dist/cjs/form-control-checkbox.cjs.entry.js +5 -5
- package/dist/cjs/form-control-date.cjs.entry.js +4 -4
- package/dist/cjs/{form-control-error-text-HM0zQerh.js → form-control-error-text-B-P5UDhm.js} +1 -1
- package/dist/cjs/form-control-file-v2_2.cjs.entry.js +5 -5
- package/dist/cjs/{form-control-help-text-5KIUw1IP.js → form-control-help-text-JoZjhb9m.js} +1 -1
- package/dist/cjs/form-control-help-text.cjs.entry.js +1 -1
- package/dist/cjs/form-control-monetary-provisioning.cjs.entry.js +5 -5
- package/dist/cjs/form-control-monetary.cjs.entry.js +6 -7
- package/dist/cjs/form-control-number-masked_2.cjs.entry.js +5 -5
- package/dist/cjs/form-control-number.cjs.entry.js +5 -5
- package/dist/cjs/form-control-radio.cjs.entry.js +3 -3
- package/dist/cjs/{form-control-select_2.cjs.entry.js → form-control-select_3.cjs.entry.js} +25 -6
- package/dist/cjs/{get-business-o5jPq_ME.js → get-business-BJrtsomz.js} +2 -2
- package/dist/cjs/{get-payment-details-DtCXaIMx.js → get-payment-details-BbfnopoD.js} +8 -6
- package/dist/cjs/{get-payout-csv-DE_D9y08.js → get-payout-csv-CXEQkjDm.js} +2 -2
- package/dist/cjs/{get-subaccounts-CwCH5rC8.js → get-subaccounts-CpCJjnYt.js} +8 -6
- package/dist/cjs/gross-payment-chart-core.cjs.entry.js +5 -6
- package/dist/cjs/{header-1-DD41iNlG.js → header-1-DRA3f4Jh.js} +1 -1
- package/dist/cjs/{header-3-D9Wa0IfT.js → header-3-sOdOpfx3.js} +1 -1
- package/dist/cjs/iframe-input-styles-state-DH-5a2Mg.js +26 -0
- package/dist/cjs/{hidden-input_2.cjs.entry.js → iframe-input_4.cjs.entry.js} +154 -112
- package/dist/cjs/{index-Yd9aLenr.js → index-B32W0A3m.js} +1 -1
- package/dist/cjs/{index-dm_GlYlb.js → index-C9hBD-32.js} +2 -2
- package/dist/cjs/{insurance-state-Cyva9u6S.js → insurance-state-e44s1lUQ.js} +2 -20
- package/dist/cjs/justifi-additional-questions-form-step-core_6.cjs.entry.js +10 -9
- package/dist/cjs/justifi-additional-questions-form-step_9.cjs.entry.js +22 -21
- package/dist/cjs/justifi-additional-statement_8.cjs.entry.js +9 -9
- package/dist/cjs/justifi-business-details.cjs.entry.js +16 -15
- package/dist/cjs/justifi-business-form.cjs.entry.js +18 -17
- package/dist/cjs/justifi-business-representative-form-inputs.cjs.entry.js +2 -2
- package/dist/cjs/justifi-checkout-core.cjs.entry.js +141 -0
- package/dist/cjs/justifi-checkout.cjs.entry.js +99 -91
- package/dist/cjs/justifi-checkouts-list-filters.cjs.entry.js +17 -16
- package/dist/cjs/justifi-checkouts-list.cjs.entry.js +19 -18
- package/dist/cjs/justifi-config-provider.cjs.entry.js +3 -3
- package/dist/cjs/justifi-details.cjs.entry.js +2 -2
- package/dist/cjs/justifi-dispute-management-core.cjs.entry.js +2 -2
- package/dist/cjs/justifi-dispute-management.cjs.entry.js +14 -13
- package/dist/cjs/justifi-dispute-notification_3.cjs.entry.js +20 -19
- package/dist/cjs/justifi-gross-payment-chart.cjs.entry.js +13 -12
- package/dist/cjs/justifi-order-terminals.cjs.entry.js +18 -17
- package/dist/cjs/justifi-owner-form_3.cjs.entry.js +17 -16
- package/dist/cjs/justifi-payment-details.cjs.entry.js +16 -15
- package/dist/cjs/justifi-payment-provisioning-core.cjs.entry.js +5 -5
- package/dist/cjs/justifi-payment-provisioning.cjs.entry.js +15 -14
- package/dist/cjs/justifi-payment-transactions-list.cjs.entry.js +17 -16
- package/dist/cjs/justifi-payments-list-filters.cjs.entry.js +7 -8
- package/dist/cjs/justifi-payments-list.cjs.entry.js +19 -18
- package/dist/cjs/justifi-payout-details.cjs.entry.js +15 -14
- package/dist/cjs/justifi-payout-transactions-list.cjs.entry.js +17 -16
- package/dist/cjs/justifi-payouts-list-filters.cjs.entry.js +7 -8
- package/dist/cjs/justifi-payouts-list.cjs.entry.js +20 -19
- package/dist/cjs/justifi-refund-payment.cjs.entry.js +17 -16
- package/dist/cjs/justifi-season-interruption-insurance-core.cjs.entry.js +124 -0
- package/dist/cjs/justifi-season-interruption-insurance.cjs.entry.js +21 -118
- package/dist/cjs/justifi-terminal-orders-list-filters.cjs.entry.js +12 -11
- package/dist/cjs/justifi-terminal-orders-list.cjs.entry.js +16 -15
- package/dist/cjs/justifi-terminals-list-filters.cjs.entry.js +11 -10
- package/dist/cjs/justifi-terminals-list.cjs.entry.js +18 -17
- package/dist/cjs/justifi-tokenize-payment-method.cjs.entry.js +80 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{package-B9ks67gS.js → package-C0-LCfay.js} +1 -1
- package/dist/cjs/pagination-menu.cjs.entry.js +1 -1
- package/dist/cjs/payment-details-core.cjs.entry.js +15 -16
- package/dist/cjs/{payment-provisioning-actions-CZVlnRA0.js → payment-provisioning-actions-BkWSDJQQ.js} +2 -2
- package/dist/cjs/{payment.service-1H0VC3LV.js → payment.service-CtSdIJoy.js} +5 -3
- package/dist/cjs/payments-list-core.cjs.entry.js +15 -14
- package/dist/cjs/{payouts-list-params-state-BNbT1fuJ.js → payments-list-params-state-Cewmin_p.js} +1 -1
- package/dist/cjs/{payments-status-PB63klt3.js → payments-status-DXRh_ekP.js} +2 -2
- package/dist/cjs/{payments-table-quF0NnsS.js → payments-table-CUGE6F-R.js} +3 -3
- package/dist/cjs/payout-details-core.cjs.entry.js +11 -12
- package/dist/cjs/{payout.service-CIZFU-hV.js → payout.service-7DP6F8x7.js} +5 -3
- package/dist/cjs/payouts-list-core.cjs.entry.js +15 -14
- package/dist/cjs/{terminal-orders-list-params-state-BNbT1fuJ.js → payouts-list-params-state-Cewmin_p.js} +1 -1
- package/dist/cjs/{payouts-status-Bk1JFzbP.js → payouts-status-DxTQZv3i.js} +2 -2
- package/dist/cjs/{payouts-table-D_CCTR_k.js → payouts-table-Ca9HqjV7.js} +3 -3
- package/dist/cjs/{skeleton-x-GSs3xk.js → skeleton-C7DQRD6r.js} +1 -1
- package/dist/cjs/{spinner-Kb1BFvnL.js → spinner-jmeA44Ee.js} +1 -1
- package/dist/cjs/{styled-host-CqQYxX-w.js → styled-host-BfVJlAsJ.js} +1 -1
- package/dist/cjs/{table-BJVUhh3s.js → table-Ccdrt0v_.js} +2 -2
- package/dist/cjs/table-filters-menu.cjs.entry.js +3 -3
- package/dist/cjs/terminal-orders-list-core.cjs.entry.js +14 -13
- package/dist/cjs/{checkouts-list-params-state-BNbT1fuJ.js → terminal-orders-list-params-state-Cewmin_p.js} +1 -1
- package/dist/cjs/{terminal-orders-table-0O5jtzYj.js → terminal-orders-table-DPe_2FNB.js} +8 -6
- package/dist/cjs/terminal-quantity-selector.cjs.entry.js +2 -2
- package/dist/cjs/{terminal.service-DUlyMTrX.js → terminal.service-BR9g1yaB.js} +5 -3
- package/dist/cjs/terminals-list-core.cjs.entry.js +14 -13
- package/dist/cjs/terminals-list-params-state-Cewmin_p.js +22 -0
- package/dist/cjs/{terminals-table-C2BNRUS5.js → terminals-table-DDoJIYZu.js} +3 -3
- package/dist/cjs/{utils-Df-pajL7.js → utils-Bzyj4qWe.js} +1 -1
- package/dist/cjs/{utils-BaGF9XIe.js → utils-Dewr6SlQ.js} +1667 -3
- package/dist/cjs/{utils-DvUQQLmR.js → utils-l0veqT9y.js} +1 -1
- package/dist/cjs/webcomponents.cjs.js +3 -3
- package/dist/collection/actions/checkout/checkout-actions.js +1 -2
- package/dist/collection/api/Checkout.js +3 -1
- package/dist/collection/api/ComponentError.js +0 -10
- package/dist/collection/collection-manifest.json +10 -16
- package/dist/collection/components/business-forms/business-form/additional-questions/additional-questions.js +1 -1
- package/dist/collection/components/business-forms/business-form/business-core-info/business-core-info.js +1 -1
- package/dist/collection/components/business-forms/business-form/business-representative/business-representative.js +1 -1
- package/dist/collection/components/business-forms/business-form/legal-address-form/legal-address-form.js +1 -1
- package/dist/collection/components/business-forms/owner-form/identity-address/identity-address-form.js +1 -1
- package/dist/collection/components/business-forms/owner-form/owner-form-core.js +1 -1
- package/dist/collection/components/business-forms/owner-form/owner-form-inputs.js +1 -1
- package/dist/collection/components/business-forms/owner-form/owner-form.js +1 -1
- package/dist/collection/components/business-forms/payment-provisioning/additional-questions/business-additional-questions-form-step.js +1 -1
- package/dist/collection/components/business-forms/payment-provisioning/bank-account/bank-account-document-inputs.js +1 -1
- package/dist/collection/components/business-forms/payment-provisioning/bank-account/bank-account-form-inputs.js +1 -1
- package/dist/collection/components/business-forms/payment-provisioning/bank-account/business-bank-account-form-step.js +1 -1
- package/dist/collection/components/business-forms/payment-provisioning/business-core-info/business-core-info-form-step.js +1 -1
- package/dist/collection/components/business-forms/payment-provisioning/business-owners/business-owners-form-step.js +1 -1
- package/dist/collection/components/business-forms/payment-provisioning/business-representative/business-representative-form-inputs.js +1 -1
- package/dist/collection/components/business-forms/payment-provisioning/business-representative/business-representative-form-step.js +1 -1
- package/dist/collection/components/business-forms/payment-provisioning/form-control-monetary-provisioning.js +2 -2
- package/dist/collection/components/business-forms/payment-provisioning/legal-address-form/legal-address-form-step.js +1 -1
- package/dist/collection/components/business-forms/payment-provisioning/payment-provisioning-core.js +1 -1
- package/dist/collection/components/business-forms/payment-provisioning/payment-provisioning-form-buttons.js +1 -1
- package/dist/collection/components/business-forms/payment-provisioning/payment-provisioning-form-steps.js +1 -1
- package/dist/collection/components/business-forms/payment-provisioning/payment-provisioning.js +1 -1
- package/dist/collection/components/business-forms/payment-provisioning/terms-and-conditions/business-terms-conditions-form-step.js +1 -1
- package/dist/collection/components/checkout/bank-account-form/bank-account-form.js +6 -3
- package/dist/collection/components/{modular-checkout/sub-components → checkout/billing-form}/bank-account-billing-form-simple.js +5 -7
- package/dist/collection/components/{modular-checkout/sub-components → checkout/billing-form}/billing-form-full.js +8 -12
- package/dist/collection/components/checkout/billing-form/billing-form-schema.js +3 -3
- package/dist/collection/components/{modular-checkout/sub-components → checkout/billing-form}/card-billing-form-simple.js +5 -7
- package/dist/collection/components/checkout/card-form/card-form.js +6 -3
- package/dist/collection/components/checkout/checkout-core.js +454 -0
- package/dist/collection/components/checkout/checkout.js +51 -156
- package/dist/collection/components/checkout/new-payment-method.js +378 -0
- package/dist/collection/components/checkout/payment-method-option-utils.js +1 -0
- package/dist/collection/components/checkout/payment-method-options.js +440 -0
- package/dist/collection/components/checkout/save-new-payment-method.js +5 -9
- package/dist/collection/components/checkout/saved-payment-method.js +1 -1
- package/dist/collection/components/checkout/sezzle-payment-method.js +240 -0
- package/dist/collection/components/checkouts-list/checkouts-list-core.js +1 -1
- package/dist/collection/components/checkouts-list/checkouts-list-filters.js +1 -1
- package/dist/collection/components/checkouts-list/checkouts-list.js +1 -1
- package/dist/collection/components/dispute-management/dispute-management-core.js +1 -1
- package/dist/collection/components/dispute-management/dispute-management.js +1 -1
- package/dist/collection/components/dispute-management/dispute-notification.js +1 -1
- package/dist/collection/components/dispute-management/dispute-response/additional-statement.js +1 -1
- package/dist/collection/components/dispute-management/dispute-response/cancellation-policy.js +1 -1
- package/dist/collection/components/dispute-management/dispute-response/customer-details.js +1 -1
- package/dist/collection/components/dispute-management/dispute-response/dispute-response-core.js +1 -1
- package/dist/collection/components/dispute-management/dispute-response/dispute-response.js +1 -1
- package/dist/collection/components/dispute-management/dispute-response/duplicate-charge.js +1 -1
- package/dist/collection/components/dispute-management/dispute-response/electronic-evidence.js +1 -1
- package/dist/collection/components/dispute-management/dispute-response/product-or-service.js +1 -1
- package/dist/collection/components/dispute-management/dispute-response/refund-policy.js +1 -1
- package/dist/collection/components/dispute-management/dispute-response/shipping-details.js +1 -1
- package/dist/collection/components/filters/table-filters-menu.js +1 -1
- package/dist/collection/components/gross-payment-chart/gross-payment-chart-core.js +1 -1
- package/dist/collection/components/insurance/insurance-state.js +1 -18
- package/dist/collection/components/insurance/season-interruption/season-interruption-insurance-core.js +447 -0
- package/dist/collection/components/insurance/season-interruption/season-interruption-insurance.js +12 -114
- package/dist/collection/components/order-terminals/order-terminals.js +1 -1
- package/dist/collection/components/order-terminals/terminal-quantity-selector/terminal-quantity-selector.js +1 -1
- package/dist/collection/components/payment-details/payment-details-core.js +8 -8
- package/dist/collection/components/payment-transactions-list/payment-transactions-list.js +1 -1
- package/dist/collection/components/payments-list/payments-list-core.js +1 -1
- package/dist/collection/components/payments-list/payments-list-filters.js +2 -2
- package/dist/collection/components/payments-list/payments-list.js +1 -1
- package/dist/collection/components/payout-details/payout-details-core.js +3 -3
- package/dist/collection/components/payout-transactions-list/payout-transactions-list.js +1 -1
- package/dist/collection/components/payouts-list/payouts-list-core.js +1 -1
- package/dist/collection/components/payouts-list/payouts-list-filters.js +2 -2
- package/dist/collection/components/payouts-list/payouts-list.js +1 -1
- package/dist/collection/components/terminal-orders-list/terminal-orders-list-core.js +1 -1
- package/dist/collection/components/terminal-orders-list/terminal-orders-list-filters.js +2 -2
- package/dist/collection/components/terminal-orders-list/terminal-orders-list.js +1 -1
- package/dist/collection/components/terminals-list/terminals-list-core.js +1 -1
- package/dist/collection/components/terminals-list/terminals-list-filters.js +1 -1
- package/dist/collection/components/terminals-list/terminals-list.js +1 -1
- package/dist/collection/components/tokenize-payment-method/tokenize-payment-method.js +83 -293
- package/dist/collection/ui-components/custom-popper/custom-popper.js +2 -2
- package/dist/collection/ui-components/form/form-control-checkbox.js +2 -2
- package/dist/collection/ui-components/form/form-control-date.js +2 -2
- package/dist/collection/ui-components/form/form-control-file-v2.js +1 -1
- package/dist/collection/ui-components/form/form-control-file.js +2 -2
- package/dist/collection/ui-components/form/form-control-monetary.js +2 -2
- package/dist/collection/ui-components/form/form-control-number-masked.js +2 -2
- package/dist/collection/ui-components/form/form-control-number.js +2 -2
- package/dist/collection/ui-components/form/form-control-radio.js +2 -2
- package/dist/collection/ui-components/form/form-control-select.js +2 -2
- package/dist/collection/ui-components/form/form-control-text.js +2 -2
- package/dist/collection/ui-components/form/form-control-textarea.js +2 -2
- package/dist/collection/ui-components/form/hidden-input.js +1 -1
- package/dist/collection/ui-components/form/iframe-input.js +5 -10
- package/dist/collection/ui-components/index.js +0 -1
- package/dist/collection/utils/utils.js +5 -0
- package/dist/docs.json +2822 -2308
- package/dist/esm/{Api-N_veT2p6.js → Api-BJv2_XdA.js} +2 -2
- package/dist/esm/Checkout-CIUkm9aQ.js +101 -0
- package/dist/esm/{ComponentError-Cjcsf8ku.js → ComponentError-SdntD1xf.js} +1 -11
- package/dist/esm/{Dispute-BH0Xfn-F.js → Dispute-7MWRbTXI.js} +1 -1
- package/dist/esm/Payment-DrCqUoz-.js +149 -0
- package/dist/esm/{Refund-Di6J0oN2.js → Refund-Dwnnpqim.js} +2 -244
- package/dist/esm/additional-questions-details_5.entry.js +4 -5
- package/dist/esm/{badge-D_mzXSCQ.js → badge-XXatxWS0.js} +2 -2
- package/dist/esm/bank-account-document-form-inputs_4.entry.js +16 -15
- package/dist/esm/bank-account-form_9.entry.js +534 -0
- package/dist/esm/business-details-core.entry.js +5 -5
- package/dist/esm/{business.service-Bdvhdc_d.js → business.service-Di9jP2_p.js} +6 -4
- package/dist/esm/{button-CeR8qVS3.js → button-C-ZZ9yD1.js} +2 -2
- package/dist/esm/{check-pkg-version-D3fhoIFS.js → check-pkg-version-8KHO3ihW.js} +7 -5
- package/dist/esm/{checkout.service-XgGFa7H8.js → checkout.service-l-H_OIZa.js} +6 -4
- package/dist/esm/checkouts-list-core.entry.js +16 -15
- package/dist/esm/{checkouts-list-params-state-SMXQIZTt.js → checkouts-list-params-state-D8tzsGR_.js} +1 -1
- package/dist/esm/{checkouts-table-CFZYoYjn.js → checkouts-table-DmwocPX2.js} +4 -4
- package/dist/esm/{config-state-BrllxiM0.js → config-state-DZeVYerv.js} +1 -1
- package/dist/esm/{custom-popper_2.entry.js → custom-popper.entry.js} +4 -23
- package/dist/esm/{dispute.service-CKPcmwhH.js → dispute.service-CaEbHFjw.js} +6 -4
- package/dist/esm/form-alert_5.entry.js +6 -6
- package/dist/esm/form-control-checkbox.entry.js +6 -6
- package/dist/esm/form-control-date.entry.js +5 -5
- package/dist/esm/{form-control-error-text-D3ZwkOv-.js → form-control-error-text-eKr_QuRZ.js} +2 -2
- package/dist/esm/form-control-file-v2_2.entry.js +6 -6
- package/dist/esm/{form-control-help-text-C39ZW65w.js → form-control-help-text-Dw2vjMQ5.js} +2 -2
- package/dist/esm/form-control-help-text.entry.js +1 -1
- package/dist/esm/form-control-monetary-provisioning.entry.js +6 -6
- package/dist/esm/form-control-monetary.entry.js +7 -8
- package/dist/esm/form-control-number-masked_2.entry.js +6 -6
- package/dist/esm/form-control-number.entry.js +6 -6
- package/dist/esm/form-control-radio.entry.js +4 -4
- package/dist/esm/{form-control-select_2.entry.js → form-control-select_3.entry.js} +26 -8
- package/dist/esm/{get-business-Crb6P-iI.js → get-business-GEPTefIj.js} +2 -2
- package/dist/esm/{get-payment-details-Dt-dr16k.js → get-payment-details-BOpjKcRB.js} +8 -6
- package/dist/esm/{get-payout-csv-D-Lnooki.js → get-payout-csv-D7IYYqVL.js} +2 -2
- package/dist/esm/{get-subaccounts-BsoVLANw.js → get-subaccounts-0Ri4RB5r.js} +9 -7
- package/dist/esm/gross-payment-chart-core.entry.js +6 -7
- package/dist/esm/{header-1-E-hEi3wF.js → header-1-BnwrlkS-.js} +2 -2
- package/dist/esm/{header-3-Dm7M85kz.js → header-3-IOnOCyak.js} +2 -2
- package/dist/esm/iframe-input-styles-state-Cqb62KAu.js +23 -0
- package/dist/esm/{hidden-input_2.entry.js → iframe-input_4.entry.js} +146 -106
- package/dist/esm/{index-B9me4yN2.js → index-B_KxSZIF.js} +1 -1
- package/dist/esm/{index-kpoIU4v_.js → index-Bn7inNWG.js} +2 -2
- package/dist/esm/insurance-state-DRFl0tWj.js +28 -0
- package/dist/esm/justifi-additional-questions-form-step-core_6.entry.js +12 -11
- package/dist/esm/justifi-additional-questions-form-step_9.entry.js +24 -23
- package/dist/esm/justifi-additional-statement_8.entry.js +10 -10
- package/dist/esm/justifi-business-details.entry.js +17 -16
- package/dist/esm/justifi-business-form.entry.js +20 -19
- package/dist/esm/justifi-business-representative-form-inputs.entry.js +3 -3
- package/dist/esm/justifi-checkout-core.entry.js +139 -0
- package/dist/esm/justifi-checkout.entry.js +99 -91
- package/dist/esm/justifi-checkouts-list-filters.entry.js +13 -12
- package/dist/esm/justifi-checkouts-list.entry.js +20 -19
- package/dist/esm/justifi-config-provider.entry.js +3 -3
- package/dist/esm/justifi-details.entry.js +3 -3
- package/dist/esm/justifi-dispute-management-core.entry.js +3 -3
- package/dist/esm/justifi-dispute-management.entry.js +15 -14
- package/dist/esm/justifi-dispute-notification_3.entry.js +21 -20
- package/dist/esm/justifi-gross-payment-chart.entry.js +15 -14
- package/dist/esm/justifi-order-terminals.entry.js +20 -19
- package/dist/esm/justifi-owner-form_3.entry.js +18 -17
- package/dist/esm/justifi-payment-details.entry.js +17 -16
- package/dist/esm/justifi-payment-provisioning-core.entry.js +6 -6
- package/dist/esm/justifi-payment-provisioning.entry.js +16 -15
- package/dist/esm/justifi-payment-transactions-list.entry.js +19 -18
- package/dist/esm/justifi-payments-list-filters.entry.js +8 -9
- package/dist/esm/justifi-payments-list.entry.js +20 -19
- package/dist/esm/justifi-payout-details.entry.js +17 -16
- package/dist/esm/justifi-payout-transactions-list.entry.js +19 -18
- package/dist/esm/justifi-payouts-list-filters.entry.js +8 -9
- package/dist/esm/justifi-payouts-list.entry.js +22 -21
- package/dist/esm/justifi-refund-payment.entry.js +19 -18
- package/dist/esm/justifi-season-interruption-insurance-core.entry.js +122 -0
- package/dist/esm/justifi-season-interruption-insurance.entry.js +22 -119
- package/dist/esm/justifi-terminal-orders-list-filters.entry.js +14 -13
- package/dist/esm/justifi-terminal-orders-list.entry.js +18 -17
- package/dist/esm/justifi-terminals-list-filters.entry.js +13 -12
- package/dist/esm/justifi-terminals-list.entry.js +20 -19
- package/dist/esm/justifi-tokenize-payment-method.entry.js +78 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{package-wutYt_7D.js → package-BOCuVjGs.js} +1 -1
- package/dist/esm/pagination-menu.entry.js +2 -2
- package/dist/esm/{parts-CfF8KKwx.js → parts-CVGBVdVC.js} +1 -1
- package/dist/esm/payment-details-core.entry.js +16 -17
- package/dist/esm/{payment-provisioning-actions-ONP8lDnV.js → payment-provisioning-actions-BIfyW239.js} +2 -2
- package/dist/esm/{payment.service-BWO84KlP.js → payment.service-Dz5mhgIm.js} +6 -4
- package/dist/esm/payments-list-core.entry.js +17 -16
- package/dist/esm/{payments-list-params-state-SMXQIZTt.js → payments-list-params-state-D8tzsGR_.js} +1 -1
- package/dist/esm/{payments-status-XoZrlbiZ.js → payments-status-CN8wEqKC.js} +2 -2
- package/dist/esm/{payments-table-Dh4P9mTb.js → payments-table-SmMgUr5X.js} +4 -4
- package/dist/esm/payout-details-core.entry.js +12 -13
- package/dist/esm/{payout.service-Cld6TS5W.js → payout.service-DUnRbCmv.js} +6 -4
- package/dist/esm/payouts-list-core.entry.js +17 -16
- package/dist/esm/{payouts-list-params-state-SMXQIZTt.js → payouts-list-params-state-D8tzsGR_.js} +1 -1
- package/dist/esm/{payouts-status-Qm2jZG1-.js → payouts-status-BzTh9X2W.js} +2 -2
- package/dist/esm/{payouts-table-DMVAZp-r.js → payouts-table-SB6q0e7V.js} +4 -4
- package/dist/esm/{skeleton-DrHwsgs_.js → skeleton-DK6mW457.js} +2 -2
- package/dist/esm/{spinner-XBq6mVJW.js → spinner-CWoD0q_S.js} +2 -2
- package/dist/esm/{styled-host-B_XBaM7z.js → styled-host-CTAGIN84.js} +1 -1
- package/dist/esm/{table-qqt2Ew5y.js → table-KCj3mM1K.js} +3 -3
- package/dist/esm/table-filters-menu.entry.js +4 -4
- package/dist/esm/terminal-orders-list-core.entry.js +16 -15
- package/dist/esm/{terminal-orders-list-params-state-SMXQIZTt.js → terminal-orders-list-params-state-D8tzsGR_.js} +1 -1
- package/dist/esm/{terminal-orders-table-BN4Co4T8.js → terminal-orders-table-CPsSDEWs.js} +10 -8
- package/dist/esm/terminal-quantity-selector.entry.js +3 -3
- package/dist/esm/{terminal.service-DmYCUQcA.js → terminal.service-Vhk3qPk2.js} +6 -4
- package/dist/esm/terminals-list-core.entry.js +16 -15
- package/dist/esm/terminals-list-params-state-D8tzsGR_.js +16 -0
- package/dist/esm/{terminals-table-C8LczeG_.js → terminals-table-CAavYaG5.js} +4 -4
- package/dist/esm/{utils-lb8p1Exq.js → utils-CKEiU2Q5.js} +1665 -3
- package/dist/esm/{utils-BeQLScSm.js → utils-Dccsn9BY.js} +1 -1
- package/dist/esm/{utils-kWaZhFAd.js → utils-_kzStVq_.js} +2 -2
- package/dist/esm/webcomponents.js +4 -4
- package/dist/module/Checkout.js +121 -0
- package/dist/module/Payment.js +204 -0
- package/dist/module/Refund.js +1 -328
- package/dist/module/additional-questions.js +1 -1
- package/dist/module/additional-statement.js +2 -2
- package/dist/module/badge.js +1 -1
- package/dist/module/bank-account-billing-form-simple.js +4 -9
- package/dist/module/bank-account-document-inputs.js +5 -3
- package/dist/module/bank-account-form-inputs2.js +1 -1
- package/dist/module/bank-account-form.js +1 -83
- package/dist/module/{bank-account.js → bank-account-form2.js} +11 -26
- package/dist/module/billing-form-full.js +11 -14
- package/dist/module/billing-form-schema.js +3 -3
- package/dist/module/business-additional-questions-form-step.js +2 -2
- package/dist/module/business-bank-account-form-step-core.js +4 -2
- package/dist/module/business-bank-account-form-step.js +5 -3
- package/dist/module/business-core-info-form-step.js +2 -2
- package/dist/module/business-core-info.js +1 -1
- package/dist/module/business-details-core2.js +0 -1
- package/dist/module/business-documents-on-file2.js +1 -2
- package/dist/module/business-owners-form-step-core.js +0 -1
- package/dist/module/business-owners-form-step.js +2 -2
- package/dist/module/business-representative-form-inputs.js +1 -1
- package/dist/module/business-representative-form-step.js +2 -2
- package/dist/module/business-representative.js +1 -1
- package/dist/module/business-terms-conditions-form-step.js +4 -2
- package/dist/module/business.service.js +3 -1
- package/dist/module/button.js +1 -1
- package/dist/module/cancellation-policy.js +2 -2
- package/dist/module/card-billing-form-simple.js +4 -9
- package/dist/module/card-form.js +1 -91
- package/dist/module/card-form2.js +13 -28
- package/dist/module/{Analytics.js → check-pkg-version.js} +24 -22
- package/dist/module/checkout-core.js +292 -0
- package/dist/module/checkout.service.js +3 -1
- package/dist/module/checkouts-list-core2.js +6 -6
- package/dist/module/custom-popper2.js +2 -2
- package/dist/module/customer-details.js +2 -2
- package/dist/module/dispute-management-core.js +2 -2
- package/dist/module/dispute-notification.js +2 -3
- package/dist/module/dispute-response-actions.js +3 -1
- package/dist/module/dispute-response-core.js +2 -2
- package/dist/module/dispute-response.js +3 -4
- package/dist/module/duplicate-charge.js +2 -2
- package/dist/module/electronic-evidence.js +2 -2
- package/dist/module/form-alert2.js +1 -1
- package/dist/module/form-control-checkbox2.js +3 -4
- package/dist/module/form-control-date2.js +2 -3
- package/dist/module/form-control-file-v22.js +1 -1
- package/dist/module/form-control-file2.js +2 -3
- package/dist/module/form-control-monetary-provisioning2.js +3 -4
- package/dist/module/form-control-monetary2.js +3 -4
- package/dist/module/form-control-number-masked2.js +2 -3
- package/dist/module/form-control-number.js +3 -4
- package/dist/module/form-control-radio2.js +3 -3
- package/dist/module/form-control-select2.js +2 -3
- package/dist/module/form-control-text2.js +2 -3
- package/dist/module/form-control-textarea2.js +3 -3
- package/dist/module/get-business.js +1 -1
- package/dist/module/get-payment-details.js +4 -2
- package/dist/module/get-payout-csv.js +1 -1
- package/dist/module/get-subaccounts.js +4 -2
- package/dist/module/gross-payment-chart-core2.js +2 -2
- package/dist/module/hidden-input2.js +2 -2
- package/dist/module/identity-address-form.js +1 -1
- package/dist/module/iframe-input2.js +6 -6
- package/dist/module/insurance-state.js +7 -18
- package/dist/module/justifi-business-details.js +2 -2
- package/dist/module/justifi-business-form.js +5 -4
- package/dist/module/{justifi-header.d.ts → justifi-checkout-core.d.ts} +4 -4
- package/dist/module/justifi-checkout-core.js +6 -0
- package/dist/module/justifi-checkout.js +137 -157
- package/dist/module/justifi-checkouts-list-filters.js +5 -4
- package/dist/module/justifi-checkouts-list.js +6 -5
- package/dist/module/justifi-dispute-management.js +4 -3
- package/dist/module/justifi-gross-payment-chart.js +4 -2
- package/dist/module/justifi-new-payment-method.d.ts +11 -0
- package/dist/module/justifi-new-payment-method.js +6 -0
- package/dist/module/justifi-order-terminals.js +7 -7
- package/dist/module/justifi-payment-details.js +2 -2
- package/dist/module/justifi-payment-method-options.d.ts +11 -0
- package/dist/module/justifi-payment-method-options.js +6 -0
- package/dist/module/justifi-payment-provisioning.js +5 -3
- package/dist/module/justifi-payment-transactions-list.js +7 -7
- package/dist/module/justifi-payments-list-filters.js +3 -4
- package/dist/module/justifi-payments-list.js +6 -5
- package/dist/module/justifi-payout-details.js +5 -3
- package/dist/module/justifi-payout-transactions-list.js +7 -7
- package/dist/module/justifi-payouts-list-filters.js +3 -4
- package/dist/module/justifi-payouts-list.js +6 -5
- package/dist/module/justifi-refund-payment.js +4 -3
- package/dist/module/justifi-saved-payment-method.js +1 -57
- package/dist/module/justifi-season-interruption-insurance-core.d.ts +11 -0
- package/dist/module/justifi-season-interruption-insurance-core.js +6 -0
- package/dist/module/justifi-season-interruption-insurance.js +24 -120
- package/dist/module/justifi-terminal-orders-list-filters.js +6 -5
- package/dist/module/justifi-terminal-orders-list.js +6 -5
- package/dist/module/justifi-terminals-list-filters.js +5 -4
- package/dist/module/justifi-terminals-list.js +6 -5
- package/dist/module/justifi-tokenize-payment-method.js +219 -1
- package/dist/module/legal-address-form-step.js +2 -2
- package/dist/module/legal-address-form.js +1 -1
- package/dist/module/new-payment-method.js +222 -0
- package/dist/module/owner-form-core2.js +2 -3
- package/dist/module/owner-form-inputs2.js +1 -1
- package/dist/module/owner-form.js +1 -1
- package/dist/module/package.js +3 -3
- package/dist/module/pagination-menu2.js +1 -1
- package/dist/module/parts.js +1 -1
- package/dist/module/payment-details-core2.js +9 -10
- package/dist/module/payment-method-options.js +237 -0
- package/dist/module/payment-provisioning-actions.js +1 -1
- package/dist/module/payment-provisioning-core.js +2 -3
- package/dist/module/payment-provisioning-form-buttons.js +1 -2
- package/dist/module/payment-provisioning-form-steps.js +1 -1
- package/dist/module/payment-provisioning-loading.js +0 -1
- package/dist/module/payment.service.js +3 -1
- package/dist/module/payments-list-core2.js +6 -6
- package/dist/module/payout-details-core2.js +4 -5
- package/dist/module/payout.service.js +3 -1
- package/dist/module/payouts-list-core2.js +6 -6
- package/dist/module/product-or-service.js +2 -2
- package/dist/module/refund-policy.js +2 -2
- package/dist/module/save-new-payment-method.js +6 -13
- package/dist/module/saved-payment-method.js +79 -0
- package/dist/module/season-interruption-insurance-core.js +168 -0
- package/dist/module/sezzle-payment-method.js +18 -25
- package/dist/module/shipping-details.js +2 -2
- package/dist/module/spinner.js +1 -1
- package/dist/module/table-filters-menu2.js +1 -1
- package/dist/module/table.js +1 -1
- package/dist/module/terminal-orders-list-core2.js +6 -6
- package/dist/module/terminal-quantity-selector2.js +2 -2
- package/dist/module/terminal.service.js +3 -1
- package/dist/module/terminals-list-core2.js +6 -6
- package/dist/module/utils2.js +1665 -3
- package/dist/module/utils4.js +1 -1
- package/dist/types/api/Checkout.d.ts +13 -15
- package/dist/types/api/ComponentError.d.ts +1 -10
- package/dist/types/components/checkout/bank-account-form/bank-account-form.d.ts +1 -0
- package/dist/types/components/{modular-checkout/sub-components → checkout/billing-form}/bank-account-billing-form-simple.d.ts +1 -1
- package/dist/types/components/{modular-checkout/sub-components → checkout/billing-form}/billing-form-full.d.ts +2 -1
- package/dist/types/components/checkout/billing-form/billing-form-schema.d.ts +4 -4
- package/dist/types/components/{modular-checkout/sub-components → checkout/billing-form}/card-billing-form-simple.d.ts +1 -1
- package/dist/types/components/checkout/card-form/card-form.d.ts +1 -0
- package/dist/types/components/checkout/checkout-core.d.ts +49 -0
- package/dist/types/components/checkout/checkout.d.ts +11 -27
- package/dist/types/components/checkout/new-payment-method.d.ts +31 -0
- package/dist/types/components/checkout/payment-method-options.d.ts +32 -0
- package/dist/types/components/checkout/save-new-payment-method.d.ts +1 -1
- package/dist/types/components/{modular-checkout/sub-components → checkout}/sezzle-payment-method.d.ts +9 -3
- package/dist/types/components/insurance/insurance-state.d.ts +1 -2
- package/dist/types/components/insurance/season-interruption/season-interruption-insurance-core.d.ts +32 -0
- package/dist/types/components/insurance/season-interruption/season-interruption-insurance.d.ts +3 -9
- package/dist/types/components/tokenize-payment-method/tokenize-payment-method.d.ts +15 -42
- package/dist/types/components.d.ts +219 -303
- package/dist/types/ui-components/form/iframe-input.d.ts +1 -2
- package/dist/types/ui-components/index.d.ts +0 -1
- package/dist/types/utils/utils.d.ts +1 -0
- package/dist/webcomponents/p-08e1bf28.entry.js +1 -0
- package/dist/webcomponents/p-09cb06ed.entry.js +1 -0
- package/dist/webcomponents/p-0adbbb23.entry.js +1 -0
- package/dist/webcomponents/p-0b067d3c.entry.js +1 -0
- package/dist/webcomponents/p-0bfd309e.entry.js +1 -0
- package/dist/webcomponents/p-0f005fdd.entry.js +1 -0
- package/dist/webcomponents/p-0nMw2Aul.js +1 -0
- package/dist/webcomponents/p-14dc17fd.entry.js +1 -0
- package/dist/webcomponents/p-266f1ff3.entry.js +1 -0
- package/dist/webcomponents/p-35387685.entry.js +1 -0
- package/dist/webcomponents/p-3946adfa.entry.js +1 -0
- package/dist/webcomponents/p-3c44b724.entry.js +1 -0
- package/dist/webcomponents/p-3e3b5cdb.entry.js +1 -0
- package/dist/webcomponents/p-41876098.entry.js +1 -0
- package/dist/webcomponents/p-45edf188.entry.js +1 -0
- package/dist/webcomponents/p-4786f2d0.entry.js +1 -0
- package/dist/webcomponents/p-4c1c55bb.entry.js +1 -0
- package/dist/webcomponents/p-4f358b63.entry.js +1 -0
- package/dist/webcomponents/p-5375df08.entry.js +1 -0
- package/dist/webcomponents/p-575b972d.entry.js +1 -0
- package/dist/webcomponents/p-580aa2e3.entry.js +1 -0
- package/dist/webcomponents/p-5b857a1c.entry.js +1 -0
- package/dist/webcomponents/p-5c9d1c35.entry.js +1 -0
- package/dist/webcomponents/p-690514f2.entry.js +1 -0
- package/dist/webcomponents/p-6a853571.entry.js +1 -0
- package/dist/webcomponents/p-724e4e6c.entry.js +1 -0
- package/dist/webcomponents/p-756a7021.entry.js +1 -0
- package/dist/webcomponents/{p-BH0Xfn-F.js → p-7MWRbTXI.js} +1 -1
- package/dist/webcomponents/{p-28c7bef7.entry.js → p-7a0661a2.entry.js} +4 -4
- package/dist/webcomponents/{p-a8205044.entry.js → p-80b6c011.entry.js} +1 -1
- package/dist/webcomponents/p-89431ee2.entry.js +1 -0
- package/dist/webcomponents/p-8f5c1ae6.entry.js +1 -0
- package/dist/webcomponents/{p-b0bfa20f.entry.js → p-96247d70.entry.js} +1 -1
- package/dist/webcomponents/p-989d56de.entry.js +1 -0
- package/dist/webcomponents/p-99f7a36d.entry.js +1 -0
- package/dist/webcomponents/p-BCgpQGhw.js +1 -0
- package/dist/webcomponents/p-BOCuVjGs.js +1 -0
- package/dist/webcomponents/p-BQ2TIFoY.js +1 -0
- package/dist/webcomponents/{p-YND5pTuF.js → p-BQQ7ifKz.js} +1 -1
- package/dist/webcomponents/{p-5aA7gjr5.js → p-BTS3E50C.js} +1 -1
- package/dist/webcomponents/p-BUSn_ReW.js +1 -0
- package/dist/webcomponents/p-BY1mRAvj.js +1 -0
- package/dist/webcomponents/p-BZtgbC0H.js +1 -0
- package/dist/webcomponents/p-B_t2t34m.js +1 -0
- package/dist/webcomponents/{p-kpoIU4v_.js → p-Bn7inNWG.js} +1 -1
- package/dist/webcomponents/{p-BisQ61nK.js → p-BpWSwi9x.js} +1 -1
- package/dist/webcomponents/p-Bs-84XY6.js +1 -0
- package/dist/webcomponents/{p-Dvxpy_P1.js → p-BtyEAd0R.js} +1 -1
- package/dist/webcomponents/p-BvXjypQm.js +1 -0
- package/dist/webcomponents/p-C-wMveZe.js +1 -0
- package/dist/webcomponents/{p-D2muobcE.js → p-C5RuuShs.js} +1 -1
- package/dist/webcomponents/p-CCl9g-ln.js +1 -0
- package/dist/webcomponents/p-CDPZXQAo.js +1 -0
- package/dist/webcomponents/p-CKEiU2Q5.js +1 -0
- package/dist/webcomponents/p-CS4_rnSp.js +1 -0
- package/dist/webcomponents/{p-CfF8KKwx.js → p-CVGBVdVC.js} +1 -1
- package/dist/webcomponents/p-CnMP2-Xk.js +1 -0
- package/dist/webcomponents/p-CpaS1Lex.js +1 -0
- package/dist/webcomponents/p-Cs0cIpIm.js +1 -0
- package/dist/webcomponents/p-CxHdQoIo.js +1 -0
- package/dist/webcomponents/p-DFWnHEN2.js +1 -0
- package/dist/webcomponents/{p-BbYVgLcf.js → p-DK0C7j0u.js} +1 -1
- package/dist/webcomponents/p-DKSNNnPC.js +1 -0
- package/dist/webcomponents/{p-BeszVz87.js → p-DV1c2IYS.js} +1 -1
- package/dist/webcomponents/{p-Bz164TKZ.js → p-DetWIU1e.js} +1 -1
- package/dist/webcomponents/{p-9y5MOK55.js → p-DhGNCW2f.js} +1 -1
- package/dist/webcomponents/p-DjFzWJxk.js +1 -0
- package/dist/webcomponents/p-DnGswpsl.js +1 -0
- package/dist/webcomponents/p-DniQ6yo6.js +1 -0
- package/dist/webcomponents/p-DsLxs70Z.js +1 -0
- package/dist/webcomponents/p-DsZZxRXY.js +1 -0
- package/dist/webcomponents/p-DtdcFDM_.js +1 -0
- package/dist/webcomponents/p-DwF36W04.js +1 -0
- package/dist/webcomponents/{p-CRFzwZW6.js → p-DxqCFDtF.js} +1 -1
- package/dist/webcomponents/p-L4y68wud.js +1 -0
- package/dist/webcomponents/p-SdntD1xf.js +1 -0
- package/dist/webcomponents/p-a09ca567.entry.js +1 -0
- package/dist/webcomponents/p-a3313ebe.entry.js +1 -0
- package/dist/webcomponents/{p-463ae23a.entry.js → p-abbf14b5.entry.js} +1 -1
- package/dist/webcomponents/p-aeaafe28.entry.js +1 -0
- package/dist/webcomponents/p-b25bbf0a.entry.js +1 -0
- package/dist/webcomponents/p-b7594923.entry.js +1 -0
- package/dist/webcomponents/p-b79e302a.entry.js +1 -0
- package/dist/webcomponents/p-ba268a78.entry.js +1 -0
- package/dist/webcomponents/p-ba68ea4f.entry.js +1 -0
- package/dist/webcomponents/{p-48bccf3b.entry.js → p-bcadc072.entry.js} +1 -1
- package/dist/webcomponents/p-bf0e00be.entry.js +1 -0
- package/dist/webcomponents/p-c15d8dd0.entry.js +1 -0
- package/dist/webcomponents/p-c28f2569.entry.js +1 -0
- package/dist/webcomponents/{p-c5b48e8d.entry.js → p-c51651aa.entry.js} +1 -1
- package/dist/webcomponents/p-c5911cd9.entry.js +1 -0
- package/dist/webcomponents/{p-4ba144ac.entry.js → p-cdd2c7c8.entry.js} +1 -1
- package/dist/webcomponents/p-cefb9a76.entry.js +1 -0
- package/dist/webcomponents/{p-I8XpD1TX.js → p-ck6bcYXe.js} +1 -1
- package/dist/webcomponents/p-d2ae3c55.entry.js +1 -0
- package/dist/webcomponents/p-d2e1d179.entry.js +1 -0
- package/dist/webcomponents/{p-ded22005.entry.js → p-d43a4316.entry.js} +1 -1
- package/dist/webcomponents/{p-5e10aa65.entry.js → p-d46dbb83.entry.js} +1 -1
- package/dist/webcomponents/p-d4d58793.entry.js +1 -0
- package/dist/webcomponents/{p-57143978.entry.js → p-d53c3370.entry.js} +1 -1
- package/dist/webcomponents/p-dc6b707a.entry.js +1 -0
- package/dist/webcomponents/p-dfd9aff0.entry.js +1 -0
- package/dist/webcomponents/{p-CsNubTqD.js → p-dzS7n4Xj.js} +1 -1
- package/dist/webcomponents/p-e4682bb6.entry.js +1 -0
- package/dist/webcomponents/p-eP3fmhta.js +1 -0
- package/dist/webcomponents/p-ee566062.entry.js +1 -0
- package/dist/webcomponents/p-ef07d761.entry.js +1 -0
- package/dist/webcomponents/p-f24b04eb.entry.js +1 -0
- package/dist/webcomponents/p-f8e974af.entry.js +1 -0
- package/dist/webcomponents/p-fb60bc7a.entry.js +1 -0
- package/dist/webcomponents/{p-DO3INvI2.js → p-qGbNz93o.js} +1 -1
- package/dist/webcomponents/p-sw5RO19U.js +1 -0
- package/dist/webcomponents/p-v6yK8Vbe.js +1 -0
- package/dist/webcomponents/p-znmwKCgq.js +1 -0
- package/dist/webcomponents/webcomponents.esm.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/bank-account-form.cjs.entry.js +0 -63
- package/dist/cjs/card-form.cjs.entry.js +0 -71
- package/dist/cjs/checkout.store-CV_fuGQw.js +0 -39
- package/dist/cjs/dinero-BwNN_k7x.js +0 -1657
- package/dist/cjs/justifi-bank-account-billing-form-simple_9.cjs.entry.js +0 -372
- package/dist/cjs/justifi-checkout-summary_6.cjs.entry.js +0 -706
- package/dist/cjs/justifi-saved-payment-method.cjs.entry.js +0 -31
- package/dist/cjs/justifi-skeleton.cjs.entry.js +0 -17
- package/dist/cjs/payment-method-option-utils-WYHIHy-l.js +0 -15
- package/dist/cjs/payment-method-option.cjs.entry.js +0 -17
- package/dist/cjs/terminals-list-params-state-BNbT1fuJ.js +0 -22
- package/dist/collection/api/BillingInformation.js +0 -1
- package/dist/collection/api/PaymentMethod.js +0 -1
- package/dist/collection/components/modular-checkout/modular-checkout.js +0 -430
- package/dist/collection/components/modular-checkout/sub-components/bank-account-skeleton.js +0 -10
- package/dist/collection/components/modular-checkout/sub-components/bank-account.js +0 -98
- package/dist/collection/components/modular-checkout/sub-components/card-form-skeleton.js +0 -10
- package/dist/collection/components/modular-checkout/sub-components/card-form.js +0 -102
- package/dist/collection/components/modular-checkout/sub-components/payment-method-option.js +0 -113
- package/dist/collection/components/modular-checkout/sub-components/saved-payment-methods.js +0 -40
- package/dist/collection/components/modular-checkout/sub-components/sezzle-payment-method.js +0 -127
- package/dist/collection/components/modular-checkout/sub-components/summary.js +0 -12
- package/dist/collection/store/checkout.store.js +0 -34
- package/dist/collection/ui-components/shadow-dom-components/justifi-button.js +0 -176
- package/dist/collection/ui-components/shadow-dom-components/justifi-header.js +0 -83
- package/dist/collection/ui-components/shadow-dom-components/justifi-radio-list-item.js +0 -155
- package/dist/collection/ui-components/shadow-dom-components/justifi-skeleton.js +0 -108
- package/dist/esm/bank-account-form.entry.js +0 -61
- package/dist/esm/card-form.entry.js +0 -69
- package/dist/esm/checkout.store-B60siz2l.js +0 -36
- package/dist/esm/dinero-HXpYMWUU.js +0 -1655
- package/dist/esm/insurance-state-CB4l8sOv.js +0 -45
- package/dist/esm/justifi-bank-account-billing-form-simple_9.entry.js +0 -362
- package/dist/esm/justifi-checkout-summary_6.entry.js +0 -699
- package/dist/esm/justifi-saved-payment-method.entry.js +0 -29
- package/dist/esm/justifi-skeleton.entry.js +0 -15
- package/dist/esm/payment-method-option-utils-lUHAQVFl.js +0 -15
- package/dist/esm/payment-method-option.entry.js +0 -15
- package/dist/esm/terminals-list-params-state-SMXQIZTt.js +0 -16
- package/dist/module/checkout.store.js +0 -36
- package/dist/module/dinero.js +0 -1655
- package/dist/module/header-2.js +0 -8
- package/dist/module/header-3.js +0 -8
- package/dist/module/justifi-bank-account-form.d.ts +0 -11
- package/dist/module/justifi-bank-account-form.js +0 -6
- package/dist/module/justifi-button.d.ts +0 -11
- package/dist/module/justifi-button.js +0 -6
- package/dist/module/justifi-button2.js +0 -41
- package/dist/module/justifi-card-form.d.ts +0 -11
- package/dist/module/justifi-card-form.js +0 -6
- package/dist/module/justifi-checkout-summary.d.ts +0 -11
- package/dist/module/justifi-checkout-summary.js +0 -6
- package/dist/module/justifi-header.js +0 -6
- package/dist/module/justifi-header2.js +0 -43
- package/dist/module/justifi-modular-checkout.d.ts +0 -11
- package/dist/module/justifi-modular-checkout.js +0 -6
- package/dist/module/justifi-radio-list-item.d.ts +0 -11
- package/dist/module/justifi-radio-list-item.js +0 -6
- package/dist/module/justifi-radio-list-item2.js +0 -55
- package/dist/module/justifi-saved-payment-methods.d.ts +0 -11
- package/dist/module/justifi-saved-payment-methods.js +0 -6
- package/dist/module/justifi-skeleton.d.ts +0 -11
- package/dist/module/justifi-skeleton.js +0 -39
- package/dist/module/modular-checkout.js +0 -336
- package/dist/module/payment-method-option-utils.js +0 -15
- package/dist/module/payment-method-option.d.ts +0 -11
- package/dist/module/payment-method-option.js +0 -54
- package/dist/module/saved-payment-methods.js +0 -73
- package/dist/module/summary.js +0 -35
- package/dist/module/tokenize-payment-method.js +0 -400
- package/dist/types/api/BillingInformation.d.ts +0 -13
- package/dist/types/api/PaymentMethod.d.ts +0 -21
- package/dist/types/components/modular-checkout/modular-checkout.d.ts +0 -34
- package/dist/types/components/modular-checkout/sub-components/bank-account-skeleton.d.ts +0 -6
- package/dist/types/components/modular-checkout/sub-components/bank-account.d.ts +0 -18
- package/dist/types/components/modular-checkout/sub-components/card-form-skeleton.d.ts +0 -6
- package/dist/types/components/modular-checkout/sub-components/card-form.d.ts +0 -20
- package/dist/types/components/modular-checkout/sub-components/payment-method-option.d.ts +0 -8
- package/dist/types/components/modular-checkout/sub-components/saved-payment-methods.d.ts +0 -7
- package/dist/types/components/modular-checkout/sub-components/summary.d.ts +0 -3
- package/dist/types/store/checkout.store.d.ts +0 -27
- package/dist/types/ui-components/shadow-dom-components/justifi-button.d.ts +0 -13
- package/dist/types/ui-components/shadow-dom-components/justifi-radio-list-item.d.ts +0 -12
- package/dist/types/ui-components/shadow-dom-components/justifi-skeleton.d.ts +0 -10
- package/dist/webcomponents/p-08ea8974.entry.js +0 -1
- package/dist/webcomponents/p-0932f6a9.entry.js +0 -1
- package/dist/webcomponents/p-09e768fe.entry.js +0 -1
- package/dist/webcomponents/p-15777cfe.entry.js +0 -1
- package/dist/webcomponents/p-22be0859.entry.js +0 -1
- package/dist/webcomponents/p-283cd78b.entry.js +0 -1
- package/dist/webcomponents/p-2a3d5af2.entry.js +0 -1
- package/dist/webcomponents/p-2ec9f293.entry.js +0 -1
- package/dist/webcomponents/p-3095775c.entry.js +0 -1
- package/dist/webcomponents/p-36d72e2d.entry.js +0 -1
- package/dist/webcomponents/p-39b79825.entry.js +0 -1
- package/dist/webcomponents/p-3d85d046.entry.js +0 -1
- package/dist/webcomponents/p-40ba49e4.entry.js +0 -1
- package/dist/webcomponents/p-424f491c.entry.js +0 -1
- package/dist/webcomponents/p-466f33d7.entry.js +0 -1
- package/dist/webcomponents/p-596b2653.entry.js +0 -1
- package/dist/webcomponents/p-5b09c0d8.entry.js +0 -1
- package/dist/webcomponents/p-5rVtZ2GJ.js +0 -1
- package/dist/webcomponents/p-6e18d13f.entry.js +0 -1
- package/dist/webcomponents/p-6f847539.entry.js +0 -1
- package/dist/webcomponents/p-7721a457.entry.js +0 -1
- package/dist/webcomponents/p-77515be6.entry.js +0 -1
- package/dist/webcomponents/p-79055216.entry.js +0 -1
- package/dist/webcomponents/p-7WIgS5RM.js +0 -1
- package/dist/webcomponents/p-7c51805a.entry.js +0 -1
- package/dist/webcomponents/p-7d944f7e.entry.js +0 -1
- package/dist/webcomponents/p-7ef0b68d.entry.js +0 -1
- package/dist/webcomponents/p-818f51fd.entry.js +0 -1
- package/dist/webcomponents/p-89e27079.entry.js +0 -1
- package/dist/webcomponents/p-8f0339de.entry.js +0 -1
- package/dist/webcomponents/p-904a95e5.entry.js +0 -1
- package/dist/webcomponents/p-9b75aced.entry.js +0 -1
- package/dist/webcomponents/p-9bb8bebf.entry.js +0 -1
- package/dist/webcomponents/p-BC8YDY7M.js +0 -1
- package/dist/webcomponents/p-BTkXk7ol.js +0 -1
- package/dist/webcomponents/p-BVD7g3cE.js +0 -1
- package/dist/webcomponents/p-Bb6FBEPP.js +0 -1
- package/dist/webcomponents/p-Bpcb3SsP.js +0 -1
- package/dist/webcomponents/p-Bt388eye.js +0 -1
- package/dist/webcomponents/p-BySyDTv5.js +0 -1
- package/dist/webcomponents/p-C1fMfnu0.js +0 -1
- package/dist/webcomponents/p-CCME-fyU.js +0 -1
- package/dist/webcomponents/p-CEsXw0Ph.js +0 -1
- package/dist/webcomponents/p-CLwzqWk2.js +0 -1
- package/dist/webcomponents/p-CVQyw7ao.js +0 -1
- package/dist/webcomponents/p-C_CXv7AN.js +0 -1
- package/dist/webcomponents/p-Cjcsf8ku.js +0 -1
- package/dist/webcomponents/p-CwZKT93w.js +0 -1
- package/dist/webcomponents/p-D599ZMGU.js +0 -1
- package/dist/webcomponents/p-DD74a16D.js +0 -1
- package/dist/webcomponents/p-DH8F0bsw.js +0 -1
- package/dist/webcomponents/p-DWUnL_zj.js +0 -1
- package/dist/webcomponents/p-DYGIC0QH.js +0 -1
- package/dist/webcomponents/p-DaDsBt65.js +0 -1
- package/dist/webcomponents/p-HXpYMWUU.js +0 -1
- package/dist/webcomponents/p-JgbsbAhz.js +0 -1
- package/dist/webcomponents/p-UD2JhYS2.js +0 -1
- package/dist/webcomponents/p-WEguiGt1.js +0 -1
- package/dist/webcomponents/p-ZpPDShvP.js +0 -1
- package/dist/webcomponents/p-a357be7d.entry.js +0 -1
- package/dist/webcomponents/p-a3d005dc.entry.js +0 -1
- package/dist/webcomponents/p-a4172773.entry.js +0 -1
- package/dist/webcomponents/p-a7d5e434.entry.js +0 -1
- package/dist/webcomponents/p-ae5a3c2a.entry.js +0 -1
- package/dist/webcomponents/p-b107ad76.entry.js +0 -1
- package/dist/webcomponents/p-b504a22b.entry.js +0 -1
- package/dist/webcomponents/p-b6f55d70.entry.js +0 -1
- package/dist/webcomponents/p-ba8ae31f.entry.js +0 -1
- package/dist/webcomponents/p-bdb56836.entry.js +0 -1
- package/dist/webcomponents/p-be06d86a.entry.js +0 -1
- package/dist/webcomponents/p-cb0effeb.entry.js +0 -1
- package/dist/webcomponents/p-cfca1837.entry.js +0 -1
- package/dist/webcomponents/p-d0e24727.entry.js +0 -1
- package/dist/webcomponents/p-d77908ca.entry.js +0 -1
- package/dist/webcomponents/p-dd6d6ddb.entry.js +0 -1
- package/dist/webcomponents/p-df199396.entry.js +0 -1
- package/dist/webcomponents/p-e2174f21.entry.js +0 -1
- package/dist/webcomponents/p-e57263b7.entry.js +0 -1
- package/dist/webcomponents/p-e830a580.entry.js +0 -1
- package/dist/webcomponents/p-e859ece8.entry.js +0 -1
- package/dist/webcomponents/p-eaea7cc1.entry.js +0 -1
- package/dist/webcomponents/p-f2149974.entry.js +0 -1
- package/dist/webcomponents/p-fa33df9f.entry.js +0 -1
- package/dist/webcomponents/p-ff3377e7.entry.js +0 -1
- package/dist/webcomponents/p-ff869ded.entry.js +0 -1
- package/dist/webcomponents/p-pska2q1M.js +0 -1
- package/dist/webcomponents/p-qMrd7_Gp.js +0 -1
- package/dist/webcomponents/p-vRhNRfmB.js +0 -1
- package/dist/webcomponents/p-wutYt_7D.js +0 -1
- package/dist/webcomponents/p-zdIeCUeh.js +0 -1
- package/dist/webcomponents/p-zrUQD0Wr.js +0 -1
package/dist/module/dinero.js
DELETED
|
@@ -1,1655 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default values for all Dinero objects.
|
|
3
|
-
*
|
|
4
|
-
* You can override default values for all subsequent Dinero objects by changing them directly on the global `Dinero` object.
|
|
5
|
-
* Existing instances won't be affected.
|
|
6
|
-
*
|
|
7
|
-
* @property {Number} defaultAmount - The default amount for new Dinero objects (see {@link module:Dinero Dinero} for format).
|
|
8
|
-
* @property {String} defaultCurrency - The default currency for new Dinero objects (see {@link module:Dinero Dinero} for format).
|
|
9
|
-
* @property {Number} defaultPrecision - The default precision for new Dinero objects (see {@link module:Dinero Dinero} for format).
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* // Will set currency to 'EUR' for all Dinero objects.
|
|
13
|
-
* Dinero.defaultCurrency = 'EUR'
|
|
14
|
-
*
|
|
15
|
-
* @type {Object}
|
|
16
|
-
*/
|
|
17
|
-
var Defaults = {
|
|
18
|
-
defaultAmount: 0,
|
|
19
|
-
defaultCurrency: 'USD',
|
|
20
|
-
defaultPrecision: 2
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Global settings for all Dinero objects.
|
|
24
|
-
*
|
|
25
|
-
* You can override global values for all subsequent Dinero objects by changing them directly on the global `Dinero` object.
|
|
26
|
-
* Existing instances won't be affected.
|
|
27
|
-
*
|
|
28
|
-
* @property {String} globalLocale - The global locale for new Dinero objects (see {@link module:Dinero~setLocale setLocale} for format).
|
|
29
|
-
* @property {String} globalFormat - The global format for new Dinero objects (see {@link module:Dinero~toFormat toFormat} for format).
|
|
30
|
-
* @property {String} globalRoundingMode - The global rounding mode for new Dinero objects (see {@link module:Dinero~multiply multiply} or {@link module:Dinero~divide divide} for format).
|
|
31
|
-
* @property {String} globalFormatRoundingMode - The global rounding mode to format new Dinero objects (see {@link module:Dinero~toFormat toFormat} or {@link module:Dinero~toRoundedUnit toRoundedUnit} for format).
|
|
32
|
-
* @property {(String|Promise)} globalExchangeRatesApi.endpoint - The global exchange rate API endpoint for new Dinero objects, or the global promise that resolves to the exchanges rates (see {@link module:Dinero~convert convert} for format).
|
|
33
|
-
* @property {String} globalExchangeRatesApi.propertyPath - The global exchange rate API property path for new Dinero objects (see {@link module:Dinero~convert convert} for format).
|
|
34
|
-
* @property {Object} globalExchangeRatesApi.headers - The global exchange rate API headers for new Dinero objects (see {@link module:Dinero~convert convert} for format).
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* // Will set locale to 'fr-FR' for all Dinero objects.
|
|
38
|
-
* Dinero.globalLocale = 'fr-FR'
|
|
39
|
-
* @example
|
|
40
|
-
* // Will set global exchange rate API parameters for all Dinero objects.
|
|
41
|
-
* Dinero.globalExchangeRatesApi = {
|
|
42
|
-
* endpoint: 'https://yourexchangerates.api/latest?base={{from}}',
|
|
43
|
-
* propertyPath: 'data.rates.{{to}}',
|
|
44
|
-
* headers: {
|
|
45
|
-
* 'user-key': 'xxxxxxxxx'
|
|
46
|
-
* }
|
|
47
|
-
* }
|
|
48
|
-
*
|
|
49
|
-
* @type {Object}
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
var Globals = {
|
|
53
|
-
globalLocale: 'en-US',
|
|
54
|
-
globalFormat: '$0,0.00',
|
|
55
|
-
globalRoundingMode: 'HALF_EVEN',
|
|
56
|
-
globalFormatRoundingMode: 'HALF_AWAY_FROM_ZERO',
|
|
57
|
-
globalExchangeRatesApi: {
|
|
58
|
-
endpoint: undefined,
|
|
59
|
-
headers: undefined,
|
|
60
|
-
propertyPath: undefined
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
function _typeof(obj) {
|
|
65
|
-
"@babel/helpers - typeof";
|
|
66
|
-
|
|
67
|
-
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
68
|
-
_typeof = function (obj) {
|
|
69
|
-
return typeof obj;
|
|
70
|
-
};
|
|
71
|
-
} else {
|
|
72
|
-
_typeof = function (obj) {
|
|
73
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return _typeof(obj);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function _toArray(arr) {
|
|
81
|
-
return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function _arrayWithHoles(arr) {
|
|
85
|
-
if (Array.isArray(arr)) return arr;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function _iterableToArray(iter) {
|
|
89
|
-
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
93
|
-
if (!o) return;
|
|
94
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
95
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
96
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
97
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
98
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function _arrayLikeToArray(arr, len) {
|
|
102
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
103
|
-
|
|
104
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
105
|
-
|
|
106
|
-
return arr2;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function _nonIterableRest() {
|
|
110
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Static methods for Dinero.
|
|
115
|
-
* @ignore
|
|
116
|
-
*
|
|
117
|
-
* @type {Object}
|
|
118
|
-
*/
|
|
119
|
-
var Static = {
|
|
120
|
-
/**
|
|
121
|
-
* Returns an array of Dinero objects, normalized to the same precision (the highest).
|
|
122
|
-
*
|
|
123
|
-
* @memberof module:Dinero
|
|
124
|
-
* @method
|
|
125
|
-
*
|
|
126
|
-
* @param {Dinero[]} objects - An array of Dinero objects
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
* // returns an array of Dinero objects
|
|
130
|
-
* // both with a precision of 3
|
|
131
|
-
* // and an amount of 1000
|
|
132
|
-
* Dinero.normalizePrecision([
|
|
133
|
-
* Dinero({ amount: 100, precision: 2 }),
|
|
134
|
-
* Dinero({ amount: 1000, precision: 3 })
|
|
135
|
-
* ])
|
|
136
|
-
*
|
|
137
|
-
* @return {Dinero[]}
|
|
138
|
-
*/
|
|
139
|
-
normalizePrecision: function normalizePrecision(objects) {
|
|
140
|
-
var highestPrecision = objects.reduce(function (a, b) {
|
|
141
|
-
return Math.max(a.getPrecision(), b.getPrecision());
|
|
142
|
-
});
|
|
143
|
-
return objects.map(function (object) {
|
|
144
|
-
return object.getPrecision() !== highestPrecision ? object.convertPrecision(highestPrecision) : object;
|
|
145
|
-
});
|
|
146
|
-
},
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Returns the smallest Dinero object from an array of Dinero objects
|
|
150
|
-
*
|
|
151
|
-
* @memberof module:Dinero
|
|
152
|
-
* @method
|
|
153
|
-
*
|
|
154
|
-
* @param {Dinero[]} objects - An array of Dinero objects
|
|
155
|
-
*
|
|
156
|
-
* @example
|
|
157
|
-
* // returns the smallest Dinero object with amount of 500 from an array of Dinero objects with different precisions
|
|
158
|
-
* Dinero.minimum([
|
|
159
|
-
* Dinero({ amount: 500, precision: 3 }),
|
|
160
|
-
* Dinero({ amount: 100, precision: 2 })
|
|
161
|
-
* ])
|
|
162
|
-
* @example
|
|
163
|
-
* // returns the smallest Dinero object with amount of 50 from an array of Dinero objects
|
|
164
|
-
* Dinero.minimum([
|
|
165
|
-
* Dinero({ amount: 50 }),
|
|
166
|
-
* Dinero({ amount: 100 })
|
|
167
|
-
* ])
|
|
168
|
-
*
|
|
169
|
-
* @return {Dinero[]}
|
|
170
|
-
*/
|
|
171
|
-
minimum: function minimum(objects) {
|
|
172
|
-
var _objects = _toArray(objects),
|
|
173
|
-
firstObject = _objects[0],
|
|
174
|
-
tailObjects = _objects.slice(1);
|
|
175
|
-
|
|
176
|
-
var currentMinimum = firstObject;
|
|
177
|
-
tailObjects.forEach(function (obj) {
|
|
178
|
-
currentMinimum = currentMinimum.lessThan(obj) ? currentMinimum : obj;
|
|
179
|
-
});
|
|
180
|
-
return currentMinimum;
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Returns the biggest Dinero object from an array of Dinero objects
|
|
185
|
-
*
|
|
186
|
-
* @memberof module:Dinero
|
|
187
|
-
* @method
|
|
188
|
-
*
|
|
189
|
-
* @param {Dinero[]} objects - An array of Dinero objects
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* // returns the biggest Dinero object with amount of 20, from an array of Dinero objects with different precisions
|
|
193
|
-
* Dinero.maximum([
|
|
194
|
-
* Dinero({ amount: 20, precision: 2 }),
|
|
195
|
-
* Dinero({ amount: 150, precision: 3 })
|
|
196
|
-
* ])
|
|
197
|
-
* @example
|
|
198
|
-
* // returns the biggest Dinero object with amount of 100, from an array of Dinero objects
|
|
199
|
-
* Dinero.maximum([
|
|
200
|
-
* Dinero({ amount: 100 }),
|
|
201
|
-
* Dinero({ amount: 50 })
|
|
202
|
-
* ])
|
|
203
|
-
*
|
|
204
|
-
* @return {Dinero[]}
|
|
205
|
-
*/
|
|
206
|
-
maximum: function maximum(objects) {
|
|
207
|
-
var _objects2 = _toArray(objects),
|
|
208
|
-
firstObject = _objects2[0],
|
|
209
|
-
tailObjects = _objects2.slice(1);
|
|
210
|
-
|
|
211
|
-
var currentMaximum = firstObject;
|
|
212
|
-
tailObjects.forEach(function (obj) {
|
|
213
|
-
currentMaximum = currentMaximum.greaterThan(obj) ? currentMaximum : obj;
|
|
214
|
-
});
|
|
215
|
-
return currentMaximum;
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Returns whether a value is numeric.
|
|
221
|
-
* @ignore
|
|
222
|
-
*
|
|
223
|
-
* @param {} value - The value to test.
|
|
224
|
-
*
|
|
225
|
-
* @return {Boolean}
|
|
226
|
-
*/
|
|
227
|
-
function isNumeric(value) {
|
|
228
|
-
return !isNaN(parseInt(value)) && isFinite(value);
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Returns whether a value is a percentage.
|
|
232
|
-
* @ignore
|
|
233
|
-
*
|
|
234
|
-
* @param {} percentage - The percentage to test.
|
|
235
|
-
*
|
|
236
|
-
* @return {Boolean}
|
|
237
|
-
*/
|
|
238
|
-
|
|
239
|
-
function isPercentage(percentage) {
|
|
240
|
-
return isNumeric(percentage) && percentage <= 100 && percentage >= 0;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Returns whether an array of ratios is valid.
|
|
244
|
-
* @ignore
|
|
245
|
-
*
|
|
246
|
-
* @param {} ratios - The ratios to test.
|
|
247
|
-
*
|
|
248
|
-
* @return {Boolean}
|
|
249
|
-
*/
|
|
250
|
-
|
|
251
|
-
function areValidRatios(ratios) {
|
|
252
|
-
return ratios.length > 0 && ratios.every(function (ratio) {
|
|
253
|
-
return ratio >= 0;
|
|
254
|
-
}) && ratios.some(function (ratio) {
|
|
255
|
-
return ratio > 0;
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Returns whether a value is even.
|
|
260
|
-
* @ignore
|
|
261
|
-
*
|
|
262
|
-
* @param {Number} value - The value to test.
|
|
263
|
-
*
|
|
264
|
-
* @return {Boolean}
|
|
265
|
-
*/
|
|
266
|
-
|
|
267
|
-
function isEven(value) {
|
|
268
|
-
return value % 2 === 0;
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Returns whether a value is a float.
|
|
272
|
-
* @ignore
|
|
273
|
-
*
|
|
274
|
-
* @param {} value - The value to test.
|
|
275
|
-
*
|
|
276
|
-
* @return {Boolean}
|
|
277
|
-
*/
|
|
278
|
-
|
|
279
|
-
function isFloat(value) {
|
|
280
|
-
return isNumeric(value) && !Number.isInteger(value);
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Returns how many fraction digits a number has.
|
|
284
|
-
* @ignore
|
|
285
|
-
*
|
|
286
|
-
* @param {Number} [number=0] - The number to test.
|
|
287
|
-
*
|
|
288
|
-
* @return {Number}
|
|
289
|
-
*/
|
|
290
|
-
|
|
291
|
-
function countFractionDigits() {
|
|
292
|
-
var number = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
293
|
-
var stringRepresentation = number.toString();
|
|
294
|
-
|
|
295
|
-
if (stringRepresentation.indexOf('e-') > 0) {
|
|
296
|
-
// It's too small for a normal string representation, e.g. 1e-7 instead of 0.00000001
|
|
297
|
-
return parseInt(stringRepresentation.split('e-')[1]);
|
|
298
|
-
} else {
|
|
299
|
-
var fractionDigits = stringRepresentation.split('.')[1];
|
|
300
|
-
return fractionDigits ? fractionDigits.length : 0;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Returns whether a number is half.
|
|
305
|
-
* @ignore
|
|
306
|
-
*
|
|
307
|
-
* @param {Number} number - The number to test.
|
|
308
|
-
*
|
|
309
|
-
* @return {Number}
|
|
310
|
-
*/
|
|
311
|
-
|
|
312
|
-
function isHalf(number) {
|
|
313
|
-
return Math.abs(number) % 1 === 0.5;
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Fetches a JSON resource.
|
|
317
|
-
* @ignore
|
|
318
|
-
*
|
|
319
|
-
* @param {String} url - The resource to fetch.
|
|
320
|
-
* @param {Object} [options.headers] - The headers to pass.
|
|
321
|
-
*
|
|
322
|
-
* @throws {Error} If `request.status` is lesser than 200 or greater or equal to 400.
|
|
323
|
-
* @throws {Error} If network fails.
|
|
324
|
-
*
|
|
325
|
-
* @return {JSON}
|
|
326
|
-
*/
|
|
327
|
-
|
|
328
|
-
function getJSON(url) {
|
|
329
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
330
|
-
return new Promise(function (resolve, reject) {
|
|
331
|
-
var request = Object.assign(new XMLHttpRequest(), {
|
|
332
|
-
onreadystatechange: function onreadystatechange() {
|
|
333
|
-
if (request.readyState === 4) {
|
|
334
|
-
if (request.status >= 200 && request.status < 400) resolve(JSON.parse(request.responseText));else reject(new Error(request.statusText));
|
|
335
|
-
}
|
|
336
|
-
},
|
|
337
|
-
onerror: function onerror() {
|
|
338
|
-
reject(new Error('Network error'));
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
request.open('GET', url, true);
|
|
342
|
-
setXHRHeaders(request, options.headers);
|
|
343
|
-
request.send();
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Returns an XHR object with attached headers.
|
|
348
|
-
* @ignore
|
|
349
|
-
*
|
|
350
|
-
* @param {XMLHttpRequest} xhr - The XHR request to set headers to.
|
|
351
|
-
* @param {Object} headers - The headers to set.
|
|
352
|
-
*
|
|
353
|
-
* @return {XMLHttpRequest}
|
|
354
|
-
*/
|
|
355
|
-
|
|
356
|
-
function setXHRHeaders(xhr) {
|
|
357
|
-
var headers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
358
|
-
|
|
359
|
-
for (var header in headers) {
|
|
360
|
-
xhr.setRequestHeader(header, headers[header]);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
return xhr;
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Returns whether a value is undefined.
|
|
367
|
-
* @ignore
|
|
368
|
-
*
|
|
369
|
-
* @param {} value - The value to test.
|
|
370
|
-
*
|
|
371
|
-
* @return {Boolean}
|
|
372
|
-
*/
|
|
373
|
-
|
|
374
|
-
function isUndefined(value) {
|
|
375
|
-
return typeof value === 'undefined';
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* Returns an object flattened to one level deep.
|
|
379
|
-
* @ignore
|
|
380
|
-
*
|
|
381
|
-
* @param {Object} object - The object to flatten.
|
|
382
|
-
* @param {String} separator - The separator to use between flattened nodes.
|
|
383
|
-
*
|
|
384
|
-
* @return {Object}
|
|
385
|
-
*/
|
|
386
|
-
|
|
387
|
-
function flattenObject(object) {
|
|
388
|
-
var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '.';
|
|
389
|
-
var finalObject = {};
|
|
390
|
-
Object.entries(object).forEach(function (item) {
|
|
391
|
-
if (_typeof(item[1]) === 'object') {
|
|
392
|
-
var flatObject = flattenObject(item[1]);
|
|
393
|
-
Object.entries(flatObject).forEach(function (node) {
|
|
394
|
-
finalObject[item[0] + separator + node[0]] = node[1];
|
|
395
|
-
});
|
|
396
|
-
} else {
|
|
397
|
-
finalObject[item[0]] = item[1];
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
return finalObject;
|
|
401
|
-
}
|
|
402
|
-
/**
|
|
403
|
-
* Returns whether a value is thenable.
|
|
404
|
-
* @ignore
|
|
405
|
-
*
|
|
406
|
-
* @param {} value - The value to test.
|
|
407
|
-
*
|
|
408
|
-
* @return {Boolean}
|
|
409
|
-
*/
|
|
410
|
-
|
|
411
|
-
function isThenable(value) {
|
|
412
|
-
return Boolean(value) && (_typeof(value) === 'object' || typeof value === 'function') && typeof value.then === 'function';
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
function Calculator() {
|
|
416
|
-
var floatMultiply = function floatMultiply(a, b) {
|
|
417
|
-
var getFactor = function getFactor(number) {
|
|
418
|
-
return Math.pow(10, countFractionDigits(number));
|
|
419
|
-
};
|
|
420
|
-
|
|
421
|
-
var factor = Math.max(getFactor(a), getFactor(b));
|
|
422
|
-
return Math.round(a * factor) * Math.round(b * factor) / (factor * factor);
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
var roundingModes = {
|
|
426
|
-
HALF_ODD: function HALF_ODD(number) {
|
|
427
|
-
var rounded = Math.round(number);
|
|
428
|
-
return isHalf(number) ? isEven(rounded) ? rounded - 1 : rounded : rounded;
|
|
429
|
-
},
|
|
430
|
-
HALF_EVEN: function HALF_EVEN(number) {
|
|
431
|
-
var rounded = Math.round(number);
|
|
432
|
-
return isHalf(number) ? isEven(rounded) ? rounded : rounded - 1 : rounded;
|
|
433
|
-
},
|
|
434
|
-
HALF_UP: function HALF_UP(number) {
|
|
435
|
-
return Math.round(number);
|
|
436
|
-
},
|
|
437
|
-
HALF_DOWN: function HALF_DOWN(number) {
|
|
438
|
-
return isHalf(number) ? Math.floor(number) : Math.round(number);
|
|
439
|
-
},
|
|
440
|
-
HALF_TOWARDS_ZERO: function HALF_TOWARDS_ZERO(number) {
|
|
441
|
-
return isHalf(number) ? Math.sign(number) * Math.floor(Math.abs(number)) : Math.round(number);
|
|
442
|
-
},
|
|
443
|
-
HALF_AWAY_FROM_ZERO: function HALF_AWAY_FROM_ZERO(number) {
|
|
444
|
-
return isHalf(number) ? Math.sign(number) * Math.ceil(Math.abs(number)) : Math.round(number);
|
|
445
|
-
},
|
|
446
|
-
DOWN: function DOWN(number) {
|
|
447
|
-
return Math.floor(number);
|
|
448
|
-
}
|
|
449
|
-
};
|
|
450
|
-
return {
|
|
451
|
-
/**
|
|
452
|
-
* Returns the sum of two numbers.
|
|
453
|
-
* @ignore
|
|
454
|
-
*
|
|
455
|
-
* @param {Number} a - The first number to add.
|
|
456
|
-
* @param {Number} b - The second number to add.
|
|
457
|
-
*
|
|
458
|
-
* @return {Number}
|
|
459
|
-
*/
|
|
460
|
-
add: function add(a, b) {
|
|
461
|
-
return a + b;
|
|
462
|
-
},
|
|
463
|
-
|
|
464
|
-
/**
|
|
465
|
-
* Returns the difference of two numbers.
|
|
466
|
-
* @ignore
|
|
467
|
-
*
|
|
468
|
-
* @param {Number} a - The first number to subtract.
|
|
469
|
-
* @param {Number} b - The second number to subtract.
|
|
470
|
-
*
|
|
471
|
-
* @return {Number}
|
|
472
|
-
*/
|
|
473
|
-
subtract: function subtract(a, b) {
|
|
474
|
-
return a - b;
|
|
475
|
-
},
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* Returns the product of two numbers.
|
|
479
|
-
* @ignore
|
|
480
|
-
*
|
|
481
|
-
* @param {Number} a - The first number to multiply.
|
|
482
|
-
* @param {Number} b - The second number to multiply.
|
|
483
|
-
*
|
|
484
|
-
* @return {Number}
|
|
485
|
-
*/
|
|
486
|
-
multiply: function multiply(a, b) {
|
|
487
|
-
return isFloat(a) || isFloat(b) ? floatMultiply(a, b) : a * b;
|
|
488
|
-
},
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* Returns the quotient of two numbers.
|
|
492
|
-
* @ignore
|
|
493
|
-
*
|
|
494
|
-
* @param {Number} a - The first number to divide.
|
|
495
|
-
* @param {Number} b - The second number to divide.
|
|
496
|
-
*
|
|
497
|
-
* @return {Number}
|
|
498
|
-
*/
|
|
499
|
-
divide: function divide(a, b) {
|
|
500
|
-
return a / b;
|
|
501
|
-
},
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* Returns the remainder of two numbers.
|
|
505
|
-
* @ignore
|
|
506
|
-
*
|
|
507
|
-
* @param {Number} a - The first number to divide.
|
|
508
|
-
* @param {Number} b - The second number to divide.
|
|
509
|
-
*
|
|
510
|
-
* @return {Number}
|
|
511
|
-
*/
|
|
512
|
-
modulo: function modulo(a, b) {
|
|
513
|
-
return a % b;
|
|
514
|
-
},
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* Returns a rounded number based off a specific rounding mode.
|
|
518
|
-
* @ignore
|
|
519
|
-
*
|
|
520
|
-
* @param {Number} number - The number to round.
|
|
521
|
-
* @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use.
|
|
522
|
-
*
|
|
523
|
-
* @returns {Number}
|
|
524
|
-
*/
|
|
525
|
-
round: function round(number) {
|
|
526
|
-
var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'HALF_EVEN';
|
|
527
|
-
return roundingModes[roundingMode](number);
|
|
528
|
-
}
|
|
529
|
-
};
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
var calculator = Calculator();
|
|
533
|
-
function Format(format) {
|
|
534
|
-
var matches = /^(?:(\$|USD)?0(?:(,)0)?(\.)?(0+)?|0(?:(,)0)?(\.)?(0+)?\s?(dollar)?)$/gm.exec(format);
|
|
535
|
-
return {
|
|
536
|
-
/**
|
|
537
|
-
* Returns the matches.
|
|
538
|
-
* @ignore
|
|
539
|
-
*
|
|
540
|
-
* @return {Array}
|
|
541
|
-
*/
|
|
542
|
-
getMatches: function getMatches() {
|
|
543
|
-
return matches !== null ? matches.slice(1).filter(function (match) {
|
|
544
|
-
return !isUndefined(match);
|
|
545
|
-
}) : [];
|
|
546
|
-
},
|
|
547
|
-
|
|
548
|
-
/**
|
|
549
|
-
* Returns the amount of fraction digits to display.
|
|
550
|
-
* @ignore
|
|
551
|
-
*
|
|
552
|
-
* @return {Number}
|
|
553
|
-
*/
|
|
554
|
-
getMinimumFractionDigits: function getMinimumFractionDigits() {
|
|
555
|
-
var decimalPosition = function decimalPosition(match) {
|
|
556
|
-
return match === '.';
|
|
557
|
-
};
|
|
558
|
-
|
|
559
|
-
return !isUndefined(this.getMatches().find(decimalPosition)) ? this.getMatches()[calculator.add(this.getMatches().findIndex(decimalPosition), 1)].split('').length : 0;
|
|
560
|
-
},
|
|
561
|
-
|
|
562
|
-
/**
|
|
563
|
-
* Returns the currency display mode.
|
|
564
|
-
* @ignore
|
|
565
|
-
*
|
|
566
|
-
* @return {String}
|
|
567
|
-
*/
|
|
568
|
-
getCurrencyDisplay: function getCurrencyDisplay() {
|
|
569
|
-
var modes = {
|
|
570
|
-
USD: 'code',
|
|
571
|
-
dollar: 'name',
|
|
572
|
-
$: 'symbol'
|
|
573
|
-
};
|
|
574
|
-
return modes[this.getMatches().find(function (match) {
|
|
575
|
-
return match === 'USD' || match === 'dollar' || match === '$';
|
|
576
|
-
})];
|
|
577
|
-
},
|
|
578
|
-
|
|
579
|
-
/**
|
|
580
|
-
* Returns the formatting style.
|
|
581
|
-
* @ignore
|
|
582
|
-
*
|
|
583
|
-
* @return {String}
|
|
584
|
-
*/
|
|
585
|
-
getStyle: function getStyle() {
|
|
586
|
-
return !isUndefined(this.getCurrencyDisplay(this.getMatches())) ? 'currency' : 'decimal';
|
|
587
|
-
},
|
|
588
|
-
|
|
589
|
-
/**
|
|
590
|
-
* Returns whether grouping should be used or not.
|
|
591
|
-
* @ignore
|
|
592
|
-
*
|
|
593
|
-
* @return {Boolean}
|
|
594
|
-
*/
|
|
595
|
-
getUseGrouping: function getUseGrouping() {
|
|
596
|
-
return !isUndefined(this.getMatches().find(function (match) {
|
|
597
|
-
return match === ',';
|
|
598
|
-
}));
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
function CurrencyConverter(options) {
|
|
604
|
-
/* istanbul ignore next */
|
|
605
|
-
var mergeTags = function mergeTags() {
|
|
606
|
-
var string = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
607
|
-
var tags = arguments.length > 1 ? arguments[1] : undefined;
|
|
608
|
-
|
|
609
|
-
for (var tag in tags) {
|
|
610
|
-
string = string.replace("{{".concat(tag, "}}"), tags[tag]);
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
return string;
|
|
614
|
-
};
|
|
615
|
-
/* istanbul ignore next */
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
var getRatesFromRestApi = function getRatesFromRestApi(from, to) {
|
|
619
|
-
return getJSON(mergeTags(options.endpoint, {
|
|
620
|
-
from: from,
|
|
621
|
-
to: to
|
|
622
|
-
}), {
|
|
623
|
-
headers: options.headers
|
|
624
|
-
});
|
|
625
|
-
};
|
|
626
|
-
|
|
627
|
-
return {
|
|
628
|
-
/**
|
|
629
|
-
* Returns the exchange rate.
|
|
630
|
-
* @ignore
|
|
631
|
-
*
|
|
632
|
-
* @param {String} from - The base currency.
|
|
633
|
-
* @param {String} to - The destination currency.
|
|
634
|
-
*
|
|
635
|
-
* @return {Promise}
|
|
636
|
-
*/
|
|
637
|
-
getExchangeRate: function getExchangeRate(from, to) {
|
|
638
|
-
return (isThenable(options.endpoint) ? options.endpoint : getRatesFromRestApi(from, to)).then(function (data) {
|
|
639
|
-
return flattenObject(data)[mergeTags(options.propertyPath, {
|
|
640
|
-
from: from,
|
|
641
|
-
to: to
|
|
642
|
-
})];
|
|
643
|
-
});
|
|
644
|
-
}
|
|
645
|
-
};
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
/**
|
|
649
|
-
* Performs an assertion.
|
|
650
|
-
* @ignore
|
|
651
|
-
*
|
|
652
|
-
* @param {Boolean} condition - The expression to assert.
|
|
653
|
-
* @param {String} errorMessage - The message to throw if the assertion fails
|
|
654
|
-
* @param {ErrorConstructor} [ErrorType=Error] - The error to throw if the assertion fails.
|
|
655
|
-
*
|
|
656
|
-
* @throws {Error} If `condition` returns `false`.
|
|
657
|
-
*/
|
|
658
|
-
|
|
659
|
-
function assert(condition, errorMessage) {
|
|
660
|
-
var ErrorType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Error;
|
|
661
|
-
if (!condition) throw new ErrorType(errorMessage);
|
|
662
|
-
}
|
|
663
|
-
/**
|
|
664
|
-
* Asserts a value is a percentage.
|
|
665
|
-
* @ignore
|
|
666
|
-
*
|
|
667
|
-
* @param {} percentage - The percentage to test.
|
|
668
|
-
*
|
|
669
|
-
* @throws {RangeError} If `percentage` is out of range.
|
|
670
|
-
*/
|
|
671
|
-
|
|
672
|
-
function assertPercentage(percentage) {
|
|
673
|
-
assert(isPercentage(percentage), 'You must provide a numeric value between 0 and 100.', RangeError);
|
|
674
|
-
}
|
|
675
|
-
/**
|
|
676
|
-
* Asserts an array of ratios is valid.
|
|
677
|
-
* @ignore
|
|
678
|
-
*
|
|
679
|
-
* @param {} ratios - The ratios to test.
|
|
680
|
-
*
|
|
681
|
-
* @throws {TypeError} If `ratios` are invalid.
|
|
682
|
-
*/
|
|
683
|
-
|
|
684
|
-
function assertValidRatios(ratios) {
|
|
685
|
-
assert(areValidRatios(ratios), 'You must provide a non-empty array of numeric values greater than 0.', TypeError);
|
|
686
|
-
}
|
|
687
|
-
/**
|
|
688
|
-
* Asserts a value is an integer.
|
|
689
|
-
* @ignore
|
|
690
|
-
*
|
|
691
|
-
* @param {} number - The value to test.
|
|
692
|
-
*
|
|
693
|
-
* @throws {TypeError}
|
|
694
|
-
*/
|
|
695
|
-
|
|
696
|
-
function assertInteger(number) {
|
|
697
|
-
assert(Number.isInteger(number), 'You must provide an integer.', TypeError);
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
var calculator$1 = Calculator();
|
|
701
|
-
/**
|
|
702
|
-
* A Dinero object is an immutable data structure representing a specific monetary value.
|
|
703
|
-
* It comes with methods for creating, parsing, manipulating, testing, transforming and formatting them.
|
|
704
|
-
*
|
|
705
|
-
* A Dinero object has:
|
|
706
|
-
*
|
|
707
|
-
* * An `amount`, expressed in minor currency units, as an integer.
|
|
708
|
-
* * A `currency`, expressed as an {@link https://en.wikipedia.org/wiki/ISO_4217#Active_codes ISO 4217 currency code}.
|
|
709
|
-
* * A `precision`, expressed as an integer, to represent the number of decimal places in the `amount`.
|
|
710
|
-
* This is helpful when you want to represent fractional minor currency units (e.g.: $10.4545).
|
|
711
|
-
* You can also use it to represent a currency with a different [exponent](https://en.wikipedia.org/wiki/ISO_4217#Treatment_of_minor_currency_units_.28the_.22exponent.22.29) than `2` (e.g.: Iraqi dinar with 1000 fils in 1 dinar (exponent of `3`), Japanese yen with no sub-units (exponent of `0`)).
|
|
712
|
-
* * An optional `locale` property that affects how output strings are formatted.
|
|
713
|
-
*
|
|
714
|
-
* Here's an overview of the public API:
|
|
715
|
-
*
|
|
716
|
-
* * **Access:** {@link module:Dinero~getAmount getAmount}, {@link module:Dinero~getCurrency getCurrency}, {@link module:Dinero~getLocale getLocale} and {@link module:Dinero~getPrecision getPrecision}.
|
|
717
|
-
* * **Manipulation:** {@link module:Dinero~add add}, {@link module:Dinero~subtract subtract}, {@link module:Dinero~multiply multiply}, {@link module:Dinero~divide divide}, {@link module:Dinero~percentage percentage}, {@link module:Dinero~allocate allocate} and {@link module:Dinero~convert convert}.
|
|
718
|
-
* * **Testing:** {@link module:Dinero~equalsTo equalsTo}, {@link module:Dinero~lessThan lessThan}, {@link module:Dinero~lessThanOrEqual lessThanOrEqual}, {@link module:Dinero~greaterThan greaterThan}, {@link module:Dinero~greaterThanOrEqual greaterThanOrEqual}, {@link module:Dinero~isZero isZero}, {@link module:Dinero~isPositive isPositive}, {@link module:Dinero~isNegative isNegative}, {@link module:Dinero~hasSubUnits hasSubUnits}, {@link module:Dinero~hasSameCurrency hasSameCurrency} and {@link module:Dinero~hasSameAmount hasSameAmount}.
|
|
719
|
-
* * **Configuration:** {@link module:Dinero~setLocale setLocale}.
|
|
720
|
-
* * **Conversion & formatting:** {@link module:Dinero~toFormat toFormat}, {@link module:Dinero~toUnit toUnit}, {@link module:Dinero~toRoundedUnit toRoundedUnit}, {@link module:Dinero~toObject toObject}, {@link module:Dinero~toJSON toJSON}, {@link module:Dinero~convertPrecision convertPrecision} and {@link module:Dinero.normalizePrecision normalizePrecision}.
|
|
721
|
-
*
|
|
722
|
-
* Dinero.js uses `number`s under the hood, so it's constrained by the [double-precision floating-point format](https://en.wikipedia.org/wiki/Double-precision_floating-point_format). Using values over [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Number/MAX_SAFE_INTEGER) or below [`Number.MIN_SAFE_INTEGER`](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Number/MIN_SAFE_INTEGER) will yield unpredictable results.
|
|
723
|
-
* Same goes with performing calculations: once the internal `amount` value exceeds those limits, precision is no longer guaranteed.
|
|
724
|
-
*
|
|
725
|
-
* @module Dinero
|
|
726
|
-
* @param {Number} [options.amount=0] - The amount in minor currency units (as an integer).
|
|
727
|
-
* @param {String} [options.currency='USD'] - An ISO 4217 currency code.
|
|
728
|
-
* @param {String} [options.precision=2] - The number of decimal places to represent.
|
|
729
|
-
*
|
|
730
|
-
* @throws {TypeError} If `amount` or `precision` is invalid. Integers over [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Number/MAX_SAFE_INTEGER) or below [`Number.MIN_SAFE_INTEGER`](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Number/MIN_SAFE_INTEGER) are considered valid, even though they can lead to imprecise amounts.
|
|
731
|
-
*
|
|
732
|
-
* @return {Object}
|
|
733
|
-
*/
|
|
734
|
-
|
|
735
|
-
var Dinero = function Dinero(options) {
|
|
736
|
-
var _Object$assign = Object.assign({}, {
|
|
737
|
-
amount: Dinero.defaultAmount,
|
|
738
|
-
currency: Dinero.defaultCurrency,
|
|
739
|
-
precision: Dinero.defaultPrecision
|
|
740
|
-
}, options),
|
|
741
|
-
amount = _Object$assign.amount,
|
|
742
|
-
currency = _Object$assign.currency,
|
|
743
|
-
precision = _Object$assign.precision;
|
|
744
|
-
|
|
745
|
-
assertInteger(amount);
|
|
746
|
-
assertInteger(precision);
|
|
747
|
-
var globalLocale = Dinero.globalLocale,
|
|
748
|
-
globalFormat = Dinero.globalFormat,
|
|
749
|
-
globalRoundingMode = Dinero.globalRoundingMode,
|
|
750
|
-
globalFormatRoundingMode = Dinero.globalFormatRoundingMode;
|
|
751
|
-
var globalExchangeRatesApi = Object.assign({}, Dinero.globalExchangeRatesApi);
|
|
752
|
-
/**
|
|
753
|
-
* Uses ES5 function notation so `this` can be passed through call, apply and bind
|
|
754
|
-
* @ignore
|
|
755
|
-
*/
|
|
756
|
-
|
|
757
|
-
var create = function create(options) {
|
|
758
|
-
var obj = Object.assign({}, Object.assign({}, {
|
|
759
|
-
amount: amount,
|
|
760
|
-
currency: currency,
|
|
761
|
-
precision: precision
|
|
762
|
-
}, options), Object.assign({}, {
|
|
763
|
-
locale: this.locale
|
|
764
|
-
}, options));
|
|
765
|
-
return Object.assign(Dinero({
|
|
766
|
-
amount: obj.amount,
|
|
767
|
-
currency: obj.currency,
|
|
768
|
-
precision: obj.precision
|
|
769
|
-
}), {
|
|
770
|
-
locale: obj.locale
|
|
771
|
-
});
|
|
772
|
-
};
|
|
773
|
-
/**
|
|
774
|
-
* Uses ES5 function notation so `this` can be passed through call, apply and bind
|
|
775
|
-
* @ignore
|
|
776
|
-
*/
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
var assertSameCurrency = function assertSameCurrency(comparator) {
|
|
780
|
-
assert(this.hasSameCurrency(comparator), 'You must provide a Dinero instance with the same currency.', TypeError);
|
|
781
|
-
};
|
|
782
|
-
|
|
783
|
-
return {
|
|
784
|
-
/**
|
|
785
|
-
* Returns the amount.
|
|
786
|
-
*
|
|
787
|
-
* @example
|
|
788
|
-
* // returns 500
|
|
789
|
-
* Dinero({ amount: 500 }).getAmount()
|
|
790
|
-
*
|
|
791
|
-
* @return {Number}
|
|
792
|
-
*/
|
|
793
|
-
getAmount: function getAmount() {
|
|
794
|
-
return amount;
|
|
795
|
-
},
|
|
796
|
-
|
|
797
|
-
/**
|
|
798
|
-
* Returns the currency.
|
|
799
|
-
*
|
|
800
|
-
* @example
|
|
801
|
-
* // returns 'EUR'
|
|
802
|
-
* Dinero({ currency: 'EUR' }).getCurrency()
|
|
803
|
-
*
|
|
804
|
-
* @return {String}
|
|
805
|
-
*/
|
|
806
|
-
getCurrency: function getCurrency() {
|
|
807
|
-
return currency;
|
|
808
|
-
},
|
|
809
|
-
|
|
810
|
-
/**
|
|
811
|
-
* Returns the locale.
|
|
812
|
-
*
|
|
813
|
-
* @example
|
|
814
|
-
* // returns 'fr-FR'
|
|
815
|
-
* Dinero().setLocale('fr-FR').getLocale()
|
|
816
|
-
*
|
|
817
|
-
* @return {String}
|
|
818
|
-
*/
|
|
819
|
-
getLocale: function getLocale() {
|
|
820
|
-
return this.locale || globalLocale;
|
|
821
|
-
},
|
|
822
|
-
|
|
823
|
-
/**
|
|
824
|
-
* Returns a new Dinero object with an embedded locale.
|
|
825
|
-
*
|
|
826
|
-
* @param {String} newLocale - The new locale as an {@link http://tools.ietf.org/html/rfc5646 BCP 47 language tag}.
|
|
827
|
-
*
|
|
828
|
-
* @example
|
|
829
|
-
* // Returns a Dinero object with locale 'ja-JP'
|
|
830
|
-
* Dinero().setLocale('ja-JP')
|
|
831
|
-
*
|
|
832
|
-
* @return {Dinero}
|
|
833
|
-
*/
|
|
834
|
-
setLocale: function setLocale(newLocale) {
|
|
835
|
-
return create.call(this, {
|
|
836
|
-
locale: newLocale
|
|
837
|
-
});
|
|
838
|
-
},
|
|
839
|
-
|
|
840
|
-
/**
|
|
841
|
-
* Returns the precision.
|
|
842
|
-
*
|
|
843
|
-
* @example
|
|
844
|
-
* // returns 3
|
|
845
|
-
* Dinero({ precision: 3 }).getPrecision()
|
|
846
|
-
*
|
|
847
|
-
* @return {Number}
|
|
848
|
-
*/
|
|
849
|
-
getPrecision: function getPrecision() {
|
|
850
|
-
return precision;
|
|
851
|
-
},
|
|
852
|
-
|
|
853
|
-
/**
|
|
854
|
-
* Returns a new Dinero object with a new precision and a converted amount.
|
|
855
|
-
*
|
|
856
|
-
* By default, fractional minor currency units are rounded using the **half to even** rule ([banker's rounding](http://wiki.c2.com/?BankersRounding)).
|
|
857
|
-
* This can be necessary when you need to convert objects to a smaller precision.
|
|
858
|
-
*
|
|
859
|
-
* Rounding *can* lead to accuracy issues as you chain many times. Consider a minimal amount of subsequent conversions for safer results.
|
|
860
|
-
* You can also specify a different `roundingMode` to better fit your needs.
|
|
861
|
-
*
|
|
862
|
-
* @param {Number} newPrecision - The new precision.
|
|
863
|
-
* @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
|
|
864
|
-
*
|
|
865
|
-
* @example
|
|
866
|
-
* // Returns a Dinero object with precision 3 and amount 1000
|
|
867
|
-
* Dinero({ amount: 100, precision: 2 }).convertPrecision(3)
|
|
868
|
-
*
|
|
869
|
-
* @throws {TypeError} If `newPrecision` is invalid.
|
|
870
|
-
*
|
|
871
|
-
* @return {Dinero}
|
|
872
|
-
*/
|
|
873
|
-
convertPrecision: function convertPrecision(newPrecision) {
|
|
874
|
-
var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalFormatRoundingMode;
|
|
875
|
-
assertInteger(newPrecision);
|
|
876
|
-
var precision = this.getPrecision();
|
|
877
|
-
var isNewPrecisionLarger = newPrecision > precision;
|
|
878
|
-
var operation = isNewPrecisionLarger ? calculator$1.multiply : calculator$1.divide;
|
|
879
|
-
var terms = isNewPrecisionLarger ? [newPrecision, precision] : [precision, newPrecision];
|
|
880
|
-
var factor = Math.pow(10, calculator$1.subtract.apply(calculator$1, terms));
|
|
881
|
-
return create.call(this, {
|
|
882
|
-
amount: calculator$1.round(operation(this.getAmount(), factor), roundingMode),
|
|
883
|
-
precision: newPrecision
|
|
884
|
-
});
|
|
885
|
-
},
|
|
886
|
-
|
|
887
|
-
/**
|
|
888
|
-
* Returns a new Dinero object that represents the sum of this and an other Dinero object.
|
|
889
|
-
*
|
|
890
|
-
* If Dinero objects have a different `precision`, they will be first converted to the highest.
|
|
891
|
-
*
|
|
892
|
-
* @param {Dinero} addend - The Dinero object to add.
|
|
893
|
-
*
|
|
894
|
-
* @example
|
|
895
|
-
* // returns a Dinero object with amount 600
|
|
896
|
-
* Dinero({ amount: 400 }).add(Dinero({ amount: 200 }))
|
|
897
|
-
* @example
|
|
898
|
-
* // returns a Dinero object with amount 144545 and precision 4
|
|
899
|
-
* Dinero({ amount: 400 }).add(Dinero({ amount: 104545, precision: 4 }))
|
|
900
|
-
*
|
|
901
|
-
* @throws {TypeError} If `addend` has a different currency.
|
|
902
|
-
*
|
|
903
|
-
* @return {Dinero}
|
|
904
|
-
*/
|
|
905
|
-
add: function add(addend) {
|
|
906
|
-
assertSameCurrency.call(this, addend);
|
|
907
|
-
var addends = Dinero.normalizePrecision([this, addend]);
|
|
908
|
-
return create.call(this, {
|
|
909
|
-
amount: calculator$1.add(addends[0].getAmount(), addends[1].getAmount()),
|
|
910
|
-
precision: addends[0].getPrecision()
|
|
911
|
-
});
|
|
912
|
-
},
|
|
913
|
-
|
|
914
|
-
/**
|
|
915
|
-
* Returns a new Dinero object that represents the difference of this and an other Dinero object.
|
|
916
|
-
*
|
|
917
|
-
* If Dinero objects have a different `precision`, they will be first converted to the highest.
|
|
918
|
-
*
|
|
919
|
-
* @param {Dinero} subtrahend - The Dinero object to subtract.
|
|
920
|
-
*
|
|
921
|
-
* @example
|
|
922
|
-
* // returns a Dinero object with amount 200
|
|
923
|
-
* Dinero({ amount: 400 }).subtract(Dinero({ amount: 200 }))
|
|
924
|
-
* @example
|
|
925
|
-
* // returns a Dinero object with amount 64545 and precision 4
|
|
926
|
-
* Dinero({ amount: 104545, precision: 4 }).subtract(Dinero({ amount: 400 }))
|
|
927
|
-
*
|
|
928
|
-
* @throws {TypeError} If `subtrahend` has a different currency.
|
|
929
|
-
*
|
|
930
|
-
* @return {Dinero}
|
|
931
|
-
*/
|
|
932
|
-
subtract: function subtract(subtrahend) {
|
|
933
|
-
assertSameCurrency.call(this, subtrahend);
|
|
934
|
-
var subtrahends = Dinero.normalizePrecision([this, subtrahend]);
|
|
935
|
-
return create.call(this, {
|
|
936
|
-
amount: calculator$1.subtract(subtrahends[0].getAmount(), subtrahends[1].getAmount()),
|
|
937
|
-
precision: subtrahends[0].getPrecision()
|
|
938
|
-
});
|
|
939
|
-
},
|
|
940
|
-
|
|
941
|
-
/**
|
|
942
|
-
* Returns a new Dinero object that represents the multiplied value by the given factor.
|
|
943
|
-
*
|
|
944
|
-
* By default, fractional minor currency units are rounded using the **half to even** rule ([banker's rounding](http://wiki.c2.com/?BankersRounding)).
|
|
945
|
-
*
|
|
946
|
-
* Rounding *can* lead to accuracy issues as you chain many times. Consider a minimal amount of subsequent calculations for safer results.
|
|
947
|
-
* You can also specify a different `roundingMode` to better fit your needs.
|
|
948
|
-
*
|
|
949
|
-
* @param {Number} multiplier - The factor to multiply by.
|
|
950
|
-
* @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
|
|
951
|
-
*
|
|
952
|
-
* @example
|
|
953
|
-
* // returns a Dinero object with amount 1600
|
|
954
|
-
* Dinero({ amount: 400 }).multiply(4)
|
|
955
|
-
* @example
|
|
956
|
-
* // returns a Dinero object with amount 800
|
|
957
|
-
* Dinero({ amount: 400 }).multiply(2.001)
|
|
958
|
-
* @example
|
|
959
|
-
* // returns a Dinero object with amount 801
|
|
960
|
-
* Dinero({ amount: 400 }).multiply(2.00125, 'HALF_UP')
|
|
961
|
-
*
|
|
962
|
-
* @return {Dinero}
|
|
963
|
-
*/
|
|
964
|
-
multiply: function multiply(multiplier) {
|
|
965
|
-
var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalRoundingMode;
|
|
966
|
-
return create.call(this, {
|
|
967
|
-
amount: calculator$1.round(calculator$1.multiply(this.getAmount(), multiplier), roundingMode)
|
|
968
|
-
});
|
|
969
|
-
},
|
|
970
|
-
|
|
971
|
-
/**
|
|
972
|
-
* Returns a new Dinero object that represents the divided value by the given factor.
|
|
973
|
-
*
|
|
974
|
-
* By default, fractional minor currency units are rounded using the **half to even** rule ([banker's rounding](http://wiki.c2.com/?BankersRounding)).
|
|
975
|
-
*
|
|
976
|
-
* Rounding *can* lead to accuracy issues as you chain many times. Consider a minimal amount of subsequent calculations for safer results.
|
|
977
|
-
* You can also specify a different `roundingMode` to better fit your needs.
|
|
978
|
-
*
|
|
979
|
-
* As rounding is applied, precision may be lost in the process. If you want to accurately split a Dinero object, use {@link module:Dinero~allocate allocate} instead.
|
|
980
|
-
*
|
|
981
|
-
* @param {Number} divisor - The factor to divide by.
|
|
982
|
-
* @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
|
|
983
|
-
*
|
|
984
|
-
* @example
|
|
985
|
-
* // returns a Dinero object with amount 100
|
|
986
|
-
* Dinero({ amount: 400 }).divide(4)
|
|
987
|
-
* @example
|
|
988
|
-
* // returns a Dinero object with amount 52
|
|
989
|
-
* Dinero({ amount: 105 }).divide(2)
|
|
990
|
-
* @example
|
|
991
|
-
* // returns a Dinero object with amount 53
|
|
992
|
-
* Dinero({ amount: 105 }).divide(2, 'HALF_UP')
|
|
993
|
-
*
|
|
994
|
-
* @return {Dinero}
|
|
995
|
-
*/
|
|
996
|
-
divide: function divide(divisor) {
|
|
997
|
-
var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalRoundingMode;
|
|
998
|
-
return create.call(this, {
|
|
999
|
-
amount: calculator$1.round(calculator$1.divide(this.getAmount(), divisor), roundingMode)
|
|
1000
|
-
});
|
|
1001
|
-
},
|
|
1002
|
-
|
|
1003
|
-
/**
|
|
1004
|
-
* Returns a new Dinero object that represents a percentage of this.
|
|
1005
|
-
*
|
|
1006
|
-
* As rounding is applied, precision may be lost in the process. If you want to accurately split a Dinero object, use {@link module:Dinero~allocate allocate} instead.
|
|
1007
|
-
*
|
|
1008
|
-
* @param {Number} percentage - The percentage to extract (between 0 and 100).
|
|
1009
|
-
* @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
|
|
1010
|
-
*
|
|
1011
|
-
* @example
|
|
1012
|
-
* // returns a Dinero object with amount 5000
|
|
1013
|
-
* Dinero({ amount: 10000 }).percentage(50)
|
|
1014
|
-
* @example
|
|
1015
|
-
* // returns a Dinero object with amount 29
|
|
1016
|
-
* Dinero({ amount: 57 }).percentage(50, "HALF_ODD")
|
|
1017
|
-
*
|
|
1018
|
-
* @throws {RangeError} If `percentage` is out of range.
|
|
1019
|
-
*
|
|
1020
|
-
* @return {Dinero}
|
|
1021
|
-
*/
|
|
1022
|
-
percentage: function percentage(_percentage) {
|
|
1023
|
-
var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalRoundingMode;
|
|
1024
|
-
assertPercentage(_percentage);
|
|
1025
|
-
return this.multiply(calculator$1.divide(_percentage, 100), roundingMode);
|
|
1026
|
-
},
|
|
1027
|
-
|
|
1028
|
-
/**
|
|
1029
|
-
* Allocates the amount of a Dinero object according to a list of ratios.
|
|
1030
|
-
*
|
|
1031
|
-
* Sometimes you need to split monetary values but percentages can't cut it without adding or losing pennies.
|
|
1032
|
-
* A good example is invoicing: let's say you need to bill $1,000.03 and you want a 50% downpayment.
|
|
1033
|
-
* If you use {@link module:Dinero~percentage percentage}, you'll get an accurate Dinero object but the amount won't be billable: you can't split a penny.
|
|
1034
|
-
* If you round it, you'll bill a penny extra.
|
|
1035
|
-
* With {@link module:Dinero~allocate allocate}, you can split a monetary amount then distribute the remainder as evenly as possible.
|
|
1036
|
-
*
|
|
1037
|
-
* You can use percentage style or ratio style for `ratios`: `[25, 75]` and `[1, 3]` will do the same thing.
|
|
1038
|
-
*
|
|
1039
|
-
* Since v1.8.0, you can use zero ratios (such as [0, 50, 50]). If there's a remainder to distribute, zero ratios are skipped and return a Dinero object with amount zero.
|
|
1040
|
-
*
|
|
1041
|
-
* @param {Number[]} ratios - The ratios to allocate the money to.
|
|
1042
|
-
*
|
|
1043
|
-
* @example
|
|
1044
|
-
* // returns an array of two Dinero objects
|
|
1045
|
-
* // the first one with an amount of 502
|
|
1046
|
-
* // the second one with an amount of 501
|
|
1047
|
-
* Dinero({ amount: 1003 }).allocate([50, 50])
|
|
1048
|
-
* @example
|
|
1049
|
-
* // returns an array of two Dinero objects
|
|
1050
|
-
* // the first one with an amount of 25
|
|
1051
|
-
* // the second one with an amount of 75
|
|
1052
|
-
* Dinero({ amount: 100 }).allocate([1, 3])
|
|
1053
|
-
* @example
|
|
1054
|
-
* // since version 1.8.0
|
|
1055
|
-
* // returns an array of three Dinero objects
|
|
1056
|
-
* // the first one with an amount of 0
|
|
1057
|
-
* // the second one with an amount of 502
|
|
1058
|
-
* // the third one with an amount of 501
|
|
1059
|
-
* Dinero({ amount: 1003 }).allocate([0, 50, 50])
|
|
1060
|
-
*
|
|
1061
|
-
* @throws {TypeError} If ratios are invalid.
|
|
1062
|
-
*
|
|
1063
|
-
* @return {Dinero[]}
|
|
1064
|
-
*/
|
|
1065
|
-
allocate: function allocate(ratios) {
|
|
1066
|
-
var _this = this;
|
|
1067
|
-
|
|
1068
|
-
assertValidRatios(ratios);
|
|
1069
|
-
var total = ratios.reduce(function (a, b) {
|
|
1070
|
-
return calculator$1.add(a, b);
|
|
1071
|
-
});
|
|
1072
|
-
var remainder = this.getAmount();
|
|
1073
|
-
var shares = ratios.map(function (ratio) {
|
|
1074
|
-
var share = Math.floor(calculator$1.divide(calculator$1.multiply(_this.getAmount(), ratio), total));
|
|
1075
|
-
remainder = calculator$1.subtract(remainder, share);
|
|
1076
|
-
return create.call(_this, {
|
|
1077
|
-
amount: share
|
|
1078
|
-
});
|
|
1079
|
-
});
|
|
1080
|
-
var i = 0;
|
|
1081
|
-
|
|
1082
|
-
while (remainder > 0) {
|
|
1083
|
-
if (ratios[i] > 0) {
|
|
1084
|
-
shares[i] = shares[i].add(create.call(this, {
|
|
1085
|
-
amount: 1
|
|
1086
|
-
}));
|
|
1087
|
-
remainder = calculator$1.subtract(remainder, 1);
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
i += 1;
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
return shares;
|
|
1094
|
-
},
|
|
1095
|
-
|
|
1096
|
-
/**
|
|
1097
|
-
* Returns a Promise containing a new Dinero object converted to another currency.
|
|
1098
|
-
*
|
|
1099
|
-
* You have two options to provide the exchange rates:
|
|
1100
|
-
*
|
|
1101
|
-
* 1. **Use an exchange rate REST API, and let Dinero handle the fetching and conversion.**
|
|
1102
|
-
* This is a simple option if you have access to an exchange rate REST API and want Dinero to do the rest.
|
|
1103
|
-
* 2. **Fetch the exchange rates on your own and provide them directly.**
|
|
1104
|
-
* This is useful if you're fetching your rates from somewhere else (a file, a database), use a different protocol or query language than REST (SOAP, GraphQL) or want to fetch rates once and cache them instead of making new requests every time.
|
|
1105
|
-
*
|
|
1106
|
-
* **If you want to use a REST API**, you must provide a third-party endpoint yourself. Dinero doesn't come bundled with an exchange rates endpoint.
|
|
1107
|
-
*
|
|
1108
|
-
* Here are some exchange rate APIs you can use:
|
|
1109
|
-
*
|
|
1110
|
-
* * [Fixer](https://fixer.io)
|
|
1111
|
-
* * [Open Exchange Rates](https://openexchangerates.org)
|
|
1112
|
-
* * [Coinbase](https://api.coinbase.com/v2/exchange-rates)
|
|
1113
|
-
* * More [foreign](https://github.com/toddmotto/public-apis#currency-exchange) and [crypto](https://github.com/toddmotto/public-apis#cryptocurrency) exchange rate APIs.
|
|
1114
|
-
*
|
|
1115
|
-
* **If you want to fetch your own rates and provide them directly**, you need to pass a promise that resolves to the exchanges rates.
|
|
1116
|
-
*
|
|
1117
|
-
* In both cases, you need to specify at least:
|
|
1118
|
-
*
|
|
1119
|
-
* * a **destination currency**: the currency in which you want to convert your Dinero object. You can specify it with `currency`.
|
|
1120
|
-
* * an **endpoint**: the API URL to query exchange rates, with parameters, or a promise that resolves to the exchange rates. You can specify it with `options.endpoint`.
|
|
1121
|
-
* * a **property path**: the path to access the wanted rate in your API's JSON response (or the custom promise's payload). For example, with a response of:
|
|
1122
|
-
* ```json
|
|
1123
|
-
* {
|
|
1124
|
-
* "data": {
|
|
1125
|
-
* "base": "USD",
|
|
1126
|
-
* "destination": "EUR",
|
|
1127
|
-
* "rate": "0.827728919"
|
|
1128
|
-
* }
|
|
1129
|
-
* }
|
|
1130
|
-
* ```
|
|
1131
|
-
* Then the property path is `'data.rate'`. You can specify it with `options.propertyPath`.
|
|
1132
|
-
*
|
|
1133
|
-
* The base currency (the one of your Dinero object) and the destination currency can be used as "merge tags" with the mustache syntax, respectively `{{from}}` and `{{to}}`.
|
|
1134
|
-
* You can use these tags to refer to these values in `options.endpoint` and `options.propertyPath`.
|
|
1135
|
-
*
|
|
1136
|
-
* For example, if you need to specify the base currency as a query parameter, you can do the following:
|
|
1137
|
-
*
|
|
1138
|
-
* ```js
|
|
1139
|
-
* {
|
|
1140
|
-
* endpoint: 'https://yourexchangerates.api/latest?base={{from}}'
|
|
1141
|
-
* }
|
|
1142
|
-
* ```
|
|
1143
|
-
*
|
|
1144
|
-
* @param {String} currency - The destination currency, expressed as an {@link https://en.wikipedia.org/wiki/ISO_4217#Active_codes ISO 4217 currency code}.
|
|
1145
|
-
* @param {(String|Promise)} options.endpoint - The API endpoint to retrieve exchange rates. You can substitute this with a promise that resolves to the exchanges rates if you already have them.
|
|
1146
|
-
* @param {String} [options.propertyPath='rates.{{to}}'] - The property path to the rate.
|
|
1147
|
-
* @param {Object} [options.headers] - The HTTP headers to provide, if needed.
|
|
1148
|
-
* @param {String} [options.roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
|
|
1149
|
-
*
|
|
1150
|
-
* @example
|
|
1151
|
-
* // your global API parameters
|
|
1152
|
-
* Dinero.globalExchangeRatesApi = { ... }
|
|
1153
|
-
*
|
|
1154
|
-
* // returns a Promise containing a Dinero object with the destination currency
|
|
1155
|
-
* // and the initial amount converted to the new currency.
|
|
1156
|
-
* Dinero({ amount: 500 }).convert('EUR')
|
|
1157
|
-
* @example
|
|
1158
|
-
* // returns a Promise containing a Dinero object,
|
|
1159
|
-
* // with specific API parameters and rounding mode for this specific instance.
|
|
1160
|
-
* Dinero({ amount: 500 })
|
|
1161
|
-
* .convert('XBT', {
|
|
1162
|
-
* endpoint: 'https://yourexchangerates.api/latest?base={{from}}',
|
|
1163
|
-
* propertyPath: 'data.rates.{{to}}',
|
|
1164
|
-
* headers: {
|
|
1165
|
-
* 'user-key': 'xxxxxxxxx'
|
|
1166
|
-
* },
|
|
1167
|
-
* roundingMode: 'HALF_UP'
|
|
1168
|
-
* })
|
|
1169
|
-
* @example
|
|
1170
|
-
* // usage with exchange rates provided as a custom promise
|
|
1171
|
-
* // using the default `propertyPath` format (so it doesn't have to be specified)
|
|
1172
|
-
* const rates = {
|
|
1173
|
-
* rates: {
|
|
1174
|
-
* EUR: 0.81162
|
|
1175
|
-
* }
|
|
1176
|
-
* }
|
|
1177
|
-
*
|
|
1178
|
-
* Dinero({ amount: 500 })
|
|
1179
|
-
* .convert('EUR', {
|
|
1180
|
-
* endpoint: new Promise(resolve => resolve(rates))
|
|
1181
|
-
* })
|
|
1182
|
-
* @example
|
|
1183
|
-
* // usage with Promise.prototype.then and Promise.prototype.catch
|
|
1184
|
-
* Dinero({ amount: 500 })
|
|
1185
|
-
* .convert('EUR')
|
|
1186
|
-
* .then(dinero => {
|
|
1187
|
-
* dinero.getCurrency() // returns 'EUR'
|
|
1188
|
-
* })
|
|
1189
|
-
* .catch(err => {
|
|
1190
|
-
* // handle errors
|
|
1191
|
-
* })
|
|
1192
|
-
* @example
|
|
1193
|
-
* // usage with async/await
|
|
1194
|
-
* (async () => {
|
|
1195
|
-
* const price = await Dinero({ amount: 500 }).convert('EUR')
|
|
1196
|
-
* price.getCurrency() // returns 'EUR'
|
|
1197
|
-
* })()
|
|
1198
|
-
*
|
|
1199
|
-
* @return {Promise}
|
|
1200
|
-
*/
|
|
1201
|
-
convert: function convert(currency) {
|
|
1202
|
-
var _this2 = this;
|
|
1203
|
-
|
|
1204
|
-
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
1205
|
-
_ref$endpoint = _ref.endpoint,
|
|
1206
|
-
endpoint = _ref$endpoint === void 0 ? globalExchangeRatesApi.endpoint : _ref$endpoint,
|
|
1207
|
-
_ref$propertyPath = _ref.propertyPath,
|
|
1208
|
-
propertyPath = _ref$propertyPath === void 0 ? globalExchangeRatesApi.propertyPath || 'rates.{{to}}' : _ref$propertyPath,
|
|
1209
|
-
_ref$headers = _ref.headers,
|
|
1210
|
-
headers = _ref$headers === void 0 ? globalExchangeRatesApi.headers : _ref$headers,
|
|
1211
|
-
_ref$roundingMode = _ref.roundingMode,
|
|
1212
|
-
roundingMode = _ref$roundingMode === void 0 ? globalRoundingMode : _ref$roundingMode;
|
|
1213
|
-
|
|
1214
|
-
var options = Object.assign({}, {
|
|
1215
|
-
endpoint: endpoint,
|
|
1216
|
-
propertyPath: propertyPath,
|
|
1217
|
-
headers: headers,
|
|
1218
|
-
roundingMode: roundingMode
|
|
1219
|
-
});
|
|
1220
|
-
return CurrencyConverter(options).getExchangeRate(this.getCurrency(), currency).then(function (rate) {
|
|
1221
|
-
assert(!isUndefined(rate), "No rate was found for the destination currency \"".concat(currency, "\"."), TypeError);
|
|
1222
|
-
return create.call(_this2, {
|
|
1223
|
-
amount: calculator$1.round(calculator$1.multiply(_this2.getAmount(), parseFloat(rate)), options.roundingMode),
|
|
1224
|
-
currency: currency
|
|
1225
|
-
});
|
|
1226
|
-
});
|
|
1227
|
-
},
|
|
1228
|
-
|
|
1229
|
-
/**
|
|
1230
|
-
* Checks whether the value represented by this object equals to the other.
|
|
1231
|
-
*
|
|
1232
|
-
* @param {Dinero} comparator - The Dinero object to compare to.
|
|
1233
|
-
*
|
|
1234
|
-
* @example
|
|
1235
|
-
* // returns true
|
|
1236
|
-
* Dinero({ amount: 500, currency: 'EUR' }).equalsTo(Dinero({ amount: 500, currency: 'EUR' }))
|
|
1237
|
-
* @example
|
|
1238
|
-
* // returns false
|
|
1239
|
-
* Dinero({ amount: 500, currency: 'EUR' }).equalsTo(Dinero({ amount: 800, currency: 'EUR' }))
|
|
1240
|
-
* @example
|
|
1241
|
-
* // returns false
|
|
1242
|
-
* Dinero({ amount: 500, currency: 'USD' }).equalsTo(Dinero({ amount: 500, currency: 'EUR' }))
|
|
1243
|
-
* @example
|
|
1244
|
-
* // returns false
|
|
1245
|
-
* Dinero({ amount: 500, currency: 'USD' }).equalsTo(Dinero({ amount: 800, currency: 'EUR' }))
|
|
1246
|
-
* @example
|
|
1247
|
-
* // returns true
|
|
1248
|
-
* Dinero({ amount: 1000, currency: 'EUR', precision: 2 }).equalsTo(Dinero({ amount: 10000, currency: 'EUR', precision: 3 }))
|
|
1249
|
-
* @example
|
|
1250
|
-
* // returns false
|
|
1251
|
-
* Dinero({ amount: 10000, currency: 'EUR', precision: 2 }).equalsTo(Dinero({ amount: 10000, currency: 'EUR', precision: 3 }))
|
|
1252
|
-
*
|
|
1253
|
-
* @return {Boolean}
|
|
1254
|
-
*/
|
|
1255
|
-
equalsTo: function equalsTo(comparator) {
|
|
1256
|
-
return this.hasSameAmount(comparator) && this.hasSameCurrency(comparator);
|
|
1257
|
-
},
|
|
1258
|
-
|
|
1259
|
-
/**
|
|
1260
|
-
* Checks whether the value represented by this object is less than the other.
|
|
1261
|
-
*
|
|
1262
|
-
* @param {Dinero} comparator - The Dinero object to compare to.
|
|
1263
|
-
*
|
|
1264
|
-
* @example
|
|
1265
|
-
* // returns true
|
|
1266
|
-
* Dinero({ amount: 500 }).lessThan(Dinero({ amount: 800 }))
|
|
1267
|
-
* @example
|
|
1268
|
-
* // returns false
|
|
1269
|
-
* Dinero({ amount: 800 }).lessThan(Dinero({ amount: 500 }))
|
|
1270
|
-
* @example
|
|
1271
|
-
* // returns true
|
|
1272
|
-
* Dinero({ amount: 5000, precision: 3 }).lessThan(Dinero({ amount: 800 }))
|
|
1273
|
-
* @example
|
|
1274
|
-
* // returns false
|
|
1275
|
-
* Dinero({ amount: 800 }).lessThan(Dinero({ amount: 5000, precision: 3 }))
|
|
1276
|
-
*
|
|
1277
|
-
* @throws {TypeError} If `comparator` has a different currency.
|
|
1278
|
-
*
|
|
1279
|
-
* @return {Boolean}
|
|
1280
|
-
*/
|
|
1281
|
-
lessThan: function lessThan(comparator) {
|
|
1282
|
-
assertSameCurrency.call(this, comparator);
|
|
1283
|
-
var comparators = Dinero.normalizePrecision([this, comparator]);
|
|
1284
|
-
return comparators[0].getAmount() < comparators[1].getAmount();
|
|
1285
|
-
},
|
|
1286
|
-
|
|
1287
|
-
/**
|
|
1288
|
-
* Checks whether the value represented by this object is less than or equal to the other.
|
|
1289
|
-
*
|
|
1290
|
-
* @param {Dinero} comparator - The Dinero object to compare to.
|
|
1291
|
-
*
|
|
1292
|
-
* @example
|
|
1293
|
-
* // returns true
|
|
1294
|
-
* Dinero({ amount: 500 }).lessThanOrEqual(Dinero({ amount: 800 }))
|
|
1295
|
-
* @example
|
|
1296
|
-
* // returns true
|
|
1297
|
-
* Dinero({ amount: 500 }).lessThanOrEqual(Dinero({ amount: 500 }))
|
|
1298
|
-
* @example
|
|
1299
|
-
* // returns false
|
|
1300
|
-
* Dinero({ amount: 500 }).lessThanOrEqual(Dinero({ amount: 300 }))
|
|
1301
|
-
* @example
|
|
1302
|
-
* // returns true
|
|
1303
|
-
* Dinero({ amount: 5000, precision: 3 }).lessThanOrEqual(Dinero({ amount: 800 }))
|
|
1304
|
-
* @example
|
|
1305
|
-
* // returns true
|
|
1306
|
-
* Dinero({ amount: 5000, precision: 3 }).lessThanOrEqual(Dinero({ amount: 500 }))
|
|
1307
|
-
* @example
|
|
1308
|
-
* // returns false
|
|
1309
|
-
* Dinero({ amount: 800 }).lessThanOrEqual(Dinero({ amount: 5000, precision: 3 }))
|
|
1310
|
-
*
|
|
1311
|
-
* @throws {TypeError} If `comparator` has a different currency.
|
|
1312
|
-
*
|
|
1313
|
-
* @return {Boolean}
|
|
1314
|
-
*/
|
|
1315
|
-
lessThanOrEqual: function lessThanOrEqual(comparator) {
|
|
1316
|
-
assertSameCurrency.call(this, comparator);
|
|
1317
|
-
var comparators = Dinero.normalizePrecision([this, comparator]);
|
|
1318
|
-
return comparators[0].getAmount() <= comparators[1].getAmount();
|
|
1319
|
-
},
|
|
1320
|
-
|
|
1321
|
-
/**
|
|
1322
|
-
* Checks whether the value represented by this object is greater than the other.
|
|
1323
|
-
*
|
|
1324
|
-
* @param {Dinero} comparator - The Dinero object to compare to.
|
|
1325
|
-
*
|
|
1326
|
-
* @example
|
|
1327
|
-
* // returns false
|
|
1328
|
-
* Dinero({ amount: 500 }).greaterThan(Dinero({ amount: 800 }))
|
|
1329
|
-
* @example
|
|
1330
|
-
* // returns true
|
|
1331
|
-
* Dinero({ amount: 800 }).greaterThan(Dinero({ amount: 500 }))
|
|
1332
|
-
* @example
|
|
1333
|
-
* // returns true
|
|
1334
|
-
* Dinero({ amount: 800 }).greaterThan(Dinero({ amount: 5000, precision: 3 }))
|
|
1335
|
-
* @example
|
|
1336
|
-
* // returns false
|
|
1337
|
-
* Dinero({ amount: 5000, precision: 3 }).greaterThan(Dinero({ amount: 800 }))
|
|
1338
|
-
*
|
|
1339
|
-
* @throws {TypeError} If `comparator` has a different currency.
|
|
1340
|
-
*
|
|
1341
|
-
* @return {Boolean}
|
|
1342
|
-
*/
|
|
1343
|
-
greaterThan: function greaterThan(comparator) {
|
|
1344
|
-
assertSameCurrency.call(this, comparator);
|
|
1345
|
-
var comparators = Dinero.normalizePrecision([this, comparator]);
|
|
1346
|
-
return comparators[0].getAmount() > comparators[1].getAmount();
|
|
1347
|
-
},
|
|
1348
|
-
|
|
1349
|
-
/**
|
|
1350
|
-
* Checks whether the value represented by this object is greater than or equal to the other.
|
|
1351
|
-
*
|
|
1352
|
-
* @param {Dinero} comparator - The Dinero object to compare to.
|
|
1353
|
-
*
|
|
1354
|
-
* @example
|
|
1355
|
-
* // returns true
|
|
1356
|
-
* Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 300 }))
|
|
1357
|
-
* @example
|
|
1358
|
-
* // returns true
|
|
1359
|
-
* Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 500 }))
|
|
1360
|
-
* @example
|
|
1361
|
-
* // returns false
|
|
1362
|
-
* Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 800 }))
|
|
1363
|
-
* @example
|
|
1364
|
-
* // returns true
|
|
1365
|
-
* Dinero({ amount: 800 }).greaterThanOrEqual(Dinero({ amount: 5000, precision: 3 }))
|
|
1366
|
-
* @example
|
|
1367
|
-
* // returns true
|
|
1368
|
-
* Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 5000, precision: 3 }))
|
|
1369
|
-
* @example
|
|
1370
|
-
* // returns false
|
|
1371
|
-
* Dinero({ amount: 5000, precision: 3 }).greaterThanOrEqual(Dinero({ amount: 800 }))
|
|
1372
|
-
*
|
|
1373
|
-
* @throws {TypeError} If `comparator` has a different currency.
|
|
1374
|
-
*
|
|
1375
|
-
* @return {Boolean}
|
|
1376
|
-
*/
|
|
1377
|
-
greaterThanOrEqual: function greaterThanOrEqual(comparator) {
|
|
1378
|
-
assertSameCurrency.call(this, comparator);
|
|
1379
|
-
var comparators = Dinero.normalizePrecision([this, comparator]);
|
|
1380
|
-
return comparators[0].getAmount() >= comparators[1].getAmount();
|
|
1381
|
-
},
|
|
1382
|
-
|
|
1383
|
-
/**
|
|
1384
|
-
* Checks if the value represented by this object is zero.
|
|
1385
|
-
*
|
|
1386
|
-
* @example
|
|
1387
|
-
* // returns true
|
|
1388
|
-
* Dinero({ amount: 0 }).isZero()
|
|
1389
|
-
* @example
|
|
1390
|
-
* // returns false
|
|
1391
|
-
* Dinero({ amount: 100 }).isZero()
|
|
1392
|
-
*
|
|
1393
|
-
* @return {Boolean}
|
|
1394
|
-
*/
|
|
1395
|
-
isZero: function isZero() {
|
|
1396
|
-
return this.getAmount() === 0;
|
|
1397
|
-
},
|
|
1398
|
-
|
|
1399
|
-
/**
|
|
1400
|
-
* Checks if the value represented by this object is positive.
|
|
1401
|
-
*
|
|
1402
|
-
* @example
|
|
1403
|
-
* // returns false
|
|
1404
|
-
* Dinero({ amount: -10 }).isPositive()
|
|
1405
|
-
* @example
|
|
1406
|
-
* // returns true
|
|
1407
|
-
* Dinero({ amount: 10 }).isPositive()
|
|
1408
|
-
* @example
|
|
1409
|
-
* // returns true
|
|
1410
|
-
* Dinero({ amount: 0 }).isPositive()
|
|
1411
|
-
*
|
|
1412
|
-
* @return {Boolean}
|
|
1413
|
-
*/
|
|
1414
|
-
isPositive: function isPositive() {
|
|
1415
|
-
return this.getAmount() >= 0;
|
|
1416
|
-
},
|
|
1417
|
-
|
|
1418
|
-
/**
|
|
1419
|
-
* Checks if the value represented by this object is negative.
|
|
1420
|
-
*
|
|
1421
|
-
* @example
|
|
1422
|
-
* // returns true
|
|
1423
|
-
* Dinero({ amount: -10 }).isNegative()
|
|
1424
|
-
* @example
|
|
1425
|
-
* // returns false
|
|
1426
|
-
* Dinero({ amount: 10 }).isNegative()
|
|
1427
|
-
* @example
|
|
1428
|
-
* // returns false
|
|
1429
|
-
* Dinero({ amount: 0 }).isNegative()
|
|
1430
|
-
*
|
|
1431
|
-
* @return {Boolean}
|
|
1432
|
-
*/
|
|
1433
|
-
isNegative: function isNegative() {
|
|
1434
|
-
return this.getAmount() < 0;
|
|
1435
|
-
},
|
|
1436
|
-
|
|
1437
|
-
/**
|
|
1438
|
-
* Checks if this has minor currency units.
|
|
1439
|
-
* Deprecates {@link module:Dinero~hasCents hasCents}.
|
|
1440
|
-
*
|
|
1441
|
-
* @example
|
|
1442
|
-
* // returns false
|
|
1443
|
-
* Dinero({ amount: 1100 }).hasSubUnits()
|
|
1444
|
-
* @example
|
|
1445
|
-
* // returns true
|
|
1446
|
-
* Dinero({ amount: 1150 }).hasSubUnits()
|
|
1447
|
-
*
|
|
1448
|
-
* @return {Boolean}
|
|
1449
|
-
*/
|
|
1450
|
-
hasSubUnits: function hasSubUnits() {
|
|
1451
|
-
return calculator$1.modulo(this.getAmount(), Math.pow(10, precision)) !== 0;
|
|
1452
|
-
},
|
|
1453
|
-
|
|
1454
|
-
/**
|
|
1455
|
-
* Checks if this has minor currency units.
|
|
1456
|
-
*
|
|
1457
|
-
* @deprecated since version 1.4.0, will be removed in 2.0.0
|
|
1458
|
-
* Use {@link module:Dinero~hasSubUnits hasSubUnits} instead.
|
|
1459
|
-
*
|
|
1460
|
-
* @example
|
|
1461
|
-
* // returns false
|
|
1462
|
-
* Dinero({ amount: 1100 }).hasCents()
|
|
1463
|
-
* @example
|
|
1464
|
-
* // returns true
|
|
1465
|
-
* Dinero({ amount: 1150 }).hasCents()
|
|
1466
|
-
*
|
|
1467
|
-
* @return {Boolean}
|
|
1468
|
-
*/
|
|
1469
|
-
hasCents: function hasCents() {
|
|
1470
|
-
return calculator$1.modulo(this.getAmount(), Math.pow(10, precision)) !== 0;
|
|
1471
|
-
},
|
|
1472
|
-
|
|
1473
|
-
/**
|
|
1474
|
-
* Checks whether the currency represented by this object equals to the other.
|
|
1475
|
-
*
|
|
1476
|
-
* @param {Dinero} comparator - The Dinero object to compare to.
|
|
1477
|
-
*
|
|
1478
|
-
* @example
|
|
1479
|
-
* // returns true
|
|
1480
|
-
* Dinero({ amount: 2000, currency: 'EUR' }).hasSameCurrency(Dinero({ amount: 1000, currency: 'EUR' }))
|
|
1481
|
-
* @example
|
|
1482
|
-
* // returns false
|
|
1483
|
-
* Dinero({ amount: 1000, currency: 'EUR' }).hasSameCurrency(Dinero({ amount: 1000, currency: 'USD' }))
|
|
1484
|
-
*
|
|
1485
|
-
* @return {Boolean}
|
|
1486
|
-
*/
|
|
1487
|
-
hasSameCurrency: function hasSameCurrency(comparator) {
|
|
1488
|
-
return this.getCurrency() === comparator.getCurrency();
|
|
1489
|
-
},
|
|
1490
|
-
|
|
1491
|
-
/**
|
|
1492
|
-
* Checks whether the amount represented by this object equals to the other.
|
|
1493
|
-
*
|
|
1494
|
-
* @param {Dinero} comparator - The Dinero object to compare to.
|
|
1495
|
-
*
|
|
1496
|
-
* @example
|
|
1497
|
-
* // returns true
|
|
1498
|
-
* Dinero({ amount: 1000, currency: 'EUR' }).hasSameAmount(Dinero({ amount: 1000 }))
|
|
1499
|
-
* @example
|
|
1500
|
-
* // returns false
|
|
1501
|
-
* Dinero({ amount: 2000, currency: 'EUR' }).hasSameAmount(Dinero({ amount: 1000, currency: 'EUR' }))
|
|
1502
|
-
* @example
|
|
1503
|
-
* // returns true
|
|
1504
|
-
* Dinero({ amount: 1000, currency: 'EUR', precision: 2 }).hasSameAmount(Dinero({ amount: 10000, precision: 3 }))
|
|
1505
|
-
* @example
|
|
1506
|
-
* // returns false
|
|
1507
|
-
* Dinero({ amount: 10000, currency: 'EUR', precision: 2 }).hasSameAmount(Dinero({ amount: 10000, precision: 3 }))
|
|
1508
|
-
*
|
|
1509
|
-
* @return {Boolean}
|
|
1510
|
-
*/
|
|
1511
|
-
hasSameAmount: function hasSameAmount(comparator) {
|
|
1512
|
-
var comparators = Dinero.normalizePrecision([this, comparator]);
|
|
1513
|
-
return comparators[0].getAmount() === comparators[1].getAmount();
|
|
1514
|
-
},
|
|
1515
|
-
|
|
1516
|
-
/**
|
|
1517
|
-
* Returns this object formatted as a string.
|
|
1518
|
-
*
|
|
1519
|
-
* The format is a mask which defines how the output string will be formatted.
|
|
1520
|
-
* It defines whether to display a currency, in what format, how many fraction digits to display and whether to use grouping separators.
|
|
1521
|
-
* The output is formatted according to the applying locale.
|
|
1522
|
-
*
|
|
1523
|
-
* Object | Format | String
|
|
1524
|
-
* :--------------------------- | :---------------- | :---
|
|
1525
|
-
* `Dinero({ amount: 500050 })` | `'$0,0.00'` | $5,000.50
|
|
1526
|
-
* `Dinero({ amount: 500050 })` | `'$0,0'` | $5,001
|
|
1527
|
-
* `Dinero({ amount: 500050 })` | `'$0'` | $5001
|
|
1528
|
-
* `Dinero({ amount: 500050 })` | `'$0.0'` | $5000.5
|
|
1529
|
-
* `Dinero({ amount: 500050 })` | `'USD0,0.0'` | USD5,000.5
|
|
1530
|
-
* `Dinero({ amount: 500050 })` | `'0,0.0 dollar'` | 5,000.5 dollars
|
|
1531
|
-
*
|
|
1532
|
-
* Don't try to substitute the `$` sign or the `USD` code with your target currency, nor adapt the format string to the exact format you want.
|
|
1533
|
-
* The format is a mask which defines a pattern and returns a valid, localized currency string.
|
|
1534
|
-
* If you want to display the object in a custom way, either use {@link module:Dinero~getAmount getAmount}, {@link module:Dinero~toUnit toUnit} or {@link module:Dinero~toRoundedUnit toRoundedUnit} and manipulate the output string as you wish.
|
|
1535
|
-
*
|
|
1536
|
-
* {@link module:Dinero~toFormat toFormat} wraps around `Number.prototype.toLocaleString`. For that reason, **format will vary depending on how it's implemented in the end user's environment**.
|
|
1537
|
-
*
|
|
1538
|
-
* You can also use `toLocaleString` directly:
|
|
1539
|
-
* `Dinero().toRoundedUnit(digits, roundingMode).toLocaleString(locale, options)`.
|
|
1540
|
-
*
|
|
1541
|
-
* By default, amounts are rounded using the **half away from zero** rule ([commercial rounding](https://en.wikipedia.org/wiki/Rounding#Round_half_away_from_zero)).
|
|
1542
|
-
* You can also specify a different `roundingMode` to better fit your needs.
|
|
1543
|
-
*
|
|
1544
|
-
* @param {String} [format='$0,0.00'] - The format mask to format to.
|
|
1545
|
-
* @param {String} [roundingMode='HALF_AWAY_FROM_ZERO'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
|
|
1546
|
-
*
|
|
1547
|
-
* @example
|
|
1548
|
-
* // returns $2,000
|
|
1549
|
-
* Dinero({ amount: 200000 }).toFormat('$0,0')
|
|
1550
|
-
* @example
|
|
1551
|
-
* // returns €50.5
|
|
1552
|
-
* Dinero({ amount: 5050, currency: 'EUR' }).toFormat('$0,0.0')
|
|
1553
|
-
* @example
|
|
1554
|
-
* // returns 100 euros
|
|
1555
|
-
* Dinero({ amount: 10000, currency: 'EUR' }).setLocale('fr-FR').toFormat('0,0 dollar')
|
|
1556
|
-
* @example
|
|
1557
|
-
* // returns 2000
|
|
1558
|
-
* Dinero({ amount: 200000, currency: 'EUR' }).toFormat()
|
|
1559
|
-
* @example
|
|
1560
|
-
* // returns $10
|
|
1561
|
-
* Dinero({ amount: 1050 }).toFormat('$0', 'HALF_EVEN')
|
|
1562
|
-
*
|
|
1563
|
-
* @return {String}
|
|
1564
|
-
*/
|
|
1565
|
-
toFormat: function toFormat() {
|
|
1566
|
-
var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : globalFormat;
|
|
1567
|
-
var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalFormatRoundingMode;
|
|
1568
|
-
var formatter = Format(format);
|
|
1569
|
-
return this.toRoundedUnit(formatter.getMinimumFractionDigits(), roundingMode).toLocaleString(this.getLocale(), {
|
|
1570
|
-
currencyDisplay: formatter.getCurrencyDisplay(),
|
|
1571
|
-
useGrouping: formatter.getUseGrouping(),
|
|
1572
|
-
minimumFractionDigits: formatter.getMinimumFractionDigits(),
|
|
1573
|
-
style: formatter.getStyle(),
|
|
1574
|
-
currency: this.getCurrency()
|
|
1575
|
-
});
|
|
1576
|
-
},
|
|
1577
|
-
|
|
1578
|
-
/**
|
|
1579
|
-
* Returns the amount represented by this object in units.
|
|
1580
|
-
*
|
|
1581
|
-
* @example
|
|
1582
|
-
* // returns 10.5
|
|
1583
|
-
* Dinero({ amount: 1050 }).toUnit()
|
|
1584
|
-
* @example
|
|
1585
|
-
* // returns 10.545
|
|
1586
|
-
* Dinero({ amount: 10545, precision: 3 }).toUnit()
|
|
1587
|
-
*
|
|
1588
|
-
* @return {Number}
|
|
1589
|
-
*/
|
|
1590
|
-
toUnit: function toUnit() {
|
|
1591
|
-
return calculator$1.divide(this.getAmount(), Math.pow(10, precision));
|
|
1592
|
-
},
|
|
1593
|
-
|
|
1594
|
-
/**
|
|
1595
|
-
* Returns the amount represented by this object in rounded units.
|
|
1596
|
-
*
|
|
1597
|
-
* By default, the method uses the **half away from zero** rule ([commercial rounding](https://en.wikipedia.org/wiki/Rounding#Round_half_away_from_zero)).
|
|
1598
|
-
* You can also specify a different `roundingMode` to better fit your needs.
|
|
1599
|
-
*
|
|
1600
|
-
* @example
|
|
1601
|
-
* // returns 10.6
|
|
1602
|
-
* Dinero({ amount: 1055 }).toRoundedUnit(1)
|
|
1603
|
-
* @example
|
|
1604
|
-
* // returns 10
|
|
1605
|
-
* Dinero({ amount: 1050 }).toRoundedUnit(0, 'HALF_EVEN')
|
|
1606
|
-
*
|
|
1607
|
-
* @param {Number} digits - The number of fraction digits to round to.
|
|
1608
|
-
* @param {String} [roundingMode='HALF_AWAY_FROM_ZERO'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
|
|
1609
|
-
*
|
|
1610
|
-
* @return {Number}
|
|
1611
|
-
*/
|
|
1612
|
-
toRoundedUnit: function toRoundedUnit(digits) {
|
|
1613
|
-
var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalFormatRoundingMode;
|
|
1614
|
-
var factor = Math.pow(10, digits);
|
|
1615
|
-
return calculator$1.divide(calculator$1.round(calculator$1.multiply(this.toUnit(), factor), roundingMode), factor);
|
|
1616
|
-
},
|
|
1617
|
-
|
|
1618
|
-
/**
|
|
1619
|
-
* Returns the object's data as an object literal.
|
|
1620
|
-
*
|
|
1621
|
-
* @example
|
|
1622
|
-
* // returns { amount: 500, currency: 'EUR', precision: 2 }
|
|
1623
|
-
* Dinero({ amount: 500, currency: 'EUR', precision: 2 }).toObject()
|
|
1624
|
-
*
|
|
1625
|
-
* @return {Object}
|
|
1626
|
-
*/
|
|
1627
|
-
toObject: function toObject() {
|
|
1628
|
-
return {
|
|
1629
|
-
amount: amount,
|
|
1630
|
-
currency: currency,
|
|
1631
|
-
precision: precision
|
|
1632
|
-
};
|
|
1633
|
-
},
|
|
1634
|
-
|
|
1635
|
-
/**
|
|
1636
|
-
* Returns the object's data as an object literal.
|
|
1637
|
-
*
|
|
1638
|
-
* Alias of {@link module:Dinero~toObject toObject}.
|
|
1639
|
-
* It is defined so that calling `JSON.stringify` on a Dinero object will automatically extract the relevant data.
|
|
1640
|
-
*
|
|
1641
|
-
* @example
|
|
1642
|
-
* // returns '{"amount":500,"currency":"EUR","precision":2}'
|
|
1643
|
-
* JSON.stringify(Dinero({ amount: 500, currency: 'EUR', precision: 2 }))
|
|
1644
|
-
*
|
|
1645
|
-
* @return {Object}
|
|
1646
|
-
*/
|
|
1647
|
-
toJSON: function toJSON() {
|
|
1648
|
-
return this.toObject();
|
|
1649
|
-
}
|
|
1650
|
-
};
|
|
1651
|
-
};
|
|
1652
|
-
|
|
1653
|
-
var dinero = Object.assign(Dinero, Defaults, Globals, Static);
|
|
1654
|
-
|
|
1655
|
-
export { dinero as d };
|