v2.0.0
Full rewrite of @ernane/svelte-star-rating — TypeScript support, modern build tooling, tests, CI/CD, and an interactive playground.
Highlights
- TypeScript —
RatingConfig,StarConfig, andResolvedRatingConfigexported;.d.tsfiles shipped. Fixes #18 — "Cannot find module or its type declarations" @sveltejs/package— replaces the manual Rollup config;exportsnow includes the"types"condition so TypeScript resolves the package correctly- Partial config — all
RatingConfigfields are optional; omit what you don't need and sensible defaults kick in - Svelte 4 + 5 — peer dependency updated to
svelte >=4.0.0 on:inputforwarded — get real-time score updates while the user drags, not just on mouse-release- 23 unit tests — Vitest +
@testing-library/svelte, covering render, readOnly, scoreFormat, slider range, gradient fills, and aria attributes - GitHub Actions CI/CD — type-check + tests + build on every push/PR; automated npm publish on release; GitHub Pages deploy on push to
main - Interactive playground at ernanej.github.io/svelte-star-rating — built with Tailwind CSS v4; real-time preview with color pickers, range controls, live code snippet, and one-click copy
Breaking changes
| v1 | v2 | |
|---|---|---|
scoreFormat |
function() { return \(${this.score}/${this.countStars})`; }` |
(score, total) => \(${score}/${total})`` |
| Partial config | Full object required | All fields optional |
| Peer dependency | svelte ^3 |
svelte >=4.0.0 |
| Node.js | — | >=20.0.0 |
Installation
npm install @ernane/svelte-star-rating@2<script lang="ts">
import { StarRating } from '@ernane/svelte-star-rating';
import type { RatingConfig } from '@ernane/svelte-star-rating';
let config: RatingConfig = { score: 3.5, countStars: 5 };
</script>
<StarRating bind:config on:change={(e) => console.log(e.currentTarget.value)} />