# `<ixfx-labelled-radial-input>`

A composite radial input that pairs an editable label (`ixfx-editable-number`) with a rotary dial (`ixfx-radial-input`). The two controls are always in sync — turning the dial updates the number, and editing the number moves the dial.

## Basic usage

```html
<ixfx-labelled-radial-input label="Volume" value="50" min="0" max="100">
</ixfx-labelled-radial-input>
```

## Layout

Layout is driven by a container query on the component's aspect ratio (width / height).

| Aspect Ratio (width/height) | Layout                         |
|----------------------------|--------------------------------|
| >= 1.5 (wide)              | **Horizontal** — label to the left of dial |
| < 1.5 (tall/square)       | **Vertical** — label above dial |

### Force a layout with `--flow`

Override the container query entirely:

```html
<ixfx-labelled-radial-input style="--flow: row" ...>    <!-- always horizontal (label left) -->
<ixfx-labelled-radial-input style="--flow: column" ...> <!-- always vertical (label above) -->
```

## Mini mode

When the component is very small the label is hidden and only the dial is shown, with the tooltip forced on.

Mini mode activates when **both** of the following are true:
- `width < mini-width-threshold` (default 120px)
- `height < mini-height-threshold` (default 45px)

Override with a CSS variable:

```html
<ixfx-labelled-radial-input style="--mini: 1" ...> <!-- always mini  -->
<ixfx-labelled-radial-input style="--mini: 0" ...> <!-- never mini   -->
```

## Formatter

Apply a function to format the displayed value. Set it as a JS property — it cannot be set as an HTML attribute.

```js
const el = document.querySelector('ixfx-labelled-radial-input');
el.formatter = (v) => `${Math.round(Number(v))}%`;
```

The formatter receives the raw string value and returns the string to display.

## Properties / attributes

| Attribute                | Type                                           | Default      | Description                                         |
|--------------------------|------------------------------------------------|--------------|-----------------------------------------------------|
| `label`                  | `string`                                       | `""`         | Label text shown in the editable-number             |
| `value`                  | `number`                                      | `0`          | Current value                                       |
| `min`                    | `number`                                      | `0`          | Minimum value                                       |
| `max`                    | `number`                                      | `100`        | Maximum value                                       |
| `step`                   | `number`                                      | `1`          | Step increment                                      |
| `drag-sensitivity`       | `number`                                      | `1`          | Steps per pixel when dragging the number label      |
| `precision`              | `number`                                      | `0`          | Decimal places shown                                |
| `radius`                 | `number` (10-50)                              | `45`         | Dial size                                           |
| `flatten`                | `number` (0-1)                                | `0.3`        | How much circle to hide                             |
| `marker-style`           | `"needle" \| "dot" \| "none"`                 | `"needle"`   | Marker type                                         |
| `wedge`                  | `boolean`                                     | `false`      | Show filled wedge sector                            |
| `value-mode`             | `"range" \| "bipolar" \| "unipolar"`           | `"range"`    | Value display mode                                 |
| `tooltip`                | `boolean`                                     | `false`      | Show dial tooltip                                   |
| `tooltipFormatter`       | `(value, relative) => string`                 | —            | Format the dial tooltip text (`value` in min..max units, `relative` 0..1). Property only |
| `aspect-ratio-threshold` | `number`                                      | `1.5`        | Width/height ratio to trigger horizontal layout     |
| `mini-width-threshold`   | `number`                                      | `120`        | Width (px) below which mini mode can activate       |
| `mini-height-threshold`  | `number`                                      | `45`         | Height (px) below which mini mode can activate      |
| `display-text-logic`     | `"hidden" \| "show" \| "override" \| "transient"` | `"transient"` | Controls when label text vs value is shown    |
| `formatter`              | `(value: string) => string`                   | —            | JS property only — formats value for display        |

### `display-text-logic` values

| Value       | Behaviour                                              |
|-------------|--------------------------------------------------------|
| `transient` | Shows the label when idle, value on hover/interaction  |
| `show`      | Always shows the value                                 |
| `hidden`    | Always shows the label text, never the value           |
| `override`  | Label text replaces value at all times                 |

## Events

