Content-Length: 351143 | pFad | http://github.com/bootstrap-vue-next/bootstrap-vue-next/pull/2732

51 draft of BApp by xvaara · Pull Request #2732 · bootstrap-vue-next/bootstrap-vue-next · GitHub
Skip to content

draft of BApp #2732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

draft of BApp #2732

wants to merge 2 commits into from

Conversation

xvaara
Copy link
Contributor

@xvaara xvaara commented Jun 6, 2025

BApp Component

The BApp component is the new recommended way to configure bootstrap-vue-next. It replaces the plugin-based approach and provides better defaults management and orchestrator integration.

Features

  • Defaults Management: Inject and merge component defaults throughout your application
  • Orchestrator Integration: Automatically includes Modal, Toast, and Popover orchestrators
  • Plugin Compatibility: Works alongside existing plugins for backward compatibility
  • Type Safety: Full TypeScript support with proper type inference
  • RTL Support: Built-in right-to-left language support
  • Flexible Teleporting: Control where orchestrators are rendered in the DOM

Basic Usage

<template>
  <BApp>
    <!-- Your application content -->
    <router-view />
  </BApp>
</template>

<script setup lang="ts">
import {BApp} from 'bootstrap-vue-next'
</script>

Configuration

Setting Component Defaults

<template>
  <BApp :defaults="appDefaults">
    <!-- Your application content -->
  </BApp>
</template>

<script setup lang="ts">
import {BApp} from 'bootstrap-vue-next'

const appDefaults = {
  BButton: {
    variant: 'primary',
    size: 'sm',
  },
  BModal: {
    centered: true,
    noCloseOnBackdrop: true,
  },
  BToast: {
    variant: 'success',
    solid: true,
  },
}
</script>

Advanced Defaults Configuration

<template>
  <BApp :defaults="appDefaults" :merge-defaults="true" :deep-merge="true">
    <!-- Your application content -->
  </BApp>
</template>

<script setup lang="ts">
import {BApp} from 'bootstrap-vue-next'

const appDefaults = {
  BButton: {
    variant: 'primary',
    size: 'sm',
  },
}
</script>

Orchestrator Configuration

<template>
  <BApp :teleport-to="'body'" :append-toast="true">
    <!-- Your application content -->
  </BApp>
</template>

Disabling Orchestrators

<template>
  <BApp :no-modals="true" :no-toasts="true" :no-popovers="true">
    <!-- Your application content -->
  </BApp>
</template>

RTL Configuration

<template>
  <BApp :rtl="rtlConfig">
    <!-- Your application content -->
  </BApp>
</template>

<script setup lang="ts">
import {BApp} from 'bootstrap-vue-next'

const rtlConfig = {
  rtlInitial: true,
  localeInitial: 'ar',
}
</script>

Migration from Plugins

Before (Plugin-based)

import {createApp} from 'vue'
import {createBootstrap} from 'bootstrap-vue-next'

const app = createApp(App)

app.use(
  createBootstrap({
    components: {
      BButton: {
        variant: 'primary',
      },
    },
  })
)

After (BApp-based)

<template>
  <BApp :defaults="{BButton: {variant: 'primary'}}">
    <App />
  </BApp>
</template>

<script setup lang="ts">
import {BApp} from 'bootstrap-vue-next'
import App from './App.vue'
</script>

Props

Prop Type Default Description
defaults Partial<BvnComponentProps> undefined Component defaults to apply globally
mergeDefaults boolean false Whether to merge with existing defaults
deepMerge boolean false Whether to perform deep merge of nested objects
teleportTo TeleportProps['to'] undefined Where to teleport the orchestrator container
noModals boolean false Whether to disable modal orchestrator
noToasts boolean false Whether to disable toast orchestrator
noPopovers boolean false Whether to disable popover orchestrator
noOrchestrator boolean false Whether to disable all orchestrators
appendToast boolean false Whether new toasts should be appended to the list
inhert boolean false Whether to inherit parent orchestrator controllers
rtl boolean | RTLConfig false RTL configuration object or boolean

RTL Configuration Object

interface RTLConfig {
  rtlInitial: boolean // Initial RTL state
  localeInitial?: string // Initial locale
}

Composables

When using BApp, the following composables work without requiring plugin installation:

  • useToastController() - Create and manage toasts programmatically
  • useModalController() - Create and manage modals programmatically
  • usePopoverController() - Create and manage popovers programmatically

Internal Features

The BApp component automatically provides several internal services:

  • Show/Hide Registry: Global registry for show/hide components
  • Modal Manager: Stack management for multiple modals
  • Breadcrumb Service: Global breadcrumb item management
  • RTL Service: Right-to-left text direction support

Default Merging Behavior

The component supports three modes for handling defaults:

  1. Replace Mode (default): defaults prop completely replaces any existing defaults
  2. Merge Mode (mergeDefaults: true): Shallow merge with existing defaults
  3. Deep Merge Mode (mergeDefaults: true, deepMerge: true): Deep merge nested objects

Teleporting

By default, orchestrators render inline. Use teleportTo to render them elsewhere:

<template>
  <BApp teleport-to="body">
    <!-- Orchestrators will render in document.body -->
  </BApp>
</template>

Backward Compatibility

The BApp component is fully backward compatible with existing plugin-based setups. You can gradually migrate by:

  1. Adding BApp to your root component
  2. Moving defaults from plugin configuration to BApp props
  3. Removing plugin installations once migration is complete

The plugins will show deprecation warnings but continue to work until removed in a future version.

Notes

  • Only one BApp or orchestrator should be active at a time per application
  • The component uses Vue's provide/inject system for dependency injection
  • All orchestrators are automatically teleported when teleportTo is specified
  • The component inherits all attributes and passes them to the default slot

PR checklist

What kind of change does this PR introduce? (check at least one)

  • Bugfix 🐛 - fix(...)
  • Feature - feat(...)
  • ARIA accessibility - fix(...)
  • Documentation update - docs(...)
  • Other (please describe)

The PR fulfills these requirements:

  • Pull request title and all commits follow the Conventional Commits convention or has an override in this pull request body This is very important, as the CHANGELOG is generated from these messages, and determines the next version type. Pull requests that do not follow conventional commits or do not have an override will be denied

Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

coderabbitai bot commented Jun 6, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dwgray
Copy link
Member

dwgray commented Jun 6, 2025

@xvaara, I really like this for the core setup. It's what I would use in my app, given a choice between this and the current plugin.

The main question I have is about tree shaking. As @VividLemon mentioned previously, there is some segment of our user base that is quite concerned about the deployed size of BSVN. If we eventually deprecate the plugins and only allow this method of installation, do we effectively disable tree shaking?

@VividLemon
Copy link
Member

@xvaara, I really like this for the core setup. It's what I would use in my app, given a choice between this and the current plugin.

The main question I have is about tree shaking. As @VividLemon mentioned previously, there is some segment of our user base that is quite concerned about the deployed size of BSVN. If we eventually deprecate the plugins and only allow this method of installation, do we effectively disable tree shaking?

I think the best solution to this is to effectively give people the tools to build their own "bapp" and document how to do it well

teleportTo: undefined,
defaults: undefined,
mergeDefaults: false,
deepMerge: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe mergeDefaults is boolean | function to where the function is the algorithm to use for merging?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally dislike props that just effect the behavior of other props. Begs the question why it's not just an object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/bootstrap-vue-next/bootstrap-vue-next/pull/2732

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy