@molecule/app-bulk-action-toolbar-vue

Feature · bulk-action-toolbar · App (browser) · v1.1.2 · Apache-2.0

Selection-aware floating toolbar that appears when N rows are selected

npm install @molecule/app-bulk-action-toolbar-vue

npm · Source on GitHub

How it works

@molecule/app-bulk-action-toolbar-vue is a ready-made bulk-action-toolbar feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

import { createApp, defineComponent, h } from 'vue'
import { BulkActionToolbar } from '@molecule/app-bulk-action-toolbar-vue'

const App = defineComponent({
  setup() {
    return () =>
      h(BulkActionToolbar, {
        count: selectedIds.value.length,
        actions: [
          {
            id: 'delete',
            label: 'Delete',
            onClick: () => handleDelete(selectedIds.value),
            destructive: true,
          },
          { id: 'export', label: 'Export', onClick: () => handleExport(selectedIds.value) },
        ],
        onClearSelection: () => (selectedIds.value = []),
      })
  },
})

createApp(App).mount('#app')

Works with: @molecule/app-ui, @molecule/app-ui-vue, @molecule/app-vue

Reference

Vue selection-aware bulk action toolbar.

Exports <BulkActionToolbar> and the BulkAction type — the Vue counterpart of @molecule/app-bulk-action-toolbar-react: the same props (React names) and the same DOM for the same input.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

import { createApp, defineComponent, h } from 'vue'
import { BulkActionToolbar } from '@molecule/app-bulk-action-toolbar-vue'

const App = defineComponent({
  setup() {
    return () =>
      h(BulkActionToolbar, {
        count: selectedIds.value.length,
        actions: [
          {
            id: 'delete',
            label: 'Delete',
            onClick: () => handleDelete(selectedIds.value),
            destructive: true,
          },
          { id: 'export', label: 'Export', onClick: () => handleExport(selectedIds.value) },
        ],
        onClearSelection: () => (selectedIds.value = []),
      })
  },
})

createApp(App).mount('#app')

Type

feature

Installation

npm install @molecule/app-bulk-action-toolbar-vue @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue

API

Interfaces

BulkAction

Descriptor for a single action button rendered inside BulkActionToolbar.

interface BulkAction {
  /** Stable id — the render key of the action's button. */
  id: string
  /** Button label. */
  label: VNodeChild
  /** Optional leading icon inside the button. */
  icon?: VNodeChild
  /** Called when the action's button is clicked. */
  onClick: () => void
  /** Renders the button as a solid error-colored (destructive) button. */
  destructive?: boolean
  /** Disables the button. */
  disabled?: boolean
}

BulkActionToolbarProps

Props accepted by the BulkActionToolbar component.

interface BulkActionToolbarProps {
  /** Selection count — toolbar hides when 0. */
  count: number
  /** Action buttons. */
  actions: BulkAction[]
  /** Called when "Clear selection" is clicked. */
  onClearSelection?: () => void
  /** Position — `'sticky-bottom'` (default), `'sticky-top'`, or `'inline'`. */
  position?: 'sticky-bottom' | 'sticky-top' | 'inline'
  /** Extra classes. */
  className?: string
}

Constants

BulkActionToolbar

Vue selection-aware bulk action toolbar.

Renders nothing while count <= 0 (the render function returns null, the way React's component does). position defaults to 'sticky-bottom' (16px inset, z-30); 'sticky-top' and 'inline' are also supported. Destructive actions render as solid error-colored buttons. The count label, the Clear button and the toolbar's own aria-label are translated via useTranslation() with React's exact keys and default values.

const BulkActionToolbar: DefineComponent<
  ExtractPropTypes<{
    count: { type: NumberConstructor; required: true }
    actions: { type: PropType<BulkAction[]>; required: true }
    onClearSelection: PropType<() => void>
    position: { type: PropType<'sticky-bottom' | 'sticky-top' | 'inline'>; default: string }
    className: StringConstructor
  }>,
  () => VNode | null,
  {},
  {},
  {},
  ComponentOptionsMixin,
  ComponentOptionsMixin,
  {},
  string,
  PublicProps,
  Readonly<
    ExtractPropTypes<{
      count: { type: NumberConstructor; required: true }
      actions: { type: PropType<BulkAction[]>; required: true }
      onClearSelection: PropType<() => void>
      position: { type: PropType<'sticky-bottom' | 'sticky-top' | 'inline'>; default: string }
      className: StringConstructor
    }>
  > &
    Readonly<{}>,
  { position: 'sticky-bottom' | 'sticky-top' | 'inline' },
  {},
  {},
  {},
  string,
  ComponentProvideOptions,
  true,
  {},
  any
>
  • props — Component props (see BulkActionToolbarProps in ./types.js).

Returns: The toolbar component.

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-vue ^1.1.0
  • @molecule/app-vue ^3.5.0 || ^4.0.0
  • vue ^3.4.0

Runtime Dependencies

  • @molecule/app-ui
  • @molecule/app-ui-vue
  • @molecule/app-vue
  • vue

Renders nothing while count <= 0 — mount it unconditionally and drive it from selection state. position defaults to 'sticky-bottom' (16px inset, z-30); 'sticky-top' and 'inline' are also supported. Destructive actions render as solid error-colored buttons. The count label and Clear button are translated via useTranslation() (React's exact keys and default values) and the companion @molecule/app-locales-bulk-action-toolbar locale bond. An action's node-valued fields (label, icon) are Vue nodes (VNodeChild).

Translations

Translation strings are provided by @molecule/app-locales-bulk-action-toolbar.