@molecule/app-time-slot-picker-svelte

Feature · time-slot-picker · App (browser) · v1.1.3 · Apache-2.0

Pick a delivery / appointment slot from a list of available time windows

npm install @molecule/app-time-slot-picker-svelte

npm · Source on GitHub

How it works

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

<script lang="ts">
  import { TimeSlotPicker, type TimeSlot } from '@molecule/app-time-slot-picker-svelte'

  let selected = $state<string>()
  const slots: TimeSlot[] = [
    { id: 'am', label: '9:00–12:00', meta: '3 spots left' },
    { id: 'pm', label: '14:00–17:00', meta: 'Available' },
    { id: 'eve', label: '18:00–20:00', disabled: true, meta: 'Full' },
  ]
</script>

<TimeSlotPicker
  {slots}
  selectedId={selected}
  layout="grid"
  columns={3}
  onSelect={(slot) => (selected = slot.id)}
>
  {#snippet title()}
    <strong>Pick a delivery window</strong>
  {/snippet}
</TimeSlotPicker>

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

Reference

Time-slot picker for delivery / appointment / reservation flows — the Svelte counterpart of @molecule/app-time-slot-picker-react.

Exports TimeSlotPicker and the TimeSlot type, with 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

<script lang="ts">
  import { TimeSlotPicker, type TimeSlot } from '@molecule/app-time-slot-picker-svelte'

  let selected = $state<string>()
  const slots: TimeSlot[] = [
    { id: 'am', label: '9:00–12:00', meta: '3 spots left' },
    { id: 'pm', label: '14:00–17:00', meta: 'Available' },
    { id: 'eve', label: '18:00–20:00', disabled: true, meta: 'Full' },
  ]
</script>

<TimeSlotPicker
  {slots}
  selectedId={selected}
  layout="grid"
  columns={3}
  onSelect={(slot) => (selected = slot.id)}
>
  {#snippet title()}
    <strong>Pick a delivery window</strong>
  {/snippet}
</TimeSlotPicker>

Type

feature

Installation

npm install @molecule/app-time-slot-picker-svelte @molecule/app-svelte @molecule/app-ui @molecule/app-ui-svelte svelte

API

Interfaces

TimeSlot

Represents a single selectable time slot with an optional meta line and disabled state.

interface TimeSlot {
  /** Stable identity, used as the list key and compared with `selectedId`. */
  id: string
  /** Display label — `'14:00–16:00'`, `'Morning (9–12)'`, etc.: text or a snippet. */
  label: string | Snippet
  /** Optional secondary line — date, fee, capacity: text or a snippet. */
  meta?: string | Snippet
  /** When true, slot is disabled (full / past / unavailable). */
  disabled?: boolean
}

TimeSlotPickerProps

Props accepted by the TimeSlotPicker component.

interface TimeSlotPickerProps {
  /** The selectable slots, rendered in order. */
  slots: TimeSlot[]
  /** Currently selected slot id. */
  selectedId?: string
  /** Called when an enabled slot is picked. */
  onSelect: (slot: TimeSlot) => void
  /** Layout — `'list'` stacks vertically (mobile), `'grid'` lays out in columns. */
  layout?: 'list' | 'grid'
  /** Grid column count (only for `layout='grid'`). Defaults to `2`. */
  columns?: 2 | 3 | 4
  /** Optional title above the slots: text, or a snippet. */
  title?: string | Snippet
  /** Extra classes. */
  className?: string
}

Constants

TimeSlotPicker

const TimeSlotPicker: LegacyComponentType

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-svelte ^3.13.0 || ^4.0.0
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-svelte ^1.1.0
  • svelte ^5.0.0

Runtime Dependencies

  • @molecule/app-svelte

  • @molecule/app-ui

  • @molecule/app-ui-svelte

  • svelte

  • Must render inside the app's i18n provider and with a ClassMap bond wired (useTranslation() / getClassMap() throw otherwise).

  • The picker has NO date/timezone logic — label/meta are opaque nodes. Format times in the user's locale AND timezone yourself before passing them.

  • layout="grid" uses a FIXED column count (no breakpoint collapse) — choose columns for your narrowest supported viewport or switch to layout="list" on mobile.

  • Selection is conveyed by aria-checked + bolder font only — add a selected surface via className logic in your wrapper if the state reads too subtle.

  • Disabled slots are dimmed and non-clickable (onSelect never fires for them).

  • Node-valued fields (title, and an item's label/meta) are snippets.

Translations

Translation strings are provided by @molecule/app-locales-time-slot-picker.