LiveTable.Range (live_table v0.4.0)

View Source

A module for handling numeric range-based filters in LiveTable.

This module provides functionality for creating and managing range filters for numeric values. It supports creating range sliders with customizable options and appearances using Sutra UI's range_slider component.

Options

The module accepts the following options:

  • :label - The label text for the range filter
  • :unit - The unit to display after the label (optional)
  • :min - Minimum value of the range
  • :max - Maximum value of the range
  • :step - Step increment (integer for integers, float for decimals)
  • :default_min - Default minimum selected value
  • :default_max - Default maximum selected value
  • :pips - Show scale markers (boolean)
  • :css_classes - CSS classes for the main container
  • :slider_classes - CSS classes for the slider element
  • :label_classes - CSS classes for the label element

For default values, see: LiveTable.Range source code

Examples

# Creating a numeric range filter with integer step
Range.new(:price, "price_range", %{
  label: "Price Range",
  unit: "$",
  min: 0,
  max: 1000,
  step: 10
})

# Creating a range filter with float step
Range.new(:rating, "rating_range", %{
  label: "Rating",
  min: 0.0,
  max: 5.0,
  step: 0.5
})

If you want to use the range filter with a joined schema, you can pass the field as a tuple:

Range.new({:products, :price}, "price", %{
  label: "Product Price",
  min: 0,
  max: 1000,
})