create-businessdash 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +125 -2
- package/dist/index.mjs +3672 -0
- package/index.js +2 -0
- package/package.json +40 -5
- package/templates/angular/.claude/CLAUDE.md +54 -0
- package/templates/angular/.cursor/rules/cursor.mdc +60 -0
- package/templates/angular/.editorconfig +17 -0
- package/templates/angular/.env.example +62 -0
- package/templates/angular/.prettierrc +12 -0
- package/templates/angular/.vscode/extensions.json +4 -0
- package/templates/angular/.vscode/launch.json +20 -0
- package/templates/angular/.vscode/mcp.json +9 -0
- package/templates/angular/.vscode/tasks.json +42 -0
- package/templates/angular/AGENTS.md +54 -0
- package/templates/angular/README.md +382 -0
- package/templates/angular/_gitignore +49 -0
- package/templates/angular/angular.json +93 -0
- package/templates/angular/bd.config.ts +331 -0
- package/templates/angular/bd.data-model.config.ts +89 -0
- package/templates/angular/package.json +60 -0
- package/templates/angular/pnpm-lock.yaml +5506 -0
- package/templates/angular/public/favicon.ico +0 -0
- package/templates/angular/src/app/app.config.server.ts +10 -0
- package/templates/angular/src/app/app.config.ts +48 -0
- package/templates/angular/src/app/app.html +7 -0
- package/templates/angular/src/app/app.routes.server.ts +14 -0
- package/templates/angular/src/app/app.routes.ts +69 -0
- package/templates/angular/src/app/app.scss +5 -0
- package/templates/angular/src/app/app.spec.ts +25 -0
- package/templates/angular/src/app/app.ts +27 -0
- package/templates/angular/src/app/lib/bd-api.client.ts +416 -0
- package/templates/angular/src/app/lib/bd-forms.client.ts +107 -0
- package/templates/angular/src/app/lib/bd.service.ts +145 -0
- package/templates/angular/src/app/lib/followers.service.ts +143 -0
- package/templates/angular/src/app/pages/booking.page.ts +142 -0
- package/templates/angular/src/app/pages/cart.page.ts +131 -0
- package/templates/angular/src/app/pages/home.page.ts +37 -0
- package/templates/angular/src/app/pages/my-account.page.ts +197 -0
- package/templates/angular/src/app/pages/product-detail.page.ts +217 -0
- package/templates/angular/src/app/pages/reviews.page.ts +89 -0
- package/templates/angular/src/app/pages/service-area.page.ts +86 -0
- package/templates/angular/src/app/pages/services-index.page.ts +49 -0
- package/templates/angular/src/app/pages/store.page.ts +422 -0
- package/templates/angular/src/app/pages/subscriptions.page.ts +102 -0
- package/templates/angular/src/app/pages/todos.page.ts +194 -0
- package/templates/angular/src/app/pages/updates.page.ts +45 -0
- package/templates/angular/src/app/sections/about.component.ts +24 -0
- package/templates/angular/src/app/sections/blog.component.ts +33 -0
- package/templates/angular/src/app/sections/contact-form.component.ts +51 -0
- package/templates/angular/src/app/sections/footer.component.ts +14 -0
- package/templates/angular/src/app/sections/header.component.ts +36 -0
- package/templates/angular/src/app/sections/hero.component.ts +21 -0
- package/templates/angular/src/app/sections/news-banner.component.ts +50 -0
- package/templates/angular/src/app/sections/reviews-summary.component.ts +41 -0
- package/templates/angular/src/app/sections/sdk-setup-banner.component.ts +125 -0
- package/templates/angular/src/app/sections/services.component.ts +27 -0
- package/templates/angular/src/app/sections/subscribe.component.ts +140 -0
- package/templates/angular/src/app/sections/updates.component.ts +38 -0
- package/templates/angular/src/environments/environment.prod.ts +13 -0
- package/templates/angular/src/environments/environment.ts +23 -0
- package/templates/angular/src/index.html +13 -0
- package/templates/angular/src/main.server.ts +7 -0
- package/templates/angular/src/main.ts +5 -0
- package/templates/angular/src/server/bd-api.ts +1098 -0
- package/templates/angular/src/server/bd-seo.ts +55 -0
- package/templates/angular/src/server/bd-server.ts +293 -0
- package/templates/angular/src/server.ts +94 -0
- package/templates/angular/src/styles.scss +1102 -0
- package/templates/angular/tsconfig.app.json +11 -0
- package/templates/angular/tsconfig.json +33 -0
- package/templates/angular/tsconfig.spec.json +10 -0
- package/templates/astro/.env.example +48 -0
- package/templates/astro/.vscode/extensions.json +4 -0
- package/templates/astro/.vscode/launch.json +11 -0
- package/templates/astro/README.md +432 -0
- package/templates/astro/_gitignore +25 -0
- package/templates/astro/astro.config.mjs +13 -0
- package/templates/astro/bd.config.ts +331 -0
- package/templates/astro/bd.data-model.config.ts +90 -0
- package/templates/astro/package.json +40 -0
- package/templates/astro/pnpm-lock.yaml +3788 -0
- package/templates/astro/public/favicon.ico +0 -0
- package/templates/astro/public/favicon.svg +9 -0
- package/templates/astro/src/components/About.astro +59 -0
- package/templates/astro/src/components/Banner.astro +78 -0
- package/templates/astro/src/components/Blog.astro +62 -0
- package/templates/astro/src/components/Booking.astro +285 -0
- package/templates/astro/src/components/ContactForm.astro +89 -0
- package/templates/astro/src/components/ContactForm.tsx +80 -0
- package/templates/astro/src/components/Footer.astro +39 -0
- package/templates/astro/src/components/Gallery.astro +77 -0
- package/templates/astro/src/components/Header.astro +65 -0
- package/templates/astro/src/components/Hero.astro +45 -0
- package/templates/astro/src/components/NotFound.astro +22 -0
- package/templates/astro/src/components/Reviews.astro +169 -0
- package/templates/astro/src/components/SdkSetupBanner.astro +83 -0
- package/templates/astro/src/components/Services.astro +87 -0
- package/templates/astro/src/components/Subscribe.astro +196 -0
- package/templates/astro/src/components/Subscribe.tsx +171 -0
- package/templates/astro/src/layouts/Layout.astro +89 -0
- package/templates/astro/src/lib/bd-bundle.ts +113 -0
- package/templates/astro/src/lib/bd-distribution.ts +36 -0
- package/templates/astro/src/lib/bd-portal.ts +158 -0
- package/templates/astro/src/lib/bd-seo.ts +81 -0
- package/templates/astro/src/lib/bd-store.ts +185 -0
- package/templates/astro/src/lib/bd-suspension.ts +67 -0
- package/templates/astro/src/lib/bd-todos.ts +124 -0
- package/templates/astro/src/lib/bd.ts +73 -0
- package/templates/astro/src/pages/.well-known/mcp.json.ts +22 -0
- package/templates/astro/src/pages/404.astro +15 -0
- package/templates/astro/src/pages/[...slug].astro +50 -0
- package/templates/astro/src/pages/ai/product-feed.ts +25 -0
- package/templates/astro/src/pages/api/bd/cart/add.ts +41 -0
- package/templates/astro/src/pages/api/bd/cart/clear.ts +29 -0
- package/templates/astro/src/pages/api/bd/cart/coupon.ts +35 -0
- package/templates/astro/src/pages/api/bd/cart/get.ts +28 -0
- package/templates/astro/src/pages/api/bd/cart/remove.ts +33 -0
- package/templates/astro/src/pages/api/bd/cart/update.ts +41 -0
- package/templates/astro/src/pages/api/bd/checkout/start.ts +37 -0
- package/templates/astro/src/pages/api/bd/forms/[slug].ts +75 -0
- package/templates/astro/src/pages/api/bd/portal/plan.ts +31 -0
- package/templates/astro/src/pages/api/bd/portal/submit-review.ts +56 -0
- package/templates/astro/src/pages/api/bd/revalidate.ts +49 -0
- package/templates/astro/src/pages/api/bd/reviews.ts +39 -0
- package/templates/astro/src/pages/api/bd/scheduling/bookings.ts +44 -0
- package/templates/astro/src/pages/api/bd/scheduling/slots.ts +40 -0
- package/templates/astro/src/pages/api/bd/subscriptions/checkout.ts +29 -0
- package/templates/astro/src/pages/api/bd-auth/[...slug].ts +61 -0
- package/templates/astro/src/pages/api/mcp.ts +40 -0
- package/templates/astro/src/pages/index.astro +47 -0
- package/templates/astro/src/pages/llms.txt.ts +25 -0
- package/templates/astro/src/pages/my-account.astro +388 -0
- package/templates/astro/src/pages/reviews.astro +18 -0
- package/templates/astro/src/pages/robots.txt.ts +46 -0
- package/templates/astro/src/pages/services/[service]/[area].astro +103 -0
- package/templates/astro/src/pages/services/index.astro +104 -0
- package/templates/astro/src/pages/sitemap.xml.ts +89 -0
- package/templates/astro/src/pages/store/[id].astro +208 -0
- package/templates/astro/src/pages/store/cart.astro +458 -0
- package/templates/astro/src/pages/store/index.astro +567 -0
- package/templates/astro/src/pages/store/subscriptions.astro +155 -0
- package/templates/astro/src/pages/todos.astro +199 -0
- package/templates/astro/src/pages/updates.astro +135 -0
- package/templates/astro/src/styles/global.css +631 -0
- package/templates/astro/tsconfig.json +8 -0
- package/templates/elixir/.env.example +58 -0
- package/templates/elixir/README.md +293 -0
- package/templates/elixir/_gitignore +16 -0
- package/templates/elixir/assets/js/app.js +16 -0
- package/templates/elixir/bd-records/README.md +50 -0
- package/templates/elixir/bd-records/todo-images.json +14 -0
- package/templates/elixir/bd-records/todos.json +20 -0
- package/templates/elixir/bd.config.ts +331 -0
- package/templates/elixir/bd.data-model.config.ts +89 -0
- package/templates/elixir/config/config.exs +30 -0
- package/templates/elixir/config/dev.exs +20 -0
- package/templates/elixir/config/prod.exs +6 -0
- package/templates/elixir/config/runtime.exs +68 -0
- package/templates/elixir/config/test.exs +9 -0
- package/templates/elixir/lib/bd_starter/application.ex +29 -0
- package/templates/elixir/lib/bd_starter/bd/auth.ex +126 -0
- package/templates/elixir/lib/bd_starter/bd/cache.ex +148 -0
- package/templates/elixir/lib/bd_starter/bd/chat_session.ex +214 -0
- package/templates/elixir/lib/bd_starter/bd/client.ex +203 -0
- package/templates/elixir/lib/bd_starter/bd/customer_auth.ex +116 -0
- package/templates/elixir/lib/bd_starter/bd/resources/blog.ex +18 -0
- package/templates/elixir/lib/bd_starter/bd/resources/cart.ex +40 -0
- package/templates/elixir/lib/bd_starter/bd/resources/checkout.ex +22 -0
- package/templates/elixir/lib/bd_starter/bd/resources/data_model.ex +53 -0
- package/templates/elixir/lib/bd_starter/bd/resources/donations.ex +50 -0
- package/templates/elixir/lib/bd_starter/bd/resources/followers.ex +25 -0
- package/templates/elixir/lib/bd_starter/bd/resources/forms.ex +29 -0
- package/templates/elixir/lib/bd_starter/bd/resources/marketing.ex +20 -0
- package/templates/elixir/lib/bd_starter/bd/resources/notifications.ex +87 -0
- package/templates/elixir/lib/bd_starter/bd/resources/parallel_pages.ex +21 -0
- package/templates/elixir/lib/bd_starter/bd/resources/portal.ex +153 -0
- package/templates/elixir/lib/bd_starter/bd/resources/reviews.ex +8 -0
- package/templates/elixir/lib/bd_starter/bd/resources/scheduling.ex +122 -0
- package/templates/elixir/lib/bd_starter/bd/resources/storefront.ex +47 -0
- package/templates/elixir/lib/bd_starter/bd/resources/subscriptions.ex +13 -0
- package/templates/elixir/lib/bd_starter/bd/seo.ex +148 -0
- package/templates/elixir/lib/bd_starter/bd/sign_in_core.ex +258 -0
- package/templates/elixir/lib/bd_starter/bd/social_platforms.ex +46 -0
- package/templates/elixir/lib/bd_starter/bd/socials.ex +99 -0
- package/templates/elixir/lib/bd_starter/bd/webhook.ex +89 -0
- package/templates/elixir/lib/bd_starter/bd.ex +156 -0
- package/templates/elixir/lib/bd_starter/forms/backend.ex +74 -0
- package/templates/elixir/lib/bd_starter/forms/calculation.ex +158 -0
- package/templates/elixir/lib/bd_starter/forms/dates.ex +151 -0
- package/templates/elixir/lib/bd_starter/forms/field.ex +211 -0
- package/templates/elixir/lib/bd_starter/forms/field_path.ex +18 -0
- package/templates/elixir/lib/bd_starter/forms/form_controller.ex +615 -0
- package/templates/elixir/lib/bd_starter/forms/form_view.ex +339 -0
- package/templates/elixir/lib/bd_starter/forms/forms.ex +37 -0
- package/templates/elixir/lib/bd_starter/forms/forms_data.ex +298 -0
- package/templates/elixir/lib/bd_starter/forms/formula.ex +602 -0
- package/templates/elixir/lib/bd_starter/forms/formula_parser.ex +197 -0
- package/templates/elixir/lib/bd_starter/forms/js.ex +501 -0
- package/templates/elixir/lib/bd_starter/forms/json.ex +103 -0
- package/templates/elixir/lib/bd_starter/forms/messages.ex +95 -0
- package/templates/elixir/lib/bd_starter/forms/package_backend.ex +175 -0
- package/templates/elixir/lib/bd_starter/forms/quiz_arrange.ex +120 -0
- package/templates/elixir/lib/bd_starter/forms/quiz_backend.ex +14 -0
- package/templates/elixir/lib/bd_starter/forms/quiz_config.ex +51 -0
- package/templates/elixir/lib/bd_starter/forms/quiz_controller.ex +188 -0
- package/templates/elixir/lib/bd_starter/forms/quiz_engine.ex +682 -0
- package/templates/elixir/lib/bd_starter/forms/quiz_options.ex +99 -0
- package/templates/elixir/lib/bd_starter/forms/quiz_page.ex +93 -0
- package/templates/elixir/lib/bd_starter/forms/quiz_runs.ex +44 -0
- package/templates/elixir/lib/bd_starter/forms/quiz_scoring.ex +397 -0
- package/templates/elixir/lib/bd_starter/forms/quiz_state.ex +68 -0
- package/templates/elixir/lib/bd_starter/forms/quiz_words.ex +101 -0
- package/templates/elixir/lib/bd_starter/forms/quizzes.ex +98 -0
- package/templates/elixir/lib/bd_starter/forms/re.ex +22 -0
- package/templates/elixir/lib/bd_starter/forms/rules.ex +1355 -0
- package/templates/elixir/lib/bd_starter/forms/sample_backend.ex +44 -0
- package/templates/elixir/lib/bd_starter/forms/schema.ex +50 -0
- package/templates/elixir/lib/bd_starter/forms/submit_result.ex +60 -0
- package/templates/elixir/lib/bd_starter/forms/units.ex +75 -0
- package/templates/elixir/lib/bd_starter_web/bundle.ex +27 -0
- package/templates/elixir/lib/bd_starter_web/components/form_components.ex +779 -0
- package/templates/elixir/lib/bd_starter_web/components/layouts/app.html.heex +50 -0
- package/templates/elixir/lib/bd_starter_web/components/layouts/root.html.heex +24 -0
- package/templates/elixir/lib/bd_starter_web/components/layouts.ex +6 -0
- package/templates/elixir/lib/bd_starter_web/controllers/bd_auth_controller.ex +144 -0
- package/templates/elixir/lib/bd_starter_web/controllers/bd_customer_auth_controller.ex +224 -0
- package/templates/elixir/lib/bd_starter_web/controllers/blog_controller.ex +28 -0
- package/templates/elixir/lib/bd_starter_web/controllers/blog_html/index.html.heex +10 -0
- package/templates/elixir/lib/bd_starter_web/controllers/blog_html/show.html.heex +20 -0
- package/templates/elixir/lib/bd_starter_web/controllers/blog_html.ex +6 -0
- package/templates/elixir/lib/bd_starter_web/controllers/cart_controller.ex +140 -0
- package/templates/elixir/lib/bd_starter_web/controllers/cart_html/show.html.heex +42 -0
- package/templates/elixir/lib/bd_starter_web/controllers/cart_html.ex +6 -0
- package/templates/elixir/lib/bd_starter_web/controllers/error_html.ex +8 -0
- package/templates/elixir/lib/bd_starter_web/controllers/form_page_controller.ex +77 -0
- package/templates/elixir/lib/bd_starter_web/controllers/form_page_html/form.html.heex +2 -0
- package/templates/elixir/lib/bd_starter_web/controllers/form_page_html/quiz.html.heex +4 -0
- package/templates/elixir/lib/bd_starter_web/controllers/form_page_html.ex +5 -0
- package/templates/elixir/lib/bd_starter_web/controllers/page_controller.ex +56 -0
- package/templates/elixir/lib/bd_starter_web/controllers/page_html/home.html.heex +53 -0
- package/templates/elixir/lib/bd_starter_web/controllers/page_html/reviews.html.heex +10 -0
- package/templates/elixir/lib/bd_starter_web/controllers/page_html/updates.html.heex +8 -0
- package/templates/elixir/lib/bd_starter_web/controllers/page_html.ex +6 -0
- package/templates/elixir/lib/bd_starter_web/controllers/portal_controller.ex +109 -0
- package/templates/elixir/lib/bd_starter_web/controllers/portal_html/delete_account.html.heex +31 -0
- package/templates/elixir/lib/bd_starter_web/controllers/portal_html/index.html.heex +29 -0
- package/templates/elixir/lib/bd_starter_web/controllers/portal_html/sign_in.html.heex +18 -0
- package/templates/elixir/lib/bd_starter_web/controllers/portal_html.ex +6 -0
- package/templates/elixir/lib/bd_starter_web/controllers/seo_controller.ex +87 -0
- package/templates/elixir/lib/bd_starter_web/controllers/service_area_controller.ex +14 -0
- package/templates/elixir/lib/bd_starter_web/controllers/service_area_html/index.html.heex +12 -0
- package/templates/elixir/lib/bd_starter_web/controllers/service_area_html/show.html.heex +4 -0
- package/templates/elixir/lib/bd_starter_web/controllers/service_area_html.ex +6 -0
- package/templates/elixir/lib/bd_starter_web/controllers/store_controller.ex +34 -0
- package/templates/elixir/lib/bd_starter_web/controllers/store_html/index.html.heex +31 -0
- package/templates/elixir/lib/bd_starter_web/controllers/store_html/show.html.heex +29 -0
- package/templates/elixir/lib/bd_starter_web/controllers/store_html.ex +6 -0
- package/templates/elixir/lib/bd_starter_web/controllers/subscription_controller.ex +31 -0
- package/templates/elixir/lib/bd_starter_web/controllers/subscription_html/index.html.heex +14 -0
- package/templates/elixir/lib/bd_starter_web/controllers/subscription_html.ex +6 -0
- package/templates/elixir/lib/bd_starter_web/controllers/todos_controller.ex +58 -0
- package/templates/elixir/lib/bd_starter_web/controllers/todos_html/index.html.heex +38 -0
- package/templates/elixir/lib/bd_starter_web/controllers/todos_html.ex +6 -0
- package/templates/elixir/lib/bd_starter_web/controllers/webhook_controller.ex +30 -0
- package/templates/elixir/lib/bd_starter_web/endpoint.ex +40 -0
- package/templates/elixir/lib/bd_starter_web/live/chat_live.ex +113 -0
- package/templates/elixir/lib/bd_starter_web/live/form_live.ex +431 -0
- package/templates/elixir/lib/bd_starter_web/live/quiz_live.ex +532 -0
- package/templates/elixir/lib/bd_starter_web/live/sign_in_live.ex +533 -0
- package/templates/elixir/lib/bd_starter_web/money.ex +50 -0
- package/templates/elixir/lib/bd_starter_web/plugs/cache_body_reader.ex +33 -0
- package/templates/elixir/lib/bd_starter_web/router.ex +110 -0
- package/templates/elixir/lib/bd_starter_web.ex +75 -0
- package/templates/elixir/mix.exs +42 -0
- package/templates/elixir/package.json +20 -0
- package/templates/elixir/pnpm-lock.yaml +347 -0
- package/templates/elixir/priv/forms/demo-form.json +283 -0
- package/templates/elixir/priv/forms/demo-quiz.json +97 -0
- package/templates/elixir/priv/static/assets/app.css +113 -0
- package/templates/elixir/priv/static/bd-sign-in.css +51 -0
- package/templates/elixir/priv/static/forms.css +1153 -0
- package/templates/elixir/test/fixtures/forms-parity.json +3806 -0
- package/templates/elixir/test/fixtures/quiz-parity.json +9937 -0
- package/templates/elixir/test/form_controller_test.exs +314 -0
- package/templates/elixir/test/forms_parity_test.exs +206 -0
- package/templates/elixir/test/quiz_parity_test.exs +243 -0
- package/templates/elixir/test/support/parity.ex +46 -0
- package/templates/elixir/test/test_helper.exs +1 -0
- package/templates/elixir/tsconfig.json +19 -0
- package/templates/flutter/README.md +321 -0
- package/templates/flutter/_gitignore +9 -0
- package/templates/flutter/analysis_options.yaml +8 -0
- package/templates/flutter/bd-records/README.md +50 -0
- package/templates/flutter/bd-records/todo-images.json +14 -0
- package/templates/flutter/bd-records/todos.json +20 -0
- package/templates/flutter/bd.config.ts +331 -0
- package/templates/flutter/bd.data-model.config.ts +89 -0
- package/templates/flutter/lib/forms/demo_form.dart +289 -0
- package/templates/flutter/lib/forms/demo_quiz.dart +104 -0
- package/templates/flutter/lib/forms/form_hooks.dart +147 -0
- package/templates/flutter/lib/main.dart +120 -0
- package/templates/flutter/lib/ui/account_page.dart +153 -0
- package/templates/flutter/lib/ui/bd_scope.dart +39 -0
- package/templates/flutter/lib/ui/cart_page.dart +102 -0
- package/templates/flutter/lib/ui/chat_page.dart +111 -0
- package/templates/flutter/lib/ui/form_page.dart +50 -0
- package/templates/flutter/lib/ui/load_state.dart +62 -0
- package/templates/flutter/lib/ui/product_page.dart +71 -0
- package/templates/flutter/lib/ui/quiz_page.dart +83 -0
- package/templates/flutter/lib/ui/storefront_page.dart +85 -0
- package/templates/flutter/package.json +20 -0
- package/templates/flutter/packages/businessdash_forms/analysis_options.yaml +8 -0
- package/templates/flutter/packages/businessdash_forms/lib/businessdash_forms.dart +47 -0
- package/templates/flutter/packages/businessdash_forms/lib/src/controls/choice.dart +865 -0
- package/templates/flutter/packages/businessdash_forms/lib/src/controls/dates.dart +527 -0
- package/templates/flutter/packages/businessdash_forms/lib/src/controls/media.dart +507 -0
- package/templates/flutter/packages/businessdash_forms/lib/src/controls/static.dart +302 -0
- package/templates/flutter/packages/businessdash_forms/lib/src/controls/text.dart +537 -0
- package/templates/flutter/packages/businessdash_forms/lib/src/form.dart +781 -0
- package/templates/flutter/packages/businessdash_forms/lib/src/icons.dart +398 -0
- package/templates/flutter/packages/businessdash_forms/lib/src/logic.dart +719 -0
- package/templates/flutter/packages/businessdash_forms/lib/src/primitives.dart +1223 -0
- package/templates/flutter/packages/businessdash_forms/lib/src/quiz.dart +1225 -0
- package/templates/flutter/packages/businessdash_forms/lib/src/sign_in.dart +570 -0
- package/templates/flutter/packages/businessdash_forms/lib/src/sign_in_core.dart +1069 -0
- package/templates/flutter/packages/businessdash_forms/lib/src/style.dart +497 -0
- package/templates/flutter/packages/businessdash_forms/lib/src/tree.dart +491 -0
- package/templates/flutter/packages/businessdash_forms/pubspec.yaml +34 -0
- package/templates/flutter/packages/businessdash_forms/test/form_widget_test.dart +358 -0
- package/templates/flutter/packages/businessdash_forms/test/logic_test.dart +207 -0
- package/templates/flutter/packages/businessdash_forms/test/quiz_widget_test.dart +221 -0
- package/templates/flutter/packages/businessdash_forms/test/sign_in_test.dart +279 -0
- package/templates/flutter/packages/businessdash_sdk/CHANGELOG.md +66 -0
- package/templates/flutter/packages/businessdash_sdk/LICENSE +21 -0
- package/templates/flutter/packages/businessdash_sdk/analysis_options.yaml +6 -0
- package/templates/flutter/packages/businessdash_sdk/lib/businessdash_sdk.dart +21 -0
- package/templates/flutter/packages/businessdash_sdk/lib/forms.dart +29 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/bundle.dart +34 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/chat.dart +122 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/client.dart +161 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/customer_account.dart +31 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/donations.dart +179 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/errors.dart +82 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/forms/backend.dart +488 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/forms/calculation.dart +172 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/forms/controller.dart +1004 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/forms/dates.dart +173 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/forms/forms_data.generated.dart +405 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/forms/formula.dart +920 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/forms/json.dart +462 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/forms/quiz.dart +1185 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/forms/quiz_backend.dart +382 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/forms/quiz_controller.dart +277 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/forms/quiz_page.dart +148 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/forms/quiz_scoring.dart +550 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/forms/quiz_screen.dart +388 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/forms/quiz_words.dart +280 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/forms/rules.dart +1268 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/forms/schema.dart +1114 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/forms/units.dart +105 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/models.dart +311 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/money.dart +38 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/portal.dart +227 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/resources.dart +164 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/scheduling.dart +135 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/seo.dart +144 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/social_platforms.generated.dart +45 -0
- package/templates/flutter/packages/businessdash_sdk/lib/src/socials.dart +88 -0
- package/templates/flutter/packages/businessdash_sdk/pubspec.yaml +23 -0
- package/templates/flutter/packages/businessdash_sdk/test/bd_test.dart +335 -0
- package/templates/flutter/packages/businessdash_sdk/test/fixtures/forms-parity.json +3806 -0
- package/templates/flutter/packages/businessdash_sdk/test/fixtures/quiz-parity.json +9937 -0
- package/templates/flutter/packages/businessdash_sdk/test/form_controller_test.dart +449 -0
- package/templates/flutter/packages/businessdash_sdk/test/forms_parity_test.dart +254 -0
- package/templates/flutter/packages/businessdash_sdk/test/quiz_controller_test.dart +390 -0
- package/templates/flutter/packages/businessdash_sdk/test/quiz_parity_test.dart +269 -0
- package/templates/flutter/pnpm-lock.yaml +347 -0
- package/templates/flutter/pubspec.yaml +33 -0
- package/templates/flutter/tsconfig.json +19 -0
- package/templates/htmx/.env.example +59 -0
- package/templates/htmx/README.md +446 -0
- package/templates/htmx/_gitignore +7 -0
- package/templates/htmx/bd.config.ts +331 -0
- package/templates/htmx/bd.data-model.config.ts +89 -0
- package/templates/htmx/package.json +27 -0
- package/templates/htmx/pnpm-lock.yaml +97 -0
- package/templates/htmx/public/forms.css +1134 -0
- package/templates/htmx/public/index.html +68 -0
- package/templates/htmx/public/styles.css +1078 -0
- package/templates/htmx/server.ts +387 -0
- package/templates/htmx/src/bd.ts +142 -0
- package/templates/htmx/src/cache.ts +45 -0
- package/templates/htmx/src/form-pages.ts +35 -0
- package/templates/htmx/src/form.ts +955 -0
- package/templates/htmx/src/forms/demo-form.json +283 -0
- package/templates/htmx/src/forms/demo-quiz.json +97 -0
- package/templates/htmx/src/html.ts +55 -0
- package/templates/htmx/src/layout.ts +232 -0
- package/templates/htmx/src/pages.ts +975 -0
- package/templates/htmx/src/quiz.ts +582 -0
- package/templates/htmx/src/sections/about.ts +63 -0
- package/templates/htmx/src/sections/blog.ts +53 -0
- package/templates/htmx/src/sections/header.ts +42 -0
- package/templates/htmx/src/sections/hero.ts +48 -0
- package/templates/htmx/src/sections/services.ts +71 -0
- package/templates/htmx/src/sections/subscribe.ts +141 -0
- package/templates/htmx/src/sign-in.ts +636 -0
- package/templates/htmx/tsconfig.json +19 -0
- package/templates/kotlin/README.md +318 -0
- package/templates/kotlin/_gitignore +12 -0
- package/templates/kotlin/app/build.gradle.kts +70 -0
- package/templates/kotlin/app/src/main/AndroidManifest.xml +21 -0
- package/templates/kotlin/app/src/main/assets/bd-demo-form.json +283 -0
- package/templates/kotlin/app/src/main/assets/bd-demo-quiz.json +97 -0
- package/templates/kotlin/app/src/main/kotlin/app/bdstarter/AccountScreen.kt +209 -0
- package/templates/kotlin/app/src/main/kotlin/app/bdstarter/BdApp.kt +68 -0
- package/templates/kotlin/app/src/main/kotlin/app/bdstarter/DemoFormsBackend.kt +52 -0
- package/templates/kotlin/app/src/main/kotlin/app/bdstarter/FormScreen.kt +37 -0
- package/templates/kotlin/app/src/main/kotlin/app/bdstarter/MainActivity.kt +186 -0
- package/templates/kotlin/app/src/main/kotlin/app/bdstarter/QuizScreen.kt +75 -0
- package/templates/kotlin/app/src/main/kotlin/app/bdstarter/SessionStore.kt +68 -0
- package/templates/kotlin/app/src/main/kotlin/app/bdstarter/ShopViewModel.kt +73 -0
- package/templates/kotlin/app/src/main/res/values/strings.xml +4 -0
- package/templates/kotlin/app/src/main/res/values/themes.xml +5 -0
- package/templates/kotlin/app/src/main/res/values-night/themes.xml +4 -0
- package/templates/kotlin/bd/LICENSE +21 -0
- package/templates/kotlin/bd/README.md +31 -0
- package/templates/kotlin/bd/build.gradle.kts +126 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/Auth.kt +58 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/BdClient.kt +166 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/BdError.kt +62 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/Bundle.kt +52 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/ChatFeed.kt +82 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/DataModel.kt +95 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/Donations.kt +111 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/Models.kt +271 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/Money.kt +48 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/Portal.kt +250 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/Resources.kt +129 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/Scheduling.kt +134 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/Seo.kt +120 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/SocialPlatforms.generated.kt +46 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/Socials.kt +79 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/forms/BdCalculation.kt +157 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/forms/BdDates.kt +108 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/forms/BdFormController.kt +770 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/forms/BdFormRules.kt +1149 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/forms/BdFormSchema.kt +528 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/forms/BdFormsBackend.kt +392 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/forms/BdFormula.kt +767 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/forms/BdJson.kt +294 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/forms/BdQuizBackend.kt +310 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/forms/BdQuizController.kt +281 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/forms/BdQuizEngine.kt +578 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/forms/BdQuizPage.kt +128 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/forms/BdQuizScoring.kt +386 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/forms/BdQuizScreen.kt +477 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/forms/BdQuizWords.kt +196 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/forms/BdUnits.kt +84 -0
- package/templates/kotlin/bd/src/main/kotlin/app/bd/forms/FormsData.generated.kt +292 -0
- package/templates/kotlin/bd/src/test/kotlin/app/bd/BdClientTest.kt +278 -0
- package/templates/kotlin/bd/src/test/kotlin/app/bd/forms/FormControllerTest.kt +294 -0
- package/templates/kotlin/bd/src/test/kotlin/app/bd/forms/FormsBackendPathTest.kt +27 -0
- package/templates/kotlin/bd/src/test/kotlin/app/bd/forms/FormsParityTest.kt +233 -0
- package/templates/kotlin/bd/src/test/kotlin/app/bd/forms/PackageFormsBackendTest.kt +123 -0
- package/templates/kotlin/bd/src/test/kotlin/app/bd/forms/QuizControllerTest.kt +359 -0
- package/templates/kotlin/bd/src/test/kotlin/app/bd/forms/QuizParityTest.kt +260 -0
- package/templates/kotlin/bd/src/test/resources/forms-parity.json +3806 -0
- package/templates/kotlin/bd/src/test/resources/quiz-parity.json +9937 -0
- package/templates/kotlin/bd-forms/build.gradle.kts +51 -0
- package/templates/kotlin/bd-forms/src/main/AndroidManifest.xml +5 -0
- package/templates/kotlin/bd-forms/src/main/kotlin/app/bd/forms/ui/BdChoiceControls.kt +651 -0
- package/templates/kotlin/bd-forms/src/main/kotlin/app/bd/forms/ui/BdDateControls.kt +470 -0
- package/templates/kotlin/bd-forms/src/main/kotlin/app/bd/forms/ui/BdFieldControl.kt +520 -0
- package/templates/kotlin/bd-forms/src/main/kotlin/app/bd/forms/ui/BdFieldTree.kt +328 -0
- package/templates/kotlin/bd-forms/src/main/kotlin/app/bd/forms/ui/BdForm.kt +573 -0
- package/templates/kotlin/bd-forms/src/main/kotlin/app/bd/forms/ui/BdFormStyle.kt +279 -0
- package/templates/kotlin/bd-forms/src/main/kotlin/app/bd/forms/ui/BdHtml.kt +438 -0
- package/templates/kotlin/bd-forms/src/main/kotlin/app/bd/forms/ui/BdIcon.kt +282 -0
- package/templates/kotlin/bd-forms/src/main/kotlin/app/bd/forms/ui/BdMediaControls.kt +412 -0
- package/templates/kotlin/bd-forms/src/main/kotlin/app/bd/forms/ui/BdQuiz.kt +896 -0
- package/templates/kotlin/bd-forms/src/main/kotlin/app/bd/forms/ui/BdStaticViews.kt +250 -0
- package/templates/kotlin/bd-forms/src/main/kotlin/app/bd/forms/ui/BdTextControls.kt +409 -0
- package/templates/kotlin/bd-forms/src/test/kotlin/app/bd/forms/ui/RendererLogicTest.kt +177 -0
- package/templates/kotlin/bd-records/README.md +50 -0
- package/templates/kotlin/bd-records/todo-images.json +14 -0
- package/templates/kotlin/bd-records/todos.json +20 -0
- package/templates/kotlin/bd-sign-in/build.gradle.kts +49 -0
- package/templates/kotlin/bd-sign-in/src/main/AndroidManifest.xml +27 -0
- package/templates/kotlin/bd-sign-in/src/main/kotlin/app/bd/signin/BdSignIn.kt +713 -0
- package/templates/kotlin/bd-sign-in/src/main/kotlin/app/bd/signin/BdSignInBackend.kt +291 -0
- package/templates/kotlin/bd-sign-in/src/main/kotlin/app/bd/signin/BdSignInChecks.kt +162 -0
- package/templates/kotlin/bd-sign-in/src/main/kotlin/app/bd/signin/BdSignInOAuth.kt +95 -0
- package/templates/kotlin/bd-sign-in/src/test/kotlin/app/bd/signin/BdSignInChecksTest.kt +64 -0
- package/templates/kotlin/bd.config.ts +331 -0
- package/templates/kotlin/bd.data-model.config.ts +89 -0
- package/templates/kotlin/build.gradle.kts +8 -0
- package/templates/kotlin/gradle/libs.versions.toml +38 -0
- package/templates/kotlin/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/templates/kotlin/gradle/wrapper/gradle-wrapper.properties +10 -0
- package/templates/kotlin/gradle.properties +8 -0
- package/templates/kotlin/gradlew +248 -0
- package/templates/kotlin/gradlew.bat +112 -0
- package/templates/kotlin/local.properties.example +30 -0
- package/templates/kotlin/package.json +20 -0
- package/templates/kotlin/pnpm-lock.yaml +347 -0
- package/templates/kotlin/settings.gradle.kts +39 -0
- package/templates/kotlin/tsconfig.json +19 -0
- package/templates/laravel/.env.example +76 -0
- package/templates/laravel/README.md +316 -0
- package/templates/laravel/_gitignore +28 -0
- package/templates/laravel/app/Bd/Auth.php +181 -0
- package/templates/laravel/app/Bd/Bd.php +131 -0
- package/templates/laravel/app/Bd/BdAccessRejectedException.php +29 -0
- package/templates/laravel/app/Bd/BdApiException.php +18 -0
- package/templates/laravel/app/Bd/Client.php +358 -0
- package/templates/laravel/app/Bd/CustomerAnswer.php +58 -0
- package/templates/laravel/app/Bd/CustomerAuth.php +93 -0
- package/templates/laravel/app/Bd/Forms/Backend.php +35 -0
- package/templates/laravel/app/Bd/Forms/Calculation.php +179 -0
- package/templates/laravel/app/Bd/Forms/Dates.php +91 -0
- package/templates/laravel/app/Bd/Forms/Field.php +274 -0
- package/templates/laravel/app/Bd/Forms/FieldPath.php +36 -0
- package/templates/laravel/app/Bd/Forms/FormController.php +730 -0
- package/templates/laravel/app/Bd/Forms/FormView.php +307 -0
- package/templates/laravel/app/Bd/Forms/Forms.php +39 -0
- package/templates/laravel/app/Bd/Forms/FormsData.php +298 -0
- package/templates/laravel/app/Bd/Forms/FormsError.php +12 -0
- package/templates/laravel/app/Bd/Forms/Formula.php +696 -0
- package/templates/laravel/app/Bd/Forms/FormulaError.php +6 -0
- package/templates/laravel/app/Bd/Forms/FormulaParser.php +223 -0
- package/templates/laravel/app/Bd/Forms/Js.php +300 -0
- package/templates/laravel/app/Bd/Forms/Json.php +254 -0
- package/templates/laravel/app/Bd/Forms/Messages.php +89 -0
- package/templates/laravel/app/Bd/Forms/PackageBackend.php +181 -0
- package/templates/laravel/app/Bd/Forms/PickedFile.php +25 -0
- package/templates/laravel/app/Bd/Forms/QuizArrange.php +144 -0
- package/templates/laravel/app/Bd/Forms/QuizBackend.php +26 -0
- package/templates/laravel/app/Bd/Forms/QuizConfig.php +65 -0
- package/templates/laravel/app/Bd/Forms/QuizController.php +232 -0
- package/templates/laravel/app/Bd/Forms/QuizEngine.php +712 -0
- package/templates/laravel/app/Bd/Forms/QuizOptions.php +109 -0
- package/templates/laravel/app/Bd/Forms/QuizPage.php +99 -0
- package/templates/laravel/app/Bd/Forms/QuizScoring.php +459 -0
- package/templates/laravel/app/Bd/Forms/QuizState.php +96 -0
- package/templates/laravel/app/Bd/Forms/QuizWords.php +188 -0
- package/templates/laravel/app/Bd/Forms/Quizzes.php +123 -0
- package/templates/laravel/app/Bd/Forms/Rules.php +1593 -0
- package/templates/laravel/app/Bd/Forms/SampleBackend.php +48 -0
- package/templates/laravel/app/Bd/Forms/Schema.php +76 -0
- package/templates/laravel/app/Bd/Forms/Submission.php +33 -0
- package/templates/laravel/app/Bd/Forms/SubmitOptions.php +19 -0
- package/templates/laravel/app/Bd/Forms/SubmitResult.php +69 -0
- package/templates/laravel/app/Bd/Forms/Undefined.php +28 -0
- package/templates/laravel/app/Bd/Forms/Units.php +113 -0
- package/templates/laravel/app/Bd/Resources/Blog.php +50 -0
- package/templates/laravel/app/Bd/Resources/Cart.php +81 -0
- package/templates/laravel/app/Bd/Resources/Chatbot.php +117 -0
- package/templates/laravel/app/Bd/Resources/Checkout.php +51 -0
- package/templates/laravel/app/Bd/Resources/DataModel.php +61 -0
- package/templates/laravel/app/Bd/Resources/Donations.php +74 -0
- package/templates/laravel/app/Bd/Resources/Followers.php +48 -0
- package/templates/laravel/app/Bd/Resources/Forms.php +52 -0
- package/templates/laravel/app/Bd/Resources/Marketing.php +47 -0
- package/templates/laravel/app/Bd/Resources/Notifications.php +130 -0
- package/templates/laravel/app/Bd/Resources/ParallelPages.php +45 -0
- package/templates/laravel/app/Bd/Resources/Portal.php +241 -0
- package/templates/laravel/app/Bd/Resources/Reviews.php +22 -0
- package/templates/laravel/app/Bd/Resources/Scheduling.php +170 -0
- package/templates/laravel/app/Bd/Resources/Storefront.php +89 -0
- package/templates/laravel/app/Bd/Resources/Subscriptions.php +34 -0
- package/templates/laravel/app/Bd/Seo.php +167 -0
- package/templates/laravel/app/Bd/SignInCore.php +276 -0
- package/templates/laravel/app/Bd/SocialPlatforms.php +45 -0
- package/templates/laravel/app/Bd/Socials.php +118 -0
- package/templates/laravel/app/Bd/Webhook.php +93 -0
- package/templates/laravel/app/Http/Controllers/BdAuthController.php +146 -0
- package/templates/laravel/app/Http/Controllers/BdCustomerAuthController.php +214 -0
- package/templates/laravel/app/Http/Controllers/BlogController.php +49 -0
- package/templates/laravel/app/Http/Controllers/CartController.php +183 -0
- package/templates/laravel/app/Http/Controllers/Controller.php +8 -0
- package/templates/laravel/app/Http/Controllers/FormPageController.php +55 -0
- package/templates/laravel/app/Http/Controllers/HomeController.php +104 -0
- package/templates/laravel/app/Http/Controllers/PortalController.php +95 -0
- package/templates/laravel/app/Http/Controllers/SeoController.php +103 -0
- package/templates/laravel/app/Http/Controllers/ServiceAreaController.php +56 -0
- package/templates/laravel/app/Http/Controllers/StoreController.php +78 -0
- package/templates/laravel/app/Http/Controllers/SubscriptionController.php +40 -0
- package/templates/laravel/app/Http/Controllers/TodosController.php +87 -0
- package/templates/laravel/app/Http/Controllers/WebhookController.php +44 -0
- package/templates/laravel/app/Livewire/BdForm.php +508 -0
- package/templates/laravel/app/Livewire/BdQuiz.php +429 -0
- package/templates/laravel/app/Livewire/SignIn.php +449 -0
- package/templates/laravel/app/Support/Money.php +54 -0
- package/templates/laravel/app/Support/PhpSecurity.php +94 -0
- package/templates/laravel/artisan +16 -0
- package/templates/laravel/bd-records/README.md +50 -0
- package/templates/laravel/bd-records/todo-images.json +14 -0
- package/templates/laravel/bd-records/todos.json +20 -0
- package/templates/laravel/bd.config.ts +331 -0
- package/templates/laravel/bd.data-model.config.ts +89 -0
- package/templates/laravel/bootstrap/app.php +33 -0
- package/templates/laravel/bootstrap/cache/.gitkeep +0 -0
- package/templates/laravel/composer.json +47 -0
- package/templates/laravel/config/bd.php +75 -0
- package/templates/laravel/package.json +20 -0
- package/templates/laravel/phpunit.xml +22 -0
- package/templates/laravel/pnpm-lock.yaml +347 -0
- package/templates/laravel/public/bd-sign-in.css +48 -0
- package/templates/laravel/public/forms.css +1153 -0
- package/templates/laravel/public/index.php +17 -0
- package/templates/laravel/public/styles.css +100 -0
- package/templates/laravel/resources/forms/demo-form.json +283 -0
- package/templates/laravel/resources/forms/demo-quiz.json +97 -0
- package/templates/laravel/resources/views/forms/control.blade.php +238 -0
- package/templates/laravel/resources/views/forms/field.blade.php +39 -0
- package/templates/laravel/resources/views/forms/files.blade.php +36 -0
- package/templates/laravel/resources/views/forms/pair.blade.php +6 -0
- package/templates/laravel/resources/views/forms/repeater.blade.php +16 -0
- package/templates/laravel/resources/views/forms/styles.blade.php +8 -0
- package/templates/laravel/resources/views/forms/tree.blade.php +58 -0
- package/templates/laravel/resources/views/layout.blade.php +94 -0
- package/templates/laravel/resources/views/livewire/bd-form.blade.php +103 -0
- package/templates/laravel/resources/views/livewire/bd-quiz.blade.php +101 -0
- package/templates/laravel/resources/views/livewire/sign-in.blade.php +82 -0
- package/templates/laravel/resources/views/pages/blog-post.blade.php +24 -0
- package/templates/laravel/resources/views/pages/blog.blade.php +15 -0
- package/templates/laravel/resources/views/pages/cart.blade.php +41 -0
- package/templates/laravel/resources/views/pages/delete-account.blade.php +26 -0
- package/templates/laravel/resources/views/pages/form.blade.php +10 -0
- package/templates/laravel/resources/views/pages/home.blade.php +73 -0
- package/templates/laravel/resources/views/pages/my-account.blade.php +40 -0
- package/templates/laravel/resources/views/pages/product.blade.php +39 -0
- package/templates/laravel/resources/views/pages/quiz.blade.php +12 -0
- package/templates/laravel/resources/views/pages/reviews.blade.php +17 -0
- package/templates/laravel/resources/views/pages/service-area.blade.php +14 -0
- package/templates/laravel/resources/views/pages/services.blade.php +20 -0
- package/templates/laravel/resources/views/pages/sign-in.blade.php +30 -0
- package/templates/laravel/resources/views/pages/store.blade.php +35 -0
- package/templates/laravel/resources/views/pages/subscriptions.blade.php +19 -0
- package/templates/laravel/resources/views/pages/todos.blade.php +45 -0
- package/templates/laravel/resources/views/pages/updates.blade.php +13 -0
- package/templates/laravel/resources/views/quiz/actions.blade.php +14 -0
- package/templates/laravel/resources/views/quiz/error.blade.php +3 -0
- package/templates/laravel/resources/views/quiz/feedback.blade.php +19 -0
- package/templates/laravel/resources/views/quiz/header.blade.php +10 -0
- package/templates/laravel/resources/views/quiz/question.blade.php +55 -0
- package/templates/laravel/routes/web.php +97 -0
- package/templates/laravel/storage/framework/cache/.gitkeep +0 -0
- package/templates/laravel/storage/framework/sessions/.gitkeep +0 -0
- package/templates/laravel/storage/framework/views/.gitkeep +0 -0
- package/templates/laravel/storage/logs/.gitkeep +0 -0
- package/templates/laravel/tests/Fixtures/forms-parity.json +3806 -0
- package/templates/laravel/tests/Fixtures/quiz-parity.json +9937 -0
- package/templates/laravel/tests/Unit/FormControllerTest.php +310 -0
- package/templates/laravel/tests/Unit/FormsParityTest.php +314 -0
- package/templates/laravel/tests/Unit/PhpSecurityTest.php +38 -0
- package/templates/laravel/tests/Unit/QuizParityTest.php +303 -0
- package/templates/laravel/tsconfig.json +19 -0
- package/templates/nuxt/.env.example +47 -0
- package/templates/nuxt/README.md +446 -0
- package/templates/nuxt/_gitignore +10 -0
- package/templates/nuxt/app/app.vue +28 -0
- package/templates/nuxt/app/assets/css/bd-tokens.css +944 -0
- package/templates/nuxt/app/components/bd/About.vue +34 -0
- package/templates/nuxt/app/components/bd/BdFooter.vue +22 -0
- package/templates/nuxt/app/components/bd/BdHeader.vue +25 -0
- package/templates/nuxt/app/components/bd/Blog.vue +43 -0
- package/templates/nuxt/app/components/bd/Booking.vue +235 -0
- package/templates/nuxt/app/components/bd/ContactForm.vue +111 -0
- package/templates/nuxt/app/components/bd/Gallery.vue +46 -0
- package/templates/nuxt/app/components/bd/Hero.vue +14 -0
- package/templates/nuxt/app/components/bd/NewsBanner.vue +44 -0
- package/templates/nuxt/app/components/bd/NotFoundBody.vue +22 -0
- package/templates/nuxt/app/components/bd/ReviewForm.vue +106 -0
- package/templates/nuxt/app/components/bd/SdkSetupBanner.vue +111 -0
- package/templates/nuxt/app/components/bd/Services.vue +34 -0
- package/templates/nuxt/app/components/bd/Subscribe.vue +205 -0
- package/templates/nuxt/app/composables/useCart.ts +83 -0
- package/templates/nuxt/app/pages/[...slug].vue +52 -0
- package/templates/nuxt/app/pages/cart.vue +194 -0
- package/templates/nuxt/app/pages/index.vue +58 -0
- package/templates/nuxt/app/pages/my-account.vue +207 -0
- package/templates/nuxt/app/pages/reviews.vue +104 -0
- package/templates/nuxt/app/pages/services/[service]/[area].vue +85 -0
- package/templates/nuxt/app/pages/services/index.vue +57 -0
- package/templates/nuxt/app/pages/store/[id].vue +128 -0
- package/templates/nuxt/app/pages/store/index.vue +73 -0
- package/templates/nuxt/app/pages/subscriptions.vue +117 -0
- package/templates/nuxt/app/pages/todos.vue +222 -0
- package/templates/nuxt/app/pages/updates.vue +78 -0
- package/templates/nuxt/bd.config.ts +331 -0
- package/templates/nuxt/bd.data-model.config.ts +89 -0
- package/templates/nuxt/nuxt.config.ts +78 -0
- package/templates/nuxt/package.json +35 -0
- package/templates/nuxt/pnpm-lock.yaml +6211 -0
- package/templates/nuxt/public/favicon.ico +0 -0
- package/templates/nuxt/server/api/bd/cart/add.post.ts +21 -0
- package/templates/nuxt/server/api/bd/cart/clear.post.ts +10 -0
- package/templates/nuxt/server/api/bd/cart/coupon.post.ts +15 -0
- package/templates/nuxt/server/api/bd/cart/index.get.ts +25 -0
- package/templates/nuxt/server/api/bd/cart/remove.post.ts +10 -0
- package/templates/nuxt/server/api/bd/cart/update.post.ts +13 -0
- package/templates/nuxt/server/api/bd/checkout/start.post.ts +35 -0
- package/templates/nuxt/server/api/bd/forms/[slug].post.ts +37 -0
- package/templates/nuxt/server/api/bd/home.get.ts +284 -0
- package/templates/nuxt/server/api/bd/jsonld.get.ts +42 -0
- package/templates/nuxt/server/api/bd/legal.get.ts +30 -0
- package/templates/nuxt/server/api/bd/parallel/render.get.ts +53 -0
- package/templates/nuxt/server/api/bd/parallel/variants.get.ts +27 -0
- package/templates/nuxt/server/api/bd/portal/context.get.ts +76 -0
- package/templates/nuxt/server/api/bd/portal/plan.post.ts +27 -0
- package/templates/nuxt/server/api/bd/portal/submit-review.post.ts +53 -0
- package/templates/nuxt/server/api/bd/revalidate.post.ts +38 -0
- package/templates/nuxt/server/api/bd/reviews.get.ts +44 -0
- package/templates/nuxt/server/api/bd/scheduling/bookings.post.ts +40 -0
- package/templates/nuxt/server/api/bd/scheduling/slots.get.ts +37 -0
- package/templates/nuxt/server/api/bd/store/product/[id].get.ts +39 -0
- package/templates/nuxt/server/api/bd/store/products-meta.get.ts +101 -0
- package/templates/nuxt/server/api/bd/store/products.get.ts +53 -0
- package/templates/nuxt/server/api/bd/store/subscriptions/[id]/checkout.post.ts +36 -0
- package/templates/nuxt/server/api/bd/store/subscriptions.get.ts +42 -0
- package/templates/nuxt/server/api/bd/todos.get.ts +111 -0
- package/templates/nuxt/server/api/bd-auth/[...slug].ts +57 -0
- package/templates/nuxt/server/api/mcp.get.ts +14 -0
- package/templates/nuxt/server/api/mcp.post.ts +37 -0
- package/templates/nuxt/server/routes/.well-known/mcp.json.ts +31 -0
- package/templates/nuxt/server/routes/llms.txt.ts +43 -0
- package/templates/nuxt/server/routes/robots.txt.ts +38 -0
- package/templates/nuxt/server/routes/sitemap.xml.ts +60 -0
- package/templates/nuxt/server/utils/bd-cart.ts +73 -0
- package/templates/nuxt/server/utils/bd-env.ts +54 -0
- package/templates/nuxt/server/utils/bd-portal.ts +151 -0
- package/templates/nuxt/server/utils/bd.ts +36 -0
- package/templates/nuxt/tsconfig.json +18 -0
- package/templates/qwik/.env.example +48 -0
- package/templates/qwik/.prettierignore +37 -0
- package/templates/qwik/.vscode/launch.json +24 -0
- package/templates/qwik/.vscode/qwik-city.code-snippets +36 -0
- package/templates/qwik/.vscode/qwik.code-snippets +78 -0
- package/templates/qwik/README.md +436 -0
- package/templates/qwik/_gitignore +42 -0
- package/templates/qwik/bd.config.ts +331 -0
- package/templates/qwik/bd.data-model.config.ts +90 -0
- package/templates/qwik/eslint.config.js +76 -0
- package/templates/qwik/package.json +58 -0
- package/templates/qwik/pnpm-lock.yaml +4928 -0
- package/templates/qwik/public/favicon.svg +1 -0
- package/templates/qwik/public/manifest.json +9 -0
- package/templates/qwik/public/robots.txt +0 -0
- package/templates/qwik/qwik.env.d.ts +4 -0
- package/templates/qwik/src/components/bd/About.tsx +26 -0
- package/templates/qwik/src/components/bd/Banner.tsx +46 -0
- package/templates/qwik/src/components/bd/Blog.tsx +53 -0
- package/templates/qwik/src/components/bd/Booking.tsx +296 -0
- package/templates/qwik/src/components/bd/ContactForm.tsx +100 -0
- package/templates/qwik/src/components/bd/Footer.tsx +28 -0
- package/templates/qwik/src/components/bd/Gallery.tsx +53 -0
- package/templates/qwik/src/components/bd/Header.tsx +18 -0
- package/templates/qwik/src/components/bd/Hero.tsx +21 -0
- package/templates/qwik/src/components/bd/SdkSetupBanner.tsx +115 -0
- package/templates/qwik/src/components/bd/Services.tsx +38 -0
- package/templates/qwik/src/components/bd/SiteHeader.tsx +49 -0
- package/templates/qwik/src/components/bd/Stars.tsx +46 -0
- package/templates/qwik/src/components/bd/Subscribe.tsx +175 -0
- package/templates/qwik/src/components/router-head/router-head.tsx +48 -0
- package/templates/qwik/src/entry.dev.tsx +17 -0
- package/templates/qwik/src/entry.preview.tsx +21 -0
- package/templates/qwik/src/entry.ssr.tsx +31 -0
- package/templates/qwik/src/global.css +875 -0
- package/templates/qwik/src/lib/bd-content.ts +143 -0
- package/templates/qwik/src/lib/bd-distribution.ts +25 -0
- package/templates/qwik/src/lib/bd-portal.ts +181 -0
- package/templates/qwik/src/lib/bd-store.ts +308 -0
- package/templates/qwik/src/lib/bd-todos.ts +137 -0
- package/templates/qwik/src/lib/bd.ts +42 -0
- package/templates/qwik/src/root.tsx +38 -0
- package/templates/qwik/src/routes/.well-known/mcp.json/index.ts +19 -0
- package/templates/qwik/src/routes/[...slug]/index.tsx +85 -0
- package/templates/qwik/src/routes/ai/product-feed/index.ts +24 -0
- package/templates/qwik/src/routes/api/bd/revalidate/index.ts +45 -0
- package/templates/qwik/src/routes/api/bd-auth/[...slug]/index.ts +77 -0
- package/templates/qwik/src/routes/api/mcp/index.ts +38 -0
- package/templates/qwik/src/routes/cart/index.tsx +254 -0
- package/templates/qwik/src/routes/index.tsx +239 -0
- package/templates/qwik/src/routes/llms.txt/index.ts +23 -0
- package/templates/qwik/src/routes/my-account/index.tsx +370 -0
- package/templates/qwik/src/routes/reviews/index.tsx +147 -0
- package/templates/qwik/src/routes/robots.txt/index.ts +70 -0
- package/templates/qwik/src/routes/services/[service]/[area]/index.tsx +115 -0
- package/templates/qwik/src/routes/services/index.tsx +99 -0
- package/templates/qwik/src/routes/sitemap.xml/index.ts +62 -0
- package/templates/qwik/src/routes/store/[id]/index.tsx +362 -0
- package/templates/qwik/src/routes/store/index.tsx +436 -0
- package/templates/qwik/src/routes/store/order/index.tsx +74 -0
- package/templates/qwik/src/routes/subscriptions/index.tsx +164 -0
- package/templates/qwik/src/routes/todos/index.tsx +202 -0
- package/templates/qwik/src/routes/updates/index.tsx +106 -0
- package/templates/qwik/tsconfig.json +26 -0
- package/templates/qwik/vite.config.ts +115 -0
- package/templates/react-bun/.env.example +65 -0
- package/templates/react-bun/README.md +354 -0
- package/templates/react-bun/_gitignore +24 -0
- package/templates/react-bun/bd.config.ts +331 -0
- package/templates/react-bun/bd.data-model.config.ts +90 -0
- package/templates/react-bun/eslint.config.js +22 -0
- package/templates/react-bun/index.html +13 -0
- package/templates/react-bun/package.json +46 -0
- package/templates/react-bun/pnpm-lock.yaml +2060 -0
- package/templates/react-bun/public/favicon.svg +1 -0
- package/templates/react-bun/public/icons.svg +24 -0
- package/templates/react-bun/server.ts +978 -0
- package/templates/react-bun/src/App.css +910 -0
- package/templates/react-bun/src/App.tsx +104 -0
- package/templates/react-bun/src/assets/hero.png +0 -0
- package/templates/react-bun/src/assets/react.svg +1 -0
- package/templates/react-bun/src/assets/vite.svg +1 -0
- package/templates/react-bun/src/components/About.tsx +46 -0
- package/templates/react-bun/src/components/Banner.tsx +53 -0
- package/templates/react-bun/src/components/Blog.tsx +84 -0
- package/templates/react-bun/src/components/Booking.tsx +278 -0
- package/templates/react-bun/src/components/ContactForm.tsx +47 -0
- package/templates/react-bun/src/components/Footer.tsx +24 -0
- package/templates/react-bun/src/components/Gallery.tsx +83 -0
- package/templates/react-bun/src/components/Header.tsx +27 -0
- package/templates/react-bun/src/components/Hero.tsx +65 -0
- package/templates/react-bun/src/components/SdkSetupBanner.tsx +102 -0
- package/templates/react-bun/src/components/Services.tsx +92 -0
- package/templates/react-bun/src/components/Subscribe.tsx +169 -0
- package/templates/react-bun/src/index.css +302 -0
- package/templates/react-bun/src/lib/bd.ts +370 -0
- package/templates/react-bun/src/lib/router.tsx +54 -0
- package/templates/react-bun/src/main.tsx +14 -0
- package/templates/react-bun/src/pages/Cart.tsx +144 -0
- package/templates/react-bun/src/pages/MyAccount.tsx +207 -0
- package/templates/react-bun/src/pages/Product.tsx +220 -0
- package/templates/react-bun/src/pages/Reviews.tsx +73 -0
- package/templates/react-bun/src/pages/ServiceArea.tsx +41 -0
- package/templates/react-bun/src/pages/ServiceAreas.tsx +31 -0
- package/templates/react-bun/src/pages/Store.tsx +274 -0
- package/templates/react-bun/src/pages/Subscriptions.tsx +70 -0
- package/templates/react-bun/src/pages/Todos.tsx +147 -0
- package/templates/react-bun/src/pages/Updates.tsx +53 -0
- package/templates/react-bun/src/pages/ui.tsx +52 -0
- package/templates/react-bun/tsconfig.app.json +25 -0
- package/templates/react-bun/tsconfig.json +7 -0
- package/templates/react-bun/tsconfig.node.json +24 -0
- package/templates/react-bun/vite.config.ts +41 -0
- package/templates/react-native/.env.example +32 -0
- package/templates/react-native/README.md +299 -0
- package/templates/react-native/SECURITY-NOTES.md +22 -0
- package/templates/react-native/_gitignore +21 -0
- package/templates/react-native/app/(tabs)/_layout.tsx +13 -0
- package/templates/react-native/app/(tabs)/account.tsx +116 -0
- package/templates/react-native/app/(tabs)/cart.tsx +79 -0
- package/templates/react-native/app/(tabs)/chat.tsx +58 -0
- package/templates/react-native/app/(tabs)/form.tsx +41 -0
- package/templates/react-native/app/(tabs)/index.tsx +74 -0
- package/templates/react-native/app/_layout.tsx +19 -0
- package/templates/react-native/app/product/[id].tsx +78 -0
- package/templates/react-native/app.json +15 -0
- package/templates/react-native/bd-records/README.md +50 -0
- package/templates/react-native/bd-records/todo-images.json +14 -0
- package/templates/react-native/bd-records/todos.json +20 -0
- package/templates/react-native/bd.config.ts +331 -0
- package/templates/react-native/bd.data-model.config.ts +89 -0
- package/templates/react-native/metro.config.js +16 -0
- package/templates/react-native/package.json +51 -0
- package/templates/react-native/pnpm-lock.yaml +5967 -0
- package/templates/react-native/src/bd/auth.ts +152 -0
- package/templates/react-native/src/bd/client.ts +103 -0
- package/templates/react-native/src/bd/demo-form.json +283 -0
- package/templates/react-native/src/bd/forms.tsx +148 -0
- package/templates/react-native/src/bd/money.ts +29 -0
- package/templates/react-native/src/bd/session.ts +53 -0
- package/templates/react-native/src/bd/useBd.ts +63 -0
- package/templates/react-native/src/bd/useChat.ts +116 -0
- package/templates/react-native/src/bd-forms/BdForm.tsx +973 -0
- package/templates/react-native/src/bd-forms/__tests__/logic.test.ts +195 -0
- package/templates/react-native/src/bd-forms/controls.tsx +1966 -0
- package/templates/react-native/src/bd-forms/index.ts +34 -0
- package/templates/react-native/src/bd-forms/keyboard.ts +139 -0
- package/templates/react-native/src/bd-forms/logic.ts +737 -0
- package/templates/react-native/src/bd-forms/pickers.tsx +487 -0
- package/templates/react-native/src/bd-forms/primitives.tsx +1162 -0
- package/templates/react-native/src/bd-forms/runtime.ts +95 -0
- package/templates/react-native/src/bd-forms/static.tsx +304 -0
- package/templates/react-native/src/bd-forms/theme.ts +385 -0
- package/templates/react-native/src/components/LoadState.tsx +53 -0
- package/templates/react-native/src/components/SignInScreen.tsx +399 -0
- package/templates/react-native/tsconfig.json +19 -0
- package/templates/remix/.env.example +63 -0
- package/templates/remix/README.md +392 -0
- package/templates/remix/_gitignore +10 -0
- package/templates/remix/app/components/ContactForm.tsx +55 -0
- package/templates/remix/app/components/NewsBanner.tsx +43 -0
- package/templates/remix/app/components/SdkSetupBanner.tsx +96 -0
- package/templates/remix/app/components/SiteHeader.tsx +37 -0
- package/templates/remix/app/components/Subscribe.tsx +138 -0
- package/templates/remix/app/lib/bd-booking.server.ts +90 -0
- package/templates/remix/app/lib/bd-bundle.server.ts +143 -0
- package/templates/remix/app/lib/bd-cache.server.ts +71 -0
- package/templates/remix/app/lib/bd-distribution.server.ts +26 -0
- package/templates/remix/app/lib/bd-pages.server.ts +84 -0
- package/templates/remix/app/lib/bd-portal.server.ts +170 -0
- package/templates/remix/app/lib/bd-seo.server.ts +56 -0
- package/templates/remix/app/lib/bd-store.server.ts +320 -0
- package/templates/remix/app/lib/bd-todos.server.ts +124 -0
- package/templates/remix/app/lib/bd.server.ts +112 -0
- package/templates/remix/app/lib/format.ts +17 -0
- package/templates/remix/app/lib/sdk-sections.server.ts +217 -0
- package/templates/remix/app/root.tsx +73 -0
- package/templates/remix/app/routes/$.tsx +85 -0
- package/templates/remix/app/routes/[.well-known].[mcp.json].ts +19 -0
- package/templates/remix/app/routes/[llms.txt].ts +22 -0
- package/templates/remix/app/routes/[robots.txt].ts +45 -0
- package/templates/remix/app/routes/[sitemap.xml].ts +57 -0
- package/templates/remix/app/routes/_index.tsx +210 -0
- package/templates/remix/app/routes/ai.product-feed.ts +24 -0
- package/templates/remix/app/routes/api.bd-auth.$.ts +47 -0
- package/templates/remix/app/routes/api.bd.forms.ts +53 -0
- package/templates/remix/app/routes/api.bd.revalidate.ts +46 -0
- package/templates/remix/app/routes/api.mcp.ts +38 -0
- package/templates/remix/app/routes/api.reviews.ts +44 -0
- package/templates/remix/app/routes/book.tsx +155 -0
- package/templates/remix/app/routes/my-account.tsx +349 -0
- package/templates/remix/app/routes/reviews.tsx +129 -0
- package/templates/remix/app/routes/services.$service.$area.tsx +80 -0
- package/templates/remix/app/routes/services._index.tsx +51 -0
- package/templates/remix/app/routes/store.$id.tsx +287 -0
- package/templates/remix/app/routes/store._index.tsx +318 -0
- package/templates/remix/app/routes/store.cart.tsx +196 -0
- package/templates/remix/app/routes/store.subscriptions.tsx +122 -0
- package/templates/remix/app/routes/todos.tsx +163 -0
- package/templates/remix/app/routes/updates._index.tsx +70 -0
- package/templates/remix/app/routes.ts +9 -0
- package/templates/remix/app/styles.css +699 -0
- package/templates/remix/bd.config.ts +331 -0
- package/templates/remix/bd.data-model.config.ts +90 -0
- package/templates/remix/package.json +52 -0
- package/templates/remix/pnpm-lock.yaml +2368 -0
- package/templates/remix/react-router.config.ts +5 -0
- package/templates/remix/tsconfig.json +22 -0
- package/templates/remix/vite.config.ts +16 -0
- package/templates/solid/.cta.json +24 -0
- package/templates/solid/.cursorrules +35 -0
- package/templates/solid/.env.example +56 -0
- package/templates/solid/.vscode/settings.json +35 -0
- package/templates/solid/README.md +421 -0
- package/templates/solid/VERCEL.md +50 -0
- package/templates/solid/_gitignore +12 -0
- package/templates/solid/bd.config.ts +331 -0
- package/templates/solid/bd.data-model.config.ts +90 -0
- package/templates/solid/biome.json +39 -0
- package/templates/solid/package.json +63 -0
- package/templates/solid/pnpm-lock.yaml +4086 -0
- package/templates/solid/public/favicon.ico +0 -0
- package/templates/solid/public/logo192.png +0 -0
- package/templates/solid/public/logo512.png +0 -0
- package/templates/solid/public/manifest.json +25 -0
- package/templates/solid/public/robots.txt +3 -0
- package/templates/solid/src/components/Header.tsx +58 -0
- package/templates/solid/src/components/bd/About.tsx +22 -0
- package/templates/solid/src/components/bd/Blog.tsx +52 -0
- package/templates/solid/src/components/bd/Booking.tsx +286 -0
- package/templates/solid/src/components/bd/ContactForm.tsx +102 -0
- package/templates/solid/src/components/bd/Footer.tsx +23 -0
- package/templates/solid/src/components/bd/Gallery.tsx +52 -0
- package/templates/solid/src/components/bd/Header.tsx +25 -0
- package/templates/solid/src/components/bd/Hero.tsx +14 -0
- package/templates/solid/src/components/bd/NewsBanner.tsx +47 -0
- package/templates/solid/src/components/bd/SdkSetupBanner.tsx +111 -0
- package/templates/solid/src/components/bd/Services.tsx +34 -0
- package/templates/solid/src/components/bd/Stars.tsx +32 -0
- package/templates/solid/src/components/bd/Subscribe.tsx +217 -0
- package/templates/solid/src/components/bd/money.ts +38 -0
- package/templates/solid/src/env.ts +48 -0
- package/templates/solid/src/integrations/tanstack-query/header-user.tsx +5 -0
- package/templates/solid/src/integrations/tanstack-query/provider.tsx +8 -0
- package/templates/solid/src/lib/bd-distribution.ts +26 -0
- package/templates/solid/src/lib/bd-server-fns.ts +1346 -0
- package/templates/solid/src/lib/bd-todos.ts +122 -0
- package/templates/solid/src/lib/bd.ts +169 -0
- package/templates/solid/src/lib/utils.ts +6 -0
- package/templates/solid/src/routeTree.gen.ts +513 -0
- package/templates/solid/src/router.tsx +23 -0
- package/templates/solid/src/routes/$.tsx +63 -0
- package/templates/solid/src/routes/[.]well-known.mcp[.]json.tsx +16 -0
- package/templates/solid/src/routes/__root.tsx +64 -0
- package/templates/solid/src/routes/about.tsx +23 -0
- package/templates/solid/src/routes/ai.product-feed.tsx +18 -0
- package/templates/solid/src/routes/api/bd/revalidate.tsx +48 -0
- package/templates/solid/src/routes/api/bd-auth.$.tsx +63 -0
- package/templates/solid/src/routes/api/mcp.tsx +23 -0
- package/templates/solid/src/routes/demo.tanstack-query.tsx +28 -0
- package/templates/solid/src/routes/index.tsx +65 -0
- package/templates/solid/src/routes/llms[.]txt.tsx +18 -0
- package/templates/solid/src/routes/my-account.tsx +365 -0
- package/templates/solid/src/routes/reviews.tsx +124 -0
- package/templates/solid/src/routes/robots[.]txt.tsx +17 -0
- package/templates/solid/src/routes/services.$service.$area.tsx +107 -0
- package/templates/solid/src/routes/services.index.tsx +68 -0
- package/templates/solid/src/routes/sitemap[.]xml.tsx +16 -0
- package/templates/solid/src/routes/store.$id.tsx +253 -0
- package/templates/solid/src/routes/store.cart.tsx +242 -0
- package/templates/solid/src/routes/store.index.tsx +392 -0
- package/templates/solid/src/routes/subscriptions.tsx +155 -0
- package/templates/solid/src/routes/todos.tsx +214 -0
- package/templates/solid/src/routes/updates.tsx +92 -0
- package/templates/solid/src/styles.css +1571 -0
- package/templates/solid/tsconfig.json +29 -0
- package/templates/solid/ui.config.json +13 -0
- package/templates/solid/vercel.json +7 -0
- package/templates/solid/vite.config.ts +23 -0
- package/templates/solid-1/.cta.json +24 -0
- package/templates/solid-1/.cursorrules +35 -0
- package/templates/solid-1/.env.example +56 -0
- package/templates/solid-1/.vscode/settings.json +35 -0
- package/templates/solid-1/README.md +385 -0
- package/templates/solid-1/VERCEL.md +50 -0
- package/templates/solid-1/_gitignore +12 -0
- package/templates/solid-1/bd.config.ts +331 -0
- package/templates/solid-1/bd.data-model.config.ts +90 -0
- package/templates/solid-1/biome.json +39 -0
- package/templates/solid-1/package.json +99 -0
- package/templates/solid-1/pnpm-lock.yaml +3937 -0
- package/templates/solid-1/public/favicon.ico +0 -0
- package/templates/solid-1/public/logo192.png +0 -0
- package/templates/solid-1/public/logo512.png +0 -0
- package/templates/solid-1/public/manifest.json +25 -0
- package/templates/solid-1/public/robots.txt +3 -0
- package/templates/solid-1/src/components/Header.tsx +70 -0
- package/templates/solid-1/src/components/bd/About.tsx +22 -0
- package/templates/solid-1/src/components/bd/Blog.tsx +52 -0
- package/templates/solid-1/src/components/bd/Booking.tsx +271 -0
- package/templates/solid-1/src/components/bd/ContactForm.tsx +102 -0
- package/templates/solid-1/src/components/bd/Footer.tsx +23 -0
- package/templates/solid-1/src/components/bd/Gallery.tsx +52 -0
- package/templates/solid-1/src/components/bd/Header.tsx +25 -0
- package/templates/solid-1/src/components/bd/Hero.tsx +14 -0
- package/templates/solid-1/src/components/bd/NewsBanner.tsx +47 -0
- package/templates/solid-1/src/components/bd/SdkSetupBanner.tsx +111 -0
- package/templates/solid-1/src/components/bd/Services.tsx +34 -0
- package/templates/solid-1/src/components/bd/Stars.tsx +30 -0
- package/templates/solid-1/src/components/bd/Subscribe.tsx +215 -0
- package/templates/solid-1/src/components/bd/money.ts +38 -0
- package/templates/solid-1/src/env.ts +48 -0
- package/templates/solid-1/src/integrations/tanstack-query/header-user.tsx +5 -0
- package/templates/solid-1/src/integrations/tanstack-query/provider.tsx +8 -0
- package/templates/solid-1/src/lib/bd-distribution.ts +26 -0
- package/templates/solid-1/src/lib/bd-server-fns.ts +1346 -0
- package/templates/solid-1/src/lib/bd-todos.ts +122 -0
- package/templates/solid-1/src/lib/bd.ts +169 -0
- package/templates/solid-1/src/lib/demo-store.ts +14 -0
- package/templates/solid-1/src/lib/utils.ts +6 -0
- package/templates/solid-1/src/routeTree.gen.ts +555 -0
- package/templates/solid-1/src/router.tsx +23 -0
- package/templates/solid-1/src/routes/$.tsx +63 -0
- package/templates/solid-1/src/routes/[.]well-known.mcp[.]json.tsx +16 -0
- package/templates/solid-1/src/routes/__root.tsx +62 -0
- package/templates/solid-1/src/routes/about.tsx +23 -0
- package/templates/solid-1/src/routes/ai.product-feed.tsx +18 -0
- package/templates/solid-1/src/routes/api/bd/revalidate.tsx +48 -0
- package/templates/solid-1/src/routes/api/bd-auth.$.tsx +63 -0
- package/templates/solid-1/src/routes/api/mcp.tsx +23 -0
- package/templates/solid-1/src/routes/demo.form.tsx +339 -0
- package/templates/solid-1/src/routes/demo.store.tsx +62 -0
- package/templates/solid-1/src/routes/demo.tanstack-query.tsx +28 -0
- package/templates/solid-1/src/routes/index.tsx +65 -0
- package/templates/solid-1/src/routes/llms[.]txt.tsx +18 -0
- package/templates/solid-1/src/routes/my-account.tsx +365 -0
- package/templates/solid-1/src/routes/reviews.tsx +124 -0
- package/templates/solid-1/src/routes/robots[.]txt.tsx +17 -0
- package/templates/solid-1/src/routes/services.$service.$area.tsx +107 -0
- package/templates/solid-1/src/routes/services.index.tsx +68 -0
- package/templates/solid-1/src/routes/sitemap[.]xml.tsx +16 -0
- package/templates/solid-1/src/routes/store.$id.tsx +253 -0
- package/templates/solid-1/src/routes/store.cart.tsx +242 -0
- package/templates/solid-1/src/routes/store.index.tsx +384 -0
- package/templates/solid-1/src/routes/subscriptions.tsx +155 -0
- package/templates/solid-1/src/routes/todos.tsx +214 -0
- package/templates/solid-1/src/routes/updates.tsx +92 -0
- package/templates/solid-1/src/styles.css +1571 -0
- package/templates/solid-1/tsconfig.json +29 -0
- package/templates/solid-1/ui.config.json +13 -0
- package/templates/solid-1/vercel.json +7 -0
- package/templates/solid-1/vite.config.ts +22 -0
- package/templates/svelte/.cursor/mcp.json +11 -0
- package/templates/svelte/.env.example +61 -0
- package/templates/svelte/.mcp.json +15 -0
- package/templates/svelte/.opencode/opencode.json +6 -0
- package/templates/svelte/.opencode/svelte.json +3 -0
- package/templates/svelte/.prettierignore +10 -0
- package/templates/svelte/.prettierrc +19 -0
- package/templates/svelte/.storybook/main.ts +17 -0
- package/templates/svelte/.storybook/preview.ts +21 -0
- package/templates/svelte/.vscode/extensions.json +7 -0
- package/templates/svelte/.vscode/settings.json +5 -0
- package/templates/svelte/AGENTS.md +23 -0
- package/templates/svelte/CLAUDE.md +23 -0
- package/templates/svelte/README.md +416 -0
- package/templates/svelte/_gitignore +30 -0
- package/templates/svelte/_npmrc +1 -0
- package/templates/svelte/bd.config.ts +331 -0
- package/templates/svelte/bd.data-model.config.ts +89 -0
- package/templates/svelte/drizzle.config.ts +11 -0
- package/templates/svelte/messages/en.json +4 -0
- package/templates/svelte/messages/es.json +4 -0
- package/templates/svelte/package.json +80 -0
- package/templates/svelte/playwright.config.ts +6 -0
- package/templates/svelte/pnpm-lock.yaml +4332 -0
- package/templates/svelte/project.inlang/settings.json +15 -0
- package/templates/svelte/src/app.d.ts +13 -0
- package/templates/svelte/src/app.html +17 -0
- package/templates/svelte/src/env.ts +22 -0
- package/templates/svelte/src/hooks.server.ts +17 -0
- package/templates/svelte/src/hooks.ts +4 -0
- package/templates/svelte/src/lib/assets/favicon.svg +1 -0
- package/templates/svelte/src/lib/bd/cart-client.ts +111 -0
- package/templates/svelte/src/lib/components/bd/About.svelte +31 -0
- package/templates/svelte/src/lib/components/bd/Banner.svelte +79 -0
- package/templates/svelte/src/lib/components/bd/Blog.svelte +47 -0
- package/templates/svelte/src/lib/components/bd/Booking.svelte +243 -0
- package/templates/svelte/src/lib/components/bd/ContactForm.svelte +69 -0
- package/templates/svelte/src/lib/components/bd/Footer.svelte +35 -0
- package/templates/svelte/src/lib/components/bd/Gallery.svelte +54 -0
- package/templates/svelte/src/lib/components/bd/Header.svelte +51 -0
- package/templates/svelte/src/lib/components/bd/Hero.svelte +19 -0
- package/templates/svelte/src/lib/components/bd/SdkSetupBanner.svelte +107 -0
- package/templates/svelte/src/lib/components/bd/Services.svelte +36 -0
- package/templates/svelte/src/lib/components/bd/StoreNav.svelte +65 -0
- package/templates/svelte/src/lib/components/bd/Subscribe.svelte +180 -0
- package/templates/svelte/src/lib/index.ts +1 -0
- package/templates/svelte/src/lib/server/bd-ai.ts +21 -0
- package/templates/svelte/src/lib/server/bd-bundle.ts +142 -0
- package/templates/svelte/src/lib/server/bd-parallel.ts +94 -0
- package/templates/svelte/src/lib/server/bd-portal.ts +187 -0
- package/templates/svelte/src/lib/server/bd-seo.ts +40 -0
- package/templates/svelte/src/lib/server/bd-store.ts +262 -0
- package/templates/svelte/src/lib/server/bd.ts +45 -0
- package/templates/svelte/src/lib/server/db/index.ts +30 -0
- package/templates/svelte/src/lib/server/db/schema.ts +7 -0
- package/templates/svelte/src/lib/vitest-examples/Welcome.svelte +8 -0
- package/templates/svelte/src/lib/vitest-examples/Welcome.svelte.spec.ts +13 -0
- package/templates/svelte/src/lib/vitest-examples/greet.spec.ts +8 -0
- package/templates/svelte/src/lib/vitest-examples/greet.ts +3 -0
- package/templates/svelte/src/routes/+error.svelte +30 -0
- package/templates/svelte/src/routes/+layout.svelte +33 -0
- package/templates/svelte/src/routes/+page.server.ts +167 -0
- package/templates/svelte/src/routes/+page.svelte +45 -0
- package/templates/svelte/src/routes/.well-known/mcp.json/+server.ts +34 -0
- package/templates/svelte/src/routes/[...slug]/+page.server.ts +30 -0
- package/templates/svelte/src/routes/[...slug]/+page.svelte +19 -0
- package/templates/svelte/src/routes/api/bd/cart/+server.ts +19 -0
- package/templates/svelte/src/routes/api/bd/cart/clear/+server.ts +13 -0
- package/templates/svelte/src/routes/api/bd/cart/coupon/+server.ts +29 -0
- package/templates/svelte/src/routes/api/bd/cart/items/+server.ts +28 -0
- package/templates/svelte/src/routes/api/bd/cart/items/[itemId]/+server.ts +31 -0
- package/templates/svelte/src/routes/api/bd/checkout/start/+server.ts +15 -0
- package/templates/svelte/src/routes/api/bd/forms/[slug]/+server.ts +36 -0
- package/templates/svelte/src/routes/api/bd/revalidate/+server.ts +40 -0
- package/templates/svelte/src/routes/api/bd/reviews/+server.ts +37 -0
- package/templates/svelte/src/routes/api/bd/scheduling/bookings/+server.ts +41 -0
- package/templates/svelte/src/routes/api/bd/scheduling/slots/+server.ts +33 -0
- package/templates/svelte/src/routes/api/bd/subscriptions/[id]/checkout/+server.ts +43 -0
- package/templates/svelte/src/routes/api/bd-auth/[...slug]/+server.ts +63 -0
- package/templates/svelte/src/routes/api/mcp/+server.ts +40 -0
- package/templates/svelte/src/routes/bd-tokens.css +518 -0
- package/templates/svelte/src/routes/demo/+page.svelte +6 -0
- package/templates/svelte/src/routes/demo/paraglide/+page.svelte +22 -0
- package/templates/svelte/src/routes/demo/playwright/+page.svelte +1 -0
- package/templates/svelte/src/routes/demo/playwright/page.svelte.e2e.ts +6 -0
- package/templates/svelte/src/routes/layout.css +10 -0
- package/templates/svelte/src/routes/llms.txt/+server.ts +42 -0
- package/templates/svelte/src/routes/my-account/+page.server.ts +165 -0
- package/templates/svelte/src/routes/my-account/+page.svelte +291 -0
- package/templates/svelte/src/routes/reviews/+page.server.ts +40 -0
- package/templates/svelte/src/routes/reviews/+page.svelte +137 -0
- package/templates/svelte/src/routes/robots.txt/+server.ts +52 -0
- package/templates/svelte/src/routes/services/+page.server.ts +15 -0
- package/templates/svelte/src/routes/services/+page.svelte +70 -0
- package/templates/svelte/src/routes/services/[service]/[area]/+page.server.ts +41 -0
- package/templates/svelte/src/routes/services/[service]/[area]/+page.svelte +67 -0
- package/templates/svelte/src/routes/sitemap.xml/+server.ts +63 -0
- package/templates/svelte/src/routes/store/+page.server.ts +98 -0
- package/templates/svelte/src/routes/store/+page.svelte +514 -0
- package/templates/svelte/src/routes/store/[id]/+page.server.ts +54 -0
- package/templates/svelte/src/routes/store/[id]/+page.svelte +511 -0
- package/templates/svelte/src/routes/store/cart/+page.server.ts +17 -0
- package/templates/svelte/src/routes/store/cart/+page.svelte +237 -0
- package/templates/svelte/src/routes/store/order/+page.server.ts +24 -0
- package/templates/svelte/src/routes/store/order/+page.svelte +68 -0
- package/templates/svelte/src/routes/store/subscriptions/+page.server.ts +35 -0
- package/templates/svelte/src/routes/store/subscriptions/+page.svelte +136 -0
- package/templates/svelte/src/routes/todos/+page.server.ts +153 -0
- package/templates/svelte/src/routes/todos/+page.svelte +175 -0
- package/templates/svelte/src/routes/updates/+page.server.ts +20 -0
- package/templates/svelte/src/routes/updates/+page.svelte +94 -0
- package/templates/svelte/src/stories/Button.stories.svelte +31 -0
- package/templates/svelte/src/stories/Button.svelte +30 -0
- package/templates/svelte/src/stories/Configure.mdx +388 -0
- package/templates/svelte/src/stories/Header.stories.svelte +26 -0
- package/templates/svelte/src/stories/Header.svelte +45 -0
- package/templates/svelte/src/stories/Page.stories.svelte +30 -0
- package/templates/svelte/src/stories/Page.svelte +70 -0
- package/templates/svelte/src/stories/assets/accessibility.png +0 -0
- package/templates/svelte/src/stories/assets/accessibility.svg +1 -0
- package/templates/svelte/src/stories/assets/addon-library.png +0 -0
- package/templates/svelte/src/stories/assets/assets.png +0 -0
- package/templates/svelte/src/stories/assets/avif-test-image.avif +0 -0
- package/templates/svelte/src/stories/assets/context.png +0 -0
- package/templates/svelte/src/stories/assets/discord.svg +1 -0
- package/templates/svelte/src/stories/assets/docs.png +0 -0
- package/templates/svelte/src/stories/assets/figma-plugin.png +0 -0
- package/templates/svelte/src/stories/assets/github.svg +1 -0
- package/templates/svelte/src/stories/assets/share.png +0 -0
- package/templates/svelte/src/stories/assets/styling.png +0 -0
- package/templates/svelte/src/stories/assets/testing.png +0 -0
- package/templates/svelte/src/stories/assets/theming.png +0 -0
- package/templates/svelte/src/stories/assets/tutorials.svg +1 -0
- package/templates/svelte/src/stories/assets/youtube.svg +1 -0
- package/templates/svelte/src/stories/button.css +30 -0
- package/templates/svelte/src/stories/header.css +32 -0
- package/templates/svelte/src/stories/page.css +68 -0
- package/templates/svelte/tsconfig.json +8 -0
- package/templates/svelte/vite.config.ts +88 -0
- package/templates/svelte/vitest.shims.d.ts +1 -0
- package/templates/swift/BdStarter.xcconfig +30 -0
- package/templates/swift/LICENSE +21 -0
- package/templates/swift/Package.swift +62 -0
- package/templates/swift/README.md +334 -0
- package/templates/swift/Sources/BdForms/Backend/BdFormsBackend.swift +441 -0
- package/templates/swift/Sources/BdForms/Controller/BdFormController.swift +717 -0
- package/templates/swift/Sources/BdForms/Engine/BdCalculation.swift +173 -0
- package/templates/swift/Sources/BdForms/Engine/BdFormRules+Client.swift +200 -0
- package/templates/swift/Sources/BdForms/Engine/BdFormRules.swift +949 -0
- package/templates/swift/Sources/BdForms/Engine/BdFormula.swift +783 -0
- package/templates/swift/Sources/BdForms/Engine/BdUnits.swift +171 -0
- package/templates/swift/Sources/BdForms/Generated/BdFormsData.generated.swift +294 -0
- package/templates/swift/Sources/BdForms/Model/BdFormSchema.swift +509 -0
- package/templates/swift/Sources/BdForms/Model/BdJSON.swift +302 -0
- package/templates/swift/Sources/BdForms/Quiz/BdQuizBackend.swift +313 -0
- package/templates/swift/Sources/BdForms/Quiz/BdQuizController.swift +271 -0
- package/templates/swift/Sources/BdForms/Quiz/BdQuizEngine.swift +757 -0
- package/templates/swift/Sources/BdForms/Quiz/BdQuizPage.swift +124 -0
- package/templates/swift/Sources/BdForms/Quiz/BdQuizScoring.swift +445 -0
- package/templates/swift/Sources/BdForms/Quiz/BdQuizScreen.swift +461 -0
- package/templates/swift/Sources/BdForms/Quiz/BdQuizWords.swift +110 -0
- package/templates/swift/Sources/BdForms/UI/BdFieldTree.swift +352 -0
- package/templates/swift/Sources/BdForms/UI/BdForm.swift +346 -0
- package/templates/swift/Sources/BdForms/UI/BdFormStyle.swift +247 -0
- package/templates/swift/Sources/BdForms/UI/BdHTML.swift +304 -0
- package/templates/swift/Sources/BdForms/UI/BdIcon.swift +351 -0
- package/templates/swift/Sources/BdForms/UI/Controls/BdChoiceControls.swift +677 -0
- package/templates/swift/Sources/BdForms/UI/Controls/BdDateControls.swift +360 -0
- package/templates/swift/Sources/BdForms/UI/Controls/BdFieldControl.swift +338 -0
- package/templates/swift/Sources/BdForms/UI/Controls/BdMediaControls.swift +412 -0
- package/templates/swift/Sources/BdForms/UI/Controls/BdStaticViews.swift +183 -0
- package/templates/swift/Sources/BdForms/UI/Controls/BdTextControls.swift +388 -0
- package/templates/swift/Sources/BdForms/UI/Quiz/BdQuiz.swift +696 -0
- package/templates/swift/Sources/BdSignIn/BdSignInBackend.swift +299 -0
- package/templates/swift/Sources/BdSignIn/BdSignInChecks.swift +158 -0
- package/templates/swift/Sources/BdSignIn/BdSignInView.swift +806 -0
- package/templates/swift/Sources/BdStarterApp/BdEnvironment.swift +138 -0
- package/templates/swift/Sources/BdStarterApp/ViewModels/CartViewModel.swift +74 -0
- package/templates/swift/Sources/BdStarterApp/ViewModels/ChatViewModel.swift +87 -0
- package/templates/swift/Sources/BdStarterApp/ViewModels/StorefrontViewModel.swift +73 -0
- package/templates/swift/Sources/BdStarterApp/ViewModels/ViewModel.swift +53 -0
- package/templates/swift/Sources/BdStarterApp/Views/AccountView.swift +163 -0
- package/templates/swift/Sources/BdStarterApp/Views/BdFormView.swift +50 -0
- package/templates/swift/Sources/BdStarterApp/Views/BdQuizView.swift +59 -0
- package/templates/swift/Sources/BdStarterApp/Views/BlogView.swift +33 -0
- package/templates/swift/Sources/BdStarterApp/Views/CartView.swift +73 -0
- package/templates/swift/Sources/BdStarterApp/Views/ChatView.swift +57 -0
- package/templates/swift/Sources/BdStarterApp/Views/LoadState.swift +50 -0
- package/templates/swift/Sources/BdStarterApp/Views/ProductDetailView.swift +57 -0
- package/templates/swift/Sources/BdStarterApp/Views/RootView.swift +60 -0
- package/templates/swift/Sources/BdStarterApp/Views/StorefrontView.swift +68 -0
- package/templates/swift/Sources/BusinessDashKit/BdAuth.swift +113 -0
- package/templates/swift/Sources/BusinessDashKit/BdClient.swift +223 -0
- package/templates/swift/Sources/BusinessDashKit/BdConfiguration.swift +59 -0
- package/templates/swift/Sources/BusinessDashKit/BdError.swift +71 -0
- package/templates/swift/Sources/BusinessDashKit/BdSessionStore.swift +83 -0
- package/templates/swift/Sources/BusinessDashKit/ChatFeed.swift +145 -0
- package/templates/swift/Sources/BusinessDashKit/Donations.swift +144 -0
- package/templates/swift/Sources/BusinessDashKit/JSONValue.swift +118 -0
- package/templates/swift/Sources/BusinessDashKit/Models.swift +447 -0
- package/templates/swift/Sources/BusinessDashKit/Money.swift +33 -0
- package/templates/swift/Sources/BusinessDashKit/Resources.swift +439 -0
- package/templates/swift/Sources/BusinessDashKit/Scheduling.swift +128 -0
- package/templates/swift/Sources/BusinessDashKit/Seo.swift +169 -0
- package/templates/swift/Sources/BusinessDashKit/SocialPlatforms.generated.swift +48 -0
- package/templates/swift/Sources/BusinessDashKit/Socials.swift +160 -0
- package/templates/swift/Tests/BdFormsTests/ControllerTests.swift +356 -0
- package/templates/swift/Tests/BdFormsTests/Fixtures/forms-parity.json +3806 -0
- package/templates/swift/Tests/BdFormsTests/Fixtures/quiz-parity.json +9937 -0
- package/templates/swift/Tests/BdFormsTests/FormsBackendPathTests.swift +17 -0
- package/templates/swift/Tests/BdFormsTests/ParityTests.swift +192 -0
- package/templates/swift/Tests/BdFormsTests/QuizControllerTests.swift +342 -0
- package/templates/swift/Tests/BdFormsTests/QuizParityTests.swift +230 -0
- package/templates/swift/Tests/BdSignInTests/BdSignInChecksTests.swift +49 -0
- package/templates/swift/Tests/BusinessDashKitTests/BusinessDashKitTests.swift +367 -0
- package/templates/swift/_gitignore +9 -0
- package/templates/swift/bd-records/README.md +50 -0
- package/templates/swift/bd-records/todo-images.json +14 -0
- package/templates/swift/bd-records/todos.json +20 -0
- package/templates/swift/bd.config.ts +331 -0
- package/templates/swift/bd.data-model.config.ts +89 -0
- package/templates/swift/package.json +20 -0
- package/templates/swift/pnpm-lock.yaml +347 -0
- package/templates/swift/tsconfig.json +19 -0
- package/templates/t3/.env.example +62 -0
- package/templates/t3/README.md +428 -0
- package/templates/t3/_gitignore +46 -0
- package/templates/t3/bd.config.ts +331 -0
- package/templates/t3/bd.data-model.config.ts +90 -0
- package/templates/t3/biome.jsonc +69 -0
- package/templates/t3/drizzle.config.ts +15 -0
- package/templates/t3/next.config.js +17 -0
- package/templates/t3/package.json +64 -0
- package/templates/t3/pnpm-lock.yaml +1843 -0
- package/templates/t3/postcss.config.js +5 -0
- package/templates/t3/public/favicon.ico +0 -0
- package/templates/t3/src/app/.well-known/mcp.json/route.ts +17 -0
- package/templates/t3/src/app/[...slug]/page.tsx +71 -0
- package/templates/t3/src/app/_actions/plans.ts +60 -0
- package/templates/t3/src/app/_actions/review.ts +88 -0
- package/templates/t3/src/app/_actions/store.ts +119 -0
- package/templates/t3/src/app/_components/bd/About.tsx +25 -0
- package/templates/t3/src/app/_components/bd/AuthButtons.tsx +49 -0
- package/templates/t3/src/app/_components/bd/Blog.tsx +47 -0
- package/templates/t3/src/app/_components/bd/Booking.tsx +257 -0
- package/templates/t3/src/app/_components/bd/ContactForm.tsx +82 -0
- package/templates/t3/src/app/_components/bd/Footer.tsx +25 -0
- package/templates/t3/src/app/_components/bd/Gallery.tsx +49 -0
- package/templates/t3/src/app/_components/bd/Header.tsx +27 -0
- package/templates/t3/src/app/_components/bd/Hero.tsx +14 -0
- package/templates/t3/src/app/_components/bd/NewsBanner.tsx +57 -0
- package/templates/t3/src/app/_components/bd/ReviewForm.tsx +95 -0
- package/templates/t3/src/app/_components/bd/Reviews.tsx +83 -0
- package/templates/t3/src/app/_components/bd/ReviewsLoadMore.tsx +107 -0
- package/templates/t3/src/app/_components/bd/SdkSetupBanner.tsx +97 -0
- package/templates/t3/src/app/_components/bd/Services.tsx +30 -0
- package/templates/t3/src/app/_components/bd/SignInScreen.tsx +32 -0
- package/templates/t3/src/app/_components/bd/Subscribe.tsx +157 -0
- package/templates/t3/src/app/_components/bd/Updates.tsx +90 -0
- package/templates/t3/src/app/_components/post.tsx +50 -0
- package/templates/t3/src/app/ai/product-feed/route.ts +21 -0
- package/templates/t3/src/app/api/bd/revalidate/route.ts +16 -0
- package/templates/t3/src/app/api/bd-auth/[...slug]/route.ts +39 -0
- package/templates/t3/src/app/api/mcp/route.ts +36 -0
- package/templates/t3/src/app/api/trpc/[trpc]/route.ts +34 -0
- package/templates/t3/src/app/layout.tsx +55 -0
- package/templates/t3/src/app/llms.txt/route.ts +21 -0
- package/templates/t3/src/app/my-account/page.tsx +259 -0
- package/templates/t3/src/app/not-found.tsx +26 -0
- package/templates/t3/src/app/page.tsx +89 -0
- package/templates/t3/src/app/robots.txt/route.ts +51 -0
- package/templates/t3/src/app/services/[service]/[area]/page.tsx +114 -0
- package/templates/t3/src/app/sitemap.xml/route.ts +75 -0
- package/templates/t3/src/app/store/[id]/page.tsx +69 -0
- package/templates/t3/src/app/store/_components/AddToCart.tsx +117 -0
- package/templates/t3/src/app/store/_components/CartClient.tsx +198 -0
- package/templates/t3/src/app/store/_components/Notice.tsx +11 -0
- package/templates/t3/src/app/store/_components/StoreView.tsx +372 -0
- package/templates/t3/src/app/store/_components/store-utils.ts +63 -0
- package/templates/t3/src/app/store/cart/page.tsx +28 -0
- package/templates/t3/src/app/store/layout.tsx +38 -0
- package/templates/t3/src/app/store/order/page.tsx +88 -0
- package/templates/t3/src/app/store/page.tsx +104 -0
- package/templates/t3/src/app/store/subscriptions/page.tsx +110 -0
- package/templates/t3/src/app/todos/TodoCreateForm.tsx +68 -0
- package/templates/t3/src/app/todos/page.tsx +134 -0
- package/templates/t3/src/env.js +78 -0
- package/templates/t3/src/server/api/root.ts +25 -0
- package/templates/t3/src/server/api/routers/bd.ts +359 -0
- package/templates/t3/src/server/api/routers/post.ts +30 -0
- package/templates/t3/src/server/api/trpc.ts +106 -0
- package/templates/t3/src/server/db/index.ts +40 -0
- package/templates/t3/src/server/db/schema.ts +26 -0
- package/templates/t3/src/server/lib/bd-distribution.ts +28 -0
- package/templates/t3/src/server/lib/bd-portal.ts +163 -0
- package/templates/t3/src/server/lib/bd-seo.ts +55 -0
- package/templates/t3/src/server/lib/bd-store.ts +177 -0
- package/templates/t3/src/server/lib/bd-todos.ts +138 -0
- package/templates/t3/src/server/lib/bd.ts +260 -0
- package/templates/t3/src/styles/globals.css +1088 -0
- package/templates/t3/src/trpc/query-client.ts +25 -0
- package/templates/t3/src/trpc/react.tsx +78 -0
- package/templates/t3/src/trpc/server.ts +30 -0
- package/templates/t3/start-database.sh +88 -0
- package/templates/t3/tsconfig.json +42 -0
- package/templates/vanilla/.env.example +51 -0
- package/templates/vanilla/README.md +345 -0
- package/templates/vanilla/_gitignore +7 -0
- package/templates/vanilla/bd.config.ts +331 -0
- package/templates/vanilla/bd.data-model.config.ts +89 -0
- package/templates/vanilla/lib/cache.ts +58 -0
- package/templates/vanilla/package.json +23 -0
- package/templates/vanilla/pnpm-lock.yaml +97 -0
- package/templates/vanilla/public/banner.js +75 -0
- package/templates/vanilla/public/bd.js +435 -0
- package/templates/vanilla/public/index.html +74 -0
- package/templates/vanilla/public/main.js +59 -0
- package/templates/vanilla/public/pages/_ui.js +24 -0
- package/templates/vanilla/public/pages/cart.js +143 -0
- package/templates/vanilla/public/pages/my-account.js +182 -0
- package/templates/vanilla/public/pages/product.js +211 -0
- package/templates/vanilla/public/pages/reviews.js +56 -0
- package/templates/vanilla/public/pages/services-area.js +33 -0
- package/templates/vanilla/public/pages/services.js +26 -0
- package/templates/vanilla/public/pages/store.js +271 -0
- package/templates/vanilla/public/pages/subscriptions.js +80 -0
- package/templates/vanilla/public/pages/todos.js +160 -0
- package/templates/vanilla/public/pages/updates.js +46 -0
- package/templates/vanilla/public/sections/about.js +47 -0
- package/templates/vanilla/public/sections/blog.js +66 -0
- package/templates/vanilla/public/sections/booking.js +304 -0
- package/templates/vanilla/public/sections/contact-form.js +104 -0
- package/templates/vanilla/public/sections/gallery.js +70 -0
- package/templates/vanilla/public/sections/hero.js +43 -0
- package/templates/vanilla/public/sections/services.js +70 -0
- package/templates/vanilla/public/sections/subscribe.js +160 -0
- package/templates/vanilla/public/setup-banner.js +81 -0
- package/templates/vanilla/public/styles.css +1720 -0
- package/templates/vanilla/server.ts +1192 -0
- package/templates/vanilla/src/content/en/home/about.json +4 -0
- package/templates/vanilla/src/content/en/home/hero.json +6 -0
- package/templates/vanilla/src/content/en/shared/brand.json +5 -0
- package/templates/vanilla/src/content/en/shared/companyInfo.json +11 -0
- package/templates/vanilla/tsconfig.json +14 -0
- package/templates/vapor/.env.example +38 -0
- package/templates/vapor/Package.resolved +285 -0
- package/templates/vapor/Package.swift +33 -0
- package/templates/vapor/Public/bd-sign-in.css +53 -0
- package/templates/vapor/Public/forms.css +1158 -0
- package/templates/vapor/Public/styles.css +100 -0
- package/templates/vapor/README.md +280 -0
- package/templates/vapor/Resources/Forms/demo-form.json +283 -0
- package/templates/vapor/Resources/Forms/demo-quiz.json +97 -0
- package/templates/vapor/Resources/Views/account.leaf +23 -0
- package/templates/vapor/Resources/Views/base.leaf +51 -0
- package/templates/vapor/Resources/Views/blog.leaf +18 -0
- package/templates/vapor/Resources/Views/cart.leaf +30 -0
- package/templates/vapor/Resources/Views/delete-account.leaf +26 -0
- package/templates/vapor/Resources/Views/form.leaf +6 -0
- package/templates/vapor/Resources/Views/home.leaf +37 -0
- package/templates/vapor/Resources/Views/post.leaf +15 -0
- package/templates/vapor/Resources/Views/product.leaf +28 -0
- package/templates/vapor/Resources/Views/quiz.leaf +6 -0
- package/templates/vapor/Resources/Views/reviews.leaf +16 -0
- package/templates/vapor/Resources/Views/service-area.leaf +9 -0
- package/templates/vapor/Resources/Views/services.leaf +15 -0
- package/templates/vapor/Resources/Views/store.leaf +37 -0
- package/templates/vapor/Resources/Views/subscriptions.leaf +18 -0
- package/templates/vapor/Resources/Views/todos.leaf +28 -0
- package/templates/vapor/Sources/App/Bd/BdCache.swift +99 -0
- package/templates/vapor/Sources/App/Bd/BdClient.swift +178 -0
- package/templates/vapor/Sources/App/Bd/BdWebhook.swift +92 -0
- package/templates/vapor/Sources/App/Bd/Donations.swift +95 -0
- package/templates/vapor/Sources/App/Bd/JSONValue.swift +66 -0
- package/templates/vapor/Sources/App/Bd/Models.swift +153 -0
- package/templates/vapor/Sources/App/Bd/Money.swift +29 -0
- package/templates/vapor/Sources/App/Bd/PortalResources.swift +372 -0
- package/templates/vapor/Sources/App/Bd/Resources.swift +115 -0
- package/templates/vapor/Sources/App/Bd/Scheduling.swift +135 -0
- package/templates/vapor/Sources/App/Bd/Seo.swift +169 -0
- package/templates/vapor/Sources/App/Bd/SignInCore.swift +232 -0
- package/templates/vapor/Sources/App/Bd/SocialPlatforms.generated.swift +48 -0
- package/templates/vapor/Sources/App/Bd/Socials.swift +96 -0
- package/templates/vapor/Sources/App/Controllers/AccountController.swift +435 -0
- package/templates/vapor/Sources/App/Controllers/CartController.swift +107 -0
- package/templates/vapor/Sources/App/Controllers/Contexts.swift +124 -0
- package/templates/vapor/Sources/App/Controllers/PageController.swift +151 -0
- package/templates/vapor/Sources/App/Controllers/SeoController.swift +83 -0
- package/templates/vapor/Sources/App/Controllers/SignInController.swift +583 -0
- package/templates/vapor/Sources/App/Controllers/StoreController.swift +48 -0
- package/templates/vapor/Sources/App/Controllers/WebhookController.swift +34 -0
- package/templates/vapor/Sources/App/Forms/FormPage.swift +900 -0
- package/templates/vapor/Sources/App/Forms/FormPost.swift +125 -0
- package/templates/vapor/Sources/App/Forms/FormRoutes.swift +36 -0
- package/templates/vapor/Sources/App/Forms/FormSamples.swift +45 -0
- package/templates/vapor/Sources/App/Forms/QuizPage.swift +481 -0
- package/templates/vapor/Sources/App/Forms/QuizRoutes.swift +77 -0
- package/templates/vapor/Sources/App/configure.swift +18 -0
- package/templates/vapor/Sources/App/entrypoint.swift +20 -0
- package/templates/vapor/Sources/App/routes.swift +62 -0
- package/templates/vapor/Sources/BdForms/Backend/BdFormsBackend.swift +445 -0
- package/templates/vapor/Sources/BdForms/Controller/BdFormController.swift +721 -0
- package/templates/vapor/Sources/BdForms/Engine/BdCalculation.swift +177 -0
- package/templates/vapor/Sources/BdForms/Engine/BdFormRules+Client.swift +204 -0
- package/templates/vapor/Sources/BdForms/Engine/BdFormRules.swift +953 -0
- package/templates/vapor/Sources/BdForms/Engine/BdFormula.swift +787 -0
- package/templates/vapor/Sources/BdForms/Engine/BdUnits.swift +175 -0
- package/templates/vapor/Sources/BdForms/Generated/BdFormsData.generated.swift +298 -0
- package/templates/vapor/Sources/BdForms/Model/BdFormSchema.swift +513 -0
- package/templates/vapor/Sources/BdForms/Model/BdJSON.swift +306 -0
- package/templates/vapor/Sources/BdForms/Quiz/BdQuizBackend.swift +317 -0
- package/templates/vapor/Sources/BdForms/Quiz/BdQuizController.swift +275 -0
- package/templates/vapor/Sources/BdForms/Quiz/BdQuizEngine.swift +761 -0
- package/templates/vapor/Sources/BdForms/Quiz/BdQuizPage.swift +128 -0
- package/templates/vapor/Sources/BdForms/Quiz/BdQuizScoring.swift +449 -0
- package/templates/vapor/Sources/BdForms/Quiz/BdQuizScreen.swift +465 -0
- package/templates/vapor/Sources/BdForms/Quiz/BdQuizWords.swift +114 -0
- package/templates/vapor/_gitignore +9 -0
- package/templates/vapor/bd-records/README.md +50 -0
- package/templates/vapor/bd-records/todo-images.json +14 -0
- package/templates/vapor/bd-records/todos.json +20 -0
- package/templates/vapor/bd.config.ts +331 -0
- package/templates/vapor/bd.data-model.config.ts +89 -0
- package/templates/vapor/package.json +20 -0
- package/templates/vapor/pnpm-lock.yaml +347 -0
- package/templates/vapor/tsconfig.json +19 -0
|
@@ -0,0 +1,1966 @@
|
|
|
1
|
+
import {
|
|
2
|
+
baseUnitFor,
|
|
3
|
+
COLLECTION_SELECT_TEXT,
|
|
4
|
+
collectionOptionVisual,
|
|
5
|
+
convertToBase,
|
|
6
|
+
type FormCoreField,
|
|
7
|
+
formatMeasurement,
|
|
8
|
+
isMeasurementCategory,
|
|
9
|
+
isPendingFileValue,
|
|
10
|
+
resolveFieldAutocomplete,
|
|
11
|
+
shouldSearchOptions,
|
|
12
|
+
US_STATES,
|
|
13
|
+
unitsForCategory,
|
|
14
|
+
validateFile,
|
|
15
|
+
} from '@businessdash/sdk/forms'
|
|
16
|
+
import { useEffect, useMemo, useState } from 'react'
|
|
17
|
+
import { Image, Linking, Pressable, ScrollView, StyleSheet, View } from 'react-native'
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
addDays,
|
|
21
|
+
formatBytes,
|
|
22
|
+
formatNumber,
|
|
23
|
+
formatPhone,
|
|
24
|
+
formatTime,
|
|
25
|
+
htmlToMarkup,
|
|
26
|
+
markupToHtml,
|
|
27
|
+
parseDay,
|
|
28
|
+
parseNumber,
|
|
29
|
+
record,
|
|
30
|
+
safeHttpUrl,
|
|
31
|
+
sanitizeNumber,
|
|
32
|
+
str,
|
|
33
|
+
stringList,
|
|
34
|
+
timesOfDay,
|
|
35
|
+
today,
|
|
36
|
+
toggled,
|
|
37
|
+
toggleListLine,
|
|
38
|
+
wrapSelection,
|
|
39
|
+
} from './logic'
|
|
40
|
+
import { BdColorField, BdDateField, BdTimeField, monthNames } from './pickers'
|
|
41
|
+
import {
|
|
42
|
+
BdButton,
|
|
43
|
+
BdCheckGlyph,
|
|
44
|
+
BdChip,
|
|
45
|
+
BdChoiceGroup,
|
|
46
|
+
BdChoiceRow,
|
|
47
|
+
BdLoadingRow,
|
|
48
|
+
BdMark,
|
|
49
|
+
type BdOption,
|
|
50
|
+
BdOptionPicker,
|
|
51
|
+
BdRetryRow,
|
|
52
|
+
BdSegmented,
|
|
53
|
+
BdSlider,
|
|
54
|
+
BdText,
|
|
55
|
+
BdTextField,
|
|
56
|
+
BdSwitch,
|
|
57
|
+
inputTraits,
|
|
58
|
+
SIGNED_KEYBOARD,
|
|
59
|
+
} from './primitives'
|
|
60
|
+
import {
|
|
61
|
+
type BdFieldContext,
|
|
62
|
+
type BdPendingFile,
|
|
63
|
+
type BdPickedFile,
|
|
64
|
+
useBdFormRuntime,
|
|
65
|
+
} from './runtime'
|
|
66
|
+
import { BdCalculationView, BdIcon, BdStaticContent } from './static'
|
|
67
|
+
import { fmt, useBdForm } from './theme'
|
|
68
|
+
|
|
69
|
+
const STATIC_TYPES = new Set([
|
|
70
|
+
'title',
|
|
71
|
+
'subtitle',
|
|
72
|
+
'separator',
|
|
73
|
+
'richtext',
|
|
74
|
+
'body_text',
|
|
75
|
+
'bullet_list',
|
|
76
|
+
'table',
|
|
77
|
+
'image',
|
|
78
|
+
])
|
|
79
|
+
|
|
80
|
+
/** The built-in control for a field's type. */
|
|
81
|
+
export function BdFieldControl(ctx: BdFieldContext) {
|
|
82
|
+
const t = ctx.field.type
|
|
83
|
+
if (STATIC_TYPES.has(t)) return <BdStaticContent field={ctx.field} />
|
|
84
|
+
switch (t) {
|
|
85
|
+
case 'calculation':
|
|
86
|
+
return <BdCalculationView field={ctx.field} value={ctx.value} />
|
|
87
|
+
case 'textarea':
|
|
88
|
+
return <TextAreaControl {...ctx} />
|
|
89
|
+
case 'phone':
|
|
90
|
+
return <PhoneControl {...ctx} />
|
|
91
|
+
case 'url':
|
|
92
|
+
return <UrlControl {...ctx} />
|
|
93
|
+
case 'number':
|
|
94
|
+
return <NumberControl {...ctx} />
|
|
95
|
+
case 'currency':
|
|
96
|
+
return <CurrencyControl {...ctx} />
|
|
97
|
+
case 'measurement':
|
|
98
|
+
return <MeasurementControl {...ctx} />
|
|
99
|
+
case 'name':
|
|
100
|
+
return <NameControl {...ctx} />
|
|
101
|
+
case 'address':
|
|
102
|
+
return <AddressControl {...ctx} />
|
|
103
|
+
case 'tags':
|
|
104
|
+
return <TagsControl {...ctx} />
|
|
105
|
+
case 'rich_text_input':
|
|
106
|
+
return <RichTextControl {...ctx} />
|
|
107
|
+
case 'select':
|
|
108
|
+
return <SelectControl {...ctx} />
|
|
109
|
+
case 'radio':
|
|
110
|
+
return <RadioControl {...ctx} />
|
|
111
|
+
case 'checkbox':
|
|
112
|
+
return <CheckboxControl {...ctx} />
|
|
113
|
+
case 'choice_cards':
|
|
114
|
+
return <ChoiceCardsControl {...ctx} />
|
|
115
|
+
case 'boolean':
|
|
116
|
+
return <BooleanControl {...ctx} />
|
|
117
|
+
case 'icon_select':
|
|
118
|
+
return <IconSelectControl {...ctx} />
|
|
119
|
+
case 'service_selector':
|
|
120
|
+
return <ServiceControl {...ctx} />
|
|
121
|
+
case 'collection_select':
|
|
122
|
+
return <CollectionControl {...ctx} />
|
|
123
|
+
case 'color_picker':
|
|
124
|
+
return (
|
|
125
|
+
<BdColorField value={str(ctx.value)} presets={ctx.field.options ?? []} onChange={ctx.set} />
|
|
126
|
+
)
|
|
127
|
+
case 'slider':
|
|
128
|
+
return <SliderControl {...ctx} />
|
|
129
|
+
case 'star_rating':
|
|
130
|
+
return <StarsControl {...ctx} />
|
|
131
|
+
case 'happiness_rating':
|
|
132
|
+
return <HappinessControl {...ctx} />
|
|
133
|
+
case 'stepper':
|
|
134
|
+
return <StepperControl {...ctx} />
|
|
135
|
+
case 'date':
|
|
136
|
+
return (
|
|
137
|
+
<BdDateField
|
|
138
|
+
value={str(ctx.value)}
|
|
139
|
+
onChange={ctx.set}
|
|
140
|
+
title={ctx.field.label ?? undefined}
|
|
141
|
+
placeholder={ctx.field.placeholder}
|
|
142
|
+
isError={!!ctx.error}
|
|
143
|
+
/>
|
|
144
|
+
)
|
|
145
|
+
case 'date_range':
|
|
146
|
+
return <DateRangeControl {...ctx} />
|
|
147
|
+
case 'time_picker':
|
|
148
|
+
return <TimeControl {...ctx} />
|
|
149
|
+
case 'month_year':
|
|
150
|
+
return <MonthYearControl {...ctx} />
|
|
151
|
+
case 'schedule':
|
|
152
|
+
return (ctx.field as { scheduleConfig?: { mode?: string } }).scheduleConfig?.mode ===
|
|
153
|
+
'auto' ? (
|
|
154
|
+
<BookingControl {...ctx} />
|
|
155
|
+
) : (
|
|
156
|
+
<AvailabilityControl {...ctx} />
|
|
157
|
+
)
|
|
158
|
+
case 'file_upload':
|
|
159
|
+
return <FileControl {...ctx} />
|
|
160
|
+
case 'image_input':
|
|
161
|
+
return <ImageInputControl {...ctx} />
|
|
162
|
+
case 'credit_card':
|
|
163
|
+
return <CardControl {...ctx} />
|
|
164
|
+
default:
|
|
165
|
+
return <TextControl {...ctx} />
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// ─── Text ────────────────────────────────────────────────────────────────────
|
|
170
|
+
|
|
171
|
+
function useTraits(field: FormCoreField) {
|
|
172
|
+
const { autocomplete } = useBdFormRuntime()
|
|
173
|
+
return inputTraits(resolveFieldAutocomplete(field, autocomplete))
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function TextControl({ field, value, error, set }: BdFieldContext) {
|
|
177
|
+
const traits = useTraits(field)
|
|
178
|
+
const email = field.type === 'email'
|
|
179
|
+
return (
|
|
180
|
+
<BdTextField
|
|
181
|
+
value={str(value)}
|
|
182
|
+
onChangeText={set}
|
|
183
|
+
placeholder={field.placeholder || (email ? 'name@example.com' : undefined)}
|
|
184
|
+
isError={!!error}
|
|
185
|
+
returnKeyType="next"
|
|
186
|
+
{...traits}
|
|
187
|
+
{...(email
|
|
188
|
+
? {
|
|
189
|
+
keyboardType: 'email-address' as const,
|
|
190
|
+
autoCapitalize: 'none' as const,
|
|
191
|
+
autoCorrect: false,
|
|
192
|
+
autoComplete: traits.autoComplete ?? ('email' as const),
|
|
193
|
+
}
|
|
194
|
+
: {})}
|
|
195
|
+
/>
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function TextAreaControl({ field, value, error, set }: BdFieldContext) {
|
|
200
|
+
const rows = Math.max(
|
|
201
|
+
(field as { textareaConfig?: { rows?: number } }).textareaConfig?.rows ?? 4,
|
|
202
|
+
1,
|
|
203
|
+
)
|
|
204
|
+
return (
|
|
205
|
+
<BdTextField
|
|
206
|
+
value={str(value)}
|
|
207
|
+
onChangeText={set}
|
|
208
|
+
placeholder={field.placeholder}
|
|
209
|
+
isError={!!error}
|
|
210
|
+
multiline
|
|
211
|
+
minLines={rows}
|
|
212
|
+
/>
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function PhoneControl({ field, value, error, set }: BdFieldContext) {
|
|
217
|
+
const cfg = field.phoneConfig
|
|
218
|
+
const intl = cfg?.international === true
|
|
219
|
+
const traits = useTraits(field)
|
|
220
|
+
return (
|
|
221
|
+
<BdTextField
|
|
222
|
+
value={str(value)}
|
|
223
|
+
onChangeText={(t) => set(formatPhone(t, intl))}
|
|
224
|
+
placeholder={field.placeholder || (intl ? '+1 555 000 0000' : '(555) 000-0000')}
|
|
225
|
+
keyboardType="phone-pad"
|
|
226
|
+
autoComplete={traits.autoComplete ?? 'tel'}
|
|
227
|
+
textContentType="telephoneNumber"
|
|
228
|
+
leading={cfg?.showFlags ? <BdText>🇺🇸</BdText> : undefined}
|
|
229
|
+
isError={!!error}
|
|
230
|
+
/>
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function UrlControl({ field, value, error, set }: BdFieldContext) {
|
|
235
|
+
return (
|
|
236
|
+
<BdTextField
|
|
237
|
+
value={str(record(value)['url'])}
|
|
238
|
+
onChangeText={(t) => set({ url: t })}
|
|
239
|
+
placeholder={field.placeholder || 'https://example.com'}
|
|
240
|
+
keyboardType="url"
|
|
241
|
+
autoCapitalize="none"
|
|
242
|
+
autoCorrect={false}
|
|
243
|
+
autoComplete="url"
|
|
244
|
+
textContentType="URL"
|
|
245
|
+
isError={!!error}
|
|
246
|
+
/>
|
|
247
|
+
)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// ─── Numbers ─────────────────────────────────────────────────────────────────
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* A number typed as text: keeps what the visitor typed ("1.", "-") while the
|
|
254
|
+
* value stays a number, and filters out what the field doesn't allow.
|
|
255
|
+
*/
|
|
256
|
+
function BdNumericInput({
|
|
257
|
+
value,
|
|
258
|
+
onChange,
|
|
259
|
+
allowDecimal,
|
|
260
|
+
allowNegative,
|
|
261
|
+
placeholder,
|
|
262
|
+
leading,
|
|
263
|
+
isError,
|
|
264
|
+
style,
|
|
265
|
+
}: {
|
|
266
|
+
value: number | null
|
|
267
|
+
onChange: (n: number | null) => void
|
|
268
|
+
allowDecimal: boolean
|
|
269
|
+
allowNegative: boolean
|
|
270
|
+
placeholder?: string | undefined
|
|
271
|
+
leading?: React.ReactNode
|
|
272
|
+
isError?: boolean | undefined
|
|
273
|
+
style?: import('react-native').StyleProp<import('react-native').ViewStyle>
|
|
274
|
+
}) {
|
|
275
|
+
const [text, setText] = useState(formatNumber(value))
|
|
276
|
+
const [seen, setSeen] = useState(value)
|
|
277
|
+
// A change from outside (reset, a default) replaces the text; the
|
|
278
|
+
// visitor's own keystrokes don't round-trip through it.
|
|
279
|
+
if (value !== seen) {
|
|
280
|
+
setSeen(value)
|
|
281
|
+
if (parseNumber(text) !== value) setText(formatNumber(value))
|
|
282
|
+
}
|
|
283
|
+
return (
|
|
284
|
+
<BdTextField
|
|
285
|
+
style={style}
|
|
286
|
+
value={text}
|
|
287
|
+
onChangeText={(raw) => {
|
|
288
|
+
const clean = sanitizeNumber(raw, allowDecimal, allowNegative)
|
|
289
|
+
setText(clean)
|
|
290
|
+
const n = parseNumber(clean)
|
|
291
|
+
if (n !== value) {
|
|
292
|
+
setSeen(n)
|
|
293
|
+
onChange(n)
|
|
294
|
+
}
|
|
295
|
+
}}
|
|
296
|
+
placeholder={placeholder}
|
|
297
|
+
keyboardType={allowNegative ? SIGNED_KEYBOARD : allowDecimal ? 'decimal-pad' : 'number-pad'}
|
|
298
|
+
leading={leading}
|
|
299
|
+
isError={isError}
|
|
300
|
+
/>
|
|
301
|
+
)
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function num(v: unknown): number | null {
|
|
305
|
+
return typeof v === 'number' && Number.isFinite(v) ? v : null
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function NumberControl({ field, value, error, set }: BdFieldContext) {
|
|
309
|
+
const allowDecimal = field.allowDecimal !== false
|
|
310
|
+
return (
|
|
311
|
+
<BdNumericInput
|
|
312
|
+
value={num(value)}
|
|
313
|
+
onChange={(n) => set(n == null ? null : allowDecimal ? n : Math.trunc(n))}
|
|
314
|
+
allowDecimal={allowDecimal}
|
|
315
|
+
allowNegative={field.allowNegative !== false}
|
|
316
|
+
placeholder={field.placeholder}
|
|
317
|
+
isError={!!error}
|
|
318
|
+
/>
|
|
319
|
+
)
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function CurrencyControl({ field, value, error, set }: BdFieldContext) {
|
|
323
|
+
const cfg = field.currencyConfig
|
|
324
|
+
const allowDecimal = cfg?.allowDecimal !== false
|
|
325
|
+
const { theme } = useBdForm()
|
|
326
|
+
return (
|
|
327
|
+
<BdNumericInput
|
|
328
|
+
value={num(value)}
|
|
329
|
+
onChange={(n) => set(n == null ? null : allowDecimal ? n : Math.trunc(n))}
|
|
330
|
+
allowDecimal={allowDecimal}
|
|
331
|
+
allowNegative={cfg?.allowNegative === true}
|
|
332
|
+
placeholder={field.placeholder || (allowDecimal ? '0.00' : '0')}
|
|
333
|
+
leading={<BdText color={theme.colors.textSecondary}>{cfg?.symbol || '$'}</BdText>}
|
|
334
|
+
isError={!!error}
|
|
335
|
+
/>
|
|
336
|
+
)
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function MeasurementControl({ field, value, error, set }: BdFieldContext) {
|
|
340
|
+
const { theme } = useBdForm()
|
|
341
|
+
const cfg = field.unitConfig ?? {}
|
|
342
|
+
const category = isMeasurementCategory(cfg.category) ? cfg.category : 'length'
|
|
343
|
+
const units = cfg.units && cfg.units.length > 0 ? cfg.units : unitsForCategory(category)
|
|
344
|
+
const mv = record(value)
|
|
345
|
+
const unit = str(mv['unit']) || cfg.defaultUnit || units[0] || ''
|
|
346
|
+
const n = num(mv['value'])
|
|
347
|
+
const allowDecimal = cfg.allowDecimal !== false
|
|
348
|
+
const emit = (next: number | null, nextUnit: string) => {
|
|
349
|
+
const base = next == null ? null : convertToBase(next, nextUnit, category)
|
|
350
|
+
set({
|
|
351
|
+
value: next ?? '',
|
|
352
|
+
unit: nextUnit,
|
|
353
|
+
...(base == null ? {} : { base }),
|
|
354
|
+
baseUnit: baseUnitFor(category),
|
|
355
|
+
})
|
|
356
|
+
}
|
|
357
|
+
return (
|
|
358
|
+
<View style={styles.gap6}>
|
|
359
|
+
<View style={styles.row8}>
|
|
360
|
+
<BdNumericInput
|
|
361
|
+
style={styles.flex}
|
|
362
|
+
value={n}
|
|
363
|
+
onChange={(v) => emit(v == null ? null : allowDecimal ? v : Math.trunc(v), unit)}
|
|
364
|
+
allowDecimal={allowDecimal}
|
|
365
|
+
allowNegative={category === 'temperature'}
|
|
366
|
+
placeholder={field.placeholder || '0'}
|
|
367
|
+
isError={!!error}
|
|
368
|
+
/>
|
|
369
|
+
{cfg.mode === 'fixed' ? (
|
|
370
|
+
<BdText color={theme.colors.textSecondary}>{unit}</BdText>
|
|
371
|
+
) : (
|
|
372
|
+
<BdOptionPicker
|
|
373
|
+
style={styles.unitPicker}
|
|
374
|
+
title={field.label || unit}
|
|
375
|
+
placeholder={unit}
|
|
376
|
+
options={units.map((u) => ({ value: u, label: u }))}
|
|
377
|
+
selection={[unit]}
|
|
378
|
+
onSelect={(next) => next[0] && emit(n, next[0])}
|
|
379
|
+
multi={false}
|
|
380
|
+
searchable={false}
|
|
381
|
+
/>
|
|
382
|
+
)}
|
|
383
|
+
</View>
|
|
384
|
+
{n != null ? (
|
|
385
|
+
<BdText variant="caption">≈ {formatMeasurement(n, unit, category)}</BdText>
|
|
386
|
+
) : null}
|
|
387
|
+
</View>
|
|
388
|
+
)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// ─── Name & address ──────────────────────────────────────────────────────────
|
|
392
|
+
|
|
393
|
+
function PartField({
|
|
394
|
+
ctx,
|
|
395
|
+
part,
|
|
396
|
+
label,
|
|
397
|
+
placeholder,
|
|
398
|
+
token,
|
|
399
|
+
filter,
|
|
400
|
+
}: {
|
|
401
|
+
ctx: BdFieldContext
|
|
402
|
+
part: string
|
|
403
|
+
label: string
|
|
404
|
+
placeholder?: string
|
|
405
|
+
token?: string
|
|
406
|
+
filter?: (s: string) => string
|
|
407
|
+
}) {
|
|
408
|
+
const v = record(ctx.value)[part]
|
|
409
|
+
const text = Array.isArray(v) ? stringList(v).join(', ') : str(v)
|
|
410
|
+
const off = ctx.field.autocomplete === 'off'
|
|
411
|
+
const traits = inputTraits(off ? 'off' : token)
|
|
412
|
+
return (
|
|
413
|
+
<BdTextField
|
|
414
|
+
label={label}
|
|
415
|
+
value={text}
|
|
416
|
+
onChangeText={(t) => ctx.set({ ...record(ctx.value), [part]: filter ? filter(t) : t })}
|
|
417
|
+
placeholder={placeholder}
|
|
418
|
+
isError={!!ctx.error}
|
|
419
|
+
{...traits}
|
|
420
|
+
/>
|
|
421
|
+
)
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function NameControl(ctx: BdFieldContext) {
|
|
425
|
+
const { strings } = useBdForm()
|
|
426
|
+
const cfg = ctx.field.nameConfig
|
|
427
|
+
return (
|
|
428
|
+
<View style={styles.gap10}>
|
|
429
|
+
{cfg?.prefix ? (
|
|
430
|
+
<PartField
|
|
431
|
+
ctx={ctx}
|
|
432
|
+
part="prefix"
|
|
433
|
+
label={strings.namePrefix}
|
|
434
|
+
placeholder="Dr."
|
|
435
|
+
token="honorific-prefix"
|
|
436
|
+
/>
|
|
437
|
+
) : null}
|
|
438
|
+
<PartField
|
|
439
|
+
ctx={ctx}
|
|
440
|
+
part="first"
|
|
441
|
+
label={strings.firstName}
|
|
442
|
+
placeholder="Jane"
|
|
443
|
+
token="given-name"
|
|
444
|
+
/>
|
|
445
|
+
{cfg?.middle ? (
|
|
446
|
+
<PartField
|
|
447
|
+
ctx={ctx}
|
|
448
|
+
part="middle"
|
|
449
|
+
label={strings.middleName}
|
|
450
|
+
placeholder="Quinn"
|
|
451
|
+
token="additional-name"
|
|
452
|
+
/>
|
|
453
|
+
) : null}
|
|
454
|
+
<PartField
|
|
455
|
+
ctx={ctx}
|
|
456
|
+
part="last"
|
|
457
|
+
label={strings.lastName}
|
|
458
|
+
placeholder="Doe"
|
|
459
|
+
token="family-name"
|
|
460
|
+
/>
|
|
461
|
+
{cfg?.suffix ? (
|
|
462
|
+
<PartField
|
|
463
|
+
ctx={ctx}
|
|
464
|
+
part="suffix"
|
|
465
|
+
label={strings.nameSuffix}
|
|
466
|
+
placeholder="Jr."
|
|
467
|
+
token="honorific-suffix"
|
|
468
|
+
/>
|
|
469
|
+
) : null}
|
|
470
|
+
{cfg?.nicknames ? (
|
|
471
|
+
<PartField
|
|
472
|
+
ctx={ctx}
|
|
473
|
+
part="nicknames"
|
|
474
|
+
label={strings.nicknames}
|
|
475
|
+
placeholder={strings.nicknamesPlaceholder}
|
|
476
|
+
token="nickname"
|
|
477
|
+
/>
|
|
478
|
+
) : null}
|
|
479
|
+
</View>
|
|
480
|
+
)
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
const STATE_OPTIONS: BdOption[] = US_STATES.map((s) => ({ value: s.abbr, label: s.name }))
|
|
484
|
+
|
|
485
|
+
function AddressControl(ctx: BdFieldContext) {
|
|
486
|
+
const { strings } = useBdForm()
|
|
487
|
+
const v = record(ctx.value)
|
|
488
|
+
return (
|
|
489
|
+
<View style={styles.gap10}>
|
|
490
|
+
<PartField ctx={ctx} part="line1" label={strings.addressLine1} token="address-line1" />
|
|
491
|
+
<PartField ctx={ctx} part="line2" label={strings.addressLine2} token="address-line2" />
|
|
492
|
+
<PartField ctx={ctx} part="city" label={strings.city} token="address-level2" />
|
|
493
|
+
<View style={styles.row8}>
|
|
494
|
+
<View style={styles.flex14}>
|
|
495
|
+
<BdText variant="caption" style={styles.partLabel}>
|
|
496
|
+
{strings.state}
|
|
497
|
+
</BdText>
|
|
498
|
+
<BdOptionPicker
|
|
499
|
+
title={strings.state}
|
|
500
|
+
placeholder={strings.selectState}
|
|
501
|
+
options={STATE_OPTIONS}
|
|
502
|
+
selection={str(v['state']) ? [str(v['state'])] : []}
|
|
503
|
+
onSelect={(next) => ctx.set({ ...v, state: next[0] ?? '' })}
|
|
504
|
+
multi={false}
|
|
505
|
+
isError={!!ctx.error}
|
|
506
|
+
/>
|
|
507
|
+
</View>
|
|
508
|
+
<View style={styles.flex}>
|
|
509
|
+
<PartField
|
|
510
|
+
ctx={ctx}
|
|
511
|
+
part="zip"
|
|
512
|
+
label={strings.zip}
|
|
513
|
+
placeholder="90210"
|
|
514
|
+
token="postal-code"
|
|
515
|
+
filter={(s) => s.replace(/[^0-9-]/g, '').slice(0, 10)}
|
|
516
|
+
/>
|
|
517
|
+
</View>
|
|
518
|
+
</View>
|
|
519
|
+
</View>
|
|
520
|
+
)
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// ─── Tags ────────────────────────────────────────────────────────────────────
|
|
524
|
+
|
|
525
|
+
function TagsControl({ field, value, error, set }: BdFieldContext) {
|
|
526
|
+
const { strings } = useBdForm()
|
|
527
|
+
const [draft, setDraft] = useState('')
|
|
528
|
+
const tags = stringList(value)
|
|
529
|
+
const add = (text: string) => {
|
|
530
|
+
const parts = text
|
|
531
|
+
.split(',')
|
|
532
|
+
.map((p) => p.trim())
|
|
533
|
+
.filter((p) => p.length > 0)
|
|
534
|
+
setDraft('')
|
|
535
|
+
if (parts.length === 0) return
|
|
536
|
+
const next = [...tags]
|
|
537
|
+
for (const p of parts) if (!next.includes(p)) next.push(p)
|
|
538
|
+
set(next)
|
|
539
|
+
}
|
|
540
|
+
return (
|
|
541
|
+
<View style={styles.gap10}>
|
|
542
|
+
<BdTextField
|
|
543
|
+
value={draft}
|
|
544
|
+
onChangeText={(t) => (t.endsWith(',') ? add(t) : setDraft(t))}
|
|
545
|
+
placeholder={field.placeholder || strings.addTag}
|
|
546
|
+
returnKeyType="done"
|
|
547
|
+
blurOnSubmit={false}
|
|
548
|
+
onSubmitEditing={() => add(draft)}
|
|
549
|
+
onBlur={() => draft.trim() && add(draft)}
|
|
550
|
+
isError={!!error}
|
|
551
|
+
/>
|
|
552
|
+
{tags.length > 0 ? (
|
|
553
|
+
<View style={styles.wrap}>
|
|
554
|
+
{tags.map((tag) => (
|
|
555
|
+
<BdChip
|
|
556
|
+
key={tag}
|
|
557
|
+
label={`${tag} ×`}
|
|
558
|
+
selected
|
|
559
|
+
accessibilityLabel={fmt(strings.removeTag, tag)}
|
|
560
|
+
onPress={() => set(tags.filter((t) => t !== tag))}
|
|
561
|
+
/>
|
|
562
|
+
))}
|
|
563
|
+
</View>
|
|
564
|
+
) : null}
|
|
565
|
+
</View>
|
|
566
|
+
)
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// ─── Rich text ───────────────────────────────────────────────────────────────
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Rich text, stored as the HTML BD keeps (`p strong em s ul ol li`). The
|
|
573
|
+
* editor is light markup the toolbar writes: `**bold**`, `*italic*`,
|
|
574
|
+
* `~~struck~~`, and `• ` / `1. ` lines for lists.
|
|
575
|
+
*/
|
|
576
|
+
function RichTextControl({ field, value, error, set }: BdFieldContext) {
|
|
577
|
+
const { theme, strings } = useBdForm()
|
|
578
|
+
const html = str(value)
|
|
579
|
+
const [markup, setMarkup] = useState(() => htmlToMarkup(html))
|
|
580
|
+
const [emitted, setEmitted] = useState(html)
|
|
581
|
+
const [sel, setSel] = useState({ start: 0, end: 0 })
|
|
582
|
+
const [forced, setForced] = useState<{ start: number; end: number } | undefined>()
|
|
583
|
+
// A change from outside (reset, a restored draft) replaces the text.
|
|
584
|
+
if (html !== emitted) {
|
|
585
|
+
setEmitted(html)
|
|
586
|
+
if (markupToHtml(markup) !== html) setMarkup(htmlToMarkup(html))
|
|
587
|
+
}
|
|
588
|
+
const update = (text: string) => {
|
|
589
|
+
setMarkup(text)
|
|
590
|
+
const out = markupToHtml(text)
|
|
591
|
+
if (out !== emitted) {
|
|
592
|
+
setEmitted(out)
|
|
593
|
+
set(out)
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
const apply = (next: { text: string; start: number; end: number }) => {
|
|
597
|
+
update(next.text)
|
|
598
|
+
setSel({ start: next.start, end: next.end })
|
|
599
|
+
setForced({ start: next.start, end: next.end })
|
|
600
|
+
}
|
|
601
|
+
const minHeight =
|
|
602
|
+
(field as { richTextConfig?: { minHeight?: number } }).richTextConfig?.minHeight ?? 140
|
|
603
|
+
const tool = (label: string, a11y: string, onPress: () => void, extra?: object) => (
|
|
604
|
+
<Pressable
|
|
605
|
+
key={a11y}
|
|
606
|
+
accessibilityRole="button"
|
|
607
|
+
accessibilityLabel={a11y}
|
|
608
|
+
onPress={onPress}
|
|
609
|
+
style={({ pressed }) => [
|
|
610
|
+
styles.tool,
|
|
611
|
+
{
|
|
612
|
+
backgroundColor: theme.colors.surface,
|
|
613
|
+
borderRadius: theme.variant === 'ios' ? 8 : 20,
|
|
614
|
+
opacity: pressed ? 0.6 : 1,
|
|
615
|
+
},
|
|
616
|
+
]}
|
|
617
|
+
>
|
|
618
|
+
<BdText style={extra}>{label}</BdText>
|
|
619
|
+
</Pressable>
|
|
620
|
+
)
|
|
621
|
+
return (
|
|
622
|
+
<View style={styles.gap8}>
|
|
623
|
+
<View style={styles.row4}>
|
|
624
|
+
{tool('B', strings.bold, () => apply(wrapSelection({ text: markup, ...sel }, '**')), {
|
|
625
|
+
fontWeight: '700',
|
|
626
|
+
})}
|
|
627
|
+
{tool('I', strings.italic, () => apply(wrapSelection({ text: markup, ...sel }, '*')), {
|
|
628
|
+
fontStyle: 'italic',
|
|
629
|
+
})}
|
|
630
|
+
{tool(
|
|
631
|
+
'S',
|
|
632
|
+
strings.strikethrough,
|
|
633
|
+
() => apply(wrapSelection({ text: markup, ...sel }, '~~')),
|
|
634
|
+
{
|
|
635
|
+
textDecorationLine: 'line-through',
|
|
636
|
+
},
|
|
637
|
+
)}
|
|
638
|
+
<View style={[styles.toolDivider, { backgroundColor: theme.colors.separator }]} />
|
|
639
|
+
{tool('•', strings.bulletList, () =>
|
|
640
|
+
apply(toggleListLine({ text: markup, ...sel }, false)),
|
|
641
|
+
)}
|
|
642
|
+
{tool('1.', strings.numberedList, () =>
|
|
643
|
+
apply(toggleListLine({ text: markup, ...sel }, true)),
|
|
644
|
+
)}
|
|
645
|
+
</View>
|
|
646
|
+
<BdTextField
|
|
647
|
+
value={markup}
|
|
648
|
+
onChangeText={update}
|
|
649
|
+
selection={forced}
|
|
650
|
+
onSelectionChange={(e) => {
|
|
651
|
+
setSel(e.nativeEvent.selection)
|
|
652
|
+
if (forced) setForced(undefined)
|
|
653
|
+
}}
|
|
654
|
+
placeholder={field.placeholder}
|
|
655
|
+
multiline
|
|
656
|
+
minLines={Math.max(Math.round((minHeight - 22) / 22), 3)}
|
|
657
|
+
isError={!!error}
|
|
658
|
+
/>
|
|
659
|
+
</View>
|
|
660
|
+
)
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
// ─── Choices ─────────────────────────────────────────────────────────────────
|
|
664
|
+
|
|
665
|
+
function optionIcons(field: FormCoreField): Record<string, string> {
|
|
666
|
+
const raw = (field as { optionIcons?: unknown }).optionIcons
|
|
667
|
+
return raw && typeof raw === 'object' ? (raw as Record<string, string>) : {}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
function OptionLabel({ option }: { option: BdOption }) {
|
|
671
|
+
const { theme } = useBdForm()
|
|
672
|
+
const visual = option.image ? collectionOptionVisual(option.image) : null
|
|
673
|
+
const bareIcon = option.image && /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(option.image)
|
|
674
|
+
return (
|
|
675
|
+
<View style={styles.optionLabel}>
|
|
676
|
+
{option.icon ? <BdIcon name={option.icon} size={20} color={theme.colors.tint} /> : null}
|
|
677
|
+
{bareIcon ? (
|
|
678
|
+
<BdIcon name={option.image} size={20} color={theme.colors.tint} />
|
|
679
|
+
) : visual?.kind === 'emoji' ? (
|
|
680
|
+
<BdText>{visual.text}</BdText>
|
|
681
|
+
) : visual?.kind === 'image' &&
|
|
682
|
+
/^https?:/.test(visual.src) &&
|
|
683
|
+
!/\.svg(\?|$)/i.test(visual.src) ? (
|
|
684
|
+
<Image source={{ uri: visual.src }} style={styles.optionImage} />
|
|
685
|
+
) : null}
|
|
686
|
+
<BdText style={styles.flex}>{option.label}</BdText>
|
|
687
|
+
{option.detail ? <BdText variant="caption">{option.detail}</BdText> : null}
|
|
688
|
+
</View>
|
|
689
|
+
)
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
function SelectControl({ field, value, error, set }: BdFieldContext) {
|
|
693
|
+
const { strings } = useBdForm()
|
|
694
|
+
const icons = optionIcons(field)
|
|
695
|
+
const options = (field.options ?? []).map((o) => ({ value: o, label: o, icon: icons[o] }))
|
|
696
|
+
const current = str(value)
|
|
697
|
+
return (
|
|
698
|
+
<BdOptionPicker
|
|
699
|
+
title={field.label ?? ''}
|
|
700
|
+
placeholder={field.placeholder || strings.select}
|
|
701
|
+
options={options}
|
|
702
|
+
selection={current ? [current] : []}
|
|
703
|
+
onSelect={(next) => set(next[0] ?? '')}
|
|
704
|
+
multi={false}
|
|
705
|
+
searchable={shouldSearchOptions(options.length, field.display)}
|
|
706
|
+
allowCustom={field.allowCustom === true}
|
|
707
|
+
isError={!!error}
|
|
708
|
+
renderLabel={(o) => <OptionLabel option={o} />}
|
|
709
|
+
/>
|
|
710
|
+
)
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
function RadioControl({ field, value, set }: BdFieldContext) {
|
|
714
|
+
const icons = optionIcons(field)
|
|
715
|
+
const opts = field.options ?? []
|
|
716
|
+
return (
|
|
717
|
+
<BdChoiceGroup multi={false}>
|
|
718
|
+
{opts.map((o, i) => (
|
|
719
|
+
<BdChoiceRow
|
|
720
|
+
key={o}
|
|
721
|
+
selected={value === o}
|
|
722
|
+
multi={false}
|
|
723
|
+
last={i === opts.length - 1}
|
|
724
|
+
onPress={() => set(o)}
|
|
725
|
+
>
|
|
726
|
+
<OptionLabel option={{ value: o, label: o, icon: icons[o] }} />
|
|
727
|
+
</BdChoiceRow>
|
|
728
|
+
))}
|
|
729
|
+
</BdChoiceGroup>
|
|
730
|
+
)
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
function CheckboxControl({ field, value, error, set }: BdFieldContext) {
|
|
734
|
+
const { strings } = useBdForm()
|
|
735
|
+
const icons = optionIcons(field)
|
|
736
|
+
const opts = field.options ?? []
|
|
737
|
+
const selected = stringList(value)
|
|
738
|
+
if (field.display === 'dropdown' || shouldSearchOptions(opts.length, field.display)) {
|
|
739
|
+
return (
|
|
740
|
+
<BdOptionPicker
|
|
741
|
+
title={field.label ?? ''}
|
|
742
|
+
placeholder={field.placeholder || strings.select}
|
|
743
|
+
options={opts.map((o) => ({ value: o, label: o, icon: icons[o] }))}
|
|
744
|
+
selection={selected}
|
|
745
|
+
onSelect={set}
|
|
746
|
+
multi
|
|
747
|
+
allowCustom={field.allowCustom === true}
|
|
748
|
+
isError={!!error}
|
|
749
|
+
renderLabel={(o) => <OptionLabel option={o} />}
|
|
750
|
+
/>
|
|
751
|
+
)
|
|
752
|
+
}
|
|
753
|
+
return (
|
|
754
|
+
<BdChoiceGroup multi>
|
|
755
|
+
{opts.map((o, i) => (
|
|
756
|
+
<BdChoiceRow
|
|
757
|
+
key={o}
|
|
758
|
+
selected={selected.includes(o)}
|
|
759
|
+
multi
|
|
760
|
+
last={i === opts.length - 1}
|
|
761
|
+
onPress={() => set(toggled(selected, o))}
|
|
762
|
+
>
|
|
763
|
+
<OptionLabel option={{ value: o, label: o, icon: icons[o] }} />
|
|
764
|
+
</BdChoiceRow>
|
|
765
|
+
))}
|
|
766
|
+
</BdChoiceGroup>
|
|
767
|
+
)
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
function ChoiceCardsControl({ field, value, set }: BdFieldContext) {
|
|
771
|
+
const { theme, strings } = useBdForm()
|
|
772
|
+
const c = theme.colors
|
|
773
|
+
const cfg = field.choiceConfig
|
|
774
|
+
const multi = cfg?.mode === 'multi'
|
|
775
|
+
const picked = multi ? stringList(value) : str(value) ? [str(value)] : []
|
|
776
|
+
const toggle = (label: string) =>
|
|
777
|
+
multi ? set(toggled(picked, label)) : set(picked[0] === label ? '' : label)
|
|
778
|
+
return (
|
|
779
|
+
<View style={styles.gap10} accessibilityRole={multi ? undefined : 'radiogroup'}>
|
|
780
|
+
{(cfg?.options ?? []).map((opt) => {
|
|
781
|
+
const on = picked.includes(opt.label)
|
|
782
|
+
const image = safeHttpUrl(opt.imageUrl)
|
|
783
|
+
const href = safeHttpUrl(opt.href)
|
|
784
|
+
return (
|
|
785
|
+
<Pressable
|
|
786
|
+
key={opt.label}
|
|
787
|
+
accessibilityRole={multi ? 'checkbox' : 'radio'}
|
|
788
|
+
accessibilityState={{ checked: on, selected: on }}
|
|
789
|
+
accessibilityLabel={[opt.label, opt.price, opt.description].filter(Boolean).join(', ')}
|
|
790
|
+
onPress={() => toggle(opt.label)}
|
|
791
|
+
style={({ pressed }) => [
|
|
792
|
+
styles.card,
|
|
793
|
+
{
|
|
794
|
+
borderRadius: theme.cornerRadius,
|
|
795
|
+
borderColor: on ? c.tint : c.separator,
|
|
796
|
+
borderWidth: on ? 2 : 1,
|
|
797
|
+
padding: on ? 11 : 12,
|
|
798
|
+
backgroundColor: on
|
|
799
|
+
? c.tintSoft
|
|
800
|
+
: theme.variant === 'ios'
|
|
801
|
+
? c.field
|
|
802
|
+
: 'transparent',
|
|
803
|
+
opacity: pressed && theme.variant === 'ios' ? 0.7 : 1,
|
|
804
|
+
},
|
|
805
|
+
]}
|
|
806
|
+
>
|
|
807
|
+
{image ? (
|
|
808
|
+
<Image
|
|
809
|
+
source={{ uri: image }}
|
|
810
|
+
style={styles.cardImage}
|
|
811
|
+
accessibilityIgnoresInvertColors
|
|
812
|
+
/>
|
|
813
|
+
) : opt.icon ? (
|
|
814
|
+
<View style={styles.cardIcon}>
|
|
815
|
+
<BdIcon name={opt.icon} size={24} color={c.tint} />
|
|
816
|
+
</View>
|
|
817
|
+
) : null}
|
|
818
|
+
<View style={[styles.flex, styles.gap4]}>
|
|
819
|
+
<View style={styles.row8}>
|
|
820
|
+
<BdText style={[styles.flex, styles.semibold]}>{opt.label}</BdText>
|
|
821
|
+
{opt.price ? <BdText variant="caption">{opt.price}</BdText> : null}
|
|
822
|
+
</View>
|
|
823
|
+
{opt.description ? <BdText variant="caption">{opt.description}</BdText> : null}
|
|
824
|
+
{href ? (
|
|
825
|
+
<Pressable
|
|
826
|
+
accessibilityRole="link"
|
|
827
|
+
onPress={() => void Linking.openURL(href).catch(() => {})}
|
|
828
|
+
hitSlop={8}
|
|
829
|
+
>
|
|
830
|
+
<BdText variant="caption" color={c.tint}>
|
|
831
|
+
{strings.view}
|
|
832
|
+
</BdText>
|
|
833
|
+
</Pressable>
|
|
834
|
+
) : null}
|
|
835
|
+
</View>
|
|
836
|
+
<BdMark on={on} multi={multi} />
|
|
837
|
+
</Pressable>
|
|
838
|
+
)
|
|
839
|
+
})}
|
|
840
|
+
</View>
|
|
841
|
+
)
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
function BooleanControl({ field, value, set }: BdFieldContext) {
|
|
845
|
+
const { strings } = useBdForm()
|
|
846
|
+
const on = value === true
|
|
847
|
+
const label = field.placeholder || strings.yesNo
|
|
848
|
+
if (field.display === 'checkbox') {
|
|
849
|
+
return (
|
|
850
|
+
<BdChoiceRow selected={on} multi last onPress={() => set(!on)}>
|
|
851
|
+
<BdText>{label}</BdText>
|
|
852
|
+
</BdChoiceRow>
|
|
853
|
+
)
|
|
854
|
+
}
|
|
855
|
+
return (
|
|
856
|
+
<Pressable
|
|
857
|
+
accessibilityRole="switch"
|
|
858
|
+
accessibilityState={{ checked: on }}
|
|
859
|
+
accessibilityLabel={field.label ? `${field.label}, ${label}` : label}
|
|
860
|
+
onPress={() => set(!on)}
|
|
861
|
+
style={styles.switchRow}
|
|
862
|
+
>
|
|
863
|
+
<BdText style={styles.flex}>{label}</BdText>
|
|
864
|
+
<BdSwitch value={on} onValueChange={set} />
|
|
865
|
+
</Pressable>
|
|
866
|
+
)
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
function IconSelectControl({ field, value, set }: BdFieldContext) {
|
|
870
|
+
const { theme, strings, renderIcon } = useBdForm()
|
|
871
|
+
const { host } = useBdFormRuntime()
|
|
872
|
+
const c = theme.colors
|
|
873
|
+
const curated = field.iconConfig?.allowedIcons ?? []
|
|
874
|
+
const [all, setAll] = useState<string[]>([])
|
|
875
|
+
const [query, setQuery] = useState('')
|
|
876
|
+
useEffect(() => {
|
|
877
|
+
if (curated.length > 0) return
|
|
878
|
+
let live = true
|
|
879
|
+
fetch(`${host}/api/icons`)
|
|
880
|
+
.then((r) => (r.ok ? r.json() : { icons: [] }))
|
|
881
|
+
.then((d: { icons?: string[] }) => live && setAll(d.icons ?? []))
|
|
882
|
+
.catch(() => {})
|
|
883
|
+
return () => {
|
|
884
|
+
live = false
|
|
885
|
+
}
|
|
886
|
+
}, [curated.length, host])
|
|
887
|
+
const q = query.trim().toLowerCase()
|
|
888
|
+
const names = (curated.length > 0 ? curated : all)
|
|
889
|
+
.filter((n) => !q || n.includes(q))
|
|
890
|
+
.slice(0, 120)
|
|
891
|
+
const columns = Math.max(field.iconConfig?.columns ?? 6, 2)
|
|
892
|
+
const current = str(value)
|
|
893
|
+
const rows: string[][] = []
|
|
894
|
+
for (let i = 0; i < names.length; i += columns) rows.push(names.slice(i, i + columns))
|
|
895
|
+
return (
|
|
896
|
+
<View style={styles.gap10}>
|
|
897
|
+
{curated.length === 0 ? (
|
|
898
|
+
<BdTextField
|
|
899
|
+
value={query}
|
|
900
|
+
onChangeText={setQuery}
|
|
901
|
+
placeholder={strings.searchIcons}
|
|
902
|
+
autoCapitalize="none"
|
|
903
|
+
autoCorrect={false}
|
|
904
|
+
returnKeyType="search"
|
|
905
|
+
/>
|
|
906
|
+
) : null}
|
|
907
|
+
{rows.map((row, ri) => (
|
|
908
|
+
<View key={`ir-${ri}`} style={styles.row8}>
|
|
909
|
+
{row.map((name) => {
|
|
910
|
+
const on = name === current
|
|
911
|
+
return (
|
|
912
|
+
<Pressable
|
|
913
|
+
key={name}
|
|
914
|
+
accessibilityRole="radio"
|
|
915
|
+
accessibilityLabel={name.replace(/-/g, ' ')}
|
|
916
|
+
accessibilityState={{ selected: on, checked: on }}
|
|
917
|
+
onPress={() => set(on ? '' : name)}
|
|
918
|
+
style={[
|
|
919
|
+
styles.iconCell,
|
|
920
|
+
{
|
|
921
|
+
borderRadius: theme.cornerRadius * 0.75,
|
|
922
|
+
backgroundColor: on ? c.tint : c.surface,
|
|
923
|
+
},
|
|
924
|
+
]}
|
|
925
|
+
>
|
|
926
|
+
{renderIcon ? (
|
|
927
|
+
<BdIcon name={name} size={22} color={on ? c.onTint : c.text} />
|
|
928
|
+
) : (
|
|
929
|
+
<BdText variant="caption" numberOfLines={1} color={on ? c.onTint : c.text}>
|
|
930
|
+
{name}
|
|
931
|
+
</BdText>
|
|
932
|
+
)}
|
|
933
|
+
</Pressable>
|
|
934
|
+
)
|
|
935
|
+
})}
|
|
936
|
+
{Array.from({ length: columns - row.length }, (_, i) => (
|
|
937
|
+
<View key={`pad-${i}`} style={styles.flex} />
|
|
938
|
+
))}
|
|
939
|
+
</View>
|
|
940
|
+
))}
|
|
941
|
+
{current ? (
|
|
942
|
+
<View style={styles.row8}>
|
|
943
|
+
<BdText variant="caption" style={styles.flex}>
|
|
944
|
+
{current}
|
|
945
|
+
</BdText>
|
|
946
|
+
<BdButton kind="text" title={strings.clear} onPress={() => set('')} />
|
|
947
|
+
</View>
|
|
948
|
+
) : null}
|
|
949
|
+
</View>
|
|
950
|
+
)
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
type ServiceOption = { id: string; title: string; estimatedHours?: number }
|
|
954
|
+
|
|
955
|
+
function ServiceControl({ field, value, set }: BdFieldContext) {
|
|
956
|
+
const { strings } = useBdForm()
|
|
957
|
+
const cfg = (field as { serviceConfig?: { options?: ServiceOption[]; multi?: boolean } })
|
|
958
|
+
.serviceConfig
|
|
959
|
+
const multi = cfg?.multi !== false
|
|
960
|
+
const picked = stringList(value)
|
|
961
|
+
const opts = cfg?.options ?? []
|
|
962
|
+
return (
|
|
963
|
+
<BdChoiceGroup multi={multi}>
|
|
964
|
+
{opts.map((o, i) => {
|
|
965
|
+
const h = o.estimatedHours
|
|
966
|
+
return (
|
|
967
|
+
<BdChoiceRow
|
|
968
|
+
key={o.id}
|
|
969
|
+
selected={picked.includes(o.id)}
|
|
970
|
+
multi={multi}
|
|
971
|
+
last={i === opts.length - 1}
|
|
972
|
+
onPress={() =>
|
|
973
|
+
set(
|
|
974
|
+
multi
|
|
975
|
+
? toggled(picked, o.id)
|
|
976
|
+
: picked.length === 1 && picked[0] === o.id
|
|
977
|
+
? []
|
|
978
|
+
: [o.id],
|
|
979
|
+
)
|
|
980
|
+
}
|
|
981
|
+
>
|
|
982
|
+
<OptionLabel
|
|
983
|
+
option={{
|
|
984
|
+
value: o.id,
|
|
985
|
+
label: o.title,
|
|
986
|
+
detail: h && h > 0 ? `${h} ${h === 1 ? strings.hour : strings.hours}` : undefined,
|
|
987
|
+
}}
|
|
988
|
+
/>
|
|
989
|
+
</BdChoiceRow>
|
|
990
|
+
)
|
|
991
|
+
})}
|
|
992
|
+
</BdChoiceGroup>
|
|
993
|
+
)
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
function CollectionControl({ field, value, error, set }: BdFieldContext) {
|
|
997
|
+
const { strings } = useBdForm()
|
|
998
|
+
const { controller, collectionOptions } = useBdFormRuntime()
|
|
999
|
+
const state = collectionOptions[field.id]
|
|
1000
|
+
const multi = field.collectionSelectConfig?.multi === true
|
|
1001
|
+
useEffect(() => {
|
|
1002
|
+
void controller.loadCollectionOptions(field.id)
|
|
1003
|
+
}, [controller, field.id])
|
|
1004
|
+
|
|
1005
|
+
if (!state || state.status === 'idle' || state.status === 'loading') {
|
|
1006
|
+
return <BdLoadingRow text={strings.loadingOptions} />
|
|
1007
|
+
}
|
|
1008
|
+
if (state.status === 'error' || state.status === 'unavailable') {
|
|
1009
|
+
return (
|
|
1010
|
+
<BdRetryRow
|
|
1011
|
+
message={state.error ?? COLLECTION_SELECT_TEXT.error}
|
|
1012
|
+
onRetry={() => void controller.reloadCollectionOptions(field.id)}
|
|
1013
|
+
/>
|
|
1014
|
+
)
|
|
1015
|
+
}
|
|
1016
|
+
if (state.status === 'empty' || state.options.length === 0) {
|
|
1017
|
+
return <BdText variant="caption">{strings.noRecords}</BdText>
|
|
1018
|
+
}
|
|
1019
|
+
const options: BdOption[] = state.options.map((o) => ({
|
|
1020
|
+
value: o.value,
|
|
1021
|
+
label: o.label,
|
|
1022
|
+
image: o.image,
|
|
1023
|
+
}))
|
|
1024
|
+
const selection = multi ? stringList(value) : str(value) ? [str(value)] : []
|
|
1025
|
+
const write = (next: string[]) => set(multi ? next : (next[0] ?? ''))
|
|
1026
|
+
if (options.length > 10 || field.display === 'combobox') {
|
|
1027
|
+
return (
|
|
1028
|
+
<BdOptionPicker
|
|
1029
|
+
title={field.label ?? ''}
|
|
1030
|
+
placeholder={field.placeholder || strings.select}
|
|
1031
|
+
options={options}
|
|
1032
|
+
selection={selection}
|
|
1033
|
+
onSelect={write}
|
|
1034
|
+
multi={multi}
|
|
1035
|
+
searchable
|
|
1036
|
+
isError={!!error}
|
|
1037
|
+
renderLabel={(o) => <OptionLabel option={o} />}
|
|
1038
|
+
/>
|
|
1039
|
+
)
|
|
1040
|
+
}
|
|
1041
|
+
return (
|
|
1042
|
+
<BdChoiceGroup multi={multi}>
|
|
1043
|
+
{options.map((o, i) => (
|
|
1044
|
+
<BdChoiceRow
|
|
1045
|
+
key={o.value}
|
|
1046
|
+
selected={selection.includes(o.value)}
|
|
1047
|
+
multi={multi}
|
|
1048
|
+
last={i === options.length - 1}
|
|
1049
|
+
onPress={() =>
|
|
1050
|
+
write(
|
|
1051
|
+
multi
|
|
1052
|
+
? toggled(selection, o.value)
|
|
1053
|
+
: selection.length === 1 && selection[0] === o.value
|
|
1054
|
+
? []
|
|
1055
|
+
: [o.value],
|
|
1056
|
+
)
|
|
1057
|
+
}
|
|
1058
|
+
>
|
|
1059
|
+
<OptionLabel option={o} />
|
|
1060
|
+
</BdChoiceRow>
|
|
1061
|
+
))}
|
|
1062
|
+
</BdChoiceGroup>
|
|
1063
|
+
)
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
// ─── Slider, ratings, stepper ────────────────────────────────────────────────
|
|
1067
|
+
|
|
1068
|
+
function SliderControl({ field, value, set }: BdFieldContext) {
|
|
1069
|
+
const cfg = field.sliderConfig
|
|
1070
|
+
const lo = cfg?.min ?? 0
|
|
1071
|
+
const hi = Math.max(cfg?.max ?? 100, lo + 1)
|
|
1072
|
+
const step = Math.max(cfg?.step ?? 1, Number.EPSILON)
|
|
1073
|
+
const v = num(value) ?? lo
|
|
1074
|
+
const unit = (cfg as { unit?: string } | undefined)?.unit
|
|
1075
|
+
const show = (n: number) =>
|
|
1076
|
+
unit === 'currency' ? `$${n}` : unit === 'percent' ? `${n}%` : String(n)
|
|
1077
|
+
return (
|
|
1078
|
+
<View style={styles.gap4}>
|
|
1079
|
+
<View style={styles.row8}>
|
|
1080
|
+
<BdText variant="caption">{show(lo)}</BdText>
|
|
1081
|
+
<BdText variant="headline" style={[styles.flex, styles.center, styles.tnum]}>
|
|
1082
|
+
{show(v)}
|
|
1083
|
+
</BdText>
|
|
1084
|
+
<BdText variant="caption">{show(hi)}</BdText>
|
|
1085
|
+
</View>
|
|
1086
|
+
<BdSlider
|
|
1087
|
+
value={v}
|
|
1088
|
+
min={lo}
|
|
1089
|
+
max={hi}
|
|
1090
|
+
step={step}
|
|
1091
|
+
onChange={set}
|
|
1092
|
+
accessibilityLabel={field.label ?? ''}
|
|
1093
|
+
valueText={show(v)}
|
|
1094
|
+
/>
|
|
1095
|
+
</View>
|
|
1096
|
+
)
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
function StarsControl({ field, value, set }: BdFieldContext) {
|
|
1100
|
+
const { theme, strings } = useBdForm()
|
|
1101
|
+
const max = Math.max(field.starRatingConfig?.maxStars ?? 5, 1)
|
|
1102
|
+
const v = Math.trunc(num(value) ?? 0)
|
|
1103
|
+
return (
|
|
1104
|
+
<View style={styles.row4} accessibilityRole="radiogroup">
|
|
1105
|
+
{Array.from({ length: max }, (_, k) => {
|
|
1106
|
+
const i = k + 1
|
|
1107
|
+
return (
|
|
1108
|
+
<Pressable
|
|
1109
|
+
key={`star-${i}`}
|
|
1110
|
+
accessibilityRole="radio"
|
|
1111
|
+
accessibilityLabel={fmt(strings.ratingOf, i, max)}
|
|
1112
|
+
accessibilityState={{ selected: i === v, checked: i === v }}
|
|
1113
|
+
onPress={() => set(i)}
|
|
1114
|
+
hitSlop={4}
|
|
1115
|
+
style={styles.star}
|
|
1116
|
+
>
|
|
1117
|
+
<BdText
|
|
1118
|
+
style={styles.starGlyph}
|
|
1119
|
+
color={i <= v ? theme.colors.star : theme.colors.separator}
|
|
1120
|
+
>
|
|
1121
|
+
★
|
|
1122
|
+
</BdText>
|
|
1123
|
+
</Pressable>
|
|
1124
|
+
)
|
|
1125
|
+
})}
|
|
1126
|
+
</View>
|
|
1127
|
+
)
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
const FACES = ['😞', '😕', '😐', '🙂', '😄']
|
|
1131
|
+
|
|
1132
|
+
function HappinessControl({ value, set }: BdFieldContext) {
|
|
1133
|
+
const { theme, strings } = useBdForm()
|
|
1134
|
+
// 0 is a real answer (😞), so "unanswered" is null, not 0.
|
|
1135
|
+
const v = typeof value === 'number' ? value : -1
|
|
1136
|
+
return (
|
|
1137
|
+
<View style={styles.faces} accessibilityRole="radiogroup">
|
|
1138
|
+
{FACES.map((face, i) => {
|
|
1139
|
+
const on = i === v
|
|
1140
|
+
return (
|
|
1141
|
+
<Pressable
|
|
1142
|
+
key={face}
|
|
1143
|
+
accessibilityRole="radio"
|
|
1144
|
+
accessibilityLabel={strings.happinessNames[i] ?? face}
|
|
1145
|
+
accessibilityState={{ selected: on, checked: on }}
|
|
1146
|
+
onPress={() => set(i)}
|
|
1147
|
+
style={[styles.face, on && { backgroundColor: theme.colors.tintSoft }]}
|
|
1148
|
+
>
|
|
1149
|
+
<BdText
|
|
1150
|
+
style={[
|
|
1151
|
+
styles.faceGlyph,
|
|
1152
|
+
{ opacity: v < 0 || on ? 1 : 0.45, transform: [{ scale: on ? 1.15 : 1 }] },
|
|
1153
|
+
]}
|
|
1154
|
+
>
|
|
1155
|
+
{face}
|
|
1156
|
+
</BdText>
|
|
1157
|
+
</Pressable>
|
|
1158
|
+
)
|
|
1159
|
+
})}
|
|
1160
|
+
</View>
|
|
1161
|
+
)
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
function StepperControl({ field, value, set }: BdFieldContext) {
|
|
1165
|
+
const { strings } = useBdForm()
|
|
1166
|
+
const v = num(value) ?? 0
|
|
1167
|
+
const lo = field.validation?.min ?? -1_000_000
|
|
1168
|
+
const hi = Math.max(field.validation?.max ?? 1_000_000, lo)
|
|
1169
|
+
const write = (n: number) => set(Math.min(Math.max(n, lo), hi))
|
|
1170
|
+
return (
|
|
1171
|
+
<View style={styles.stepper}>
|
|
1172
|
+
<BdButton
|
|
1173
|
+
kind="outlined"
|
|
1174
|
+
title="−"
|
|
1175
|
+
accessibilityLabel={strings.decrease}
|
|
1176
|
+
disabled={v - 1 < lo}
|
|
1177
|
+
onPress={() => write(v - 1)}
|
|
1178
|
+
style={styles.stepperButton}
|
|
1179
|
+
/>
|
|
1180
|
+
<BdText
|
|
1181
|
+
variant="title"
|
|
1182
|
+
style={styles.tnum}
|
|
1183
|
+
accessibilityLabel={`${field.label ?? ''}, ${v}`}
|
|
1184
|
+
accessibilityLiveRegion="polite"
|
|
1185
|
+
>
|
|
1186
|
+
{v}
|
|
1187
|
+
</BdText>
|
|
1188
|
+
<BdButton
|
|
1189
|
+
kind="outlined"
|
|
1190
|
+
title="+"
|
|
1191
|
+
accessibilityLabel={strings.increase}
|
|
1192
|
+
disabled={v + 1 > hi}
|
|
1193
|
+
onPress={() => write(v + 1)}
|
|
1194
|
+
style={styles.stepperButton}
|
|
1195
|
+
/>
|
|
1196
|
+
</View>
|
|
1197
|
+
)
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
// ─── Dates & times ───────────────────────────────────────────────────────────
|
|
1201
|
+
|
|
1202
|
+
function DateRangeControl({ field, value, error, set }: BdFieldContext) {
|
|
1203
|
+
const { strings } = useBdForm()
|
|
1204
|
+
const v = record(value)
|
|
1205
|
+
const start = parseDay(str(v['start']))
|
|
1206
|
+
const sameDayOk =
|
|
1207
|
+
(field as { dateRangeConfig?: { allowSameDay?: boolean } }).dateRangeConfig?.allowSameDay !==
|
|
1208
|
+
false
|
|
1209
|
+
const minEnd = start ? (sameDayOk ? start : addDays(start, 1)) : null
|
|
1210
|
+
return (
|
|
1211
|
+
<View style={styles.gap10}>
|
|
1212
|
+
<BdDateField
|
|
1213
|
+
label={strings.start}
|
|
1214
|
+
value={str(v['start'])}
|
|
1215
|
+
onChange={(d) => set({ ...v, start: d })}
|
|
1216
|
+
isError={!!error}
|
|
1217
|
+
/>
|
|
1218
|
+
<BdDateField
|
|
1219
|
+
label={strings.end}
|
|
1220
|
+
value={str(v['end'])}
|
|
1221
|
+
min={minEnd}
|
|
1222
|
+
onChange={(d) => set({ ...v, end: d })}
|
|
1223
|
+
isError={!!error}
|
|
1224
|
+
/>
|
|
1225
|
+
</View>
|
|
1226
|
+
)
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
function TimeControl({ field, value, error, set }: BdFieldContext) {
|
|
1230
|
+
const { strings } = useBdForm()
|
|
1231
|
+
const cfg = field.timeConfig
|
|
1232
|
+
const twelve = (cfg?.format ?? '12h') !== '24h'
|
|
1233
|
+
const mode = cfg?.mode ?? 'simple'
|
|
1234
|
+
const v = record(value)
|
|
1235
|
+
const step = Math.max(cfg?.stepMinutes ?? 15, 1)
|
|
1236
|
+
if (mode === 'time_block') {
|
|
1237
|
+
return (
|
|
1238
|
+
<View style={styles.gap10}>
|
|
1239
|
+
<BdTimeField
|
|
1240
|
+
label={strings.start}
|
|
1241
|
+
value={str(v['start'])}
|
|
1242
|
+
onChange={(t) => set({ ...v, start: t })}
|
|
1243
|
+
step={step}
|
|
1244
|
+
twelveHour={twelve}
|
|
1245
|
+
isError={!!error}
|
|
1246
|
+
/>
|
|
1247
|
+
<BdTimeField
|
|
1248
|
+
label={strings.end}
|
|
1249
|
+
value={str(v['end'])}
|
|
1250
|
+
onChange={(t) => set({ ...v, end: t })}
|
|
1251
|
+
step={step}
|
|
1252
|
+
twelveHour={twelve}
|
|
1253
|
+
isError={!!error}
|
|
1254
|
+
/>
|
|
1255
|
+
</View>
|
|
1256
|
+
)
|
|
1257
|
+
}
|
|
1258
|
+
if (mode === 'appointment') {
|
|
1259
|
+
return (
|
|
1260
|
+
<View style={styles.gap10}>
|
|
1261
|
+
<BdDateField
|
|
1262
|
+
label={strings.date}
|
|
1263
|
+
value={str(v['date'])}
|
|
1264
|
+
min={today()}
|
|
1265
|
+
onChange={(d) => set({ ...v, date: d })}
|
|
1266
|
+
isError={!!error}
|
|
1267
|
+
/>
|
|
1268
|
+
<BdTimeField
|
|
1269
|
+
label={strings.time}
|
|
1270
|
+
value={str(v['time'])}
|
|
1271
|
+
onChange={(t) => set({ ...v, time: t })}
|
|
1272
|
+
step={step}
|
|
1273
|
+
twelveHour={twelve}
|
|
1274
|
+
isError={!!error}
|
|
1275
|
+
/>
|
|
1276
|
+
</View>
|
|
1277
|
+
)
|
|
1278
|
+
}
|
|
1279
|
+
const options = timesOfDay(Math.max(cfg?.stepMinutes ?? 30, 1)).map((t) => ({
|
|
1280
|
+
value: t,
|
|
1281
|
+
label: formatTime(t, twelve),
|
|
1282
|
+
}))
|
|
1283
|
+
const current = str(value)
|
|
1284
|
+
return (
|
|
1285
|
+
<BdOptionPicker
|
|
1286
|
+
title={field.label ?? strings.time}
|
|
1287
|
+
placeholder={field.placeholder || strings.selectTime}
|
|
1288
|
+
options={options}
|
|
1289
|
+
selection={current ? [current] : []}
|
|
1290
|
+
onSelect={(next) => set(next[0] ?? '')}
|
|
1291
|
+
multi={false}
|
|
1292
|
+
searchable={false}
|
|
1293
|
+
isError={!!error}
|
|
1294
|
+
startAt="09:00"
|
|
1295
|
+
/>
|
|
1296
|
+
)
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
function MonthYearControl({ field, value, error, set }: BdFieldContext) {
|
|
1300
|
+
const { strings } = useBdForm()
|
|
1301
|
+
const raw = str(value)
|
|
1302
|
+
const m = /^(\d{4})-(\d{2})$/.exec(raw)
|
|
1303
|
+
const [month, setMonth] = useState<number | null>(m ? Number(m[2]) : null)
|
|
1304
|
+
const [year, setYear] = useState<number | null>(m ? Number(m[1]) : null)
|
|
1305
|
+
const [seen, setSeen] = useState(raw)
|
|
1306
|
+
if (raw !== seen) {
|
|
1307
|
+
setSeen(raw)
|
|
1308
|
+
if (m) {
|
|
1309
|
+
setMonth(Number(m[2]))
|
|
1310
|
+
setYear(Number(m[1]))
|
|
1311
|
+
} else if (raw === '') {
|
|
1312
|
+
setMonth(null)
|
|
1313
|
+
setYear(null)
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
const cfg = (field as { monthYearConfig?: { minYear?: number; maxYear?: number } })
|
|
1317
|
+
.monthYearConfig
|
|
1318
|
+
const thisYear = new Date().getFullYear()
|
|
1319
|
+
const minYear = cfg?.minYear ?? thisYear - 100
|
|
1320
|
+
const maxYear = Math.max(cfg?.maxYear ?? thisYear + 10, minYear)
|
|
1321
|
+
const names = useMemo(monthNames, [])
|
|
1322
|
+
const emit = (mo: number | null, y: number | null) => {
|
|
1323
|
+
setMonth(mo)
|
|
1324
|
+
setYear(y)
|
|
1325
|
+
const out =
|
|
1326
|
+
mo != null && y != null ? `${String(y).padStart(4, '0')}-${String(mo).padStart(2, '0')}` : ''
|
|
1327
|
+
setSeen(out)
|
|
1328
|
+
set(out)
|
|
1329
|
+
}
|
|
1330
|
+
const years: BdOption[] = []
|
|
1331
|
+
for (let y = maxYear; y >= minYear; y--) years.push({ value: String(y), label: String(y) })
|
|
1332
|
+
return (
|
|
1333
|
+
<View style={styles.row8}>
|
|
1334
|
+
<BdOptionPicker
|
|
1335
|
+
style={styles.flex13}
|
|
1336
|
+
title={strings.month}
|
|
1337
|
+
placeholder={strings.month}
|
|
1338
|
+
options={names.map((n, i) => ({ value: String(i + 1), label: n }))}
|
|
1339
|
+
selection={month != null ? [String(month)] : []}
|
|
1340
|
+
onSelect={(next) => emit(next[0] ? Number(next[0]) : null, year)}
|
|
1341
|
+
multi={false}
|
|
1342
|
+
searchable={false}
|
|
1343
|
+
isError={!!error}
|
|
1344
|
+
/>
|
|
1345
|
+
<BdOptionPicker
|
|
1346
|
+
style={styles.flex}
|
|
1347
|
+
title={strings.year}
|
|
1348
|
+
placeholder={strings.year}
|
|
1349
|
+
options={years}
|
|
1350
|
+
selection={year != null ? [String(year)] : []}
|
|
1351
|
+
onSelect={(next) => emit(month, next[0] ? Number(next[0]) : null)}
|
|
1352
|
+
multi={false}
|
|
1353
|
+
searchable={false}
|
|
1354
|
+
isError={!!error}
|
|
1355
|
+
startAt={String(thisYear)}
|
|
1356
|
+
/>
|
|
1357
|
+
</View>
|
|
1358
|
+
)
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
// ─── Schedule ────────────────────────────────────────────────────────────────
|
|
1362
|
+
|
|
1363
|
+
type ScheduleConfig = {
|
|
1364
|
+
allowAsap?: boolean
|
|
1365
|
+
days?: string[]
|
|
1366
|
+
timeWindows?: string[]
|
|
1367
|
+
granularTimes?: boolean
|
|
1368
|
+
allowNotes?: boolean
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
function AvailabilityControl({ field, value, set }: BdFieldContext) {
|
|
1372
|
+
const { strings } = useBdForm()
|
|
1373
|
+
const cfg = (field as { scheduleConfig?: ScheduleConfig }).scheduleConfig
|
|
1374
|
+
const v = record(value)
|
|
1375
|
+
const days = cfg?.days?.length ? cfg.days : ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']
|
|
1376
|
+
const windows = cfg?.timeWindows?.length
|
|
1377
|
+
? cfg.timeWindows
|
|
1378
|
+
: cfg?.granularTimes
|
|
1379
|
+
? [
|
|
1380
|
+
'morning_8_10',
|
|
1381
|
+
'morning_10_12',
|
|
1382
|
+
'afternoon_12_2',
|
|
1383
|
+
'afternoon_2_4',
|
|
1384
|
+
'evening_4_6',
|
|
1385
|
+
'evening_6_8',
|
|
1386
|
+
]
|
|
1387
|
+
: ['morning', 'afternoon', 'evening']
|
|
1388
|
+
const toggle = (key: 'days' | 'times', item: string) =>
|
|
1389
|
+
set({ ...v, [key]: toggled(stringList(v[key]), item) })
|
|
1390
|
+
const asap = v['asap'] === true
|
|
1391
|
+
return (
|
|
1392
|
+
<View style={styles.gap14}>
|
|
1393
|
+
{cfg?.allowAsap !== false ? (
|
|
1394
|
+
<Pressable
|
|
1395
|
+
accessibilityRole="switch"
|
|
1396
|
+
accessibilityState={{ checked: asap }}
|
|
1397
|
+
accessibilityLabel={strings.asap}
|
|
1398
|
+
onPress={() => set({ ...v, asap: !asap })}
|
|
1399
|
+
style={styles.switchRow}
|
|
1400
|
+
>
|
|
1401
|
+
<BdText style={styles.flex}>{strings.asap}</BdText>
|
|
1402
|
+
<BdSwitch value={asap} onValueChange={(on) => set({ ...v, asap: on })} />
|
|
1403
|
+
</Pressable>
|
|
1404
|
+
) : null}
|
|
1405
|
+
<ChipGroup
|
|
1406
|
+
title={strings.preferredDays}
|
|
1407
|
+
items={days}
|
|
1408
|
+
picked={stringList(v['days'])}
|
|
1409
|
+
name={(d) => strings.dayNames[d] ?? d}
|
|
1410
|
+
onToggle={(d) => toggle('days', d)}
|
|
1411
|
+
/>
|
|
1412
|
+
<ChipGroup
|
|
1413
|
+
title={strings.preferredTimes}
|
|
1414
|
+
items={windows}
|
|
1415
|
+
picked={stringList(v['times'])}
|
|
1416
|
+
name={(w) => strings.timeWindowNames[w] ?? w}
|
|
1417
|
+
onToggle={(w) => toggle('times', w)}
|
|
1418
|
+
/>
|
|
1419
|
+
{cfg?.allowNotes !== false ? (
|
|
1420
|
+
<BdTextField
|
|
1421
|
+
value={str(v['notes'])}
|
|
1422
|
+
onChangeText={(t) => set({ ...v, notes: t })}
|
|
1423
|
+
placeholder={strings.schedulingNotes}
|
|
1424
|
+
multiline
|
|
1425
|
+
minLines={2}
|
|
1426
|
+
/>
|
|
1427
|
+
) : null}
|
|
1428
|
+
</View>
|
|
1429
|
+
)
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
function ChipGroup({
|
|
1433
|
+
title,
|
|
1434
|
+
items,
|
|
1435
|
+
picked,
|
|
1436
|
+
name,
|
|
1437
|
+
onToggle,
|
|
1438
|
+
}: {
|
|
1439
|
+
title: string
|
|
1440
|
+
items: string[]
|
|
1441
|
+
picked: string[]
|
|
1442
|
+
name: (item: string) => string
|
|
1443
|
+
onToggle: (item: string) => void
|
|
1444
|
+
}) {
|
|
1445
|
+
return (
|
|
1446
|
+
<View style={styles.gap6}>
|
|
1447
|
+
<BdText variant="caption">{title}</BdText>
|
|
1448
|
+
<View style={styles.wrap}>
|
|
1449
|
+
{items.map((item) => (
|
|
1450
|
+
<BdChip
|
|
1451
|
+
key={item}
|
|
1452
|
+
label={name(item)}
|
|
1453
|
+
selected={picked.includes(item)}
|
|
1454
|
+
onPress={() => onToggle(item)}
|
|
1455
|
+
/>
|
|
1456
|
+
))}
|
|
1457
|
+
</View>
|
|
1458
|
+
</View>
|
|
1459
|
+
)
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
type SlotState = { status: 'loading' } | { status: 'error' } | { status: 'ready'; slots: string[] }
|
|
1463
|
+
|
|
1464
|
+
function localDayKey(d: Date): string {
|
|
1465
|
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
/** Live booking: open slots from BD, grouped by day. */
|
|
1469
|
+
function BookingControl({ field, value, set }: BdFieldContext) {
|
|
1470
|
+
const { theme, strings } = useBdForm()
|
|
1471
|
+
const { client, slug } = useBdFormRuntime()
|
|
1472
|
+
const c = theme.colors
|
|
1473
|
+
const [state, setState] = useState<SlotState>({ status: 'loading' })
|
|
1474
|
+
const [attempt, setAttempt] = useState(0)
|
|
1475
|
+
const [day, setDay] = useState<string | null>(null)
|
|
1476
|
+
const fetchSlots = client?.forms.scheduleSlots
|
|
1477
|
+
useEffect(() => {
|
|
1478
|
+
if (!fetchSlots || !slug) {
|
|
1479
|
+
setState({ status: 'error' })
|
|
1480
|
+
return
|
|
1481
|
+
}
|
|
1482
|
+
let live = true
|
|
1483
|
+
setState({ status: 'loading' })
|
|
1484
|
+
const from = new Date()
|
|
1485
|
+
const to = new Date(from.getTime() + 21 * 24 * 60 * 60 * 1000)
|
|
1486
|
+
fetchSlots(slug, { fieldId: field.id, from, to })
|
|
1487
|
+
.then((r) => live && setState({ status: 'ready', slots: r.slots.map((s) => s.startAt) }))
|
|
1488
|
+
.catch(() => live && setState({ status: 'error' }))
|
|
1489
|
+
return () => {
|
|
1490
|
+
live = false
|
|
1491
|
+
}
|
|
1492
|
+
}, [fetchSlots, slug, field.id, attempt])
|
|
1493
|
+
|
|
1494
|
+
if (state.status === 'loading') return <BdLoadingRow text={strings.loadingTimes} />
|
|
1495
|
+
if (state.status === 'error')
|
|
1496
|
+
return (
|
|
1497
|
+
<BdRetryRow message={strings.timesUnavailable} onRetry={() => setAttempt((n) => n + 1)} />
|
|
1498
|
+
)
|
|
1499
|
+
|
|
1500
|
+
const slots = state.slots
|
|
1501
|
+
.map((raw) => ({ raw, at: new Date(raw) }))
|
|
1502
|
+
.filter((s) => !Number.isNaN(s.at.getTime()))
|
|
1503
|
+
if (slots.length === 0) return <BdText variant="caption">{strings.noOpenTimes}</BdText>
|
|
1504
|
+
const byDay = new Map<string, Array<{ raw: string; at: Date }>>()
|
|
1505
|
+
for (const s of slots) {
|
|
1506
|
+
const k = localDayKey(s.at)
|
|
1507
|
+
byDay.set(k, [...(byDay.get(k) ?? []), s])
|
|
1508
|
+
}
|
|
1509
|
+
const days = [...byDay.keys()].sort()
|
|
1510
|
+
const selected = str(record(value)['slotStartAt'])
|
|
1511
|
+
const selectedDay = slots.find((s) => s.raw === selected)
|
|
1512
|
+
const current = day ?? (selectedDay ? localDayKey(selectedDay.at) : days[0]) ?? days[0]
|
|
1513
|
+
const zone = Intl.DateTimeFormat().resolvedOptions().timeZone ?? 'UTC'
|
|
1514
|
+
return (
|
|
1515
|
+
<View style={styles.gap10}>
|
|
1516
|
+
<ScrollView
|
|
1517
|
+
horizontal
|
|
1518
|
+
showsHorizontalScrollIndicator={false}
|
|
1519
|
+
contentContainerStyle={styles.row8}
|
|
1520
|
+
>
|
|
1521
|
+
{days.map((k) => {
|
|
1522
|
+
const d = byDay.get(k)?.[0]?.at as Date
|
|
1523
|
+
const on = k === current
|
|
1524
|
+
return (
|
|
1525
|
+
<Pressable
|
|
1526
|
+
key={k}
|
|
1527
|
+
accessibilityRole="radio"
|
|
1528
|
+
accessibilityState={{ selected: on }}
|
|
1529
|
+
accessibilityLabel={d.toLocaleDateString(undefined, {
|
|
1530
|
+
weekday: 'long',
|
|
1531
|
+
month: 'long',
|
|
1532
|
+
day: 'numeric',
|
|
1533
|
+
})}
|
|
1534
|
+
onPress={() => setDay(k)}
|
|
1535
|
+
style={[
|
|
1536
|
+
styles.dayCard,
|
|
1537
|
+
{ borderRadius: theme.cornerRadius, backgroundColor: on ? c.tint : c.surface },
|
|
1538
|
+
]}
|
|
1539
|
+
>
|
|
1540
|
+
<BdText variant="caption" color={on ? c.onTint : c.textSecondary}>
|
|
1541
|
+
{d.toLocaleDateString(undefined, { weekday: 'short' })}
|
|
1542
|
+
</BdText>
|
|
1543
|
+
<BdText variant="headline" color={on ? c.onTint : c.text}>
|
|
1544
|
+
{d.getDate()}
|
|
1545
|
+
</BdText>
|
|
1546
|
+
<BdText variant="caption" color={on ? c.onTint : c.textSecondary}>
|
|
1547
|
+
{d.toLocaleDateString(undefined, { month: 'short' })}
|
|
1548
|
+
</BdText>
|
|
1549
|
+
</Pressable>
|
|
1550
|
+
)
|
|
1551
|
+
})}
|
|
1552
|
+
</ScrollView>
|
|
1553
|
+
<View style={styles.wrap}>
|
|
1554
|
+
{(byDay.get(current as string) ?? []).map((s) => (
|
|
1555
|
+
<BdChip
|
|
1556
|
+
key={s.raw}
|
|
1557
|
+
label={s.at.toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' })}
|
|
1558
|
+
selected={s.raw === selected}
|
|
1559
|
+
onPress={() => set({ slotStartAt: s.raw, timezone: zone })}
|
|
1560
|
+
/>
|
|
1561
|
+
))}
|
|
1562
|
+
</View>
|
|
1563
|
+
</View>
|
|
1564
|
+
)
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
// ─── Files & images ──────────────────────────────────────────────────────────
|
|
1568
|
+
|
|
1569
|
+
const MIME_BY_EXT: Record<string, string> = {
|
|
1570
|
+
jpg: 'image/jpeg',
|
|
1571
|
+
jpeg: 'image/jpeg',
|
|
1572
|
+
png: 'image/png',
|
|
1573
|
+
gif: 'image/gif',
|
|
1574
|
+
webp: 'image/webp',
|
|
1575
|
+
heic: 'image/heic',
|
|
1576
|
+
heif: 'image/heif',
|
|
1577
|
+
pdf: 'application/pdf',
|
|
1578
|
+
txt: 'text/plain',
|
|
1579
|
+
csv: 'text/csv',
|
|
1580
|
+
doc: 'application/msword',
|
|
1581
|
+
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
1582
|
+
xls: 'application/vnd.ms-excel',
|
|
1583
|
+
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
1584
|
+
mp4: 'video/mp4',
|
|
1585
|
+
mov: 'video/quicktime',
|
|
1586
|
+
zip: 'application/zip',
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
function mimeFor(p: BdPickedFile): string {
|
|
1590
|
+
if (p.mimeType) return p.mimeType
|
|
1591
|
+
const ext = p.name.split('.').pop()?.toLowerCase() ?? ''
|
|
1592
|
+
return MIME_BY_EXT[ext] ?? 'application/octet-stream'
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
/** Read a picked file into a Blob that uploads on submit. */
|
|
1596
|
+
async function toPending(p: BdPickedFile): Promise<BdPendingFile> {
|
|
1597
|
+
const res = await fetch(p.uri)
|
|
1598
|
+
let blob = await res.blob()
|
|
1599
|
+
const type = mimeFor(p)
|
|
1600
|
+
// The upload's Content-Type comes from the blob; make sure it's the real one.
|
|
1601
|
+
if (blob.type !== type) blob = new Blob([blob], { type })
|
|
1602
|
+
return {
|
|
1603
|
+
pending: true,
|
|
1604
|
+
file: blob,
|
|
1605
|
+
name: p.name,
|
|
1606
|
+
size: p.size ?? blob.size,
|
|
1607
|
+
uri: p.uri,
|
|
1608
|
+
mimeType: type,
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
function acceptsImages(allowed: string[]): boolean {
|
|
1613
|
+
return (
|
|
1614
|
+
allowed.length === 0 ||
|
|
1615
|
+
allowed.some((a) => {
|
|
1616
|
+
const t = a.trim().toLowerCase()
|
|
1617
|
+
return (
|
|
1618
|
+
t === '*/*' ||
|
|
1619
|
+
t.startsWith('image/') ||
|
|
1620
|
+
['.jpg', '.jpeg', '.png', '.gif', '.webp', '.heic'].includes(t)
|
|
1621
|
+
)
|
|
1622
|
+
})
|
|
1623
|
+
)
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
function FileControl({ field, value, set }: BdFieldContext) {
|
|
1627
|
+
const { theme, strings } = useBdForm()
|
|
1628
|
+
const { pickFiles } = useBdFormRuntime()
|
|
1629
|
+
const [problem, setProblem] = useState<string | null>(null)
|
|
1630
|
+
const cfg = field.fileConfig
|
|
1631
|
+
const allowed = cfg?.allowedTypes ?? []
|
|
1632
|
+
const files = Array.isArray(value) ? (value as Array<Record<string, unknown>>) : []
|
|
1633
|
+
const maxFiles = Math.max(cfg?.maxFiles ?? 1, 1)
|
|
1634
|
+
const remaining = Math.max(maxFiles - files.length, 0)
|
|
1635
|
+
|
|
1636
|
+
const pick = async (kind: 'files' | 'images') => {
|
|
1637
|
+
if (!pickFiles) return
|
|
1638
|
+
setProblem(null)
|
|
1639
|
+
try {
|
|
1640
|
+
const picked = (
|
|
1641
|
+
await pickFiles({ kind, multiple: remaining > 1, allowedTypes: allowed })
|
|
1642
|
+
).slice(0, remaining)
|
|
1643
|
+
const additions: BdPendingFile[] = []
|
|
1644
|
+
for (const p of picked) {
|
|
1645
|
+
const issue = validateFile(
|
|
1646
|
+
{ name: p.name, type: mimeFor(p), size: p.size },
|
|
1647
|
+
{ allowedTypes: allowed, maxSize: cfg?.maxSize },
|
|
1648
|
+
)
|
|
1649
|
+
if (issue) {
|
|
1650
|
+
setProblem(issue)
|
|
1651
|
+
continue
|
|
1652
|
+
}
|
|
1653
|
+
additions.push(await toPending(p))
|
|
1654
|
+
}
|
|
1655
|
+
if (additions.length > 0) set([...files, ...additions])
|
|
1656
|
+
} catch (e) {
|
|
1657
|
+
setProblem(e instanceof Error ? e.message : String(e))
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
return (
|
|
1662
|
+
<View style={styles.gap8}>
|
|
1663
|
+
{files.map((f, i) => {
|
|
1664
|
+
const pending = isPendingFileValue(f)
|
|
1665
|
+
const name = str(f['name']) || 'File'
|
|
1666
|
+
const size = formatBytes(typeof f['size'] === 'number' ? (f['size'] as number) : undefined)
|
|
1667
|
+
const uri = pending ? (f as unknown as BdPendingFile).uri : safeHttpUrl(str(f['url']))
|
|
1668
|
+
const isImage = (
|
|
1669
|
+
str((f as unknown as BdPendingFile).mimeType) || str(f['mimeType'])
|
|
1670
|
+
).startsWith('image/')
|
|
1671
|
+
return (
|
|
1672
|
+
<View
|
|
1673
|
+
key={`${name}-${i}`}
|
|
1674
|
+
style={[
|
|
1675
|
+
styles.fileRow,
|
|
1676
|
+
{ backgroundColor: theme.colors.surface, borderRadius: theme.cornerRadius },
|
|
1677
|
+
]}
|
|
1678
|
+
>
|
|
1679
|
+
{isImage && uri ? (
|
|
1680
|
+
<Image source={{ uri }} style={styles.fileThumb} accessibilityIgnoresInvertColors />
|
|
1681
|
+
) : (
|
|
1682
|
+
<View
|
|
1683
|
+
style={[styles.fileThumb, styles.fileGlyph, { borderColor: theme.colors.border }]}
|
|
1684
|
+
>
|
|
1685
|
+
<BdText variant="caption">
|
|
1686
|
+
{name.split('.').pop()?.slice(0, 4).toUpperCase()}
|
|
1687
|
+
</BdText>
|
|
1688
|
+
</View>
|
|
1689
|
+
)}
|
|
1690
|
+
<View style={styles.flex}>
|
|
1691
|
+
<BdText numberOfLines={1}>{name}</BdText>
|
|
1692
|
+
<BdText variant="caption">
|
|
1693
|
+
{[size, pending ? strings.uploadsOnSubmit : null].filter(Boolean).join(' · ')}
|
|
1694
|
+
</BdText>
|
|
1695
|
+
</View>
|
|
1696
|
+
<BdButton
|
|
1697
|
+
kind="text"
|
|
1698
|
+
title="✕"
|
|
1699
|
+
accessibilityLabel={`${strings.removeFile} ${name}`}
|
|
1700
|
+
onPress={() => set(files.filter((_, k) => k !== i))}
|
|
1701
|
+
/>
|
|
1702
|
+
</View>
|
|
1703
|
+
)
|
|
1704
|
+
})}
|
|
1705
|
+
{remaining > 0 ? (
|
|
1706
|
+
pickFiles ? (
|
|
1707
|
+
<View style={styles.wrap}>
|
|
1708
|
+
<BdButton
|
|
1709
|
+
kind="outlined"
|
|
1710
|
+
title={strings.chooseFiles}
|
|
1711
|
+
onPress={() => void pick('files')}
|
|
1712
|
+
/>
|
|
1713
|
+
{acceptsImages(allowed) ? (
|
|
1714
|
+
<BdButton
|
|
1715
|
+
kind="outlined"
|
|
1716
|
+
title={strings.choosePhotos}
|
|
1717
|
+
onPress={() => void pick('images')}
|
|
1718
|
+
/>
|
|
1719
|
+
) : null}
|
|
1720
|
+
</View>
|
|
1721
|
+
) : (
|
|
1722
|
+
<BdText variant="caption">{strings.filePickingUnavailable}</BdText>
|
|
1723
|
+
)
|
|
1724
|
+
) : null}
|
|
1725
|
+
{problem ? <BdText variant="error">{problem}</BdText> : null}
|
|
1726
|
+
</View>
|
|
1727
|
+
)
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
function ImageInputControl({ field, value, error, set }: BdFieldContext) {
|
|
1731
|
+
const { theme, strings } = useBdForm()
|
|
1732
|
+
const { pickFiles } = useBdFormRuntime()
|
|
1733
|
+
const cfg = field.imageInputConfig
|
|
1734
|
+
const sources = cfg?.sources ?? 'both'
|
|
1735
|
+
const [chosen, setChosen] = useState<'upload' | 'url'>('upload')
|
|
1736
|
+
const [problem, setProblem] = useState<string | null>(null)
|
|
1737
|
+
const mode = sources === 'url' ? 'url' : sources === 'upload' ? 'upload' : chosen
|
|
1738
|
+
const pending = isPendingFileValue(value) ? (value as BdPendingFile) : null
|
|
1739
|
+
const url = typeof value === 'string' ? safeHttpUrl(value) : null
|
|
1740
|
+
const preview = pending?.uri ?? url
|
|
1741
|
+
|
|
1742
|
+
const pick = async () => {
|
|
1743
|
+
if (!pickFiles) return
|
|
1744
|
+
setProblem(null)
|
|
1745
|
+
try {
|
|
1746
|
+
const [p] = await pickFiles({
|
|
1747
|
+
kind: 'images',
|
|
1748
|
+
multiple: false,
|
|
1749
|
+
allowedTypes: cfg?.allowedTypes ?? ['image/*'],
|
|
1750
|
+
})
|
|
1751
|
+
if (!p) return
|
|
1752
|
+
const issue = validateFile(
|
|
1753
|
+
{ name: p.name, type: mimeFor(p), size: p.size },
|
|
1754
|
+
{ allowedTypes: cfg?.allowedTypes ?? ['image/*'], maxSize: cfg?.maxSize ?? 5 },
|
|
1755
|
+
)
|
|
1756
|
+
if (issue) {
|
|
1757
|
+
setProblem(issue)
|
|
1758
|
+
return
|
|
1759
|
+
}
|
|
1760
|
+
set(await toPending(p))
|
|
1761
|
+
} catch (e) {
|
|
1762
|
+
setProblem(e instanceof Error ? e.message : String(e))
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
return (
|
|
1767
|
+
<View style={styles.gap10}>
|
|
1768
|
+
{sources === 'both' ? (
|
|
1769
|
+
<BdSegmented
|
|
1770
|
+
options={[
|
|
1771
|
+
{ value: 'upload', label: strings.upload },
|
|
1772
|
+
{ value: 'url', label: strings.pasteURL },
|
|
1773
|
+
]}
|
|
1774
|
+
value={mode}
|
|
1775
|
+
onChange={(m) => setChosen(m as 'upload' | 'url')}
|
|
1776
|
+
/>
|
|
1777
|
+
) : null}
|
|
1778
|
+
{mode === 'upload' ? (
|
|
1779
|
+
pickFiles ? (
|
|
1780
|
+
<BdButton
|
|
1781
|
+
kind="outlined"
|
|
1782
|
+
title={strings.choosePhotos}
|
|
1783
|
+
onPress={() => void pick()}
|
|
1784
|
+
style={styles.start}
|
|
1785
|
+
/>
|
|
1786
|
+
) : (
|
|
1787
|
+
<BdText variant="caption">{strings.filePickingUnavailable}</BdText>
|
|
1788
|
+
)
|
|
1789
|
+
) : (
|
|
1790
|
+
<BdTextField
|
|
1791
|
+
value={pending ? '' : str(value)}
|
|
1792
|
+
onChangeText={set}
|
|
1793
|
+
placeholder={field.placeholder || 'https://example.com/image.png'}
|
|
1794
|
+
keyboardType="url"
|
|
1795
|
+
autoCapitalize="none"
|
|
1796
|
+
autoCorrect={false}
|
|
1797
|
+
isError={!!error}
|
|
1798
|
+
/>
|
|
1799
|
+
)}
|
|
1800
|
+
{cfg?.showPreview !== false && preview ? (
|
|
1801
|
+
<View
|
|
1802
|
+
style={[
|
|
1803
|
+
styles.preview,
|
|
1804
|
+
{ borderRadius: theme.cornerRadius, backgroundColor: theme.colors.surface },
|
|
1805
|
+
]}
|
|
1806
|
+
>
|
|
1807
|
+
<Image
|
|
1808
|
+
source={{ uri: preview }}
|
|
1809
|
+
style={StyleSheet.absoluteFill}
|
|
1810
|
+
resizeMode="cover"
|
|
1811
|
+
accessibilityIgnoresInvertColors
|
|
1812
|
+
/>
|
|
1813
|
+
<Pressable
|
|
1814
|
+
accessibilityRole="button"
|
|
1815
|
+
accessibilityLabel={strings.clear}
|
|
1816
|
+
onPress={() => set('')}
|
|
1817
|
+
style={styles.previewClear}
|
|
1818
|
+
>
|
|
1819
|
+
<BdText color="#FFFFFF">✕</BdText>
|
|
1820
|
+
</Pressable>
|
|
1821
|
+
</View>
|
|
1822
|
+
) : null}
|
|
1823
|
+
{pending ? (
|
|
1824
|
+
<BdText variant="caption">
|
|
1825
|
+
{pending.name} — {strings.uploadsOnSubmit.toLowerCase()}.
|
|
1826
|
+
</BdText>
|
|
1827
|
+
) : null}
|
|
1828
|
+
{problem ? <BdText variant="error">{problem}</BdText> : null}
|
|
1829
|
+
</View>
|
|
1830
|
+
)
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
type PaymentConfig = {
|
|
1834
|
+
mode?: 'card_on_file' | 'deposit'
|
|
1835
|
+
amountCents?: number
|
|
1836
|
+
currency?: string
|
|
1837
|
+
buttonLabel?: string
|
|
1838
|
+
description?: string
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
function CardControl({ field, value, set }: BdFieldContext) {
|
|
1842
|
+
const { theme, strings } = useBdForm()
|
|
1843
|
+
const { client, slug, collectPayment } = useBdFormRuntime()
|
|
1844
|
+
const [busy, setBusy] = useState(false)
|
|
1845
|
+
const [problem, setProblem] = useState<string | null>(null)
|
|
1846
|
+
const pc = (field as { paymentConfig?: PaymentConfig }).paymentConfig
|
|
1847
|
+
const deposit = pc?.mode === 'deposit'
|
|
1848
|
+
const amount =
|
|
1849
|
+
deposit && pc?.amountCents
|
|
1850
|
+
? `${(pc.amountCents / 100).toFixed(2)} ${(pc.currency ?? 'usd').toUpperCase()}`
|
|
1851
|
+
: null
|
|
1852
|
+
const saved = str(value).length > 0
|
|
1853
|
+
|
|
1854
|
+
const collect = async () => {
|
|
1855
|
+
const mint = client?.forms.paymentIntent
|
|
1856
|
+
if (!mint || !slug || !collectPayment) {
|
|
1857
|
+
setProblem(strings.cardUnavailable)
|
|
1858
|
+
return
|
|
1859
|
+
}
|
|
1860
|
+
setBusy(true)
|
|
1861
|
+
setProblem(null)
|
|
1862
|
+
try {
|
|
1863
|
+
const intent = await mint(slug, field.id)
|
|
1864
|
+
set(await collectPayment(intent, field))
|
|
1865
|
+
} catch (e) {
|
|
1866
|
+
setProblem(e instanceof Error && e.message ? e.message : strings.cardFailed)
|
|
1867
|
+
} finally {
|
|
1868
|
+
setBusy(false)
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
return (
|
|
1873
|
+
<View style={styles.gap10}>
|
|
1874
|
+
<View style={styles.row8}>
|
|
1875
|
+
<BdText style={[styles.flex, styles.semibold]}>
|
|
1876
|
+
{deposit ? `${strings.deposit}${amount ? ` · ${amount}` : ''}` : strings.cardOnFile}
|
|
1877
|
+
</BdText>
|
|
1878
|
+
{saved ? (
|
|
1879
|
+
<View style={styles.row4}>
|
|
1880
|
+
<BdCheckGlyph color={theme.colors.success} size={16} />
|
|
1881
|
+
<BdText variant="caption" color={theme.colors.success}>
|
|
1882
|
+
{strings.cardSaved}
|
|
1883
|
+
</BdText>
|
|
1884
|
+
</View>
|
|
1885
|
+
) : null}
|
|
1886
|
+
</View>
|
|
1887
|
+
{pc?.description ? <BdText variant="caption">{pc.description}</BdText> : null}
|
|
1888
|
+
<BdButton
|
|
1889
|
+
kind="outlined"
|
|
1890
|
+
title={pc?.buttonLabel || strings.addCard}
|
|
1891
|
+
busy={busy}
|
|
1892
|
+
onPress={() => void collect()}
|
|
1893
|
+
style={styles.start}
|
|
1894
|
+
/>
|
|
1895
|
+
{problem ? <BdText variant="error">{problem}</BdText> : null}
|
|
1896
|
+
</View>
|
|
1897
|
+
)
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
const styles = StyleSheet.create({
|
|
1901
|
+
flex: { flex: 1 },
|
|
1902
|
+
flex13: { flex: 1.3 },
|
|
1903
|
+
flex14: { flex: 1.4 },
|
|
1904
|
+
start: { alignSelf: 'flex-start' },
|
|
1905
|
+
center: { textAlign: 'center' },
|
|
1906
|
+
semibold: { fontWeight: '600' },
|
|
1907
|
+
tnum: { fontVariant: ['tabular-nums'] },
|
|
1908
|
+
gap4: { gap: 4 },
|
|
1909
|
+
gap6: { gap: 6 },
|
|
1910
|
+
gap8: { gap: 8 },
|
|
1911
|
+
gap10: { gap: 10 },
|
|
1912
|
+
gap14: { gap: 14 },
|
|
1913
|
+
row4: { flexDirection: 'row', alignItems: 'center', gap: 4 },
|
|
1914
|
+
row8: { flexDirection: 'row', alignItems: 'center', gap: 8 },
|
|
1915
|
+
wrap: { flexDirection: 'row', flexWrap: 'wrap', gap: 8 },
|
|
1916
|
+
partLabel: { marginBottom: 4 },
|
|
1917
|
+
unitPicker: { minWidth: 96 },
|
|
1918
|
+
optionLabel: { flexDirection: 'row', alignItems: 'center', gap: 10 },
|
|
1919
|
+
optionImage: { width: 28, height: 28, borderRadius: 6 },
|
|
1920
|
+
tool: {
|
|
1921
|
+
minWidth: 40,
|
|
1922
|
+
height: 36,
|
|
1923
|
+
alignItems: 'center',
|
|
1924
|
+
justifyContent: 'center',
|
|
1925
|
+
paddingHorizontal: 10,
|
|
1926
|
+
},
|
|
1927
|
+
toolDivider: { width: StyleSheet.hairlineWidth, height: 24, marginHorizontal: 4 },
|
|
1928
|
+
card: { flexDirection: 'row', alignItems: 'center', gap: 12 },
|
|
1929
|
+
cardImage: { width: 56, height: 56, borderRadius: 10 },
|
|
1930
|
+
cardIcon: { width: 32, alignItems: 'center' },
|
|
1931
|
+
switchRow: { flexDirection: 'row', alignItems: 'center', minHeight: 48, gap: 12 },
|
|
1932
|
+
iconCell: {
|
|
1933
|
+
flex: 1,
|
|
1934
|
+
minHeight: 48,
|
|
1935
|
+
alignItems: 'center',
|
|
1936
|
+
justifyContent: 'center',
|
|
1937
|
+
paddingHorizontal: 2,
|
|
1938
|
+
},
|
|
1939
|
+
star: { padding: 2 },
|
|
1940
|
+
starGlyph: { fontSize: 34, lineHeight: 40 },
|
|
1941
|
+
faces: { flexDirection: 'row', justifyContent: 'space-evenly' },
|
|
1942
|
+
face: { width: 56, height: 56, borderRadius: 28, alignItems: 'center', justifyContent: 'center' },
|
|
1943
|
+
faceGlyph: { fontSize: 32, lineHeight: 40 },
|
|
1944
|
+
stepper: { flexDirection: 'row', alignItems: 'center', gap: 18 },
|
|
1945
|
+
stepperButton: { minWidth: 48, paddingHorizontal: 0 },
|
|
1946
|
+
dayCard: { width: 58, height: 72, alignItems: 'center', justifyContent: 'center' },
|
|
1947
|
+
fileRow: { flexDirection: 'row', alignItems: 'center', gap: 12, padding: 8 },
|
|
1948
|
+
fileThumb: { width: 40, height: 40, borderRadius: 6 },
|
|
1949
|
+
fileGlyph: {
|
|
1950
|
+
alignItems: 'center',
|
|
1951
|
+
justifyContent: 'center',
|
|
1952
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
1953
|
+
},
|
|
1954
|
+
preview: { height: 180, overflow: 'hidden' },
|
|
1955
|
+
previewClear: {
|
|
1956
|
+
position: 'absolute',
|
|
1957
|
+
top: 8,
|
|
1958
|
+
right: 8,
|
|
1959
|
+
width: 32,
|
|
1960
|
+
height: 32,
|
|
1961
|
+
borderRadius: 16,
|
|
1962
|
+
alignItems: 'center',
|
|
1963
|
+
justifyContent: 'center',
|
|
1964
|
+
backgroundColor: 'rgba(0,0,0,0.5)',
|
|
1965
|
+
},
|
|
1966
|
+
})
|