@lemonadejs/rating 2.0.1 → 2.3.0
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.
- package/README.md +169 -95
- package/dist/index.d.ts +28 -28
- package/dist/index.js +116 -110
- package/dist/react.d.ts +18 -15
- package/dist/react.js +35 -35
- package/dist/vue.d.ts +15 -15
- package/dist/vue.js +46 -46
- package/package.json +23 -23
package/README.md
CHANGED
|
@@ -1,95 +1,169 @@
|
|
|
1
|
-
# LemonadeJS Rating
|
|
2
|
-
|
|
3
|
-
[Official website and documentation is here](https://lemonadejs.net/components/rating)
|
|
4
|
-
|
|
5
|
-
Compatible with Vanilla JavaScript, LemonadeJS, React, Vue or Angular.
|
|
6
|
-
|
|
7
|
-
The LemonadeJS star rating plugin is a micro JavaScript component that implements the five star rating.
|
|
8
|
-
|
|
9
|
-
## Features
|
|
10
|
-
|
|
11
|
-
- Lightweight: The JavaScript rating is only about 2 KBytes;
|
|
12
|
-
- Integration: It can be used as a standalone library or integrated with any modern framework;
|
|
13
|
-
|
|
14
|
-
## Getting Started
|
|
15
|
-
|
|
16
|
-
You can install using NPM or using directly from a CDN.
|
|
17
|
-
|
|
18
|
-
### npm Installation
|
|
19
|
-
|
|
20
|
-
To install it in your project using npm, run the following command:
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
$ npm install @lemonadejs/rating
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
### CDN
|
|
27
|
-
|
|
28
|
-
To use rating via a CDN, include the following script tags in your HTML file:
|
|
29
|
-
|
|
30
|
-
```html
|
|
31
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lemonadejs/dist/lemonade.min.js"></script>
|
|
32
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@lemonadejs/rating/dist/index.min.js"></script>
|
|
33
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@lemonadejs/rating/dist/style.min.css" />
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Usage
|
|
37
|
-
|
|
38
|
-
Quick example with Lemonade
|
|
39
|
-
|
|
40
|
-
```javascript
|
|
41
|
-
// For installation: % npm install @lemonadejs/rating
|
|
42
|
-
// Add to your HTML: <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
|
43
|
-
import lemonade from "lemonadejs";
|
|
44
|
-
import Rating from "@lemonadejs/rating";
|
|
45
|
-
|
|
46
|
-
export default function Component() {
|
|
47
|
-
const self = this;
|
|
48
|
-
|
|
49
|
-
self.plus = () => {
|
|
50
|
-
self.number++;
|
|
51
|
-
}
|
|
52
|
-
self.minus = () => {
|
|
53
|
-
self.number--;
|
|
54
|
-
}
|
|
55
|
-
self.reset = () => {
|
|
56
|
-
self.value = 1;
|
|
57
|
-
}
|
|
58
|
-
self.change = (newValue) => {
|
|
59
|
-
console.log('New value', newValue);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
self.number = 5;
|
|
63
|
-
self.value = 3;
|
|
64
|
-
|
|
65
|
-
return `<div>
|
|
66
|
-
<p><Rating :value="self.value" :number="self.number" onchange="self.change" /></p>
|
|
67
|
-
<input type="button" value="Value=1" onclick="self.reset" />
|
|
68
|
-
<input type="button" value="Add star" onclick="self.plus" />
|
|
69
|
-
<input type="button" value="Remove star" onclick="self.minus" />
|
|
70
|
-
</div>`;
|
|
71
|
-
}
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
1
|
+
# LemonadeJS Rating
|
|
2
|
+
|
|
3
|
+
[Official website and documentation is here](https://lemonadejs.net/components/rating)
|
|
4
|
+
|
|
5
|
+
Compatible with Vanilla JavaScript, LemonadeJS, React, Vue or Angular.
|
|
6
|
+
|
|
7
|
+
The LemonadeJS star rating plugin is a micro JavaScript component that implements the five star rating.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Lightweight: The JavaScript rating is only about 2 KBytes;
|
|
12
|
+
- Integration: It can be used as a standalone library or integrated with any modern framework;
|
|
13
|
+
|
|
14
|
+
## Getting Started
|
|
15
|
+
|
|
16
|
+
You can install using NPM or using directly from a CDN.
|
|
17
|
+
|
|
18
|
+
### npm Installation
|
|
19
|
+
|
|
20
|
+
To install it in your project using npm, run the following command:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
$ npm install @lemonadejs/rating
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### CDN
|
|
27
|
+
|
|
28
|
+
To use rating via a CDN, include the following script tags in your HTML file:
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lemonadejs/dist/lemonade.min.js"></script>
|
|
32
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@lemonadejs/rating/dist/index.min.js"></script>
|
|
33
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@lemonadejs/rating/dist/style.min.css" />
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Usage
|
|
37
|
+
|
|
38
|
+
Quick example with Lemonade
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
// For installation: % npm install @lemonadejs/rating
|
|
42
|
+
// Add to your HTML: <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
|
43
|
+
import lemonade from "lemonadejs";
|
|
44
|
+
import Rating from "@lemonadejs/rating";
|
|
45
|
+
|
|
46
|
+
export default function Component() {
|
|
47
|
+
const self = this;
|
|
48
|
+
|
|
49
|
+
self.plus = () => {
|
|
50
|
+
self.number++;
|
|
51
|
+
}
|
|
52
|
+
self.minus = () => {
|
|
53
|
+
self.number--;
|
|
54
|
+
}
|
|
55
|
+
self.reset = () => {
|
|
56
|
+
self.value = 1;
|
|
57
|
+
}
|
|
58
|
+
self.change = (newValue) => {
|
|
59
|
+
console.log('New value', newValue);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
self.number = 5;
|
|
63
|
+
self.value = 3;
|
|
64
|
+
|
|
65
|
+
return `<div>
|
|
66
|
+
<p><Rating :value="self.value" :number="self.number" onchange="self.change" /></p>
|
|
67
|
+
<input type="button" value="Value=1" onclick="self.reset" />
|
|
68
|
+
<input type="button" value="Add star" onclick="self.plus" />
|
|
69
|
+
<input type="button" value="Remove star" onclick="self.minus" />
|
|
70
|
+
</div>`;
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Quick example with React
|
|
75
|
+
|
|
76
|
+
```jsx
|
|
77
|
+
import React, { useRef, useState } from "react";
|
|
78
|
+
import Rating from "@lemonadejs/rating/dist/react";
|
|
79
|
+
|
|
80
|
+
export default function App() {
|
|
81
|
+
const ratingRef = useRef();
|
|
82
|
+
const [number, setNumber] = useState(5);
|
|
83
|
+
const [value, setValue] = useState(3);
|
|
84
|
+
|
|
85
|
+
const plus = () => {
|
|
86
|
+
setNumber(number+1)
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const minus = () => {
|
|
90
|
+
setNumber(number-1)
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const reset = () => {
|
|
94
|
+
setValue(1);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const change = (newValue) => {
|
|
98
|
+
console.log('New value', newValue);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<>
|
|
103
|
+
<Rating value={value} number={number} onchange={change} ref={ratingRef} />
|
|
104
|
+
<input type="button" value="Value=1" onClick={reset} />
|
|
105
|
+
<input type="button" value="Add star" onClick={plus} />
|
|
106
|
+
<input type="button" value="Remove star" onClick={minus} />
|
|
107
|
+
</>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Quick example with React
|
|
113
|
+
|
|
114
|
+
```vue
|
|
115
|
+
<template>
|
|
116
|
+
<Rating :value="1" :number="5" :onchange="handleChange" ref="component" />
|
|
117
|
+
<button @click="reset">Value=1</button>
|
|
118
|
+
<button @click="plus">Add Star</button>
|
|
119
|
+
<button @click="minus">Remove Star</button>
|
|
120
|
+
</template>
|
|
121
|
+
|
|
122
|
+
<script>
|
|
123
|
+
import Rating from '@lemonadejs/rating/dist/vue';
|
|
124
|
+
|
|
125
|
+
export default {
|
|
126
|
+
name: 'App',
|
|
127
|
+
components: {
|
|
128
|
+
Rating,
|
|
129
|
+
},
|
|
130
|
+
methods: {
|
|
131
|
+
reset: function () {
|
|
132
|
+
this.$refs.component.current.value = 1;
|
|
133
|
+
},
|
|
134
|
+
plus: function () {
|
|
135
|
+
this.$refs.component.current.number++;
|
|
136
|
+
},
|
|
137
|
+
minus: function () {
|
|
138
|
+
this.$refs.component.current.number--;
|
|
139
|
+
},
|
|
140
|
+
handleChange: function (v) {
|
|
141
|
+
console.log('New value: ', v)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
</script>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Attributes
|
|
149
|
+
|
|
150
|
+
| Attribute | Type | Description |
|
|
151
|
+
| --- | --- | --- |
|
|
152
|
+
| name? | String | The name of the component |
|
|
153
|
+
| number? | Number | The number of stars. Default 5. |
|
|
154
|
+
| value? | Number | The initial value. Default null. |
|
|
155
|
+
|
|
156
|
+
### Events
|
|
157
|
+
|
|
158
|
+
| Attribute | Description |
|
|
159
|
+
| --- | --- |
|
|
160
|
+
| onchange? | When the value of the component changes. |
|
|
161
|
+
|
|
162
|
+
## License
|
|
163
|
+
|
|
164
|
+
The [LemonadeJS](https://lemonadejs.net) LemonadeJS Rating is released under the MIT.
|
|
165
|
+
|
|
166
|
+
## Other Tools
|
|
167
|
+
|
|
168
|
+
- [jSuites Plugins](https://jsuites.net/docs)
|
|
169
|
+
- [Jspreadsheet Data Grid](https://jspreadsheet.com)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Official Type definitions for LemonadeJS plugins
|
|
3
|
-
* https://lemonadejs.net
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
declare function Rating(el: HTMLElement, options?: Rating.Options): Rating.Instance;
|
|
7
|
-
|
|
8
|
-
declare namespace Rating {
|
|
9
|
-
|
|
10
|
-
interface Options {
|
|
11
|
-
/** Number of stars */
|
|
12
|
-
number?: number;
|
|
13
|
-
/** Form element name */
|
|
14
|
-
name?: string;
|
|
15
|
-
/** Current value */
|
|
16
|
-
value?: number;
|
|
17
|
-
/** Onchange Event */
|
|
18
|
-
onchange?: (newValue: number) => void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface Instance {
|
|
22
|
-
/** Number of stars */
|
|
23
|
-
number: number;
|
|
24
|
-
/** Current value */
|
|
25
|
-
value: number;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Official Type definitions for LemonadeJS plugins
|
|
3
|
+
* https://lemonadejs.net
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
declare function Rating(el: HTMLElement, options?: Rating.Options): Rating.Instance;
|
|
7
|
+
|
|
8
|
+
declare namespace Rating {
|
|
9
|
+
|
|
10
|
+
interface Options {
|
|
11
|
+
/** Number of stars */
|
|
12
|
+
number?: number;
|
|
13
|
+
/** Form element name */
|
|
14
|
+
name?: string;
|
|
15
|
+
/** Current value */
|
|
16
|
+
value?: number;
|
|
17
|
+
/** Onchange Event */
|
|
18
|
+
onchange?: (newValue: number) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface Instance {
|
|
22
|
+
/** Number of stars */
|
|
23
|
+
number: number;
|
|
24
|
+
/** Current value */
|
|
25
|
+
value: number;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
29
|
export default Rating;
|
package/dist/index.js
CHANGED
|
@@ -1,111 +1,117 @@
|
|
|
1
|
-
if (!lemonade && typeof (require) === 'function') {
|
|
2
|
-
var lemonade = require('lemonadejs');
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
;(function (global, factory) {
|
|
6
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
7
|
-
typeof define === 'function' && define.amd ? define(factory) :
|
|
8
|
-
global.Rating = factory();
|
|
9
|
-
}(this, (function () {
|
|
10
|
-
|
|
11
|
-
const Rating = function() {
|
|
12
|
-
let self = this;
|
|
13
|
-
|
|
14
|
-
if (! self.number) {
|
|
15
|
-
self.number = 5;
|
|
16
|
-
}
|
|
17
|
-
self.stars = [];
|
|
18
|
-
|
|
19
|
-
// Event
|
|
20
|
-
let change = self.onchange;
|
|
21
|
-
|
|
22
|
-
// Current self star
|
|
23
|
-
let current = null;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Update the number of stars
|
|
27
|
-
*/
|
|
28
|
-
const len = function() {
|
|
29
|
-
// Remove stars
|
|
30
|
-
if (self.number < self.stars.length) {
|
|
31
|
-
self.stars.splice(self.number, self.stars.length);
|
|
32
|
-
if (self.value > self.number) {
|
|
33
|
-
self.value = self.number;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
// Add missing stars
|
|
37
|
-
for (let i = 0; i < self.number; i++) {
|
|
38
|
-
if (! self.stars[i]) {
|
|
39
|
-
self.stars[i] = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
self.value
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
1
|
+
if (!lemonade && typeof (require) === 'function') {
|
|
2
|
+
var lemonade = require('lemonadejs');
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
;(function (global, factory) {
|
|
6
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
7
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
8
|
+
global.Rating = factory();
|
|
9
|
+
}(this, (function () {
|
|
10
|
+
|
|
11
|
+
const Rating = function() {
|
|
12
|
+
let self = this;
|
|
13
|
+
|
|
14
|
+
if (! self.number) {
|
|
15
|
+
self.number = 5;
|
|
16
|
+
}
|
|
17
|
+
self.stars = [];
|
|
18
|
+
|
|
19
|
+
// Event
|
|
20
|
+
let change = self.onchange;
|
|
21
|
+
|
|
22
|
+
// Current self star
|
|
23
|
+
let current = null;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Update the number of stars
|
|
27
|
+
*/
|
|
28
|
+
const len = function() {
|
|
29
|
+
// Remove stars
|
|
30
|
+
if (self.number < self.stars.length) {
|
|
31
|
+
self.stars.splice(self.number, self.stars.length);
|
|
32
|
+
if (self.value > self.number) {
|
|
33
|
+
self.value = self.number;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Add missing stars
|
|
37
|
+
for (let i = 0; i < self.number; i++) {
|
|
38
|
+
if (! self.stars[i]) {
|
|
39
|
+
self.stars[i] = {
|
|
40
|
+
icon: 'star_outline',
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Refresh
|
|
45
|
+
self.refresh('stars');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const val = function() {
|
|
49
|
+
// Update value
|
|
50
|
+
if (self.value > 0) {
|
|
51
|
+
let t = self.stars[self.value-1];
|
|
52
|
+
if (t) {
|
|
53
|
+
self.click(null, t);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
self.onchange = function(prop) {
|
|
59
|
+
if (prop === 'number') {
|
|
60
|
+
len();
|
|
61
|
+
} else if (prop === 'value') {
|
|
62
|
+
val();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
self.onload = function() {
|
|
67
|
+
// Bind global method to be compatible with LemonadeJS forms
|
|
68
|
+
self.el.val = function(v) {
|
|
69
|
+
if (typeof(v) === 'undefined') {
|
|
70
|
+
return self.value;
|
|
71
|
+
} else {
|
|
72
|
+
self.value = v;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
len();
|
|
77
|
+
val();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
self.click = function(e, s) {
|
|
81
|
+
if (! s.selected) {
|
|
82
|
+
current = null;
|
|
83
|
+
}
|
|
84
|
+
let index = self.stars.indexOf(s);
|
|
85
|
+
for (let i = 0; i < self.number; i++) {
|
|
86
|
+
let selected = i <= index && s !== current ? 1 : 0;
|
|
87
|
+
self.stars[i].selected = selected;
|
|
88
|
+
self.stars[i].el.style.color = selected ? 'red' : '';
|
|
89
|
+
self.stars[i].icon = selected ? 'star' : 'star_outline';
|
|
90
|
+
}
|
|
91
|
+
current = s;
|
|
92
|
+
|
|
93
|
+
if (typeof(change) === 'function') {
|
|
94
|
+
change(index+1, s);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return `<div value="{{self.value}}" number="{{self.number}}" name="{{self.name}}" :loop="self.stars" :ref="self.component" style="cursor: pointer">
|
|
99
|
+
<i class="material-icons" onclick="self.parent.click">{{self.icon}}</i>
|
|
100
|
+
</div>`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Register the LemonadeJS Component
|
|
104
|
+
lemonade.setComponents({ Rating: Rating });
|
|
105
|
+
// Register the web component
|
|
106
|
+
lemonade.createWebComponent('rating', Rating);
|
|
107
|
+
|
|
108
|
+
return function (root, options) {
|
|
109
|
+
if (typeof (root) === 'object') {
|
|
110
|
+
lemonade.render(Rating, root, options)
|
|
111
|
+
return options;
|
|
112
|
+
} else {
|
|
113
|
+
return Rating.call(this, root)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
111
117
|
})));
|
package/dist/react.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Official Type definitions for the LemonadeJS plugins
|
|
3
|
-
* https://lemonadejs.net
|
|
4
|
-
* Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
5
|
-
*/
|
|
6
|
-
import Component from './index';
|
|
7
|
-
|
|
8
|
-
interface Rating {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Official Type definitions for the LemonadeJS plugins
|
|
3
|
+
* https://lemonadejs.net
|
|
4
|
+
* Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
5
|
+
*/
|
|
6
|
+
import Component from './index';
|
|
7
|
+
|
|
8
|
+
interface Rating {
|
|
9
|
+
ref?: MutableRefObject<undefined>;
|
|
10
|
+
(): any
|
|
11
|
+
[key: string]: any
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type Props = IntrinsicAttributes & Component.Options & Rating;
|
|
15
|
+
|
|
16
|
+
declare function Rating<Rating>(props: Props): any;
|
|
17
|
+
|
|
18
|
+
export default Rating;
|
package/dist/react.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import React, { useRef, useEffect } from "react";
|
|
2
|
-
import Component from './index';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export default React.forwardRef((props, mainReference) => {
|
|
6
|
-
// Dom element
|
|
7
|
-
const Ref = useRef(null);
|
|
8
|
-
|
|
9
|
-
// Get the properties for the spreadsheet
|
|
10
|
-
let options = { ...props };
|
|
11
|
-
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
if (!Ref.current.innerHTML) {
|
|
14
|
-
mainReference.current = Component(Ref.current, options);
|
|
15
|
-
}
|
|
16
|
-
}, []);
|
|
17
|
-
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
for (let key in props) {
|
|
20
|
-
if (key === 'onchange' || key === 'onload') {
|
|
21
|
-
continue
|
|
22
|
-
} else if (props.hasOwnProperty(key) && mainReference.current.hasOwnProperty(key)) {
|
|
23
|
-
if (props[key] !== mainReference.current[key]) {
|
|
24
|
-
mainReference.current[key] = props[key];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}, [props])
|
|
29
|
-
|
|
30
|
-
let prop = {
|
|
31
|
-
ref: Ref,
|
|
32
|
-
style: { height: '100%', width: '100%' }
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
return React.createElement("div", prop);
|
|
1
|
+
import React, { useRef, useEffect } from "react";
|
|
2
|
+
import Component from './index';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export default React.forwardRef((props, mainReference) => {
|
|
6
|
+
// Dom element
|
|
7
|
+
const Ref = useRef(null);
|
|
8
|
+
|
|
9
|
+
// Get the properties for the spreadsheet
|
|
10
|
+
let options = { ...props };
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!Ref.current.innerHTML) {
|
|
14
|
+
mainReference.current = Component(Ref.current, options);
|
|
15
|
+
}
|
|
16
|
+
}, []);
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
for (let key in props) {
|
|
20
|
+
if (key === 'onchange' || key === 'onload') {
|
|
21
|
+
continue
|
|
22
|
+
} else if (props.hasOwnProperty(key) && mainReference.current.hasOwnProperty(key)) {
|
|
23
|
+
if (props[key] !== mainReference.current[key]) {
|
|
24
|
+
mainReference.current[key] = props[key];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}, [props])
|
|
29
|
+
|
|
30
|
+
let prop = {
|
|
31
|
+
ref: Ref,
|
|
32
|
+
style: { height: '100%', width: '100%' }
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return React.createElement("div", prop);
|
|
36
36
|
})
|
package/dist/vue.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Official Type definitions for the LemonadeJS plugins
|
|
3
|
-
* https://lemonadejs.net
|
|
4
|
-
* Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
5
|
-
*/
|
|
6
|
-
import Component from './index';
|
|
7
|
-
|
|
8
|
-
interface Rating {
|
|
9
|
-
(): any
|
|
10
|
-
[key: string]: any
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
declare function Rating<Rating>(props: Component.Options): any;
|
|
14
|
-
|
|
15
|
-
export default Rating;
|
|
1
|
+
/**
|
|
2
|
+
* Official Type definitions for the LemonadeJS plugins
|
|
3
|
+
* https://lemonadejs.net
|
|
4
|
+
* Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
5
|
+
*/
|
|
6
|
+
import Component from './index';
|
|
7
|
+
|
|
8
|
+
interface Rating {
|
|
9
|
+
(): any
|
|
10
|
+
[key: string]: any
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare function Rating<Rating>(props: Component.Options): any;
|
|
14
|
+
|
|
15
|
+
export default Rating;
|
package/dist/vue.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { h } from 'vue';
|
|
2
|
-
import component from "./index";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const Rating = {
|
|
6
|
-
inheritAttrs: false,
|
|
7
|
-
mounted() {
|
|
8
|
-
let options = {
|
|
9
|
-
...this.$attrs
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
this.el = this.$refs.container;
|
|
13
|
-
|
|
14
|
-
this.current = component(this.$refs.container, options);
|
|
15
|
-
},
|
|
16
|
-
setup() {
|
|
17
|
-
let containerProps = {
|
|
18
|
-
ref: 'container',
|
|
19
|
-
style: {
|
|
20
|
-
width: '100%',
|
|
21
|
-
height: '100%',
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
return () => h('div', containerProps);
|
|
25
|
-
},
|
|
26
|
-
watch: {
|
|
27
|
-
$attrs: {
|
|
28
|
-
deep: true,
|
|
29
|
-
handler() {
|
|
30
|
-
this.updateState();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
methods: {
|
|
35
|
-
updateState() {
|
|
36
|
-
for (let key in this.$attrs) {
|
|
37
|
-
if (this.$attrs.hasOwnProperty(key) && this.current.hasOwnProperty(key)) {
|
|
38
|
-
if (this.$attrs[key] !== this.current[key]) {
|
|
39
|
-
this.current[key] = this.$attrs[key];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
1
|
+
import { h } from 'vue';
|
|
2
|
+
import component from "./index";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export const Rating = {
|
|
6
|
+
inheritAttrs: false,
|
|
7
|
+
mounted() {
|
|
8
|
+
let options = {
|
|
9
|
+
...this.$attrs
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
this.el = this.$refs.container;
|
|
13
|
+
|
|
14
|
+
this.current = component(this.$refs.container, options);
|
|
15
|
+
},
|
|
16
|
+
setup() {
|
|
17
|
+
let containerProps = {
|
|
18
|
+
ref: 'container',
|
|
19
|
+
style: {
|
|
20
|
+
width: '100%',
|
|
21
|
+
height: '100%',
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
return () => h('div', containerProps);
|
|
25
|
+
},
|
|
26
|
+
watch: {
|
|
27
|
+
$attrs: {
|
|
28
|
+
deep: true,
|
|
29
|
+
handler() {
|
|
30
|
+
this.updateState();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
methods: {
|
|
35
|
+
updateState() {
|
|
36
|
+
for (let key in this.$attrs) {
|
|
37
|
+
if (this.$attrs.hasOwnProperty(key) && this.current.hasOwnProperty(key)) {
|
|
38
|
+
if (this.$attrs[key] !== this.current[key]) {
|
|
39
|
+
this.current[key] = this.$attrs[key];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
47
|
export default Rating;
|
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@lemonadejs/rating",
|
|
3
|
-
"title": "LemonadeJS star rating javascript plugin",
|
|
4
|
-
"description": "LemonadeJS star rating plugin",
|
|
5
|
-
"author": {
|
|
6
|
-
"name": "Contact <contact@lemonadejs.net>",
|
|
7
|
-
"url": "https://lemonadejs.net"
|
|
8
|
-
},
|
|
9
|
-
"keywords": [
|
|
10
|
-
"javascript star rating",
|
|
11
|
-
"javascript rating",
|
|
12
|
-
"lemonadejs plugins",
|
|
13
|
-
"js",
|
|
14
|
-
"library",
|
|
15
|
-
"javascript plugins"
|
|
16
|
-
],
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"lemonadejs": "^4.
|
|
19
|
-
},
|
|
20
|
-
"main": "dist/index.js",
|
|
21
|
-
"types": "dist/index.d.ts",
|
|
22
|
-
"version": "2.0
|
|
23
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@lemonadejs/rating",
|
|
3
|
+
"title": "LemonadeJS star rating javascript plugin",
|
|
4
|
+
"description": "LemonadeJS star rating plugin",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Contact <contact@lemonadejs.net>",
|
|
7
|
+
"url": "https://lemonadejs.net"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"javascript star rating",
|
|
11
|
+
"javascript rating",
|
|
12
|
+
"lemonadejs plugins",
|
|
13
|
+
"js",
|
|
14
|
+
"library",
|
|
15
|
+
"javascript plugins"
|
|
16
|
+
],
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"lemonadejs": "^4.3.3"
|
|
19
|
+
},
|
|
20
|
+
"main": "dist/index.js",
|
|
21
|
+
"types": "dist/index.d.ts",
|
|
22
|
+
"version": "2.3.0"
|
|
23
|
+
}
|