@neovici/cosmoz-rating 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- import { CosmozRatingElement } from '../types';
2
- declare const useRating: (host: CosmozRatingElement) => {
1
+ import { Props } from '../types';
2
+ declare const useRating: (props: Props) => {
3
3
  rating: number | null;
4
- disabled: boolean;
4
+ disabled: boolean | undefined;
5
5
  maxRating: number;
6
6
  handleComponentLeave: () => void;
7
7
  renderStar: (index: number) => import("lit-html").TemplateResult<1>;
@@ -1,12 +1,14 @@
1
1
  import { useState, html, useEffect } from '@pionjs/pion';
2
2
  import { svg } from 'lit-html';
3
- const useRating = (host) => {
3
+ import { useHost } from '@neovici/cosmoz-utils/hooks/use-host';
4
+ const useRating = (props) => {
5
+ const host = useHost();
4
6
  const [hoveredRating, setHoveredRating] = useState(null);
5
- const ratingAttr = host.getAttribute('rating');
6
- const rating = ratingAttr ? parseFloat(ratingAttr) : null;
7
- const disabled = host.hasAttribute('disabled');
8
- const maxRatingAttr = host.getAttribute('max-rating');
9
- const maxRating = maxRatingAttr ? parseInt(maxRatingAttr, 10) : 5;
7
+ const ratingRaw = props.rating;
8
+ const rating = ratingRaw ? parseFloat(ratingRaw) : null;
9
+ const disabled = props.disabled;
10
+ const maxRatingRaw = props.maxRating;
11
+ const maxRating = maxRatingRaw ? parseInt(maxRatingRaw, 10) : 5;
10
12
  useEffect(() => {
11
13
  // Set appropriate tabIndex for accessibility
12
14
  if (!disabled && host.tabIndex === -1) {
package/dist/rating.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CosmozRatingElement } from './types';
2
- declare const CosmozRating: import("@pionjs/pion/lib/component").ComponentConstructor<CosmozRatingElement>;
1
+ import { Props } from './types';
2
+ declare const CosmozRating: import("@pionjs/pion/lib/component").ComponentConstructor<Props>;
3
3
  export { CosmozRating };
4
4
  export default CosmozRating;
package/dist/rating.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { component, html } from '@pionjs/pion';
2
2
  import useRating from './hooks/use-rating';
3
3
  import { styles } from './rating.css';
4
- const Rating = (host) => {
5
- const { maxRating, renderStar, handleComponentLeave } = useRating(host);
4
+ const Rating = (props) => {
5
+ const { maxRating, renderStar, handleComponentLeave } = useRating(props);
6
6
  return html `
7
7
  <div class="rating-container" @mouseleave=${handleComponentLeave}>
8
8
  ${Array.from({ length: maxRating }, (_, index) => renderStar(index))}
package/dist/types.d.ts CHANGED
@@ -3,10 +3,8 @@ export interface RatingEvent extends CustomEvent {
3
3
  rating: number;
4
4
  };
5
5
  }
6
- export interface CosmozRatingProps {
7
- rating?: number | null;
6
+ export interface Props {
7
+ rating?: string;
8
8
  disabled?: boolean;
9
- maxRating?: number;
10
- }
11
- export interface CosmozRatingElement extends HTMLElement, CosmozRatingProps {
9
+ maxRating?: string;
12
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-rating",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "A simple rating web component",
5
5
  "keywords": [
6
6
  "web-components",
@@ -9,13 +9,13 @@
9
9
  "pion",
10
10
  "lit-html"
11
11
  ],
12
- "homepage": "https://github.com/neovici/cosmoz-rating#readme",
12
+ "homepage": "https://github.com/Neovici/cosmoz-rating#readme",
13
13
  "bugs": {
14
- "url": "https://github.com/neovici/cosmoz-rating/issues"
14
+ "url": "https://github.com/Neovici/cosmoz-rating/issues"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
18
- "url": "git+https://github.com/neovici/cosmoz-rating.git"
18
+ "url": "git+https://github.com/Neovici/cosmoz-rating.git"
19
19
  },
20
20
  "license": "Apache-2.0",
21
21
  "author": "",
@@ -34,19 +34,8 @@
34
34
  "storybook:build": "storybook build",
35
35
  "storybook:deploy": "storybook-to-ghpages",
36
36
  "storybook:preview": "npm run storybook:build && http-server -d ./storybook-static/",
37
- "prepare": "husky"
38
- },
39
- "release": {
40
- "plugins": [
41
- "@semantic-release/commit-analyzer",
42
- "@semantic-release/release-notes-generator",
43
- "@semantic-release/changelog",
44
- "@semantic-release/github",
45
- "@semantic-release/npm",
46
- "@semantic-release/git"
47
- ],
48
- "branch": "master",
49
- "preset": "conventionalcommits"
37
+ "prepare": "husky",
38
+ "changeset": "changeset"
50
39
  },
51
40
  "publishConfig": {
52
41
  "access": "public"
@@ -59,31 +48,27 @@
59
48
  ".": "./dist/index.js"
60
49
  },
61
50
  "dependencies": {
51
+ "@neovici/cosmoz-utils": "^6.14.2",
62
52
  "@pionjs/pion": "^2.5.2",
63
53
  "lit-html": "^3.3.1"
64
54
  },
65
55
  "devDependencies": {
56
+ "@changesets/cli": "^2.27.0",
66
57
  "@commitlint/cli": "^19.2.1",
67
58
  "@commitlint/config-conventional": "^19.1.0",
68
59
  "@eslint/eslintrc": "^2.0.0",
69
60
  "@neovici/cfg": "^2.0.0",
70
61
  "@open-wc/testing": "^4.0.0",
71
- "@semantic-release/changelog": "^6.0.0",
72
- "@semantic-release/git": "^10.0.0",
73
- "@storybook/addon-essentials": "^7.0.0",
74
- "@storybook/addon-links": "^7.0.0",
75
- "@storybook/web-components": "7.6.17",
62
+ "@playwright/test": "1.60.0",
63
+ "@storybook/web-components-vite": "^9.1.5",
76
64
  "@types/mocha": "^10.0.6",
77
65
  "@types/node": "^22.10.2",
78
- "@web/storybook-builder": "^0.1.9",
79
- "@web/storybook-framework-web-components": "^0.1.1",
80
66
  "esbuild": "^0.24.0",
81
67
  "http-server": "^14.1.1",
82
68
  "husky": "^9.0.11",
83
69
  "rollup-plugin-esbuild": "^6.1.1",
84
- "semantic-release": "^24.0.0",
85
70
  "sinon": "^19.0.0",
86
- "storybook": "^7.0.0",
71
+ "storybook": "^9.1.5",
87
72
  "typescript": "^5.4.3"
88
73
  },
89
74
  "overrides": {