@c2n/rate 0.0.9

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Nguyen Thai Vinh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # @c2n/rate
2
+
3
+ `<c2-rate>` is an accessible, form-associated star rating input with pointer preview, keyboard control and optional half-star values.
4
+
5
+ ```bash
6
+ npm install @c2n/rate
7
+ ```
8
+
9
+ ```html
10
+ <c2-rate name="score" aria-label="Product rating" value="3.5" allow-half required></c2-rate>
11
+ ```
12
+
13
+ ```js
14
+ import '@c2n/rate'
15
+
16
+ document.querySelector('c2-rate').addEventListener('rate-change', (event) => {
17
+ console.log(event.detail.value)
18
+ })
19
+ ```
20
+
21
+ Use `readonly` to display a score without interaction, `disabled` to exclude it from form submission, and `clearable` to let users reset the rating by selecting the current value again.
package/dist/rate.js ADDED
@@ -0,0 +1,244 @@
1
+ import { LitElement, html, unsafeCSS } from "lit";
2
+ import { property, state } from "lit/decorators.js";
3
+ import { styleMap } from "lit/directives/style-map.js";
4
+ import { customElement } from "@c2n/core/element-helper.js";
5
+ //#region src/rate.scss?inline
6
+ var rate_default = "/* ex : var((width: 24px), width, c2-checkbox) returns var(--c2-checkbox-width, 24px) */\n:host {\n display: inline-flex;\n vertical-align: middle;\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.rate {\n display: inline-flex;\n align-items: center;\n gap: var(--c2-rate__container--gap,4px);\n border-radius: var(--c2-rate__container--border-radius,4px);\n cursor: pointer;\n touch-action: manipulation;\n}\n.rate:focus-visible {\n outline: var(--c2-rate__container__focus--outline,2px solid rgba(2, 101, 220, 0.4));\n outline-offset: var(--c2-rate__container__focus--outline-offset,3px);\n}\n\n.item {\n position: relative;\n display: inline-flex;\n width: var(--c2-rate__icon--size,24px);\n height: var(--c2-rate__icon--size,24px);\n flex: none;\n transition: transform var(--c2-rate__icon--transition-duration,150ms) ease;\n}\n.item:hover {\n transform: scale(var(--c2-rate__icon__hover--scale,1.12));\n}\n\n.star {\n display: block;\n width: var(--c2-rate__icon--size,24px);\n height: var(--c2-rate__icon--size,24px);\n fill: currentColor;\n}\n\n.star--empty {\n color: var(--c2-rate__icon--color,#e4e4e7);\n}\n\n.fill {\n position: absolute;\n inset: 0 auto 0 0;\n display: block;\n overflow: hidden;\n color: var(--c2-rate__icon__filled--color,#facc15);\n transition: width var(--c2-rate__icon--transition-duration,150ms) ease;\n}\n\n.item--preview .fill {\n color: var(--c2-rate__icon__preview--color,#fbbf24);\n}\n\n:host([readonly]) .rate {\n cursor: default;\n}\n\n:host([readonly]) .item:hover {\n transform: none;\n}\n\n:host([disabled]) .rate {\n cursor: default;\n opacity: var(--c2-rate__container__disabled--opacity,0.38);\n}\n\n:host([disabled]) .item:hover {\n transform: none;\n}";
7
+ //#endregion
8
+ //#region \0@oxc-project+runtime@0.148.0/helpers/esm/decorate.js
9
+ function __decorate(decorators, target, key, desc) {
10
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
14
+ }
15
+ //#endregion
16
+ //#region src/rate.ts
17
+ var Rate = class Rate extends LitElement {
18
+ constructor(..._args) {
19
+ super(..._args);
20
+ this.internals = this.attachInternals();
21
+ this.defaultValue = 0;
22
+ this.defaultValueCaptured = false;
23
+ this.customValidityMessage = "";
24
+ this.previewValue = null;
25
+ this.disabledByForm = false;
26
+ this.value = 0;
27
+ this.max = 5;
28
+ this.allowHalf = false;
29
+ this.clearable = false;
30
+ this.readonly = false;
31
+ this.disabled = false;
32
+ this.required = false;
33
+ this.name = "";
34
+ this.ariaLabel = null;
35
+ }
36
+ static {
37
+ this.formAssociated = true;
38
+ }
39
+ static {
40
+ this.styles = unsafeCSS(rate_default);
41
+ }
42
+ static {
43
+ this.shadowRootOptions = {
44
+ ...LitElement.shadowRootOptions,
45
+ delegatesFocus: true
46
+ };
47
+ }
48
+ get form() {
49
+ return this.internals.form;
50
+ }
51
+ get labels() {
52
+ return this.internals.labels;
53
+ }
54
+ get validity() {
55
+ return this.internals.validity;
56
+ }
57
+ get validationMessage() {
58
+ return this.internals.validationMessage;
59
+ }
60
+ get willValidate() {
61
+ return this.internals.willValidate;
62
+ }
63
+ connectedCallback() {
64
+ super.connectedCallback();
65
+ if (!this.defaultValueCaptured) {
66
+ this.defaultValue = this.normalizeValue(Number(this.getAttribute("value") ?? 0));
67
+ this.defaultValueCaptured = true;
68
+ }
69
+ }
70
+ formResetCallback() {
71
+ this.value = this.defaultValue;
72
+ }
73
+ formDisabledCallback(disabled) {
74
+ this.disabledByForm = disabled && !this.hasAttribute("disabled");
75
+ }
76
+ formStateRestoreCallback(state) {
77
+ if (typeof state === "string") this.value = this.normalizeValue(Number(state));
78
+ }
79
+ checkValidity() {
80
+ return this.internals.checkValidity();
81
+ }
82
+ reportValidity() {
83
+ return this.internals.reportValidity();
84
+ }
85
+ setCustomValidity(message) {
86
+ this.customValidityMessage = message;
87
+ this.syncFormState();
88
+ }
89
+ willUpdate(changed) {
90
+ if (changed.has("max")) {
91
+ const max = Number.isFinite(this.max) ? Math.max(1, Math.floor(this.max)) : 5;
92
+ if (max !== this.max) this.max = max;
93
+ }
94
+ if (changed.has("value") || changed.has("max") || changed.has("allowHalf")) {
95
+ const value = this.normalizeValue(this.value);
96
+ if (value !== this.value) this.value = value;
97
+ }
98
+ }
99
+ updated(_changed) {
100
+ this.syncFormState();
101
+ }
102
+ get effectiveDisabled() {
103
+ return this.disabled || this.disabledByForm;
104
+ }
105
+ get step() {
106
+ return this.allowHalf ? .5 : 1;
107
+ }
108
+ normalizeValue(value) {
109
+ if (!Number.isFinite(value)) return 0;
110
+ const max = Number.isFinite(this.max) ? Math.max(1, Math.floor(this.max)) : 5;
111
+ return Math.min(max, Math.max(0, Math.round(value / this.step) * this.step));
112
+ }
113
+ valueFromPointer(event, index) {
114
+ if (!this.allowHalf) return index + 1;
115
+ const bounds = event.currentTarget.getBoundingClientRect();
116
+ return index + (event.clientX - bounds.left <= bounds.width / 2 ? .5 : 1);
117
+ }
118
+ handlePointerMove(event, index) {
119
+ if (this.readonly || this.effectiveDisabled) return;
120
+ this.previewValue = this.valueFromPointer(event, index);
121
+ }
122
+ handleClick(event, index) {
123
+ if (this.readonly || this.effectiveDisabled) return;
124
+ const next = this.valueFromPointer(event, index);
125
+ this.commit(this.clearable && next === this.value ? 0 : next);
126
+ }
127
+ handleKeydown(event) {
128
+ if (this.readonly || this.effectiveDisabled) return;
129
+ let next;
130
+ if (event.key === "ArrowRight" || event.key === "ArrowUp") next = this.value + this.step;
131
+ if (event.key === "ArrowLeft" || event.key === "ArrowDown") next = this.value - this.step;
132
+ if (event.key === "Home") next = 0;
133
+ if (event.key === "End") next = this.max;
134
+ if (next === void 0) return;
135
+ event.preventDefault();
136
+ this.commit(next);
137
+ }
138
+ commit(value) {
139
+ const next = this.normalizeValue(value);
140
+ if (next === this.value) return;
141
+ this.value = next;
142
+ this.previewValue = null;
143
+ this.dispatchEvent(new CustomEvent("rate-change", {
144
+ detail: { value: next },
145
+ bubbles: true,
146
+ composed: true
147
+ }));
148
+ this.dispatchEvent(new Event("input", {
149
+ bubbles: true,
150
+ composed: true
151
+ }));
152
+ this.dispatchEvent(new Event("change", {
153
+ bubbles: true,
154
+ composed: true
155
+ }));
156
+ }
157
+ syncFormState() {
158
+ const serialized = String(this.value);
159
+ this.internals.setFormValue(this.effectiveDisabled ? null : serialized, serialized);
160
+ const missing = this.required && this.value === 0;
161
+ const flags = this.customValidityMessage ? { customError: true } : missing ? { valueMissing: true } : {};
162
+ const message = this.customValidityMessage || (missing ? "Please choose a rating." : "");
163
+ this.internals.setValidity(flags, message, this.renderRoot.querySelector(".rate"));
164
+ }
165
+ fillFor(index) {
166
+ const value = this.previewValue ?? this.value;
167
+ return Math.max(0, Math.min(1, value - index)) * 100;
168
+ }
169
+ renderStar(className) {
170
+ return html`<svg class=${className} viewBox="0 0 24 24" aria-hidden="true">
171
+ <path d="m12 2.8 2.82 5.72 6.31.92-4.57 4.45 1.08 6.29L12 17.21l-5.64 2.97 1.08-6.29-4.57-4.45 6.31-.92L12 2.8Z"></path>
172
+ </svg>`;
173
+ }
174
+ render() {
175
+ const previewing = this.previewValue !== null;
176
+ return html`
177
+ <div
178
+ class="rate"
179
+ role="slider"
180
+ tabindex=${this.readonly || this.effectiveDisabled ? -1 : 0}
181
+ aria-label=${this.ariaLabel || "Rating"}
182
+ aria-valuemin="0"
183
+ aria-valuemax=${this.max}
184
+ aria-valuenow=${this.value}
185
+ aria-valuetext=${`${this.value} out of ${this.max}`}
186
+ aria-disabled=${this.effectiveDisabled ? "true" : "false"}
187
+ aria-readonly=${this.readonly ? "true" : "false"}
188
+ @keydown=${this.handleKeydown}
189
+ @pointerleave=${() => this.previewValue = null}
190
+ >
191
+ ${Array.from({ length: this.max }, (_, index) => {
192
+ const fill = this.fillFor(index);
193
+ return html`
194
+ <span
195
+ class="item ${previewing ? "item--preview" : ""}"
196
+ data-index=${index}
197
+ @pointermove=${(event) => this.handlePointerMove(event, index)}
198
+ @click=${(event) => this.handleClick(event, index)}
199
+ >
200
+ ${this.renderStar("star star--empty")}
201
+ <span class="fill" style=${styleMap({ width: `${fill}%` })}>${this.renderStar("star star--filled")}</span>
202
+ </span>
203
+ `;
204
+ })}
205
+ </div>
206
+ `;
207
+ }
208
+ };
209
+ __decorate([state()], Rate.prototype, "previewValue", void 0);
210
+ __decorate([state()], Rate.prototype, "disabledByForm", void 0);
211
+ __decorate([property({
212
+ type: Number,
213
+ reflect: true
214
+ })], Rate.prototype, "value", void 0);
215
+ __decorate([property({
216
+ type: Number,
217
+ reflect: true
218
+ })], Rate.prototype, "max", void 0);
219
+ __decorate([property({
220
+ type: Boolean,
221
+ attribute: "allow-half",
222
+ reflect: true
223
+ })], Rate.prototype, "allowHalf", void 0);
224
+ __decorate([property({
225
+ type: Boolean,
226
+ reflect: true
227
+ })], Rate.prototype, "clearable", void 0);
228
+ __decorate([property({
229
+ type: Boolean,
230
+ reflect: true
231
+ })], Rate.prototype, "readonly", void 0);
232
+ __decorate([property({
233
+ type: Boolean,
234
+ reflect: true
235
+ })], Rate.prototype, "disabled", void 0);
236
+ __decorate([property({
237
+ type: Boolean,
238
+ reflect: true
239
+ })], Rate.prototype, "required", void 0);
240
+ __decorate([property({ type: String })], Rate.prototype, "name", void 0);
241
+ __decorate([property({ attribute: "aria-label" })], Rate.prototype, "ariaLabel", void 0);
242
+ Rate = __decorate([customElement("c2-rate")], Rate);
243
+ //#endregion
244
+ export { Rate };
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@c2n/rate",
3
+ "version": "0.0.9",
4
+ "type": "module",
5
+ "main": "dist/rate.js",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./types/src/rate.d.ts",
9
+ "default": "./dist/rate.js"
10
+ },
11
+ "./react": {
12
+ "types": "./react.d.ts",
13
+ "default": "./react.js"
14
+ },
15
+ "./vue": {
16
+ "types": "./vue.d.ts",
17
+ "default": "./vue.js"
18
+ },
19
+ "./custom-elements.json": "./custom-elements.json"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "types",
24
+ "react.d.ts",
25
+ "react.js",
26
+ "vue.d.ts",
27
+ "vue.js"
28
+ ],
29
+ "keywords": [
30
+ "rate",
31
+ "web component",
32
+ "lit"
33
+ ],
34
+ "license": "MIT",
35
+ "author": "code2nguyen@gmail.com",
36
+ "publishConfig": {
37
+ "registry": "https://registry.npmjs.org",
38
+ "access": "public"
39
+ },
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "https://github.com/code2nguyen/web-components.git"
43
+ },
44
+ "scripts": {
45
+ "dev": "vite",
46
+ "build": "wireit",
47
+ "build:only": "vite build",
48
+ "type-check": "wireit"
49
+ },
50
+ "wireit": {
51
+ "type-check": {
52
+ "dependencies": [
53
+ "../../core:build"
54
+ ],
55
+ "command": "tsc -p tsconfig.lib.json --composite false"
56
+ },
57
+ "build": {
58
+ "dependencies": [
59
+ "type-check"
60
+ ],
61
+ "command": "vite build"
62
+ }
63
+ },
64
+ "dependencies": {
65
+ "@c2n/core": "0.0.9",
66
+ "lit": "3.3.3"
67
+ },
68
+ "devDependencies": {
69
+ "@c2n/config": "*"
70
+ },
71
+ "customElements": "custom-elements.json",
72
+ "gitHead": "e4768cce5e0fbd5bc3165cd493a1e8d57cf0fff4"
73
+ }
package/react.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ // GENERATED by @c2n/framework-types. Do not edit by hand.
2
+ //
3
+ // JSX types for the custom elements of @c2n/rate. Import once, anywhere in the program:
4
+ //
5
+ // import '@c2n/rate/react'
6
+ //
7
+ // Register the elements at module scope before React renders, or React writes an object prop as an
8
+ // attribute and it stringifies.
9
+
10
+ import type { DetailedHTMLProps, HTMLAttributes } from 'react'
11
+ import type { Rate } from '@c2n/rate'
12
+
13
+ /** Standard React host-element attributes plus the element's own public properties. */
14
+ type C2Props<T> = DetailedHTMLProps<HTMLAttributes<T>, T> & Partial<Omit<T, keyof HTMLElement>>
15
+
16
+ declare module 'react' {
17
+ namespace JSX {
18
+ interface IntrinsicElements {
19
+ 'c2-rate': C2Props<Rate>
20
+ }
21
+ }
22
+ }
23
+
24
+ export {}
package/react.js ADDED
@@ -0,0 +1,3 @@
1
+ // GENERATED by @c2n/framework-types. Do not edit by hand.
2
+ // Types only — see the matching .d.ts.
3
+ export {}
@@ -0,0 +1,104 @@
1
+ import { LitElement, type PropertyValues } from 'lit';
2
+ import type { TypedAddEventListener, TypedRemoveEventListener } from '@c2n/core/event-helper.js';
3
+ export interface RateChangeEventDetail {
4
+ value: number;
5
+ }
6
+ /** Events fired by {@link Rate}, keyed for `addEventListener`. */
7
+ export interface RateEventMap {
8
+ 'rate-change': CustomEvent<RateChangeEventDetail>;
9
+ input: Event;
10
+ change: Event;
11
+ }
12
+ export interface Rate {
13
+ addEventListener: TypedAddEventListener<Rate, RateEventMap>;
14
+ removeEventListener: TypedRemoveEventListener<Rate, RateEventMap>;
15
+ }
16
+ /**
17
+ * Accessible star rating control with pointer preview, keyboard adjustment and optional half-star values.
18
+ *
19
+ * @tag c2-rate
20
+ *
21
+ * @event {CustomEvent<RateChangeEventDetail>} rate-change - Fired after the user commits a rating. `detail.value` is the new value.
22
+ * @event {Event} input - Fired with `rate-change` for form and framework bindings.
23
+ * @event {Event} change - Fired with `rate-change` after the value is committed.
24
+ *
25
+ * @cssproperty {pixel} [--c2-rate__icon--size=24px]
26
+ * @cssproperty {pixel} [--c2-rate__container--gap=4px]
27
+ * @cssproperty {color} [--c2-rate__icon--color=#e4e4e7]
28
+ * @cssproperty {color} [--c2-rate__icon__filled--color=#facc15]
29
+ * @cssproperty {color} [--c2-rate__icon__preview--color=#fbbf24]
30
+ * @cssproperty {number} [--c2-rate__icon__hover--scale=1.12]
31
+ * @cssproperty {duration} [--c2-rate__icon--transition-duration=150ms]
32
+ * @cssproperty {outline} [--c2-rate__container__focus--outline=2px solid rgba(2, 101, 220, 0.4)]
33
+ * @cssproperty {pixel} [--c2-rate__container__focus--outline-offset=3px]
34
+ * @cssproperty {border-radius} [--c2-rate__container--border-radius=4px]
35
+ * @cssproperty {opacity} [--c2-rate__container__disabled--opacity=0.38]
36
+ */
37
+ export declare class Rate extends LitElement {
38
+ static formAssociated: boolean;
39
+ static styles: import("lit").CSSResult;
40
+ static shadowRootOptions: {
41
+ delegatesFocus: boolean;
42
+ clonable?: boolean;
43
+ customElementRegistry?: CustomElementRegistry | null;
44
+ mode: ShadowRootMode;
45
+ serializable?: boolean;
46
+ slotAssignment?: SlotAssignmentMode;
47
+ };
48
+ private readonly internals;
49
+ private defaultValue;
50
+ private defaultValueCaptured;
51
+ private customValidityMessage;
52
+ private previewValue;
53
+ private disabledByForm;
54
+ /** Current rating and submitted form value. */
55
+ value: number;
56
+ /** Number of rating icons. */
57
+ max: number;
58
+ /** Allow values in half-star steps. */
59
+ allowHalf: boolean;
60
+ /** Clicking the committed rating again clears it to zero. */
61
+ clearable: boolean;
62
+ /** Prevents changes while keeping the rating visually available. */
63
+ readonly: boolean;
64
+ /** Disables interaction and form submission. */
65
+ disabled: boolean;
66
+ /** Requires a rating greater than zero for native form validation. */
67
+ required: boolean;
68
+ /** Name used when the rating participates in a form. */
69
+ name: string;
70
+ /** Accessible name of the rating control. */
71
+ ariaLabel: string | null;
72
+ get form(): HTMLFormElement | null;
73
+ get labels(): NodeList;
74
+ get validity(): ValidityState;
75
+ get validationMessage(): string;
76
+ get willValidate(): boolean;
77
+ connectedCallback(): void;
78
+ formResetCallback(): void;
79
+ formDisabledCallback(disabled: boolean): void;
80
+ formStateRestoreCallback(state: string | File | FormData | null): void;
81
+ checkValidity(): boolean;
82
+ reportValidity(): boolean;
83
+ setCustomValidity(message: string): void;
84
+ protected willUpdate(changed: PropertyValues<this>): void;
85
+ protected updated(_changed: PropertyValues<this>): void;
86
+ private get effectiveDisabled();
87
+ private get step();
88
+ private normalizeValue;
89
+ private valueFromPointer;
90
+ private handlePointerMove;
91
+ private handleClick;
92
+ private handleKeydown;
93
+ private commit;
94
+ private syncFormState;
95
+ private fillFor;
96
+ private renderStar;
97
+ render(): import("lit-html").TemplateResult<1>;
98
+ }
99
+ declare global {
100
+ interface HTMLElementTagNameMap {
101
+ 'c2-rate': Rate;
102
+ }
103
+ }
104
+ //# sourceMappingURL=rate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate.d.ts","sourceRoot":"","sources":["../../src/rate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAA;AAItE,OAAO,KAAK,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AAGhG,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAA;CACd;AAED,kEAAkE;AAClE,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,WAAW,CAAC,qBAAqB,CAAC,CAAA;IACjD,KAAK,EAAE,KAAK,CAAA;IACZ,MAAM,EAAE,KAAK,CAAA;CACd;AAED,MAAM,WAAW,IAAI;IACnB,gBAAgB,EAAE,qBAAqB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;IAC3D,mBAAmB,EAAE,wBAAwB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;CAClE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBACa,IAAK,SAAQ,UAAU;IAClC,MAAM,CAAC,cAAc,UAAO;IAE5B,OAAgB,MAAM,0BAAoB;IAC1C,OAAgB,iBAAiB;;;;;;;MAA4D;IAE7F,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyB;IACnD,OAAO,CAAC,YAAY,CAAI;IACxB,OAAO,CAAC,oBAAoB,CAAQ;IACpC,OAAO,CAAC,qBAAqB,CAAK;IACzB,OAAO,CAAC,YAAY,CAAsB;IAC1C,OAAO,CAAC,cAAc,CAAQ;IAEvC,+CAA+C;IACJ,KAAK,SAAI;IAEpD,8BAA8B;IACa,GAAG,SAAI;IAElD,uCAAuC;IAC8B,SAAS,UAAQ;IAEtF,6DAA6D;IACjB,SAAS,UAAQ;IAE7D,oEAAoE;IACxB,QAAQ,UAAQ;IAE5D,gDAAgD;IACJ,QAAQ,UAAQ;IAE5D,sEAAsE;IAC1B,QAAQ,UAAQ;IAE5D,wDAAwD;IAC5B,IAAI,SAAK;IAErC,6CAA6C;IACG,SAAS,EAAE,MAAM,GAAG,IAAI,CAAO;IAE/E,IAAI,IAAI,2BAEP;IAED,IAAI,MAAM,aAET;IAED,IAAI,QAAQ,kBAEX;IAED,IAAI,iBAAiB,WAEpB;IAED,IAAI,YAAY,YAEf;IAEQ,iBAAiB,IAAI,IAAI;IAQlC,iBAAiB,IAAI,IAAI;IAIzB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAI7C,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,GAAG,IAAI,GAAG,IAAI;IAItE,aAAa,IAAI,OAAO;IAIxB,cAAc,IAAI,OAAO;IAIzB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;cAKrB,UAAU,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;cAW/C,OAAO,CAAC,QAAQ,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAIhE,OAAO,KAAK,iBAAiB,GAE5B;IAED,OAAO,KAAK,IAAI,GAEf;IAED,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,MAAM;IAUd,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,OAAO;IAKf,OAAO,CAAC,UAAU;IAMT,MAAM;CAkChB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,SAAS,EAAE,IAAI,CAAA;KAChB;CACF"}
package/vue.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ // GENERATED by @c2n/framework-types. Do not edit by hand.
2
+ //
3
+ // Vue template types for the custom elements of @c2n/rate. Import once, anywhere in the program:
4
+ //
5
+ // import '@c2n/rate/vue'
6
+ //
7
+ // Tell the compiler about the tags as well, or every c2-* tag is resolved as a Vue component and renders
8
+ // nothing: template.compilerOptions.isCustomElement = (tag) => tag.startsWith('c2-') in vite.config.ts.
9
+
10
+ import type { DefineComponent, HTMLAttributes } from 'vue'
11
+ import type { Rate, RateEventMap } from '@c2n/rate'
12
+
13
+ /** The element's own public properties, plus every attribute Vue understands on a host element. */
14
+ type C2Props<T> = Partial<Omit<T, keyof HTMLElement>> & HTMLAttributes
15
+
16
+ declare module 'vue' {
17
+ interface GlobalComponents {
18
+ 'c2-rate': DefineComponent<
19
+ C2Props<Rate> & {
20
+ 'allow-half'?: unknown
21
+ 'aria-label'?: unknown
22
+ onRateChange?: (event: RateEventMap['rate-change']) => void
23
+ onInput?: (event: RateEventMap['input']) => void
24
+ onChange?: (event: RateEventMap['change']) => void
25
+ }
26
+ >
27
+ }
28
+ }
29
+
30
+ declare module '@vue/runtime-dom' {
31
+ interface HTMLAttributes {
32
+ /** Vue's own definition omits it, and slotting a plain element into a component needs it. */
33
+ slot?: string
34
+ }
35
+ }
36
+
37
+ export {}
package/vue.js ADDED
@@ -0,0 +1,3 @@
1
+ // GENERATED by @c2n/framework-types. Do not edit by hand.
2
+ // Types only — see the matching .d.ts.
3
+ export {}