**DSI Units JS Library** is a JavaScript library for parsing, rendering, and interactively editing D‑SI unit strings.
This library is a mainly LMM-generated version of the corresponding [dsiunits](https://pypi.org/project/dsiunits/) Python package. (Repository: [digitaldynamicmeasurement/dsiUnits](https://gitlab1.ptb.de/digitaldynamicmeasurement/dsiUnits)).
The library includes two main components:
-**DSIUnit** – a class for parsing and rendering D‑SI unit strings.
-**DSIUnitInput** – a custom web component (`<dsi-unit-input>`) that provides an auto‑complete interactive input field for D‑SI units.
## License
This project is licensed under the [LGPL-2.1](../LICENSE) License.
## Installation
You will be able to install the library via npm in near future:
```bash
npm install dsi-units-js-lib
```
Or clone the repository and bundle the code with your preferred bundler (Webpack, Rollup, etc.).
As you type after a backslash (`\\`), suggestions are provided based on context:
- If a prefix is accepted (e.g., `\milli`), only allowed units are suggested.
- If a unit is accepted, all allowed tokens (including `\per` and `\tothe`) are suggested.
- Arrow keys navigate suggestions; Tab, Enter, or Right Arrow accept a suggestion.
-**Focus/Blur Behavior:**
When the field loses focus, the rendered unit (using `DSIUnit.toHTML({ oneLine: true })`) is shown. Clicking the rendered output restores the raw input for editing.
-**Customization:**
Override the allowed tokens by setting the `suggestions-list` attribute with a comma‑separated list.
#### Properties
-**value**
Returns the current raw D‑SI unit string.
-**live**
A boolean property (default: `true`) to enable/disable live updating.