stripe-pwa-elements 3.0.0-0 → 3.0.0
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/app-globals-V2Kpy_OQ.js +8 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js.map +1 -0
- package/dist/cjs/index-BmB5d_Yj.js +194 -0
- package/dist/cjs/index-BmB5d_Yj.js.map +1 -0
- package/dist/cjs/index-CQkz7IJv.js +1904 -0
- package/dist/cjs/index-CQkz7IJv.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -2
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/ion-icon.cjs.entry.js +339 -252
- package/dist/cjs/ion-icon.entry.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js +7 -17
- package/dist/cjs/loader.cjs.js.map +1 -1
- package/dist/cjs/stripe-card-element-modal.cjs.entry.js +111 -0
- package/dist/cjs/stripe-card-element-modal.entry.cjs.js.map +1 -0
- package/dist/cjs/stripe-card-element.stripe-modal.entry.cjs.js.map +1 -0
- package/dist/cjs/stripe-card-element_2.cjs.entry.js +3677 -0
- package/dist/cjs/stripe-elements.cjs.js +16 -18
- package/dist/cjs/stripe-elements.cjs.js.map +1 -1
- package/dist/cjs/stripe-payment-request-button.cjs.entry.js +170 -162
- package/dist/cjs/stripe-payment-request-button.entry.cjs.js.map +1 -0
- package/dist/collection/collection-manifest.json +6 -6
- package/dist/collection/components/{stripe-payment-sheet/stripe-payment-sheet.css → stripe-card-element/stripe-card-element.css} +6 -4
- package/dist/collection/components/stripe-card-element/stripe-card-element.js +878 -0
- package/dist/collection/components/stripe-card-element/stripe-card-element.js.map +1 -0
- package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js +547 -0
- package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js.map +1 -0
- package/dist/collection/components/stripe-modal/stripe-modal.js +177 -0
- package/dist/collection/components/stripe-modal/stripe-modal.js.map +1 -0
- package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js +539 -500
- package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js.map +1 -1
- package/dist/collection/index.js +1 -1
- package/dist/collection/interfaces.js.map +1 -1
- package/dist/collection/services/card-element-manager.js +147 -0
- package/dist/collection/services/card-element-manager.js.map +1 -0
- package/dist/collection/services/factory.js +28 -0
- package/dist/collection/services/factory.js.map +1 -0
- package/dist/collection/services/interfaces.js +2 -0
- package/dist/collection/services/interfaces.js.map +1 -0
- package/dist/collection/services/stripe-service.js +118 -0
- package/dist/collection/services/stripe-service.js.map +1 -0
- package/dist/collection/utils/error.js +12 -0
- package/dist/collection/utils/error.js.map +1 -0
- package/dist/collection/utils/i18n.js +40 -40
- package/dist/collection/utils/i18n.js.map +1 -1
- package/dist/collection/utils/platform.js +51 -51
- package/dist/collection/utils/platform.js.map +1 -1
- package/dist/collection/utils/utils.js +22 -22
- package/dist/collection/utils/utils.js.map +1 -1
- package/dist/components/icon.js +375 -276
- package/dist/components/icon.js.map +1 -1
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.js +2 -1
- package/dist/components/ion-icon.js +1 -0
- package/dist/components/stripe-card-element-modal.d.ts +11 -0
- package/dist/components/stripe-card-element-modal.js +174 -0
- package/dist/components/stripe-card-element-modal.js.map +1 -0
- package/dist/components/{stripe-payment.d.ts → stripe-card-element.d.ts} +4 -4
- package/dist/components/stripe-card-element.js +9 -0
- package/dist/components/stripe-card-element.js.map +1 -0
- package/dist/components/stripe-card-element2.js +3586 -0
- package/dist/components/stripe-card-element2.js.map +1 -0
- package/dist/components/{stripe-sheet.d.ts → stripe-modal.d.ts} +4 -4
- package/dist/components/stripe-modal.js +9 -0
- package/dist/components/stripe-modal.js.map +1 -0
- package/dist/components/stripe-modal2.js +87 -0
- package/dist/components/stripe-modal2.js.map +1 -0
- package/dist/components/stripe-payment-request-button.d.ts +2 -2
- package/dist/components/stripe-payment-request-button.js +1 -0
- package/dist/components/stripe-payment-request-button2.js +299 -225
- package/dist/components/stripe-payment-request-button2.js.map +1 -1
- package/dist/components/utils.js +54 -70
- package/dist/components/utils.js.map +1 -1
- package/dist/esm/app-globals-DQuL1Twl.js +6 -0
- package/dist/esm/app-globals-DQuL1Twl.js.map +1 -0
- package/dist/esm/index-C5QyifTT.js +192 -0
- package/dist/esm/index-C5QyifTT.js.map +1 -0
- package/dist/esm/index-DB2hiILr.js +1892 -0
- package/dist/esm/index-DB2hiILr.js.map +1 -0
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/ion-icon.entry.js +339 -250
- package/dist/esm/ion-icon.entry.js.map +1 -1
- package/dist/esm/loader.js +9 -17
- package/dist/esm/loader.js.map +1 -1
- package/dist/esm/stripe-card-element-modal.entry.js +109 -0
- package/dist/esm/stripe-card-element-modal.entry.js.map +1 -0
- package/dist/esm/stripe-card-element.stripe-modal.entry.js.map +1 -0
- package/dist/esm/stripe-card-element_2.entry.js +3674 -0
- package/dist/esm/stripe-elements.js +16 -17
- package/dist/esm/stripe-elements.js.map +1 -1
- package/dist/esm/stripe-payment-request-button.entry.js +170 -160
- package/dist/esm/stripe-payment-request-button.entry.js.map +1 -1
- package/dist/stripe-elements/index.esm.js.map +1 -1
- package/dist/stripe-elements/ion-icon.entry.esm.js.map +1 -0
- package/dist/stripe-elements/loader.esm.js.map +1 -0
- package/dist/stripe-elements/p-263cf51d.entry.js +2 -0
- package/dist/stripe-elements/p-263cf51d.entry.js.map +1 -0
- package/dist/stripe-elements/p-5beb3870.entry.js +2 -0
- package/dist/stripe-elements/p-5beb3870.entry.js.map +1 -0
- package/dist/stripe-elements/p-C5QyifTT.js +2 -0
- package/dist/stripe-elements/p-C5QyifTT.js.map +1 -0
- package/dist/stripe-elements/p-DB2hiILr.js +3 -0
- package/dist/stripe-elements/p-DB2hiILr.js.map +1 -0
- package/dist/stripe-elements/p-DQuL1Twl.js +2 -0
- package/dist/stripe-elements/p-DQuL1Twl.js.map +1 -0
- package/dist/stripe-elements/p-b598431f.entry.js +2 -0
- package/dist/stripe-elements/p-b598431f.entry.js.map +1 -0
- package/dist/stripe-elements/p-bb923a08.entry.js +2 -0
- package/dist/stripe-elements/p-bb923a08.entry.js.map +1 -0
- package/dist/stripe-elements/stripe-card-element-modal.entry.esm.js.map +1 -0
- package/dist/stripe-elements/stripe-card-element.stripe-modal.entry.esm.js.map +1 -0
- package/dist/stripe-elements/stripe-elements.esm.js +1 -1
- package/dist/stripe-elements/stripe-elements.esm.js.map +1 -1
- package/dist/stripe-elements/stripe-payment-request-button.entry.esm.js.map +1 -0
- package/dist/stripe-elements/svg/accessibility-outline.svg +1 -1
- package/dist/stripe-elements/svg/accessibility-sharp.svg +1 -1
- package/dist/stripe-elements/svg/accessibility.svg +1 -1
- package/dist/stripe-elements/svg/add-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/add-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/add-circle.svg +1 -1
- package/dist/stripe-elements/svg/add-outline.svg +1 -1
- package/dist/stripe-elements/svg/add-sharp.svg +1 -1
- package/dist/stripe-elements/svg/add.svg +1 -1
- package/dist/stripe-elements/svg/airplane-outline.svg +1 -1
- package/dist/stripe-elements/svg/airplane-sharp.svg +1 -1
- package/dist/stripe-elements/svg/airplane.svg +1 -1
- package/dist/stripe-elements/svg/alarm-outline.svg +1 -1
- package/dist/stripe-elements/svg/alarm-sharp.svg +1 -1
- package/dist/stripe-elements/svg/alarm.svg +1 -1
- package/dist/stripe-elements/svg/albums-outline.svg +1 -1
- package/dist/stripe-elements/svg/albums-sharp.svg +1 -1
- package/dist/stripe-elements/svg/albums.svg +1 -1
- package/dist/stripe-elements/svg/alert-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/alert-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/alert-circle.svg +1 -1
- package/dist/stripe-elements/svg/alert-outline.svg +1 -1
- package/dist/stripe-elements/svg/alert-sharp.svg +1 -1
- package/dist/stripe-elements/svg/alert.svg +1 -1
- package/dist/stripe-elements/svg/american-football-outline.svg +1 -1
- package/dist/stripe-elements/svg/american-football-sharp.svg +1 -1
- package/dist/stripe-elements/svg/american-football.svg +1 -1
- package/dist/stripe-elements/svg/analytics-outline.svg +1 -1
- package/dist/stripe-elements/svg/analytics-sharp.svg +1 -1
- package/dist/stripe-elements/svg/analytics.svg +1 -1
- package/dist/stripe-elements/svg/aperture-outline.svg +1 -1
- package/dist/stripe-elements/svg/aperture-sharp.svg +1 -1
- package/dist/stripe-elements/svg/aperture.svg +1 -1
- package/dist/stripe-elements/svg/apps-outline.svg +1 -1
- package/dist/stripe-elements/svg/apps-sharp.svg +1 -1
- package/dist/stripe-elements/svg/apps.svg +1 -1
- package/dist/stripe-elements/svg/archive-outline.svg +1 -1
- package/dist/stripe-elements/svg/archive-sharp.svg +1 -1
- package/dist/stripe-elements/svg/archive.svg +1 -1
- package/dist/stripe-elements/svg/arrow-back-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/arrow-back-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/arrow-back-circle.svg +1 -1
- package/dist/stripe-elements/svg/arrow-back-outline.svg +1 -1
- package/dist/stripe-elements/svg/arrow-back-sharp.svg +1 -1
- package/dist/stripe-elements/svg/arrow-back.svg +1 -1
- package/dist/stripe-elements/svg/arrow-down-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/arrow-down-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/arrow-down-circle.svg +1 -1
- package/dist/stripe-elements/svg/arrow-down-left-box-outline.svg +1 -0
- package/dist/stripe-elements/svg/arrow-down-left-box-sharp.svg +1 -0
- package/dist/stripe-elements/svg/arrow-down-left-box.svg +1 -0
- package/dist/stripe-elements/svg/arrow-down-outline.svg +1 -1
- package/dist/stripe-elements/svg/arrow-down-right-box-outline.svg +1 -0
- package/dist/stripe-elements/svg/arrow-down-right-box-sharp.svg +1 -0
- package/dist/stripe-elements/svg/arrow-down-right-box.svg +1 -0
- package/dist/stripe-elements/svg/arrow-down-sharp.svg +1 -1
- package/dist/stripe-elements/svg/arrow-down.svg +1 -1
- package/dist/stripe-elements/svg/arrow-forward-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/arrow-forward-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/arrow-forward-circle.svg +1 -1
- package/dist/stripe-elements/svg/arrow-forward-outline.svg +1 -1
- package/dist/stripe-elements/svg/arrow-forward-sharp.svg +1 -1
- package/dist/stripe-elements/svg/arrow-forward.svg +1 -1
- package/dist/stripe-elements/svg/arrow-redo-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/arrow-redo-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/arrow-redo-circle.svg +1 -1
- package/dist/stripe-elements/svg/arrow-redo-outline.svg +1 -1
- package/dist/stripe-elements/svg/arrow-redo-sharp.svg +1 -1
- package/dist/stripe-elements/svg/arrow-redo.svg +1 -1
- package/dist/stripe-elements/svg/arrow-undo-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/arrow-undo-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/arrow-undo-circle.svg +1 -1
- package/dist/stripe-elements/svg/arrow-undo-outline.svg +1 -1
- package/dist/stripe-elements/svg/arrow-undo-sharp.svg +1 -1
- package/dist/stripe-elements/svg/arrow-undo.svg +1 -1
- package/dist/stripe-elements/svg/arrow-up-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/arrow-up-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/arrow-up-circle.svg +1 -1
- package/dist/stripe-elements/svg/arrow-up-left-box-outline.svg +1 -0
- package/dist/stripe-elements/svg/arrow-up-left-box-sharp.svg +1 -0
- package/dist/stripe-elements/svg/arrow-up-left-box.svg +1 -0
- package/dist/stripe-elements/svg/arrow-up-outline.svg +1 -1
- package/dist/stripe-elements/svg/arrow-up-right-box-outline.svg +1 -0
- package/dist/stripe-elements/svg/arrow-up-right-box-sharp.svg +1 -0
- package/dist/stripe-elements/svg/arrow-up-right-box.svg +1 -0
- package/dist/stripe-elements/svg/arrow-up-sharp.svg +1 -1
- package/dist/stripe-elements/svg/arrow-up.svg +1 -1
- package/dist/stripe-elements/svg/at-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/at-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/at-circle.svg +1 -1
- package/dist/stripe-elements/svg/at-outline.svg +1 -1
- package/dist/stripe-elements/svg/at-sharp.svg +1 -1
- package/dist/stripe-elements/svg/at.svg +1 -1
- package/dist/stripe-elements/svg/attach-outline.svg +1 -1
- package/dist/stripe-elements/svg/attach-sharp.svg +1 -1
- package/dist/stripe-elements/svg/attach.svg +1 -1
- package/dist/stripe-elements/svg/backspace-outline.svg +1 -1
- package/dist/stripe-elements/svg/backspace-sharp.svg +1 -1
- package/dist/stripe-elements/svg/backspace.svg +1 -1
- package/dist/stripe-elements/svg/bag-add-outline.svg +1 -1
- package/dist/stripe-elements/svg/bag-add-sharp.svg +1 -1
- package/dist/stripe-elements/svg/bag-add.svg +1 -1
- package/dist/stripe-elements/svg/bag-check-outline.svg +1 -1
- package/dist/stripe-elements/svg/bag-check-sharp.svg +1 -1
- package/dist/stripe-elements/svg/bag-check.svg +1 -1
- package/dist/stripe-elements/svg/bag-handle-outline.svg +1 -1
- package/dist/stripe-elements/svg/bag-handle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/bag-handle.svg +1 -1
- package/dist/stripe-elements/svg/bag-outline.svg +1 -1
- package/dist/stripe-elements/svg/bag-remove-outline.svg +1 -1
- package/dist/stripe-elements/svg/bag-remove-sharp.svg +1 -1
- package/dist/stripe-elements/svg/bag-remove.svg +1 -1
- package/dist/stripe-elements/svg/bag-sharp.svg +1 -1
- package/dist/stripe-elements/svg/bag.svg +1 -1
- package/dist/stripe-elements/svg/balloon-outline.svg +1 -1
- package/dist/stripe-elements/svg/balloon-sharp.svg +1 -1
- package/dist/stripe-elements/svg/balloon.svg +1 -1
- package/dist/stripe-elements/svg/ban-outline.svg +1 -1
- package/dist/stripe-elements/svg/ban-sharp.svg +1 -1
- package/dist/stripe-elements/svg/ban.svg +1 -1
- package/dist/stripe-elements/svg/bandage-outline.svg +1 -1
- package/dist/stripe-elements/svg/bandage-sharp.svg +1 -1
- package/dist/stripe-elements/svg/bandage.svg +1 -1
- package/dist/stripe-elements/svg/bar-chart-outline.svg +1 -1
- package/dist/stripe-elements/svg/bar-chart-sharp.svg +1 -1
- package/dist/stripe-elements/svg/bar-chart.svg +1 -1
- package/dist/stripe-elements/svg/barbell-outline.svg +1 -1
- package/dist/stripe-elements/svg/barbell-sharp.svg +1 -1
- package/dist/stripe-elements/svg/barbell.svg +1 -1
- package/dist/stripe-elements/svg/barcode-outline.svg +1 -1
- package/dist/stripe-elements/svg/barcode-sharp.svg +1 -1
- package/dist/stripe-elements/svg/barcode.svg +1 -1
- package/dist/stripe-elements/svg/baseball-outline.svg +1 -1
- package/dist/stripe-elements/svg/baseball-sharp.svg +1 -1
- package/dist/stripe-elements/svg/baseball.svg +1 -1
- package/dist/stripe-elements/svg/basket-outline.svg +1 -1
- package/dist/stripe-elements/svg/basket-sharp.svg +1 -1
- package/dist/stripe-elements/svg/basket.svg +1 -1
- package/dist/stripe-elements/svg/basketball-outline.svg +1 -1
- package/dist/stripe-elements/svg/basketball-sharp.svg +1 -1
- package/dist/stripe-elements/svg/basketball.svg +1 -1
- package/dist/stripe-elements/svg/battery-charging-outline.svg +1 -1
- package/dist/stripe-elements/svg/battery-charging-sharp.svg +1 -1
- package/dist/stripe-elements/svg/battery-charging.svg +1 -1
- package/dist/stripe-elements/svg/battery-dead-outline.svg +1 -1
- package/dist/stripe-elements/svg/battery-dead-sharp.svg +1 -1
- package/dist/stripe-elements/svg/battery-dead.svg +1 -1
- package/dist/stripe-elements/svg/battery-full-outline.svg +1 -1
- package/dist/stripe-elements/svg/battery-full-sharp.svg +1 -1
- package/dist/stripe-elements/svg/battery-full.svg +1 -1
- package/dist/stripe-elements/svg/battery-half-outline.svg +1 -1
- package/dist/stripe-elements/svg/battery-half-sharp.svg +1 -1
- package/dist/stripe-elements/svg/battery-half.svg +1 -1
- package/dist/stripe-elements/svg/beaker-outline.svg +1 -1
- package/dist/stripe-elements/svg/beaker-sharp.svg +1 -1
- package/dist/stripe-elements/svg/beaker.svg +1 -1
- package/dist/stripe-elements/svg/bed-outline.svg +1 -1
- package/dist/stripe-elements/svg/bed-sharp.svg +1 -1
- package/dist/stripe-elements/svg/bed.svg +1 -1
- package/dist/stripe-elements/svg/beer-outline.svg +1 -1
- package/dist/stripe-elements/svg/beer-sharp.svg +1 -1
- package/dist/stripe-elements/svg/beer.svg +1 -1
- package/dist/stripe-elements/svg/bicycle-outline.svg +1 -1
- package/dist/stripe-elements/svg/bicycle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/bicycle.svg +1 -1
- package/dist/stripe-elements/svg/binoculars-outline.svg +1 -0
- package/dist/stripe-elements/svg/binoculars-sharp.svg +1 -0
- package/dist/stripe-elements/svg/binoculars.svg +1 -0
- package/dist/stripe-elements/svg/bluetooth-outline.svg +1 -1
- package/dist/stripe-elements/svg/bluetooth-sharp.svg +1 -1
- package/dist/stripe-elements/svg/bluetooth.svg +1 -1
- package/dist/stripe-elements/svg/boat-outline.svg +1 -1
- package/dist/stripe-elements/svg/boat-sharp.svg +1 -1
- package/dist/stripe-elements/svg/boat.svg +1 -1
- package/dist/stripe-elements/svg/body-outline.svg +1 -1
- package/dist/stripe-elements/svg/body-sharp.svg +1 -1
- package/dist/stripe-elements/svg/body.svg +1 -1
- package/dist/stripe-elements/svg/bonfire-outline.svg +1 -1
- package/dist/stripe-elements/svg/bonfire-sharp.svg +1 -1
- package/dist/stripe-elements/svg/bonfire.svg +1 -1
- package/dist/stripe-elements/svg/book-outline.svg +1 -1
- package/dist/stripe-elements/svg/book-sharp.svg +1 -1
- package/dist/stripe-elements/svg/book.svg +1 -1
- package/dist/stripe-elements/svg/bookmark-outline.svg +1 -1
- package/dist/stripe-elements/svg/bookmark-sharp.svg +1 -1
- package/dist/stripe-elements/svg/bookmark.svg +1 -1
- package/dist/stripe-elements/svg/bookmarks-outline.svg +1 -1
- package/dist/stripe-elements/svg/bookmarks-sharp.svg +1 -1
- package/dist/stripe-elements/svg/bookmarks.svg +1 -1
- package/dist/stripe-elements/svg/bowling-ball-outline.svg +1 -1
- package/dist/stripe-elements/svg/bowling-ball-sharp.svg +1 -1
- package/dist/stripe-elements/svg/bowling-ball.svg +1 -1
- package/dist/stripe-elements/svg/briefcase-outline.svg +1 -1
- package/dist/stripe-elements/svg/briefcase-sharp.svg +1 -1
- package/dist/stripe-elements/svg/briefcase.svg +1 -1
- package/dist/stripe-elements/svg/browsers-outline.svg +1 -1
- package/dist/stripe-elements/svg/browsers-sharp.svg +1 -1
- package/dist/stripe-elements/svg/browsers.svg +1 -1
- package/dist/stripe-elements/svg/brush-outline.svg +1 -1
- package/dist/stripe-elements/svg/brush-sharp.svg +1 -1
- package/dist/stripe-elements/svg/brush.svg +1 -1
- package/dist/stripe-elements/svg/bug-outline.svg +1 -1
- package/dist/stripe-elements/svg/bug-sharp.svg +1 -1
- package/dist/stripe-elements/svg/bug.svg +1 -1
- package/dist/stripe-elements/svg/build-outline.svg +1 -1
- package/dist/stripe-elements/svg/build-sharp.svg +1 -1
- package/dist/stripe-elements/svg/build.svg +1 -1
- package/dist/stripe-elements/svg/bulb-outline.svg +1 -1
- package/dist/stripe-elements/svg/bulb-sharp.svg +1 -1
- package/dist/stripe-elements/svg/bulb.svg +1 -1
- package/dist/stripe-elements/svg/bus-outline.svg +1 -1
- package/dist/stripe-elements/svg/bus-sharp.svg +1 -1
- package/dist/stripe-elements/svg/bus.svg +1 -1
- package/dist/stripe-elements/svg/business-outline.svg +1 -1
- package/dist/stripe-elements/svg/business-sharp.svg +1 -1
- package/dist/stripe-elements/svg/business.svg +1 -1
- package/dist/stripe-elements/svg/cafe-outline.svg +1 -1
- package/dist/stripe-elements/svg/cafe-sharp.svg +1 -1
- package/dist/stripe-elements/svg/cafe.svg +1 -1
- package/dist/stripe-elements/svg/calculator-outline.svg +1 -1
- package/dist/stripe-elements/svg/calculator-sharp.svg +1 -1
- package/dist/stripe-elements/svg/calculator.svg +1 -1
- package/dist/stripe-elements/svg/calendar-clear-outline.svg +1 -1
- package/dist/stripe-elements/svg/calendar-clear-sharp.svg +1 -1
- package/dist/stripe-elements/svg/calendar-clear.svg +1 -1
- package/dist/stripe-elements/svg/calendar-number-outline.svg +1 -1
- package/dist/stripe-elements/svg/calendar-number-sharp.svg +1 -1
- package/dist/stripe-elements/svg/calendar-number.svg +1 -1
- package/dist/stripe-elements/svg/calendar-outline.svg +1 -1
- package/dist/stripe-elements/svg/calendar-sharp.svg +1 -1
- package/dist/stripe-elements/svg/calendar.svg +1 -1
- package/dist/stripe-elements/svg/call-outline.svg +1 -1
- package/dist/stripe-elements/svg/call-sharp.svg +1 -1
- package/dist/stripe-elements/svg/call.svg +1 -1
- package/dist/stripe-elements/svg/camera-outline.svg +1 -1
- package/dist/stripe-elements/svg/camera-reverse-outline.svg +1 -1
- package/dist/stripe-elements/svg/camera-reverse-sharp.svg +1 -1
- package/dist/stripe-elements/svg/camera-reverse.svg +1 -1
- package/dist/stripe-elements/svg/camera-sharp.svg +1 -1
- package/dist/stripe-elements/svg/camera.svg +1 -1
- package/dist/stripe-elements/svg/car-outline.svg +1 -1
- package/dist/stripe-elements/svg/car-sharp.svg +1 -1
- package/dist/stripe-elements/svg/car-sport-outline.svg +1 -1
- package/dist/stripe-elements/svg/car-sport-sharp.svg +1 -1
- package/dist/stripe-elements/svg/car-sport.svg +1 -1
- package/dist/stripe-elements/svg/car.svg +1 -1
- package/dist/stripe-elements/svg/card-outline.svg +1 -1
- package/dist/stripe-elements/svg/card-sharp.svg +1 -1
- package/dist/stripe-elements/svg/card.svg +1 -1
- package/dist/stripe-elements/svg/caret-back-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/caret-back-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/caret-back-circle.svg +1 -1
- package/dist/stripe-elements/svg/caret-back-outline.svg +1 -1
- package/dist/stripe-elements/svg/caret-back-sharp.svg +1 -1
- package/dist/stripe-elements/svg/caret-back.svg +1 -1
- package/dist/stripe-elements/svg/caret-down-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/caret-down-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/caret-down-circle.svg +1 -1
- package/dist/stripe-elements/svg/caret-down-outline.svg +1 -1
- package/dist/stripe-elements/svg/caret-down-sharp.svg +1 -1
- package/dist/stripe-elements/svg/caret-down.svg +1 -1
- package/dist/stripe-elements/svg/caret-forward-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/caret-forward-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/caret-forward-circle.svg +1 -1
- package/dist/stripe-elements/svg/caret-forward-outline.svg +1 -1
- package/dist/stripe-elements/svg/caret-forward-sharp.svg +1 -1
- package/dist/stripe-elements/svg/caret-forward.svg +1 -1
- package/dist/stripe-elements/svg/caret-up-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/caret-up-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/caret-up-circle.svg +1 -1
- package/dist/stripe-elements/svg/caret-up-outline.svg +1 -1
- package/dist/stripe-elements/svg/caret-up-sharp.svg +1 -1
- package/dist/stripe-elements/svg/caret-up.svg +1 -1
- package/dist/stripe-elements/svg/cart-outline.svg +1 -1
- package/dist/stripe-elements/svg/cart-sharp.svg +1 -1
- package/dist/stripe-elements/svg/cart.svg +1 -1
- package/dist/stripe-elements/svg/cash-outline.svg +1 -1
- package/dist/stripe-elements/svg/cash-sharp.svg +1 -1
- package/dist/stripe-elements/svg/cash.svg +1 -1
- package/dist/stripe-elements/svg/cellular-outline.svg +1 -1
- package/dist/stripe-elements/svg/cellular-sharp.svg +1 -1
- package/dist/stripe-elements/svg/cellular.svg +1 -1
- package/dist/stripe-elements/svg/chatbox-ellipses-outline.svg +1 -1
- package/dist/stripe-elements/svg/chatbox-ellipses-sharp.svg +1 -1
- package/dist/stripe-elements/svg/chatbox-ellipses.svg +1 -1
- package/dist/stripe-elements/svg/chatbox-outline.svg +1 -1
- package/dist/stripe-elements/svg/chatbox-sharp.svg +1 -1
- package/dist/stripe-elements/svg/chatbox.svg +1 -1
- package/dist/stripe-elements/svg/chatbubble-ellipses-outline.svg +1 -1
- package/dist/stripe-elements/svg/chatbubble-ellipses-sharp.svg +1 -1
- package/dist/stripe-elements/svg/chatbubble-ellipses.svg +1 -1
- package/dist/stripe-elements/svg/chatbubble-outline.svg +1 -1
- package/dist/stripe-elements/svg/chatbubble-sharp.svg +1 -1
- package/dist/stripe-elements/svg/chatbubble.svg +1 -1
- package/dist/stripe-elements/svg/chatbubbles-outline.svg +1 -1
- package/dist/stripe-elements/svg/chatbubbles-sharp.svg +1 -1
- package/dist/stripe-elements/svg/chatbubbles.svg +1 -1
- package/dist/stripe-elements/svg/checkbox-outline.svg +1 -1
- package/dist/stripe-elements/svg/checkbox-sharp.svg +1 -1
- package/dist/stripe-elements/svg/checkbox.svg +1 -1
- package/dist/stripe-elements/svg/checkmark-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/checkmark-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/checkmark-circle.svg +1 -1
- package/dist/stripe-elements/svg/checkmark-done-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/checkmark-done-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/checkmark-done-circle.svg +1 -1
- package/dist/stripe-elements/svg/checkmark-done-outline.svg +1 -1
- package/dist/stripe-elements/svg/checkmark-done-sharp.svg +1 -1
- package/dist/stripe-elements/svg/checkmark-done.svg +1 -1
- package/dist/stripe-elements/svg/checkmark-outline.svg +1 -1
- package/dist/stripe-elements/svg/checkmark-sharp.svg +1 -1
- package/dist/stripe-elements/svg/checkmark.svg +1 -1
- package/dist/stripe-elements/svg/chevron-back-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/chevron-back-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/chevron-back-circle.svg +1 -1
- package/dist/stripe-elements/svg/chevron-back-outline.svg +1 -1
- package/dist/stripe-elements/svg/chevron-back-sharp.svg +1 -1
- package/dist/stripe-elements/svg/chevron-back.svg +1 -1
- package/dist/stripe-elements/svg/chevron-collapse-outline.svg +1 -1
- package/dist/stripe-elements/svg/chevron-collapse-sharp.svg +1 -1
- package/dist/stripe-elements/svg/chevron-collapse.svg +1 -1
- package/dist/stripe-elements/svg/chevron-down-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/chevron-down-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/chevron-down-circle.svg +1 -1
- package/dist/stripe-elements/svg/chevron-down-outline.svg +1 -1
- package/dist/stripe-elements/svg/chevron-down-sharp.svg +1 -1
- package/dist/stripe-elements/svg/chevron-down.svg +1 -1
- package/dist/stripe-elements/svg/chevron-expand-outline.svg +1 -1
- package/dist/stripe-elements/svg/chevron-expand-sharp.svg +1 -1
- package/dist/stripe-elements/svg/chevron-expand.svg +1 -1
- package/dist/stripe-elements/svg/chevron-forward-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/chevron-forward-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/chevron-forward-circle.svg +1 -1
- package/dist/stripe-elements/svg/chevron-forward-outline.svg +1 -1
- package/dist/stripe-elements/svg/chevron-forward-sharp.svg +1 -1
- package/dist/stripe-elements/svg/chevron-forward.svg +1 -1
- package/dist/stripe-elements/svg/chevron-up-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/chevron-up-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/chevron-up-circle.svg +1 -1
- package/dist/stripe-elements/svg/chevron-up-outline.svg +1 -1
- package/dist/stripe-elements/svg/chevron-up-sharp.svg +1 -1
- package/dist/stripe-elements/svg/chevron-up.svg +1 -1
- package/dist/stripe-elements/svg/clipboard-outline.svg +1 -1
- package/dist/stripe-elements/svg/clipboard-sharp.svg +1 -1
- package/dist/stripe-elements/svg/clipboard.svg +1 -1
- package/dist/stripe-elements/svg/close-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/close-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/close-circle.svg +1 -1
- package/dist/stripe-elements/svg/close-outline.svg +1 -1
- package/dist/stripe-elements/svg/close-sharp.svg +1 -1
- package/dist/stripe-elements/svg/close.svg +1 -1
- package/dist/stripe-elements/svg/cloud-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/cloud-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/cloud-circle.svg +1 -1
- package/dist/stripe-elements/svg/cloud-done-outline.svg +1 -1
- package/dist/stripe-elements/svg/cloud-done-sharp.svg +1 -1
- package/dist/stripe-elements/svg/cloud-done.svg +1 -1
- package/dist/stripe-elements/svg/cloud-download-outline.svg +1 -1
- package/dist/stripe-elements/svg/cloud-download-sharp.svg +1 -1
- package/dist/stripe-elements/svg/cloud-download.svg +1 -1
- package/dist/stripe-elements/svg/cloud-offline-outline.svg +1 -1
- package/dist/stripe-elements/svg/cloud-offline-sharp.svg +1 -1
- package/dist/stripe-elements/svg/cloud-offline.svg +1 -1
- package/dist/stripe-elements/svg/cloud-outline.svg +1 -1
- package/dist/stripe-elements/svg/cloud-sharp.svg +1 -1
- package/dist/stripe-elements/svg/cloud-upload-outline.svg +1 -1
- package/dist/stripe-elements/svg/cloud-upload-sharp.svg +1 -1
- package/dist/stripe-elements/svg/cloud-upload.svg +1 -1
- package/dist/stripe-elements/svg/cloud.svg +1 -1
- package/dist/stripe-elements/svg/cloudy-night-outline.svg +1 -1
- package/dist/stripe-elements/svg/cloudy-night-sharp.svg +1 -1
- package/dist/stripe-elements/svg/cloudy-night.svg +1 -1
- package/dist/stripe-elements/svg/cloudy-outline.svg +1 -1
- package/dist/stripe-elements/svg/cloudy-sharp.svg +1 -1
- package/dist/stripe-elements/svg/cloudy.svg +1 -1
- package/dist/stripe-elements/svg/code-download-outline.svg +1 -1
- package/dist/stripe-elements/svg/code-download-sharp.svg +1 -1
- package/dist/stripe-elements/svg/code-download.svg +1 -1
- package/dist/stripe-elements/svg/code-outline.svg +1 -1
- package/dist/stripe-elements/svg/code-sharp.svg +1 -1
- package/dist/stripe-elements/svg/code-slash-outline.svg +1 -1
- package/dist/stripe-elements/svg/code-slash-sharp.svg +1 -1
- package/dist/stripe-elements/svg/code-slash.svg +1 -1
- package/dist/stripe-elements/svg/code-working-outline.svg +1 -1
- package/dist/stripe-elements/svg/code-working-sharp.svg +1 -1
- package/dist/stripe-elements/svg/code-working.svg +1 -1
- package/dist/stripe-elements/svg/code.svg +1 -1
- package/dist/stripe-elements/svg/cog-outline.svg +1 -1
- package/dist/stripe-elements/svg/cog-sharp.svg +1 -1
- package/dist/stripe-elements/svg/cog.svg +1 -1
- package/dist/stripe-elements/svg/color-fill-outline.svg +1 -1
- package/dist/stripe-elements/svg/color-fill-sharp.svg +1 -1
- package/dist/stripe-elements/svg/color-fill.svg +1 -1
- package/dist/stripe-elements/svg/color-filter-outline.svg +1 -1
- package/dist/stripe-elements/svg/color-filter-sharp.svg +1 -1
- package/dist/stripe-elements/svg/color-filter.svg +1 -1
- package/dist/stripe-elements/svg/color-palette-outline.svg +1 -1
- package/dist/stripe-elements/svg/color-palette-sharp.svg +1 -1
- package/dist/stripe-elements/svg/color-palette.svg +1 -1
- package/dist/stripe-elements/svg/color-wand-outline.svg +1 -1
- package/dist/stripe-elements/svg/color-wand-sharp.svg +1 -1
- package/dist/stripe-elements/svg/color-wand.svg +1 -1
- package/dist/stripe-elements/svg/compass-outline.svg +1 -1
- package/dist/stripe-elements/svg/compass-sharp.svg +1 -1
- package/dist/stripe-elements/svg/compass.svg +1 -1
- package/dist/stripe-elements/svg/construct-outline.svg +1 -1
- package/dist/stripe-elements/svg/construct-sharp.svg +1 -1
- package/dist/stripe-elements/svg/construct.svg +1 -1
- package/dist/stripe-elements/svg/contract-outline.svg +1 -1
- package/dist/stripe-elements/svg/contract-sharp.svg +1 -1
- package/dist/stripe-elements/svg/contract.svg +1 -1
- package/dist/stripe-elements/svg/contrast-outline.svg +1 -1
- package/dist/stripe-elements/svg/contrast-sharp.svg +1 -1
- package/dist/stripe-elements/svg/contrast.svg +1 -1
- package/dist/stripe-elements/svg/copy-outline.svg +1 -1
- package/dist/stripe-elements/svg/copy-sharp.svg +1 -1
- package/dist/stripe-elements/svg/copy.svg +1 -1
- package/dist/stripe-elements/svg/create-outline.svg +1 -1
- package/dist/stripe-elements/svg/create-sharp.svg +1 -1
- package/dist/stripe-elements/svg/create.svg +1 -1
- package/dist/stripe-elements/svg/crop-outline.svg +1 -1
- package/dist/stripe-elements/svg/crop-sharp.svg +1 -1
- package/dist/stripe-elements/svg/crop.svg +1 -1
- package/dist/stripe-elements/svg/cube-outline.svg +1 -1
- package/dist/stripe-elements/svg/cube-sharp.svg +1 -1
- package/dist/stripe-elements/svg/cube.svg +1 -1
- package/dist/stripe-elements/svg/cut-outline.svg +1 -1
- package/dist/stripe-elements/svg/cut-sharp.svg +1 -1
- package/dist/stripe-elements/svg/cut.svg +1 -1
- package/dist/stripe-elements/svg/desktop-outline.svg +1 -1
- package/dist/stripe-elements/svg/desktop-sharp.svg +1 -1
- package/dist/stripe-elements/svg/desktop.svg +1 -1
- package/dist/stripe-elements/svg/diamond-outline.svg +1 -1
- package/dist/stripe-elements/svg/diamond-sharp.svg +1 -1
- package/dist/stripe-elements/svg/diamond.svg +1 -1
- package/dist/stripe-elements/svg/dice-outline.svg +1 -1
- package/dist/stripe-elements/svg/dice-sharp.svg +1 -1
- package/dist/stripe-elements/svg/dice.svg +1 -1
- package/dist/stripe-elements/svg/disc-outline.svg +1 -1
- package/dist/stripe-elements/svg/disc-sharp.svg +1 -1
- package/dist/stripe-elements/svg/disc.svg +1 -1
- package/dist/stripe-elements/svg/document-attach-outline.svg +1 -1
- package/dist/stripe-elements/svg/document-attach-sharp.svg +1 -1
- package/dist/stripe-elements/svg/document-attach.svg +1 -1
- package/dist/stripe-elements/svg/document-lock-outline.svg +1 -1
- package/dist/stripe-elements/svg/document-lock-sharp.svg +1 -1
- package/dist/stripe-elements/svg/document-lock.svg +1 -1
- package/dist/stripe-elements/svg/document-outline.svg +1 -1
- package/dist/stripe-elements/svg/document-sharp.svg +1 -1
- package/dist/stripe-elements/svg/document-text-outline.svg +1 -1
- package/dist/stripe-elements/svg/document-text-sharp.svg +1 -1
- package/dist/stripe-elements/svg/document-text.svg +1 -1
- package/dist/stripe-elements/svg/document.svg +1 -1
- package/dist/stripe-elements/svg/documents-outline.svg +1 -1
- package/dist/stripe-elements/svg/documents-sharp.svg +1 -1
- package/dist/stripe-elements/svg/documents.svg +1 -1
- package/dist/stripe-elements/svg/download-outline.svg +1 -1
- package/dist/stripe-elements/svg/download-sharp.svg +1 -1
- package/dist/stripe-elements/svg/download.svg +1 -1
- package/dist/stripe-elements/svg/duplicate-outline.svg +1 -1
- package/dist/stripe-elements/svg/duplicate-sharp.svg +1 -1
- package/dist/stripe-elements/svg/duplicate.svg +1 -1
- package/dist/stripe-elements/svg/ear-outline.svg +1 -1
- package/dist/stripe-elements/svg/ear-sharp.svg +1 -1
- package/dist/stripe-elements/svg/ear.svg +1 -1
- package/dist/stripe-elements/svg/earth-outline.svg +1 -1
- package/dist/stripe-elements/svg/earth-sharp.svg +1 -1
- package/dist/stripe-elements/svg/earth.svg +1 -1
- package/dist/stripe-elements/svg/easel-outline.svg +1 -1
- package/dist/stripe-elements/svg/easel-sharp.svg +1 -1
- package/dist/stripe-elements/svg/easel.svg +1 -1
- package/dist/stripe-elements/svg/egg-outline.svg +1 -1
- package/dist/stripe-elements/svg/egg-sharp.svg +1 -1
- package/dist/stripe-elements/svg/egg.svg +1 -1
- package/dist/stripe-elements/svg/ellipse-outline.svg +1 -1
- package/dist/stripe-elements/svg/ellipse-sharp.svg +1 -1
- package/dist/stripe-elements/svg/ellipse.svg +1 -1
- package/dist/stripe-elements/svg/ellipsis-horizontal-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/ellipsis-horizontal-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/ellipsis-horizontal-circle.svg +1 -1
- package/dist/stripe-elements/svg/ellipsis-horizontal-outline.svg +1 -1
- package/dist/stripe-elements/svg/ellipsis-horizontal-sharp.svg +1 -1
- package/dist/stripe-elements/svg/ellipsis-horizontal.svg +1 -1
- package/dist/stripe-elements/svg/ellipsis-vertical-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/ellipsis-vertical-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/ellipsis-vertical-circle.svg +1 -1
- package/dist/stripe-elements/svg/ellipsis-vertical-outline.svg +1 -1
- package/dist/stripe-elements/svg/ellipsis-vertical-sharp.svg +1 -1
- package/dist/stripe-elements/svg/ellipsis-vertical.svg +1 -1
- package/dist/stripe-elements/svg/enter-outline.svg +1 -1
- package/dist/stripe-elements/svg/enter-sharp.svg +1 -1
- package/dist/stripe-elements/svg/enter.svg +1 -1
- package/dist/stripe-elements/svg/exit-outline.svg +1 -1
- package/dist/stripe-elements/svg/exit-sharp.svg +1 -1
- package/dist/stripe-elements/svg/exit.svg +1 -1
- package/dist/stripe-elements/svg/expand-outline.svg +1 -1
- package/dist/stripe-elements/svg/expand-sharp.svg +1 -1
- package/dist/stripe-elements/svg/expand.svg +1 -1
- package/dist/stripe-elements/svg/extension-puzzle-outline.svg +1 -1
- package/dist/stripe-elements/svg/extension-puzzle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/extension-puzzle.svg +1 -1
- package/dist/stripe-elements/svg/eye-off-outline.svg +1 -1
- package/dist/stripe-elements/svg/eye-off-sharp.svg +1 -1
- package/dist/stripe-elements/svg/eye-off.svg +1 -1
- package/dist/stripe-elements/svg/eye-outline.svg +1 -1
- package/dist/stripe-elements/svg/eye-sharp.svg +1 -1
- package/dist/stripe-elements/svg/eye.svg +1 -1
- package/dist/stripe-elements/svg/eyedrop-outline.svg +1 -1
- package/dist/stripe-elements/svg/eyedrop-sharp.svg +1 -1
- package/dist/stripe-elements/svg/eyedrop.svg +1 -1
- package/dist/stripe-elements/svg/fast-food-outline.svg +1 -1
- package/dist/stripe-elements/svg/fast-food-sharp.svg +1 -1
- package/dist/stripe-elements/svg/fast-food.svg +1 -1
- package/dist/stripe-elements/svg/female-outline.svg +1 -1
- package/dist/stripe-elements/svg/female-sharp.svg +1 -1
- package/dist/stripe-elements/svg/female.svg +1 -1
- package/dist/stripe-elements/svg/file-tray-full-outline.svg +1 -1
- package/dist/stripe-elements/svg/file-tray-full-sharp.svg +1 -1
- package/dist/stripe-elements/svg/file-tray-full.svg +1 -1
- package/dist/stripe-elements/svg/file-tray-outline.svg +1 -1
- package/dist/stripe-elements/svg/file-tray-sharp.svg +1 -1
- package/dist/stripe-elements/svg/file-tray-stacked-outline.svg +1 -1
- package/dist/stripe-elements/svg/file-tray-stacked-sharp.svg +1 -1
- package/dist/stripe-elements/svg/file-tray-stacked.svg +1 -1
- package/dist/stripe-elements/svg/file-tray.svg +1 -1
- package/dist/stripe-elements/svg/film-outline.svg +1 -1
- package/dist/stripe-elements/svg/film-sharp.svg +1 -1
- package/dist/stripe-elements/svg/film.svg +1 -1
- package/dist/stripe-elements/svg/filter-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/filter-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/filter-circle.svg +1 -1
- package/dist/stripe-elements/svg/filter-outline.svg +1 -1
- package/dist/stripe-elements/svg/filter-sharp.svg +1 -1
- package/dist/stripe-elements/svg/filter.svg +1 -1
- package/dist/stripe-elements/svg/finger-print-outline.svg +1 -1
- package/dist/stripe-elements/svg/finger-print-sharp.svg +1 -1
- package/dist/stripe-elements/svg/finger-print.svg +1 -1
- package/dist/stripe-elements/svg/fish-outline.svg +1 -1
- package/dist/stripe-elements/svg/fish-sharp.svg +1 -1
- package/dist/stripe-elements/svg/fish.svg +1 -1
- package/dist/stripe-elements/svg/fitness-outline.svg +1 -1
- package/dist/stripe-elements/svg/fitness-sharp.svg +1 -1
- package/dist/stripe-elements/svg/fitness.svg +1 -1
- package/dist/stripe-elements/svg/flag-outline.svg +1 -1
- package/dist/stripe-elements/svg/flag-sharp.svg +1 -1
- package/dist/stripe-elements/svg/flag.svg +1 -1
- package/dist/stripe-elements/svg/flame-outline.svg +1 -1
- package/dist/stripe-elements/svg/flame-sharp.svg +1 -1
- package/dist/stripe-elements/svg/flame.svg +1 -1
- package/dist/stripe-elements/svg/flash-off-outline.svg +1 -1
- package/dist/stripe-elements/svg/flash-off-sharp.svg +1 -1
- package/dist/stripe-elements/svg/flash-off.svg +1 -1
- package/dist/stripe-elements/svg/flash-outline.svg +1 -1
- package/dist/stripe-elements/svg/flash-sharp.svg +1 -1
- package/dist/stripe-elements/svg/flash.svg +1 -1
- package/dist/stripe-elements/svg/flashlight-outline.svg +1 -1
- package/dist/stripe-elements/svg/flashlight-sharp.svg +1 -1
- package/dist/stripe-elements/svg/flashlight.svg +1 -1
- package/dist/stripe-elements/svg/flask-outline.svg +1 -1
- package/dist/stripe-elements/svg/flask-sharp.svg +1 -1
- package/dist/stripe-elements/svg/flask.svg +1 -1
- package/dist/stripe-elements/svg/flower-outline.svg +1 -1
- package/dist/stripe-elements/svg/flower-sharp.svg +1 -1
- package/dist/stripe-elements/svg/flower.svg +1 -1
- package/dist/stripe-elements/svg/folder-open-outline.svg +1 -1
- package/dist/stripe-elements/svg/folder-open-sharp.svg +1 -1
- package/dist/stripe-elements/svg/folder-open.svg +1 -1
- package/dist/stripe-elements/svg/folder-outline.svg +1 -1
- package/dist/stripe-elements/svg/folder-sharp.svg +1 -1
- package/dist/stripe-elements/svg/folder.svg +1 -1
- package/dist/stripe-elements/svg/football-outline.svg +1 -1
- package/dist/stripe-elements/svg/football-sharp.svg +1 -1
- package/dist/stripe-elements/svg/football.svg +1 -1
- package/dist/stripe-elements/svg/footsteps-outline.svg +1 -1
- package/dist/stripe-elements/svg/footsteps-sharp.svg +1 -1
- package/dist/stripe-elements/svg/footsteps.svg +1 -1
- package/dist/stripe-elements/svg/funnel-outline.svg +1 -1
- package/dist/stripe-elements/svg/funnel-sharp.svg +1 -1
- package/dist/stripe-elements/svg/funnel.svg +1 -1
- package/dist/stripe-elements/svg/game-controller-outline.svg +1 -1
- package/dist/stripe-elements/svg/game-controller-sharp.svg +1 -1
- package/dist/stripe-elements/svg/game-controller.svg +1 -1
- package/dist/stripe-elements/svg/gift-outline.svg +1 -1
- package/dist/stripe-elements/svg/gift-sharp.svg +1 -1
- package/dist/stripe-elements/svg/gift.svg +1 -1
- package/dist/stripe-elements/svg/git-branch-outline.svg +1 -1
- package/dist/stripe-elements/svg/git-branch-sharp.svg +1 -1
- package/dist/stripe-elements/svg/git-branch.svg +1 -1
- package/dist/stripe-elements/svg/git-commit-outline.svg +1 -1
- package/dist/stripe-elements/svg/git-commit-sharp.svg +1 -1
- package/dist/stripe-elements/svg/git-commit.svg +1 -1
- package/dist/stripe-elements/svg/git-compare-outline.svg +1 -1
- package/dist/stripe-elements/svg/git-compare-sharp.svg +1 -1
- package/dist/stripe-elements/svg/git-compare.svg +1 -1
- package/dist/stripe-elements/svg/git-merge-outline.svg +1 -1
- package/dist/stripe-elements/svg/git-merge-sharp.svg +1 -1
- package/dist/stripe-elements/svg/git-merge.svg +1 -1
- package/dist/stripe-elements/svg/git-network-outline.svg +1 -1
- package/dist/stripe-elements/svg/git-network-sharp.svg +1 -1
- package/dist/stripe-elements/svg/git-network.svg +1 -1
- package/dist/stripe-elements/svg/git-pull-request-outline.svg +1 -1
- package/dist/stripe-elements/svg/git-pull-request-sharp.svg +1 -1
- package/dist/stripe-elements/svg/git-pull-request.svg +1 -1
- package/dist/stripe-elements/svg/glasses-outline.svg +1 -1
- package/dist/stripe-elements/svg/glasses-sharp.svg +1 -1
- package/dist/stripe-elements/svg/glasses.svg +1 -1
- package/dist/stripe-elements/svg/globe-outline.svg +1 -1
- package/dist/stripe-elements/svg/globe-sharp.svg +1 -1
- package/dist/stripe-elements/svg/globe.svg +1 -1
- package/dist/stripe-elements/svg/golf-outline.svg +1 -1
- package/dist/stripe-elements/svg/golf-sharp.svg +1 -1
- package/dist/stripe-elements/svg/golf.svg +1 -1
- package/dist/stripe-elements/svg/grid-outline.svg +1 -1
- package/dist/stripe-elements/svg/grid-sharp.svg +1 -1
- package/dist/stripe-elements/svg/grid.svg +1 -1
- package/dist/stripe-elements/svg/hammer-outline.svg +1 -1
- package/dist/stripe-elements/svg/hammer-sharp.svg +1 -1
- package/dist/stripe-elements/svg/hammer.svg +1 -1
- package/dist/stripe-elements/svg/hand-left-outline.svg +1 -1
- package/dist/stripe-elements/svg/hand-left-sharp.svg +1 -1
- package/dist/stripe-elements/svg/hand-left.svg +1 -1
- package/dist/stripe-elements/svg/hand-right-outline.svg +1 -1
- package/dist/stripe-elements/svg/hand-right-sharp.svg +1 -1
- package/dist/stripe-elements/svg/hand-right.svg +1 -1
- package/dist/stripe-elements/svg/happy-outline.svg +1 -1
- package/dist/stripe-elements/svg/happy-sharp.svg +1 -1
- package/dist/stripe-elements/svg/happy.svg +1 -1
- package/dist/stripe-elements/svg/hardware-chip-outline.svg +1 -1
- package/dist/stripe-elements/svg/hardware-chip-sharp.svg +1 -1
- package/dist/stripe-elements/svg/hardware-chip.svg +1 -1
- package/dist/stripe-elements/svg/headset-outline.svg +1 -1
- package/dist/stripe-elements/svg/headset-sharp.svg +1 -1
- package/dist/stripe-elements/svg/headset.svg +1 -1
- package/dist/stripe-elements/svg/heart-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/heart-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/heart-circle.svg +1 -1
- package/dist/stripe-elements/svg/heart-dislike-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/heart-dislike-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/heart-dislike-circle.svg +1 -1
- package/dist/stripe-elements/svg/heart-dislike-outline.svg +1 -1
- package/dist/stripe-elements/svg/heart-dislike-sharp.svg +1 -1
- package/dist/stripe-elements/svg/heart-dislike.svg +1 -1
- package/dist/stripe-elements/svg/heart-half-outline.svg +1 -1
- package/dist/stripe-elements/svg/heart-half-sharp.svg +1 -1
- package/dist/stripe-elements/svg/heart-half.svg +1 -1
- package/dist/stripe-elements/svg/heart-outline.svg +1 -1
- package/dist/stripe-elements/svg/heart-sharp.svg +1 -1
- package/dist/stripe-elements/svg/heart.svg +1 -1
- package/dist/stripe-elements/svg/help-buoy-outline.svg +1 -1
- package/dist/stripe-elements/svg/help-buoy-sharp.svg +1 -1
- package/dist/stripe-elements/svg/help-buoy.svg +1 -1
- package/dist/stripe-elements/svg/help-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/help-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/help-circle.svg +1 -1
- package/dist/stripe-elements/svg/help-outline.svg +1 -1
- package/dist/stripe-elements/svg/help-sharp.svg +1 -1
- package/dist/stripe-elements/svg/help.svg +1 -1
- package/dist/stripe-elements/svg/home-outline.svg +1 -1
- package/dist/stripe-elements/svg/home-sharp.svg +1 -1
- package/dist/stripe-elements/svg/home.svg +1 -1
- package/dist/stripe-elements/svg/hourglass-outline.svg +1 -1
- package/dist/stripe-elements/svg/hourglass-sharp.svg +1 -1
- package/dist/stripe-elements/svg/hourglass.svg +1 -1
- package/dist/stripe-elements/svg/ice-cream-outline.svg +1 -1
- package/dist/stripe-elements/svg/ice-cream-sharp.svg +1 -1
- package/dist/stripe-elements/svg/ice-cream.svg +1 -1
- package/dist/stripe-elements/svg/id-card-outline.svg +1 -1
- package/dist/stripe-elements/svg/id-card-sharp.svg +1 -1
- package/dist/stripe-elements/svg/id-card.svg +1 -1
- package/dist/stripe-elements/svg/image-outline.svg +1 -1
- package/dist/stripe-elements/svg/image-sharp.svg +1 -1
- package/dist/stripe-elements/svg/image.svg +1 -1
- package/dist/stripe-elements/svg/images-outline.svg +1 -1
- package/dist/stripe-elements/svg/images-sharp.svg +1 -1
- package/dist/stripe-elements/svg/images.svg +1 -1
- package/dist/stripe-elements/svg/infinite-outline.svg +1 -1
- package/dist/stripe-elements/svg/infinite-sharp.svg +1 -1
- package/dist/stripe-elements/svg/infinite.svg +1 -1
- package/dist/stripe-elements/svg/information-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/information-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/information-circle.svg +1 -1
- package/dist/stripe-elements/svg/information-outline.svg +1 -1
- package/dist/stripe-elements/svg/information-sharp.svg +1 -1
- package/dist/stripe-elements/svg/information.svg +1 -1
- package/dist/stripe-elements/svg/invert-mode-outline.svg +1 -1
- package/dist/stripe-elements/svg/invert-mode-sharp.svg +1 -1
- package/dist/stripe-elements/svg/invert-mode.svg +1 -1
- package/dist/stripe-elements/svg/journal-outline.svg +1 -1
- package/dist/stripe-elements/svg/journal-sharp.svg +1 -1
- package/dist/stripe-elements/svg/journal.svg +1 -1
- package/dist/stripe-elements/svg/key-outline.svg +1 -1
- package/dist/stripe-elements/svg/key-sharp.svg +1 -1
- package/dist/stripe-elements/svg/key.svg +1 -1
- package/dist/stripe-elements/svg/keypad-outline.svg +1 -1
- package/dist/stripe-elements/svg/keypad-sharp.svg +1 -1
- package/dist/stripe-elements/svg/keypad.svg +1 -1
- package/dist/stripe-elements/svg/language-outline.svg +1 -1
- package/dist/stripe-elements/svg/language-sharp.svg +1 -1
- package/dist/stripe-elements/svg/language.svg +1 -1
- package/dist/stripe-elements/svg/laptop-outline.svg +1 -1
- package/dist/stripe-elements/svg/laptop-sharp.svg +1 -1
- package/dist/stripe-elements/svg/laptop.svg +1 -1
- package/dist/stripe-elements/svg/layers-outline.svg +1 -1
- package/dist/stripe-elements/svg/layers-sharp.svg +1 -1
- package/dist/stripe-elements/svg/layers.svg +1 -1
- package/dist/stripe-elements/svg/leaf-outline.svg +1 -1
- package/dist/stripe-elements/svg/leaf-sharp.svg +1 -1
- package/dist/stripe-elements/svg/leaf.svg +1 -1
- package/dist/stripe-elements/svg/library-outline.svg +1 -1
- package/dist/stripe-elements/svg/library-sharp.svg +1 -1
- package/dist/stripe-elements/svg/library.svg +1 -1
- package/dist/stripe-elements/svg/link-outline.svg +1 -1
- package/dist/stripe-elements/svg/link-sharp.svg +1 -1
- package/dist/stripe-elements/svg/link.svg +1 -1
- package/dist/stripe-elements/svg/list-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/list-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/list-circle.svg +1 -1
- package/dist/stripe-elements/svg/list-outline.svg +1 -1
- package/dist/stripe-elements/svg/list-sharp.svg +1 -1
- package/dist/stripe-elements/svg/list.svg +1 -1
- package/dist/stripe-elements/svg/locate-outline.svg +1 -1
- package/dist/stripe-elements/svg/locate-sharp.svg +1 -1
- package/dist/stripe-elements/svg/locate.svg +1 -1
- package/dist/stripe-elements/svg/location-outline.svg +1 -1
- package/dist/stripe-elements/svg/location-sharp.svg +1 -1
- package/dist/stripe-elements/svg/location.svg +1 -1
- package/dist/stripe-elements/svg/lock-closed-outline.svg +1 -1
- package/dist/stripe-elements/svg/lock-closed-sharp.svg +1 -1
- package/dist/stripe-elements/svg/lock-closed.svg +1 -1
- package/dist/stripe-elements/svg/lock-open-outline.svg +1 -1
- package/dist/stripe-elements/svg/lock-open-sharp.svg +1 -1
- package/dist/stripe-elements/svg/lock-open.svg +1 -1
- package/dist/stripe-elements/svg/log-in-outline.svg +1 -1
- package/dist/stripe-elements/svg/log-in-sharp.svg +1 -1
- package/dist/stripe-elements/svg/log-in.svg +1 -1
- package/dist/stripe-elements/svg/log-out-outline.svg +1 -1
- package/dist/stripe-elements/svg/log-out-sharp.svg +1 -1
- package/dist/stripe-elements/svg/log-out.svg +1 -1
- package/dist/stripe-elements/svg/logo-alipay.svg +1 -1
- package/dist/stripe-elements/svg/logo-amazon.svg +1 -1
- package/dist/stripe-elements/svg/logo-amplify.svg +1 -1
- package/dist/stripe-elements/svg/logo-android.svg +1 -1
- package/dist/stripe-elements/svg/logo-angular.svg +1 -1
- package/dist/stripe-elements/svg/logo-appflow.svg +1 -0
- package/dist/stripe-elements/svg/logo-apple-appstore.svg +1 -1
- package/dist/stripe-elements/svg/logo-apple-ar.svg +1 -1
- package/dist/stripe-elements/svg/logo-apple.svg +1 -1
- package/dist/stripe-elements/svg/logo-behance.svg +1 -1
- package/dist/stripe-elements/svg/logo-bitbucket.svg +1 -1
- package/dist/stripe-elements/svg/logo-bitcoin.svg +1 -1
- package/dist/stripe-elements/svg/logo-buffer.svg +1 -1
- package/dist/stripe-elements/svg/logo-capacitor.svg +1 -1
- package/dist/stripe-elements/svg/logo-chrome.svg +1 -1
- package/dist/stripe-elements/svg/logo-closed-captioning.svg +1 -1
- package/dist/stripe-elements/svg/logo-codepen.svg +1 -1
- package/dist/stripe-elements/svg/logo-css3.svg +1 -1
- package/dist/stripe-elements/svg/logo-designernews.svg +1 -1
- package/dist/stripe-elements/svg/logo-deviantart.svg +1 -1
- package/dist/stripe-elements/svg/logo-discord.svg +1 -1
- package/dist/stripe-elements/svg/logo-docker.svg +1 -1
- package/dist/stripe-elements/svg/logo-dribbble.svg +1 -1
- package/dist/stripe-elements/svg/logo-dropbox.svg +1 -1
- package/dist/stripe-elements/svg/logo-edge.svg +1 -1
- package/dist/stripe-elements/svg/logo-electron.svg +1 -1
- package/dist/stripe-elements/svg/logo-euro.svg +1 -1
- package/dist/stripe-elements/svg/logo-facebook.svg +1 -1
- package/dist/stripe-elements/svg/logo-figma.svg +1 -1
- package/dist/stripe-elements/svg/logo-firebase.svg +1 -1
- package/dist/stripe-elements/svg/logo-firefox.svg +1 -1
- package/dist/stripe-elements/svg/logo-flickr.svg +1 -1
- package/dist/stripe-elements/svg/logo-foursquare.svg +1 -1
- package/dist/stripe-elements/svg/logo-github.svg +1 -1
- package/dist/stripe-elements/svg/logo-gitlab.svg +1 -1
- package/dist/stripe-elements/svg/logo-google-playstore.svg +1 -1
- package/dist/stripe-elements/svg/logo-google.svg +1 -1
- package/dist/stripe-elements/svg/logo-hackernews.svg +1 -1
- package/dist/stripe-elements/svg/logo-html5.svg +1 -1
- package/dist/stripe-elements/svg/logo-instagram.svg +1 -1
- package/dist/stripe-elements/svg/logo-ionic.svg +1 -1
- package/dist/stripe-elements/svg/logo-ionitron.svg +1 -1
- package/dist/stripe-elements/svg/logo-javascript.svg +1 -1
- package/dist/stripe-elements/svg/logo-laravel.svg +1 -1
- package/dist/stripe-elements/svg/logo-linkedin.svg +1 -1
- package/dist/stripe-elements/svg/logo-markdown.svg +1 -1
- package/dist/stripe-elements/svg/logo-mastodon.svg +1 -1
- package/dist/stripe-elements/svg/logo-medium.svg +1 -1
- package/dist/stripe-elements/svg/logo-microsoft.svg +1 -1
- package/dist/stripe-elements/svg/logo-no-smoking.svg +1 -1
- package/dist/stripe-elements/svg/logo-nodejs.svg +1 -1
- package/dist/stripe-elements/svg/logo-npm.svg +1 -1
- package/dist/stripe-elements/svg/logo-octocat.svg +1 -1
- package/dist/stripe-elements/svg/logo-paypal.svg +1 -1
- package/dist/stripe-elements/svg/logo-pinterest.svg +1 -1
- package/dist/stripe-elements/svg/logo-playstation.svg +1 -1
- package/dist/stripe-elements/svg/logo-pwa.svg +1 -1
- package/dist/stripe-elements/svg/logo-python.svg +1 -1
- package/dist/stripe-elements/svg/logo-react.svg +1 -1
- package/dist/stripe-elements/svg/logo-reddit.svg +1 -1
- package/dist/stripe-elements/svg/logo-rss.svg +1 -1
- package/dist/stripe-elements/svg/logo-sass.svg +1 -1
- package/dist/stripe-elements/svg/logo-skype.svg +1 -1
- package/dist/stripe-elements/svg/logo-slack.svg +1 -1
- package/dist/stripe-elements/svg/logo-snapchat.svg +1 -1
- package/dist/stripe-elements/svg/logo-soundcloud.svg +1 -1
- package/dist/stripe-elements/svg/logo-stackoverflow.svg +1 -1
- package/dist/stripe-elements/svg/logo-steam.svg +1 -1
- package/dist/stripe-elements/svg/logo-stencil.svg +1 -1
- package/dist/stripe-elements/svg/logo-tableau.svg +1 -1
- package/dist/stripe-elements/svg/logo-threads.svg +1 -0
- package/dist/stripe-elements/svg/logo-tiktok.svg +1 -1
- package/dist/stripe-elements/svg/logo-trapeze.svg +1 -0
- package/dist/stripe-elements/svg/logo-tumblr.svg +1 -1
- package/dist/stripe-elements/svg/logo-tux.svg +1 -1
- package/dist/stripe-elements/svg/logo-twitch.svg +1 -1
- package/dist/stripe-elements/svg/logo-twitter.svg +1 -1
- package/dist/stripe-elements/svg/logo-usd.svg +1 -1
- package/dist/stripe-elements/svg/logo-venmo.svg +1 -1
- package/dist/stripe-elements/svg/logo-vercel.svg +1 -1
- package/dist/stripe-elements/svg/logo-vimeo.svg +1 -1
- package/dist/stripe-elements/svg/logo-vk.svg +1 -1
- package/dist/stripe-elements/svg/logo-vue.svg +1 -1
- package/dist/stripe-elements/svg/logo-web-component.svg +1 -1
- package/dist/stripe-elements/svg/logo-wechat.svg +1 -1
- package/dist/stripe-elements/svg/logo-whatsapp.svg +1 -1
- package/dist/stripe-elements/svg/logo-windows.svg +1 -1
- package/dist/stripe-elements/svg/logo-wordpress.svg +1 -1
- package/dist/stripe-elements/svg/logo-x.svg +1 -0
- package/dist/stripe-elements/svg/logo-xbox.svg +1 -1
- package/dist/stripe-elements/svg/logo-xing.svg +1 -1
- package/dist/stripe-elements/svg/logo-yahoo.svg +1 -1
- package/dist/stripe-elements/svg/logo-yen.svg +1 -1
- package/dist/stripe-elements/svg/logo-youtube.svg +1 -1
- package/dist/stripe-elements/svg/magnet-outline.svg +1 -1
- package/dist/stripe-elements/svg/magnet-sharp.svg +1 -1
- package/dist/stripe-elements/svg/magnet.svg +1 -1
- package/dist/stripe-elements/svg/mail-open-outline.svg +1 -1
- package/dist/stripe-elements/svg/mail-open-sharp.svg +1 -1
- package/dist/stripe-elements/svg/mail-open.svg +1 -1
- package/dist/stripe-elements/svg/mail-outline.svg +1 -1
- package/dist/stripe-elements/svg/mail-sharp.svg +1 -1
- package/dist/stripe-elements/svg/mail-unread-outline.svg +1 -1
- package/dist/stripe-elements/svg/mail-unread-sharp.svg +1 -1
- package/dist/stripe-elements/svg/mail-unread.svg +1 -1
- package/dist/stripe-elements/svg/mail.svg +1 -1
- package/dist/stripe-elements/svg/male-female-outline.svg +1 -1
- package/dist/stripe-elements/svg/male-female-sharp.svg +1 -1
- package/dist/stripe-elements/svg/male-female.svg +1 -1
- package/dist/stripe-elements/svg/male-outline.svg +1 -1
- package/dist/stripe-elements/svg/male-sharp.svg +1 -1
- package/dist/stripe-elements/svg/male.svg +1 -1
- package/dist/stripe-elements/svg/man-outline.svg +1 -1
- package/dist/stripe-elements/svg/man-sharp.svg +1 -1
- package/dist/stripe-elements/svg/man.svg +1 -1
- package/dist/stripe-elements/svg/map-outline.svg +1 -1
- package/dist/stripe-elements/svg/map-sharp.svg +1 -1
- package/dist/stripe-elements/svg/map.svg +1 -1
- package/dist/stripe-elements/svg/medal-outline.svg +1 -1
- package/dist/stripe-elements/svg/medal-sharp.svg +1 -1
- package/dist/stripe-elements/svg/medal.svg +1 -1
- package/dist/stripe-elements/svg/medical-outline.svg +1 -1
- package/dist/stripe-elements/svg/medical-sharp.svg +1 -1
- package/dist/stripe-elements/svg/medical.svg +1 -1
- package/dist/stripe-elements/svg/medkit-outline.svg +1 -1
- package/dist/stripe-elements/svg/medkit-sharp.svg +1 -1
- package/dist/stripe-elements/svg/medkit.svg +1 -1
- package/dist/stripe-elements/svg/megaphone-outline.svg +1 -1
- package/dist/stripe-elements/svg/megaphone-sharp.svg +1 -1
- package/dist/stripe-elements/svg/megaphone.svg +1 -1
- package/dist/stripe-elements/svg/menu-outline.svg +1 -1
- package/dist/stripe-elements/svg/menu-sharp.svg +1 -1
- package/dist/stripe-elements/svg/menu.svg +1 -1
- package/dist/stripe-elements/svg/mic-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/mic-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/mic-circle.svg +1 -1
- package/dist/stripe-elements/svg/mic-off-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/mic-off-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/mic-off-circle.svg +1 -1
- package/dist/stripe-elements/svg/mic-off-outline.svg +1 -1
- package/dist/stripe-elements/svg/mic-off-sharp.svg +1 -1
- package/dist/stripe-elements/svg/mic-off.svg +1 -1
- package/dist/stripe-elements/svg/mic-outline.svg +1 -1
- package/dist/stripe-elements/svg/mic-sharp.svg +1 -1
- package/dist/stripe-elements/svg/mic.svg +1 -1
- package/dist/stripe-elements/svg/moon-outline.svg +1 -1
- package/dist/stripe-elements/svg/moon-sharp.svg +1 -1
- package/dist/stripe-elements/svg/moon.svg +1 -1
- package/dist/stripe-elements/svg/move-outline.svg +1 -1
- package/dist/stripe-elements/svg/move-sharp.svg +1 -1
- package/dist/stripe-elements/svg/move.svg +1 -1
- package/dist/stripe-elements/svg/musical-note-outline.svg +1 -1
- package/dist/stripe-elements/svg/musical-note-sharp.svg +1 -1
- package/dist/stripe-elements/svg/musical-note.svg +1 -1
- package/dist/stripe-elements/svg/musical-notes-outline.svg +1 -1
- package/dist/stripe-elements/svg/musical-notes-sharp.svg +1 -1
- package/dist/stripe-elements/svg/musical-notes.svg +1 -1
- package/dist/stripe-elements/svg/navigate-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/navigate-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/navigate-circle.svg +1 -1
- package/dist/stripe-elements/svg/navigate-outline.svg +1 -1
- package/dist/stripe-elements/svg/navigate-sharp.svg +1 -1
- package/dist/stripe-elements/svg/navigate.svg +1 -1
- package/dist/stripe-elements/svg/newspaper-outline.svg +1 -1
- package/dist/stripe-elements/svg/newspaper-sharp.svg +1 -1
- package/dist/stripe-elements/svg/newspaper.svg +1 -1
- package/dist/stripe-elements/svg/notifications-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/notifications-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/notifications-circle.svg +1 -1
- package/dist/stripe-elements/svg/notifications-off-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/notifications-off-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/notifications-off-circle.svg +1 -1
- package/dist/stripe-elements/svg/notifications-off-outline.svg +1 -1
- package/dist/stripe-elements/svg/notifications-off-sharp.svg +1 -1
- package/dist/stripe-elements/svg/notifications-off.svg +1 -1
- package/dist/stripe-elements/svg/notifications-outline.svg +1 -1
- package/dist/stripe-elements/svg/notifications-sharp.svg +1 -1
- package/dist/stripe-elements/svg/notifications.svg +1 -1
- package/dist/stripe-elements/svg/nuclear-outline.svg +1 -1
- package/dist/stripe-elements/svg/nuclear-sharp.svg +1 -1
- package/dist/stripe-elements/svg/nuclear.svg +1 -1
- package/dist/stripe-elements/svg/nutrition-outline.svg +1 -1
- package/dist/stripe-elements/svg/nutrition-sharp.svg +1 -1
- package/dist/stripe-elements/svg/nutrition.svg +1 -1
- package/dist/stripe-elements/svg/open-outline.svg +1 -1
- package/dist/stripe-elements/svg/open-sharp.svg +1 -1
- package/dist/stripe-elements/svg/open.svg +1 -1
- package/dist/stripe-elements/svg/options-outline.svg +1 -1
- package/dist/stripe-elements/svg/options-sharp.svg +1 -1
- package/dist/stripe-elements/svg/options.svg +1 -1
- package/dist/stripe-elements/svg/paper-plane-outline.svg +1 -1
- package/dist/stripe-elements/svg/paper-plane-sharp.svg +1 -1
- package/dist/stripe-elements/svg/paper-plane.svg +1 -1
- package/dist/stripe-elements/svg/partly-sunny-outline.svg +1 -1
- package/dist/stripe-elements/svg/partly-sunny-sharp.svg +1 -1
- package/dist/stripe-elements/svg/partly-sunny.svg +1 -1
- package/dist/stripe-elements/svg/pause-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/pause-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/pause-circle.svg +1 -1
- package/dist/stripe-elements/svg/pause-outline.svg +1 -1
- package/dist/stripe-elements/svg/pause-sharp.svg +1 -1
- package/dist/stripe-elements/svg/pause.svg +1 -1
- package/dist/stripe-elements/svg/paw-outline.svg +1 -1
- package/dist/stripe-elements/svg/paw-sharp.svg +1 -1
- package/dist/stripe-elements/svg/paw.svg +1 -1
- package/dist/stripe-elements/svg/pencil-outline.svg +1 -1
- package/dist/stripe-elements/svg/pencil-sharp.svg +1 -1
- package/dist/stripe-elements/svg/pencil.svg +1 -1
- package/dist/stripe-elements/svg/people-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/people-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/people-circle.svg +1 -1
- package/dist/stripe-elements/svg/people-outline.svg +1 -1
- package/dist/stripe-elements/svg/people-sharp.svg +1 -1
- package/dist/stripe-elements/svg/people.svg +1 -1
- package/dist/stripe-elements/svg/person-add-outline.svg +1 -1
- package/dist/stripe-elements/svg/person-add-sharp.svg +1 -1
- package/dist/stripe-elements/svg/person-add.svg +1 -1
- package/dist/stripe-elements/svg/person-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/person-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/person-circle.svg +1 -1
- package/dist/stripe-elements/svg/person-outline.svg +1 -1
- package/dist/stripe-elements/svg/person-remove-outline.svg +1 -1
- package/dist/stripe-elements/svg/person-remove-sharp.svg +1 -1
- package/dist/stripe-elements/svg/person-remove.svg +1 -1
- package/dist/stripe-elements/svg/person-sharp.svg +1 -1
- package/dist/stripe-elements/svg/person.svg +1 -1
- package/dist/stripe-elements/svg/phone-landscape-outline.svg +1 -1
- package/dist/stripe-elements/svg/phone-landscape-sharp.svg +1 -1
- package/dist/stripe-elements/svg/phone-landscape.svg +1 -1
- package/dist/stripe-elements/svg/phone-portrait-outline.svg +1 -1
- package/dist/stripe-elements/svg/phone-portrait-sharp.svg +1 -1
- package/dist/stripe-elements/svg/phone-portrait.svg +1 -1
- package/dist/stripe-elements/svg/pie-chart-outline.svg +1 -1
- package/dist/stripe-elements/svg/pie-chart-sharp.svg +1 -1
- package/dist/stripe-elements/svg/pie-chart.svg +1 -1
- package/dist/stripe-elements/svg/pin-outline.svg +1 -1
- package/dist/stripe-elements/svg/pin-sharp.svg +1 -1
- package/dist/stripe-elements/svg/pin.svg +1 -1
- package/dist/stripe-elements/svg/pint-outline.svg +1 -1
- package/dist/stripe-elements/svg/pint-sharp.svg +1 -1
- package/dist/stripe-elements/svg/pint.svg +1 -1
- package/dist/stripe-elements/svg/pizza-outline.svg +1 -1
- package/dist/stripe-elements/svg/pizza-sharp.svg +1 -1
- package/dist/stripe-elements/svg/pizza.svg +1 -1
- package/dist/stripe-elements/svg/planet-outline.svg +1 -1
- package/dist/stripe-elements/svg/planet-sharp.svg +1 -1
- package/dist/stripe-elements/svg/planet.svg +1 -1
- package/dist/stripe-elements/svg/play-back-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/play-back-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/play-back-circle.svg +1 -1
- package/dist/stripe-elements/svg/play-back-outline.svg +1 -1
- package/dist/stripe-elements/svg/play-back-sharp.svg +1 -1
- package/dist/stripe-elements/svg/play-back.svg +1 -1
- package/dist/stripe-elements/svg/play-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/play-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/play-circle.svg +1 -1
- package/dist/stripe-elements/svg/play-forward-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/play-forward-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/play-forward-circle.svg +1 -1
- package/dist/stripe-elements/svg/play-forward-outline.svg +1 -1
- package/dist/stripe-elements/svg/play-forward-sharp.svg +1 -1
- package/dist/stripe-elements/svg/play-forward.svg +1 -1
- package/dist/stripe-elements/svg/play-outline.svg +1 -1
- package/dist/stripe-elements/svg/play-sharp.svg +1 -1
- package/dist/stripe-elements/svg/play-skip-back-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/play-skip-back-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/play-skip-back-circle.svg +1 -1
- package/dist/stripe-elements/svg/play-skip-back-outline.svg +1 -1
- package/dist/stripe-elements/svg/play-skip-back-sharp.svg +1 -1
- package/dist/stripe-elements/svg/play-skip-back.svg +1 -1
- package/dist/stripe-elements/svg/play-skip-forward-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/play-skip-forward-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/play-skip-forward-circle.svg +1 -1
- package/dist/stripe-elements/svg/play-skip-forward-outline.svg +1 -1
- package/dist/stripe-elements/svg/play-skip-forward-sharp.svg +1 -1
- package/dist/stripe-elements/svg/play-skip-forward.svg +1 -1
- package/dist/stripe-elements/svg/play.svg +1 -1
- package/dist/stripe-elements/svg/podium-outline.svg +1 -1
- package/dist/stripe-elements/svg/podium-sharp.svg +1 -1
- package/dist/stripe-elements/svg/podium.svg +1 -1
- package/dist/stripe-elements/svg/power-outline.svg +1 -1
- package/dist/stripe-elements/svg/power-sharp.svg +1 -1
- package/dist/stripe-elements/svg/power.svg +1 -1
- package/dist/stripe-elements/svg/pricetag-outline.svg +1 -1
- package/dist/stripe-elements/svg/pricetag-sharp.svg +1 -1
- package/dist/stripe-elements/svg/pricetag.svg +1 -1
- package/dist/stripe-elements/svg/pricetags-outline.svg +1 -1
- package/dist/stripe-elements/svg/pricetags-sharp.svg +1 -1
- package/dist/stripe-elements/svg/pricetags.svg +1 -1
- package/dist/stripe-elements/svg/print-outline.svg +1 -1
- package/dist/stripe-elements/svg/print-sharp.svg +1 -1
- package/dist/stripe-elements/svg/print.svg +1 -1
- package/dist/stripe-elements/svg/prism-outline.svg +1 -1
- package/dist/stripe-elements/svg/prism-sharp.svg +1 -1
- package/dist/stripe-elements/svg/prism.svg +1 -1
- package/dist/stripe-elements/svg/pulse-outline.svg +1 -1
- package/dist/stripe-elements/svg/pulse-sharp.svg +1 -1
- package/dist/stripe-elements/svg/pulse.svg +1 -1
- package/dist/stripe-elements/svg/push-outline.svg +1 -1
- package/dist/stripe-elements/svg/push-sharp.svg +1 -1
- package/dist/stripe-elements/svg/push.svg +1 -1
- package/dist/stripe-elements/svg/qr-code-outline.svg +1 -1
- package/dist/stripe-elements/svg/qr-code-sharp.svg +1 -1
- package/dist/stripe-elements/svg/qr-code.svg +1 -1
- package/dist/stripe-elements/svg/radio-button-off-outline.svg +1 -1
- package/dist/stripe-elements/svg/radio-button-off-sharp.svg +1 -1
- package/dist/stripe-elements/svg/radio-button-off.svg +1 -1
- package/dist/stripe-elements/svg/radio-button-on-outline.svg +1 -1
- package/dist/stripe-elements/svg/radio-button-on-sharp.svg +1 -1
- package/dist/stripe-elements/svg/radio-button-on.svg +1 -1
- package/dist/stripe-elements/svg/radio-outline.svg +1 -1
- package/dist/stripe-elements/svg/radio-sharp.svg +1 -1
- package/dist/stripe-elements/svg/radio.svg +1 -1
- package/dist/stripe-elements/svg/rainy-outline.svg +1 -1
- package/dist/stripe-elements/svg/rainy-sharp.svg +1 -1
- package/dist/stripe-elements/svg/rainy.svg +1 -1
- package/dist/stripe-elements/svg/reader-outline.svg +1 -1
- package/dist/stripe-elements/svg/reader-sharp.svg +1 -1
- package/dist/stripe-elements/svg/reader.svg +1 -1
- package/dist/stripe-elements/svg/receipt-outline.svg +1 -1
- package/dist/stripe-elements/svg/receipt-sharp.svg +1 -1
- package/dist/stripe-elements/svg/receipt.svg +1 -1
- package/dist/stripe-elements/svg/recording-outline.svg +1 -1
- package/dist/stripe-elements/svg/recording-sharp.svg +1 -1
- package/dist/stripe-elements/svg/recording.svg +1 -1
- package/dist/stripe-elements/svg/refresh-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/refresh-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/refresh-circle.svg +1 -1
- package/dist/stripe-elements/svg/refresh-outline.svg +1 -1
- package/dist/stripe-elements/svg/refresh-sharp.svg +1 -1
- package/dist/stripe-elements/svg/refresh.svg +1 -1
- package/dist/stripe-elements/svg/reload-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/reload-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/reload-circle.svg +1 -1
- package/dist/stripe-elements/svg/reload-outline.svg +1 -1
- package/dist/stripe-elements/svg/reload-sharp.svg +1 -1
- package/dist/stripe-elements/svg/reload.svg +1 -1
- package/dist/stripe-elements/svg/remove-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/remove-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/remove-circle.svg +1 -1
- package/dist/stripe-elements/svg/remove-outline.svg +1 -1
- package/dist/stripe-elements/svg/remove-sharp.svg +1 -1
- package/dist/stripe-elements/svg/remove.svg +1 -1
- package/dist/stripe-elements/svg/reorder-four-outline.svg +1 -1
- package/dist/stripe-elements/svg/reorder-four-sharp.svg +1 -1
- package/dist/stripe-elements/svg/reorder-four.svg +1 -1
- package/dist/stripe-elements/svg/reorder-three-outline.svg +1 -1
- package/dist/stripe-elements/svg/reorder-three-sharp.svg +1 -1
- package/dist/stripe-elements/svg/reorder-three.svg +1 -1
- package/dist/stripe-elements/svg/reorder-two-outline.svg +1 -1
- package/dist/stripe-elements/svg/reorder-two-sharp.svg +1 -1
- package/dist/stripe-elements/svg/reorder-two.svg +1 -1
- package/dist/stripe-elements/svg/repeat-outline.svg +1 -1
- package/dist/stripe-elements/svg/repeat-sharp.svg +1 -1
- package/dist/stripe-elements/svg/repeat.svg +1 -1
- package/dist/stripe-elements/svg/resize-outline.svg +1 -1
- package/dist/stripe-elements/svg/resize-sharp.svg +1 -1
- package/dist/stripe-elements/svg/resize.svg +1 -1
- package/dist/stripe-elements/svg/restaurant-outline.svg +1 -1
- package/dist/stripe-elements/svg/restaurant-sharp.svg +1 -1
- package/dist/stripe-elements/svg/restaurant.svg +1 -1
- package/dist/stripe-elements/svg/return-down-back-outline.svg +1 -1
- package/dist/stripe-elements/svg/return-down-back-sharp.svg +1 -1
- package/dist/stripe-elements/svg/return-down-back.svg +1 -1
- package/dist/stripe-elements/svg/return-down-forward-outline.svg +1 -1
- package/dist/stripe-elements/svg/return-down-forward-sharp.svg +1 -1
- package/dist/stripe-elements/svg/return-down-forward.svg +1 -1
- package/dist/stripe-elements/svg/return-up-back-outline.svg +1 -1
- package/dist/stripe-elements/svg/return-up-back-sharp.svg +1 -1
- package/dist/stripe-elements/svg/return-up-back.svg +1 -1
- package/dist/stripe-elements/svg/return-up-forward-outline.svg +1 -1
- package/dist/stripe-elements/svg/return-up-forward-sharp.svg +1 -1
- package/dist/stripe-elements/svg/return-up-forward.svg +1 -1
- package/dist/stripe-elements/svg/ribbon-outline.svg +1 -1
- package/dist/stripe-elements/svg/ribbon-sharp.svg +1 -1
- package/dist/stripe-elements/svg/ribbon.svg +1 -1
- package/dist/stripe-elements/svg/rocket-outline.svg +1 -1
- package/dist/stripe-elements/svg/rocket-sharp.svg +1 -1
- package/dist/stripe-elements/svg/rocket.svg +1 -1
- package/dist/stripe-elements/svg/rose-outline.svg +1 -1
- package/dist/stripe-elements/svg/rose-sharp.svg +1 -1
- package/dist/stripe-elements/svg/rose.svg +1 -1
- package/dist/stripe-elements/svg/sad-outline.svg +1 -1
- package/dist/stripe-elements/svg/sad-sharp.svg +1 -1
- package/dist/stripe-elements/svg/sad.svg +1 -1
- package/dist/stripe-elements/svg/save-outline.svg +1 -1
- package/dist/stripe-elements/svg/save-sharp.svg +1 -1
- package/dist/stripe-elements/svg/save.svg +1 -1
- package/dist/stripe-elements/svg/scale-outline.svg +1 -1
- package/dist/stripe-elements/svg/scale-sharp.svg +1 -1
- package/dist/stripe-elements/svg/scale.svg +1 -1
- package/dist/stripe-elements/svg/scan-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/scan-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/scan-circle.svg +1 -1
- package/dist/stripe-elements/svg/scan-outline.svg +1 -1
- package/dist/stripe-elements/svg/scan-sharp.svg +1 -1
- package/dist/stripe-elements/svg/scan.svg +1 -1
- package/dist/stripe-elements/svg/school-outline.svg +1 -1
- package/dist/stripe-elements/svg/school-sharp.svg +1 -1
- package/dist/stripe-elements/svg/school.svg +1 -1
- package/dist/stripe-elements/svg/search-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/search-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/search-circle.svg +1 -1
- package/dist/stripe-elements/svg/search-outline.svg +1 -1
- package/dist/stripe-elements/svg/search-sharp.svg +1 -1
- package/dist/stripe-elements/svg/search.svg +1 -1
- package/dist/stripe-elements/svg/send-outline.svg +1 -1
- package/dist/stripe-elements/svg/send-sharp.svg +1 -1
- package/dist/stripe-elements/svg/send.svg +1 -1
- package/dist/stripe-elements/svg/server-outline.svg +1 -1
- package/dist/stripe-elements/svg/server-sharp.svg +1 -1
- package/dist/stripe-elements/svg/server.svg +1 -1
- package/dist/stripe-elements/svg/settings-outline.svg +1 -1
- package/dist/stripe-elements/svg/settings-sharp.svg +1 -1
- package/dist/stripe-elements/svg/settings.svg +1 -1
- package/dist/stripe-elements/svg/shapes-outline.svg +1 -1
- package/dist/stripe-elements/svg/shapes-sharp.svg +1 -1
- package/dist/stripe-elements/svg/shapes.svg +1 -1
- package/dist/stripe-elements/svg/share-outline.svg +1 -1
- package/dist/stripe-elements/svg/share-sharp.svg +1 -1
- package/dist/stripe-elements/svg/share-social-outline.svg +1 -1
- package/dist/stripe-elements/svg/share-social-sharp.svg +1 -1
- package/dist/stripe-elements/svg/share-social.svg +1 -1
- package/dist/stripe-elements/svg/share.svg +1 -1
- package/dist/stripe-elements/svg/shield-checkmark-outline.svg +1 -1
- package/dist/stripe-elements/svg/shield-checkmark-sharp.svg +1 -1
- package/dist/stripe-elements/svg/shield-checkmark.svg +1 -1
- package/dist/stripe-elements/svg/shield-half-outline.svg +1 -1
- package/dist/stripe-elements/svg/shield-half-sharp.svg +1 -1
- package/dist/stripe-elements/svg/shield-half.svg +1 -1
- package/dist/stripe-elements/svg/shield-outline.svg +1 -1
- package/dist/stripe-elements/svg/shield-sharp.svg +1 -1
- package/dist/stripe-elements/svg/shield.svg +1 -1
- package/dist/stripe-elements/svg/shirt-outline.svg +1 -1
- package/dist/stripe-elements/svg/shirt-sharp.svg +1 -1
- package/dist/stripe-elements/svg/shirt.svg +1 -1
- package/dist/stripe-elements/svg/shuffle-outline.svg +1 -1
- package/dist/stripe-elements/svg/shuffle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/shuffle.svg +1 -1
- package/dist/stripe-elements/svg/skull-outline.svg +1 -1
- package/dist/stripe-elements/svg/skull-sharp.svg +1 -1
- package/dist/stripe-elements/svg/skull.svg +1 -1
- package/dist/stripe-elements/svg/snow-outline.svg +1 -1
- package/dist/stripe-elements/svg/snow-sharp.svg +1 -1
- package/dist/stripe-elements/svg/snow.svg +1 -1
- package/dist/stripe-elements/svg/sparkles-outline.svg +1 -1
- package/dist/stripe-elements/svg/sparkles-sharp.svg +1 -1
- package/dist/stripe-elements/svg/sparkles.svg +1 -1
- package/dist/stripe-elements/svg/speedometer-outline.svg +1 -1
- package/dist/stripe-elements/svg/speedometer-sharp.svg +1 -1
- package/dist/stripe-elements/svg/speedometer.svg +1 -1
- package/dist/stripe-elements/svg/square-outline.svg +1 -1
- package/dist/stripe-elements/svg/square-sharp.svg +1 -1
- package/dist/stripe-elements/svg/square.svg +1 -1
- package/dist/stripe-elements/svg/star-half-outline.svg +1 -1
- package/dist/stripe-elements/svg/star-half-sharp.svg +1 -1
- package/dist/stripe-elements/svg/star-half.svg +1 -1
- package/dist/stripe-elements/svg/star-outline.svg +1 -1
- package/dist/stripe-elements/svg/star-sharp.svg +1 -1
- package/dist/stripe-elements/svg/star.svg +1 -1
- package/dist/stripe-elements/svg/stats-chart-outline.svg +1 -1
- package/dist/stripe-elements/svg/stats-chart-sharp.svg +1 -1
- package/dist/stripe-elements/svg/stats-chart.svg +1 -1
- package/dist/stripe-elements/svg/stop-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/stop-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/stop-circle.svg +1 -1
- package/dist/stripe-elements/svg/stop-outline.svg +1 -1
- package/dist/stripe-elements/svg/stop-sharp.svg +1 -1
- package/dist/stripe-elements/svg/stop.svg +1 -1
- package/dist/stripe-elements/svg/stopwatch-outline.svg +1 -1
- package/dist/stripe-elements/svg/stopwatch-sharp.svg +1 -1
- package/dist/stripe-elements/svg/stopwatch.svg +1 -1
- package/dist/stripe-elements/svg/storefront-outline.svg +1 -1
- package/dist/stripe-elements/svg/storefront-sharp.svg +1 -1
- package/dist/stripe-elements/svg/storefront.svg +1 -1
- package/dist/stripe-elements/svg/subway-outline.svg +1 -1
- package/dist/stripe-elements/svg/subway-sharp.svg +1 -1
- package/dist/stripe-elements/svg/subway.svg +1 -1
- package/dist/stripe-elements/svg/sunny-outline.svg +1 -1
- package/dist/stripe-elements/svg/sunny-sharp.svg +1 -1
- package/dist/stripe-elements/svg/sunny.svg +1 -1
- package/dist/stripe-elements/svg/swap-horizontal-outline.svg +1 -1
- package/dist/stripe-elements/svg/swap-horizontal-sharp.svg +1 -1
- package/dist/stripe-elements/svg/swap-horizontal.svg +1 -1
- package/dist/stripe-elements/svg/swap-vertical-outline.svg +1 -1
- package/dist/stripe-elements/svg/swap-vertical-sharp.svg +1 -1
- package/dist/stripe-elements/svg/swap-vertical.svg +1 -1
- package/dist/stripe-elements/svg/sync-circle-outline.svg +1 -1
- package/dist/stripe-elements/svg/sync-circle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/sync-circle.svg +1 -1
- package/dist/stripe-elements/svg/sync-outline.svg +1 -1
- package/dist/stripe-elements/svg/sync-sharp.svg +1 -1
- package/dist/stripe-elements/svg/sync.svg +1 -1
- package/dist/stripe-elements/svg/tablet-landscape-outline.svg +1 -1
- package/dist/stripe-elements/svg/tablet-landscape-sharp.svg +1 -1
- package/dist/stripe-elements/svg/tablet-landscape.svg +1 -1
- package/dist/stripe-elements/svg/tablet-portrait-outline.svg +1 -1
- package/dist/stripe-elements/svg/tablet-portrait-sharp.svg +1 -1
- package/dist/stripe-elements/svg/tablet-portrait.svg +1 -1
- package/dist/stripe-elements/svg/telescope-outline.svg +1 -1
- package/dist/stripe-elements/svg/telescope-sharp.svg +1 -1
- package/dist/stripe-elements/svg/telescope.svg +1 -1
- package/dist/stripe-elements/svg/tennisball-outline.svg +1 -1
- package/dist/stripe-elements/svg/tennisball-sharp.svg +1 -1
- package/dist/stripe-elements/svg/tennisball.svg +1 -1
- package/dist/stripe-elements/svg/terminal-outline.svg +1 -1
- package/dist/stripe-elements/svg/terminal-sharp.svg +1 -1
- package/dist/stripe-elements/svg/terminal.svg +1 -1
- package/dist/stripe-elements/svg/text-outline.svg +1 -1
- package/dist/stripe-elements/svg/text-sharp.svg +1 -1
- package/dist/stripe-elements/svg/text.svg +1 -1
- package/dist/stripe-elements/svg/thermometer-outline.svg +1 -1
- package/dist/stripe-elements/svg/thermometer-sharp.svg +1 -1
- package/dist/stripe-elements/svg/thermometer.svg +1 -1
- package/dist/stripe-elements/svg/thumbs-down-outline.svg +1 -1
- package/dist/stripe-elements/svg/thumbs-down-sharp.svg +1 -1
- package/dist/stripe-elements/svg/thumbs-down.svg +1 -1
- package/dist/stripe-elements/svg/thumbs-up-outline.svg +1 -1
- package/dist/stripe-elements/svg/thumbs-up-sharp.svg +1 -1
- package/dist/stripe-elements/svg/thumbs-up.svg +1 -1
- package/dist/stripe-elements/svg/thunderstorm-outline.svg +1 -1
- package/dist/stripe-elements/svg/thunderstorm-sharp.svg +1 -1
- package/dist/stripe-elements/svg/thunderstorm.svg +1 -1
- package/dist/stripe-elements/svg/ticket-outline.svg +1 -1
- package/dist/stripe-elements/svg/ticket-sharp.svg +1 -1
- package/dist/stripe-elements/svg/ticket.svg +1 -1
- package/dist/stripe-elements/svg/time-outline.svg +1 -1
- package/dist/stripe-elements/svg/time-sharp.svg +1 -1
- package/dist/stripe-elements/svg/time.svg +1 -1
- package/dist/stripe-elements/svg/timer-outline.svg +1 -1
- package/dist/stripe-elements/svg/timer-sharp.svg +1 -1
- package/dist/stripe-elements/svg/timer.svg +1 -1
- package/dist/stripe-elements/svg/today-outline.svg +1 -1
- package/dist/stripe-elements/svg/today-sharp.svg +1 -1
- package/dist/stripe-elements/svg/today.svg +1 -1
- package/dist/stripe-elements/svg/toggle-outline.svg +1 -1
- package/dist/stripe-elements/svg/toggle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/toggle.svg +1 -1
- package/dist/stripe-elements/svg/trail-sign-outline.svg +1 -1
- package/dist/stripe-elements/svg/trail-sign-sharp.svg +1 -1
- package/dist/stripe-elements/svg/trail-sign.svg +1 -1
- package/dist/stripe-elements/svg/train-outline.svg +1 -1
- package/dist/stripe-elements/svg/train-sharp.svg +1 -1
- package/dist/stripe-elements/svg/train.svg +1 -1
- package/dist/stripe-elements/svg/transgender-outline.svg +1 -1
- package/dist/stripe-elements/svg/transgender-sharp.svg +1 -1
- package/dist/stripe-elements/svg/transgender.svg +1 -1
- package/dist/stripe-elements/svg/trash-bin-outline.svg +1 -1
- package/dist/stripe-elements/svg/trash-bin-sharp.svg +1 -1
- package/dist/stripe-elements/svg/trash-bin.svg +1 -1
- package/dist/stripe-elements/svg/trash-outline.svg +1 -1
- package/dist/stripe-elements/svg/trash-sharp.svg +1 -1
- package/dist/stripe-elements/svg/trash.svg +1 -1
- package/dist/stripe-elements/svg/trending-down-outline.svg +1 -1
- package/dist/stripe-elements/svg/trending-down-sharp.svg +1 -1
- package/dist/stripe-elements/svg/trending-down.svg +1 -1
- package/dist/stripe-elements/svg/trending-up-outline.svg +1 -1
- package/dist/stripe-elements/svg/trending-up-sharp.svg +1 -1
- package/dist/stripe-elements/svg/trending-up.svg +1 -1
- package/dist/stripe-elements/svg/triangle-outline.svg +1 -1
- package/dist/stripe-elements/svg/triangle-sharp.svg +1 -1
- package/dist/stripe-elements/svg/triangle.svg +1 -1
- package/dist/stripe-elements/svg/trophy-outline.svg +1 -1
- package/dist/stripe-elements/svg/trophy-sharp.svg +1 -1
- package/dist/stripe-elements/svg/trophy.svg +1 -1
- package/dist/stripe-elements/svg/tv-outline.svg +1 -1
- package/dist/stripe-elements/svg/tv-sharp.svg +1 -1
- package/dist/stripe-elements/svg/tv.svg +1 -1
- package/dist/stripe-elements/svg/umbrella-outline.svg +1 -1
- package/dist/stripe-elements/svg/umbrella-sharp.svg +1 -1
- package/dist/stripe-elements/svg/umbrella.svg +1 -1
- package/dist/stripe-elements/svg/unlink-outline.svg +1 -1
- package/dist/stripe-elements/svg/unlink-sharp.svg +1 -1
- package/dist/stripe-elements/svg/unlink.svg +1 -1
- package/dist/stripe-elements/svg/videocam-off-outline.svg +1 -1
- package/dist/stripe-elements/svg/videocam-off-sharp.svg +1 -1
- package/dist/stripe-elements/svg/videocam-off.svg +1 -1
- package/dist/stripe-elements/svg/videocam-outline.svg +1 -1
- package/dist/stripe-elements/svg/videocam-sharp.svg +1 -1
- package/dist/stripe-elements/svg/videocam.svg +1 -1
- package/dist/stripe-elements/svg/volume-high-outline.svg +1 -1
- package/dist/stripe-elements/svg/volume-high-sharp.svg +1 -1
- package/dist/stripe-elements/svg/volume-high.svg +1 -1
- package/dist/stripe-elements/svg/volume-low-outline.svg +1 -1
- package/dist/stripe-elements/svg/volume-low-sharp.svg +1 -1
- package/dist/stripe-elements/svg/volume-low.svg +1 -1
- package/dist/stripe-elements/svg/volume-medium-outline.svg +1 -1
- package/dist/stripe-elements/svg/volume-medium-sharp.svg +1 -1
- package/dist/stripe-elements/svg/volume-medium.svg +1 -1
- package/dist/stripe-elements/svg/volume-mute-outline.svg +1 -1
- package/dist/stripe-elements/svg/volume-mute-sharp.svg +1 -1
- package/dist/stripe-elements/svg/volume-mute.svg +1 -1
- package/dist/stripe-elements/svg/volume-off-outline.svg +1 -1
- package/dist/stripe-elements/svg/volume-off-sharp.svg +1 -1
- package/dist/stripe-elements/svg/volume-off.svg +1 -1
- package/dist/stripe-elements/svg/walk-outline.svg +1 -1
- package/dist/stripe-elements/svg/walk-sharp.svg +1 -1
- package/dist/stripe-elements/svg/walk.svg +1 -1
- package/dist/stripe-elements/svg/wallet-outline.svg +1 -1
- package/dist/stripe-elements/svg/wallet-sharp.svg +1 -1
- package/dist/stripe-elements/svg/wallet.svg +1 -1
- package/dist/stripe-elements/svg/warning-outline.svg +1 -1
- package/dist/stripe-elements/svg/warning-sharp.svg +1 -1
- package/dist/stripe-elements/svg/warning.svg +1 -1
- package/dist/stripe-elements/svg/watch-outline.svg +1 -1
- package/dist/stripe-elements/svg/watch-sharp.svg +1 -1
- package/dist/stripe-elements/svg/watch.svg +1 -1
- package/dist/stripe-elements/svg/water-outline.svg +1 -1
- package/dist/stripe-elements/svg/water-sharp.svg +1 -1
- package/dist/stripe-elements/svg/water.svg +1 -1
- package/dist/stripe-elements/svg/wifi-outline.svg +1 -1
- package/dist/stripe-elements/svg/wifi-sharp.svg +1 -1
- package/dist/stripe-elements/svg/wifi.svg +1 -1
- package/dist/stripe-elements/svg/wine-outline.svg +1 -1
- package/dist/stripe-elements/svg/wine-sharp.svg +1 -1
- package/dist/stripe-elements/svg/wine.svg +1 -1
- package/dist/stripe-elements/svg/woman-outline.svg +1 -1
- package/dist/stripe-elements/svg/woman-sharp.svg +1 -1
- package/dist/stripe-elements/svg/woman.svg +1 -1
- package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +264 -0
- package/dist/types/components/stripe-card-element-modal/stripe-card-element-modal.d.ts +124 -0
- package/dist/types/components/stripe-modal/stripe-modal.d.ts +31 -0
- package/dist/types/components/stripe-payment-request-button/stripe-payment-request-button.d.ts +141 -136
- package/dist/types/components.d.ts +231 -155
- package/dist/types/interfaces.d.ts +17 -10
- package/dist/types/services/card-element-manager.d.ts +56 -0
- package/dist/types/services/factory.d.ts +22 -0
- package/dist/types/services/interfaces.d.ts +95 -0
- package/dist/types/services/stripe-service.d.ts +61 -0
- package/dist/types/stencil-public-runtime.d.ts +137 -19
- package/dist/types/utils/error.d.ts +10 -0
- package/dist/types/utils/platform.d.ts +18 -18
- package/dist/types/utils/utils.d.ts +1 -1
- package/loader/cdn.js +1 -3
- package/loader/index.cjs.js +1 -3
- package/loader/index.d.ts +4 -1
- package/loader/index.es2017.js +1 -3
- package/loader/index.js +1 -3
- package/package.json +26 -25
- package/readme.md +29 -23
- package/dist/cjs/index-0cec7387.js +0 -2053
- package/dist/cjs/index-0cec7387.js.map +0 -1
- package/dist/cjs/ion-icon.cjs.entry.js.map +0 -1
- package/dist/cjs/stripe-payment-request-button.cjs.entry.js.map +0 -1
- package/dist/cjs/stripe-payment-sheet.cjs.entry.js +0 -96
- package/dist/cjs/stripe-payment-sheet.cjs.entry.js.map +0 -1
- package/dist/cjs/stripe-payment_2.cjs.entry.js +0 -3509
- package/dist/cjs/stripe-payment_2.cjs.entry.js.map +0 -1
- package/dist/cjs/stripe.esm-603f3c17.js +0 -133
- package/dist/cjs/stripe.esm-603f3c17.js.map +0 -1
- package/dist/collection/components/stripe-element-modal/stripe-element-modal.js +0 -161
- package/dist/collection/components/stripe-element-modal/stripe-element-modal.js.map +0 -1
- package/dist/collection/components/stripe-element-modal/test/stripe-element-modal.e2e.js +0 -10
- package/dist/collection/components/stripe-element-modal/test/stripe-element-modal.e2e.js.map +0 -1
- package/dist/collection/components/stripe-element-modal/test/stripe-element-modal.spec.js +0 -120
- package/dist/collection/components/stripe-element-modal/test/stripe-element-modal.spec.js.map +0 -1
- package/dist/collection/components/stripe-payment-request-button/test/stripe-payment-request-button.e2e.js +0 -10
- package/dist/collection/components/stripe-payment-request-button/test/stripe-payment-request-button.e2e.js.map +0 -1
- package/dist/collection/components/stripe-payment-request-button/test/stripe-payment-request-button.spec.js +0 -18
- package/dist/collection/components/stripe-payment-request-button/test/stripe-payment-request-button.spec.js.map +0 -1
- package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.js +0 -808
- package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.js.map +0 -1
- package/dist/collection/components/stripe-payment-sheet/test/stripe-payment-sheet.e2e.js +0 -10
- package/dist/collection/components/stripe-payment-sheet/test/stripe-payment-sheet.e2e.js.map +0 -1
- package/dist/collection/components/stripe-payment-sheet/test/stripe-payment-sheet.spec.js +0 -111
- package/dist/collection/components/stripe-payment-sheet/test/stripe-payment-sheet.spec.js.map +0 -1
- package/dist/collection/components/stripe-payment-sheet-modal/stripe-payment-sheet-modal.js +0 -487
- package/dist/collection/components/stripe-payment-sheet-modal/stripe-payment-sheet-modal.js.map +0 -1
- package/dist/collection/components/stripe-payment-sheet-modal/test/stripe-payment-sheet-modal.e2e.js +0 -10
- package/dist/collection/components/stripe-payment-sheet-modal/test/stripe-payment-sheet-modal.e2e.js.map +0 -1
- package/dist/collection/components/stripe-payment-sheet-modal/test/stripe-payment-sheet-modal.spec.js +0 -16
- package/dist/collection/components/stripe-payment-sheet-modal/test/stripe-payment-sheet-modal.spec.js.map +0 -1
- package/dist/components/stripe-element-modal.js +0 -75
- package/dist/components/stripe-element-modal.js.map +0 -1
- package/dist/components/stripe-payment-sheet.d.ts +0 -11
- package/dist/components/stripe-payment-sheet.js +0 -153
- package/dist/components/stripe-payment-sheet.js.map +0 -1
- package/dist/components/stripe-payment-sheet2.js +0 -3404
- package/dist/components/stripe-payment-sheet2.js.map +0 -1
- package/dist/components/stripe-payment.js +0 -8
- package/dist/components/stripe-payment.js.map +0 -1
- package/dist/components/stripe-sheet.js +0 -8
- package/dist/components/stripe-sheet.js.map +0 -1
- package/dist/esm/index-58f9666b.js +0 -2023
- package/dist/esm/index-58f9666b.js.map +0 -1
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/esm/stripe-payment-sheet.entry.js +0 -92
- package/dist/esm/stripe-payment-sheet.entry.js.map +0 -1
- package/dist/esm/stripe-payment_2.entry.js +0 -3504
- package/dist/esm/stripe-payment_2.entry.js.map +0 -1
- package/dist/esm/stripe.esm-bad47977.js +0 -131
- package/dist/esm/stripe.esm-bad47977.js.map +0 -1
- package/dist/node_modules/ionicons/dist/collection/components/icon/icon.css +0 -143
- package/dist/stripe-elements/p-06c00b5c.entry.js +0 -2
- package/dist/stripe-elements/p-06c00b5c.entry.js.map +0 -1
- package/dist/stripe-elements/p-1b4515a4.js +0 -3
- package/dist/stripe-elements/p-1b4515a4.js.map +0 -1
- package/dist/stripe-elements/p-3458123a.entry.js +0 -2
- package/dist/stripe-elements/p-3458123a.entry.js.map +0 -1
- package/dist/stripe-elements/p-3a90ad5d.entry.js +0 -2
- package/dist/stripe-elements/p-3a90ad5d.entry.js.map +0 -1
- package/dist/stripe-elements/p-b10d8613.js +0 -2
- package/dist/stripe-elements/p-b10d8613.js.map +0 -1
- package/dist/stripe-elements/p-c5a2b2e8.entry.js +0 -2
- package/dist/stripe-elements/p-c5a2b2e8.entry.js.map +0 -1
- package/dist/types/components/stripe-element-modal/stripe-element-modal.d.ts +0 -31
- package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.d.ts +0 -278
- package/dist/types/components/stripe-payment-sheet-modal/stripe-payment-sheet-modal.d.ts +0 -124
- package/loader/package.json +0 -11
- /package/dist/collection/components/{stripe-payment-sheet-modal/stripe-payment-sheet-modal.css → stripe-card-element-modal/stripe-card-element-modal.css} +0 -0
- /package/dist/collection/components/{stripe-element-modal/stripe-element-modal.css → stripe-modal/stripe-modal.css} +0 -0
|
@@ -0,0 +1,3677 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-CQkz7IJv.js');
|
|
4
|
+
var index$1 = require('./index-BmB5d_Yj.js');
|
|
5
|
+
|
|
6
|
+
const getPlatforms = (win) => setupPlatforms(win);
|
|
7
|
+
const setupPlatforms = (win = window) => {
|
|
8
|
+
if (typeof win === 'undefined') {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
win.Ionic = win.Ionic || {};
|
|
12
|
+
let platforms = win.Ionic.platforms;
|
|
13
|
+
if (platforms == null) {
|
|
14
|
+
platforms = win.Ionic.platforms = detectPlatforms(win);
|
|
15
|
+
platforms.forEach(p => win.document.documentElement.classList.add(`plt-${p}`));
|
|
16
|
+
}
|
|
17
|
+
return platforms;
|
|
18
|
+
};
|
|
19
|
+
const detectPlatforms = (win) => Object.keys(PLATFORMS_MAP).filter(p => PLATFORMS_MAP[p](win));
|
|
20
|
+
const isMobileWeb = (win) => isMobile(win) && !isHybrid(win);
|
|
21
|
+
const isIpad = (win) => {
|
|
22
|
+
// iOS 12 and below
|
|
23
|
+
if (testUserAgent(win, /iPad/i)) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
// iOS 13+
|
|
27
|
+
if (testUserAgent(win, /Macintosh/i) && isMobile(win)) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
};
|
|
32
|
+
const isIphone = (win) => testUserAgent(win, /iPhone/i);
|
|
33
|
+
const isIOS = (win) => testUserAgent(win, /iPhone|iPod/i) || isIpad(win);
|
|
34
|
+
const isAndroid = (win) => testUserAgent(win, /android|sink/i);
|
|
35
|
+
const isAndroidTablet = (win) => {
|
|
36
|
+
return isAndroid(win) && !testUserAgent(win, /mobile/i);
|
|
37
|
+
};
|
|
38
|
+
const isPhablet = (win) => {
|
|
39
|
+
const width = win.innerWidth;
|
|
40
|
+
const height = win.innerHeight;
|
|
41
|
+
const smallest = Math.min(width, height);
|
|
42
|
+
const largest = Math.max(width, height);
|
|
43
|
+
return smallest > 390 && smallest < 520 && largest > 620 && largest < 800;
|
|
44
|
+
};
|
|
45
|
+
const isTablet = (win) => {
|
|
46
|
+
const width = win.innerWidth;
|
|
47
|
+
const height = win.innerHeight;
|
|
48
|
+
const smallest = Math.min(width, height);
|
|
49
|
+
const largest = Math.max(width, height);
|
|
50
|
+
return isIpad(win) || isAndroidTablet(win) || (smallest > 460 && smallest < 820 && largest > 780 && largest < 1400);
|
|
51
|
+
};
|
|
52
|
+
const isMobile = (win) => matchMedia(win, '(any-pointer:coarse)');
|
|
53
|
+
const isDesktop = (win) => !isMobile(win);
|
|
54
|
+
const isHybrid = (win) => isCordova(win) || isCapacitorNative(win);
|
|
55
|
+
const isCordova = (win) => !!(win['cordova'] || win['phonegap'] || win['PhoneGap']);
|
|
56
|
+
const isCapacitorNative = (win) => {
|
|
57
|
+
const capacitor = win['Capacitor'];
|
|
58
|
+
return !!(capacitor && capacitor.isNative);
|
|
59
|
+
};
|
|
60
|
+
const isElectron = (win) => testUserAgent(win, /electron/i);
|
|
61
|
+
const isPWA = (win) => !!(win.matchMedia('(display-mode: standalone)').matches || win.navigator.standalone);
|
|
62
|
+
const testUserAgent = (win, expr) => expr.test(win.navigator.userAgent);
|
|
63
|
+
const matchMedia = (win, query) => win.matchMedia(query).matches;
|
|
64
|
+
const PLATFORMS_MAP = {
|
|
65
|
+
ipad: isIpad,
|
|
66
|
+
iphone: isIphone,
|
|
67
|
+
ios: isIOS,
|
|
68
|
+
android: isAndroid,
|
|
69
|
+
phablet: isPhablet,
|
|
70
|
+
tablet: isTablet,
|
|
71
|
+
cordova: isCordova,
|
|
72
|
+
capacitor: isCapacitorNative,
|
|
73
|
+
electron: isElectron,
|
|
74
|
+
pwa: isPWA,
|
|
75
|
+
mobile: isMobile,
|
|
76
|
+
mobileweb: isMobileWeb,
|
|
77
|
+
desktop: isDesktop,
|
|
78
|
+
hybrid: isHybrid,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const checkPlatform = () => {
|
|
82
|
+
const device = getPlatforms();
|
|
83
|
+
if (device.includes('ios')) {
|
|
84
|
+
return 'ios';
|
|
85
|
+
}
|
|
86
|
+
if (device.includes('android')) {
|
|
87
|
+
return 'android';
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const isString = obj => typeof obj === 'string';
|
|
92
|
+
const defer = () => {
|
|
93
|
+
let res;
|
|
94
|
+
let rej;
|
|
95
|
+
const promise = new Promise((resolve, reject) => {
|
|
96
|
+
res = resolve;
|
|
97
|
+
rej = reject;
|
|
98
|
+
});
|
|
99
|
+
promise.resolve = res;
|
|
100
|
+
promise.reject = rej;
|
|
101
|
+
return promise;
|
|
102
|
+
};
|
|
103
|
+
const makeString = object => {
|
|
104
|
+
if (object == null) return '';
|
|
105
|
+
return '' + object;
|
|
106
|
+
};
|
|
107
|
+
const copy = (a, s, t) => {
|
|
108
|
+
a.forEach(m => {
|
|
109
|
+
if (s[m]) t[m] = s[m];
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
const lastOfPathSeparatorRegExp = /###/g;
|
|
113
|
+
const cleanKey = key => key && key.indexOf('###') > -1 ? key.replace(lastOfPathSeparatorRegExp, '.') : key;
|
|
114
|
+
const canNotTraverseDeeper = object => !object || isString(object);
|
|
115
|
+
const getLastOfPath = (object, path, Empty) => {
|
|
116
|
+
const stack = !isString(path) ? path : path.split('.');
|
|
117
|
+
let stackIndex = 0;
|
|
118
|
+
while (stackIndex < stack.length - 1) {
|
|
119
|
+
if (canNotTraverseDeeper(object)) return {};
|
|
120
|
+
const key = cleanKey(stack[stackIndex]);
|
|
121
|
+
if (!object[key] && Empty) object[key] = new Empty();
|
|
122
|
+
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
123
|
+
object = object[key];
|
|
124
|
+
} else {
|
|
125
|
+
object = {};
|
|
126
|
+
}
|
|
127
|
+
++stackIndex;
|
|
128
|
+
}
|
|
129
|
+
if (canNotTraverseDeeper(object)) return {};
|
|
130
|
+
return {
|
|
131
|
+
obj: object,
|
|
132
|
+
k: cleanKey(stack[stackIndex])
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
const setPath = (object, path, newValue) => {
|
|
136
|
+
const {
|
|
137
|
+
obj,
|
|
138
|
+
k
|
|
139
|
+
} = getLastOfPath(object, path, Object);
|
|
140
|
+
if (obj !== undefined || path.length === 1) {
|
|
141
|
+
obj[k] = newValue;
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
let e = path[path.length - 1];
|
|
145
|
+
let p = path.slice(0, path.length - 1);
|
|
146
|
+
let last = getLastOfPath(object, p, Object);
|
|
147
|
+
while (last.obj === undefined && p.length) {
|
|
148
|
+
e = `${p[p.length - 1]}.${e}`;
|
|
149
|
+
p = p.slice(0, p.length - 1);
|
|
150
|
+
last = getLastOfPath(object, p, Object);
|
|
151
|
+
if (last?.obj && typeof last.obj[`${last.k}.${e}`] !== 'undefined') {
|
|
152
|
+
last.obj = undefined;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
last.obj[`${last.k}.${e}`] = newValue;
|
|
156
|
+
};
|
|
157
|
+
const pushPath = (object, path, newValue, concat) => {
|
|
158
|
+
const {
|
|
159
|
+
obj,
|
|
160
|
+
k
|
|
161
|
+
} = getLastOfPath(object, path, Object);
|
|
162
|
+
obj[k] = obj[k] || [];
|
|
163
|
+
obj[k].push(newValue);
|
|
164
|
+
};
|
|
165
|
+
const getPath = (object, path) => {
|
|
166
|
+
const {
|
|
167
|
+
obj,
|
|
168
|
+
k
|
|
169
|
+
} = getLastOfPath(object, path);
|
|
170
|
+
if (!obj) return undefined;
|
|
171
|
+
if (!Object.prototype.hasOwnProperty.call(obj, k)) return undefined;
|
|
172
|
+
return obj[k];
|
|
173
|
+
};
|
|
174
|
+
const getPathWithDefaults = (data, defaultData, key) => {
|
|
175
|
+
const value = getPath(data, key);
|
|
176
|
+
if (value !== undefined) {
|
|
177
|
+
return value;
|
|
178
|
+
}
|
|
179
|
+
return getPath(defaultData, key);
|
|
180
|
+
};
|
|
181
|
+
const deepExtend = (target, source, overwrite) => {
|
|
182
|
+
for (const prop in source) {
|
|
183
|
+
if (prop !== '__proto__' && prop !== 'constructor') {
|
|
184
|
+
if (prop in target) {
|
|
185
|
+
if (isString(target[prop]) || target[prop] instanceof String || isString(source[prop]) || source[prop] instanceof String) {
|
|
186
|
+
if (overwrite) target[prop] = source[prop];
|
|
187
|
+
} else {
|
|
188
|
+
deepExtend(target[prop], source[prop], overwrite);
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
target[prop] = source[prop];
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return target;
|
|
196
|
+
};
|
|
197
|
+
const regexEscape = str => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
|
198
|
+
var _entityMap = {
|
|
199
|
+
'&': '&',
|
|
200
|
+
'<': '<',
|
|
201
|
+
'>': '>',
|
|
202
|
+
'"': '"',
|
|
203
|
+
"'": ''',
|
|
204
|
+
'/': '/'
|
|
205
|
+
};
|
|
206
|
+
const escape = data => {
|
|
207
|
+
if (isString(data)) {
|
|
208
|
+
return data.replace(/[&<>"'\/]/g, s => _entityMap[s]);
|
|
209
|
+
}
|
|
210
|
+
return data;
|
|
211
|
+
};
|
|
212
|
+
class RegExpCache {
|
|
213
|
+
constructor(capacity) {
|
|
214
|
+
this.capacity = capacity;
|
|
215
|
+
this.regExpMap = new Map();
|
|
216
|
+
this.regExpQueue = [];
|
|
217
|
+
}
|
|
218
|
+
getRegExp(pattern) {
|
|
219
|
+
const regExpFromCache = this.regExpMap.get(pattern);
|
|
220
|
+
if (regExpFromCache !== undefined) {
|
|
221
|
+
return regExpFromCache;
|
|
222
|
+
}
|
|
223
|
+
const regExpNew = new RegExp(pattern);
|
|
224
|
+
if (this.regExpQueue.length === this.capacity) {
|
|
225
|
+
this.regExpMap.delete(this.regExpQueue.shift());
|
|
226
|
+
}
|
|
227
|
+
this.regExpMap.set(pattern, regExpNew);
|
|
228
|
+
this.regExpQueue.push(pattern);
|
|
229
|
+
return regExpNew;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const chars = [' ', ',', '?', '!', ';'];
|
|
233
|
+
const looksLikeObjectPathRegExpCache = new RegExpCache(20);
|
|
234
|
+
const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
|
|
235
|
+
nsSeparator = nsSeparator || '';
|
|
236
|
+
keySeparator = keySeparator || '';
|
|
237
|
+
const possibleChars = chars.filter(c => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
|
|
238
|
+
if (possibleChars.length === 0) return true;
|
|
239
|
+
const r = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map(c => c === '?' ? '\\?' : c).join('|')})`);
|
|
240
|
+
let matched = !r.test(key);
|
|
241
|
+
if (!matched) {
|
|
242
|
+
const ki = key.indexOf(keySeparator);
|
|
243
|
+
if (ki > 0 && !r.test(key.substring(0, ki))) {
|
|
244
|
+
matched = true;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return matched;
|
|
248
|
+
};
|
|
249
|
+
const deepFind = (obj, path, keySeparator = '.') => {
|
|
250
|
+
if (!obj) return undefined;
|
|
251
|
+
if (obj[path]) {
|
|
252
|
+
if (!Object.prototype.hasOwnProperty.call(obj, path)) return undefined;
|
|
253
|
+
return obj[path];
|
|
254
|
+
}
|
|
255
|
+
const tokens = path.split(keySeparator);
|
|
256
|
+
let current = obj;
|
|
257
|
+
for (let i = 0; i < tokens.length;) {
|
|
258
|
+
if (!current || typeof current !== 'object') {
|
|
259
|
+
return undefined;
|
|
260
|
+
}
|
|
261
|
+
let next;
|
|
262
|
+
let nextPath = '';
|
|
263
|
+
for (let j = i; j < tokens.length; ++j) {
|
|
264
|
+
if (j !== i) {
|
|
265
|
+
nextPath += keySeparator;
|
|
266
|
+
}
|
|
267
|
+
nextPath += tokens[j];
|
|
268
|
+
next = current[nextPath];
|
|
269
|
+
if (next !== undefined) {
|
|
270
|
+
if (['string', 'number', 'boolean'].indexOf(typeof next) > -1 && j < tokens.length - 1) {
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
i += j - i + 1;
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
current = next;
|
|
278
|
+
}
|
|
279
|
+
return current;
|
|
280
|
+
};
|
|
281
|
+
const getCleanedCode = code => code?.replace('_', '-');
|
|
282
|
+
|
|
283
|
+
const consoleLogger = {
|
|
284
|
+
type: 'logger',
|
|
285
|
+
log(args) {
|
|
286
|
+
this.output('log', args);
|
|
287
|
+
},
|
|
288
|
+
warn(args) {
|
|
289
|
+
this.output('warn', args);
|
|
290
|
+
},
|
|
291
|
+
error(args) {
|
|
292
|
+
this.output('error', args);
|
|
293
|
+
},
|
|
294
|
+
output(type, args) {
|
|
295
|
+
console?.[type]?.apply?.(console, args);
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
class Logger {
|
|
299
|
+
constructor(concreteLogger, options = {}) {
|
|
300
|
+
this.init(concreteLogger, options);
|
|
301
|
+
}
|
|
302
|
+
init(concreteLogger, options = {}) {
|
|
303
|
+
this.prefix = options.prefix || 'i18next:';
|
|
304
|
+
this.logger = concreteLogger || consoleLogger;
|
|
305
|
+
this.options = options;
|
|
306
|
+
this.debug = options.debug;
|
|
307
|
+
}
|
|
308
|
+
log(...args) {
|
|
309
|
+
return this.forward(args, 'log', '', true);
|
|
310
|
+
}
|
|
311
|
+
warn(...args) {
|
|
312
|
+
return this.forward(args, 'warn', '', true);
|
|
313
|
+
}
|
|
314
|
+
error(...args) {
|
|
315
|
+
return this.forward(args, 'error', '');
|
|
316
|
+
}
|
|
317
|
+
deprecate(...args) {
|
|
318
|
+
return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
|
|
319
|
+
}
|
|
320
|
+
forward(args, lvl, prefix, debugOnly) {
|
|
321
|
+
if (debugOnly && !this.debug) return null;
|
|
322
|
+
if (isString(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
|
|
323
|
+
return this.logger[lvl](args);
|
|
324
|
+
}
|
|
325
|
+
create(moduleName) {
|
|
326
|
+
return new Logger(this.logger, {
|
|
327
|
+
...{
|
|
328
|
+
prefix: `${this.prefix}:${moduleName}:`
|
|
329
|
+
},
|
|
330
|
+
...this.options
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
clone(options) {
|
|
334
|
+
options = options || this.options;
|
|
335
|
+
options.prefix = options.prefix || this.prefix;
|
|
336
|
+
return new Logger(this.logger, options);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
var baseLogger = new Logger();
|
|
340
|
+
|
|
341
|
+
class EventEmitter {
|
|
342
|
+
constructor() {
|
|
343
|
+
this.observers = {};
|
|
344
|
+
}
|
|
345
|
+
on(events, listener) {
|
|
346
|
+
events.split(' ').forEach(event => {
|
|
347
|
+
if (!this.observers[event]) this.observers[event] = new Map();
|
|
348
|
+
const numListeners = this.observers[event].get(listener) || 0;
|
|
349
|
+
this.observers[event].set(listener, numListeners + 1);
|
|
350
|
+
});
|
|
351
|
+
return this;
|
|
352
|
+
}
|
|
353
|
+
off(event, listener) {
|
|
354
|
+
if (!this.observers[event]) return;
|
|
355
|
+
if (!listener) {
|
|
356
|
+
delete this.observers[event];
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
this.observers[event].delete(listener);
|
|
360
|
+
}
|
|
361
|
+
emit(event, ...args) {
|
|
362
|
+
if (this.observers[event]) {
|
|
363
|
+
const cloned = Array.from(this.observers[event].entries());
|
|
364
|
+
cloned.forEach(([observer, numTimesAdded]) => {
|
|
365
|
+
for (let i = 0; i < numTimesAdded; i++) {
|
|
366
|
+
observer(...args);
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
if (this.observers['*']) {
|
|
371
|
+
const cloned = Array.from(this.observers['*'].entries());
|
|
372
|
+
cloned.forEach(([observer, numTimesAdded]) => {
|
|
373
|
+
for (let i = 0; i < numTimesAdded; i++) {
|
|
374
|
+
observer.apply(observer, [event, ...args]);
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
class ResourceStore extends EventEmitter {
|
|
382
|
+
constructor(data, options = {
|
|
383
|
+
ns: ['translation'],
|
|
384
|
+
defaultNS: 'translation'
|
|
385
|
+
}) {
|
|
386
|
+
super();
|
|
387
|
+
this.data = data || {};
|
|
388
|
+
this.options = options;
|
|
389
|
+
if (this.options.keySeparator === undefined) {
|
|
390
|
+
this.options.keySeparator = '.';
|
|
391
|
+
}
|
|
392
|
+
if (this.options.ignoreJSONStructure === undefined) {
|
|
393
|
+
this.options.ignoreJSONStructure = true;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
addNamespaces(ns) {
|
|
397
|
+
if (this.options.ns.indexOf(ns) < 0) {
|
|
398
|
+
this.options.ns.push(ns);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
removeNamespaces(ns) {
|
|
402
|
+
const index = this.options.ns.indexOf(ns);
|
|
403
|
+
if (index > -1) {
|
|
404
|
+
this.options.ns.splice(index, 1);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
getResource(lng, ns, key, options = {}) {
|
|
408
|
+
const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
409
|
+
const ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
410
|
+
let path;
|
|
411
|
+
if (lng.indexOf('.') > -1) {
|
|
412
|
+
path = lng.split('.');
|
|
413
|
+
} else {
|
|
414
|
+
path = [lng, ns];
|
|
415
|
+
if (key) {
|
|
416
|
+
if (Array.isArray(key)) {
|
|
417
|
+
path.push(...key);
|
|
418
|
+
} else if (isString(key) && keySeparator) {
|
|
419
|
+
path.push(...key.split(keySeparator));
|
|
420
|
+
} else {
|
|
421
|
+
path.push(key);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
const result = getPath(this.data, path);
|
|
426
|
+
if (!result && !ns && !key && lng.indexOf('.') > -1) {
|
|
427
|
+
lng = path[0];
|
|
428
|
+
ns = path[1];
|
|
429
|
+
key = path.slice(2).join('.');
|
|
430
|
+
}
|
|
431
|
+
if (result || !ignoreJSONStructure || !isString(key)) return result;
|
|
432
|
+
return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
|
|
433
|
+
}
|
|
434
|
+
addResource(lng, ns, key, value, options = {
|
|
435
|
+
silent: false
|
|
436
|
+
}) {
|
|
437
|
+
const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
438
|
+
let path = [lng, ns];
|
|
439
|
+
if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
|
440
|
+
if (lng.indexOf('.') > -1) {
|
|
441
|
+
path = lng.split('.');
|
|
442
|
+
value = ns;
|
|
443
|
+
ns = path[1];
|
|
444
|
+
}
|
|
445
|
+
this.addNamespaces(ns);
|
|
446
|
+
setPath(this.data, path, value);
|
|
447
|
+
if (!options.silent) this.emit('added', lng, ns, key, value);
|
|
448
|
+
}
|
|
449
|
+
addResources(lng, ns, resources, options = {
|
|
450
|
+
silent: false
|
|
451
|
+
}) {
|
|
452
|
+
for (const m in resources) {
|
|
453
|
+
if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
|
|
454
|
+
silent: true
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
if (!options.silent) this.emit('added', lng, ns, resources);
|
|
458
|
+
}
|
|
459
|
+
addResourceBundle(lng, ns, resources, deep, overwrite, options = {
|
|
460
|
+
silent: false,
|
|
461
|
+
skipCopy: false
|
|
462
|
+
}) {
|
|
463
|
+
let path = [lng, ns];
|
|
464
|
+
if (lng.indexOf('.') > -1) {
|
|
465
|
+
path = lng.split('.');
|
|
466
|
+
deep = resources;
|
|
467
|
+
resources = ns;
|
|
468
|
+
ns = path[1];
|
|
469
|
+
}
|
|
470
|
+
this.addNamespaces(ns);
|
|
471
|
+
let pack = getPath(this.data, path) || {};
|
|
472
|
+
if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
|
|
473
|
+
if (deep) {
|
|
474
|
+
deepExtend(pack, resources, overwrite);
|
|
475
|
+
} else {
|
|
476
|
+
pack = {
|
|
477
|
+
...pack,
|
|
478
|
+
...resources
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
setPath(this.data, path, pack);
|
|
482
|
+
if (!options.silent) this.emit('added', lng, ns, resources);
|
|
483
|
+
}
|
|
484
|
+
removeResourceBundle(lng, ns) {
|
|
485
|
+
if (this.hasResourceBundle(lng, ns)) {
|
|
486
|
+
delete this.data[lng][ns];
|
|
487
|
+
}
|
|
488
|
+
this.removeNamespaces(ns);
|
|
489
|
+
this.emit('removed', lng, ns);
|
|
490
|
+
}
|
|
491
|
+
hasResourceBundle(lng, ns) {
|
|
492
|
+
return this.getResource(lng, ns) !== undefined;
|
|
493
|
+
}
|
|
494
|
+
getResourceBundle(lng, ns) {
|
|
495
|
+
if (!ns) ns = this.options.defaultNS;
|
|
496
|
+
return this.getResource(lng, ns);
|
|
497
|
+
}
|
|
498
|
+
getDataByLanguage(lng) {
|
|
499
|
+
return this.data[lng];
|
|
500
|
+
}
|
|
501
|
+
hasLanguageSomeTranslations(lng) {
|
|
502
|
+
const data = this.getDataByLanguage(lng);
|
|
503
|
+
const n = data && Object.keys(data) || [];
|
|
504
|
+
return !!n.find(v => data[v] && Object.keys(data[v]).length > 0);
|
|
505
|
+
}
|
|
506
|
+
toJSON() {
|
|
507
|
+
return this.data;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
var postProcessor = {
|
|
512
|
+
processors: {},
|
|
513
|
+
addPostProcessor(module) {
|
|
514
|
+
this.processors[module.name] = module;
|
|
515
|
+
},
|
|
516
|
+
handle(processors, value, key, options, translator) {
|
|
517
|
+
processors.forEach(processor => {
|
|
518
|
+
value = this.processors[processor]?.process(value, key, options, translator) ?? value;
|
|
519
|
+
});
|
|
520
|
+
return value;
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
const PATH_KEY = Symbol('i18next/PATH_KEY');
|
|
525
|
+
function createProxy() {
|
|
526
|
+
const state = [];
|
|
527
|
+
const handler = Object.create(null);
|
|
528
|
+
let proxy;
|
|
529
|
+
handler.get = (target, key) => {
|
|
530
|
+
proxy?.revoke?.();
|
|
531
|
+
if (key === PATH_KEY) return state;
|
|
532
|
+
state.push(key);
|
|
533
|
+
proxy = Proxy.revocable(target, handler);
|
|
534
|
+
return proxy.proxy;
|
|
535
|
+
};
|
|
536
|
+
return Proxy.revocable(Object.create(null), handler).proxy;
|
|
537
|
+
}
|
|
538
|
+
function keysFromSelector(selector, opts) {
|
|
539
|
+
const {
|
|
540
|
+
[PATH_KEY]: path
|
|
541
|
+
} = selector(createProxy());
|
|
542
|
+
return path.join(opts?.keySeparator ?? '.');
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
const checkedLoadedFor = {};
|
|
546
|
+
const shouldHandleAsObject = res => !isString(res) && typeof res !== 'boolean' && typeof res !== 'number';
|
|
547
|
+
class Translator extends EventEmitter {
|
|
548
|
+
constructor(services, options = {}) {
|
|
549
|
+
super();
|
|
550
|
+
copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, this);
|
|
551
|
+
this.options = options;
|
|
552
|
+
if (this.options.keySeparator === undefined) {
|
|
553
|
+
this.options.keySeparator = '.';
|
|
554
|
+
}
|
|
555
|
+
this.logger = baseLogger.create('translator');
|
|
556
|
+
}
|
|
557
|
+
changeLanguage(lng) {
|
|
558
|
+
if (lng) this.language = lng;
|
|
559
|
+
}
|
|
560
|
+
exists(key, o = {
|
|
561
|
+
interpolation: {}
|
|
562
|
+
}) {
|
|
563
|
+
const opt = {
|
|
564
|
+
...o
|
|
565
|
+
};
|
|
566
|
+
if (key == null) return false;
|
|
567
|
+
const resolved = this.resolve(key, opt);
|
|
568
|
+
if (resolved?.res === undefined) return false;
|
|
569
|
+
const isObject = shouldHandleAsObject(resolved.res);
|
|
570
|
+
if (opt.returnObjects === false && isObject) {
|
|
571
|
+
return false;
|
|
572
|
+
}
|
|
573
|
+
return true;
|
|
574
|
+
}
|
|
575
|
+
extractFromKey(key, opt) {
|
|
576
|
+
let nsSeparator = opt.nsSeparator !== undefined ? opt.nsSeparator : this.options.nsSeparator;
|
|
577
|
+
if (nsSeparator === undefined) nsSeparator = ':';
|
|
578
|
+
const keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
|
|
579
|
+
let namespaces = opt.ns || this.options.defaultNS || [];
|
|
580
|
+
const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
|
|
581
|
+
const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !opt.keySeparator && !this.options.userDefinedNsSeparator && !opt.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
|
|
582
|
+
if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
|
|
583
|
+
const m = key.match(this.interpolator.nestingRegexp);
|
|
584
|
+
if (m && m.length > 0) {
|
|
585
|
+
return {
|
|
586
|
+
key,
|
|
587
|
+
namespaces: isString(namespaces) ? [namespaces] : namespaces
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
const parts = key.split(nsSeparator);
|
|
591
|
+
if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
|
|
592
|
+
key = parts.join(keySeparator);
|
|
593
|
+
}
|
|
594
|
+
return {
|
|
595
|
+
key,
|
|
596
|
+
namespaces: isString(namespaces) ? [namespaces] : namespaces
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
translate(keys, o, lastKey) {
|
|
600
|
+
let opt = typeof o === 'object' ? {
|
|
601
|
+
...o
|
|
602
|
+
} : o;
|
|
603
|
+
if (typeof opt !== 'object' && this.options.overloadTranslationOptionHandler) {
|
|
604
|
+
opt = this.options.overloadTranslationOptionHandler(arguments);
|
|
605
|
+
}
|
|
606
|
+
if (typeof opt === 'object') opt = {
|
|
607
|
+
...opt
|
|
608
|
+
};
|
|
609
|
+
if (!opt) opt = {};
|
|
610
|
+
if (keys == null) return '';
|
|
611
|
+
if (typeof keys === 'function') keys = keysFromSelector(keys, {
|
|
612
|
+
...this.options,
|
|
613
|
+
...opt
|
|
614
|
+
});
|
|
615
|
+
if (!Array.isArray(keys)) keys = [String(keys)];
|
|
616
|
+
const returnDetails = opt.returnDetails !== undefined ? opt.returnDetails : this.options.returnDetails;
|
|
617
|
+
const keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
|
|
618
|
+
const {
|
|
619
|
+
key,
|
|
620
|
+
namespaces
|
|
621
|
+
} = this.extractFromKey(keys[keys.length - 1], opt);
|
|
622
|
+
const namespace = namespaces[namespaces.length - 1];
|
|
623
|
+
let nsSeparator = opt.nsSeparator !== undefined ? opt.nsSeparator : this.options.nsSeparator;
|
|
624
|
+
if (nsSeparator === undefined) nsSeparator = ':';
|
|
625
|
+
const lng = opt.lng || this.language;
|
|
626
|
+
const appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
|
627
|
+
if (lng?.toLowerCase() === 'cimode') {
|
|
628
|
+
if (appendNamespaceToCIMode) {
|
|
629
|
+
if (returnDetails) {
|
|
630
|
+
return {
|
|
631
|
+
res: `${namespace}${nsSeparator}${key}`,
|
|
632
|
+
usedKey: key,
|
|
633
|
+
exactUsedKey: key,
|
|
634
|
+
usedLng: lng,
|
|
635
|
+
usedNS: namespace,
|
|
636
|
+
usedParams: this.getUsedParamsDetails(opt)
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
return `${namespace}${nsSeparator}${key}`;
|
|
640
|
+
}
|
|
641
|
+
if (returnDetails) {
|
|
642
|
+
return {
|
|
643
|
+
res: key,
|
|
644
|
+
usedKey: key,
|
|
645
|
+
exactUsedKey: key,
|
|
646
|
+
usedLng: lng,
|
|
647
|
+
usedNS: namespace,
|
|
648
|
+
usedParams: this.getUsedParamsDetails(opt)
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
return key;
|
|
652
|
+
}
|
|
653
|
+
const resolved = this.resolve(keys, opt);
|
|
654
|
+
let res = resolved?.res;
|
|
655
|
+
const resUsedKey = resolved?.usedKey || key;
|
|
656
|
+
const resExactUsedKey = resolved?.exactUsedKey || key;
|
|
657
|
+
const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
|
|
658
|
+
const joinArrays = opt.joinArrays !== undefined ? opt.joinArrays : this.options.joinArrays;
|
|
659
|
+
const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
|
|
660
|
+
const needsPluralHandling = opt.count !== undefined && !isString(opt.count);
|
|
661
|
+
const hasDefaultValue = Translator.hasDefaultValue(opt);
|
|
662
|
+
const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, opt) : '';
|
|
663
|
+
const defaultValueSuffixOrdinalFallback = opt.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, {
|
|
664
|
+
ordinal: false
|
|
665
|
+
}) : '';
|
|
666
|
+
const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
|
|
667
|
+
const defaultValue = needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] || opt[`defaultValue${defaultValueSuffix}`] || opt[`defaultValue${defaultValueSuffixOrdinalFallback}`] || opt.defaultValue;
|
|
668
|
+
let resForObjHndl = res;
|
|
669
|
+
if (handleAsObjectInI18nFormat && !res && hasDefaultValue) {
|
|
670
|
+
resForObjHndl = defaultValue;
|
|
671
|
+
}
|
|
672
|
+
const handleAsObject = shouldHandleAsObject(resForObjHndl);
|
|
673
|
+
const resType = Object.prototype.toString.apply(resForObjHndl);
|
|
674
|
+
if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
|
|
675
|
+
if (!opt.returnObjects && !this.options.returnObjects) {
|
|
676
|
+
if (!this.options.returnedObjectHandler) {
|
|
677
|
+
this.logger.warn('accessing an object - but returnObjects options is not enabled!');
|
|
678
|
+
}
|
|
679
|
+
const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
|
|
680
|
+
...opt,
|
|
681
|
+
ns: namespaces
|
|
682
|
+
}) : `key '${key} (${this.language})' returned an object instead of string.`;
|
|
683
|
+
if (returnDetails) {
|
|
684
|
+
resolved.res = r;
|
|
685
|
+
resolved.usedParams = this.getUsedParamsDetails(opt);
|
|
686
|
+
return resolved;
|
|
687
|
+
}
|
|
688
|
+
return r;
|
|
689
|
+
}
|
|
690
|
+
if (keySeparator) {
|
|
691
|
+
const resTypeIsArray = Array.isArray(resForObjHndl);
|
|
692
|
+
const copy = resTypeIsArray ? [] : {};
|
|
693
|
+
const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
|
|
694
|
+
for (const m in resForObjHndl) {
|
|
695
|
+
if (Object.prototype.hasOwnProperty.call(resForObjHndl, m)) {
|
|
696
|
+
const deepKey = `${newKeyToUse}${keySeparator}${m}`;
|
|
697
|
+
if (hasDefaultValue && !res) {
|
|
698
|
+
copy[m] = this.translate(deepKey, {
|
|
699
|
+
...opt,
|
|
700
|
+
defaultValue: shouldHandleAsObject(defaultValue) ? defaultValue[m] : undefined,
|
|
701
|
+
...{
|
|
702
|
+
joinArrays: false,
|
|
703
|
+
ns: namespaces
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
} else {
|
|
707
|
+
copy[m] = this.translate(deepKey, {
|
|
708
|
+
...opt,
|
|
709
|
+
...{
|
|
710
|
+
joinArrays: false,
|
|
711
|
+
ns: namespaces
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
if (copy[m] === deepKey) copy[m] = resForObjHndl[m];
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
res = copy;
|
|
719
|
+
}
|
|
720
|
+
} else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
|
|
721
|
+
res = res.join(joinArrays);
|
|
722
|
+
if (res) res = this.extendTranslation(res, keys, opt, lastKey);
|
|
723
|
+
} else {
|
|
724
|
+
let usedDefault = false;
|
|
725
|
+
let usedKey = false;
|
|
726
|
+
if (!this.isValidLookup(res) && hasDefaultValue) {
|
|
727
|
+
usedDefault = true;
|
|
728
|
+
res = defaultValue;
|
|
729
|
+
}
|
|
730
|
+
if (!this.isValidLookup(res)) {
|
|
731
|
+
usedKey = true;
|
|
732
|
+
res = key;
|
|
733
|
+
}
|
|
734
|
+
const missingKeyNoValueFallbackToKey = opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
|
|
735
|
+
const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
|
|
736
|
+
const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
|
|
737
|
+
if (usedKey || usedDefault || updateMissing) {
|
|
738
|
+
this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
|
|
739
|
+
if (keySeparator) {
|
|
740
|
+
const fk = this.resolve(key, {
|
|
741
|
+
...opt,
|
|
742
|
+
keySeparator: false
|
|
743
|
+
});
|
|
744
|
+
if (fk && fk.res) this.logger.warn('Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.');
|
|
745
|
+
}
|
|
746
|
+
let lngs = [];
|
|
747
|
+
const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, opt.lng || this.language);
|
|
748
|
+
if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
|
|
749
|
+
for (let i = 0; i < fallbackLngs.length; i++) {
|
|
750
|
+
lngs.push(fallbackLngs[i]);
|
|
751
|
+
}
|
|
752
|
+
} else if (this.options.saveMissingTo === 'all') {
|
|
753
|
+
lngs = this.languageUtils.toResolveHierarchy(opt.lng || this.language);
|
|
754
|
+
} else {
|
|
755
|
+
lngs.push(opt.lng || this.language);
|
|
756
|
+
}
|
|
757
|
+
const send = (l, k, specificDefaultValue) => {
|
|
758
|
+
const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
|
|
759
|
+
if (this.options.missingKeyHandler) {
|
|
760
|
+
this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, opt);
|
|
761
|
+
} else if (this.backendConnector?.saveMissing) {
|
|
762
|
+
this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, opt);
|
|
763
|
+
}
|
|
764
|
+
this.emit('missingKey', l, namespace, k, res);
|
|
765
|
+
};
|
|
766
|
+
if (this.options.saveMissing) {
|
|
767
|
+
if (this.options.saveMissingPlurals && needsPluralHandling) {
|
|
768
|
+
lngs.forEach(language => {
|
|
769
|
+
const suffixes = this.pluralResolver.getSuffixes(language, opt);
|
|
770
|
+
if (needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
|
|
771
|
+
suffixes.push(`${this.options.pluralSeparator}zero`);
|
|
772
|
+
}
|
|
773
|
+
suffixes.forEach(suffix => {
|
|
774
|
+
send([language], key + suffix, opt[`defaultValue${suffix}`] || defaultValue);
|
|
775
|
+
});
|
|
776
|
+
});
|
|
777
|
+
} else {
|
|
778
|
+
send(lngs, key, defaultValue);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
res = this.extendTranslation(res, keys, opt, resolved, lastKey);
|
|
783
|
+
if (usedKey && res === key && this.options.appendNamespaceToMissingKey) {
|
|
784
|
+
res = `${namespace}${nsSeparator}${key}`;
|
|
785
|
+
}
|
|
786
|
+
if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
|
|
787
|
+
res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}${nsSeparator}${key}` : key, usedDefault ? res : undefined, opt);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
if (returnDetails) {
|
|
791
|
+
resolved.res = res;
|
|
792
|
+
resolved.usedParams = this.getUsedParamsDetails(opt);
|
|
793
|
+
return resolved;
|
|
794
|
+
}
|
|
795
|
+
return res;
|
|
796
|
+
}
|
|
797
|
+
extendTranslation(res, key, opt, resolved, lastKey) {
|
|
798
|
+
if (this.i18nFormat?.parse) {
|
|
799
|
+
res = this.i18nFormat.parse(res, {
|
|
800
|
+
...this.options.interpolation.defaultVariables,
|
|
801
|
+
...opt
|
|
802
|
+
}, opt.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
|
|
803
|
+
resolved
|
|
804
|
+
});
|
|
805
|
+
} else if (!opt.skipInterpolation) {
|
|
806
|
+
if (opt.interpolation) this.interpolator.init({
|
|
807
|
+
...opt,
|
|
808
|
+
...{
|
|
809
|
+
interpolation: {
|
|
810
|
+
...this.options.interpolation,
|
|
811
|
+
...opt.interpolation
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
});
|
|
815
|
+
const skipOnVariables = isString(res) && (opt?.interpolation?.skipOnVariables !== undefined ? opt.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
|
|
816
|
+
let nestBef;
|
|
817
|
+
if (skipOnVariables) {
|
|
818
|
+
const nb = res.match(this.interpolator.nestingRegexp);
|
|
819
|
+
nestBef = nb && nb.length;
|
|
820
|
+
}
|
|
821
|
+
let data = opt.replace && !isString(opt.replace) ? opt.replace : opt;
|
|
822
|
+
if (this.options.interpolation.defaultVariables) data = {
|
|
823
|
+
...this.options.interpolation.defaultVariables,
|
|
824
|
+
...data
|
|
825
|
+
};
|
|
826
|
+
res = this.interpolator.interpolate(res, data, opt.lng || this.language || resolved.usedLng, opt);
|
|
827
|
+
if (skipOnVariables) {
|
|
828
|
+
const na = res.match(this.interpolator.nestingRegexp);
|
|
829
|
+
const nestAft = na && na.length;
|
|
830
|
+
if (nestBef < nestAft) opt.nest = false;
|
|
831
|
+
}
|
|
832
|
+
if (!opt.lng && resolved && resolved.res) opt.lng = this.language || resolved.usedLng;
|
|
833
|
+
if (opt.nest !== false) res = this.interpolator.nest(res, (...args) => {
|
|
834
|
+
if (lastKey?.[0] === args[0] && !opt.context) {
|
|
835
|
+
this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
|
|
836
|
+
return null;
|
|
837
|
+
}
|
|
838
|
+
return this.translate(...args, key);
|
|
839
|
+
}, opt);
|
|
840
|
+
if (opt.interpolation) this.interpolator.reset();
|
|
841
|
+
}
|
|
842
|
+
const postProcess = opt.postProcess || this.options.postProcess;
|
|
843
|
+
const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
|
|
844
|
+
if (res != null && postProcessorNames?.length && opt.applyPostProcessor !== false) {
|
|
845
|
+
res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
|
|
846
|
+
i18nResolved: {
|
|
847
|
+
...resolved,
|
|
848
|
+
usedParams: this.getUsedParamsDetails(opt)
|
|
849
|
+
},
|
|
850
|
+
...opt
|
|
851
|
+
} : opt, this);
|
|
852
|
+
}
|
|
853
|
+
return res;
|
|
854
|
+
}
|
|
855
|
+
resolve(keys, opt = {}) {
|
|
856
|
+
let found;
|
|
857
|
+
let usedKey;
|
|
858
|
+
let exactUsedKey;
|
|
859
|
+
let usedLng;
|
|
860
|
+
let usedNS;
|
|
861
|
+
if (isString(keys)) keys = [keys];
|
|
862
|
+
keys.forEach(k => {
|
|
863
|
+
if (this.isValidLookup(found)) return;
|
|
864
|
+
const extracted = this.extractFromKey(k, opt);
|
|
865
|
+
const key = extracted.key;
|
|
866
|
+
usedKey = key;
|
|
867
|
+
let namespaces = extracted.namespaces;
|
|
868
|
+
if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
|
|
869
|
+
const needsPluralHandling = opt.count !== undefined && !isString(opt.count);
|
|
870
|
+
const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
|
|
871
|
+
const needsContextHandling = opt.context !== undefined && (isString(opt.context) || typeof opt.context === 'number') && opt.context !== '';
|
|
872
|
+
const codes = opt.lngs ? opt.lngs : this.languageUtils.toResolveHierarchy(opt.lng || this.language, opt.fallbackLng);
|
|
873
|
+
namespaces.forEach(ns => {
|
|
874
|
+
if (this.isValidLookup(found)) return;
|
|
875
|
+
usedNS = ns;
|
|
876
|
+
if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(usedNS)) {
|
|
877
|
+
checkedLoadedFor[`${codes[0]}-${ns}`] = true;
|
|
878
|
+
this.logger.warn(`key "${usedKey}" for languages "${codes.join(', ')}" won't get resolved as namespace "${usedNS}" was not yet loaded`, 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
|
|
879
|
+
}
|
|
880
|
+
codes.forEach(code => {
|
|
881
|
+
if (this.isValidLookup(found)) return;
|
|
882
|
+
usedLng = code;
|
|
883
|
+
const finalKeys = [key];
|
|
884
|
+
if (this.i18nFormat?.addLookupKeys) {
|
|
885
|
+
this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, opt);
|
|
886
|
+
} else {
|
|
887
|
+
let pluralSuffix;
|
|
888
|
+
if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, opt.count, opt);
|
|
889
|
+
const zeroSuffix = `${this.options.pluralSeparator}zero`;
|
|
890
|
+
const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
|
|
891
|
+
if (needsPluralHandling) {
|
|
892
|
+
if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
|
|
893
|
+
finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
|
|
894
|
+
}
|
|
895
|
+
finalKeys.push(key + pluralSuffix);
|
|
896
|
+
if (needsZeroSuffixLookup) {
|
|
897
|
+
finalKeys.push(key + zeroSuffix);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
if (needsContextHandling) {
|
|
901
|
+
const contextKey = `${key}${this.options.contextSeparator || '_'}${opt.context}`;
|
|
902
|
+
finalKeys.push(contextKey);
|
|
903
|
+
if (needsPluralHandling) {
|
|
904
|
+
if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
|
|
905
|
+
finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
|
|
906
|
+
}
|
|
907
|
+
finalKeys.push(contextKey + pluralSuffix);
|
|
908
|
+
if (needsZeroSuffixLookup) {
|
|
909
|
+
finalKeys.push(contextKey + zeroSuffix);
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
let possibleKey;
|
|
915
|
+
while (possibleKey = finalKeys.pop()) {
|
|
916
|
+
if (!this.isValidLookup(found)) {
|
|
917
|
+
exactUsedKey = possibleKey;
|
|
918
|
+
found = this.getResource(code, ns, possibleKey, opt);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
});
|
|
923
|
+
});
|
|
924
|
+
return {
|
|
925
|
+
res: found,
|
|
926
|
+
usedKey,
|
|
927
|
+
exactUsedKey,
|
|
928
|
+
usedLng,
|
|
929
|
+
usedNS
|
|
930
|
+
};
|
|
931
|
+
}
|
|
932
|
+
isValidLookup(res) {
|
|
933
|
+
return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
|
|
934
|
+
}
|
|
935
|
+
getResource(code, ns, key, options = {}) {
|
|
936
|
+
if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key, options);
|
|
937
|
+
return this.resourceStore.getResource(code, ns, key, options);
|
|
938
|
+
}
|
|
939
|
+
getUsedParamsDetails(options = {}) {
|
|
940
|
+
const optionsKeys = ['defaultValue', 'ordinal', 'context', 'replace', 'lng', 'lngs', 'fallbackLng', 'ns', 'keySeparator', 'nsSeparator', 'returnObjects', 'returnDetails', 'joinArrays', 'postProcess', 'interpolation'];
|
|
941
|
+
const useOptionsReplaceForData = options.replace && !isString(options.replace);
|
|
942
|
+
let data = useOptionsReplaceForData ? options.replace : options;
|
|
943
|
+
if (useOptionsReplaceForData && typeof options.count !== 'undefined') {
|
|
944
|
+
data.count = options.count;
|
|
945
|
+
}
|
|
946
|
+
if (this.options.interpolation.defaultVariables) {
|
|
947
|
+
data = {
|
|
948
|
+
...this.options.interpolation.defaultVariables,
|
|
949
|
+
...data
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
if (!useOptionsReplaceForData) {
|
|
953
|
+
data = {
|
|
954
|
+
...data
|
|
955
|
+
};
|
|
956
|
+
for (const key of optionsKeys) {
|
|
957
|
+
delete data[key];
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
return data;
|
|
961
|
+
}
|
|
962
|
+
static hasDefaultValue(options) {
|
|
963
|
+
const prefix = 'defaultValue';
|
|
964
|
+
for (const option in options) {
|
|
965
|
+
if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
|
|
966
|
+
return true;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
return false;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
class LanguageUtil {
|
|
974
|
+
constructor(options) {
|
|
975
|
+
this.options = options;
|
|
976
|
+
this.supportedLngs = this.options.supportedLngs || false;
|
|
977
|
+
this.logger = baseLogger.create('languageUtils');
|
|
978
|
+
}
|
|
979
|
+
getScriptPartFromCode(code) {
|
|
980
|
+
code = getCleanedCode(code);
|
|
981
|
+
if (!code || code.indexOf('-') < 0) return null;
|
|
982
|
+
const p = code.split('-');
|
|
983
|
+
if (p.length === 2) return null;
|
|
984
|
+
p.pop();
|
|
985
|
+
if (p[p.length - 1].toLowerCase() === 'x') return null;
|
|
986
|
+
return this.formatLanguageCode(p.join('-'));
|
|
987
|
+
}
|
|
988
|
+
getLanguagePartFromCode(code) {
|
|
989
|
+
code = getCleanedCode(code);
|
|
990
|
+
if (!code || code.indexOf('-') < 0) return code;
|
|
991
|
+
const p = code.split('-');
|
|
992
|
+
return this.formatLanguageCode(p[0]);
|
|
993
|
+
}
|
|
994
|
+
formatLanguageCode(code) {
|
|
995
|
+
if (isString(code) && code.indexOf('-') > -1) {
|
|
996
|
+
let formattedCode;
|
|
997
|
+
try {
|
|
998
|
+
formattedCode = Intl.getCanonicalLocales(code)[0];
|
|
999
|
+
} catch (e) {}
|
|
1000
|
+
if (formattedCode && this.options.lowerCaseLng) {
|
|
1001
|
+
formattedCode = formattedCode.toLowerCase();
|
|
1002
|
+
}
|
|
1003
|
+
if (formattedCode) return formattedCode;
|
|
1004
|
+
if (this.options.lowerCaseLng) {
|
|
1005
|
+
return code.toLowerCase();
|
|
1006
|
+
}
|
|
1007
|
+
return code;
|
|
1008
|
+
}
|
|
1009
|
+
return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
|
|
1010
|
+
}
|
|
1011
|
+
isSupportedCode(code) {
|
|
1012
|
+
if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
|
|
1013
|
+
code = this.getLanguagePartFromCode(code);
|
|
1014
|
+
}
|
|
1015
|
+
return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
|
|
1016
|
+
}
|
|
1017
|
+
getBestMatchFromCodes(codes) {
|
|
1018
|
+
if (!codes) return null;
|
|
1019
|
+
let found;
|
|
1020
|
+
codes.forEach(code => {
|
|
1021
|
+
if (found) return;
|
|
1022
|
+
const cleanedLng = this.formatLanguageCode(code);
|
|
1023
|
+
if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
|
|
1024
|
+
});
|
|
1025
|
+
if (!found && this.options.supportedLngs) {
|
|
1026
|
+
codes.forEach(code => {
|
|
1027
|
+
if (found) return;
|
|
1028
|
+
const lngScOnly = this.getScriptPartFromCode(code);
|
|
1029
|
+
if (this.isSupportedCode(lngScOnly)) return found = lngScOnly;
|
|
1030
|
+
const lngOnly = this.getLanguagePartFromCode(code);
|
|
1031
|
+
if (this.isSupportedCode(lngOnly)) return found = lngOnly;
|
|
1032
|
+
found = this.options.supportedLngs.find(supportedLng => {
|
|
1033
|
+
if (supportedLng === lngOnly) return supportedLng;
|
|
1034
|
+
if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;
|
|
1035
|
+
if (supportedLng.indexOf('-') > 0 && lngOnly.indexOf('-') < 0 && supportedLng.substring(0, supportedLng.indexOf('-')) === lngOnly) return supportedLng;
|
|
1036
|
+
if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng;
|
|
1037
|
+
});
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
|
|
1041
|
+
return found;
|
|
1042
|
+
}
|
|
1043
|
+
getFallbackCodes(fallbacks, code) {
|
|
1044
|
+
if (!fallbacks) return [];
|
|
1045
|
+
if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
|
|
1046
|
+
if (isString(fallbacks)) fallbacks = [fallbacks];
|
|
1047
|
+
if (Array.isArray(fallbacks)) return fallbacks;
|
|
1048
|
+
if (!code) return fallbacks.default || [];
|
|
1049
|
+
let found = fallbacks[code];
|
|
1050
|
+
if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
|
|
1051
|
+
if (!found) found = fallbacks[this.formatLanguageCode(code)];
|
|
1052
|
+
if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
|
|
1053
|
+
if (!found) found = fallbacks.default;
|
|
1054
|
+
return found || [];
|
|
1055
|
+
}
|
|
1056
|
+
toResolveHierarchy(code, fallbackCode) {
|
|
1057
|
+
const fallbackCodes = this.getFallbackCodes((fallbackCode === false ? [] : fallbackCode) || this.options.fallbackLng || [], code);
|
|
1058
|
+
const codes = [];
|
|
1059
|
+
const addCode = c => {
|
|
1060
|
+
if (!c) return;
|
|
1061
|
+
if (this.isSupportedCode(c)) {
|
|
1062
|
+
codes.push(c);
|
|
1063
|
+
} else {
|
|
1064
|
+
this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
if (isString(code) && (code.indexOf('-') > -1 || code.indexOf('_') > -1)) {
|
|
1068
|
+
if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
|
|
1069
|
+
if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
|
|
1070
|
+
if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
|
|
1071
|
+
} else if (isString(code)) {
|
|
1072
|
+
addCode(this.formatLanguageCode(code));
|
|
1073
|
+
}
|
|
1074
|
+
fallbackCodes.forEach(fc => {
|
|
1075
|
+
if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
|
|
1076
|
+
});
|
|
1077
|
+
return codes;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
const suffixesOrder = {
|
|
1082
|
+
zero: 0,
|
|
1083
|
+
one: 1,
|
|
1084
|
+
two: 2,
|
|
1085
|
+
few: 3,
|
|
1086
|
+
many: 4,
|
|
1087
|
+
other: 5
|
|
1088
|
+
};
|
|
1089
|
+
const dummyRule = {
|
|
1090
|
+
select: count => count === 1 ? 'one' : 'other',
|
|
1091
|
+
resolvedOptions: () => ({
|
|
1092
|
+
pluralCategories: ['one', 'other']
|
|
1093
|
+
})
|
|
1094
|
+
};
|
|
1095
|
+
class PluralResolver {
|
|
1096
|
+
constructor(languageUtils, options = {}) {
|
|
1097
|
+
this.languageUtils = languageUtils;
|
|
1098
|
+
this.options = options;
|
|
1099
|
+
this.logger = baseLogger.create('pluralResolver');
|
|
1100
|
+
this.pluralRulesCache = {};
|
|
1101
|
+
}
|
|
1102
|
+
addRule(lng, obj) {
|
|
1103
|
+
this.rules[lng] = obj;
|
|
1104
|
+
}
|
|
1105
|
+
clearCache() {
|
|
1106
|
+
this.pluralRulesCache = {};
|
|
1107
|
+
}
|
|
1108
|
+
getRule(code, options = {}) {
|
|
1109
|
+
const cleanedCode = getCleanedCode(code === 'dev' ? 'en' : code);
|
|
1110
|
+
const type = options.ordinal ? 'ordinal' : 'cardinal';
|
|
1111
|
+
const cacheKey = JSON.stringify({
|
|
1112
|
+
cleanedCode,
|
|
1113
|
+
type
|
|
1114
|
+
});
|
|
1115
|
+
if (cacheKey in this.pluralRulesCache) {
|
|
1116
|
+
return this.pluralRulesCache[cacheKey];
|
|
1117
|
+
}
|
|
1118
|
+
let rule;
|
|
1119
|
+
try {
|
|
1120
|
+
rule = new Intl.PluralRules(cleanedCode, {
|
|
1121
|
+
type
|
|
1122
|
+
});
|
|
1123
|
+
} catch (err) {
|
|
1124
|
+
if (!Intl) {
|
|
1125
|
+
this.logger.error('No Intl support, please use an Intl polyfill!');
|
|
1126
|
+
return dummyRule;
|
|
1127
|
+
}
|
|
1128
|
+
if (!code.match(/-|_/)) return dummyRule;
|
|
1129
|
+
const lngPart = this.languageUtils.getLanguagePartFromCode(code);
|
|
1130
|
+
rule = this.getRule(lngPart, options);
|
|
1131
|
+
}
|
|
1132
|
+
this.pluralRulesCache[cacheKey] = rule;
|
|
1133
|
+
return rule;
|
|
1134
|
+
}
|
|
1135
|
+
needsPlural(code, options = {}) {
|
|
1136
|
+
let rule = this.getRule(code, options);
|
|
1137
|
+
if (!rule) rule = this.getRule('dev', options);
|
|
1138
|
+
return rule?.resolvedOptions().pluralCategories.length > 1;
|
|
1139
|
+
}
|
|
1140
|
+
getPluralFormsOfKey(code, key, options = {}) {
|
|
1141
|
+
return this.getSuffixes(code, options).map(suffix => `${key}${suffix}`);
|
|
1142
|
+
}
|
|
1143
|
+
getSuffixes(code, options = {}) {
|
|
1144
|
+
let rule = this.getRule(code, options);
|
|
1145
|
+
if (!rule) rule = this.getRule('dev', options);
|
|
1146
|
+
if (!rule) return [];
|
|
1147
|
+
return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${pluralCategory}`);
|
|
1148
|
+
}
|
|
1149
|
+
getSuffix(code, count, options = {}) {
|
|
1150
|
+
const rule = this.getRule(code, options);
|
|
1151
|
+
if (rule) {
|
|
1152
|
+
return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${rule.select(count)}`;
|
|
1153
|
+
}
|
|
1154
|
+
this.logger.warn(`no plural rule found for: ${code}`);
|
|
1155
|
+
return this.getSuffix('dev', count, options);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
const deepFindWithDefaults = (data, defaultData, key, keySeparator = '.', ignoreJSONStructure = true) => {
|
|
1160
|
+
let path = getPathWithDefaults(data, defaultData, key);
|
|
1161
|
+
if (!path && ignoreJSONStructure && isString(key)) {
|
|
1162
|
+
path = deepFind(data, key, keySeparator);
|
|
1163
|
+
if (path === undefined) path = deepFind(defaultData, key, keySeparator);
|
|
1164
|
+
}
|
|
1165
|
+
return path;
|
|
1166
|
+
};
|
|
1167
|
+
const regexSafe = val => val.replace(/\$/g, '$$$$');
|
|
1168
|
+
class Interpolator {
|
|
1169
|
+
constructor(options = {}) {
|
|
1170
|
+
this.logger = baseLogger.create('interpolator');
|
|
1171
|
+
this.options = options;
|
|
1172
|
+
this.format = options?.interpolation?.format || (value => value);
|
|
1173
|
+
this.init(options);
|
|
1174
|
+
}
|
|
1175
|
+
init(options = {}) {
|
|
1176
|
+
if (!options.interpolation) options.interpolation = {
|
|
1177
|
+
escapeValue: true
|
|
1178
|
+
};
|
|
1179
|
+
const {
|
|
1180
|
+
escape: escape$1,
|
|
1181
|
+
escapeValue,
|
|
1182
|
+
useRawValueToEscape,
|
|
1183
|
+
prefix,
|
|
1184
|
+
prefixEscaped,
|
|
1185
|
+
suffix,
|
|
1186
|
+
suffixEscaped,
|
|
1187
|
+
formatSeparator,
|
|
1188
|
+
unescapeSuffix,
|
|
1189
|
+
unescapePrefix,
|
|
1190
|
+
nestingPrefix,
|
|
1191
|
+
nestingPrefixEscaped,
|
|
1192
|
+
nestingSuffix,
|
|
1193
|
+
nestingSuffixEscaped,
|
|
1194
|
+
nestingOptionsSeparator,
|
|
1195
|
+
maxReplaces,
|
|
1196
|
+
alwaysFormat
|
|
1197
|
+
} = options.interpolation;
|
|
1198
|
+
this.escape = escape$1 !== undefined ? escape$1 : escape;
|
|
1199
|
+
this.escapeValue = escapeValue !== undefined ? escapeValue : true;
|
|
1200
|
+
this.useRawValueToEscape = useRawValueToEscape !== undefined ? useRawValueToEscape : false;
|
|
1201
|
+
this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || '{{';
|
|
1202
|
+
this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || '}}';
|
|
1203
|
+
this.formatSeparator = formatSeparator || ',';
|
|
1204
|
+
this.unescapePrefix = unescapeSuffix ? '' : unescapePrefix || '-';
|
|
1205
|
+
this.unescapeSuffix = this.unescapePrefix ? '' : unescapeSuffix || '';
|
|
1206
|
+
this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape('$t(');
|
|
1207
|
+
this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(')');
|
|
1208
|
+
this.nestingOptionsSeparator = nestingOptionsSeparator || ',';
|
|
1209
|
+
this.maxReplaces = maxReplaces || 1000;
|
|
1210
|
+
this.alwaysFormat = alwaysFormat !== undefined ? alwaysFormat : false;
|
|
1211
|
+
this.resetRegExp();
|
|
1212
|
+
}
|
|
1213
|
+
reset() {
|
|
1214
|
+
if (this.options) this.init(this.options);
|
|
1215
|
+
}
|
|
1216
|
+
resetRegExp() {
|
|
1217
|
+
const getOrResetRegExp = (existingRegExp, pattern) => {
|
|
1218
|
+
if (existingRegExp?.source === pattern) {
|
|
1219
|
+
existingRegExp.lastIndex = 0;
|
|
1220
|
+
return existingRegExp;
|
|
1221
|
+
}
|
|
1222
|
+
return new RegExp(pattern, 'g');
|
|
1223
|
+
};
|
|
1224
|
+
this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
|
|
1225
|
+
this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
|
|
1226
|
+
this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
|
|
1227
|
+
}
|
|
1228
|
+
interpolate(str, data, lng, options) {
|
|
1229
|
+
let match;
|
|
1230
|
+
let value;
|
|
1231
|
+
let replaces;
|
|
1232
|
+
const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
|
|
1233
|
+
const handleFormat = key => {
|
|
1234
|
+
if (key.indexOf(this.formatSeparator) < 0) {
|
|
1235
|
+
const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
|
|
1236
|
+
return this.alwaysFormat ? this.format(path, undefined, lng, {
|
|
1237
|
+
...options,
|
|
1238
|
+
...data,
|
|
1239
|
+
interpolationkey: key
|
|
1240
|
+
}) : path;
|
|
1241
|
+
}
|
|
1242
|
+
const p = key.split(this.formatSeparator);
|
|
1243
|
+
const k = p.shift().trim();
|
|
1244
|
+
const f = p.join(this.formatSeparator).trim();
|
|
1245
|
+
return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
|
|
1246
|
+
...options,
|
|
1247
|
+
...data,
|
|
1248
|
+
interpolationkey: k
|
|
1249
|
+
});
|
|
1250
|
+
};
|
|
1251
|
+
this.resetRegExp();
|
|
1252
|
+
const missingInterpolationHandler = options?.missingInterpolationHandler || this.options.missingInterpolationHandler;
|
|
1253
|
+
const skipOnVariables = options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
|
|
1254
|
+
const todos = [{
|
|
1255
|
+
regex: this.regexpUnescape,
|
|
1256
|
+
safeValue: val => regexSafe(val)
|
|
1257
|
+
}, {
|
|
1258
|
+
regex: this.regexp,
|
|
1259
|
+
safeValue: val => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
|
|
1260
|
+
}];
|
|
1261
|
+
todos.forEach(todo => {
|
|
1262
|
+
replaces = 0;
|
|
1263
|
+
while (match = todo.regex.exec(str)) {
|
|
1264
|
+
const matchedVar = match[1].trim();
|
|
1265
|
+
value = handleFormat(matchedVar);
|
|
1266
|
+
if (value === undefined) {
|
|
1267
|
+
if (typeof missingInterpolationHandler === 'function') {
|
|
1268
|
+
const temp = missingInterpolationHandler(str, match, options);
|
|
1269
|
+
value = isString(temp) ? temp : '';
|
|
1270
|
+
} else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
|
|
1271
|
+
value = '';
|
|
1272
|
+
} else if (skipOnVariables) {
|
|
1273
|
+
value = match[0];
|
|
1274
|
+
continue;
|
|
1275
|
+
} else {
|
|
1276
|
+
this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
|
|
1277
|
+
value = '';
|
|
1278
|
+
}
|
|
1279
|
+
} else if (!isString(value) && !this.useRawValueToEscape) {
|
|
1280
|
+
value = makeString(value);
|
|
1281
|
+
}
|
|
1282
|
+
const safeValue = todo.safeValue(value);
|
|
1283
|
+
str = str.replace(match[0], safeValue);
|
|
1284
|
+
if (skipOnVariables) {
|
|
1285
|
+
todo.regex.lastIndex += value.length;
|
|
1286
|
+
todo.regex.lastIndex -= match[0].length;
|
|
1287
|
+
} else {
|
|
1288
|
+
todo.regex.lastIndex = 0;
|
|
1289
|
+
}
|
|
1290
|
+
replaces++;
|
|
1291
|
+
if (replaces >= this.maxReplaces) {
|
|
1292
|
+
break;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
});
|
|
1296
|
+
return str;
|
|
1297
|
+
}
|
|
1298
|
+
nest(str, fc, options = {}) {
|
|
1299
|
+
let match;
|
|
1300
|
+
let value;
|
|
1301
|
+
let clonedOptions;
|
|
1302
|
+
const handleHasOptions = (key, inheritedOptions) => {
|
|
1303
|
+
const sep = this.nestingOptionsSeparator;
|
|
1304
|
+
if (key.indexOf(sep) < 0) return key;
|
|
1305
|
+
const c = key.split(new RegExp(`${sep}[ ]*{`));
|
|
1306
|
+
let optionsString = `{${c[1]}`;
|
|
1307
|
+
key = c[0];
|
|
1308
|
+
optionsString = this.interpolate(optionsString, clonedOptions);
|
|
1309
|
+
const matchedSingleQuotes = optionsString.match(/'/g);
|
|
1310
|
+
const matchedDoubleQuotes = optionsString.match(/"/g);
|
|
1311
|
+
if ((matchedSingleQuotes?.length ?? 0) % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
|
|
1312
|
+
optionsString = optionsString.replace(/'/g, '"');
|
|
1313
|
+
}
|
|
1314
|
+
try {
|
|
1315
|
+
clonedOptions = JSON.parse(optionsString);
|
|
1316
|
+
if (inheritedOptions) clonedOptions = {
|
|
1317
|
+
...inheritedOptions,
|
|
1318
|
+
...clonedOptions
|
|
1319
|
+
};
|
|
1320
|
+
} catch (e) {
|
|
1321
|
+
this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
|
|
1322
|
+
return `${key}${sep}${optionsString}`;
|
|
1323
|
+
}
|
|
1324
|
+
if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
|
|
1325
|
+
return key;
|
|
1326
|
+
};
|
|
1327
|
+
while (match = this.nestingRegexp.exec(str)) {
|
|
1328
|
+
let formatters = [];
|
|
1329
|
+
clonedOptions = {
|
|
1330
|
+
...options
|
|
1331
|
+
};
|
|
1332
|
+
clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
|
|
1333
|
+
clonedOptions.applyPostProcessor = false;
|
|
1334
|
+
delete clonedOptions.defaultValue;
|
|
1335
|
+
const keyEndIndex = /{.*}/.test(match[1]) ? match[1].lastIndexOf('}') + 1 : match[1].indexOf(this.formatSeparator);
|
|
1336
|
+
if (keyEndIndex !== -1) {
|
|
1337
|
+
formatters = match[1].slice(keyEndIndex).split(this.formatSeparator).map(elem => elem.trim()).filter(Boolean);
|
|
1338
|
+
match[1] = match[1].slice(0, keyEndIndex);
|
|
1339
|
+
}
|
|
1340
|
+
value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
|
|
1341
|
+
if (value && match[0] === str && !isString(value)) return value;
|
|
1342
|
+
if (!isString(value)) value = makeString(value);
|
|
1343
|
+
if (!value) {
|
|
1344
|
+
this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
|
|
1345
|
+
value = '';
|
|
1346
|
+
}
|
|
1347
|
+
if (formatters.length) {
|
|
1348
|
+
value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
|
|
1349
|
+
...options,
|
|
1350
|
+
interpolationkey: match[1].trim()
|
|
1351
|
+
}), value.trim());
|
|
1352
|
+
}
|
|
1353
|
+
str = str.replace(match[0], value);
|
|
1354
|
+
this.regexp.lastIndex = 0;
|
|
1355
|
+
}
|
|
1356
|
+
return str;
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
const parseFormatStr = formatStr => {
|
|
1361
|
+
let formatName = formatStr.toLowerCase().trim();
|
|
1362
|
+
const formatOptions = {};
|
|
1363
|
+
if (formatStr.indexOf('(') > -1) {
|
|
1364
|
+
const p = formatStr.split('(');
|
|
1365
|
+
formatName = p[0].toLowerCase().trim();
|
|
1366
|
+
const optStr = p[1].substring(0, p[1].length - 1);
|
|
1367
|
+
if (formatName === 'currency' && optStr.indexOf(':') < 0) {
|
|
1368
|
+
if (!formatOptions.currency) formatOptions.currency = optStr.trim();
|
|
1369
|
+
} else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
|
|
1370
|
+
if (!formatOptions.range) formatOptions.range = optStr.trim();
|
|
1371
|
+
} else {
|
|
1372
|
+
const opts = optStr.split(';');
|
|
1373
|
+
opts.forEach(opt => {
|
|
1374
|
+
if (opt) {
|
|
1375
|
+
const [key, ...rest] = opt.split(':');
|
|
1376
|
+
const val = rest.join(':').trim().replace(/^'+|'+$/g, '');
|
|
1377
|
+
const trimmedKey = key.trim();
|
|
1378
|
+
if (!formatOptions[trimmedKey]) formatOptions[trimmedKey] = val;
|
|
1379
|
+
if (val === 'false') formatOptions[trimmedKey] = false;
|
|
1380
|
+
if (val === 'true') formatOptions[trimmedKey] = true;
|
|
1381
|
+
if (!isNaN(val)) formatOptions[trimmedKey] = parseInt(val, 10);
|
|
1382
|
+
}
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
return {
|
|
1387
|
+
formatName,
|
|
1388
|
+
formatOptions
|
|
1389
|
+
};
|
|
1390
|
+
};
|
|
1391
|
+
const createCachedFormatter = fn => {
|
|
1392
|
+
const cache = {};
|
|
1393
|
+
return (v, l, o) => {
|
|
1394
|
+
let optForCache = o;
|
|
1395
|
+
if (o && o.interpolationkey && o.formatParams && o.formatParams[o.interpolationkey] && o[o.interpolationkey]) {
|
|
1396
|
+
optForCache = {
|
|
1397
|
+
...optForCache,
|
|
1398
|
+
[o.interpolationkey]: undefined
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1401
|
+
const key = l + JSON.stringify(optForCache);
|
|
1402
|
+
let frm = cache[key];
|
|
1403
|
+
if (!frm) {
|
|
1404
|
+
frm = fn(getCleanedCode(l), o);
|
|
1405
|
+
cache[key] = frm;
|
|
1406
|
+
}
|
|
1407
|
+
return frm(v);
|
|
1408
|
+
};
|
|
1409
|
+
};
|
|
1410
|
+
const createNonCachedFormatter = fn => (v, l, o) => fn(getCleanedCode(l), o)(v);
|
|
1411
|
+
class Formatter {
|
|
1412
|
+
constructor(options = {}) {
|
|
1413
|
+
this.logger = baseLogger.create('formatter');
|
|
1414
|
+
this.options = options;
|
|
1415
|
+
this.init(options);
|
|
1416
|
+
}
|
|
1417
|
+
init(services, options = {
|
|
1418
|
+
interpolation: {}
|
|
1419
|
+
}) {
|
|
1420
|
+
this.formatSeparator = options.interpolation.formatSeparator || ',';
|
|
1421
|
+
const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
|
|
1422
|
+
this.formats = {
|
|
1423
|
+
number: cf((lng, opt) => {
|
|
1424
|
+
const formatter = new Intl.NumberFormat(lng, {
|
|
1425
|
+
...opt
|
|
1426
|
+
});
|
|
1427
|
+
return val => formatter.format(val);
|
|
1428
|
+
}),
|
|
1429
|
+
currency: cf((lng, opt) => {
|
|
1430
|
+
const formatter = new Intl.NumberFormat(lng, {
|
|
1431
|
+
...opt,
|
|
1432
|
+
style: 'currency'
|
|
1433
|
+
});
|
|
1434
|
+
return val => formatter.format(val);
|
|
1435
|
+
}),
|
|
1436
|
+
datetime: cf((lng, opt) => {
|
|
1437
|
+
const formatter = new Intl.DateTimeFormat(lng, {
|
|
1438
|
+
...opt
|
|
1439
|
+
});
|
|
1440
|
+
return val => formatter.format(val);
|
|
1441
|
+
}),
|
|
1442
|
+
relativetime: cf((lng, opt) => {
|
|
1443
|
+
const formatter = new Intl.RelativeTimeFormat(lng, {
|
|
1444
|
+
...opt
|
|
1445
|
+
});
|
|
1446
|
+
return val => formatter.format(val, opt.range || 'day');
|
|
1447
|
+
}),
|
|
1448
|
+
list: cf((lng, opt) => {
|
|
1449
|
+
const formatter = new Intl.ListFormat(lng, {
|
|
1450
|
+
...opt
|
|
1451
|
+
});
|
|
1452
|
+
return val => formatter.format(val);
|
|
1453
|
+
})
|
|
1454
|
+
};
|
|
1455
|
+
}
|
|
1456
|
+
add(name, fc) {
|
|
1457
|
+
this.formats[name.toLowerCase().trim()] = fc;
|
|
1458
|
+
}
|
|
1459
|
+
addCached(name, fc) {
|
|
1460
|
+
this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
|
|
1461
|
+
}
|
|
1462
|
+
format(value, format, lng, options = {}) {
|
|
1463
|
+
const formats = format.split(this.formatSeparator);
|
|
1464
|
+
if (formats.length > 1 && formats[0].indexOf('(') > 1 && formats[0].indexOf(')') < 0 && formats.find(f => f.indexOf(')') > -1)) {
|
|
1465
|
+
const lastIndex = formats.findIndex(f => f.indexOf(')') > -1);
|
|
1466
|
+
formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
|
|
1467
|
+
}
|
|
1468
|
+
const result = formats.reduce((mem, f) => {
|
|
1469
|
+
const {
|
|
1470
|
+
formatName,
|
|
1471
|
+
formatOptions
|
|
1472
|
+
} = parseFormatStr(f);
|
|
1473
|
+
if (this.formats[formatName]) {
|
|
1474
|
+
let formatted = mem;
|
|
1475
|
+
try {
|
|
1476
|
+
const valOptions = options?.formatParams?.[options.interpolationkey] || {};
|
|
1477
|
+
const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
|
|
1478
|
+
formatted = this.formats[formatName](mem, l, {
|
|
1479
|
+
...formatOptions,
|
|
1480
|
+
...options,
|
|
1481
|
+
...valOptions
|
|
1482
|
+
});
|
|
1483
|
+
} catch (error) {
|
|
1484
|
+
this.logger.warn(error);
|
|
1485
|
+
}
|
|
1486
|
+
return formatted;
|
|
1487
|
+
} else {
|
|
1488
|
+
this.logger.warn(`there was no format function for ${formatName}`);
|
|
1489
|
+
}
|
|
1490
|
+
return mem;
|
|
1491
|
+
}, value);
|
|
1492
|
+
return result;
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
const removePending = (q, name) => {
|
|
1497
|
+
if (q.pending[name] !== undefined) {
|
|
1498
|
+
delete q.pending[name];
|
|
1499
|
+
q.pendingCount--;
|
|
1500
|
+
}
|
|
1501
|
+
};
|
|
1502
|
+
class Connector extends EventEmitter {
|
|
1503
|
+
constructor(backend, store, services, options = {}) {
|
|
1504
|
+
super();
|
|
1505
|
+
this.backend = backend;
|
|
1506
|
+
this.store = store;
|
|
1507
|
+
this.services = services;
|
|
1508
|
+
this.languageUtils = services.languageUtils;
|
|
1509
|
+
this.options = options;
|
|
1510
|
+
this.logger = baseLogger.create('backendConnector');
|
|
1511
|
+
this.waitingReads = [];
|
|
1512
|
+
this.maxParallelReads = options.maxParallelReads || 10;
|
|
1513
|
+
this.readingCalls = 0;
|
|
1514
|
+
this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
|
|
1515
|
+
this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
|
|
1516
|
+
this.state = {};
|
|
1517
|
+
this.queue = [];
|
|
1518
|
+
this.backend?.init?.(services, options.backend, options);
|
|
1519
|
+
}
|
|
1520
|
+
queueLoad(languages, namespaces, options, callback) {
|
|
1521
|
+
const toLoad = {};
|
|
1522
|
+
const pending = {};
|
|
1523
|
+
const toLoadLanguages = {};
|
|
1524
|
+
const toLoadNamespaces = {};
|
|
1525
|
+
languages.forEach(lng => {
|
|
1526
|
+
let hasAllNamespaces = true;
|
|
1527
|
+
namespaces.forEach(ns => {
|
|
1528
|
+
const name = `${lng}|${ns}`;
|
|
1529
|
+
if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
|
|
1530
|
+
this.state[name] = 2;
|
|
1531
|
+
} else if (this.state[name] < 0) ; else if (this.state[name] === 1) {
|
|
1532
|
+
if (pending[name] === undefined) pending[name] = true;
|
|
1533
|
+
} else {
|
|
1534
|
+
this.state[name] = 1;
|
|
1535
|
+
hasAllNamespaces = false;
|
|
1536
|
+
if (pending[name] === undefined) pending[name] = true;
|
|
1537
|
+
if (toLoad[name] === undefined) toLoad[name] = true;
|
|
1538
|
+
if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
|
|
1539
|
+
}
|
|
1540
|
+
});
|
|
1541
|
+
if (!hasAllNamespaces) toLoadLanguages[lng] = true;
|
|
1542
|
+
});
|
|
1543
|
+
if (Object.keys(toLoad).length || Object.keys(pending).length) {
|
|
1544
|
+
this.queue.push({
|
|
1545
|
+
pending,
|
|
1546
|
+
pendingCount: Object.keys(pending).length,
|
|
1547
|
+
loaded: {},
|
|
1548
|
+
errors: [],
|
|
1549
|
+
callback
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1552
|
+
return {
|
|
1553
|
+
toLoad: Object.keys(toLoad),
|
|
1554
|
+
pending: Object.keys(pending),
|
|
1555
|
+
toLoadLanguages: Object.keys(toLoadLanguages),
|
|
1556
|
+
toLoadNamespaces: Object.keys(toLoadNamespaces)
|
|
1557
|
+
};
|
|
1558
|
+
}
|
|
1559
|
+
loaded(name, err, data) {
|
|
1560
|
+
const s = name.split('|');
|
|
1561
|
+
const lng = s[0];
|
|
1562
|
+
const ns = s[1];
|
|
1563
|
+
if (err) this.emit('failedLoading', lng, ns, err);
|
|
1564
|
+
if (!err && data) {
|
|
1565
|
+
this.store.addResourceBundle(lng, ns, data, undefined, undefined, {
|
|
1566
|
+
skipCopy: true
|
|
1567
|
+
});
|
|
1568
|
+
}
|
|
1569
|
+
this.state[name] = err ? -1 : 2;
|
|
1570
|
+
if (err && data) this.state[name] = 0;
|
|
1571
|
+
const loaded = {};
|
|
1572
|
+
this.queue.forEach(q => {
|
|
1573
|
+
pushPath(q.loaded, [lng], ns);
|
|
1574
|
+
removePending(q, name);
|
|
1575
|
+
if (err) q.errors.push(err);
|
|
1576
|
+
if (q.pendingCount === 0 && !q.done) {
|
|
1577
|
+
Object.keys(q.loaded).forEach(l => {
|
|
1578
|
+
if (!loaded[l]) loaded[l] = {};
|
|
1579
|
+
const loadedKeys = q.loaded[l];
|
|
1580
|
+
if (loadedKeys.length) {
|
|
1581
|
+
loadedKeys.forEach(n => {
|
|
1582
|
+
if (loaded[l][n] === undefined) loaded[l][n] = true;
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
});
|
|
1586
|
+
q.done = true;
|
|
1587
|
+
if (q.errors.length) {
|
|
1588
|
+
q.callback(q.errors);
|
|
1589
|
+
} else {
|
|
1590
|
+
q.callback();
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
});
|
|
1594
|
+
this.emit('loaded', loaded);
|
|
1595
|
+
this.queue = this.queue.filter(q => !q.done);
|
|
1596
|
+
}
|
|
1597
|
+
read(lng, ns, fcName, tried = 0, wait = this.retryTimeout, callback) {
|
|
1598
|
+
if (!lng.length) return callback(null, {});
|
|
1599
|
+
if (this.readingCalls >= this.maxParallelReads) {
|
|
1600
|
+
this.waitingReads.push({
|
|
1601
|
+
lng,
|
|
1602
|
+
ns,
|
|
1603
|
+
fcName,
|
|
1604
|
+
tried,
|
|
1605
|
+
wait,
|
|
1606
|
+
callback
|
|
1607
|
+
});
|
|
1608
|
+
return;
|
|
1609
|
+
}
|
|
1610
|
+
this.readingCalls++;
|
|
1611
|
+
const resolver = (err, data) => {
|
|
1612
|
+
this.readingCalls--;
|
|
1613
|
+
if (this.waitingReads.length > 0) {
|
|
1614
|
+
const next = this.waitingReads.shift();
|
|
1615
|
+
this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
|
|
1616
|
+
}
|
|
1617
|
+
if (err && data && tried < this.maxRetries) {
|
|
1618
|
+
setTimeout(() => {
|
|
1619
|
+
this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
|
|
1620
|
+
}, wait);
|
|
1621
|
+
return;
|
|
1622
|
+
}
|
|
1623
|
+
callback(err, data);
|
|
1624
|
+
};
|
|
1625
|
+
const fc = this.backend[fcName].bind(this.backend);
|
|
1626
|
+
if (fc.length === 2) {
|
|
1627
|
+
try {
|
|
1628
|
+
const r = fc(lng, ns);
|
|
1629
|
+
if (r && typeof r.then === 'function') {
|
|
1630
|
+
r.then(data => resolver(null, data)).catch(resolver);
|
|
1631
|
+
} else {
|
|
1632
|
+
resolver(null, r);
|
|
1633
|
+
}
|
|
1634
|
+
} catch (err) {
|
|
1635
|
+
resolver(err);
|
|
1636
|
+
}
|
|
1637
|
+
return;
|
|
1638
|
+
}
|
|
1639
|
+
return fc(lng, ns, resolver);
|
|
1640
|
+
}
|
|
1641
|
+
prepareLoading(languages, namespaces, options = {}, callback) {
|
|
1642
|
+
if (!this.backend) {
|
|
1643
|
+
this.logger.warn('No backend was added via i18next.use. Will not load resources.');
|
|
1644
|
+
return callback && callback();
|
|
1645
|
+
}
|
|
1646
|
+
if (isString(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
|
|
1647
|
+
if (isString(namespaces)) namespaces = [namespaces];
|
|
1648
|
+
const toLoad = this.queueLoad(languages, namespaces, options, callback);
|
|
1649
|
+
if (!toLoad.toLoad.length) {
|
|
1650
|
+
if (!toLoad.pending.length) callback();
|
|
1651
|
+
return null;
|
|
1652
|
+
}
|
|
1653
|
+
toLoad.toLoad.forEach(name => {
|
|
1654
|
+
this.loadOne(name);
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
load(languages, namespaces, callback) {
|
|
1658
|
+
this.prepareLoading(languages, namespaces, {}, callback);
|
|
1659
|
+
}
|
|
1660
|
+
reload(languages, namespaces, callback) {
|
|
1661
|
+
this.prepareLoading(languages, namespaces, {
|
|
1662
|
+
reload: true
|
|
1663
|
+
}, callback);
|
|
1664
|
+
}
|
|
1665
|
+
loadOne(name, prefix = '') {
|
|
1666
|
+
const s = name.split('|');
|
|
1667
|
+
const lng = s[0];
|
|
1668
|
+
const ns = s[1];
|
|
1669
|
+
this.read(lng, ns, 'read', undefined, undefined, (err, data) => {
|
|
1670
|
+
if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
|
|
1671
|
+
if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
|
|
1672
|
+
this.loaded(name, err, data);
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
saveMissing(languages, namespace, key, fallbackValue, isUpdate, options = {}, clb = () => {}) {
|
|
1676
|
+
if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(namespace)) {
|
|
1677
|
+
this.logger.warn(`did not save key "${key}" as the namespace "${namespace}" was not yet loaded`, 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
|
|
1678
|
+
return;
|
|
1679
|
+
}
|
|
1680
|
+
if (key === undefined || key === null || key === '') return;
|
|
1681
|
+
if (this.backend?.create) {
|
|
1682
|
+
const opts = {
|
|
1683
|
+
...options,
|
|
1684
|
+
isUpdate
|
|
1685
|
+
};
|
|
1686
|
+
const fc = this.backend.create.bind(this.backend);
|
|
1687
|
+
if (fc.length < 6) {
|
|
1688
|
+
try {
|
|
1689
|
+
let r;
|
|
1690
|
+
if (fc.length === 5) {
|
|
1691
|
+
r = fc(languages, namespace, key, fallbackValue, opts);
|
|
1692
|
+
} else {
|
|
1693
|
+
r = fc(languages, namespace, key, fallbackValue);
|
|
1694
|
+
}
|
|
1695
|
+
if (r && typeof r.then === 'function') {
|
|
1696
|
+
r.then(data => clb(null, data)).catch(clb);
|
|
1697
|
+
} else {
|
|
1698
|
+
clb(null, r);
|
|
1699
|
+
}
|
|
1700
|
+
} catch (err) {
|
|
1701
|
+
clb(err);
|
|
1702
|
+
}
|
|
1703
|
+
} else {
|
|
1704
|
+
fc(languages, namespace, key, fallbackValue, clb, opts);
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
if (!languages || !languages[0]) return;
|
|
1708
|
+
this.store.addResource(languages[0], namespace, key, fallbackValue);
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
const get = () => ({
|
|
1713
|
+
debug: false,
|
|
1714
|
+
initAsync: true,
|
|
1715
|
+
ns: ['translation'],
|
|
1716
|
+
defaultNS: ['translation'],
|
|
1717
|
+
fallbackLng: ['dev'],
|
|
1718
|
+
fallbackNS: false,
|
|
1719
|
+
supportedLngs: false,
|
|
1720
|
+
nonExplicitSupportedLngs: false,
|
|
1721
|
+
load: 'all',
|
|
1722
|
+
preload: false,
|
|
1723
|
+
simplifyPluralSuffix: true,
|
|
1724
|
+
keySeparator: '.',
|
|
1725
|
+
nsSeparator: ':',
|
|
1726
|
+
pluralSeparator: '_',
|
|
1727
|
+
contextSeparator: '_',
|
|
1728
|
+
partialBundledLanguages: false,
|
|
1729
|
+
saveMissing: false,
|
|
1730
|
+
updateMissing: false,
|
|
1731
|
+
saveMissingTo: 'fallback',
|
|
1732
|
+
saveMissingPlurals: true,
|
|
1733
|
+
missingKeyHandler: false,
|
|
1734
|
+
missingInterpolationHandler: false,
|
|
1735
|
+
postProcess: false,
|
|
1736
|
+
postProcessPassResolved: false,
|
|
1737
|
+
returnNull: false,
|
|
1738
|
+
returnEmptyString: true,
|
|
1739
|
+
returnObjects: false,
|
|
1740
|
+
joinArrays: false,
|
|
1741
|
+
returnedObjectHandler: false,
|
|
1742
|
+
parseMissingKeyHandler: false,
|
|
1743
|
+
appendNamespaceToMissingKey: false,
|
|
1744
|
+
appendNamespaceToCIMode: false,
|
|
1745
|
+
overloadTranslationOptionHandler: args => {
|
|
1746
|
+
let ret = {};
|
|
1747
|
+
if (typeof args[1] === 'object') ret = args[1];
|
|
1748
|
+
if (isString(args[1])) ret.defaultValue = args[1];
|
|
1749
|
+
if (isString(args[2])) ret.tDescription = args[2];
|
|
1750
|
+
if (typeof args[2] === 'object' || typeof args[3] === 'object') {
|
|
1751
|
+
const options = args[3] || args[2];
|
|
1752
|
+
Object.keys(options).forEach(key => {
|
|
1753
|
+
ret[key] = options[key];
|
|
1754
|
+
});
|
|
1755
|
+
}
|
|
1756
|
+
return ret;
|
|
1757
|
+
},
|
|
1758
|
+
interpolation: {
|
|
1759
|
+
escapeValue: true,
|
|
1760
|
+
format: value => value,
|
|
1761
|
+
prefix: '{{',
|
|
1762
|
+
suffix: '}}',
|
|
1763
|
+
formatSeparator: ',',
|
|
1764
|
+
unescapePrefix: '-',
|
|
1765
|
+
nestingPrefix: '$t(',
|
|
1766
|
+
nestingSuffix: ')',
|
|
1767
|
+
nestingOptionsSeparator: ',',
|
|
1768
|
+
maxReplaces: 1000,
|
|
1769
|
+
skipOnVariables: true
|
|
1770
|
+
},
|
|
1771
|
+
cacheInBuiltFormats: true
|
|
1772
|
+
});
|
|
1773
|
+
const transformOptions = options => {
|
|
1774
|
+
if (isString(options.ns)) options.ns = [options.ns];
|
|
1775
|
+
if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
|
|
1776
|
+
if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
|
|
1777
|
+
if (options.supportedLngs?.indexOf?.('cimode') < 0) {
|
|
1778
|
+
options.supportedLngs = options.supportedLngs.concat(['cimode']);
|
|
1779
|
+
}
|
|
1780
|
+
if (typeof options.initImmediate === 'boolean') options.initAsync = options.initImmediate;
|
|
1781
|
+
return options;
|
|
1782
|
+
};
|
|
1783
|
+
|
|
1784
|
+
const noop = () => {};
|
|
1785
|
+
const bindMemberFunctions = inst => {
|
|
1786
|
+
const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
|
|
1787
|
+
mems.forEach(mem => {
|
|
1788
|
+
if (typeof inst[mem] === 'function') {
|
|
1789
|
+
inst[mem] = inst[mem].bind(inst);
|
|
1790
|
+
}
|
|
1791
|
+
});
|
|
1792
|
+
};
|
|
1793
|
+
class I18n extends EventEmitter {
|
|
1794
|
+
constructor(options = {}, callback) {
|
|
1795
|
+
super();
|
|
1796
|
+
this.options = transformOptions(options);
|
|
1797
|
+
this.services = {};
|
|
1798
|
+
this.logger = baseLogger;
|
|
1799
|
+
this.modules = {
|
|
1800
|
+
external: []
|
|
1801
|
+
};
|
|
1802
|
+
bindMemberFunctions(this);
|
|
1803
|
+
if (callback && !this.isInitialized && !options.isClone) {
|
|
1804
|
+
if (!this.options.initAsync) {
|
|
1805
|
+
this.init(options, callback);
|
|
1806
|
+
return this;
|
|
1807
|
+
}
|
|
1808
|
+
setTimeout(() => {
|
|
1809
|
+
this.init(options, callback);
|
|
1810
|
+
}, 0);
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
init(options = {}, callback) {
|
|
1814
|
+
this.isInitializing = true;
|
|
1815
|
+
if (typeof options === 'function') {
|
|
1816
|
+
callback = options;
|
|
1817
|
+
options = {};
|
|
1818
|
+
}
|
|
1819
|
+
if (options.defaultNS == null && options.ns) {
|
|
1820
|
+
if (isString(options.ns)) {
|
|
1821
|
+
options.defaultNS = options.ns;
|
|
1822
|
+
} else if (options.ns.indexOf('translation') < 0) {
|
|
1823
|
+
options.defaultNS = options.ns[0];
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
const defOpts = get();
|
|
1827
|
+
this.options = {
|
|
1828
|
+
...defOpts,
|
|
1829
|
+
...this.options,
|
|
1830
|
+
...transformOptions(options)
|
|
1831
|
+
};
|
|
1832
|
+
this.options.interpolation = {
|
|
1833
|
+
...defOpts.interpolation,
|
|
1834
|
+
...this.options.interpolation
|
|
1835
|
+
};
|
|
1836
|
+
if (options.keySeparator !== undefined) {
|
|
1837
|
+
this.options.userDefinedKeySeparator = options.keySeparator;
|
|
1838
|
+
}
|
|
1839
|
+
if (options.nsSeparator !== undefined) {
|
|
1840
|
+
this.options.userDefinedNsSeparator = options.nsSeparator;
|
|
1841
|
+
}
|
|
1842
|
+
const createClassOnDemand = ClassOrObject => {
|
|
1843
|
+
if (!ClassOrObject) return null;
|
|
1844
|
+
if (typeof ClassOrObject === 'function') return new ClassOrObject();
|
|
1845
|
+
return ClassOrObject;
|
|
1846
|
+
};
|
|
1847
|
+
if (!this.options.isClone) {
|
|
1848
|
+
if (this.modules.logger) {
|
|
1849
|
+
baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
|
|
1850
|
+
} else {
|
|
1851
|
+
baseLogger.init(null, this.options);
|
|
1852
|
+
}
|
|
1853
|
+
let formatter;
|
|
1854
|
+
if (this.modules.formatter) {
|
|
1855
|
+
formatter = this.modules.formatter;
|
|
1856
|
+
} else {
|
|
1857
|
+
formatter = Formatter;
|
|
1858
|
+
}
|
|
1859
|
+
const lu = new LanguageUtil(this.options);
|
|
1860
|
+
this.store = new ResourceStore(this.options.resources, this.options);
|
|
1861
|
+
const s = this.services;
|
|
1862
|
+
s.logger = baseLogger;
|
|
1863
|
+
s.resourceStore = this.store;
|
|
1864
|
+
s.languageUtils = lu;
|
|
1865
|
+
s.pluralResolver = new PluralResolver(lu, {
|
|
1866
|
+
prepend: this.options.pluralSeparator,
|
|
1867
|
+
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
|
1868
|
+
});
|
|
1869
|
+
const usingLegacyFormatFunction = this.options.interpolation.format && this.options.interpolation.format !== defOpts.interpolation.format;
|
|
1870
|
+
if (usingLegacyFormatFunction) {
|
|
1871
|
+
this.logger.deprecate(`init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting`);
|
|
1872
|
+
}
|
|
1873
|
+
if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
|
|
1874
|
+
s.formatter = createClassOnDemand(formatter);
|
|
1875
|
+
if (s.formatter.init) s.formatter.init(s, this.options);
|
|
1876
|
+
this.options.interpolation.format = s.formatter.format.bind(s.formatter);
|
|
1877
|
+
}
|
|
1878
|
+
s.interpolator = new Interpolator(this.options);
|
|
1879
|
+
s.utils = {
|
|
1880
|
+
hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
|
|
1881
|
+
};
|
|
1882
|
+
s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
|
|
1883
|
+
s.backendConnector.on('*', (event, ...args) => {
|
|
1884
|
+
this.emit(event, ...args);
|
|
1885
|
+
});
|
|
1886
|
+
if (this.modules.languageDetector) {
|
|
1887
|
+
s.languageDetector = createClassOnDemand(this.modules.languageDetector);
|
|
1888
|
+
if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
|
|
1889
|
+
}
|
|
1890
|
+
if (this.modules.i18nFormat) {
|
|
1891
|
+
s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
|
|
1892
|
+
if (s.i18nFormat.init) s.i18nFormat.init(this);
|
|
1893
|
+
}
|
|
1894
|
+
this.translator = new Translator(this.services, this.options);
|
|
1895
|
+
this.translator.on('*', (event, ...args) => {
|
|
1896
|
+
this.emit(event, ...args);
|
|
1897
|
+
});
|
|
1898
|
+
this.modules.external.forEach(m => {
|
|
1899
|
+
if (m.init) m.init(this);
|
|
1900
|
+
});
|
|
1901
|
+
}
|
|
1902
|
+
this.format = this.options.interpolation.format;
|
|
1903
|
+
if (!callback) callback = noop;
|
|
1904
|
+
if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
|
|
1905
|
+
const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
1906
|
+
if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
|
|
1907
|
+
}
|
|
1908
|
+
if (!this.services.languageDetector && !this.options.lng) {
|
|
1909
|
+
this.logger.warn('init: no languageDetector is used and no lng is defined');
|
|
1910
|
+
}
|
|
1911
|
+
const storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
|
|
1912
|
+
storeApi.forEach(fcName => {
|
|
1913
|
+
this[fcName] = (...args) => this.store[fcName](...args);
|
|
1914
|
+
});
|
|
1915
|
+
const storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
|
|
1916
|
+
storeApiChained.forEach(fcName => {
|
|
1917
|
+
this[fcName] = (...args) => {
|
|
1918
|
+
this.store[fcName](...args);
|
|
1919
|
+
return this;
|
|
1920
|
+
};
|
|
1921
|
+
});
|
|
1922
|
+
const deferred = defer();
|
|
1923
|
+
const load = () => {
|
|
1924
|
+
const finish = (err, t) => {
|
|
1925
|
+
this.isInitializing = false;
|
|
1926
|
+
if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn('init: i18next is already initialized. You should call init just once!');
|
|
1927
|
+
this.isInitialized = true;
|
|
1928
|
+
if (!this.options.isClone) this.logger.log('initialized', this.options);
|
|
1929
|
+
this.emit('initialized', this.options);
|
|
1930
|
+
deferred.resolve(t);
|
|
1931
|
+
callback(err, t);
|
|
1932
|
+
};
|
|
1933
|
+
if (this.languages && !this.isInitialized) return finish(null, this.t.bind(this));
|
|
1934
|
+
this.changeLanguage(this.options.lng, finish);
|
|
1935
|
+
};
|
|
1936
|
+
if (this.options.resources || !this.options.initAsync) {
|
|
1937
|
+
load();
|
|
1938
|
+
} else {
|
|
1939
|
+
setTimeout(load, 0);
|
|
1940
|
+
}
|
|
1941
|
+
return deferred;
|
|
1942
|
+
}
|
|
1943
|
+
loadResources(language, callback = noop) {
|
|
1944
|
+
let usedCallback = callback;
|
|
1945
|
+
const usedLng = isString(language) ? language : this.language;
|
|
1946
|
+
if (typeof language === 'function') usedCallback = language;
|
|
1947
|
+
if (!this.options.resources || this.options.partialBundledLanguages) {
|
|
1948
|
+
if (usedLng?.toLowerCase() === 'cimode' && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
|
|
1949
|
+
const toLoad = [];
|
|
1950
|
+
const append = lng => {
|
|
1951
|
+
if (!lng) return;
|
|
1952
|
+
if (lng === 'cimode') return;
|
|
1953
|
+
const lngs = this.services.languageUtils.toResolveHierarchy(lng);
|
|
1954
|
+
lngs.forEach(l => {
|
|
1955
|
+
if (l === 'cimode') return;
|
|
1956
|
+
if (toLoad.indexOf(l) < 0) toLoad.push(l);
|
|
1957
|
+
});
|
|
1958
|
+
};
|
|
1959
|
+
if (!usedLng) {
|
|
1960
|
+
const fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
1961
|
+
fallbacks.forEach(l => append(l));
|
|
1962
|
+
} else {
|
|
1963
|
+
append(usedLng);
|
|
1964
|
+
}
|
|
1965
|
+
this.options.preload?.forEach?.(l => append(l));
|
|
1966
|
+
this.services.backendConnector.load(toLoad, this.options.ns, e => {
|
|
1967
|
+
if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
|
|
1968
|
+
usedCallback(e);
|
|
1969
|
+
});
|
|
1970
|
+
} else {
|
|
1971
|
+
usedCallback(null);
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
reloadResources(lngs, ns, callback) {
|
|
1975
|
+
const deferred = defer();
|
|
1976
|
+
if (typeof lngs === 'function') {
|
|
1977
|
+
callback = lngs;
|
|
1978
|
+
lngs = undefined;
|
|
1979
|
+
}
|
|
1980
|
+
if (typeof ns === 'function') {
|
|
1981
|
+
callback = ns;
|
|
1982
|
+
ns = undefined;
|
|
1983
|
+
}
|
|
1984
|
+
if (!lngs) lngs = this.languages;
|
|
1985
|
+
if (!ns) ns = this.options.ns;
|
|
1986
|
+
if (!callback) callback = noop;
|
|
1987
|
+
this.services.backendConnector.reload(lngs, ns, err => {
|
|
1988
|
+
deferred.resolve();
|
|
1989
|
+
callback(err);
|
|
1990
|
+
});
|
|
1991
|
+
return deferred;
|
|
1992
|
+
}
|
|
1993
|
+
use(module) {
|
|
1994
|
+
if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
|
|
1995
|
+
if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
|
|
1996
|
+
if (module.type === 'backend') {
|
|
1997
|
+
this.modules.backend = module;
|
|
1998
|
+
}
|
|
1999
|
+
if (module.type === 'logger' || module.log && module.warn && module.error) {
|
|
2000
|
+
this.modules.logger = module;
|
|
2001
|
+
}
|
|
2002
|
+
if (module.type === 'languageDetector') {
|
|
2003
|
+
this.modules.languageDetector = module;
|
|
2004
|
+
}
|
|
2005
|
+
if (module.type === 'i18nFormat') {
|
|
2006
|
+
this.modules.i18nFormat = module;
|
|
2007
|
+
}
|
|
2008
|
+
if (module.type === 'postProcessor') {
|
|
2009
|
+
postProcessor.addPostProcessor(module);
|
|
2010
|
+
}
|
|
2011
|
+
if (module.type === 'formatter') {
|
|
2012
|
+
this.modules.formatter = module;
|
|
2013
|
+
}
|
|
2014
|
+
if (module.type === '3rdParty') {
|
|
2015
|
+
this.modules.external.push(module);
|
|
2016
|
+
}
|
|
2017
|
+
return this;
|
|
2018
|
+
}
|
|
2019
|
+
setResolvedLanguage(l) {
|
|
2020
|
+
if (!l || !this.languages) return;
|
|
2021
|
+
if (['cimode', 'dev'].indexOf(l) > -1) return;
|
|
2022
|
+
for (let li = 0; li < this.languages.length; li++) {
|
|
2023
|
+
const lngInLngs = this.languages[li];
|
|
2024
|
+
if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
|
|
2025
|
+
if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
|
|
2026
|
+
this.resolvedLanguage = lngInLngs;
|
|
2027
|
+
break;
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
if (!this.resolvedLanguage && this.languages.indexOf(l) < 0 && this.store.hasLanguageSomeTranslations(l)) {
|
|
2031
|
+
this.resolvedLanguage = l;
|
|
2032
|
+
this.languages.unshift(l);
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
changeLanguage(lng, callback) {
|
|
2036
|
+
this.isLanguageChangingTo = lng;
|
|
2037
|
+
const deferred = defer();
|
|
2038
|
+
this.emit('languageChanging', lng);
|
|
2039
|
+
const setLngProps = l => {
|
|
2040
|
+
this.language = l;
|
|
2041
|
+
this.languages = this.services.languageUtils.toResolveHierarchy(l);
|
|
2042
|
+
this.resolvedLanguage = undefined;
|
|
2043
|
+
this.setResolvedLanguage(l);
|
|
2044
|
+
};
|
|
2045
|
+
const done = (err, l) => {
|
|
2046
|
+
if (l) {
|
|
2047
|
+
if (this.isLanguageChangingTo === lng) {
|
|
2048
|
+
setLngProps(l);
|
|
2049
|
+
this.translator.changeLanguage(l);
|
|
2050
|
+
this.isLanguageChangingTo = undefined;
|
|
2051
|
+
this.emit('languageChanged', l);
|
|
2052
|
+
this.logger.log('languageChanged', l);
|
|
2053
|
+
}
|
|
2054
|
+
} else {
|
|
2055
|
+
this.isLanguageChangingTo = undefined;
|
|
2056
|
+
}
|
|
2057
|
+
deferred.resolve((...args) => this.t(...args));
|
|
2058
|
+
if (callback) callback(err, (...args) => this.t(...args));
|
|
2059
|
+
};
|
|
2060
|
+
const setLng = lngs => {
|
|
2061
|
+
if (!lng && !lngs && this.services.languageDetector) lngs = [];
|
|
2062
|
+
const fl = isString(lngs) ? lngs : lngs && lngs[0];
|
|
2063
|
+
const l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
|
|
2064
|
+
if (l) {
|
|
2065
|
+
if (!this.language) {
|
|
2066
|
+
setLngProps(l);
|
|
2067
|
+
}
|
|
2068
|
+
if (!this.translator.language) this.translator.changeLanguage(l);
|
|
2069
|
+
this.services.languageDetector?.cacheUserLanguage?.(l);
|
|
2070
|
+
}
|
|
2071
|
+
this.loadResources(l, err => {
|
|
2072
|
+
done(err, l);
|
|
2073
|
+
});
|
|
2074
|
+
};
|
|
2075
|
+
if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
|
|
2076
|
+
setLng(this.services.languageDetector.detect());
|
|
2077
|
+
} else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
|
|
2078
|
+
if (this.services.languageDetector.detect.length === 0) {
|
|
2079
|
+
this.services.languageDetector.detect().then(setLng);
|
|
2080
|
+
} else {
|
|
2081
|
+
this.services.languageDetector.detect(setLng);
|
|
2082
|
+
}
|
|
2083
|
+
} else {
|
|
2084
|
+
setLng(lng);
|
|
2085
|
+
}
|
|
2086
|
+
return deferred;
|
|
2087
|
+
}
|
|
2088
|
+
getFixedT(lng, ns, keyPrefix) {
|
|
2089
|
+
const fixedT = (key, opts, ...rest) => {
|
|
2090
|
+
let o;
|
|
2091
|
+
if (typeof opts !== 'object') {
|
|
2092
|
+
o = this.options.overloadTranslationOptionHandler([key, opts].concat(rest));
|
|
2093
|
+
} else {
|
|
2094
|
+
o = {
|
|
2095
|
+
...opts
|
|
2096
|
+
};
|
|
2097
|
+
}
|
|
2098
|
+
o.lng = o.lng || fixedT.lng;
|
|
2099
|
+
o.lngs = o.lngs || fixedT.lngs;
|
|
2100
|
+
o.ns = o.ns || fixedT.ns;
|
|
2101
|
+
if (o.keyPrefix !== '') o.keyPrefix = o.keyPrefix || keyPrefix || fixedT.keyPrefix;
|
|
2102
|
+
const keySeparator = this.options.keySeparator || '.';
|
|
2103
|
+
let resultKey;
|
|
2104
|
+
if (o.keyPrefix && Array.isArray(key)) {
|
|
2105
|
+
resultKey = key.map(k => {
|
|
2106
|
+
if (typeof k === 'function') k = keysFromSelector(k, {
|
|
2107
|
+
...this.options,
|
|
2108
|
+
...opts
|
|
2109
|
+
});
|
|
2110
|
+
return `${o.keyPrefix}${keySeparator}${k}`;
|
|
2111
|
+
});
|
|
2112
|
+
} else {
|
|
2113
|
+
if (typeof key === 'function') key = keysFromSelector(key, {
|
|
2114
|
+
...this.options,
|
|
2115
|
+
...opts
|
|
2116
|
+
});
|
|
2117
|
+
resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key}` : key;
|
|
2118
|
+
}
|
|
2119
|
+
return this.t(resultKey, o);
|
|
2120
|
+
};
|
|
2121
|
+
if (isString(lng)) {
|
|
2122
|
+
fixedT.lng = lng;
|
|
2123
|
+
} else {
|
|
2124
|
+
fixedT.lngs = lng;
|
|
2125
|
+
}
|
|
2126
|
+
fixedT.ns = ns;
|
|
2127
|
+
fixedT.keyPrefix = keyPrefix;
|
|
2128
|
+
return fixedT;
|
|
2129
|
+
}
|
|
2130
|
+
t(...args) {
|
|
2131
|
+
return this.translator?.translate(...args);
|
|
2132
|
+
}
|
|
2133
|
+
exists(...args) {
|
|
2134
|
+
return this.translator?.exists(...args);
|
|
2135
|
+
}
|
|
2136
|
+
setDefaultNamespace(ns) {
|
|
2137
|
+
this.options.defaultNS = ns;
|
|
2138
|
+
}
|
|
2139
|
+
hasLoadedNamespace(ns, options = {}) {
|
|
2140
|
+
if (!this.isInitialized) {
|
|
2141
|
+
this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
|
|
2142
|
+
return false;
|
|
2143
|
+
}
|
|
2144
|
+
if (!this.languages || !this.languages.length) {
|
|
2145
|
+
this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
|
|
2146
|
+
return false;
|
|
2147
|
+
}
|
|
2148
|
+
const lng = options.lng || this.resolvedLanguage || this.languages[0];
|
|
2149
|
+
const fallbackLng = this.options ? this.options.fallbackLng : false;
|
|
2150
|
+
const lastLng = this.languages[this.languages.length - 1];
|
|
2151
|
+
if (lng.toLowerCase() === 'cimode') return true;
|
|
2152
|
+
const loadNotPending = (l, n) => {
|
|
2153
|
+
const loadState = this.services.backendConnector.state[`${l}|${n}`];
|
|
2154
|
+
return loadState === -1 || loadState === 0 || loadState === 2;
|
|
2155
|
+
};
|
|
2156
|
+
if (options.precheck) {
|
|
2157
|
+
const preResult = options.precheck(this, loadNotPending);
|
|
2158
|
+
if (preResult !== undefined) return preResult;
|
|
2159
|
+
}
|
|
2160
|
+
if (this.hasResourceBundle(lng, ns)) return true;
|
|
2161
|
+
if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
|
|
2162
|
+
if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
|
|
2163
|
+
return false;
|
|
2164
|
+
}
|
|
2165
|
+
loadNamespaces(ns, callback) {
|
|
2166
|
+
const deferred = defer();
|
|
2167
|
+
if (!this.options.ns) {
|
|
2168
|
+
if (callback) callback();
|
|
2169
|
+
return Promise.resolve();
|
|
2170
|
+
}
|
|
2171
|
+
if (isString(ns)) ns = [ns];
|
|
2172
|
+
ns.forEach(n => {
|
|
2173
|
+
if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
|
|
2174
|
+
});
|
|
2175
|
+
this.loadResources(err => {
|
|
2176
|
+
deferred.resolve();
|
|
2177
|
+
if (callback) callback(err);
|
|
2178
|
+
});
|
|
2179
|
+
return deferred;
|
|
2180
|
+
}
|
|
2181
|
+
loadLanguages(lngs, callback) {
|
|
2182
|
+
const deferred = defer();
|
|
2183
|
+
if (isString(lngs)) lngs = [lngs];
|
|
2184
|
+
const preloaded = this.options.preload || [];
|
|
2185
|
+
const newLngs = lngs.filter(lng => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
|
|
2186
|
+
if (!newLngs.length) {
|
|
2187
|
+
if (callback) callback();
|
|
2188
|
+
return Promise.resolve();
|
|
2189
|
+
}
|
|
2190
|
+
this.options.preload = preloaded.concat(newLngs);
|
|
2191
|
+
this.loadResources(err => {
|
|
2192
|
+
deferred.resolve();
|
|
2193
|
+
if (callback) callback(err);
|
|
2194
|
+
});
|
|
2195
|
+
return deferred;
|
|
2196
|
+
}
|
|
2197
|
+
dir(lng) {
|
|
2198
|
+
if (!lng) lng = this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language);
|
|
2199
|
+
if (!lng) return 'rtl';
|
|
2200
|
+
try {
|
|
2201
|
+
const l = new Intl.Locale(lng);
|
|
2202
|
+
if (l && l.getTextInfo) {
|
|
2203
|
+
const ti = l.getTextInfo();
|
|
2204
|
+
if (ti && ti.direction) return ti.direction;
|
|
2205
|
+
}
|
|
2206
|
+
} catch (e) {}
|
|
2207
|
+
const rtlLngs = ['ar', 'shu', 'sqr', 'ssh', 'xaa', 'yhd', 'yud', 'aao', 'abh', 'abv', 'acm', 'acq', 'acw', 'acx', 'acy', 'adf', 'ads', 'aeb', 'aec', 'afb', 'ajp', 'apc', 'apd', 'arb', 'arq', 'ars', 'ary', 'arz', 'auz', 'avl', 'ayh', 'ayl', 'ayn', 'ayp', 'bbz', 'pga', 'he', 'iw', 'ps', 'pbt', 'pbu', 'pst', 'prp', 'prd', 'ug', 'ur', 'ydd', 'yds', 'yih', 'ji', 'yi', 'hbo', 'men', 'xmn', 'fa', 'jpr', 'peo', 'pes', 'prs', 'dv', 'sam', 'ckb'];
|
|
2208
|
+
const languageUtils = this.services?.languageUtils || new LanguageUtil(get());
|
|
2209
|
+
if (lng.toLowerCase().indexOf('-latn') > 1) return 'ltr';
|
|
2210
|
+
return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
|
|
2211
|
+
}
|
|
2212
|
+
static createInstance(options = {}, callback) {
|
|
2213
|
+
const instance = new I18n(options, callback);
|
|
2214
|
+
instance.createInstance = I18n.createInstance;
|
|
2215
|
+
return instance;
|
|
2216
|
+
}
|
|
2217
|
+
cloneInstance(options = {}, callback = noop) {
|
|
2218
|
+
const forkResourceStore = options.forkResourceStore;
|
|
2219
|
+
if (forkResourceStore) delete options.forkResourceStore;
|
|
2220
|
+
const mergedOptions = {
|
|
2221
|
+
...this.options,
|
|
2222
|
+
...options,
|
|
2223
|
+
...{
|
|
2224
|
+
isClone: true
|
|
2225
|
+
}
|
|
2226
|
+
};
|
|
2227
|
+
const clone = new I18n(mergedOptions);
|
|
2228
|
+
if (options.debug !== undefined || options.prefix !== undefined) {
|
|
2229
|
+
clone.logger = clone.logger.clone(options);
|
|
2230
|
+
}
|
|
2231
|
+
const membersToCopy = ['store', 'services', 'language'];
|
|
2232
|
+
membersToCopy.forEach(m => {
|
|
2233
|
+
clone[m] = this[m];
|
|
2234
|
+
});
|
|
2235
|
+
clone.services = {
|
|
2236
|
+
...this.services
|
|
2237
|
+
};
|
|
2238
|
+
clone.services.utils = {
|
|
2239
|
+
hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
|
|
2240
|
+
};
|
|
2241
|
+
if (forkResourceStore) {
|
|
2242
|
+
const clonedData = Object.keys(this.store.data).reduce((prev, l) => {
|
|
2243
|
+
prev[l] = {
|
|
2244
|
+
...this.store.data[l]
|
|
2245
|
+
};
|
|
2246
|
+
prev[l] = Object.keys(prev[l]).reduce((acc, n) => {
|
|
2247
|
+
acc[n] = {
|
|
2248
|
+
...prev[l][n]
|
|
2249
|
+
};
|
|
2250
|
+
return acc;
|
|
2251
|
+
}, prev[l]);
|
|
2252
|
+
return prev;
|
|
2253
|
+
}, {});
|
|
2254
|
+
clone.store = new ResourceStore(clonedData, mergedOptions);
|
|
2255
|
+
clone.services.resourceStore = clone.store;
|
|
2256
|
+
}
|
|
2257
|
+
clone.translator = new Translator(clone.services, mergedOptions);
|
|
2258
|
+
clone.translator.on('*', (event, ...args) => {
|
|
2259
|
+
clone.emit(event, ...args);
|
|
2260
|
+
});
|
|
2261
|
+
clone.init(mergedOptions, callback);
|
|
2262
|
+
clone.translator.options = mergedOptions;
|
|
2263
|
+
clone.translator.backendConnector.services.utils = {
|
|
2264
|
+
hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
|
|
2265
|
+
};
|
|
2266
|
+
return clone;
|
|
2267
|
+
}
|
|
2268
|
+
toJSON() {
|
|
2269
|
+
return {
|
|
2270
|
+
options: this.options,
|
|
2271
|
+
store: this.store,
|
|
2272
|
+
language: this.language,
|
|
2273
|
+
languages: this.languages,
|
|
2274
|
+
resolvedLanguage: this.resolvedLanguage
|
|
2275
|
+
};
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
const instance = I18n.createInstance();
|
|
2279
|
+
|
|
2280
|
+
const {
|
|
2281
|
+
slice,
|
|
2282
|
+
forEach
|
|
2283
|
+
} = [];
|
|
2284
|
+
function defaults(obj) {
|
|
2285
|
+
forEach.call(slice.call(arguments, 1), source => {
|
|
2286
|
+
if (source) {
|
|
2287
|
+
for (const prop in source) {
|
|
2288
|
+
if (obj[prop] === undefined) obj[prop] = source[prop];
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
});
|
|
2292
|
+
return obj;
|
|
2293
|
+
}
|
|
2294
|
+
function hasXSS(input) {
|
|
2295
|
+
if (typeof input !== 'string') return false;
|
|
2296
|
+
|
|
2297
|
+
// Common XSS attack patterns
|
|
2298
|
+
const xssPatterns = [/<\s*script.*?>/i, /<\s*\/\s*script\s*>/i, /<\s*img.*?on\w+\s*=/i, /<\s*\w+\s*on\w+\s*=.*?>/i, /javascript\s*:/i, /vbscript\s*:/i, /expression\s*\(/i, /eval\s*\(/i, /alert\s*\(/i, /document\.cookie/i, /document\.write\s*\(/i, /window\.location/i, /innerHTML/i];
|
|
2299
|
+
return xssPatterns.some(pattern => pattern.test(input));
|
|
2300
|
+
}
|
|
2301
|
+
|
|
2302
|
+
// eslint-disable-next-line no-control-regex
|
|
2303
|
+
const fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
2304
|
+
const serializeCookie = function (name, val) {
|
|
2305
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
2306
|
+
path: '/'
|
|
2307
|
+
};
|
|
2308
|
+
const opt = options;
|
|
2309
|
+
const value = encodeURIComponent(val);
|
|
2310
|
+
let str = `${name}=${value}`;
|
|
2311
|
+
if (opt.maxAge > 0) {
|
|
2312
|
+
const maxAge = opt.maxAge - 0;
|
|
2313
|
+
if (Number.isNaN(maxAge)) throw new Error('maxAge should be a Number');
|
|
2314
|
+
str += `; Max-Age=${Math.floor(maxAge)}`;
|
|
2315
|
+
}
|
|
2316
|
+
if (opt.domain) {
|
|
2317
|
+
if (!fieldContentRegExp.test(opt.domain)) {
|
|
2318
|
+
throw new TypeError('option domain is invalid');
|
|
2319
|
+
}
|
|
2320
|
+
str += `; Domain=${opt.domain}`;
|
|
2321
|
+
}
|
|
2322
|
+
if (opt.path) {
|
|
2323
|
+
if (!fieldContentRegExp.test(opt.path)) {
|
|
2324
|
+
throw new TypeError('option path is invalid');
|
|
2325
|
+
}
|
|
2326
|
+
str += `; Path=${opt.path}`;
|
|
2327
|
+
}
|
|
2328
|
+
if (opt.expires) {
|
|
2329
|
+
if (typeof opt.expires.toUTCString !== 'function') {
|
|
2330
|
+
throw new TypeError('option expires is invalid');
|
|
2331
|
+
}
|
|
2332
|
+
str += `; Expires=${opt.expires.toUTCString()}`;
|
|
2333
|
+
}
|
|
2334
|
+
if (opt.httpOnly) str += '; HttpOnly';
|
|
2335
|
+
if (opt.secure) str += '; Secure';
|
|
2336
|
+
if (opt.sameSite) {
|
|
2337
|
+
const sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite;
|
|
2338
|
+
switch (sameSite) {
|
|
2339
|
+
case true:
|
|
2340
|
+
str += '; SameSite=Strict';
|
|
2341
|
+
break;
|
|
2342
|
+
case 'lax':
|
|
2343
|
+
str += '; SameSite=Lax';
|
|
2344
|
+
break;
|
|
2345
|
+
case 'strict':
|
|
2346
|
+
str += '; SameSite=Strict';
|
|
2347
|
+
break;
|
|
2348
|
+
case 'none':
|
|
2349
|
+
str += '; SameSite=None';
|
|
2350
|
+
break;
|
|
2351
|
+
default:
|
|
2352
|
+
throw new TypeError('option sameSite is invalid');
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
if (opt.partitioned) str += '; Partitioned';
|
|
2356
|
+
return str;
|
|
2357
|
+
};
|
|
2358
|
+
const cookie = {
|
|
2359
|
+
create(name, value, minutes, domain) {
|
|
2360
|
+
let cookieOptions = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
2361
|
+
path: '/',
|
|
2362
|
+
sameSite: 'strict'
|
|
2363
|
+
};
|
|
2364
|
+
if (minutes) {
|
|
2365
|
+
cookieOptions.expires = new Date();
|
|
2366
|
+
cookieOptions.expires.setTime(cookieOptions.expires.getTime() + minutes * 60 * 1000);
|
|
2367
|
+
}
|
|
2368
|
+
if (domain) cookieOptions.domain = domain;
|
|
2369
|
+
document.cookie = serializeCookie(name, value, cookieOptions);
|
|
2370
|
+
},
|
|
2371
|
+
read(name) {
|
|
2372
|
+
const nameEQ = `${name}=`;
|
|
2373
|
+
const ca = document.cookie.split(';');
|
|
2374
|
+
for (let i = 0; i < ca.length; i++) {
|
|
2375
|
+
let c = ca[i];
|
|
2376
|
+
while (c.charAt(0) === ' ') c = c.substring(1, c.length);
|
|
2377
|
+
if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
|
|
2378
|
+
}
|
|
2379
|
+
return null;
|
|
2380
|
+
},
|
|
2381
|
+
remove(name, domain) {
|
|
2382
|
+
this.create(name, '', -1, domain);
|
|
2383
|
+
}
|
|
2384
|
+
};
|
|
2385
|
+
var cookie$1 = {
|
|
2386
|
+
name: 'cookie',
|
|
2387
|
+
// Deconstruct the options object and extract the lookupCookie property
|
|
2388
|
+
lookup(_ref) {
|
|
2389
|
+
let {
|
|
2390
|
+
lookupCookie
|
|
2391
|
+
} = _ref;
|
|
2392
|
+
if (lookupCookie && typeof document !== 'undefined') {
|
|
2393
|
+
return cookie.read(lookupCookie) || undefined;
|
|
2394
|
+
}
|
|
2395
|
+
return undefined;
|
|
2396
|
+
},
|
|
2397
|
+
// Deconstruct the options object and extract the lookupCookie, cookieMinutes, cookieDomain, and cookieOptions properties
|
|
2398
|
+
cacheUserLanguage(lng, _ref2) {
|
|
2399
|
+
let {
|
|
2400
|
+
lookupCookie,
|
|
2401
|
+
cookieMinutes,
|
|
2402
|
+
cookieDomain,
|
|
2403
|
+
cookieOptions
|
|
2404
|
+
} = _ref2;
|
|
2405
|
+
if (lookupCookie && typeof document !== 'undefined') {
|
|
2406
|
+
cookie.create(lookupCookie, lng, cookieMinutes, cookieDomain, cookieOptions);
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
};
|
|
2410
|
+
|
|
2411
|
+
var querystring = {
|
|
2412
|
+
name: 'querystring',
|
|
2413
|
+
// Deconstruct the options object and extract the lookupQuerystring property
|
|
2414
|
+
lookup(_ref) {
|
|
2415
|
+
let {
|
|
2416
|
+
lookupQuerystring
|
|
2417
|
+
} = _ref;
|
|
2418
|
+
let found;
|
|
2419
|
+
if (typeof window !== 'undefined') {
|
|
2420
|
+
let {
|
|
2421
|
+
search
|
|
2422
|
+
} = window.location;
|
|
2423
|
+
if (!window.location.search && window.location.hash?.indexOf('?') > -1) {
|
|
2424
|
+
search = window.location.hash.substring(window.location.hash.indexOf('?'));
|
|
2425
|
+
}
|
|
2426
|
+
const query = search.substring(1);
|
|
2427
|
+
const params = query.split('&');
|
|
2428
|
+
for (let i = 0; i < params.length; i++) {
|
|
2429
|
+
const pos = params[i].indexOf('=');
|
|
2430
|
+
if (pos > 0) {
|
|
2431
|
+
const key = params[i].substring(0, pos);
|
|
2432
|
+
if (key === lookupQuerystring) {
|
|
2433
|
+
found = params[i].substring(pos + 1);
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
return found;
|
|
2439
|
+
}
|
|
2440
|
+
};
|
|
2441
|
+
|
|
2442
|
+
var hash = {
|
|
2443
|
+
name: 'hash',
|
|
2444
|
+
// Deconstruct the options object and extract the lookupHash property and the lookupFromHashIndex property
|
|
2445
|
+
lookup(_ref) {
|
|
2446
|
+
let {
|
|
2447
|
+
lookupHash,
|
|
2448
|
+
lookupFromHashIndex
|
|
2449
|
+
} = _ref;
|
|
2450
|
+
let found;
|
|
2451
|
+
if (typeof window !== 'undefined') {
|
|
2452
|
+
const {
|
|
2453
|
+
hash
|
|
2454
|
+
} = window.location;
|
|
2455
|
+
if (hash && hash.length > 2) {
|
|
2456
|
+
const query = hash.substring(1);
|
|
2457
|
+
if (lookupHash) {
|
|
2458
|
+
const params = query.split('&');
|
|
2459
|
+
for (let i = 0; i < params.length; i++) {
|
|
2460
|
+
const pos = params[i].indexOf('=');
|
|
2461
|
+
if (pos > 0) {
|
|
2462
|
+
const key = params[i].substring(0, pos);
|
|
2463
|
+
if (key === lookupHash) {
|
|
2464
|
+
found = params[i].substring(pos + 1);
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2469
|
+
if (found) return found;
|
|
2470
|
+
if (!found && lookupFromHashIndex > -1) {
|
|
2471
|
+
const language = hash.match(/\/([a-zA-Z-]*)/g);
|
|
2472
|
+
if (!Array.isArray(language)) return undefined;
|
|
2473
|
+
const index = typeof lookupFromHashIndex === 'number' ? lookupFromHashIndex : 0;
|
|
2474
|
+
return language[index]?.replace('/', '');
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
return found;
|
|
2479
|
+
}
|
|
2480
|
+
};
|
|
2481
|
+
|
|
2482
|
+
let hasLocalStorageSupport = null;
|
|
2483
|
+
const localStorageAvailable = () => {
|
|
2484
|
+
if (hasLocalStorageSupport !== null) return hasLocalStorageSupport;
|
|
2485
|
+
try {
|
|
2486
|
+
hasLocalStorageSupport = typeof window !== 'undefined' && window.localStorage !== null;
|
|
2487
|
+
if (!hasLocalStorageSupport) {
|
|
2488
|
+
return false;
|
|
2489
|
+
}
|
|
2490
|
+
const testKey = 'i18next.translate.boo';
|
|
2491
|
+
window.localStorage.setItem(testKey, 'foo');
|
|
2492
|
+
window.localStorage.removeItem(testKey);
|
|
2493
|
+
} catch (e) {
|
|
2494
|
+
hasLocalStorageSupport = false;
|
|
2495
|
+
}
|
|
2496
|
+
return hasLocalStorageSupport;
|
|
2497
|
+
};
|
|
2498
|
+
var localStorage = {
|
|
2499
|
+
name: 'localStorage',
|
|
2500
|
+
// Deconstruct the options object and extract the lookupLocalStorage property
|
|
2501
|
+
lookup(_ref) {
|
|
2502
|
+
let {
|
|
2503
|
+
lookupLocalStorage
|
|
2504
|
+
} = _ref;
|
|
2505
|
+
if (lookupLocalStorage && localStorageAvailable()) {
|
|
2506
|
+
return window.localStorage.getItem(lookupLocalStorage) || undefined; // Undefined ensures type consistency with the previous version of this function
|
|
2507
|
+
}
|
|
2508
|
+
return undefined;
|
|
2509
|
+
},
|
|
2510
|
+
// Deconstruct the options object and extract the lookupLocalStorage property
|
|
2511
|
+
cacheUserLanguage(lng, _ref2) {
|
|
2512
|
+
let {
|
|
2513
|
+
lookupLocalStorage
|
|
2514
|
+
} = _ref2;
|
|
2515
|
+
if (lookupLocalStorage && localStorageAvailable()) {
|
|
2516
|
+
window.localStorage.setItem(lookupLocalStorage, lng);
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
};
|
|
2520
|
+
|
|
2521
|
+
let hasSessionStorageSupport = null;
|
|
2522
|
+
const sessionStorageAvailable = () => {
|
|
2523
|
+
if (hasSessionStorageSupport !== null) return hasSessionStorageSupport;
|
|
2524
|
+
try {
|
|
2525
|
+
hasSessionStorageSupport = typeof window !== 'undefined' && window.sessionStorage !== null;
|
|
2526
|
+
if (!hasSessionStorageSupport) {
|
|
2527
|
+
return false;
|
|
2528
|
+
}
|
|
2529
|
+
const testKey = 'i18next.translate.boo';
|
|
2530
|
+
window.sessionStorage.setItem(testKey, 'foo');
|
|
2531
|
+
window.sessionStorage.removeItem(testKey);
|
|
2532
|
+
} catch (e) {
|
|
2533
|
+
hasSessionStorageSupport = false;
|
|
2534
|
+
}
|
|
2535
|
+
return hasSessionStorageSupport;
|
|
2536
|
+
};
|
|
2537
|
+
var sessionStorage = {
|
|
2538
|
+
name: 'sessionStorage',
|
|
2539
|
+
lookup(_ref) {
|
|
2540
|
+
let {
|
|
2541
|
+
lookupSessionStorage
|
|
2542
|
+
} = _ref;
|
|
2543
|
+
if (lookupSessionStorage && sessionStorageAvailable()) {
|
|
2544
|
+
return window.sessionStorage.getItem(lookupSessionStorage) || undefined;
|
|
2545
|
+
}
|
|
2546
|
+
return undefined;
|
|
2547
|
+
},
|
|
2548
|
+
cacheUserLanguage(lng, _ref2) {
|
|
2549
|
+
let {
|
|
2550
|
+
lookupSessionStorage
|
|
2551
|
+
} = _ref2;
|
|
2552
|
+
if (lookupSessionStorage && sessionStorageAvailable()) {
|
|
2553
|
+
window.sessionStorage.setItem(lookupSessionStorage, lng);
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
};
|
|
2557
|
+
|
|
2558
|
+
var navigator$1 = {
|
|
2559
|
+
name: 'navigator',
|
|
2560
|
+
lookup(options) {
|
|
2561
|
+
const found = [];
|
|
2562
|
+
if (typeof navigator !== 'undefined') {
|
|
2563
|
+
const {
|
|
2564
|
+
languages,
|
|
2565
|
+
userLanguage,
|
|
2566
|
+
language
|
|
2567
|
+
} = navigator;
|
|
2568
|
+
if (languages) {
|
|
2569
|
+
// chrome only; not an array, so can't use .push.apply instead of iterating
|
|
2570
|
+
for (let i = 0; i < languages.length; i++) {
|
|
2571
|
+
found.push(languages[i]);
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2574
|
+
if (userLanguage) {
|
|
2575
|
+
found.push(userLanguage);
|
|
2576
|
+
}
|
|
2577
|
+
if (language) {
|
|
2578
|
+
found.push(language);
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
return found.length > 0 ? found : undefined;
|
|
2582
|
+
}
|
|
2583
|
+
};
|
|
2584
|
+
|
|
2585
|
+
var htmlTag = {
|
|
2586
|
+
name: 'htmlTag',
|
|
2587
|
+
// Deconstruct the options object and extract the htmlTag property
|
|
2588
|
+
lookup(_ref) {
|
|
2589
|
+
let {
|
|
2590
|
+
htmlTag
|
|
2591
|
+
} = _ref;
|
|
2592
|
+
let found;
|
|
2593
|
+
const internalHtmlTag = htmlTag || (typeof document !== 'undefined' ? document.documentElement : null);
|
|
2594
|
+
if (internalHtmlTag && typeof internalHtmlTag.getAttribute === 'function') {
|
|
2595
|
+
found = internalHtmlTag.getAttribute('lang');
|
|
2596
|
+
}
|
|
2597
|
+
return found;
|
|
2598
|
+
}
|
|
2599
|
+
};
|
|
2600
|
+
|
|
2601
|
+
var path = {
|
|
2602
|
+
name: 'path',
|
|
2603
|
+
// Deconstruct the options object and extract the lookupFromPathIndex property
|
|
2604
|
+
lookup(_ref) {
|
|
2605
|
+
let {
|
|
2606
|
+
lookupFromPathIndex
|
|
2607
|
+
} = _ref;
|
|
2608
|
+
if (typeof window === 'undefined') return undefined;
|
|
2609
|
+
const language = window.location.pathname.match(/\/([a-zA-Z-]*)/g);
|
|
2610
|
+
if (!Array.isArray(language)) return undefined;
|
|
2611
|
+
const index = typeof lookupFromPathIndex === 'number' ? lookupFromPathIndex : 0;
|
|
2612
|
+
return language[index]?.replace('/', '');
|
|
2613
|
+
}
|
|
2614
|
+
};
|
|
2615
|
+
|
|
2616
|
+
var subdomain = {
|
|
2617
|
+
name: 'subdomain',
|
|
2618
|
+
lookup(_ref) {
|
|
2619
|
+
let {
|
|
2620
|
+
lookupFromSubdomainIndex
|
|
2621
|
+
} = _ref;
|
|
2622
|
+
// If given get the subdomain index else 1
|
|
2623
|
+
const internalLookupFromSubdomainIndex = typeof lookupFromSubdomainIndex === 'number' ? lookupFromSubdomainIndex + 1 : 1;
|
|
2624
|
+
// get all matches if window.location. is existing
|
|
2625
|
+
// first item of match is the match itself and the second is the first group match which should be the first subdomain match
|
|
2626
|
+
// is the hostname no public domain get the or option of localhost
|
|
2627
|
+
const language = typeof window !== 'undefined' && window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);
|
|
2628
|
+
|
|
2629
|
+
// if there is no match (null) return undefined
|
|
2630
|
+
if (!language) return undefined;
|
|
2631
|
+
// return the given group match
|
|
2632
|
+
return language[internalLookupFromSubdomainIndex];
|
|
2633
|
+
}
|
|
2634
|
+
};
|
|
2635
|
+
|
|
2636
|
+
// some environments, throws when accessing document.cookie
|
|
2637
|
+
let canCookies = false;
|
|
2638
|
+
try {
|
|
2639
|
+
canCookies = true;
|
|
2640
|
+
// eslint-disable-next-line no-empty
|
|
2641
|
+
} catch (e) {}
|
|
2642
|
+
const order = ['querystring', 'cookie', 'localStorage', 'sessionStorage', 'navigator', 'htmlTag'];
|
|
2643
|
+
if (!canCookies) order.splice(1, 1);
|
|
2644
|
+
const getDefaults = () => ({
|
|
2645
|
+
order,
|
|
2646
|
+
lookupQuerystring: 'lng',
|
|
2647
|
+
lookupCookie: 'i18next',
|
|
2648
|
+
lookupLocalStorage: 'i18nextLng',
|
|
2649
|
+
lookupSessionStorage: 'i18nextLng',
|
|
2650
|
+
// cache user language
|
|
2651
|
+
caches: ['localStorage'],
|
|
2652
|
+
excludeCacheFor: ['cimode'],
|
|
2653
|
+
// cookieMinutes: 10,
|
|
2654
|
+
// cookieDomain: 'myDomain'
|
|
2655
|
+
|
|
2656
|
+
convertDetectedLanguage: l => l
|
|
2657
|
+
});
|
|
2658
|
+
class Browser {
|
|
2659
|
+
constructor(services) {
|
|
2660
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2661
|
+
this.type = 'languageDetector';
|
|
2662
|
+
this.detectors = {};
|
|
2663
|
+
this.init(services, options);
|
|
2664
|
+
}
|
|
2665
|
+
init() {
|
|
2666
|
+
let services = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
2667
|
+
languageUtils: {}
|
|
2668
|
+
};
|
|
2669
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2670
|
+
let i18nOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2671
|
+
this.services = services;
|
|
2672
|
+
this.options = defaults(options, this.options || {}, getDefaults());
|
|
2673
|
+
if (typeof this.options.convertDetectedLanguage === 'string' && this.options.convertDetectedLanguage.indexOf('15897') > -1) {
|
|
2674
|
+
this.options.convertDetectedLanguage = l => l.replace('-', '_');
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
// backwards compatibility
|
|
2678
|
+
if (this.options.lookupFromUrlIndex) this.options.lookupFromPathIndex = this.options.lookupFromUrlIndex;
|
|
2679
|
+
this.i18nOptions = i18nOptions;
|
|
2680
|
+
this.addDetector(cookie$1);
|
|
2681
|
+
this.addDetector(querystring);
|
|
2682
|
+
this.addDetector(localStorage);
|
|
2683
|
+
this.addDetector(sessionStorage);
|
|
2684
|
+
this.addDetector(navigator$1);
|
|
2685
|
+
this.addDetector(htmlTag);
|
|
2686
|
+
this.addDetector(path);
|
|
2687
|
+
this.addDetector(subdomain);
|
|
2688
|
+
this.addDetector(hash);
|
|
2689
|
+
}
|
|
2690
|
+
addDetector(detector) {
|
|
2691
|
+
this.detectors[detector.name] = detector;
|
|
2692
|
+
return this;
|
|
2693
|
+
}
|
|
2694
|
+
detect() {
|
|
2695
|
+
let detectionOrder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.options.order;
|
|
2696
|
+
let detected = [];
|
|
2697
|
+
detectionOrder.forEach(detectorName => {
|
|
2698
|
+
if (this.detectors[detectorName]) {
|
|
2699
|
+
let lookup = this.detectors[detectorName].lookup(this.options);
|
|
2700
|
+
if (lookup && typeof lookup === 'string') lookup = [lookup];
|
|
2701
|
+
if (lookup) detected = detected.concat(lookup);
|
|
2702
|
+
}
|
|
2703
|
+
});
|
|
2704
|
+
detected = detected.filter(d => d !== undefined && d !== null && !hasXSS(d)).map(d => this.options.convertDetectedLanguage(d));
|
|
2705
|
+
if (this.services && this.services.languageUtils && this.services.languageUtils.getBestMatchFromCodes) return detected; // new i18next v19.5.0
|
|
2706
|
+
return detected.length > 0 ? detected[0] : null; // a little backward compatibility
|
|
2707
|
+
}
|
|
2708
|
+
cacheUserLanguage(lng) {
|
|
2709
|
+
let caches = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.options.caches;
|
|
2710
|
+
if (!caches) return;
|
|
2711
|
+
if (this.options.excludeCacheFor && this.options.excludeCacheFor.indexOf(lng) > -1) return;
|
|
2712
|
+
caches.forEach(cacheName => {
|
|
2713
|
+
if (this.detectors[cacheName]) this.detectors[cacheName].cacheUserLanguage(lng, this.options);
|
|
2714
|
+
});
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2717
|
+
Browser.type = 'languageDetector';
|
|
2718
|
+
|
|
2719
|
+
instance.use(Browser).init({
|
|
2720
|
+
fallbackLng: 'en',
|
|
2721
|
+
debug: false,
|
|
2722
|
+
resources: {
|
|
2723
|
+
en: {
|
|
2724
|
+
translation: {},
|
|
2725
|
+
},
|
|
2726
|
+
ja: {
|
|
2727
|
+
translation: {
|
|
2728
|
+
'Pay': '支払う',
|
|
2729
|
+
'Failed to load Stripe': 'ライブラリの読み込みに失敗しました。',
|
|
2730
|
+
'Add your payment information': '支払情報を追加',
|
|
2731
|
+
'Add card': 'カードを追加',
|
|
2732
|
+
'Add a card': 'カードを追加',
|
|
2733
|
+
'Add': '追加',
|
|
2734
|
+
'Card information': 'カード情報',
|
|
2735
|
+
'Card Number': 'カード番号',
|
|
2736
|
+
'MM / YY': '月 / 年',
|
|
2737
|
+
'CVC': 'セキュリティコード(CVC)',
|
|
2738
|
+
'Country or region': '地域',
|
|
2739
|
+
'Postal Code': '郵便番号',
|
|
2740
|
+
},
|
|
2741
|
+
},
|
|
2742
|
+
'pt-BR': {
|
|
2743
|
+
translation: {
|
|
2744
|
+
'Pay': 'Pagar',
|
|
2745
|
+
'Failed to load Stripe': 'Falha ao ler Stripe',
|
|
2746
|
+
'Add your payment information': 'Informações do seu Pagamento',
|
|
2747
|
+
'Add card': 'Adicionar Cartão',
|
|
2748
|
+
'Add a card': 'Adicionar um Cartão',
|
|
2749
|
+
'Add': 'Adicionar',
|
|
2750
|
+
'Card information': 'Informações do Cartão',
|
|
2751
|
+
'Card Number': 'Número do Cartão',
|
|
2752
|
+
'MM / YY': 'MM / AA',
|
|
2753
|
+
'CVC': 'Número de Segurança(CVC)',
|
|
2754
|
+
'Country or region': 'País ou região',
|
|
2755
|
+
'Postal Code': 'Cep',
|
|
2756
|
+
},
|
|
2757
|
+
},
|
|
2758
|
+
},
|
|
2759
|
+
});
|
|
2760
|
+
const i18n = instance;
|
|
2761
|
+
|
|
2762
|
+
const appendToMap = (map, propName, value) => {
|
|
2763
|
+
const items = map.get(propName);
|
|
2764
|
+
if (!items) {
|
|
2765
|
+
map.set(propName, [value]);
|
|
2766
|
+
}
|
|
2767
|
+
else if (!items.includes(value)) {
|
|
2768
|
+
items.push(value);
|
|
2769
|
+
}
|
|
2770
|
+
};
|
|
2771
|
+
const debounce = (fn, ms) => {
|
|
2772
|
+
let timeoutId;
|
|
2773
|
+
return (...args) => {
|
|
2774
|
+
if (timeoutId) {
|
|
2775
|
+
clearTimeout(timeoutId);
|
|
2776
|
+
}
|
|
2777
|
+
timeoutId = setTimeout(() => {
|
|
2778
|
+
timeoutId = 0;
|
|
2779
|
+
fn(...args);
|
|
2780
|
+
}, ms);
|
|
2781
|
+
};
|
|
2782
|
+
};
|
|
2783
|
+
|
|
2784
|
+
/**
|
|
2785
|
+
* Check if a possible element isConnected.
|
|
2786
|
+
* The property might not be there, so we check for it.
|
|
2787
|
+
*
|
|
2788
|
+
* We want it to return true if isConnected is not a property,
|
|
2789
|
+
* otherwise we would remove these elements and would not update.
|
|
2790
|
+
*
|
|
2791
|
+
* Better leak in Edge than to be useless.
|
|
2792
|
+
*/
|
|
2793
|
+
const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
|
|
2794
|
+
const cleanupElements = debounce((map) => {
|
|
2795
|
+
for (let key of map.keys()) {
|
|
2796
|
+
map.set(key, map.get(key).filter(isConnected));
|
|
2797
|
+
}
|
|
2798
|
+
}, 2_000);
|
|
2799
|
+
const stencilSubscription = () => {
|
|
2800
|
+
if (typeof index.getRenderingRef !== 'function') {
|
|
2801
|
+
// If we are not in a stencil project, we do nothing.
|
|
2802
|
+
// This function is not really exported by @stencil/core.
|
|
2803
|
+
return {};
|
|
2804
|
+
}
|
|
2805
|
+
const elmsToUpdate = new Map();
|
|
2806
|
+
return {
|
|
2807
|
+
dispose: () => elmsToUpdate.clear(),
|
|
2808
|
+
get: (propName) => {
|
|
2809
|
+
const elm = index.getRenderingRef();
|
|
2810
|
+
if (elm) {
|
|
2811
|
+
appendToMap(elmsToUpdate, propName, elm);
|
|
2812
|
+
}
|
|
2813
|
+
},
|
|
2814
|
+
set: (propName) => {
|
|
2815
|
+
const elements = elmsToUpdate.get(propName);
|
|
2816
|
+
if (elements) {
|
|
2817
|
+
elmsToUpdate.set(propName, elements.filter(index.forceUpdate));
|
|
2818
|
+
}
|
|
2819
|
+
cleanupElements(elmsToUpdate);
|
|
2820
|
+
},
|
|
2821
|
+
reset: () => {
|
|
2822
|
+
elmsToUpdate.forEach((elms) => elms.forEach(index.forceUpdate));
|
|
2823
|
+
cleanupElements(elmsToUpdate);
|
|
2824
|
+
},
|
|
2825
|
+
};
|
|
2826
|
+
};
|
|
2827
|
+
|
|
2828
|
+
const unwrap = (val) => (typeof val === 'function' ? val() : val);
|
|
2829
|
+
const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
|
|
2830
|
+
const unwrappedState = unwrap(defaultState);
|
|
2831
|
+
let states = new Map(Object.entries(unwrappedState ?? {}));
|
|
2832
|
+
const handlers = {
|
|
2833
|
+
dispose: [],
|
|
2834
|
+
get: [],
|
|
2835
|
+
set: [],
|
|
2836
|
+
reset: [],
|
|
2837
|
+
};
|
|
2838
|
+
// Track onChange listeners to enable removeListener functionality
|
|
2839
|
+
const changeListeners = new Map();
|
|
2840
|
+
const reset = () => {
|
|
2841
|
+
// When resetting the state, the default state may be a function - unwrap it to invoke it.
|
|
2842
|
+
// otherwise, the state won't be properly reset
|
|
2843
|
+
states = new Map(Object.entries(unwrap(defaultState) ?? {}));
|
|
2844
|
+
handlers.reset.forEach((cb) => cb());
|
|
2845
|
+
};
|
|
2846
|
+
const dispose = () => {
|
|
2847
|
+
// Call first dispose as resetting the state would
|
|
2848
|
+
// cause less updates ;)
|
|
2849
|
+
handlers.dispose.forEach((cb) => cb());
|
|
2850
|
+
reset();
|
|
2851
|
+
};
|
|
2852
|
+
const get = (propName) => {
|
|
2853
|
+
handlers.get.forEach((cb) => cb(propName));
|
|
2854
|
+
return states.get(propName);
|
|
2855
|
+
};
|
|
2856
|
+
const set = (propName, value) => {
|
|
2857
|
+
const oldValue = states.get(propName);
|
|
2858
|
+
if (shouldUpdate(value, oldValue, propName)) {
|
|
2859
|
+
states.set(propName, value);
|
|
2860
|
+
handlers.set.forEach((cb) => cb(propName, value, oldValue));
|
|
2861
|
+
}
|
|
2862
|
+
};
|
|
2863
|
+
const state = (typeof Proxy === 'undefined'
|
|
2864
|
+
? {}
|
|
2865
|
+
: new Proxy(unwrappedState, {
|
|
2866
|
+
get(_, propName) {
|
|
2867
|
+
return get(propName);
|
|
2868
|
+
},
|
|
2869
|
+
ownKeys(_) {
|
|
2870
|
+
return Array.from(states.keys());
|
|
2871
|
+
},
|
|
2872
|
+
getOwnPropertyDescriptor() {
|
|
2873
|
+
return {
|
|
2874
|
+
enumerable: true,
|
|
2875
|
+
configurable: true,
|
|
2876
|
+
};
|
|
2877
|
+
},
|
|
2878
|
+
has(_, propName) {
|
|
2879
|
+
return states.has(propName);
|
|
2880
|
+
},
|
|
2881
|
+
set(_, propName, value) {
|
|
2882
|
+
set(propName, value);
|
|
2883
|
+
return true;
|
|
2884
|
+
},
|
|
2885
|
+
}));
|
|
2886
|
+
const on = (eventName, callback) => {
|
|
2887
|
+
handlers[eventName].push(callback);
|
|
2888
|
+
return () => {
|
|
2889
|
+
removeFromArray(handlers[eventName], callback);
|
|
2890
|
+
};
|
|
2891
|
+
};
|
|
2892
|
+
const onChange = (propName, cb) => {
|
|
2893
|
+
const setHandler = (key, newValue) => {
|
|
2894
|
+
if (key === propName) {
|
|
2895
|
+
cb(newValue);
|
|
2896
|
+
}
|
|
2897
|
+
};
|
|
2898
|
+
const resetHandler = () => cb(unwrap(defaultState)[propName]);
|
|
2899
|
+
// Register the handlers
|
|
2900
|
+
const unSet = on('set', setHandler);
|
|
2901
|
+
const unReset = on('reset', resetHandler);
|
|
2902
|
+
// Track the relationship between the user callback and internal handlers
|
|
2903
|
+
changeListeners.set(cb, { setHandler, resetHandler, propName });
|
|
2904
|
+
return () => {
|
|
2905
|
+
unSet();
|
|
2906
|
+
unReset();
|
|
2907
|
+
changeListeners.delete(cb);
|
|
2908
|
+
};
|
|
2909
|
+
};
|
|
2910
|
+
const use = (...subscriptions) => {
|
|
2911
|
+
const unsubs = subscriptions.reduce((unsubs, subscription) => {
|
|
2912
|
+
if (subscription.set) {
|
|
2913
|
+
unsubs.push(on('set', subscription.set));
|
|
2914
|
+
}
|
|
2915
|
+
if (subscription.get) {
|
|
2916
|
+
unsubs.push(on('get', subscription.get));
|
|
2917
|
+
}
|
|
2918
|
+
if (subscription.reset) {
|
|
2919
|
+
unsubs.push(on('reset', subscription.reset));
|
|
2920
|
+
}
|
|
2921
|
+
if (subscription.dispose) {
|
|
2922
|
+
unsubs.push(on('dispose', subscription.dispose));
|
|
2923
|
+
}
|
|
2924
|
+
return unsubs;
|
|
2925
|
+
}, []);
|
|
2926
|
+
return () => unsubs.forEach((unsub) => unsub());
|
|
2927
|
+
};
|
|
2928
|
+
const forceUpdate = (key) => {
|
|
2929
|
+
const oldValue = states.get(key);
|
|
2930
|
+
handlers.set.forEach((cb) => cb(key, oldValue, oldValue));
|
|
2931
|
+
};
|
|
2932
|
+
const removeListener = (propName, listener) => {
|
|
2933
|
+
const listenerInfo = changeListeners.get(listener);
|
|
2934
|
+
if (listenerInfo && listenerInfo.propName === propName) {
|
|
2935
|
+
// Remove the specific handlers that were created for this listener
|
|
2936
|
+
removeFromArray(handlers.set, listenerInfo.setHandler);
|
|
2937
|
+
removeFromArray(handlers.reset, listenerInfo.resetHandler);
|
|
2938
|
+
changeListeners.delete(listener);
|
|
2939
|
+
}
|
|
2940
|
+
};
|
|
2941
|
+
return {
|
|
2942
|
+
state,
|
|
2943
|
+
get,
|
|
2944
|
+
set,
|
|
2945
|
+
on,
|
|
2946
|
+
onChange,
|
|
2947
|
+
use,
|
|
2948
|
+
dispose,
|
|
2949
|
+
reset,
|
|
2950
|
+
forceUpdate,
|
|
2951
|
+
removeListener,
|
|
2952
|
+
};
|
|
2953
|
+
};
|
|
2954
|
+
const removeFromArray = (array, item) => {
|
|
2955
|
+
const index = array.indexOf(item);
|
|
2956
|
+
if (index >= 0) {
|
|
2957
|
+
array[index] = array[array.length - 1];
|
|
2958
|
+
array.length--;
|
|
2959
|
+
}
|
|
2960
|
+
};
|
|
2961
|
+
|
|
2962
|
+
const createStore = (defaultState, shouldUpdate) => {
|
|
2963
|
+
const map = createObservableMap(defaultState, shouldUpdate);
|
|
2964
|
+
map.use(stencilSubscription());
|
|
2965
|
+
return map;
|
|
2966
|
+
};
|
|
2967
|
+
|
|
2968
|
+
/**
|
|
2969
|
+
* Core Stripe Service
|
|
2970
|
+
* Manages Stripe.js initialization and Elements instance only
|
|
2971
|
+
* Does NOT manage specific element types (Card, Payment, etc.)
|
|
2972
|
+
*/
|
|
2973
|
+
class StripeServiceClass {
|
|
2974
|
+
constructor() {
|
|
2975
|
+
this.store = createStore({
|
|
2976
|
+
loadStripeStatus: '',
|
|
2977
|
+
applicationName: 'stripe-pwa-elements',
|
|
2978
|
+
});
|
|
2979
|
+
this.changeListeners = new Map();
|
|
2980
|
+
}
|
|
2981
|
+
/**
|
|
2982
|
+
* Get the reactive state object
|
|
2983
|
+
* Components can use this directly in render() for automatic reactivity
|
|
2984
|
+
*/
|
|
2985
|
+
get state() {
|
|
2986
|
+
return this.store.state;
|
|
2987
|
+
}
|
|
2988
|
+
/**
|
|
2989
|
+
* Register a callback for when a specific state property changes
|
|
2990
|
+
* @param key - The state property to watch
|
|
2991
|
+
* @param callback - Function to call when the property changes
|
|
2992
|
+
* @returns Unsubscribe function
|
|
2993
|
+
*/
|
|
2994
|
+
onChange(key, callback) {
|
|
2995
|
+
const dispose = this.store.onChange(key, callback);
|
|
2996
|
+
// Track listeners for cleanup
|
|
2997
|
+
if (!this.changeListeners.has(key)) {
|
|
2998
|
+
this.changeListeners.set(key, []);
|
|
2999
|
+
}
|
|
3000
|
+
this.changeListeners.get(key).push(dispose);
|
|
3001
|
+
return dispose;
|
|
3002
|
+
}
|
|
3003
|
+
/**
|
|
3004
|
+
* Initialize Stripe.js client
|
|
3005
|
+
* @param publishableKey - Your Stripe publishable API key
|
|
3006
|
+
* @param options - Optional configuration
|
|
3007
|
+
*/
|
|
3008
|
+
async initialize(publishableKey, options) {
|
|
3009
|
+
// Update configuration
|
|
3010
|
+
this.store.state.publishableKey = publishableKey;
|
|
3011
|
+
if (options === null || options === void 0 ? void 0 : options.stripeAccount) {
|
|
3012
|
+
this.store.state.stripeAccount = options.stripeAccount;
|
|
3013
|
+
}
|
|
3014
|
+
if (options === null || options === void 0 ? void 0 : options.applicationName) {
|
|
3015
|
+
this.store.state.applicationName = options.applicationName;
|
|
3016
|
+
}
|
|
3017
|
+
// If Stripe.js already loaded with same config, do nothing
|
|
3018
|
+
if (this.store.state.stripe && this.store.state.publishableKey === publishableKey && this.store.state.stripeAccount === (options === null || options === void 0 ? void 0 : options.stripeAccount)) {
|
|
3019
|
+
return;
|
|
3020
|
+
}
|
|
3021
|
+
this.store.state.loadStripeStatus = 'loading';
|
|
3022
|
+
try {
|
|
3023
|
+
const stripe = await index$1.loadStripe(publishableKey, {
|
|
3024
|
+
stripeAccount: options === null || options === void 0 ? void 0 : options.stripeAccount,
|
|
3025
|
+
});
|
|
3026
|
+
// Register app info
|
|
3027
|
+
stripe.registerAppInfo({
|
|
3028
|
+
name: this.store.state.applicationName,
|
|
3029
|
+
});
|
|
3030
|
+
this.store.state.stripe = stripe;
|
|
3031
|
+
this.store.state.elements = stripe.elements();
|
|
3032
|
+
this.store.state.loadStripeStatus = 'success';
|
|
3033
|
+
}
|
|
3034
|
+
catch (e) {
|
|
3035
|
+
console.error('Failed to load Stripe.js:', e);
|
|
3036
|
+
this.store.state.loadStripeStatus = 'failure';
|
|
3037
|
+
}
|
|
3038
|
+
}
|
|
3039
|
+
/**
|
|
3040
|
+
* Get the current Stripe instance
|
|
3041
|
+
*/
|
|
3042
|
+
getStripe() {
|
|
3043
|
+
return this.store.state.stripe;
|
|
3044
|
+
}
|
|
3045
|
+
/**
|
|
3046
|
+
* Get the current Elements instance
|
|
3047
|
+
*/
|
|
3048
|
+
getElements() {
|
|
3049
|
+
return this.store.state.elements;
|
|
3050
|
+
}
|
|
3051
|
+
/**
|
|
3052
|
+
* Reset the service to initial state
|
|
3053
|
+
* Useful for testing and cleanup
|
|
3054
|
+
*/
|
|
3055
|
+
reset() {
|
|
3056
|
+
this.store.reset();
|
|
3057
|
+
}
|
|
3058
|
+
/**
|
|
3059
|
+
* Dispose of all listeners and reset state
|
|
3060
|
+
* Should be called in test cleanup
|
|
3061
|
+
*/
|
|
3062
|
+
dispose() {
|
|
3063
|
+
// Dispose all onChange listeners
|
|
3064
|
+
this.changeListeners.forEach(listeners => {
|
|
3065
|
+
listeners.forEach(dispose => dispose());
|
|
3066
|
+
});
|
|
3067
|
+
this.changeListeners.clear();
|
|
3068
|
+
// Dispose the store
|
|
3069
|
+
this.store.dispose();
|
|
3070
|
+
}
|
|
3071
|
+
}
|
|
3072
|
+
/**
|
|
3073
|
+
* Singleton instance of StripeService (for backward compatibility)
|
|
3074
|
+
* New code should use ServiceFactory for better testability
|
|
3075
|
+
*
|
|
3076
|
+
* @deprecated Use ServiceFactory.createStripeService() for better DI support
|
|
3077
|
+
*/
|
|
3078
|
+
new StripeServiceClass();
|
|
3079
|
+
|
|
3080
|
+
/**
|
|
3081
|
+
* Card Element Manager
|
|
3082
|
+
* Manages Stripe Card Elements (cardNumber, cardExpiry, cardCvc)
|
|
3083
|
+
* with dependency injection of StripeService
|
|
3084
|
+
*/
|
|
3085
|
+
class CardElementManager {
|
|
3086
|
+
/**
|
|
3087
|
+
* Constructor with dependency injection
|
|
3088
|
+
* @param stripeService - Injected Stripe service instance
|
|
3089
|
+
*/
|
|
3090
|
+
constructor(stripeService) {
|
|
3091
|
+
this.stripeService = stripeService;
|
|
3092
|
+
this.store = createStore({
|
|
3093
|
+
errorMessage: '',
|
|
3094
|
+
errorSource: undefined,
|
|
3095
|
+
});
|
|
3096
|
+
}
|
|
3097
|
+
/**
|
|
3098
|
+
* Get current card element state (reactive)
|
|
3099
|
+
*/
|
|
3100
|
+
getState() {
|
|
3101
|
+
return this.store.state;
|
|
3102
|
+
}
|
|
3103
|
+
/**
|
|
3104
|
+
* Initialize and mount card elements to DOM
|
|
3105
|
+
* @param containerElement - Parent element containing mount points
|
|
3106
|
+
* @returns Promise resolving to card element instances
|
|
3107
|
+
*/
|
|
3108
|
+
async initialize(containerElement) {
|
|
3109
|
+
const elements = this.stripeService.getElements();
|
|
3110
|
+
if (!elements) {
|
|
3111
|
+
throw new Error('StripeService not initialized. Call StripeService.initialize() first.');
|
|
3112
|
+
}
|
|
3113
|
+
// Unmount if already initialized
|
|
3114
|
+
if (this.cardElements) {
|
|
3115
|
+
this.unmount();
|
|
3116
|
+
}
|
|
3117
|
+
// Create and mount card number element
|
|
3118
|
+
const cardNumber = elements.create('cardNumber', {
|
|
3119
|
+
placeholder: i18n.t('Card Number'),
|
|
3120
|
+
});
|
|
3121
|
+
const cardNumberElement = await this.findElement(containerElement, '#card-number');
|
|
3122
|
+
cardNumber.mount(cardNumberElement);
|
|
3123
|
+
cardNumber.on('change', this.handleCardError('cardNumber'));
|
|
3124
|
+
// Create and mount card expiry element
|
|
3125
|
+
const cardExpiry = elements.create('cardExpiry');
|
|
3126
|
+
const cardExpiryElement = await this.findElement(containerElement, '#card-expiry');
|
|
3127
|
+
cardExpiry.mount(cardExpiryElement);
|
|
3128
|
+
cardExpiry.on('change', this.handleCardError('cardExpiry'));
|
|
3129
|
+
// Create and mount card CVC element
|
|
3130
|
+
const cardCVC = elements.create('cardCvc');
|
|
3131
|
+
const cardCVCElement = await this.findElement(containerElement, '#card-cvc');
|
|
3132
|
+
cardCVC.mount(cardCVCElement);
|
|
3133
|
+
cardCVC.on('change', this.handleCardError('cardCvc'));
|
|
3134
|
+
this.cardElements = {
|
|
3135
|
+
cardNumber,
|
|
3136
|
+
cardExpiry,
|
|
3137
|
+
cardCVC,
|
|
3138
|
+
};
|
|
3139
|
+
return this.cardElements;
|
|
3140
|
+
}
|
|
3141
|
+
/**
|
|
3142
|
+
* Get mounted card element instances
|
|
3143
|
+
*/
|
|
3144
|
+
getElements() {
|
|
3145
|
+
return this.cardElements;
|
|
3146
|
+
}
|
|
3147
|
+
/**
|
|
3148
|
+
* Set error message (triggers reactivity)
|
|
3149
|
+
*/
|
|
3150
|
+
setError(message) {
|
|
3151
|
+
this.store.set('errorMessage', message);
|
|
3152
|
+
}
|
|
3153
|
+
/**
|
|
3154
|
+
* Clear error message (triggers reactivity)
|
|
3155
|
+
*/
|
|
3156
|
+
clearError() {
|
|
3157
|
+
this.store.set('errorMessage', '');
|
|
3158
|
+
this.store.set('errorSource', undefined);
|
|
3159
|
+
}
|
|
3160
|
+
/**
|
|
3161
|
+
* Unmount all card elements
|
|
3162
|
+
*/
|
|
3163
|
+
unmount() {
|
|
3164
|
+
var _a, _b, _c;
|
|
3165
|
+
if (!this.cardElements) {
|
|
3166
|
+
return;
|
|
3167
|
+
}
|
|
3168
|
+
(_a = this.cardElements.cardNumber) === null || _a === void 0 ? void 0 : _a.unmount();
|
|
3169
|
+
(_b = this.cardElements.cardExpiry) === null || _b === void 0 ? void 0 : _b.unmount();
|
|
3170
|
+
(_c = this.cardElements.cardCVC) === null || _c === void 0 ? void 0 : _c.unmount();
|
|
3171
|
+
this.cardElements = undefined;
|
|
3172
|
+
}
|
|
3173
|
+
/**
|
|
3174
|
+
* Handle card element errors
|
|
3175
|
+
* Only clears error if it's from the same element type
|
|
3176
|
+
* Uses store.set() to trigger reactivity
|
|
3177
|
+
*/
|
|
3178
|
+
handleCardError(elementType) {
|
|
3179
|
+
return ({ error }) => {
|
|
3180
|
+
if (error) {
|
|
3181
|
+
this.store.set('errorMessage', error.message);
|
|
3182
|
+
this.store.set('errorSource', elementType);
|
|
3183
|
+
return;
|
|
3184
|
+
}
|
|
3185
|
+
// Only clear error if it originated from the same element
|
|
3186
|
+
if (this.store.state.errorSource === elementType) {
|
|
3187
|
+
this.store.set('errorMessage', '');
|
|
3188
|
+
this.store.set('errorSource', undefined);
|
|
3189
|
+
}
|
|
3190
|
+
};
|
|
3191
|
+
}
|
|
3192
|
+
/**
|
|
3193
|
+
* Wait for an element to appear in the DOM
|
|
3194
|
+
* @param containerElement - Parent element to search in
|
|
3195
|
+
* @param selector - CSS selector
|
|
3196
|
+
* @param timeout - Timeout in milliseconds (default: 5000ms)
|
|
3197
|
+
* @returns Promise that resolves to the found element or rejects on timeout
|
|
3198
|
+
*/
|
|
3199
|
+
findElement(containerElement, selector, timeout = 5000) {
|
|
3200
|
+
return new Promise((resolve, reject) => {
|
|
3201
|
+
const elem = containerElement.querySelector(selector);
|
|
3202
|
+
if (elem) {
|
|
3203
|
+
return resolve(elem);
|
|
3204
|
+
}
|
|
3205
|
+
const timeoutId = setTimeout(() => {
|
|
3206
|
+
observer.disconnect();
|
|
3207
|
+
reject(new Error(`Element "${selector}" not found within ${timeout}ms`));
|
|
3208
|
+
}, timeout);
|
|
3209
|
+
const observer = new MutationObserver(() => {
|
|
3210
|
+
const elem = containerElement.querySelector(selector);
|
|
3211
|
+
if (elem) {
|
|
3212
|
+
clearTimeout(timeoutId);
|
|
3213
|
+
observer.disconnect();
|
|
3214
|
+
resolve(elem);
|
|
3215
|
+
}
|
|
3216
|
+
});
|
|
3217
|
+
observer.observe(containerElement, {
|
|
3218
|
+
childList: true,
|
|
3219
|
+
subtree: true,
|
|
3220
|
+
});
|
|
3221
|
+
});
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
|
|
3225
|
+
/**
|
|
3226
|
+
* Service Factory
|
|
3227
|
+
* Creates service instances with proper dependency injection
|
|
3228
|
+
* Can be mocked in tests for better testability
|
|
3229
|
+
*/
|
|
3230
|
+
class ServiceFactory {
|
|
3231
|
+
/**
|
|
3232
|
+
* Create a new StripeService instance
|
|
3233
|
+
*/
|
|
3234
|
+
createStripeService() {
|
|
3235
|
+
return new StripeServiceClass();
|
|
3236
|
+
}
|
|
3237
|
+
/**
|
|
3238
|
+
* Create a new CardElementManager instance
|
|
3239
|
+
* @param stripeService - Injected StripeService dependency
|
|
3240
|
+
*/
|
|
3241
|
+
createCardElementManager(stripeService) {
|
|
3242
|
+
return new CardElementManager(stripeService);
|
|
3243
|
+
}
|
|
3244
|
+
}
|
|
3245
|
+
/**
|
|
3246
|
+
* Default factory instance
|
|
3247
|
+
* Can be replaced with a mock in tests
|
|
3248
|
+
*/
|
|
3249
|
+
const serviceFactory = new ServiceFactory();
|
|
3250
|
+
|
|
3251
|
+
class StripeAPIError extends Error {
|
|
3252
|
+
constructor(error) {
|
|
3253
|
+
super(error.message);
|
|
3254
|
+
this.code = error.code;
|
|
3255
|
+
this.docUrl = error.doc_url;
|
|
3256
|
+
this.message = error.message;
|
|
3257
|
+
this.param = error.param;
|
|
3258
|
+
this.requestLogUrl = error.request_log_url;
|
|
3259
|
+
this.type = error.type;
|
|
3260
|
+
}
|
|
3261
|
+
}
|
|
3262
|
+
|
|
3263
|
+
const stripeCardElementCss = ":root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}.stripe-payment-sheet-wrap{}.stripe-payment-sheet-wrap *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:\"Roboto\", sans-serif;box-sizing:border-box}.stripe-payment-sheet-wrap button{cursor:pointer}.stripe-payment-sheet-wrap{display:block;width:100%;background:#fff;padding:32px 16px}.stripe-payment-sheet-wrap .StripeElement{padding:8px 16px;min-height:64px;border-bottom:1px solid var(--color-input-border);border-radius:4px;display:flex;justify-content:center;align-items:center}.stripe-payment-sheet-wrap .StripeElement>.__PrivateStripeElement{width:100%}.stripe-payment-sheet-wrap .stripe-input-box{background-color:#fff;border-radius:2px;filter:drop-shadow(0 0 1px var(--color-input-border))}.stripe-payment-sheet-wrap .stripe-input-column .StripeElement{border-right:1px solid var(--color-input-border)}.stripe-payment-sheet-wrap .stripe-input-column .StripeElement:last-child{border-right:none}.stripe-payment-sheet-wrap .stripe-heading{font-size:24px;font-weight:bold;color:var(--color-heading-text);margin-bottom:24px}.stripe-payment-sheet-wrap .stripe-section-title{font-size:14px;font-weight:bold;color:var(--color-label);margin-bottom:8px}.stripe-payment-sheet-wrap .payment-info label{color:var(--color-label)}.stripe-payment-sheet-wrap .stripe-element-errors{margin-top:8px;font-size:14px;color:var(--color-text-error)}.stripe-payment-sheet-wrap button{display:block;color:var(--color-button-text);background-color:var(--color-primary);width:100%;text-align:center;padding:16px 16px;font-size:18px;border-radius:8px;min-height:42px}.stripe-payment-sheet-wrap button:disabled{color:var(--color-button-text-disabled)}";
|
|
3264
|
+
|
|
3265
|
+
const StripeCardElement = class {
|
|
3266
|
+
/**
|
|
3267
|
+
* Get Stripe.js, and initialize elements
|
|
3268
|
+
* @param publishableKey
|
|
3269
|
+
* @param options
|
|
3270
|
+
* @example
|
|
3271
|
+
* ```
|
|
3272
|
+
* const stripeElement = document.createElement('stripe-card-element');
|
|
3273
|
+
* customElements
|
|
3274
|
+
* .whenDefined('stripe-card-element')
|
|
3275
|
+
* .then(() => {
|
|
3276
|
+
* tripeElement.initStripe('pk_test_XXXXXXXXX')
|
|
3277
|
+
* })
|
|
3278
|
+
* ```
|
|
3279
|
+
*/
|
|
3280
|
+
async initStripe(publishableKey, options) {
|
|
3281
|
+
await this.stripeService.initialize(publishableKey, {
|
|
3282
|
+
stripeAccount: options === null || options === void 0 ? void 0 : options.stripeAccount,
|
|
3283
|
+
applicationName: this.applicationName,
|
|
3284
|
+
});
|
|
3285
|
+
// If already successfully loaded, initialize elements immediately
|
|
3286
|
+
if (this.stripeService.state.loadStripeStatus === 'success') {
|
|
3287
|
+
await this.initElement();
|
|
3288
|
+
this.stripeLoadedEventHandler();
|
|
3289
|
+
}
|
|
3290
|
+
else {
|
|
3291
|
+
// Otherwise, wait for successful load
|
|
3292
|
+
const unsubscribe = this.stripeService.onChange('loadStripeStatus', async (newState) => {
|
|
3293
|
+
if (newState !== 'success') {
|
|
3294
|
+
return;
|
|
3295
|
+
}
|
|
3296
|
+
await this.initElement();
|
|
3297
|
+
this.stripeLoadedEventHandler();
|
|
3298
|
+
unsubscribe(); // Clean up listener after first success
|
|
3299
|
+
});
|
|
3300
|
+
}
|
|
3301
|
+
}
|
|
3302
|
+
/**
|
|
3303
|
+
* Update the form submit progress
|
|
3304
|
+
* @param progress
|
|
3305
|
+
* @returns
|
|
3306
|
+
* @example
|
|
3307
|
+
* ```
|
|
3308
|
+
* const stripeElement = document.createElement('stripe-card-element');
|
|
3309
|
+
* customElements
|
|
3310
|
+
* .whenDefined('stripe-card-element')
|
|
3311
|
+
* .then(() => {
|
|
3312
|
+
* // You must set the attributes to stop running default form submit action when you want to listen the 'formSubmit' event.
|
|
3313
|
+
* stripeElement.setAttribute('should-use-default-form-submit-action', false)
|
|
3314
|
+
* stripeElement.addEventListener('formSubmit', async props => {
|
|
3315
|
+
* const {
|
|
3316
|
+
* detail: { stripe, cardNumber, event },
|
|
3317
|
+
* } = props;
|
|
3318
|
+
* const result = await stripe.createPaymentMethod({
|
|
3319
|
+
* type: 'card',
|
|
3320
|
+
* card: cardNumber,
|
|
3321
|
+
* });
|
|
3322
|
+
* console.log(result);
|
|
3323
|
+
* stripeElement.updateProgress('success')
|
|
3324
|
+
* });
|
|
3325
|
+
* })
|
|
3326
|
+
*/
|
|
3327
|
+
async updateProgress(progress) {
|
|
3328
|
+
this.progress = progress;
|
|
3329
|
+
return this;
|
|
3330
|
+
}
|
|
3331
|
+
/**
|
|
3332
|
+
* Set error message
|
|
3333
|
+
* @param errorMessage string
|
|
3334
|
+
* @returns
|
|
3335
|
+
* @example
|
|
3336
|
+
* ```
|
|
3337
|
+
* const stripeElement = document.createElement('stripe-card-element');
|
|
3338
|
+
* customElements
|
|
3339
|
+
* .whenDefined('stripe-card-element')
|
|
3340
|
+
* .then(() => {
|
|
3341
|
+
* // You must set the attributes to stop running default form submit action when you want to listen the 'formSubmit' event.
|
|
3342
|
+
* stripeElement.setAttribute('should-use-default-form-submit-action', false)
|
|
3343
|
+
* stripeElement.addEventListener('formSubmit', async props => {
|
|
3344
|
+
* try {
|
|
3345
|
+
* throw new Error('debug')
|
|
3346
|
+
* } catch (e) {
|
|
3347
|
+
* stripeElement.setErrorMessage(`Error: ${e.message}`)
|
|
3348
|
+
* stripeElement.updateProgress('failure')
|
|
3349
|
+
* }
|
|
3350
|
+
* });
|
|
3351
|
+
* })
|
|
3352
|
+
*/
|
|
3353
|
+
async setErrorMessage(errorMessage) {
|
|
3354
|
+
this.cardElementManager.setError(errorMessage);
|
|
3355
|
+
return this;
|
|
3356
|
+
}
|
|
3357
|
+
updatePublishableKey(publishableKey) {
|
|
3358
|
+
const options = {};
|
|
3359
|
+
options.stripeAccount = this.stripeService.state.stripeAccount;
|
|
3360
|
+
const hasOptionValue = Object.values(options).filter(Boolean).length > 0;
|
|
3361
|
+
this.initStripe(publishableKey, hasOptionValue ? options : undefined);
|
|
3362
|
+
}
|
|
3363
|
+
updateStripeAccountId(stripeAccount) {
|
|
3364
|
+
this.initStripe(this.stripeService.state.publishableKey, {
|
|
3365
|
+
stripeAccount: stripeAccount,
|
|
3366
|
+
});
|
|
3367
|
+
}
|
|
3368
|
+
/**
|
|
3369
|
+
* @param option
|
|
3370
|
+
* @private
|
|
3371
|
+
*/
|
|
3372
|
+
async setPaymentRequestOption(option) {
|
|
3373
|
+
this.paymentRequestOption = option;
|
|
3374
|
+
this.createPaymentRequestButton();
|
|
3375
|
+
return this;
|
|
3376
|
+
}
|
|
3377
|
+
stripeLoadedEventHandler() {
|
|
3378
|
+
const event = {
|
|
3379
|
+
stripe: this.stripeService.getStripe(),
|
|
3380
|
+
};
|
|
3381
|
+
if (this.stripeDidLoaded) {
|
|
3382
|
+
this.stripeDidLoaded(event);
|
|
3383
|
+
}
|
|
3384
|
+
this.stripeLoaded.emit(event);
|
|
3385
|
+
}
|
|
3386
|
+
async formSubmitEventHandler() {
|
|
3387
|
+
const cardElements = this.cardElementManager.getElements();
|
|
3388
|
+
const stripe = this.stripeService.getStripe();
|
|
3389
|
+
if (!cardElements) {
|
|
3390
|
+
console.error('Card elements not initialized');
|
|
3391
|
+
return;
|
|
3392
|
+
}
|
|
3393
|
+
this.formSubmit.emit({
|
|
3394
|
+
cardCVCElement: cardElements.cardCVC,
|
|
3395
|
+
cardExpiryElement: cardElements.cardExpiry,
|
|
3396
|
+
cardNumberElement: cardElements.cardNumber,
|
|
3397
|
+
stripe,
|
|
3398
|
+
});
|
|
3399
|
+
}
|
|
3400
|
+
async defaultFormSubmitResultHandler(result) {
|
|
3401
|
+
this.defaultFormSubmitResult.emit(result);
|
|
3402
|
+
}
|
|
3403
|
+
componentWillUpdate() {
|
|
3404
|
+
if (!this.stripeService.state.publishableKey) {
|
|
3405
|
+
return;
|
|
3406
|
+
}
|
|
3407
|
+
if (['success', 'loading'].includes(this.stripeService.state.loadStripeStatus)) {
|
|
3408
|
+
return;
|
|
3409
|
+
}
|
|
3410
|
+
this.initStripe(this.stripeService.state.publishableKey, {
|
|
3411
|
+
stripeAccount: this.stripeService.state.stripeAccount,
|
|
3412
|
+
});
|
|
3413
|
+
this.createPaymentRequestButton();
|
|
3414
|
+
}
|
|
3415
|
+
/**
|
|
3416
|
+
* Default form submit action (just call a confirmCardPayment).
|
|
3417
|
+
* If you don't want use it, please set `should-use-default-form-submit-action="false"`
|
|
3418
|
+
* @param event
|
|
3419
|
+
* @param param1
|
|
3420
|
+
*/
|
|
3421
|
+
async defaultFormSubmitAction(event, { stripe, cardNumberElement, intentClientSecret }) {
|
|
3422
|
+
event.preventDefault();
|
|
3423
|
+
try {
|
|
3424
|
+
const { intentType } = this;
|
|
3425
|
+
const result = await (() => {
|
|
3426
|
+
if (intentType === 'payment') {
|
|
3427
|
+
return stripe.confirmCardPayment(intentClientSecret, {
|
|
3428
|
+
payment_method: {
|
|
3429
|
+
card: cardNumberElement,
|
|
3430
|
+
},
|
|
3431
|
+
});
|
|
3432
|
+
}
|
|
3433
|
+
return stripe.confirmCardSetup(intentClientSecret, {
|
|
3434
|
+
payment_method: {
|
|
3435
|
+
card: cardNumberElement,
|
|
3436
|
+
},
|
|
3437
|
+
});
|
|
3438
|
+
})();
|
|
3439
|
+
if (result.error) {
|
|
3440
|
+
throw new StripeAPIError(result.error);
|
|
3441
|
+
}
|
|
3442
|
+
this.defaultFormSubmitResultHandler(result);
|
|
3443
|
+
}
|
|
3444
|
+
catch (e) {
|
|
3445
|
+
console.error(e);
|
|
3446
|
+
this.defaultFormSubmitResultHandler(e);
|
|
3447
|
+
throw e;
|
|
3448
|
+
}
|
|
3449
|
+
}
|
|
3450
|
+
constructor(hostRef) {
|
|
3451
|
+
index.registerInstance(this, hostRef);
|
|
3452
|
+
this.stripeLoaded = index.createEvent(this, "stripeLoaded");
|
|
3453
|
+
this.formSubmit = index.createEvent(this, "formSubmit");
|
|
3454
|
+
this.defaultFormSubmitResult = index.createEvent(this, "defaultFormSubmitResult");
|
|
3455
|
+
/**
|
|
3456
|
+
* Default submit handle type.
|
|
3457
|
+
* If you want to use `setupIntent`, should update this attribute.
|
|
3458
|
+
*/
|
|
3459
|
+
this.intentType = 'payment';
|
|
3460
|
+
/**
|
|
3461
|
+
* If true, show zip code field
|
|
3462
|
+
*/
|
|
3463
|
+
this.zip = true;
|
|
3464
|
+
/**
|
|
3465
|
+
* Payment sheet title
|
|
3466
|
+
* By default we recommended to use these string
|
|
3467
|
+
* - 'Add your payment information' -> PaymentSheet / PaymentFlow(Android)
|
|
3468
|
+
* - 'Add a card' -> PaymentFlow(iOS)
|
|
3469
|
+
* These strings will translated automatically by this library.
|
|
3470
|
+
*/
|
|
3471
|
+
this.sheetTitle = 'Add your payment information';
|
|
3472
|
+
/**
|
|
3473
|
+
* Submit button label
|
|
3474
|
+
* By default we recommended to use these string
|
|
3475
|
+
* - 'Pay' -> PaymentSheet
|
|
3476
|
+
* - 'Add' -> PaymentFlow(Android)
|
|
3477
|
+
* - 'Add card' -> PaymentFlow(iOS)
|
|
3478
|
+
* - 'Add a card' -> PaymentFlow(iOS)
|
|
3479
|
+
* These strings will translated automatically by this library.
|
|
3480
|
+
*
|
|
3481
|
+
*/
|
|
3482
|
+
this.buttonLabel = 'Pay';
|
|
3483
|
+
/**
|
|
3484
|
+
* The progress status of the checkout process
|
|
3485
|
+
*/
|
|
3486
|
+
this.progress = '';
|
|
3487
|
+
/**
|
|
3488
|
+
* zip code
|
|
3489
|
+
*/
|
|
3490
|
+
this.zipCode = '';
|
|
3491
|
+
/**
|
|
3492
|
+
* Overwrite the application name that registered
|
|
3493
|
+
* For wrapper library (like Capacitor)
|
|
3494
|
+
*/
|
|
3495
|
+
this.applicationName = 'stripe-pwa-elements';
|
|
3496
|
+
/**
|
|
3497
|
+
* Show the form label
|
|
3498
|
+
*/
|
|
3499
|
+
this.showLabel = false;
|
|
3500
|
+
/**
|
|
3501
|
+
* The component will provide a function to call the `stripe.confirmCardPayment`API.
|
|
3502
|
+
* If you want to customize the behavior, should set false.
|
|
3503
|
+
* And listen the 'formSubmit' event on the element
|
|
3504
|
+
*/
|
|
3505
|
+
this.shouldUseDefaultFormSubmitAction = true;
|
|
3506
|
+
// Dependency Injection via factory
|
|
3507
|
+
this.stripeService = serviceFactory.createStripeService();
|
|
3508
|
+
this.cardElementManager = serviceFactory.createCardElementManager(this.stripeService);
|
|
3509
|
+
if (this.publishableKey) {
|
|
3510
|
+
this.initStripe(this.publishableKey, {
|
|
3511
|
+
stripeAccount: this.stripeAccount,
|
|
3512
|
+
});
|
|
3513
|
+
}
|
|
3514
|
+
}
|
|
3515
|
+
/**
|
|
3516
|
+
* Initialize Component using Stripe Element
|
|
3517
|
+
*/
|
|
3518
|
+
async initElement() {
|
|
3519
|
+
// Initialize card elements
|
|
3520
|
+
await this.cardElementManager.initialize(this.el);
|
|
3521
|
+
// Add form submit listener scoped to this component instance
|
|
3522
|
+
const formElement = this.el.querySelector('#stripe-card-element');
|
|
3523
|
+
if (!formElement) {
|
|
3524
|
+
console.error('Form element #stripe-card-element not found');
|
|
3525
|
+
return;
|
|
3526
|
+
}
|
|
3527
|
+
formElement.addEventListener('submit', async (e) => {
|
|
3528
|
+
const cardElements = this.cardElementManager.getElements();
|
|
3529
|
+
const stripe = this.stripeService.getStripe();
|
|
3530
|
+
const { intentClientSecret } = this;
|
|
3531
|
+
if (!cardElements || !stripe) {
|
|
3532
|
+
console.error('Stripe not properly initialized');
|
|
3533
|
+
return;
|
|
3534
|
+
}
|
|
3535
|
+
const submitEventProps = {
|
|
3536
|
+
cardCVCElement: cardElements.cardCVC,
|
|
3537
|
+
cardExpiryElement: cardElements.cardExpiry,
|
|
3538
|
+
cardNumberElement: cardElements.cardNumber,
|
|
3539
|
+
stripe,
|
|
3540
|
+
intentClientSecret,
|
|
3541
|
+
zipCode: this.zipCode,
|
|
3542
|
+
};
|
|
3543
|
+
this.progress = 'loading';
|
|
3544
|
+
try {
|
|
3545
|
+
if (this.handleSubmit) {
|
|
3546
|
+
await this.handleSubmit(e, submitEventProps);
|
|
3547
|
+
}
|
|
3548
|
+
else if (this.shouldUseDefaultFormSubmitAction === true && intentClientSecret) {
|
|
3549
|
+
await this.defaultFormSubmitAction(e, submitEventProps);
|
|
3550
|
+
}
|
|
3551
|
+
else {
|
|
3552
|
+
e.preventDefault();
|
|
3553
|
+
}
|
|
3554
|
+
await this.formSubmitEventHandler();
|
|
3555
|
+
if (this.handleSubmit || this.shouldUseDefaultFormSubmitAction === true) {
|
|
3556
|
+
this.progress = 'success';
|
|
3557
|
+
}
|
|
3558
|
+
}
|
|
3559
|
+
catch (e) {
|
|
3560
|
+
this.cardElementManager.setError(e.message);
|
|
3561
|
+
this.progress = 'failure';
|
|
3562
|
+
}
|
|
3563
|
+
});
|
|
3564
|
+
}
|
|
3565
|
+
componentDidLoad() {
|
|
3566
|
+
this.el.classList.add(checkPlatform());
|
|
3567
|
+
}
|
|
3568
|
+
disconnectedCallback() {
|
|
3569
|
+
this.cardElementManager.unmount();
|
|
3570
|
+
}
|
|
3571
|
+
/**
|
|
3572
|
+
* Create payment request button
|
|
3573
|
+
* It's just proxy of stripe-payment-request-button
|
|
3574
|
+
*/
|
|
3575
|
+
createPaymentRequestButton() {
|
|
3576
|
+
const { showPaymentRequestButton, paymentRequestOption } = this;
|
|
3577
|
+
if (!showPaymentRequestButton || !paymentRequestOption) {
|
|
3578
|
+
return null;
|
|
3579
|
+
}
|
|
3580
|
+
if (!document) {
|
|
3581
|
+
return null;
|
|
3582
|
+
}
|
|
3583
|
+
const targetElement = this.el.querySelector('#stripe-payment-request-button');
|
|
3584
|
+
if (!targetElement) {
|
|
3585
|
+
console.error('Target element #stripe-payment-request-button not found');
|
|
3586
|
+
return null;
|
|
3587
|
+
}
|
|
3588
|
+
const stripePaymentRequestElement = document.createElement('stripe-payment-request-button');
|
|
3589
|
+
targetElement.appendChild(stripePaymentRequestElement);
|
|
3590
|
+
const { paymentRequestPaymentMethodHandler, paymentRequestShippingOptionChangeHandler, paymentRequestShippingAddressChangeHandler } = paymentRequestOption;
|
|
3591
|
+
customElements.whenDefined('stripe-payment-request-button').then(() => {
|
|
3592
|
+
stripePaymentRequestElement.setPaymentRequestOption(paymentRequestOption);
|
|
3593
|
+
if (paymentRequestPaymentMethodHandler) {
|
|
3594
|
+
stripePaymentRequestElement.setPaymentMethodEventHandler(paymentRequestPaymentMethodHandler);
|
|
3595
|
+
}
|
|
3596
|
+
if (paymentRequestShippingOptionChangeHandler) {
|
|
3597
|
+
stripePaymentRequestElement.setPaymentRequestShippingOptionEventHandler(paymentRequestShippingOptionChangeHandler);
|
|
3598
|
+
}
|
|
3599
|
+
if (paymentRequestShippingAddressChangeHandler) {
|
|
3600
|
+
stripePaymentRequestElement.setPaymentRequestShippingAddressEventHandler(paymentRequestShippingAddressChangeHandler);
|
|
3601
|
+
}
|
|
3602
|
+
return stripePaymentRequestElement.initStripe(this.publishableKey);
|
|
3603
|
+
});
|
|
3604
|
+
}
|
|
3605
|
+
render() {
|
|
3606
|
+
const { loadStripeStatus } = this.stripeService.state;
|
|
3607
|
+
const { errorMessage } = this.cardElementManager.getState();
|
|
3608
|
+
if (loadStripeStatus === 'failure') {
|
|
3609
|
+
return index.h("p", null, i18n.t('Failed to load Stripe'));
|
|
3610
|
+
}
|
|
3611
|
+
const disabled = this.progress === 'loading';
|
|
3612
|
+
return (index.h("div", { class: "stripe-payment-sheet-wrap" }, index.h("form", { id: "stripe-card-element" }, index.h("div", { class: "stripe-heading" }, i18n.t(this.sheetTitle)), index.h("div", { id: "stripe-payment-request-button" }), index.h("div", null, index.h("div", { class: "stripe-section-title" }, i18n.t('Card information'))), index.h("div", { class: "payment-info card visible" }, index.h("fieldset", { class: "stripe-input-box" }, index.h("div", null, index.h("label", null, this.showLabel ? index.h("lenged", null, i18n.t('Card Number')) : null, index.h("div", { id: "card-number" }))), index.h("div", { class: "stripe-input-column", style: { display: 'flex' } }, index.h("label", { style: { width: '50%' } }, this.showLabel ? index.h("lenged", null, i18n.t('MM / YY')) : null, index.h("div", { id: "card-expiry" })), index.h("label", { style: { width: '50%' } }, this.showLabel ? index.h("lenged", null, i18n.t('CVC')) : null, index.h("div", { id: "card-cvc" }))))), index.h("div", { id: "card-errors", class: "stripe-element-errors" }, errorMessage), this.zip ? (index.h("div", { style: { marginTop: '1.5rem' } }, index.h("div", { class: "stripe-section-title" }, i18n.t('Country or region')))) : null, this.zip ? (index.h("div", { class: "payment-info card visible" }, index.h("fieldset", { class: "stripe-input-box" }, index.h("div", null, index.h("label", null, this.showLabel ? index.h("lenged", null, i18n.t('Postal Code')) : null, index.h("input", { id: "zip", name: "zip", type: "text", inputmode: "numeric", class: "stripe-input-box StripeElement", style: { width: '100%' }, placeholder: i18n.t('Postal Code'), value: this.zipCode, onInput: e => {
|
|
3613
|
+
this.zipCode = e.target.value;
|
|
3614
|
+
} })))))) : null, index.h("div", { style: { marginTop: '32px' } }, index.h("button", { type: "submit", disabled: disabled }, this.progress === 'loading' ? i18n.t('Loading') : i18n.t(this.buttonLabel))))));
|
|
3615
|
+
}
|
|
3616
|
+
get el() { return index.getElement(this); }
|
|
3617
|
+
static get watchers() { return {
|
|
3618
|
+
"publishableKey": ["updatePublishableKey"],
|
|
3619
|
+
"stripeAccount": ["updateStripeAccountId"]
|
|
3620
|
+
}; }
|
|
3621
|
+
};
|
|
3622
|
+
StripeCardElement.style = stripeCardElementCss;
|
|
3623
|
+
|
|
3624
|
+
const stripeModalCss = "*:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:\"Roboto\", sans-serif;box-sizing:border-box}button{cursor:pointer}:root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}:host{display:block}.modal-row{display:none}.modal-row.open{position:fixed;top:0;left:0;width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;gap:1ch;background:rgba(0, 0, 0, 0.3)}.modal-child{padding:1.5rem;background-color:#fff;width:100%}.modal-close-button-wrap{padding-left:8px}.modal-close-button-wrap .modal-close-button{width:32px;display:block;fill:var(--color-label);cursor:pointer}";
|
|
3625
|
+
|
|
3626
|
+
const StripeModal = class {
|
|
3627
|
+
constructor(hostRef) {
|
|
3628
|
+
index.registerInstance(this, hostRef);
|
|
3629
|
+
this.close = index.createEvent(this, "close");
|
|
3630
|
+
/**
|
|
3631
|
+
* If true, the modal display close button
|
|
3632
|
+
*/
|
|
3633
|
+
this.showCloseButton = true;
|
|
3634
|
+
/**
|
|
3635
|
+
* Modal state.
|
|
3636
|
+
* If true, the modal will open
|
|
3637
|
+
*/
|
|
3638
|
+
this.open = false;
|
|
3639
|
+
}
|
|
3640
|
+
/**
|
|
3641
|
+
* Toggle modal state
|
|
3642
|
+
*/
|
|
3643
|
+
async toggleModal() {
|
|
3644
|
+
this.open = !this.open;
|
|
3645
|
+
if (this.open === false) {
|
|
3646
|
+
this.close.emit();
|
|
3647
|
+
}
|
|
3648
|
+
}
|
|
3649
|
+
/**
|
|
3650
|
+
* Open the modal
|
|
3651
|
+
*/
|
|
3652
|
+
async openModal() {
|
|
3653
|
+
this.open = true;
|
|
3654
|
+
}
|
|
3655
|
+
/**
|
|
3656
|
+
* Close the modal
|
|
3657
|
+
*/
|
|
3658
|
+
async closeModal() {
|
|
3659
|
+
this.open = false;
|
|
3660
|
+
this.close.emit();
|
|
3661
|
+
}
|
|
3662
|
+
componentDidLoad() {
|
|
3663
|
+
const platformName = checkPlatform();
|
|
3664
|
+
if (platformName)
|
|
3665
|
+
this.el.classList.add(platformName);
|
|
3666
|
+
}
|
|
3667
|
+
render() {
|
|
3668
|
+
const { open, showCloseButton } = this;
|
|
3669
|
+
return (index.h(index.Host, { key: '9546b5a9b619977c8040aa2f249d40f8be3f781f' }, index.h("div", { key: '7a8aa0e76c1887f8233dab951e601970a3479a3a', class: `modal-row${open ? ' open' : ''}`, onClick: () => this.closeModal() }, index.h("div", { key: '857748624c7a151fb24aa1f895a247fde51337b6', class: "modal-child", onClick: e => e.stopPropagation() }, showCloseButton ? (index.h("div", { class: "modal-close-button-wrap" }, index.h("ion-icon", { name: "close", size: "large", class: "modal-close-button", onClick: () => this.closeModal() }))) : null, index.h("slot", { key: '72e8d7f32992a47a8c77f704b331f1e445f66054' })))));
|
|
3670
|
+
}
|
|
3671
|
+
get el() { return index.getElement(this); }
|
|
3672
|
+
};
|
|
3673
|
+
StripeModal.style = stripeModalCss;
|
|
3674
|
+
|
|
3675
|
+
exports.stripe_card_element = StripeCardElement;
|
|
3676
|
+
exports.stripe_modal = StripeModal;
|
|
3677
|
+
//# sourceMappingURL=stripe-card-element.stripe-modal.entry.cjs.js.map
|