|
| 1 | +from dataclasses import dataclass |
| 2 | +from typing import Literal, TypedDict, Callable |
| 3 | + |
| 4 | +from chartlets import Component |
| 5 | + |
| 6 | + |
| 7 | +@dataclass(frozen=True) |
| 8 | +class Slider(Component): |
| 9 | + """Sliders allow users to make selections from a range of values along a |
| 10 | + bar.""" |
| 11 | + |
| 12 | + aria_label: str | None = None |
| 13 | + """The label of the slider.""" |
| 14 | + |
| 15 | + color: str | None = None |
| 16 | + """The color of the component. It supports both default and custom theme |
| 17 | + colors |
| 18 | + """ |
| 19 | + |
| 20 | + defaultValue: list[int] | int | None = None |
| 21 | + """The default value. Use when the component is not controlled. If used |
| 22 | + as an array, it will create multiple sliding points on the bar |
| 23 | + """ |
| 24 | + |
| 25 | + disableSwap: bool | None = None |
| 26 | + """If true, the active thumb doesn't swap when moving pointer over a thumb |
| 27 | + while dragging another thumb. |
| 28 | + """ |
| 29 | + |
| 30 | + getAriaValueText: Callable[[int, int], str] | None = None |
| 31 | + """Accepts a function which returns a string value that provides a |
| 32 | + user-friendly name for the current value of the slider. This is important |
| 33 | + for screen reader users. |
| 34 | + |
| 35 | + Signature: |
| 36 | + function(value: number, index: number) => string |
| 37 | +
|
| 38 | + value: The thumb label's value to format. |
| 39 | + index: The thumb label's index to format. |
| 40 | + """ |
| 41 | + |
| 42 | + min: int | None = None |
| 43 | + """The minimum allowed value of the slider. Should not be equal to max.""" |
| 44 | + |
| 45 | + max: int | None = None |
| 46 | + """The maximum allowed value of the slider. Should not be equal to min.""" |
| 47 | + |
| 48 | + marks: (bool | |
| 49 | + list[TypedDict("marks", {"value": int, "label": str})] | |
| 50 | + None) = None |
| 51 | + """Marks indicate predetermined values to which the user can move the |
| 52 | + slider. If true the marks are spaced according the value of the step |
| 53 | + prop. If an array, it should contain objects with value and an optional |
| 54 | + label keys. |
| 55 | + """ |
| 56 | + |
| 57 | + orientation: Literal["horizontal", "vertical"] | None = None |
| 58 | + """The component orientation.""" |
| 59 | + |
| 60 | + step: int | None = None |
| 61 | + """The granularity with which the slider can step through values. (A |
| 62 | + "discrete" slider.) The min prop serves as the origin for the valid values. |
| 63 | + We recommend (max - min) to be evenly divisible by the step. When step is |
| 64 | + null, the thumb can only be slid onto marks provided with the marks prop. |
| 65 | + """ |
| 66 | + |
| 67 | + size: str | None = None |
| 68 | + """The size of the slider.""" |
| 69 | + |
| 70 | + tooltip: str | None = None |
| 71 | + """Tooltip title. Optional.""" |
| 72 | + |
| 73 | + track: Literal["inverted", "normal"] | False | None = None |
| 74 | + """The track presentation: |
| 75 | +
|
| 76 | + `normal`: the track will render a bar representing the slider value. |
| 77 | + `inverted`: the track will render a bar representing the remaining slider |
| 78 | + value. |
| 79 | + `false`: the track will render without a bar. |
| 80 | + """ |
| 81 | + |
| 82 | + value: list[int] | int | None = None |
| 83 | + """The value of the slider. For ranged sliders, provide an array with two |
| 84 | + values. |
| 85 | + """ |
| 86 | + |
| 87 | + valueLabelDisplay: Literal['auto', 'on', 'off'] | None = None |
| 88 | + """Controls when the value label is displayed: |
| 89 | +
|
| 90 | + `auto` the value label will display when the thumb is hovered or focused. |
| 91 | + `on` will display persistently. |
| 92 | + `off` will never display. |
| 93 | + """ |
0 commit comments