@ozdao/prometheus-framework 0.2.80 → 0.2.82
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/auth.server.js +1 -1
- package/dist/auth.server.mjs +1 -1
- package/dist/community.server.js +3 -3
- package/dist/community.server.mjs +3 -3
- package/dist/credentials.schema-CDZCKfEI.mjs +106 -0
- package/dist/credentials.schema-CfhPcsuI.js +105 -0
- package/dist/events.server.js +4 -15
- package/dist/events.server.mjs +3 -14
- package/dist/files.server.js +1 -1
- package/dist/files.server.mjs +1 -1
- package/dist/gallery.server.js +1 -1
- package/dist/gallery.server.mjs +1 -1
- package/dist/index-B6a1mPgp.mjs +217 -0
- package/dist/index-BCCiEK_u.js +216 -0
- package/dist/main-8N2Jmsuk.js +91 -0
- package/dist/main-CkeuHuCY.mjs +13619 -0
- package/dist/main.css +1 -1
- package/dist/metadata.schema-Cu_mPkjE.js +77 -0
- package/dist/metadata.schema-cbFgazeK.mjs +78 -0
- package/dist/middlewares.server.js +1 -1
- package/dist/middlewares.server.mjs +1 -1
- package/dist/node_modules/@googlemaps/js-api-loader/dist/index.cjs +1 -0
- package/dist/node_modules/@googlemaps/js-api-loader/dist/index.js +238 -0
- package/dist/organizations.server.js +297 -134
- package/dist/organizations.server.mjs +295 -132
- package/dist/products.server.js +2 -2
- package/dist/products.server.mjs +2 -2
- package/dist/prometheus-framework/src/components/Address/Address.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Address/Address.vue2.js +33 -24
- package/dist/prometheus-framework/src/components/Block/Block.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Block/Block.vue.js +23 -20
- package/dist/prometheus-framework/src/components/Button/Button.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Button/Button.vue2.js +32 -155
- package/dist/prometheus-framework/src/components/Dropdown/Dropdown.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Dropdown/Dropdown.vue.js +55 -1
- package/dist/prometheus-framework/src/components/Dropdown/Dropdown.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Dropdown/Dropdown.vue2.js +1 -55
- package/dist/prometheus-framework/src/components/Feed/Feed.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Feed/Feed.vue.js +71 -60
- package/dist/prometheus-framework/src/components/FieldPhone/FieldPhone.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/FieldPhone/FieldPhone.vue.js +325 -340
- package/dist/prometheus-framework/src/components/FieldPhone/FieldPhone2.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/FieldPhone/FieldPhone2.vue.js +2 -2
- package/dist/prometheus-framework/src/components/LocationMarker/LocationMarker.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/LocationMarker/LocationMarker.vue2.js +53 -44
- package/dist/prometheus-framework/src/components/Popup/Popup.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Popup/Popup.vue.js +1 -72
- package/dist/prometheus-framework/src/components/Popup/Popup.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Popup/Popup.vue2.js +73 -1
- package/dist/prometheus-framework/src/components/Select/Select.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Select/Select.vue.js +1 -97
- package/dist/prometheus-framework/src/components/Select/Select.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Select/Select.vue2.js +103 -1
- package/dist/prometheus-framework/src/components/Slider/Slider.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Slider/Slider.vue.js +18 -19
- package/dist/prometheus-framework/src/components/Tooltip/Tooltip.vue.cjs +1 -1
- package/dist/prometheus-framework/src/components/Tooltip/Tooltip.vue.js +45 -1
- package/dist/prometheus-framework/src/components/Tooltip/Tooltip.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/components/Tooltip/Tooltip.vue2.js +1 -45
- package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.js +28 -28
- package/dist/prometheus-framework/src/modules/auth/store/auth.cjs +1 -1
- package/dist/prometheus-framework/src/modules/auth/store/auth.js +26 -26
- package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.js +78 -103
- package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.js +14 -14
- package/dist/prometheus-framework/src/modules/events/components/blocks/CardEvent.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/blocks/CardEvent.vue.js +4 -4
- package/dist/prometheus-framework/src/modules/events/components/elements/ButtonCheck.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/elements/ButtonCheck.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/events/components/layouts/layoutEvents.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/layouts/layoutEvents.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/events/components/pages/Event.vue.cjs +3 -3
- package/dist/prometheus-framework/src/modules/events/components/pages/Event.vue.js +132 -141
- package/dist/prometheus-framework/src/modules/events/components/pages/Events.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/pages/Events.vue.js +29 -27
- package/dist/prometheus-framework/src/modules/events/components/sections/HeroEvent.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/events/components/sections/HeroEvent.vue.js +4 -4
- package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/gallery/components/sections/GalleryWithCategories.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/gallery/components/sections/GalleryWithCategories.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/globals/components/sections/SectionPageTitle.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/globals/components/sections/SectionPageTitle.vue.js +32 -25
- package/dist/prometheus-framework/src/modules/globals/localization/vue-i18n.cjs +1 -1
- package/dist/prometheus-framework/src/modules/globals/localization/vue-i18n.js +6 -3
- package/dist/prometheus-framework/src/modules/globals/services/globals.store.cjs +1 -0
- package/dist/prometheus-framework/src/modules/globals/services/globals.store.js +70 -0
- package/dist/prometheus-framework/src/modules/icons/entities/IconGallery.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/icons/entities/IconGallery.vue.js +28 -0
- package/dist/prometheus-framework/src/modules/icons/entities/IconLeftovers.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/icons/entities/IconLeftovers.vue.js +30 -0
- package/dist/prometheus-framework/src/modules/icons/entities/IconOrders.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/icons/entities/IconOrders.vue.js +35 -0
- package/dist/prometheus-framework/src/modules/icons/entities/IconProducts.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/icons/entities/IconProducts.vue.js +28 -0
- package/dist/prometheus-framework/src/modules/landing/components/sections/MobileApp.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/landing/components/sections/MobileApp.vue.js +63 -86
- package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue.js +1 -13
- package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue2.cjs +1 -1
- package/dist/prometheus-framework/src/modules/mobile/components/Menu/Menu.vue2.js +13 -1
- package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.js +174 -114
- package/dist/prometheus-framework/src/modules/orders/components/pages/Orders.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/pages/Orders.vue.js +39 -39
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.js +141 -0
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormClientDetails.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormClientDetails.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormCustomerDetails.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormCustomerDetails.vue.js +77 -0
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormDelivery.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormDelivery.vue.js +46 -35
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormPayment.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/components/sections/FormPayment.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/orders/store/customers.store.cjs +1 -0
- package/dist/prometheus-framework/src/modules/orders/store/customers.store.js +5 -0
- package/dist/prometheus-framework/src/modules/orders/store/models/customer.cjs +1 -0
- package/dist/prometheus-framework/src/modules/orders/store/models/customer.js +30 -0
- package/dist/prometheus-framework/src/modules/orders/store/orders.cjs +1 -1
- package/dist/prometheus-framework/src/modules/orders/store/orders.js +24 -25
- package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardDepartment.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardDepartment.vue.js +16 -16
- package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.js +39 -50
- package/dist/prometheus-framework/src/modules/organizations/components/pages/Department.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/Department.vue.js +6 -6
- package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.js +161 -138
- package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.js +199 -79
- package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.js +83 -126
- package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.js +59 -70
- package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.js +3 -3
- package/dist/prometheus-framework/src/modules/organizations/organizations.client.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/organizations.client.js +34 -36
- package/dist/prometheus-framework/src/modules/organizations/store/departments.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/store/departments.js +38 -18
- package/dist/prometheus-framework/src/modules/organizations/store/invites.cjs +1 -1
- package/dist/prometheus-framework/src/modules/organizations/store/invites.js +34 -35
- package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/products/components/blocks/CardProduct.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/blocks/CardProduct.vue.js +41 -21
- package/dist/prometheus-framework/src/modules/products/components/blocks/ImagesThumbnails.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/blocks/ImagesThumbnails.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/Products.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/pages/Products.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.js +1 -1
- package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.js +24 -26
- package/dist/prometheus-framework/src/modules/users/components/blocks/CardUser.vue.cjs +1 -0
- package/dist/prometheus-framework/src/modules/users/components/blocks/CardUser.vue.js +78 -0
- package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.js +2 -2
- package/dist/prometheus-framework/src/modules/users/store/users.cjs +1 -1
- package/dist/prometheus-framework/src/modules/users/store/users.js +13 -14
- package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.cjs +1 -1
- package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.js +4 -4
- package/dist/prometheus-framework.cjs.js +1 -1
- package/dist/prometheus-framework.es.js +1 -1
- package/dist/queryProcessor-BJdKh0Ow.mjs +162 -0
- package/dist/queryProcessor-DRMo_GWK.js +161 -0
- package/dist/reports.server.js +1 -1
- package/dist/reports.server.mjs +1 -1
- package/dist/style.css +1 -1
- package/dist/users.server.js +69 -38
- package/dist/users.server.mjs +67 -36
- package/dist/wallet.server.js +2 -2
- package/dist/wallet.server.mjs +2 -2
- package/dist/web-CtVocufd.js +1 -0
- package/dist/web-DNq1tHCE.mjs +54 -0
- package/package.json +1 -1
- package/src/components/Address/Address.vue +13 -2
- package/src/components/Block/Block.vue +3 -2
- package/src/components/Button/Button.vue +9 -12
- package/src/components/Feed/Feed.vue +28 -6
- package/src/components/FieldPhone/FieldPhone.vue +592 -558
- package/src/components/LocationMarker/LocationMarker.vue +26 -22
- package/src/components/Popup/Popup.vue +22 -23
- package/src/components/Select/Select.vue +43 -32
- package/src/components/Slider/Slider.vue +3 -4
- package/src/modules/auth/components/pages/Invite.vue +7 -7
- package/src/modules/auth/store/auth.js +1 -1
- package/src/modules/backoffice/components/pages/Dashboard.vue +44 -29
- package/src/modules/community/components/sections/HotPosts.vue +1 -1
- package/src/modules/events/components/blocks/CardEvent.vue +4 -3
- package/src/modules/events/components/pages/Event.vue +4 -3
- package/src/modules/events/components/pages/Events.vue +23 -6
- package/src/modules/events/components/sections/HeroEvent.vue +1 -1
- package/src/modules/globals/components/sections/SectionPageTitle.vue +19 -7
- package/src/modules/globals/controllers/utils/queryProcessor.js +21 -7
- package/src/modules/globals/localization/vue-i18n.js +3 -0
- package/src/modules/globals/models/credentials.schema.js +7 -0
- package/src/modules/globals/models/metadata.schema.js +17 -0
- package/src/modules/globals/models/profile.schema.js +23 -0
- package/src/modules/globals/models/socials.schema.js +22 -0
- package/src/modules/globals/router/routerGuards.js +1 -0
- package/src/modules/globals/services/globals.cashe.js +26 -0
- package/src/modules/globals/services/globals.crud.js +115 -0
- package/src/modules/globals/services/globals.logger.js +41 -0
- package/src/modules/globals/services/globals.store.js +114 -0
- package/src/modules/icons/entities/IconGallery.vue +14 -0
- package/src/modules/icons/entities/IconLeftovers.vue +14 -0
- package/src/modules/icons/entities/IconOrders.vue +15 -0
- package/src/modules/icons/entities/IconProducts.vue +14 -0
- package/src/modules/landing/components/sections/HeroSection.vue +1 -1
- package/src/modules/landing/components/sections/MobileApp.vue +4 -4
- package/src/modules/landing/router/landing.js +1 -1
- package/src/modules/marketplace/components/sections/Filters.vue +3 -3
- package/src/modules/middlewares/server/accessors/AccessController.js +33 -0
- package/src/modules/middlewares/server/accessors/ReadDepartments.js +101 -0
- package/src/modules/middlewares/server/verifyAccesses.js +33 -0
- package/src/modules/middlewares/server/verifyInvites.js +4 -4
- package/src/modules/orders/components/pages/OrderCreate.vue +2 -2
- package/src/modules/orders/components/pages/OrderCreateBackoffice.vue +105 -68
- package/src/modules/orders/components/pages/Orders.vue +2 -2
- package/src/modules/orders/components/sections/FormAddCustomer.vue +152 -0
- package/src/modules/orders/components/sections/FormCustomerDetails.vue +67 -0
- package/src/modules/orders/components/sections/FormDelivery.vue +17 -3
- package/src/modules/orders/controllers/applications.controller.js +2 -0
- package/src/modules/orders/controllers/orders.controller.js +77 -52
- package/src/modules/orders/models/customer.model.js +54 -18
- package/src/modules/orders/models/order.model.js +1 -1
- package/src/modules/orders/orders.client.js +51 -51
- package/src/modules/orders/orders.server.js +32 -12
- package/src/modules/orders/router/orders.router.js +36 -41
- package/src/modules/orders/routes/orders.routes.js +3 -21
- package/src/modules/orders/store/customers.store.js +5 -0
- package/src/modules/orders/store/models/customer.js +29 -0
- package/src/modules/orders/store/orders.js +14 -20
- package/src/modules/organizations/components/blocks/CardDepartment.vue +3 -3
- package/src/modules/organizations/components/blocks/CardOrganization.vue +1 -1
- package/src/modules/organizations/components/blocks/DepartmentMemberModify.vue +1 -12
- package/src/modules/organizations/components/pages/Department.vue +1 -1
- package/src/modules/organizations/components/pages/DepartmentEdit.vue +72 -48
- package/src/modules/organizations/components/pages/Members.vue +178 -64
- package/src/modules/organizations/components/pages/Organization.vue +1 -41
- package/src/modules/organizations/components/sections/MembersAdd.vue +44 -52
- package/src/modules/organizations/controllers/departments.controller.js +2 -4
- package/src/modules/organizations/controllers/invites.controller.js +24 -23
- package/src/modules/organizations/controllers/organizations.controller.js +1 -1
- package/src/modules/organizations/models/department.model.js +52 -2
- package/src/modules/organizations/models/invite.model.js +29 -32
- package/src/modules/organizations/models/membership.model.js +2 -0
- package/src/modules/organizations/models/organization.model.js +2 -1
- package/src/modules/organizations/organizations.client.js +0 -2
- package/src/modules/organizations/routes/departments.routes.js +18 -7
- package/src/modules/organizations/routes/invites.routes.js +2 -2
- package/src/modules/organizations/store/departments.js +22 -1
- package/src/modules/organizations/store/invites.js +74 -90
- package/src/modules/products/components/blocks/CardProduct.vue +24 -0
- package/src/modules/products/components/pages/Products.vue +1 -1
- package/src/modules/reports/components/sections/FormReport.vue +40 -40
- package/src/modules/spots/components/pages/Spot.vue +1 -1
- package/src/modules/spots/components/pages/SpotEdit.vue +1 -1
- package/src/modules/users/components/blocks/CardUser.vue +85 -0
- package/src/modules/users/controllers/users.controller.js +36 -13
- package/src/modules/users/middlewares/visitor.logger.js +66 -0
- package/src/modules/users/models/request.model.js +18 -0
- package/src/modules/users/models/user.model.js +26 -55
- package/src/modules/users/models/visitor.model.js +14 -0
- package/src/modules/users/store/users.js +2 -11
- package/src/modules/wallet/controllers/routes/payments.routes.js +2 -0
- package/src/components/FieldPhone/FieldPhone(script-setup).vue +0 -1646
- package/src/components/FieldPhone/FieldPhone2.vue +0 -671
- package/src/modules/orders/components/sections/FormClientDetails.vue +0 -61
- package/src/modules/organizations/components/blocks/User.vue +0 -69
- /package/src/modules/backoffice/components/admin/{User.vue → UserEdit.vue} +0 -0
@@ -1,508 +1,31 @@
|
|
1
|
-
<script>
|
2
|
-
import { defineComponent } from 'vue';
|
3
|
-
import { parsePhoneNumberFromString } from 'libphonenumber-js';
|
4
|
-
|
5
|
-
import utils, { getCountry, setCaretPosition } from './utils';
|
6
|
-
|
7
|
-
import clickOutside from './click-outside';
|
8
|
-
|
9
|
-
function getDefault(key) {
|
10
|
-
const value = utils.options[key];
|
11
|
-
if (typeof value === 'undefined') {
|
12
|
-
return utils.options[key];
|
13
|
-
}
|
14
|
-
return value;
|
15
|
-
}
|
16
|
-
|
17
|
-
export default /*#__PURE__*/defineComponent({
|
18
|
-
name: 'Vue3ReactiveTelInput',
|
19
|
-
directives: {
|
20
|
-
clickOutside,
|
21
|
-
},
|
22
|
-
props: {
|
23
|
-
modelValue: { type: String, default: '',},
|
24
|
-
badClass: { type: [String, Array, Object], default: '', },
|
25
|
-
goodClass: { type: [String, Array, Object], default: '', },
|
26
|
-
badStyle: { type: [String, Array, Object], default: '', },
|
27
|
-
goodStyle: { type: [String, Array, Object], default: '', },
|
28
|
-
badInputClass: { type: [String, Array, Object], default: '', },
|
29
|
-
goodInputClass: { type: [String, Array, Object], default: '', },
|
30
|
-
badInputStyle: { type: [String, Array, Object], default: '', },
|
31
|
-
goodInputStyle: { type: [String, Array, Object], default: '', },
|
32
|
-
allCountries: { type: Array, default: () => getDefault('allCountries'), },
|
33
|
-
autoFormat: { type: Boolean, default: () => getDefault('autoFormat'), },
|
34
|
-
validation: { type: [Boolean, Object], default: false, },
|
35
|
-
customValidate: { type: [Boolean, RegExp], default: () => getDefault('customValidate'), },
|
36
|
-
defaultCountry: { type: String, default: () => getDefault('defaultCountry'), },
|
37
|
-
disabled: { type: Boolean, default: () => getDefault('disabled'), },
|
38
|
-
autoDefaultCountry: { type: Boolean, default: () => getDefault('autoDefaultCountry'), },
|
39
|
-
dropdownOptions: { type: Object, default: () => getDefault('dropdownOptions'), },
|
40
|
-
ignoredCountries: { type: Array, default: () => getDefault('ignoredCountries'), },
|
41
|
-
inputOptions: { type: Object, default: () => getDefault('inputOptions'), },
|
42
|
-
invalidMsg: { type: String, default: () => getDefault('invalidMsg'), },
|
43
|
-
mode: { type: String, default: () => getDefault('mode'), },
|
44
|
-
onlyCountries: { type: Array, default: () => getDefault('onlyCountries'), },
|
45
|
-
preferredCountries: { type: Array, default: () => getDefault('preferredCountries'), },
|
46
|
-
validCharactersOnly: { type: Boolean, default: () => getDefault('validCharactersOnly'), },
|
47
|
-
rootClass: { type: [String, Array, Object], default: () => getDefault('styleClasses'), },
|
48
|
-
inputClass: { type: [String, Array, Object], default: () => {return ''}, },
|
49
|
-
divInputClass: { type: [String, Array, Object], default: () => {return ''}, },
|
50
|
-
rootStyle: { type: [String, Array, Object], default: () => {return ''}, },
|
51
|
-
dropdownStyle: { type: [String, Array, Object], default: () => {return ''}, },
|
52
|
-
listStyle: { type: [String, Array, Object], default: () => {return ''}, },
|
53
|
-
inputStyle: { type: [String, Array, Object], default: () => {return ''}, },
|
54
|
-
inputId: { type: [String, Array, Object], default: () => {return ''}, },
|
55
|
-
Placeholder: { type: [String, Object, Function], default: () => {return ''}, },
|
56
|
-
},
|
57
|
-
data() {
|
58
|
-
return {
|
59
|
-
counter: 5,
|
60
|
-
initCounter: 5,
|
61
|
-
message: {
|
62
|
-
action: null,
|
63
|
-
amount: null,
|
64
|
-
},
|
65
|
-
phone: this.modelValue ? this.modelValue : '',
|
66
|
-
activeCountryCode: '',
|
67
|
-
open: false,
|
68
|
-
finishMounted: false,
|
69
|
-
selectedIndex: null,
|
70
|
-
typeToFindInput: '',
|
71
|
-
typeToFindTimer: null,
|
72
|
-
dropdownOpenDirection: 'below',
|
73
|
-
parsedPlaceholder: this.Placeholder !== '' ? this.Placeholder : this.inputOptions.placeholder,
|
74
|
-
};
|
75
|
-
},
|
76
|
-
watch: {
|
77
|
-
activeCountry(value, oldValue) {
|
78
|
-
if (!value && oldValue?.iso2) {
|
79
|
-
this.activeCountryCode = oldValue.iso2;
|
80
|
-
return;
|
81
|
-
}
|
82
|
-
if (value?.iso2) {
|
83
|
-
this.$emit('country-changed', value);
|
84
|
-
// this.resetPlaceholder();
|
85
|
-
}
|
86
|
-
},
|
87
|
-
'phoneObject.countryCode': function (value) {
|
88
|
-
this.activeCountryCode = value;
|
89
|
-
},
|
90
|
-
'phoneObject.valid': function () {
|
91
|
-
this.$emit('validate', this.phoneObject);
|
92
|
-
},
|
93
|
-
'phoneObject.formatted': function (value) {
|
94
|
-
if (!this.autoFormat || this.customValidate) {
|
95
|
-
return;
|
96
|
-
}
|
97
|
-
this.emitInput(value);
|
98
|
-
|
99
|
-
this.$nextTick(() => {
|
100
|
-
// In case `v-model` is not set, we need to update the `phone` to be new formatted value
|
101
|
-
if (value && !this.value) {
|
102
|
-
this.phone = value;
|
103
|
-
}
|
104
|
-
});
|
105
|
-
},
|
106
|
-
// finishMounted() {
|
107
|
-
// this.resetPlaceholder();
|
108
|
-
// },
|
109
|
-
'inputOptions.placeholder': function () {
|
110
|
-
this.resetPlaceholder();
|
111
|
-
},
|
112
|
-
value(value, oldValue) {
|
113
|
-
// console.log(this.phoneObject?this.phoneObject.number !== "":false)
|
114
|
-
if (!this.testCharacters()) {
|
115
|
-
// console.log(this.phoneObject?this.phoneObject.number !== "":false)
|
116
|
-
this.$nextTick(() => { this.phone = oldValue; this.onInput(); });
|
117
|
-
} else {
|
118
|
-
this.phone = value;
|
119
|
-
}
|
120
|
-
},
|
121
|
-
open(isDropdownOpened) {
|
122
|
-
// Emit open and close events
|
123
|
-
if (isDropdownOpened) {
|
124
|
-
this.setDropdownPosition();
|
125
|
-
this.$emit('open');
|
126
|
-
} else {
|
127
|
-
this.$emit('close');
|
128
|
-
}
|
129
|
-
},
|
130
|
-
},
|
131
|
-
mounted() {
|
132
|
-
if (this.value) {
|
133
|
-
this.phone = this.value;
|
134
|
-
}
|
135
|
-
|
136
|
-
this.cleanInvalidCharacters();
|
137
|
-
|
138
|
-
this.initializeCountry()
|
139
|
-
.then(() => {
|
140
|
-
if (!this.phone
|
141
|
-
&& this.inputOptions?.showDialCode
|
142
|
-
&& this.activeCountryCode) {
|
143
|
-
this.phone = `+${this.activeCountryCode}`;
|
144
|
-
}
|
145
|
-
this.$emit('validate', this.phoneObject);
|
146
|
-
})
|
147
|
-
.catch(console.error)
|
148
|
-
.then(() => {
|
149
|
-
this.finishMounted = true;
|
150
|
-
});
|
151
|
-
},
|
152
|
-
computed: {
|
153
|
-
activeCountry() {
|
154
|
-
return this.findCountry(this.activeCountryCode);
|
155
|
-
},
|
156
|
-
activeCountryFlag() {
|
157
|
-
return this.activeCountry ? this.activeCountry.flag : null;
|
158
|
-
},
|
159
|
-
parsedMode() {
|
160
|
-
if (this.mode === 'auto') {
|
161
|
-
if (!this.phone || this.phone[0] !== '+') {
|
162
|
-
return 'national';
|
163
|
-
}
|
164
|
-
return 'international';
|
165
|
-
}
|
166
|
-
if (!['international', 'national'].includes(this.mode)) {
|
167
|
-
console.error('Invalid value of prop "mode"');
|
168
|
-
return 'international';
|
169
|
-
}
|
170
|
-
return this.mode;
|
171
|
-
},
|
172
|
-
filteredCountries() {
|
173
|
-
// List countries after filtered
|
174
|
-
if (this.onlyCountries.length) {
|
175
|
-
return this.allCountries
|
176
|
-
.filter(({ iso2 }) => this.onlyCountries.some((c) => c.toUpperCase() === iso2));
|
177
|
-
}
|
178
|
-
|
179
|
-
if (this.ignoredCountries.length) {
|
180
|
-
return this.allCountries.filter(
|
181
|
-
({ iso2 }) => !this.ignoredCountries.includes(iso2.toUpperCase())
|
182
|
-
&& !this.ignoredCountries.includes(iso2.toLowerCase()),
|
183
|
-
);
|
184
|
-
}
|
185
|
-
|
186
|
-
return this.allCountries;
|
187
|
-
},
|
188
|
-
sortedCountries() {
|
189
|
-
// Sort the list countries: from preferred countries to all countries
|
190
|
-
const preferredCountries = this.getCountries(this.preferredCountries)
|
191
|
-
.map((country) => ({ ...country, preferred: true }));
|
192
|
-
|
193
|
-
return [...preferredCountries, ...this.filteredCountries];
|
194
|
-
},
|
195
|
-
phoneObject() {
|
196
|
-
let result;
|
197
|
-
|
198
|
-
if (this.phone?.[0] === '+') {
|
199
|
-
result = parsePhoneNumberFromString(this.phone) || {};
|
200
|
-
} else {
|
201
|
-
result = parsePhoneNumberFromString(this.phone, this.activeCountryCode) || {};
|
202
|
-
}
|
203
|
-
|
204
|
-
const { metadata, ...phoneObject } = result;
|
205
|
-
|
206
|
-
let valid = result.isValid?.();
|
207
|
-
let formatted = this.phone;
|
208
|
-
|
209
|
-
if (valid) {
|
210
|
-
formatted = result.format?.(this.parsedMode.toUpperCase(), { nationalPrefix: false });
|
211
|
-
}
|
212
|
-
|
213
|
-
if (result.country && (this.ignoredCountries.length || this.onlyCountries.length)) {
|
214
|
-
if (!this.findCountry(result.country)) {
|
215
|
-
valid = false;
|
216
|
-
Object.assign(result, { country: null });
|
217
|
-
}
|
218
|
-
}
|
219
|
-
|
220
|
-
Object.assign(phoneObject, {
|
221
|
-
countryCode: result.country,
|
222
|
-
valid,
|
223
|
-
country: this.activeCountry,
|
224
|
-
formatted,
|
225
|
-
});
|
226
|
-
|
227
|
-
return phoneObject;
|
228
|
-
},
|
229
|
-
classes(){
|
230
|
-
return this.phoneObject.valid === true
|
231
|
-
?
|
232
|
-
this.goodClass
|
233
|
-
:
|
234
|
-
this.phoneObject.valid === false
|
235
|
-
?
|
236
|
-
this.badClass
|
237
|
-
:
|
238
|
-
undefined
|
239
|
-
},
|
240
|
-
styles(){
|
241
|
-
return this.phoneObject.valid === true
|
242
|
-
?
|
243
|
-
this.goodStyle
|
244
|
-
:
|
245
|
-
this.phoneObject.valid === false
|
246
|
-
?
|
247
|
-
this.badStyle
|
248
|
-
:
|
249
|
-
undefined
|
250
|
-
},
|
251
|
-
Iclasses(){
|
252
|
-
return this.phoneObject.valid === true
|
253
|
-
?
|
254
|
-
this.goodInputClass
|
255
|
-
:
|
256
|
-
this.phoneObject.valid === false
|
257
|
-
?
|
258
|
-
this.badInputClass
|
259
|
-
:
|
260
|
-
undefined
|
261
|
-
},
|
262
|
-
Istyles(){
|
263
|
-
return this.phoneObject.valid === true
|
264
|
-
?
|
265
|
-
this.goodInputStyle
|
266
|
-
:
|
267
|
-
this.phoneObject.valid === false
|
268
|
-
?
|
269
|
-
this.badInputStyle
|
270
|
-
:
|
271
|
-
undefined
|
272
|
-
},
|
273
|
-
},
|
274
|
-
methods: {
|
275
|
-
resetPlaceholder() {
|
276
|
-
this.parsedPlaceholder = this.inputOptions.placeholder;
|
277
|
-
},
|
278
|
-
initializeCountry() {
|
279
|
-
return new Promise((resolve) => {
|
280
|
-
// 1. If the phone included prefix (i.e. +12), try to get the country and set it
|
281
|
-
if (this.phone?.[0] === '+') { resolve(); return; }
|
282
|
-
// 2. Use default country if passed from parent
|
283
|
-
if (this.defaultCountry) { this.choose(this.defaultCountry); resolve(); return; }
|
284
|
-
const fallbackCountry = this.preferredCountries[0] || this.filteredCountries[0];
|
285
|
-
// 3. Check if fetching country based on user's IP is allowed, set it as the default country
|
286
|
-
if (this.autoDefaultCountry) {
|
287
|
-
getCountry()
|
288
|
-
.then((res) => { this.choose(res || this.activeCountryCode); })
|
289
|
-
.catch((error) => { console.warn(error); this.choose(fallbackCountry); })
|
290
|
-
.then(() => { resolve(); });
|
291
|
-
} else {
|
292
|
-
// 4. Use the first country from preferred list (if available) or all countries list
|
293
|
-
this.choose(fallbackCountry);
|
294
|
-
resolve();
|
295
|
-
}
|
296
|
-
});
|
297
|
-
},
|
298
|
-
// Get the list of countries from the list of iso2 code
|
299
|
-
getCountries(list = []) {
|
300
|
-
return list
|
301
|
-
.map((countryCode) => this.findCountry(countryCode))
|
302
|
-
.filter(Boolean);
|
303
|
-
},
|
304
|
-
findCountry(iso = '') {
|
305
|
-
return this.filteredCountries.find((country) => country.iso2 === iso.toUpperCase());
|
306
|
-
},
|
307
|
-
getItemClass(index, iso2) {
|
308
|
-
const highlighted = this.selectedIndex === index;
|
309
|
-
const lastPreferred = index === this.preferredCountries.length - 1;
|
310
|
-
const preferred = this.preferredCountries.some((c) => c.toUpperCase() === iso2);
|
311
|
-
return {
|
312
|
-
highlighted,
|
313
|
-
'last-preferred': lastPreferred,
|
314
|
-
preferred,
|
315
|
-
};
|
316
|
-
},
|
317
|
-
choose(country) {
|
318
|
-
let parsedCountry = country;
|
319
|
-
if (typeof parsedCountry === 'string') {
|
320
|
-
parsedCountry = this.findCountry(parsedCountry);
|
321
|
-
}
|
322
|
-
|
323
|
-
if (!parsedCountry) {
|
324
|
-
return;
|
325
|
-
}
|
326
|
-
if (this.phone?.[0] === '+'
|
327
|
-
&& parsedCountry.iso2
|
328
|
-
&& this.phoneObject.nationalNumber) {
|
329
|
-
this.activeCountryCode = parsedCountry.iso2;
|
330
|
-
// Attach the current phone number with the newly selected country
|
331
|
-
this.phone = parsePhoneNumberFromString(
|
332
|
-
this.phoneObject.nationalNumber,
|
333
|
-
parsedCountry.iso2,
|
334
|
-
)
|
335
|
-
.formatInternational();
|
336
|
-
return;
|
337
|
-
}
|
338
|
-
|
339
|
-
if (this.inputOptions?.showDialCode && parsedCountry) {
|
340
|
-
// Reset phone if the showDialCode is set
|
341
|
-
this.phone = `+${parsedCountry.dialCode}`;
|
342
|
-
return;
|
343
|
-
}
|
344
|
-
|
345
|
-
// update value, even if international mode is NOT used
|
346
|
-
this.activeCountryCode = parsedCountry.iso2;
|
347
|
-
this.emitInput(this.phone);
|
348
|
-
},
|
349
|
-
cleanInvalidCharacters() {
|
350
|
-
const currentPhone = this.phone;
|
351
|
-
if (this.validCharactersOnly) {
|
352
|
-
const results = this.phone.match(/[()\-+0-9\s]*/g);
|
353
|
-
this.phone = results.join('');
|
354
|
-
}
|
355
|
-
|
356
|
-
if (this.customValidate && this.customValidate instanceof RegExp) {
|
357
|
-
const results = this.phone.match(this.customValidate);
|
358
|
-
this.phone = results.join('');
|
359
|
-
}
|
360
|
-
|
361
|
-
if (currentPhone !== this.phone) {
|
362
|
-
this.emitInput(this.phone);
|
363
|
-
}
|
364
|
-
},
|
365
|
-
testCharacters() {
|
366
|
-
if (this.validCharactersOnly) {
|
367
|
-
const result = /^[()\-+0-9\s]*$/.test(this.phone);
|
368
|
-
if (!result) {
|
369
|
-
return false;
|
370
|
-
}
|
371
|
-
}
|
372
|
-
if (this.customValidate) {
|
373
|
-
return this.testCustomValidate();
|
374
|
-
}
|
375
|
-
return true;
|
376
|
-
},
|
377
|
-
testCustomValidate() {
|
378
|
-
return this.customValidate instanceof RegExp ? this.customValidate.test(this.phone) : false;
|
379
|
-
},
|
380
|
-
onInput() {
|
381
|
-
this.$refs.input.setCustomValidity(this.phoneObject.valid ? '' : this.invalidMsg);
|
382
|
-
this.emitInput(this.phoneObject);
|
383
|
-
},
|
384
|
-
emitInput(value) {
|
385
|
-
this.$emit('update:modelValue', value);
|
386
|
-
},
|
387
|
-
onBlur() {
|
388
|
-
this.$emit('blur');
|
389
|
-
},
|
390
|
-
onFocus() {
|
391
|
-
setCaretPosition(this.$refs.input, this.phone.length);
|
392
|
-
this.$emit('focus');
|
393
|
-
},
|
394
|
-
onEnter() {
|
395
|
-
this.$emit('enter');
|
396
|
-
},
|
397
|
-
onSpace() {
|
398
|
-
this.$emit('space');
|
399
|
-
},
|
400
|
-
focus() {
|
401
|
-
this.$refs.input.focus();
|
402
|
-
},
|
403
|
-
toggleDropdown() {
|
404
|
-
if (this.disabled) {
|
405
|
-
return;
|
406
|
-
}
|
407
|
-
this.open = !this.open;
|
408
|
-
},
|
409
|
-
clickedOutside() {
|
410
|
-
this.open = false;
|
411
|
-
},
|
412
|
-
keyboardNav(e) {
|
413
|
-
if (e.keyCode === 40) {
|
414
|
-
// down arrow
|
415
|
-
e.preventDefault();
|
416
|
-
this.open = true;
|
417
|
-
if (this.selectedIndex === null) {
|
418
|
-
this.selectedIndex = 0;
|
419
|
-
} else {
|
420
|
-
this.selectedIndex = Math.min(this.sortedCountries.length - 1, this.selectedIndex + 1);
|
421
|
-
}
|
422
|
-
const selEle = this.$refs.list.children[this.selectedIndex];
|
423
|
-
if (selEle.offsetTop + selEle.clientHeight
|
424
|
-
> this.$refs.list.scrollTop + this.$refs.list.clientHeight) {
|
425
|
-
this.$refs.list.scrollTop = selEle.offsetTop
|
426
|
-
- this.$refs.list.clientHeight
|
427
|
-
+ selEle.clientHeight;
|
428
|
-
}
|
429
|
-
} else if (e.keyCode === 38) {
|
430
|
-
// up arrow
|
431
|
-
e.preventDefault();
|
432
|
-
this.open = true;
|
433
|
-
if (this.selectedIndex === null) {
|
434
|
-
this.selectedIndex = this.sortedCountries.length - 1;
|
435
|
-
} else {
|
436
|
-
this.selectedIndex = Math.max(0, this.selectedIndex - 1);
|
437
|
-
}
|
438
|
-
const selEle = this.$refs.list.children[this.selectedIndex];
|
439
|
-
if (selEle.offsetTop < this.$refs.list.scrollTop) {
|
440
|
-
this.$refs.list.scrollTop = selEle.offsetTop;
|
441
|
-
}
|
442
|
-
} else if (e.keyCode === 13) {
|
443
|
-
// enter key
|
444
|
-
if (this.selectedIndex !== null) {
|
445
|
-
this.choose(this.sortedCountries[this.selectedIndex]);
|
446
|
-
}
|
447
|
-
this.open = !this.open;
|
448
|
-
} else {
|
449
|
-
// typing a country's name
|
450
|
-
this.typeToFindInput += e.key;
|
451
|
-
clearTimeout(this.typeToFindTimer);
|
452
|
-
this.typeToFindTimer = setTimeout(() => {
|
453
|
-
this.typeToFindInput = '';
|
454
|
-
}, 700);
|
455
|
-
// don't include preferred countries so we jump to the right place in the alphabet
|
456
|
-
const typedCountryI = this.sortedCountries
|
457
|
-
.slice(this.preferredCountries.length)
|
458
|
-
.findIndex((c) => c.name.toLowerCase().startsWith(this.typeToFindInput));
|
459
|
-
if (typedCountryI >= 0) {
|
460
|
-
this.selectedIndex = this.preferredCountries.length + typedCountryI;
|
461
|
-
const selEle = this.$refs.list.children[this.selectedIndex];
|
462
|
-
const needToScrollTop = selEle.offsetTop < this.$refs.list.scrollTop;
|
463
|
-
const needToScrollBottom = selEle.offsetTop + selEle.clientHeight
|
464
|
-
> this.$refs.list.scrollTop + this.$refs.list.clientHeight;
|
465
|
-
if (needToScrollTop || needToScrollBottom) {
|
466
|
-
this.$refs.list.scrollTop = selEle.offsetTop - this.$refs.list.clientHeight / 2;
|
467
|
-
}
|
468
|
-
}
|
469
|
-
}
|
470
|
-
},
|
471
|
-
reset() {
|
472
|
-
this.selectedIndex = this.sortedCountries.map((c) => c.iso2).indexOf(this.activeCountryCode);
|
473
|
-
this.open = false;
|
474
|
-
},
|
475
|
-
setDropdownPosition() {
|
476
|
-
const spaceBelow = window.innerHeight - this.$refs.rootElement.getBoundingClientRect().bottom;
|
477
|
-
const hasEnoughSpaceBelow = spaceBelow > 200;
|
478
|
-
if (hasEnoughSpaceBelow) {
|
479
|
-
this.dropdownOpenDirection = 'below';
|
480
|
-
} else {
|
481
|
-
this.dropdownOpenDirection = 'above';
|
482
|
-
}
|
483
|
-
},
|
484
|
-
},
|
485
|
-
});
|
486
|
-
</script>
|
487
|
-
|
488
1
|
<template>
|
489
2
|
<div
|
490
|
-
:class="[
|
491
|
-
|
3
|
+
:class="[
|
4
|
+
rootClass,
|
5
|
+
classes,
|
6
|
+
$attrs.class,
|
7
|
+
{ 'bg-fourth-nano': validation },
|
8
|
+
{ disabled: disabled }
|
9
|
+
]"
|
10
|
+
:style="[
|
11
|
+
rootStyle,
|
12
|
+
styles
|
13
|
+
]"
|
492
14
|
ref="rootElement"
|
493
|
-
|
15
|
+
class="vue3-reactive-tel-input"
|
16
|
+
>
|
494
17
|
<div
|
495
18
|
v-click-outside="clickedOutside"
|
496
19
|
:class="['vti__dropdown', { open: open }]"
|
497
|
-
|
20
|
+
:style="[dropdownStyle]"
|
498
21
|
:tabindex="dropdownOptions.tabindex"
|
499
22
|
@keydown="keyboardNav"
|
500
23
|
@click="toggleDropdown"
|
501
24
|
@keydown.esc="reset"
|
502
|
-
|
25
|
+
class="br-solid br-black-transp br-1px radius-thin"
|
503
26
|
>
|
504
27
|
<span class="flex-nowrap flex flex-v-center p-medium vti__selection">
|
505
|
-
<span v-if="dropdownOptions.showFlags" v-html="activeCountryFlag" class="mn-r-
|
28
|
+
<span v-if="dropdownOptions.showFlags" v-html="activeCountryFlag" class="mn-r-nano" />
|
506
29
|
<span v-if="dropdownOptions.showDialCodeInSelection" class="vti__country-code">
|
507
30
|
+{{ activeCountry && activeCountry.dialCode }}
|
508
31
|
</span>
|
@@ -536,10 +59,9 @@
|
|
536
59
|
<input
|
537
60
|
v-model="phone"
|
538
61
|
inputmode="numeric"
|
539
|
-
|
62
|
+
pattern="\d*"
|
540
63
|
ref="input"
|
541
64
|
:type="inputOptions.type"
|
542
|
-
|
543
65
|
:autocomplete="inputOptions.autocomplete"
|
544
66
|
:autofocus="inputOptions.autofocus"
|
545
67
|
:class="['vti__input', inputOptions.styleClasses, inputClass, Iclasses]"
|
@@ -570,68 +92,580 @@
|
|
570
92
|
</transition>
|
571
93
|
</template>
|
572
94
|
|
95
|
+
|
96
|
+
<script setup>
|
97
|
+
import { ref, reactive, watch, computed, onMounted, nextTick } from 'vue';
|
98
|
+
import { parsePhoneNumberFromString } from 'libphonenumber-js';
|
99
|
+
|
100
|
+
import clickOutside from './click-outside';
|
101
|
+
import allCountries from './all-countries';
|
102
|
+
|
103
|
+
let vClickOutside = clickOutside
|
104
|
+
|
105
|
+
const props = defineProps({
|
106
|
+
modelValue: { type: String, default: '',},
|
107
|
+
badClass: { type: [String, Array, Object], default: '', },
|
108
|
+
goodClass: { type: [String, Array, Object], default: '', },
|
109
|
+
badStyle: { type: [String, Array, Object], default: '', },
|
110
|
+
goodStyle: { type: [String, Array, Object], default: '', },
|
111
|
+
badInputClass: { type: [String, Array, Object], default: '', },
|
112
|
+
goodInputClass: { type: [String, Array, Object], default: '', },
|
113
|
+
badInputStyle: { type: [String, Array, Object], default: '', },
|
114
|
+
goodInputStyle: { type: [String, Array, Object], default: '', },
|
115
|
+
allCountries: { type: Array, default: () => allCountries, },
|
116
|
+
autoFormat: { type: Boolean, default: () => true, },
|
117
|
+
validation: { type: [Boolean, Object], default: false, },
|
118
|
+
customValidate: { type: [Boolean, RegExp], default: () => false, },
|
119
|
+
defaultCountry: { type: String, default: () => '', },
|
120
|
+
disabled: { type: Boolean, default: () => false, },
|
121
|
+
autoDefaultCountry: { type: Boolean, default: () => true },
|
122
|
+
ignoredCountries: { type: Array, default: () => [], },
|
123
|
+
invalidMsg: { type: String, default: () => '', },
|
124
|
+
mode: { type: String, default: () => 'auto', },
|
125
|
+
onlyCountries: { type: Array, default: () => [], },
|
126
|
+
preferredCountries: { type: Array, default: () => [], },
|
127
|
+
validCharactersOnly: { type: Boolean, default: () => false, },
|
128
|
+
rootClass: { type: [String, Array, Object], default: () => '', },
|
129
|
+
inputClass: { type: [String, Array, Object], default: () => {return ''}, },
|
130
|
+
divInputClass: { type: [String, Array, Object], default: () => {return ''}, },
|
131
|
+
rootStyle: { type: [String, Array, Object], default: () => {return ''}, },
|
132
|
+
dropdownStyle: { type: [String, Array, Object], default: () => {return ''}, },
|
133
|
+
listStyle: { type: [String, Array, Object], default: () => {return ''}, },
|
134
|
+
inputStyle: { type: [String, Array, Object], default: () => {return ''}, },
|
135
|
+
inputId: { type: [String, Array, Object], default: () => {return ''}, },
|
136
|
+
Placeholder: { type: [String, Object, Function], default: () => {return ''}, },
|
137
|
+
dropdownOptions: {
|
138
|
+
type: Object,
|
139
|
+
default: () => {
|
140
|
+
return {
|
141
|
+
showDialCodeInList: true,
|
142
|
+
showDialCodeInSelection: false,
|
143
|
+
showFlags: true,
|
144
|
+
tabindex: 0
|
145
|
+
}
|
146
|
+
}
|
147
|
+
},
|
148
|
+
inputOptions: {
|
149
|
+
type: Object,
|
150
|
+
default: () => {
|
151
|
+
return {
|
152
|
+
autocomplete: 'on',
|
153
|
+
autofocus: false,
|
154
|
+
id: '',
|
155
|
+
maxlength: 25,
|
156
|
+
name: 'telephone',
|
157
|
+
placeholder: 'Enter a phone number',
|
158
|
+
readonly: false,
|
159
|
+
required: false,
|
160
|
+
tabindex: 0,
|
161
|
+
type: 'tel',
|
162
|
+
styleClasses: ''
|
163
|
+
}
|
164
|
+
}
|
165
|
+
},
|
166
|
+
});
|
167
|
+
|
168
|
+
const emits = defineEmits([
|
169
|
+
'update:modelValue',
|
170
|
+
'validate',
|
171
|
+
'country-changed',
|
172
|
+
'open',
|
173
|
+
'close',
|
174
|
+
'blur',
|
175
|
+
'focus',
|
176
|
+
'enter',
|
177
|
+
'space'
|
178
|
+
]);
|
179
|
+
|
180
|
+
const counter = ref(5);
|
181
|
+
const initCounter = ref(5);
|
182
|
+
const message = reactive({
|
183
|
+
action: null,
|
184
|
+
amount: null,
|
185
|
+
});
|
186
|
+
const phone = ref(props.modelValue ? props.modelValue : '');
|
187
|
+
const activeCountryCode = ref('');
|
188
|
+
const open = ref(false);
|
189
|
+
const finishMounted = ref(false);
|
190
|
+
const selectedIndex = ref(null);
|
191
|
+
const typeToFindInput = ref('');
|
192
|
+
const typeToFindTimer = ref(null);
|
193
|
+
const dropdownOpenDirection = ref('below');
|
194
|
+
const parsedPlaceholder = ref(props.Placeholder !== '' ? props.Placeholder : props.inputOptions.placeholder);
|
195
|
+
|
196
|
+
const rootElement = ref(null)
|
197
|
+
const list = ref(null)
|
198
|
+
const input = ref(null)
|
199
|
+
|
200
|
+
// Lifecycle hooks
|
201
|
+
onMounted(async () => {
|
202
|
+
if (props.modelValue) {
|
203
|
+
phone.value = props.modelValue;
|
204
|
+
}
|
205
|
+
|
206
|
+
cleanInvalidCharacters();
|
207
|
+
|
208
|
+
initializeCountry()
|
209
|
+
.then(() => {
|
210
|
+
if (!phone.value
|
211
|
+
&& props.inputOptions?.showDialCode
|
212
|
+
&& activeCountryCode.value) {
|
213
|
+
phone.value = `+${activeCountryCode.value}`;
|
214
|
+
}
|
215
|
+
emits('validate', phoneObject.value);
|
216
|
+
})
|
217
|
+
.catch(console.error)
|
218
|
+
.then(() => {
|
219
|
+
finishMounted.value = true;
|
220
|
+
});
|
221
|
+
});
|
222
|
+
|
223
|
+
// Computed properties
|
224
|
+
const activeCountry = computed(() => {
|
225
|
+
return findCountry(activeCountryCode.value);
|
226
|
+
});
|
227
|
+
|
228
|
+
const activeCountryFlag = computed(() => {
|
229
|
+
return activeCountry.value ? activeCountry.value.flag : null;
|
230
|
+
});
|
231
|
+
|
232
|
+
const parsedMode = computed(() => {
|
233
|
+
if (props.mode === 'auto') {
|
234
|
+
if (!phone.value || phone.value[0] !== '+') {
|
235
|
+
return 'national';
|
236
|
+
}
|
237
|
+
return 'international';
|
238
|
+
}
|
239
|
+
if (!['international', 'national'].includes(props.mode)) {
|
240
|
+
console.error('Invalid value of prop "mode"');
|
241
|
+
return 'international';
|
242
|
+
}
|
243
|
+
return props.mode;
|
244
|
+
});
|
245
|
+
|
246
|
+
const filteredCountries = computed(() => {
|
247
|
+
if (props.onlyCountries && props.onlyCountries.length) {
|
248
|
+
return props.allCountries.filter(({ iso2 }) => props.onlyCountries.includes(iso2.toUpperCase()));
|
249
|
+
}
|
250
|
+
|
251
|
+
if (props.ignoredCountries && props.ignoredCountries.length) {
|
252
|
+
return props.allCountries.filter(({ iso2 }) =>
|
253
|
+
!props.ignoredCountries.includes(iso2.toUpperCase()) && !props.ignoredCountries.includes(iso2.toLowerCase()),
|
254
|
+
);
|
255
|
+
}
|
256
|
+
|
257
|
+
return props.allCountries;
|
258
|
+
});
|
259
|
+
const sortedCountries = computed(() => {
|
260
|
+
const preferredCountries = getCountries(props.preferredCountries)
|
261
|
+
.map(country => ({ ...country, preferred: true }));
|
262
|
+
|
263
|
+
return [...preferredCountries, ...filteredCountries.value];
|
264
|
+
});
|
265
|
+
|
266
|
+
const phoneObject = computed(() => {
|
267
|
+
let result = {};
|
268
|
+
|
269
|
+
if (phone.value?.[0] === '+') {
|
270
|
+
result = parsePhoneNumberFromString(phone.value) || {};
|
271
|
+
} else {
|
272
|
+
result = parsePhoneNumberFromString(phone.value, activeCountryCode.value) || {};
|
273
|
+
}
|
274
|
+
|
275
|
+
const { metadata, ...phoneDetails } = result;
|
276
|
+
|
277
|
+
let valid = result.isValid?.();
|
278
|
+
let formatted = phone.value;
|
279
|
+
|
280
|
+
if (valid) {
|
281
|
+
formatted = result.format?.(parsedMode.value.toUpperCase(), { nationalPrefix: false });
|
282
|
+
}
|
283
|
+
|
284
|
+
if (result.country && (props.ignoredCountries.length || props.onlyCountries.length)) {
|
285
|
+
if (!findCountry(result.country)) {
|
286
|
+
valid = false;
|
287
|
+
result = { ...result, country: null };
|
288
|
+
}
|
289
|
+
}
|
290
|
+
|
291
|
+
return {
|
292
|
+
...phoneDetails,
|
293
|
+
countryCode: result.country,
|
294
|
+
valid,
|
295
|
+
country: activeCountry.value,
|
296
|
+
formatted,
|
297
|
+
};
|
298
|
+
});
|
299
|
+
|
300
|
+
const classes = computed(() => {
|
301
|
+
return phoneObject.value.valid === true ? props.goodClass :
|
302
|
+
phoneObject.value.valid === false ? props.badClass : undefined;
|
303
|
+
});
|
304
|
+
|
305
|
+
const styles = computed(() => {
|
306
|
+
return phoneObject.value.valid === true ? props.goodStyle :
|
307
|
+
phoneObject.value.valid === false ? props.badStyle : undefined;
|
308
|
+
});
|
309
|
+
|
310
|
+
const Iclasses = computed(() => {
|
311
|
+
return phoneObject.value.valid === true ? props.goodInputClass :
|
312
|
+
phoneObject.value.valid === false ? props.badInputClass : undefined;
|
313
|
+
});
|
314
|
+
|
315
|
+
const Istyles = computed(() => {
|
316
|
+
return phoneObject.value.valid === true ? props.goodInputStyle :
|
317
|
+
phoneObject.value.valid === false ? props.badInputStyle : undefined;
|
318
|
+
});
|
319
|
+
// ///////////
|
320
|
+
// Watchers
|
321
|
+
// ///////////
|
322
|
+
watch(activeCountry, (newValue, oldValue) => {
|
323
|
+
if (!newValue && oldValue?.iso2) {
|
324
|
+
activeCountryCode.value = oldValue.iso2;
|
325
|
+
return;
|
326
|
+
}
|
327
|
+
if (newValue?.iso2) {
|
328
|
+
emits('country-changed', newValue);
|
329
|
+
resetPlaceholder();
|
330
|
+
}
|
331
|
+
});
|
332
|
+
|
333
|
+
// Следим за изменениями countryCode в phoneObject
|
334
|
+
watch(() => phoneObject.value.countryCode, (newValue) => {
|
335
|
+
activeCountryCode.value = newValue;
|
336
|
+
});
|
337
|
+
|
338
|
+
// Следим за изменениями валидности phoneObject
|
339
|
+
watch(() => phoneObject.value.valid, () => {
|
340
|
+
emits('validate', phoneObject.value);
|
341
|
+
});
|
342
|
+
|
343
|
+
// Следим за изменениями отформатированного номера в phoneObject
|
344
|
+
watch(() => phoneObject.value.formatted, (newValue) => {
|
345
|
+
if (!props.autoFormat || props.customValidate) {
|
346
|
+
return;
|
347
|
+
}
|
348
|
+
emitInput(newValue);
|
349
|
+
|
350
|
+
nextTick(() => {
|
351
|
+
if (newValue && !props.modelValue) {
|
352
|
+
phone.value = newValue;
|
353
|
+
}
|
354
|
+
});
|
355
|
+
});
|
356
|
+
|
357
|
+
// Следим за изменениями placeholder в inputOptions
|
358
|
+
watch(() => props.inputOptions.placeholder, () => {
|
359
|
+
resetPlaceholder();
|
360
|
+
});
|
361
|
+
|
362
|
+
// Следим за внешними изменениями значения (например, через v-model)
|
363
|
+
watch(() => props.modelValue, (newValue, oldValue) => {
|
364
|
+
if (!testCharacters()) {
|
365
|
+
nextTick(() => {
|
366
|
+
phone.value = oldValue;
|
367
|
+
onInput();
|
368
|
+
});
|
369
|
+
} else {
|
370
|
+
phone.value = newValue;
|
371
|
+
}
|
372
|
+
});
|
373
|
+
|
374
|
+
// Следим за состоянием открытия/закрытия dropdown
|
375
|
+
watch(open, (isDropdownOpened) => {
|
376
|
+
if (isDropdownOpened) {
|
377
|
+
setDropdownPosition();
|
378
|
+
emits('open');
|
379
|
+
} else {
|
380
|
+
emits('close');
|
381
|
+
}
|
382
|
+
});
|
383
|
+
|
384
|
+
// Methods
|
385
|
+
function getCountry() {
|
386
|
+
return fetch('https://ip2c.org/s')
|
387
|
+
.then((response) => response.text())
|
388
|
+
.then((response) => {
|
389
|
+
const result = (response || '').toString();
|
390
|
+
|
391
|
+
if (!result || result[0] !== '1') {
|
392
|
+
throw new Error('unable to fetch the country');
|
393
|
+
}
|
394
|
+
|
395
|
+
return result.substr(2, 2);
|
396
|
+
});
|
397
|
+
}
|
398
|
+
|
399
|
+
function setCaretPosition(ctrl, pos) {
|
400
|
+
// Modern browsers
|
401
|
+
if (ctrl.setSelectionRange) {
|
402
|
+
ctrl.focus();
|
403
|
+
ctrl.setSelectionRange(pos, pos);
|
404
|
+
|
405
|
+
// IE8 and below
|
406
|
+
} else if (ctrl.createTextRange) {
|
407
|
+
const range = ctrl.createTextRange();
|
408
|
+
range.collapse(true);
|
409
|
+
range.moveEnd('character', pos);
|
410
|
+
range.moveStart('character', pos);
|
411
|
+
range.select();
|
412
|
+
}
|
413
|
+
}
|
414
|
+
|
415
|
+
function resetPlaceholder() {
|
416
|
+
parsedPlaceholder.value = props.inputOptions.placeholder;
|
417
|
+
}
|
418
|
+
function initializeCountry() {
|
419
|
+
return new Promise((resolve) => {
|
420
|
+
if (phone.value?.[0] === '+') { resolve(); return; }
|
421
|
+
if (props.defaultCountry) { choose(props.defaultCountry); resolve(); return; }
|
422
|
+
const fallbackCountry = props.preferredCountries[0] || filteredCountries.value[0];
|
423
|
+
if (props.autoDefaultCountry) {
|
424
|
+
getCountry()
|
425
|
+
.then((res) => { choose(res || activeCountryCode.value); })
|
426
|
+
.catch((error) => { console.warn(error); choose(fallbackCountry); })
|
427
|
+
.finally(() => { resolve(); });
|
428
|
+
} else {
|
429
|
+
choose(fallbackCountry);
|
430
|
+
resolve();
|
431
|
+
}
|
432
|
+
});
|
433
|
+
}
|
434
|
+
|
435
|
+
function getCountries(list = []) {
|
436
|
+
return list.map((countryCode) => findCountry(countryCode)).filter(Boolean);
|
437
|
+
}
|
438
|
+
|
439
|
+
function findCountry(iso = '') {
|
440
|
+
return filteredCountries.value.find((country) => country.iso2 === iso.toUpperCase());
|
441
|
+
}
|
442
|
+
|
443
|
+
function getItemClass(index, iso2) {
|
444
|
+
const highlighted = selectedIndex.value === index;
|
445
|
+
const lastPreferred = index === props.preferredCountries.length - 1;
|
446
|
+
const preferred = props.preferredCountries.some((c) => c.toUpperCase() === iso2);
|
447
|
+
return { highlighted, 'last-preferred': lastPreferred, preferred };
|
448
|
+
}
|
449
|
+
|
450
|
+
function choose(country) {
|
451
|
+
let parsedCountry = typeof country === 'string' ? findCountry(country) : country;
|
452
|
+
if (!parsedCountry) return;
|
453
|
+
|
454
|
+
if (phone.value?.[0] === '+' && parsedCountry.iso2 && phoneObject.value.nationalNumber) {
|
455
|
+
activeCountryCode.value = parsedCountry.iso2;
|
456
|
+
phone.value = parsePhoneNumberFromString(phoneObject.value.nationalNumber, parsedCountry.iso2).formatInternational();
|
457
|
+
return;
|
458
|
+
}
|
459
|
+
|
460
|
+
if (props.inputOptions?.showDialCode && parsedCountry) {
|
461
|
+
phone.value = `+${parsedCountry.dialCode}`;
|
462
|
+
return;
|
463
|
+
}
|
464
|
+
|
465
|
+
activeCountryCode.value = parsedCountry.iso2;
|
466
|
+
emitInput(phone.value);
|
467
|
+
}
|
468
|
+
|
469
|
+
function cleanInvalidCharacters() {
|
470
|
+
const currentPhone = phone.value;
|
471
|
+
|
472
|
+
if (props.validCharactersOnly) {
|
473
|
+
const results = phone.value.match(/[()\-+0-9\s]*/g);
|
474
|
+
phone.value = results.join('');
|
475
|
+
}
|
476
|
+
|
477
|
+
if (props.customValidate && props.customValidate instanceof RegExp) {
|
478
|
+
const results = phone.value.match(props.customValidate);
|
479
|
+
phone.value = results ? results.join('') : '';
|
480
|
+
}
|
481
|
+
|
482
|
+
if (currentPhone !== phone.value) {
|
483
|
+
emitInput(phone.value);
|
484
|
+
}
|
485
|
+
}
|
486
|
+
|
487
|
+
function testCharacters() {
|
488
|
+
if (props.validCharactersOnly) {
|
489
|
+
const result = /^[()\-+0-9\s]*$/.test(phone.value);
|
490
|
+
if (!result) return false;
|
491
|
+
}
|
492
|
+
if (props.customValidate) {
|
493
|
+
return testCustomValidate();
|
494
|
+
}
|
495
|
+
return true;
|
496
|
+
}
|
497
|
+
|
498
|
+
function testCustomValidate() {
|
499
|
+
return props.customValidate instanceof RegExp ? props.customValidate.test(phone.value) : false;
|
500
|
+
}
|
501
|
+
|
502
|
+
function onInput() {
|
503
|
+
input.value.setCustomValidity(phoneObject.valid ? '' : props.invalidMsg);
|
504
|
+
|
505
|
+
emitInput(phone.value);
|
506
|
+
}
|
507
|
+
|
508
|
+
function emitInput(value) {
|
509
|
+
emits('update:modelValue', value);
|
510
|
+
|
511
|
+
if (phoneObject.value.valid) {
|
512
|
+
emits('country', phoneObject.value.number);
|
513
|
+
} else {
|
514
|
+
emits('country', null);
|
515
|
+
}
|
516
|
+
}
|
517
|
+
|
518
|
+
function onBlur() {
|
519
|
+
emits('blur');
|
520
|
+
}
|
521
|
+
|
522
|
+
function onFocus() {
|
523
|
+
setCaretPosition(input.value, phone.value.length);
|
524
|
+
emits('focus');
|
525
|
+
}
|
526
|
+
|
527
|
+
function onEnter() {
|
528
|
+
emits('enter');
|
529
|
+
}
|
530
|
+
|
531
|
+
function onSpace() {
|
532
|
+
emits('space');
|
533
|
+
}
|
534
|
+
|
535
|
+
function focus() {
|
536
|
+
input.value.focus();
|
537
|
+
}
|
538
|
+
|
539
|
+
function toggleDropdown() {
|
540
|
+
if (props.disabled) return;
|
541
|
+
open.value = !open.value;
|
542
|
+
}
|
543
|
+
|
544
|
+
function clickedOutside() {
|
545
|
+
open.value = false;
|
546
|
+
}
|
547
|
+
|
548
|
+
function keyboardNav(e) {
|
549
|
+
if (e.keyCode === 40) { // down arrow
|
550
|
+
e.preventDefault();
|
551
|
+
open.value = true;
|
552
|
+
selectedIndex.value = selectedIndex.value === null ? 0 : Math.min(sortedCountries.value.length - 1, selectedIndex.value + 1);
|
553
|
+
nextTick(() => {
|
554
|
+
const selEle = list.value.children[selectedIndex.value];
|
555
|
+
if (selEle.offsetTop + selEle.clientHeight > list.value.scrollTop + list.value.clientHeight) {
|
556
|
+
list.value.scrollTop = selEle.offsetTop - list.value.clientHeight + selEle.clientHeight;
|
557
|
+
}
|
558
|
+
});
|
559
|
+
} else if (e.keyCode === 38) { // up arrow
|
560
|
+
e.preventDefault();
|
561
|
+
open.value = true;
|
562
|
+
selectedIndex.value = selectedIndex.value === null ? sortedCountries.value.length - 1 : Math.max(0, selectedIndex.value - 1);
|
563
|
+
nextTick(() => {
|
564
|
+
const selEle = list.value.children[selectedIndex.value];
|
565
|
+
if (selEle.offsetTop < list.value.scrollTop) {
|
566
|
+
list.value.scrollTop = selEle.offsetTop;
|
567
|
+
}
|
568
|
+
});
|
569
|
+
} else if (e.keyCode === 13) { // enter key
|
570
|
+
e.preventDefault();
|
571
|
+
if (selectedIndex.value !== null) {
|
572
|
+
choose(sortedCountries.value[selectedIndex.value]);
|
573
|
+
}
|
574
|
+
open.value = !open.value;
|
575
|
+
} else { // typing a country's name
|
576
|
+
typeToFindInput.value += e.key;
|
577
|
+
clearTimeout(typeToFindTimer);
|
578
|
+
typeToFindTimer = setTimeout(() => {
|
579
|
+
typeToFindInput.value = '';
|
580
|
+
}, 700);
|
581
|
+
nextTick(() => {
|
582
|
+
const typedCountryI = sortedCountries.value.slice(props.preferredCountries.length).findIndex((c) => c.name.toLowerCase().startsWith(typeToFindInput.value));
|
583
|
+
if (typedCountryI >= 0) {
|
584
|
+
selectedIndex.value = props.preferredCountries.length + typedCountryI;
|
585
|
+
const selEle = list.value.children[selectedIndex.value];
|
586
|
+
const needToScroll = selEle.offsetTop < list.value.scrollTop || selEle.offsetTop + selEle.clientHeight > list.value.scrollTop + list.value.clientHeight;
|
587
|
+
if (needToScroll) {
|
588
|
+
list.value.scrollTop = selEle.offsetTop - list.value.clientHeight / 2;
|
589
|
+
}
|
590
|
+
}
|
591
|
+
});
|
592
|
+
}
|
593
|
+
}
|
594
|
+
|
595
|
+
function reset() {
|
596
|
+
selectedIndex.value = sortedCountries.value.map(c => c.iso2).indexOf(activeCountryCode.value);
|
597
|
+
open.value = false;
|
598
|
+
}
|
599
|
+
|
600
|
+
function setDropdownPosition() {
|
601
|
+
const spaceBelow = window.innerHeight - rootElement.value.getBoundingClientRect().bottom;
|
602
|
+
const hasEnoughSpaceBelow = spaceBelow > 200;
|
603
|
+
dropdownOpenDirection.value = hasEnoughSpaceBelow ? 'below' : 'above';
|
604
|
+
}
|
605
|
+
</script>
|
606
|
+
|
573
607
|
<style scoped>
|
574
|
-
.vue3-reactive-tel-input{
|
575
|
-
|
576
|
-
}
|
577
|
-
.vue3-reactive-tel-input.disabled .dropdown,.vue3-reactive-tel-input.disabled .selection,.vue3-reactive-tel-input.disabled input{
|
578
|
-
|
579
|
-
}
|
580
|
-
.vti__dropdown{
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
}
|
589
|
-
.vti__dropdown.show{
|
590
|
-
|
591
|
-
|
592
|
-
}
|
593
|
-
.vti__dropdown-list{
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
}
|
606
|
-
.vti__dropdown-list.below{
|
607
|
-
|
608
|
-
}
|
609
|
-
.vti__dropdown-list.above{
|
610
|
-
|
611
|
-
|
612
|
-
}
|
613
|
-
.vti__dropdown-arrow{
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
}
|
618
|
-
.vti__dropdown-item{
|
619
|
-
|
620
|
-
|
621
|
-
}
|
622
|
-
.vti__dropdown-item.last-preferred{
|
623
|
-
|
624
|
-
}
|
625
|
-
.vti__dropdown-item .vti__flag{
|
626
|
-
|
627
|
-
|
628
|
-
}
|
629
|
-
.vti__input{
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
}
|
608
|
+
.vue3-reactive-tel-input{
|
609
|
+
display:flex
|
610
|
+
}
|
611
|
+
.vue3-reactive-tel-input.disabled .dropdown,.vue3-reactive-tel-input.disabled .selection,.vue3-reactive-tel-input.disabled input{
|
612
|
+
cursor:no-drop
|
613
|
+
}
|
614
|
+
.vti__dropdown{
|
615
|
+
display:flex;
|
616
|
+
flex-direction:column;
|
617
|
+
align-content:center;
|
618
|
+
justify-content:center;
|
619
|
+
position:relative;
|
620
|
+
padding:2px;
|
621
|
+
cursor:pointer
|
622
|
+
}
|
623
|
+
.vti__dropdown.show{
|
624
|
+
max-height:300px;
|
625
|
+
overflow:scroll
|
626
|
+
}
|
627
|
+
.vti__dropdown-list{
|
628
|
+
z-index:1;
|
629
|
+
padding:0;
|
630
|
+
margin:0;
|
631
|
+
text-align:left;
|
632
|
+
list-style:none;
|
633
|
+
max-height:200px;
|
634
|
+
overflow-y:scroll;
|
635
|
+
position:absolute;
|
636
|
+
left:-1px;
|
637
|
+
background-color:#fff;
|
638
|
+
width:fit-content
|
639
|
+
}
|
640
|
+
.vti__dropdown-list.below{
|
641
|
+
top:33px
|
642
|
+
}
|
643
|
+
.vti__dropdown-list.above{
|
644
|
+
top:auto;
|
645
|
+
bottom:100%
|
646
|
+
}
|
647
|
+
.vti__dropdown-arrow{
|
648
|
+
transform:scaleY(.5);
|
649
|
+
display:inline-block;
|
650
|
+
color:#666
|
651
|
+
}
|
652
|
+
.vti__dropdown-item{
|
653
|
+
cursor:pointer;
|
654
|
+
padding:4px 15px
|
655
|
+
}
|
656
|
+
.vti__dropdown-item.last-preferred{
|
657
|
+
border-bottom:1px solid #cacaca
|
658
|
+
}
|
659
|
+
.vti__dropdown-item .vti__flag{
|
660
|
+
display:inline-block;
|
661
|
+
margin-right:5px
|
662
|
+
}
|
663
|
+
.vti__input{
|
664
|
+
color: inherit;
|
665
|
+
border:none;
|
666
|
+
border-radius:0 2px 2px 0;
|
667
|
+
width:100%;
|
668
|
+
outline:0;
|
669
|
+
padding-left:7px
|
670
|
+
}
|
637
671
|
</style>
|