| Event    | Detail                    | Description                                              |
|----------|---------------------------|----------------------------------------------------------|
| `change` | `{ value: string }`       | Fired when the value is committed (dial release or number edit) |
| `input`  | `{ value: number }`       | Fired on every dial interaction                          |

Both events bubble and are composed (cross shadow boundary).

## CSS variables

### Layout

| Variable    | Default      | Description                                               |
|-------------|--------------|-----------------------------------------------------------|
| `--height`  | `auto`       | Component height                                          |
| `--width`   | `auto`       | Component width                                           |
| `--min-height` | `60px`    | Minimum height                                            |
| `--min-width`  | `60px`    | Minimum width                                             |
| `--flow`    | *(container query)* | `row` or `column` — overrides the automatic layout |
| `--mini`    | *(auto)*     | `1` to force mini mode, `0` to disable it                 |

### Label (passed to `ixfx-editable-number`)

| Variable              | Default                    | Description              |
|-----------------------|----------------------------|--------------------------|
| `--label-font-size`   | `var(--text-m)`            | Font size                |
| `--label-font-family` | `var(--font-family)`       | Font family              |
| `--label-color`       | `var(--surface-text)`      | Text colour              |
| `--label-muted-color` | `var(--surface-muted-text)`| Muted text colour        |
| `--label-padding`     | `var(--space-xs) var(--space-s)` | Padding             |
| `--label-radius`      | `var(--radius-s)`          | Border radius            |
| `--label-align`       | `center`                   | Text alignment           |

### Dial (passed to `ixfx-radial-input`)

| Variable                    | Default      | Description                        |
|-----------------------------|--------------|------------------------------------|
| `--dial-border-width`        | —            | Dial border width                  |
| `--dial-border-color`        | —            | Dial border colour                 |
| `--dial-fill`                | —            | Dial fill colour                   |
| `--radius`                  | `45`         | Dial radius                        |
| `--marker-color`             | —            | Marker colour                      |
| `--marker-thickness`         | —            | Marker thickness                   |
| `--marker-length`            | —            | Marker length                      |
| `--marker-offset`            | —            | Marker offset from dial edge       |
| `--marker-border-width`       | —            | Marker border width                |
| `--marker-border-color`       | —            | Marker border colour               |
| `--midpoint-color`            | —            | Midpoint colour (bipolar mode)     |
| `--midpoint-thickness`        | —            | Midpoint thickness                 |
| `--midpoint-length`           | —            | Midpoint length                    |
| `--midpoint-offset`           | —            | Midpoint offset                    |
| `--lane-width`                | —            | Lane width                         |
| `--lane-color`                | —            | Lane colour                        |
| `--lane-border-width`          | —            | Lane border width                  |
| `--lane-offset`               | —            | Lane offset                        |
| `--lane-dasharray`            | —            | Lane dash array                    |
| `--wedge-fill`                | —            | Wedge fill colour                  |
| `--wedge-fill-opacity`        | —            | Wedge fill opacity                 |
| `--wedge-border-width`        | —            | Wedge border width                 |
| `--wedge-border-color`        | —            | Wedge border colour                |

## Examples

### Horizontal layout (wide container)

```html
<ixfx-labelled-radial-input
  id="my-dial"
  label="Mix"
  value="75"
  style="width: 200px; height: 80px;"
></ixfx-labelled-radial-input>
```

### Custom dial colours

```html
<ixfx-labelled-radial-input
  label="Intensity"
  value="70"
  style="
    --dial-fill: hsl(200 80% 40%);
    --marker-color: white;
  "
></ixfx-labelled-radial-input>
```

### Wedge mode

```html
<ixfx-labelled-radial-input
  label="Mix"
  value="50"
  wedge
  style="--wedge-fill: hsl(260 80% 50%);"
></ixfx-labelled-radial-input>
```

### Force mini mode

```html
<ixfx-labelled-radial-input label="Vol" value="50" style="--mini: 1">
</ixfx-labelled-radial-input>
```

### Listen for changes

```js
const el = document.querySelector('ixfx-labelled-radial-input');

// Committed value (dial release or number edit)
el.addEventListener('change', (e) => console.log(e.detail.value));

// Every dial interaction
el.addEventListener('input', (e) => console.log(e.detail.value));
```
