@wix/agent-skills 1.16.3 → 1.18.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/package.json +1 -1
- package/skills/wix-app/SKILL.md +115 -12
- package/skills/wix-app/references/APP_MARKET_REVIEW.md +1 -1
- package/skills/wix-app/references/BACKEND_API.md +18 -0
- package/skills/wix-app/references/CUSTOM_ELEMENT_WIDGET.md +6 -0
- package/skills/wix-app/references/DASHBOARD_MODAL.md +10 -2
- package/skills/wix-app/references/DASHBOARD_PAGE.md +32 -70
- package/skills/wix-app/references/EDITOR_REACT_COMPONENT.md +145 -127
- package/skills/wix-app/references/SITE_PLUGIN.md +14 -2
- package/skills/wix-app/references/WIX_PATTERNS_DOCS.md +74 -68
- package/skills/wix-app/references/backend-event/COMMON-EVENTS.md +2 -2
- package/skills/wix-app/references/dashboard-page/COLLECTION_TOOLKIT.md +79 -0
- package/skills/wix-app/references/dashboard-page/ENTITY_PAGE_TOOLKIT.md +73 -0
- package/skills/wix-app/references/dashboard-page/PATTERNS_BUNDLE_READING.md +52 -0
- package/skills/wix-app/references/dashboard-page/UX_SUCCESS_MODEL.md +184 -0
- package/skills/wix-app/references/editor-react-component/ACCESSIBILITY.md +182 -99
- package/skills/wix-app/references/editor-react-component/ANIMATED-COMPONENTS.md +94 -49
- package/skills/wix-app/references/editor-react-component/BRANDED-COMPONENTS.md +16 -6
- package/skills/wix-app/references/editor-react-component/BROWSER-SUPPORT.md +56 -0
- package/skills/wix-app/references/editor-react-component/COMPONENT-CONTRACT.md +275 -0
- package/skills/wix-app/references/editor-react-component/COMPONENT-PREVIEW.md +35 -40
- package/skills/wix-app/references/editor-react-component/CSS-GUIDELINES.md +167 -445
- package/skills/wix-app/references/editor-react-component/DESIGN-STATES.md +56 -29
- package/skills/wix-app/references/editor-react-component/DIRECTIONALITY.md +53 -158
- package/skills/wix-app/references/editor-react-component/EDITOR-EXTENSION-CONFIGURATION.md +78 -0
- package/skills/wix-app/references/editor-react-component/FUNCTION-HANDLERS.md +42 -134
- package/skills/wix-app/references/editor-react-component/MANIFEST-ERRORS.md +11 -3
- package/skills/wix-app/references/editor-react-component/PARTS.md +46 -24
- package/skills/wix-app/references/editor-react-component/PROPS-VS-CSS.md +63 -179
- package/skills/wix-app/references/editor-react-component/REACT-GUIDELINES.md +79 -163
- package/skills/wix-app/references/editor-react-component/SITE-CONTEXT-HOOKS.md +36 -21
- package/skills/wix-app/references/editor-react-component/SSR.md +30 -99
- package/skills/wix-base44-connector/SKILL.md +156 -50
- package/skills/wix-base44-connector/references/CAPABILITY_MAP.md +78 -0
- package/skills/wix-base44-connector/scripts/utils.js +239 -45
- package/skills/wix-headless/entry/bootstrap.mjs +9 -2
- package/skills/wix-headless/entry/skill.md +1 -1
- package/skills/wix-headless/references/CAPABILITIES.md +9 -1
- package/skills/wix-headless/references/DESIGN.md +1 -0
- package/skills/wix-headless/references/DISCOVERY.md +2 -1
- package/skills/wix-headless/references/IMAGE_GENERATION.md +1 -0
- package/skills/wix-headless/references/SDK_HANDOFF.md +5 -2
- package/skills/wix-headless/references/SEED.md +2 -1
- package/skills/wix-headless/references/SETUP.md +1 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-a-blog.md +2 -2
- package/skills/wix-headless/references/inline-recipes/how-to-code-a-store.md +68 -31
- package/skills/wix-headless/references/inline-recipes/how-to-code-forms.md +26 -10
- package/skills/wix-headless/references/inline-recipes/how-to-code-members-astro.md +8 -8
- package/skills/wix-headless/references/inline-recipes/how-to-code-members-custom-login.md +1 -1
- package/skills/wix-headless/references/inline-recipes/how-to-code-members-non-astro.md +1 -1
- package/skills/wix-headless/references/inline-recipes/how-to-code-pricing-plans.md +10 -8
- package/skills/wix-headless/references/inline-recipes/how-to-code-rentals.md +254 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-restaurant-orders.md +27 -24
- package/skills/wix-headless/references/inline-recipes/setup-online-store.md +13 -0
- package/skills/wix-headless/references/inline-recipes/setup-rentals.md +254 -0
- package/skills/wix-headless/references/managed/AUTHENTICATION.md +5 -0
- package/skills/wix-headless/references/non-astro.md +1 -1
- package/skills/wix-headless-fast/SKILL.md +166 -0
- package/skills/wix-headless-fast/entry/skill.md +99 -0
- package/skills/wix-headless-fast/install/deploy.mjs +433 -0
- package/skills/wix-headless-fast/install/fast-path.mjs +141 -0
- package/skills/wix-headless-fast/references/blog/INSTRUCTIONS.md +137 -0
- package/skills/wix-headless-fast/references/blog/app/components/blog/BlogFeedView.tsx +137 -0
- package/skills/wix-headless-fast/references/blog/app/components/blog/PostView.tsx +113 -0
- package/skills/wix-headless-fast/references/blog/app/components/blog/RichContent.tsx +42 -0
- package/skills/wix-headless-fast/references/blog/app/hooks/blog/useBlogFeed.ts +123 -0
- package/skills/wix-headless-fast/references/blog/app/hooks/blog/usePost.ts +70 -0
- package/skills/wix-headless-fast/references/blog/app/wix/blog/posts.ts +99 -0
- package/skills/wix-headless-fast/references/blog/app/wix/blog/taxonomy.ts +76 -0
- package/skills/wix-headless-fast/references/blog/app/wix/blog/types.ts +62 -0
- package/skills/wix-headless-fast/references/blog/app-astro/layouts/SiteLayout.astro +40 -0
- package/skills/wix-headless-fast/references/blog/app-astro/pages/blog/[...slug].astro +99 -0
- package/skills/wix-headless-fast/references/blog/app-astro/pages/blog.astro +24 -0
- package/skills/wix-headless-fast/references/blog/lock/astro/package-lock.json +16156 -0
- package/skills/wix-headless-fast/references/blog/seed/SEED.md +72 -0
- package/skills/wix-headless-fast/references/blog/seed/seed-blog.mjs +287 -0
- package/skills/wix-headless-fast/references/bookings/INSTRUCTIONS.md +129 -0
- package/skills/wix-headless-fast/references/bookings/app/components/bookings/ServiceBookingView.tsx +143 -0
- package/skills/wix-headless-fast/references/bookings/app/components/bookings/ServicesView.tsx +119 -0
- package/skills/wix-headless-fast/references/bookings/app/hooks/bookings/useBookingFlow.ts +138 -0
- package/skills/wix-headless-fast/references/bookings/app/hooks/bookings/useServices.ts +54 -0
- package/skills/wix-headless-fast/references/bookings/app/wix/bookings/booking.ts +206 -0
- package/skills/wix-headless-fast/references/bookings/app/wix/bookings/services.ts +96 -0
- package/skills/wix-headless-fast/references/bookings/app/wix/bookings/types.ts +70 -0
- package/skills/wix-headless-fast/references/bookings/app-astro/layouts/SiteLayout.astro +40 -0
- package/skills/wix-headless-fast/references/bookings/app-astro/pages/services/[slug].astro +76 -0
- package/skills/wix-headless-fast/references/bookings/app-astro/pages/services.astro +22 -0
- package/skills/wix-headless-fast/references/bookings/lock/astro/package-lock.json +11962 -0
- package/skills/wix-headless-fast/references/bookings/seed/SEED.md +61 -0
- package/skills/wix-headless-fast/references/bookings/seed/seed-bookings.mjs +302 -0
- package/skills/wix-headless-fast/references/cms/INSTRUCTIONS.md +179 -0
- package/skills/wix-headless-fast/references/cms/app/hooks/cms/useCollection.ts +83 -0
- package/skills/wix-headless-fast/references/cms/app/hooks/cms/useItem.ts +57 -0
- package/skills/wix-headless-fast/references/cms/app/wix/cms/items.ts +151 -0
- package/skills/wix-headless-fast/references/cms/app/wix/cms/types.ts +75 -0
- package/skills/wix-headless-fast/references/cms/app-astro/layouts/SiteLayout.astro +41 -0
- package/skills/wix-headless-fast/references/cms/lock/astro/package-lock.json +11262 -0
- package/skills/wix-headless-fast/references/cms/seed/SEED.md +103 -0
- package/skills/wix-headless-fast/references/cms/seed/seed-cms.mjs +324 -0
- package/skills/wix-headless-fast/references/events/INSTRUCTIONS.md +149 -0
- package/skills/wix-headless-fast/references/events/app/components/events/EventConfirmationView.tsx +66 -0
- package/skills/wix-headless-fast/references/events/app/components/events/EventRegistrationView.tsx +176 -0
- package/skills/wix-headless-fast/references/events/app/components/events/EventsView.tsx +118 -0
- package/skills/wix-headless-fast/references/events/app/hooks/events/useEventRegistration.ts +117 -0
- package/skills/wix-headless-fast/references/events/app/hooks/events/useEvents.ts +59 -0
- package/skills/wix-headless-fast/references/events/app/wix/events/events.ts +136 -0
- package/skills/wix-headless-fast/references/events/app/wix/events/registration.ts +128 -0
- package/skills/wix-headless-fast/references/events/app/wix/events/types.ts +61 -0
- package/skills/wix-headless-fast/references/events/app-astro/layouts/SiteLayout.astro +40 -0
- package/skills/wix-headless-fast/references/events/app-astro/pages/event-confirmation.astro +12 -0
- package/skills/wix-headless-fast/references/events/app-astro/pages/events/[slug].astro +80 -0
- package/skills/wix-headless-fast/references/events/app-astro/pages/events.astro +21 -0
- package/skills/wix-headless-fast/references/events/lock/astro/package-lock.json +11884 -0
- package/skills/wix-headless-fast/references/events/seed/SEED.md +86 -0
- package/skills/wix-headless-fast/references/events/seed/seed-events.mjs +276 -0
- package/skills/wix-headless-fast/references/forms/INSTRUCTIONS.md +150 -0
- package/skills/wix-headless-fast/references/forms/app/hooks/forms/useWixForm.ts +317 -0
- package/skills/wix-headless-fast/references/forms/app/wix/forms/forms.ts +269 -0
- package/skills/wix-headless-fast/references/forms/app/wix/forms/submissions.ts +231 -0
- package/skills/wix-headless-fast/references/forms/app/wix/forms/types.ts +135 -0
- package/skills/wix-headless-fast/references/forms/lock/astro/package-lock.json +10593 -0
- package/skills/wix-headless-fast/references/forms/seed/SEED.md +108 -0
- package/skills/wix-headless-fast/references/forms/seed/seed-forms.mjs +320 -0
- package/skills/wix-headless-fast/references/members/INSTRUCTIONS.md +63 -0
- package/skills/wix-headless-fast/references/members/app/components/members/AccountView.tsx +60 -0
- package/skills/wix-headless-fast/references/members/app/components/members/LoginForm.tsx +155 -0
- package/skills/wix-headless-fast/references/members/app/components/members/MemberMenu.tsx +78 -0
- package/skills/wix-headless-fast/references/members/app/components/members/RequireAuth.tsx +47 -0
- package/skills/wix-headless-fast/references/members/app/hooks/members/useMember.ts +66 -0
- package/skills/wix-headless-fast/references/members/app/wix/members/auth.ts +88 -0
- package/skills/wix-headless-fast/references/members/app/wix/members/client.ts +53 -0
- package/skills/wix-headless-fast/references/members/app/wix/members/member-store.ts +122 -0
- package/skills/wix-headless-fast/references/members/app/wix/members/members.ts +50 -0
- package/skills/wix-headless-fast/references/members/app/wix/members/types.ts +21 -0
- package/skills/wix-headless-fast/references/members/app-astro/layouts/SiteLayout.astro +42 -0
- package/skills/wix-headless-fast/references/members/app-astro/pages/account.astro +10 -0
- package/skills/wix-headless-fast/references/members/app-astro/pages/login.astro +11 -0
- package/skills/wix-headless-fast/references/members/lock/astro/package-lock.json +10329 -0
- package/skills/wix-headless-fast/references/members/seed/SEED.md +39 -0
- package/skills/wix-headless-fast/references/members/seed/seed-members.mjs +94 -0
- package/skills/wix-headless-fast/references/portfolio/INSTRUCTIONS.md +134 -0
- package/skills/wix-headless-fast/references/portfolio/app/components/portfolio/CollectionProjectsView.tsx +110 -0
- package/skills/wix-headless-fast/references/portfolio/app/components/portfolio/CollectionsView.tsx +90 -0
- package/skills/wix-headless-fast/references/portfolio/app/components/portfolio/ProjectDetailView.tsx +115 -0
- package/skills/wix-headless-fast/references/portfolio/app/hooks/portfolio/useCollectionProjects.ts +59 -0
- package/skills/wix-headless-fast/references/portfolio/app/hooks/portfolio/useCollections.ts +39 -0
- package/skills/wix-headless-fast/references/portfolio/app/hooks/portfolio/useProjectDetail.ts +58 -0
- package/skills/wix-headless-fast/references/portfolio/app/wix/portfolio/portfolio.ts +165 -0
- package/skills/wix-headless-fast/references/portfolio/app/wix/portfolio/types.ts +55 -0
- package/skills/wix-headless-fast/references/portfolio/app-astro/layouts/SiteLayout.astro +40 -0
- package/skills/wix-headless-fast/references/portfolio/app-astro/pages/portfolio/[slug].astro +30 -0
- package/skills/wix-headless-fast/references/portfolio/app-astro/pages/portfolio.astro +21 -0
- package/skills/wix-headless-fast/references/portfolio/app-astro/pages/projects/[slug].astro +29 -0
- package/skills/wix-headless-fast/references/portfolio/lock/astro/package-lock.json +10197 -0
- package/skills/wix-headless-fast/references/portfolio/seed/SEED.md +78 -0
- package/skills/wix-headless-fast/references/portfolio/seed/seed-portfolio.mjs +258 -0
- package/skills/wix-headless-fast/references/pricing-plans/INSTRUCTIONS.md +133 -0
- package/skills/wix-headless-fast/references/pricing-plans/app/components/pricing-plans/PlanDetailView.tsx +58 -0
- package/skills/wix-headless-fast/references/pricing-plans/app/components/pricing-plans/PlansView.tsx +126 -0
- package/skills/wix-headless-fast/references/pricing-plans/app/hooks/pricing-plans/usePlanPurchase.ts +37 -0
- package/skills/wix-headless-fast/references/pricing-plans/app/hooks/pricing-plans/usePlans.ts +39 -0
- package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/plans.ts +75 -0
- package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/purchase.ts +45 -0
- package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/types.ts +30 -0
- package/skills/wix-headless-fast/references/pricing-plans/app-astro/layouts/SiteLayout.astro +41 -0
- package/skills/wix-headless-fast/references/pricing-plans/app-astro/pages/plans/[slug].astro +40 -0
- package/skills/wix-headless-fast/references/pricing-plans/app-astro/pages/plans.astro +21 -0
- package/skills/wix-headless-fast/references/pricing-plans/lock/astro/package-lock.json +11226 -0
- package/skills/wix-headless-fast/references/pricing-plans/seed/SEED.md +71 -0
- package/skills/wix-headless-fast/references/pricing-plans/seed/seed-pricing-plans.mjs +279 -0
- package/skills/wix-headless-fast/references/restaurants/INSTRUCTIONS.md +165 -0
- package/skills/wix-headless-fast/references/restaurants/app/components/restaurants/MenuView.tsx +142 -0
- package/skills/wix-headless-fast/references/restaurants/app/components/restaurants/OrderCartButton.tsx +26 -0
- package/skills/wix-headless-fast/references/restaurants/app/components/restaurants/OrderCartDrawer.tsx +121 -0
- package/skills/wix-headless-fast/references/restaurants/app/components/restaurants/ReservationView.tsx +155 -0
- package/skills/wix-headless-fast/references/restaurants/app/hooks/restaurants/useMenus.ts +55 -0
- package/skills/wix-headless-fast/references/restaurants/app/hooks/restaurants/useOrderCart.ts +43 -0
- package/skills/wix-headless-fast/references/restaurants/app/hooks/restaurants/useReservation.ts +177 -0
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/menu.ts +165 -0
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/order-store.ts +103 -0
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/ordering.ts +254 -0
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/reservations.ts +146 -0
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/types.ts +168 -0
- package/skills/wix-headless-fast/references/restaurants/app-astro/layouts/SiteLayout.astro +47 -0
- package/skills/wix-headless-fast/references/restaurants/app-astro/pages/menu.astro +22 -0
- package/skills/wix-headless-fast/references/restaurants/app-astro/pages/reservations.astro +12 -0
- package/skills/wix-headless-fast/references/restaurants/lock/astro/package-lock.json +12560 -0
- package/skills/wix-headless-fast/references/restaurants/seed/SEED.md +81 -0
- package/skills/wix-headless-fast/references/restaurants/seed/seed-restaurants.mjs +479 -0
- package/skills/wix-headless-fast/references/shared/CONTENT.md +22 -0
- package/skills/wix-headless-fast/references/shared/CUSTOM_OPERATIONS.md +73 -0
- package/skills/wix-headless-fast/references/shared/DESIGN.md +26 -0
- package/skills/wix-headless-fast/references/shared/app/styles/global.css +52 -0
- package/skills/wix-headless-fast/references/shared/app/wix/config.ts +15 -0
- package/skills/wix-headless-fast/references/shared/app/wix/media.ts +27 -0
- package/skills/wix-headless-fast/references/shared/app/wix/money.ts +24 -0
- package/skills/wix-headless-fast/references/shared/app/wix/sdk.ts +76 -0
- package/skills/wix-headless-fast/references/shared/capabilities/media-upload/app/wix/media-upload/client.ts +46 -0
- package/skills/wix-headless-fast/references/shared/capabilities/media-upload/app-astro/pages/api/wix/media-upload.ts +46 -0
- package/skills/wix-headless-fast/references/shared/seed/images.mjs +145 -0
- package/skills/wix-headless-fast/references/storefront/INSTRUCTIONS.md +149 -0
- package/skills/wix-headless-fast/references/storefront/app/components/storefront/CartButton.tsx +26 -0
- package/skills/wix-headless-fast/references/storefront/app/components/storefront/CartDrawer.tsx +121 -0
- package/skills/wix-headless-fast/references/storefront/app/components/storefront/ProductCard.tsx +100 -0
- package/skills/wix-headless-fast/references/storefront/app/components/storefront/ProductDetailView.tsx +130 -0
- package/skills/wix-headless-fast/references/storefront/app/components/storefront/ProductGrid.tsx +48 -0
- package/skills/wix-headless-fast/references/storefront/app/components/storefront/ShopView.tsx +66 -0
- package/skills/wix-headless-fast/references/storefront/app/components/storefront/VariantPicker.tsx +103 -0
- package/skills/wix-headless-fast/references/storefront/app/hooks/storefront/useCart.ts +48 -0
- package/skills/wix-headless-fast/references/storefront/app/hooks/storefront/useProductDetail.ts +140 -0
- package/skills/wix-headless-fast/references/storefront/app/hooks/storefront/useShop.ts +80 -0
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/cart-store.ts +101 -0
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/cart.ts +221 -0
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/catalog.ts +215 -0
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/types.ts +109 -0
- package/skills/wix-headless-fast/references/storefront/app-astro/layouts/SiteLayout.astro +46 -0
- package/skills/wix-headless-fast/references/storefront/app-astro/pages/products/[slug].astro +56 -0
- package/skills/wix-headless-fast/references/storefront/app-astro/pages/shop.astro +23 -0
- package/skills/wix-headless-fast/references/storefront/lock/astro/package-lock.json +12247 -0
- package/skills/wix-headless-fast/references/storefront/seed/SEED.md +85 -0
- package/skills/wix-headless-fast/references/storefront/seed/seed-store.mjs +415 -0
- package/skills/wix-manage/SKILL.md +28 -2
- package/skills/wix-manage/references/bookings/booking-system-integration-gaps.md +20 -13
- package/skills/wix-manage/references/bookings/end-to-end-booking-flow.md +24 -11
- package/skills/wix-manage/references/cms/cms-ecommerce-catalog-integration.md +5 -5
- package/skills/wix-manage/references/google-ads/manage-campaign-success-guide.md +141 -0
- package/skills/wix-manage/references/google-business-profile/connect-google-business-profile.md +134 -0
- package/skills/wix-manage/references/google-business-profile/manage-google-business-profile-locations.md +182 -0
- package/skills/wix-manage/references/marketing/create-and-publish-social-post.md +3 -0
- package/skills/wix-manage/references/seo/manage-seo-tags.md +315 -0
- package/skills/wix-manage/references/seo/manage-url-redirects.md +250 -0
- package/skills/wix-manage/references/sites/query-sites.md +72 -161
- package/skills/wix-manage/references/stores/create-product-catalog-v3.md +21 -6
- package/skills/wix-manage/references/stores/update-product-with-options.md +83 -0
- package/skills/wix-replatform/resources/rp-mapper/wix-business-solutions-taxonomy.md +5 -6
- package/skills/wix-vibe-headless/SKILL.md +18 -4
- package/skills/wix-vibe-headless/install/deploy.cjs +12 -4
- package/skills/wix-vibe-headless/install/pin-agents-md.cjs +2 -1
- package/skills/wix-vibe-headless/platforms/base44-ecom-light-seed.md +16 -10
- package/skills/wix-vibe-headless/platforms/base44-ecom-light.md +13 -8
- package/skills/wix-vibe-headless/platforms/base44.md +27 -62
- package/skills/wix-vibe-headless/platforms/generic.md +6 -3
- package/skills/wix-vibe-headless/references/bookings/INSTRUCTIONS.md +45 -0
- package/skills/wix-vibe-headless/references/bookings/app/components/RentalDurationPicker.jsx +67 -0
- package/skills/wix-vibe-headless/references/bookings/app/hooks/useRentalDuration.js +128 -0
- package/skills/wix-vibe-headless/references/bookings/app/hooks/useServiceDetail.js +5 -3
- package/skills/wix-vibe-headless/references/bookings/app/rest/wix-bookings-checkout.js +9 -8
- package/skills/wix-vibe-headless/references/bookings/app/rest/wix-bookings-rentals.js +250 -0
- package/skills/wix-vibe-headless/references/bookings/app/rest/wix-bookings-services.js +12 -5
- package/skills/wix-vibe-headless/references/bookings/seed/SEED.md +41 -0
- package/skills/wix-vibe-headless/references/bookings/seed/seed-rentals.js +267 -0
- package/skills/wix-vibe-headless/references/cms/INSTRUCTIONS.md +6 -3
- package/skills/wix-vibe-headless/references/forms/INSTRUCTIONS.md +470 -0
- package/skills/wix-vibe-headless/references/forms/app/hooks/useWixForm.js +425 -0
- package/skills/wix-vibe-headless/references/forms/app/lib/wix-form-schema-utils.js +187 -0
- package/skills/wix-vibe-headless/references/forms/app/rest/wix-forms-submissions.js +238 -0
- package/skills/wix-vibe-headless/references/forms/app/rest/wix-forms.js +108 -0
- package/skills/wix-vibe-headless/references/forms/seed/SEED.md +1762 -0
- package/skills/wix-vibe-headless/references/rentals/INSTRUCTIONS.md +13 -0
- package/skills/wix-vibe-headless/references/restaurants/INSTRUCTIONS.md +4 -1
- package/skills/wix-vibe-headless/references/restaurants/app/components/OrderCartDrawer.jsx +23 -11
- package/skills/wix-vibe-headless/references/restaurants/app/context/OrderCartContext.jsx +1 -1
- package/skills/wix-vibe-headless/references/restaurants/app/rest/wix-restaurants-ordering.js +29 -31
- package/skills/wix-vibe-headless/references/storefront/INSTRUCTIONS.md +152 -92
- package/skills/wix-vibe-headless/references/storefront/app/components/CartDrawer.jsx +37 -38
- package/skills/wix-vibe-headless/references/storefront/app/context/CartContext.jsx +2 -2
- package/skills/wix-vibe-headless/references/storefront/app/hooks/useProductDetail.js +15 -8
- package/skills/wix-vibe-headless/references/storefront/app/lib/storeImage.js +37 -0
- package/skills/wix-vibe-headless/references/storefront/app/rest/wix-store-cart.js +35 -35
- package/skills/wix-vibe-headless/references/storefront/app/rest/wix-store-catalog.js +18 -6
- package/skills/wix-vibe-headless/references/storefront/seed/SEED.md +30 -7
- package/skills/wix-vibe-headless/references/storefront/seed/seed-store.js +46 -10
- package/skills/wix-app/references/editor-react-component/A11Y-REVIEW-REFERENCE.md +0 -172
- package/skills/wix-app/references/editor-react-component/A11Y-REVIEW.md +0 -143
- package/skills/wix-app/references/editor-react-component/COMPONENT-API.md +0 -516
- package/skills/wix-app/references/editor-react-component/COMPONENT-CONFIGURATION.md +0 -225
- package/skills/wix-app/references/editor-react-component/EDIT-FLOW.md +0 -6
- package/skills/wix-app/references/editor-react-component/REACT-PATTERNS.md +0 -95
- package/skills/wix-vibe-headless/references/storefront/app/components/ProductCard.jsx +0 -110
- package/skills/wix-vibe-headless/references/storefront/app/components/ProductGallery.jsx +0 -51
- package/skills/wix-vibe-headless/references/storefront/app/components/ProductGrid.jsx +0 -49
- package/skills/wix-vibe-headless/references/storefront/app/components/VariantPicker.jsx +0 -92
- package/skills/wix-vibe-headless/references/storefront/app/pages/ProductDetail.jsx +0 -139
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { wixApiRequest } from "./wix-client.js";
|
|
2
|
+
import { normalizePhone } from "./wix-forms.js";
|
|
3
|
+
import { targetOf, inputTypeOf, isMulti, isFile, isAddress, addressPartsOf, validationOf } from "@/lib/wix-form-schema-utils";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Wix Forms — the SUBMISSION: turn the form's values into the shape the API expects, create the
|
|
7
|
+
* submission, and map the server's per-field violations back onto controls. Same plain anonymous
|
|
8
|
+
* visitor token as the schema read in `wix-forms.js` — no SDK, no backend, no elevate.
|
|
9
|
+
*
|
|
10
|
+
* ⚠️ CRITICAL — the visitor token creates the submission, despite the spec. `CreateSubmission` is
|
|
11
|
+
* listed under the owner scope `SCOPE.DC-FORMS.MANAGE-SUBMISSIONS`, and in practice returns 200 on
|
|
12
|
+
* an anonymous visitor token: Wix grants implicit visitor access so a published site can submit its
|
|
13
|
+
* own forms. Reaching for a backend here is the most common wrong turn on this vertical.
|
|
14
|
+
*
|
|
15
|
+
* ⚠️ SUBMISSIONS ARE WRITE-ONLY FROM THE BROWSER. Reading them back
|
|
16
|
+
* (`querySubmissionsByNamespace`, `getSubmission`, `countSubmission`) genuinely requires the owner
|
|
17
|
+
* scope `WIX_FORMS.SUBMISSION_READ_ANY` and 403s for a visitor. The resolved `createSubmission`
|
|
18
|
+
* promise IS the success signal — show a thank-you; the submission appears in the owner's dashboard.
|
|
19
|
+
* A site that must LIST what visitors submitted needs the `cms` vertical instead.
|
|
20
|
+
*
|
|
21
|
+
* Submit values: https://dev.wix.com/docs/api-reference/crm/forms/form-submissions/about-submission-values.md
|
|
22
|
+
* Upload URL: https://dev.wix.com/docs/api-reference/crm/forms/form-submissions/get-media-upload-url.md
|
|
23
|
+
* Create: https://dev.wix.com/docs/api-reference/crm/forms/form-submissions/create-submission.md
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Submission statuses that mean the submission EXISTS — show the thank-you. `CONFIRMED` is recorded,
|
|
28
|
+
* `PENDING` is created but not recorded yet, and `PAYMENT_WAITING` is created on a form that also
|
|
29
|
+
* collects payment. See `createSubmission` for why this is an allowlist rather than a catch-all.
|
|
30
|
+
*/
|
|
31
|
+
export const SUBMITTED_OK = new Set(["CONFIRMED", "PENDING", "PAYMENT_WAITING"]);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get a signed URL to upload one file for a form submission — the FORMS-scoped wrapper around the
|
|
35
|
+
* Media Manager's upload URL, so a visitor can attach a file without the Manage-Media credential a
|
|
36
|
+
* direct `site-media` call would demand (that one 403s for a visitor; this one is listed under the
|
|
37
|
+
* same `SCOPE.FORMS.VIEW-FORM` as the schema read).
|
|
38
|
+
* Reference: https://dev.wix.com/docs/api-reference/crm/forms/form-submissions/get-media-upload-url.md
|
|
39
|
+
*
|
|
40
|
+
* @param {string} formId
|
|
41
|
+
* @param {string} filename Including the extension — Wix reads the type from it.
|
|
42
|
+
* @param {string} mimeType e.g. "image/png". A browser gives you `file.type`.
|
|
43
|
+
* @returns {Promise<string>} The signed upload URL.
|
|
44
|
+
*/
|
|
45
|
+
export async function getMediaUploadUrl(formId, filename, mimeType) {
|
|
46
|
+
const res = await wixApiRequest("/form-submission-service/v4/submissions/media-upload-url", {
|
|
47
|
+
method: "POST",
|
|
48
|
+
body: { formId, filename, mimeType },
|
|
49
|
+
});
|
|
50
|
+
if (!res?.uploadUrl) throw new Error(`Could not get an upload URL for "${filename}".`);
|
|
51
|
+
return res.uploadUrl;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Upload one `File` and return the value to submit for its field.
|
|
56
|
+
*
|
|
57
|
+
* ⚠️ The submission value IS the generated `uploadUrl` — not the CDN URL the upload responds with,
|
|
58
|
+
* and not a file id. That's Wix's own contract (see the "media file" example on Create Submission
|
|
59
|
+
* and the "Submit a form with media" sample flow): get the URL, PUT the bytes to it, then send that
|
|
60
|
+
* same URL as the field's value.
|
|
61
|
+
*
|
|
62
|
+
* The PUT goes straight to Wix's upload host on a signed URL, so it uses plain `fetch` — NOT
|
|
63
|
+
* `wixApiRequest`: adding the visitor's Authorization header to a pre-signed URL is what turns a
|
|
64
|
+
* working upload into a 400.
|
|
65
|
+
*
|
|
66
|
+
* @param {string} formId
|
|
67
|
+
* @param {File} file From an `<input type="file">`.
|
|
68
|
+
* @returns {Promise<string>} The value to put in the submission for this field.
|
|
69
|
+
*/
|
|
70
|
+
export async function uploadSubmissionFile(formId, file) {
|
|
71
|
+
// A browser leaves `type` empty for extensions it doesn't recognize; the generic type keeps the
|
|
72
|
+
// upload-URL call valid (Media Manager rejects a mime type that contradicts the extension).
|
|
73
|
+
const mimeType = file.type || "application/octet-stream";
|
|
74
|
+
const uploadUrl = await getMediaUploadUrl(formId, file.name, mimeType);
|
|
75
|
+
const res = await fetch(`${uploadUrl}?filename=${encodeURIComponent(file.name)}`, {
|
|
76
|
+
method: "PUT",
|
|
77
|
+
headers: { "Content-Type": mimeType },
|
|
78
|
+
body: file,
|
|
79
|
+
});
|
|
80
|
+
if (!res.ok) {
|
|
81
|
+
// Media Manager's own codes land here: FILE_SIZE_OVER_LIMIT, UNSUPPORTED_FILE_FORMAT,
|
|
82
|
+
// MISMATCH_MIME_TYPE, ZERO_FILE_SIZE, SITE_QUOTA_EXCEEDED.
|
|
83
|
+
throw new Error(`Could not upload "${file.name}" (${res.status}). Check its size and file type.`);
|
|
84
|
+
}
|
|
85
|
+
return uploadUrl;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Upload every `File` sitting in the form's state and return a copy of `values` with each file
|
|
90
|
+
* field replaced by its submitted value(s). Run this BEFORE `toSubmissionValues` — a `File` object
|
|
91
|
+
* is not something the submission API accepts.
|
|
92
|
+
*
|
|
93
|
+
* @param {string} formId
|
|
94
|
+
* @param {object[]} fields The render model.
|
|
95
|
+
* @param {Record<string, unknown>} values
|
|
96
|
+
* @returns {Promise<Record<string, unknown>>}
|
|
97
|
+
*/
|
|
98
|
+
export async function uploadFormFiles(formId, fields, values) {
|
|
99
|
+
const next = { ...values };
|
|
100
|
+
for (const field of fields) {
|
|
101
|
+
if (!isFile(field)) continue;
|
|
102
|
+
const target = targetOf(field);
|
|
103
|
+
const picked = [].concat(values[target] ?? []).filter((f) => f instanceof File);
|
|
104
|
+
const uploaded = [];
|
|
105
|
+
// Sequential on purpose: a visitor's uplink is the bottleneck, and a failed file should stop
|
|
106
|
+
// the submit rather than race three more uploads it will throw away.
|
|
107
|
+
for (const file of picked) uploaded.push(await uploadSubmissionFile(formId, file));
|
|
108
|
+
next[target] = uploaded;
|
|
109
|
+
}
|
|
110
|
+
return next;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Turn the form's state into the `submissions` map `createSubmission` expects — keyed by each
|
|
115
|
+
* field's `target`, which is the same key the controls are bound to, so the keys come out right by
|
|
116
|
+
* construction with no hand-maintained list to drift.
|
|
117
|
+
*
|
|
118
|
+
* Walks the SCHEMA, not the state object: a stray key in `values` can never reach the API, and a
|
|
119
|
+
* field the owner added shows up the moment the schema does.
|
|
120
|
+
*
|
|
121
|
+
* The three value shapes and their per-`inputType` rules
|
|
122
|
+
* (https://dev.wix.com/docs/api-reference/crm/forms/form-submissions/about-submission-values.md):
|
|
123
|
+
* • flat value — text / dropdown / radio / date / time. NUMBER submits a number and PHONE the
|
|
124
|
+
* normalized E.164 string, never the raw control text.
|
|
125
|
+
* • ARRAY — a multi-choice field, holding the checked option values.
|
|
126
|
+
* • OBJECT — an ADDRESS, keyed by subfield (`city`, `country`, …), which is also the shape
|
|
127
|
+
* behind the server's nested `address/city` error paths.
|
|
128
|
+
* An empty optional field is OMITTED rather than sent as "" — the server validates what it's given.
|
|
129
|
+
*
|
|
130
|
+
* @param {object[]} fields The render model, from `hooks/useWixForm.js`.
|
|
131
|
+
* @param {Record<string, unknown>} values The form's state, keyed by `target`.
|
|
132
|
+
* @returns {Record<string, unknown>}
|
|
133
|
+
*/
|
|
134
|
+
export function toSubmissionValues(fields, values) {
|
|
135
|
+
const filled = (v) => v !== undefined && v !== null && String(v).trim() !== "";
|
|
136
|
+
const out = {};
|
|
137
|
+
for (const field of fields) {
|
|
138
|
+
const target = targetOf(field);
|
|
139
|
+
const raw = values?.[target];
|
|
140
|
+
|
|
141
|
+
if (isAddress(field)) {
|
|
142
|
+
const parts = {};
|
|
143
|
+
for (const { sub } of addressPartsOf(field)) {
|
|
144
|
+
if (filled(raw?.[sub])) parts[sub] = String(raw[sub]).trim();
|
|
145
|
+
}
|
|
146
|
+
if (Object.keys(parts).length) out[target] = parts;
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (isMulti(field)) {
|
|
151
|
+
const picked = (Array.isArray(raw) ? raw : []).filter(filled);
|
|
152
|
+
if (picked.length) out[target] = picked;
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// A file field carries what `uploadFormFiles` produced — the upload URL(s). One file submits the
|
|
157
|
+
// bare string (the shape Wix's own example uses); several submit an array. A stray `File` that
|
|
158
|
+
// never went through the upload is dropped rather than sent, since it would 400 the whole form.
|
|
159
|
+
if (isFile(field)) {
|
|
160
|
+
const urls = [].concat(raw ?? []).filter((v) => typeof v === "string" && v);
|
|
161
|
+
if (urls.length) out[target] = urls.length === 1 ? urls[0] : urls;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (!filled(raw)) continue;
|
|
166
|
+
const value = typeof raw === "string" ? raw.trim() : raw;
|
|
167
|
+
out[target] =
|
|
168
|
+
inputTypeOf(field) === "NUMBER" ? Number(value) :
|
|
169
|
+
validationOf(field).format === "PHONE" ? normalizePhone(value) : value;
|
|
170
|
+
}
|
|
171
|
+
return out;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Create a submission. This is the write — and the ONLY confirmation you get, since a visitor can't
|
|
176
|
+
* read submissions back.
|
|
177
|
+
* Reference: https://dev.wix.com/docs/api-reference/crm/forms/form-submissions/create-submission.md
|
|
178
|
+
*
|
|
179
|
+
* ⚠️ EVERY status this resolves on is a created submission — `CONFIRMED` (recorded), `PENDING`
|
|
180
|
+
* (created, not recorded yet) and `PAYMENT_WAITING` (created on a form that also collects payment).
|
|
181
|
+
* Show the thank-you for all three. Treating one as a failure invites the visitor to submit again,
|
|
182
|
+
* which costs the owner duplicate entries for a submission that already exists.
|
|
183
|
+
*
|
|
184
|
+
* `PAYMENT_WAITING` still leaves the visitor a payment step, but the SUBMIT succeeded — surface the
|
|
185
|
+
* payment inside the success state, never as a failed submission. A form only reaches this status if
|
|
186
|
+
* the UI rendered a PAYMENT field, so read the returned `status` when you build one.
|
|
187
|
+
* Success stays an ALLOWLIST rather than a catch-all, so a status added to the enum later can't
|
|
188
|
+
* silently render a thank-you for something that isn't a submission.
|
|
189
|
+
*
|
|
190
|
+
* ⚠️ REST returns `submission.id` — the SDK's normalized `_id` does not exist here.
|
|
191
|
+
*
|
|
192
|
+
* @param {string} formId
|
|
193
|
+
* @param {Record<string, unknown>} values Map of `target` → value, from `toSubmissionValues`.
|
|
194
|
+
* @returns {Promise<{ id: string, status: string }>}
|
|
195
|
+
*/
|
|
196
|
+
export async function createSubmission(formId, values) {
|
|
197
|
+
const res = await wixApiRequest("/form-submission-service/v4/submissions", {
|
|
198
|
+
method: "POST",
|
|
199
|
+
body: { submission: { formId, submissions: values } },
|
|
200
|
+
});
|
|
201
|
+
const submission = res?.submission;
|
|
202
|
+
if (!submission?.id) throw new Error("Submission failed (no submission returned).");
|
|
203
|
+
if (!SUBMITTED_OK.has(submission.status)) {
|
|
204
|
+
throw new Error(
|
|
205
|
+
`Submission status is "${submission.status}" — not one of the statuses that mean the ` +
|
|
206
|
+
`submission was created (${[...SUBMITTED_OK].join(", ")}), so don't show a success state. ` +
|
|
207
|
+
`Check the Submission status docs before adding it to SUBMITTED_OK.`,
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
return { id: submission.id, status: submission.status };
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Pull the per-field violations out of a failed `createSubmission`.
|
|
215
|
+
*
|
|
216
|
+
* The documented entries (`errorPath`, `errorType`, `errorMessage`, `params`) arrive under
|
|
217
|
+
* `details.validationError.fieldViolations[]`, each with its own nested `data.errors[]` array —
|
|
218
|
+
* two levels deeper than the docs' shape. This flattens that; turning a violation into words a
|
|
219
|
+
* visitor should read is the UI's job (`mapSubmissionErrors` in `hooks/useWixForm.js`).
|
|
220
|
+
*
|
|
221
|
+
* `errorPath` is the field's `target`, or a nested path like `address/subdivision` or
|
|
222
|
+
* `attachments/0/fileId` — which is exactly how the controls are named, so it maps straight across.
|
|
223
|
+
*
|
|
224
|
+
* Reference: https://dev.wix.com/docs/api-reference/crm/forms/form-submissions/introduction#validation-errors
|
|
225
|
+
*
|
|
226
|
+
* @param {Error & { body?: object }} err From `createSubmission`; the REST body is on `err.body`.
|
|
227
|
+
* @returns {{ errorPath: string, errorType: string, errorMessage?: string }[]} Empty when the
|
|
228
|
+
* failure wasn't a validation error at all (a network drop, a 500).
|
|
229
|
+
*/
|
|
230
|
+
export function submissionViolations(err) {
|
|
231
|
+
const violations =
|
|
232
|
+
err?.body?.details?.validationError?.fieldViolations ??
|
|
233
|
+
err?.details?.validationError?.fieldViolations ??
|
|
234
|
+
[];
|
|
235
|
+
return violations
|
|
236
|
+
.flatMap((violation) => violation.data?.errors ?? [violation])
|
|
237
|
+
.filter((entry) => entry?.errorPath);
|
|
238
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { wixApiRequest } from "./wix-client.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wix Forms — the form SCHEMA: read a form, on the plain anonymous visitor token this skill already
|
|
5
|
+
* mints. No SDK, no backend, no elevate. **The write path lives next door in
|
|
6
|
+
* `wix-forms-submissions.js`.**
|
|
7
|
+
*
|
|
8
|
+
* WHY THIS VERTICAL EXISTS: a visitor-fillable form is Wix Forms, not a CMS collection. The owner
|
|
9
|
+
* edits fields in the Wix dashboard, submissions land in their Forms inbox with spam protection
|
|
10
|
+
* and notifications, and the frontend re-renders from the live schema with no code change.
|
|
11
|
+
* Use `cms` only for content the app itself stores and READS BACK (listings, galleries, "my items").
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ CRITICAL — the visitor token is enough, and the docs say otherwise. The API spec lists every
|
|
14
|
+
* schema read (`GetForm`/`ListForms`) under the owner scope `SCOPE.FORMS.VIEW-FORM`. In practice
|
|
15
|
+
* they return 200 on an anonymous visitor token — Wix grants implicit visitor access so a published
|
|
16
|
+
* site can render its own forms. Trust the live 200, not the permission table. Do NOT add a backend,
|
|
17
|
+
* a connector token, or any elevated credential to make a form work.
|
|
18
|
+
*
|
|
19
|
+
* READING the schema is `lib/wix-form-schema-utils.js` (plain accessors over the raw fields) and checking
|
|
20
|
+
* values against it is `hooks/useWixForm.js`. This file stays the transport, plus the phone helpers
|
|
21
|
+
* both sides need — `normalizePhone` for the value that goes on the wire, `phoneExample` for the one
|
|
22
|
+
* shown to a visitor.
|
|
23
|
+
*
|
|
24
|
+
* Form object: https://dev.wix.com/docs/api-reference/crm/forms/form-schemas/form-object.md
|
|
25
|
+
* Form fields: https://dev.wix.com/docs/api-reference/crm/forms/form-schemas/about-form-fields.md
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/** The Wix Forms app namespace. Every form this vertical touches lives here. */
|
|
29
|
+
export const FORMS_NAMESPACE = "wix.form_app.form";
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Read one form schema by id. Returns the `Form` directly (the REST envelope's `form` is unwrapped
|
|
33
|
+
* for you), or throws — a 404 `FORM_NOT_FOUND` means the id is wrong or the form was deleted.
|
|
34
|
+
* Reference: https://dev.wix.com/docs/api-reference/crm/forms/form-schemas/get-form.md
|
|
35
|
+
*
|
|
36
|
+
* @param {string} formId The form's GUID (from the seed's `seeded.forms[].formId`).
|
|
37
|
+
* @returns {Promise<object>} The Form: `{ id, formFields[], steps[], … }`.
|
|
38
|
+
*/
|
|
39
|
+
export async function getForm(formId) {
|
|
40
|
+
const res = await wixApiRequest(`/form-schema-service/v4/forms/${encodeURIComponent(formId)}`, {
|
|
41
|
+
method: "GET",
|
|
42
|
+
});
|
|
43
|
+
const form = res?.form;
|
|
44
|
+
if (!form) throw new Error(`Form "${formId}" not found.`);
|
|
45
|
+
return form;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* List form schemas in the namespace. Use ONE call for several forms on a page rather than one
|
|
50
|
+
* `getForm` each; pass no `formIds` to discover every form the site has.
|
|
51
|
+
* Reference: https://dev.wix.com/docs/api-reference/crm/forms/form-schemas/list-forms.md
|
|
52
|
+
*
|
|
53
|
+
* ⚠️ Returns only ENABLED forms by default — a form the owner disabled silently vanishes from a
|
|
54
|
+
* discovery listing rather than erroring. That's usually right for a public site.
|
|
55
|
+
*
|
|
56
|
+
* @param {{ formIds?: string[], namespace?: string }} [options] `formIds` takes up to 100 ids.
|
|
57
|
+
* @returns {Promise<object[]>} Array of Form objects (the envelope's `forms`, unwrapped).
|
|
58
|
+
*/
|
|
59
|
+
export async function listForms({ formIds, namespace = FORMS_NAMESPACE } = {}) {
|
|
60
|
+
const res = await wixApiRequest("/form-schema-service/v4/forms", {
|
|
61
|
+
method: "GET",
|
|
62
|
+
query: { namespace, ...(formIds?.length ? { formIds } : {}) },
|
|
63
|
+
});
|
|
64
|
+
return res?.forms ?? [];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Phone examples shown to visitors (placeholder + error copy). Every value is a regulator-RESERVED
|
|
69
|
+
* fictional number for that country, so no real subscriber is ever printed.
|
|
70
|
+
*
|
|
71
|
+
* ⚠️ Never hardcode a user-visible example to one locale — a `+44`- or US-shaped example on a site
|
|
72
|
+
* in another market is a locale bug. Add a market only after verifying its reserved range in the
|
|
73
|
+
* national numbering plan; never invent a number. Never SUBMIT one either: a reserved number is
|
|
74
|
+
* rejected (see `validateField` in `hooks/useWixForm.js`), so these are display-only.
|
|
75
|
+
*/
|
|
76
|
+
export const PHONE_EXAMPLE = {
|
|
77
|
+
US: "+1 201 555 0123", CA: "+1 416 555 0123", // NANP 555-0100–0199 reserved for fiction
|
|
78
|
+
GB: "+44 7700 900123", // Ofcom drama range 07700 900xxx
|
|
79
|
+
IE: "+353 20 910 0001", // ComReg reserved 020 91x xxxx
|
|
80
|
+
AU: "+61 491 570 006", // ACMA reserved mobile range
|
|
81
|
+
FR: "+33 1 99 00 00 01", // ARCEP Île-de-France 01 99 00 xx xx reserved
|
|
82
|
+
DE: "+49 30 23125 000", // BNetzA Berlin 030 23125 xxx reserved
|
|
83
|
+
SE: "+46 70 174 06 05", // PTS reserved 070 174 06xx
|
|
84
|
+
KR: "+82 2 540 0000", // Seoul 02-540-xxxx reserved
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The site's country (ISO-3166 alpha-2), used for any locale-derived example. Set it once from the
|
|
89
|
+
* business you're building for — the browser's own locale is the VISITOR's, not the site's.
|
|
90
|
+
* @type {string}
|
|
91
|
+
*/
|
|
92
|
+
export let SITE_COUNTRY = "US";
|
|
93
|
+
/** Set the site's country once at app start, e.g. `setSiteCountry("GB")`. */
|
|
94
|
+
export function setSiteCountry(code) {
|
|
95
|
+
if (code) SITE_COUNTRY = code.toUpperCase();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The example phone number for a country (ISO-3166 alpha-2), falling back to the site's and then to
|
|
100
|
+
* the US. Pass a PHONE field's own country when it has one — `phoneCountryOf(field)` in
|
|
101
|
+
* `lib/wix-form-schema-utils.js` reads it — so the example shown is one that field would accept.
|
|
102
|
+
*/
|
|
103
|
+
export function phoneExample(country) {
|
|
104
|
+
return PHONE_EXAMPLE[country ?? SITE_COUNTRY] ?? PHONE_EXAMPLE[SITE_COUNTRY] ?? PHONE_EXAMPLE.US;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Strip visitor-added formatting from a phone number — submit this, not the raw value. */
|
|
108
|
+
export const normalizePhone = (v) => String(v ?? "").replace(/[\s()\-.]/g, "");
|