@codefluss/rive 0.0.1-alpha.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.
- package/README.md +74 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +5 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/locales/de.json +183 -0
- package/dist/locales/en.json +183 -0
- package/dist/locales/index.d.ts +374 -0
- package/dist/locales/index.d.ts.map +1 -0
- package/dist/locales/index.js +11 -0
- package/dist/locales/index.js.map +1 -0
- package/dist/renderer.d.ts +45 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/renderer.js +85 -0
- package/dist/renderer.js.map +1 -0
- package/dist/rive-component.d.ts +5 -0
- package/dist/rive-component.d.ts.map +1 -0
- package/dist/rive-component.js +137 -0
- package/dist/rive-component.js.map +1 -0
- package/dist/rive-config.d.ts +67 -0
- package/dist/rive-config.d.ts.map +1 -0
- package/dist/rive-config.js +264 -0
- package/dist/rive-config.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rive Plugin Localization
|
|
3
|
+
*/
|
|
4
|
+
export declare const locales: {
|
|
5
|
+
readonly en: {
|
|
6
|
+
plugin: {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
};
|
|
10
|
+
properties: {
|
|
11
|
+
src: {
|
|
12
|
+
label: string;
|
|
13
|
+
placeholder: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
artboard: {
|
|
17
|
+
label: string;
|
|
18
|
+
placeholder: string;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
stateMachines: {
|
|
22
|
+
label: string;
|
|
23
|
+
placeholder: string;
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
width: {
|
|
27
|
+
label: string;
|
|
28
|
+
placeholder: string;
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
height: {
|
|
32
|
+
label: string;
|
|
33
|
+
placeholder: string;
|
|
34
|
+
description: string;
|
|
35
|
+
};
|
|
36
|
+
fit: {
|
|
37
|
+
label: string;
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
alignment: {
|
|
41
|
+
label: string;
|
|
42
|
+
description: string;
|
|
43
|
+
};
|
|
44
|
+
loop: {
|
|
45
|
+
label: string;
|
|
46
|
+
description: string;
|
|
47
|
+
};
|
|
48
|
+
autoplay: {
|
|
49
|
+
label: string;
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
52
|
+
"mouseInteraction.enabled": {
|
|
53
|
+
label: string;
|
|
54
|
+
description: string;
|
|
55
|
+
};
|
|
56
|
+
"mouseInteraction.followMouse": {
|
|
57
|
+
label: string;
|
|
58
|
+
description: string;
|
|
59
|
+
};
|
|
60
|
+
"mouseInteraction.sensitivity": {
|
|
61
|
+
label: string;
|
|
62
|
+
placeholder: string;
|
|
63
|
+
description: string;
|
|
64
|
+
};
|
|
65
|
+
"mouseInteraction.hoverEffects": {
|
|
66
|
+
label: string;
|
|
67
|
+
description: string;
|
|
68
|
+
};
|
|
69
|
+
"mouseInteraction.clickActions": {
|
|
70
|
+
label: string;
|
|
71
|
+
description: string;
|
|
72
|
+
};
|
|
73
|
+
"stateMachineInputs.hover": {
|
|
74
|
+
label: string;
|
|
75
|
+
placeholder: string;
|
|
76
|
+
description: string;
|
|
77
|
+
};
|
|
78
|
+
"stateMachineInputs.click": {
|
|
79
|
+
label: string;
|
|
80
|
+
placeholder: string;
|
|
81
|
+
description: string;
|
|
82
|
+
};
|
|
83
|
+
"stateMachineInputs.mousePosition.x": {
|
|
84
|
+
label: string;
|
|
85
|
+
placeholder: string;
|
|
86
|
+
description: string;
|
|
87
|
+
};
|
|
88
|
+
"stateMachineInputs.mousePosition.y": {
|
|
89
|
+
label: string;
|
|
90
|
+
placeholder: string;
|
|
91
|
+
description: string;
|
|
92
|
+
};
|
|
93
|
+
"accessibility.label": {
|
|
94
|
+
label: string;
|
|
95
|
+
placeholder: string;
|
|
96
|
+
description: string;
|
|
97
|
+
};
|
|
98
|
+
"accessibility.description": {
|
|
99
|
+
label: string;
|
|
100
|
+
placeholder: string;
|
|
101
|
+
description: string;
|
|
102
|
+
};
|
|
103
|
+
"accessibility.role": {
|
|
104
|
+
label: string;
|
|
105
|
+
placeholder: string;
|
|
106
|
+
description: string;
|
|
107
|
+
};
|
|
108
|
+
"advanced.className": {
|
|
109
|
+
label: string;
|
|
110
|
+
placeholder: string;
|
|
111
|
+
description: string;
|
|
112
|
+
};
|
|
113
|
+
"advanced.id": {
|
|
114
|
+
label: string;
|
|
115
|
+
placeholder: string;
|
|
116
|
+
description: string;
|
|
117
|
+
};
|
|
118
|
+
"advanced.ariaLabel": {
|
|
119
|
+
label: string;
|
|
120
|
+
placeholder: string;
|
|
121
|
+
description: string;
|
|
122
|
+
};
|
|
123
|
+
"advanced.tabIndex": {
|
|
124
|
+
label: string;
|
|
125
|
+
placeholder: string;
|
|
126
|
+
description: string;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
categories: {
|
|
130
|
+
content: string;
|
|
131
|
+
style: string;
|
|
132
|
+
interactivity: string;
|
|
133
|
+
state: string;
|
|
134
|
+
advanced: string;
|
|
135
|
+
};
|
|
136
|
+
priorities: {
|
|
137
|
+
quick: string;
|
|
138
|
+
common: string;
|
|
139
|
+
advanced: string;
|
|
140
|
+
};
|
|
141
|
+
upload: {
|
|
142
|
+
title: string;
|
|
143
|
+
description: string;
|
|
144
|
+
button: string;
|
|
145
|
+
dragText: string;
|
|
146
|
+
supportedFormats: string;
|
|
147
|
+
invalidFormat: string;
|
|
148
|
+
fileTooLarge: string;
|
|
149
|
+
uploadSuccess: string;
|
|
150
|
+
uploadError: string;
|
|
151
|
+
fileReady: string;
|
|
152
|
+
loadedFile: string;
|
|
153
|
+
};
|
|
154
|
+
interactivity: {
|
|
155
|
+
enabled: string;
|
|
156
|
+
followMouse: string;
|
|
157
|
+
hoverEffects: string;
|
|
158
|
+
clickActions: string;
|
|
159
|
+
sensitivity: string;
|
|
160
|
+
stateMachines: string;
|
|
161
|
+
mousePosition: string;
|
|
162
|
+
};
|
|
163
|
+
controls: {
|
|
164
|
+
play: string;
|
|
165
|
+
pause: string;
|
|
166
|
+
stop: string;
|
|
167
|
+
};
|
|
168
|
+
fitModes: {
|
|
169
|
+
contain: string;
|
|
170
|
+
cover: string;
|
|
171
|
+
fill: string;
|
|
172
|
+
fitWidth: string;
|
|
173
|
+
fitHeight: string;
|
|
174
|
+
none: string;
|
|
175
|
+
};
|
|
176
|
+
alignments: {
|
|
177
|
+
center: string;
|
|
178
|
+
topLeft: string;
|
|
179
|
+
topCenter: string;
|
|
180
|
+
topRight: string;
|
|
181
|
+
centerLeft: string;
|
|
182
|
+
centerRight: string;
|
|
183
|
+
bottomLeft: string;
|
|
184
|
+
bottomCenter: string;
|
|
185
|
+
bottomRight: string;
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
readonly de: {
|
|
189
|
+
plugin: {
|
|
190
|
+
name: string;
|
|
191
|
+
description: string;
|
|
192
|
+
};
|
|
193
|
+
properties: {
|
|
194
|
+
src: {
|
|
195
|
+
label: string;
|
|
196
|
+
placeholder: string;
|
|
197
|
+
description: string;
|
|
198
|
+
};
|
|
199
|
+
artboard: {
|
|
200
|
+
label: string;
|
|
201
|
+
placeholder: string;
|
|
202
|
+
description: string;
|
|
203
|
+
};
|
|
204
|
+
stateMachines: {
|
|
205
|
+
label: string;
|
|
206
|
+
placeholder: string;
|
|
207
|
+
description: string;
|
|
208
|
+
};
|
|
209
|
+
width: {
|
|
210
|
+
label: string;
|
|
211
|
+
placeholder: string;
|
|
212
|
+
description: string;
|
|
213
|
+
};
|
|
214
|
+
height: {
|
|
215
|
+
label: string;
|
|
216
|
+
placeholder: string;
|
|
217
|
+
description: string;
|
|
218
|
+
};
|
|
219
|
+
fit: {
|
|
220
|
+
label: string;
|
|
221
|
+
description: string;
|
|
222
|
+
};
|
|
223
|
+
alignment: {
|
|
224
|
+
label: string;
|
|
225
|
+
description: string;
|
|
226
|
+
};
|
|
227
|
+
loop: {
|
|
228
|
+
label: string;
|
|
229
|
+
description: string;
|
|
230
|
+
};
|
|
231
|
+
autoplay: {
|
|
232
|
+
label: string;
|
|
233
|
+
description: string;
|
|
234
|
+
};
|
|
235
|
+
"mouseInteraction.enabled": {
|
|
236
|
+
label: string;
|
|
237
|
+
description: string;
|
|
238
|
+
};
|
|
239
|
+
"mouseInteraction.followMouse": {
|
|
240
|
+
label: string;
|
|
241
|
+
description: string;
|
|
242
|
+
};
|
|
243
|
+
"mouseInteraction.sensitivity": {
|
|
244
|
+
label: string;
|
|
245
|
+
placeholder: string;
|
|
246
|
+
description: string;
|
|
247
|
+
};
|
|
248
|
+
"mouseInteraction.hoverEffects": {
|
|
249
|
+
label: string;
|
|
250
|
+
description: string;
|
|
251
|
+
};
|
|
252
|
+
"mouseInteraction.clickActions": {
|
|
253
|
+
label: string;
|
|
254
|
+
description: string;
|
|
255
|
+
};
|
|
256
|
+
"stateMachineInputs.hover": {
|
|
257
|
+
label: string;
|
|
258
|
+
placeholder: string;
|
|
259
|
+
description: string;
|
|
260
|
+
};
|
|
261
|
+
"stateMachineInputs.click": {
|
|
262
|
+
label: string;
|
|
263
|
+
placeholder: string;
|
|
264
|
+
description: string;
|
|
265
|
+
};
|
|
266
|
+
"stateMachineInputs.mousePosition.x": {
|
|
267
|
+
label: string;
|
|
268
|
+
placeholder: string;
|
|
269
|
+
description: string;
|
|
270
|
+
};
|
|
271
|
+
"stateMachineInputs.mousePosition.y": {
|
|
272
|
+
label: string;
|
|
273
|
+
placeholder: string;
|
|
274
|
+
description: string;
|
|
275
|
+
};
|
|
276
|
+
"accessibility.label": {
|
|
277
|
+
label: string;
|
|
278
|
+
placeholder: string;
|
|
279
|
+
description: string;
|
|
280
|
+
};
|
|
281
|
+
"accessibility.description": {
|
|
282
|
+
label: string;
|
|
283
|
+
placeholder: string;
|
|
284
|
+
description: string;
|
|
285
|
+
};
|
|
286
|
+
"accessibility.role": {
|
|
287
|
+
label: string;
|
|
288
|
+
placeholder: string;
|
|
289
|
+
description: string;
|
|
290
|
+
};
|
|
291
|
+
"advanced.className": {
|
|
292
|
+
label: string;
|
|
293
|
+
placeholder: string;
|
|
294
|
+
description: string;
|
|
295
|
+
};
|
|
296
|
+
"advanced.id": {
|
|
297
|
+
label: string;
|
|
298
|
+
placeholder: string;
|
|
299
|
+
description: string;
|
|
300
|
+
};
|
|
301
|
+
"advanced.ariaLabel": {
|
|
302
|
+
label: string;
|
|
303
|
+
placeholder: string;
|
|
304
|
+
description: string;
|
|
305
|
+
};
|
|
306
|
+
"advanced.tabIndex": {
|
|
307
|
+
label: string;
|
|
308
|
+
placeholder: string;
|
|
309
|
+
description: string;
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
categories: {
|
|
313
|
+
content: string;
|
|
314
|
+
style: string;
|
|
315
|
+
interactivity: string;
|
|
316
|
+
state: string;
|
|
317
|
+
advanced: string;
|
|
318
|
+
};
|
|
319
|
+
priorities: {
|
|
320
|
+
quick: string;
|
|
321
|
+
common: string;
|
|
322
|
+
advanced: string;
|
|
323
|
+
};
|
|
324
|
+
upload: {
|
|
325
|
+
title: string;
|
|
326
|
+
description: string;
|
|
327
|
+
button: string;
|
|
328
|
+
dragText: string;
|
|
329
|
+
supportedFormats: string;
|
|
330
|
+
invalidFormat: string;
|
|
331
|
+
fileTooLarge: string;
|
|
332
|
+
uploadSuccess: string;
|
|
333
|
+
uploadError: string;
|
|
334
|
+
fileReady: string;
|
|
335
|
+
loadedFile: string;
|
|
336
|
+
};
|
|
337
|
+
interactivity: {
|
|
338
|
+
enabled: string;
|
|
339
|
+
followMouse: string;
|
|
340
|
+
hoverEffects: string;
|
|
341
|
+
clickActions: string;
|
|
342
|
+
sensitivity: string;
|
|
343
|
+
stateMachines: string;
|
|
344
|
+
mousePosition: string;
|
|
345
|
+
};
|
|
346
|
+
controls: {
|
|
347
|
+
play: string;
|
|
348
|
+
pause: string;
|
|
349
|
+
stop: string;
|
|
350
|
+
};
|
|
351
|
+
fitModes: {
|
|
352
|
+
contain: string;
|
|
353
|
+
cover: string;
|
|
354
|
+
fill: string;
|
|
355
|
+
fitWidth: string;
|
|
356
|
+
fitHeight: string;
|
|
357
|
+
none: string;
|
|
358
|
+
};
|
|
359
|
+
alignments: {
|
|
360
|
+
center: string;
|
|
361
|
+
topLeft: string;
|
|
362
|
+
topCenter: string;
|
|
363
|
+
topRight: string;
|
|
364
|
+
centerLeft: string;
|
|
365
|
+
centerRight: string;
|
|
366
|
+
bottomLeft: string;
|
|
367
|
+
bottomCenter: string;
|
|
368
|
+
bottomRight: string;
|
|
369
|
+
};
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
export type Locale = keyof typeof locales;
|
|
373
|
+
export declare const defaultLocale: Locale;
|
|
374
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/locales/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGV,CAAC;AAEX,MAAM,MAAM,MAAM,GAAG,MAAM,OAAO,OAAO,CAAC;AAC1C,eAAO,MAAM,aAAa,EAAE,MAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/locales/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3B,OAAO,EAAE,MAAM,WAAW,CAAC;AAE3B,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,EAAE;IACF,EAAE;CACM,CAAC;AAGX,MAAM,CAAC,MAAM,aAAa,GAAW,IAAI,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rive Renderer Component (SSR / View Mode)
|
|
3
|
+
*
|
|
4
|
+
* This is the Server-Side Rendering component for the Rive plugin.
|
|
5
|
+
* NO 'use client' directive - works in Node.js environment.
|
|
6
|
+
*
|
|
7
|
+
* ⚠️ IMPORTANT: This renderer produces LIVE SITE HTML!
|
|
8
|
+
* NO Tailwind classes allowed - only inline styles and semantic classes.
|
|
9
|
+
*
|
|
10
|
+
* Note: Rive animations require client-side JavaScript to play.
|
|
11
|
+
* This renderer provides a placeholder/fallback for SSR with proper styling.
|
|
12
|
+
* The actual animation will be hydrated on the client.
|
|
13
|
+
*/
|
|
14
|
+
import type { PluginDependencies } from '@codefluss/base-types';
|
|
15
|
+
import type { RiveData } from './rive-config';
|
|
16
|
+
/**
|
|
17
|
+
* Rive Renderer Props
|
|
18
|
+
*
|
|
19
|
+
* Follows the standard RendererProps pattern for consistency
|
|
20
|
+
*/
|
|
21
|
+
export interface RiveRendererProps {
|
|
22
|
+
/** Unique element identifier */
|
|
23
|
+
elementId: string;
|
|
24
|
+
/** Rive animation configuration data */
|
|
25
|
+
data: RiveData;
|
|
26
|
+
/** Current language for i18n */
|
|
27
|
+
language: string;
|
|
28
|
+
/** Plugin dependencies including design system */
|
|
29
|
+
dependencies: PluginDependencies;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Rive Renderer Component
|
|
33
|
+
*
|
|
34
|
+
* Pure functional component for SSR rendering of Rive animations.
|
|
35
|
+
* Uses ONLY inline styles and semantic classes - NO Tailwind.
|
|
36
|
+
*
|
|
37
|
+
* @param props - Renderer props following standard pattern
|
|
38
|
+
* @returns React element for server-side rendering
|
|
39
|
+
*/
|
|
40
|
+
export declare function RiveRenderer({ elementId, data, language, dependencies, }: RiveRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export declare namespace RiveRenderer {
|
|
42
|
+
var displayName: string;
|
|
43
|
+
}
|
|
44
|
+
export default RiveRenderer;
|
|
45
|
+
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IACjC,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,IAAI,EAAE,QAAQ,CAAC;IACf,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,YAAY,EAAE,kBAAkB,CAAC;CACjC;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,EAC5B,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,YAAY,GACZ,EAAE,iBAAiB,2CAiHnB;yBAtHe,YAAY;;;AA2H5B,eAAe,YAAY,CAAC"}
|
package/dist/renderer.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Rive Renderer Component
|
|
4
|
+
*
|
|
5
|
+
* Pure functional component for SSR rendering of Rive animations.
|
|
6
|
+
* Uses ONLY inline styles and semantic classes - NO Tailwind.
|
|
7
|
+
*
|
|
8
|
+
* @param props - Renderer props following standard pattern
|
|
9
|
+
* @returns React element for server-side rendering
|
|
10
|
+
*/
|
|
11
|
+
export function RiveRenderer({ elementId, data, language, dependencies, }) {
|
|
12
|
+
const { designSystem, utils } = dependencies;
|
|
13
|
+
// Resolve accessibility label based on language
|
|
14
|
+
const ariaLabel = data.accessibility?.label || 'Rive Animation';
|
|
15
|
+
const ariaDescription = data.accessibility?.description || '';
|
|
16
|
+
// Get custom class name from advanced settings
|
|
17
|
+
const customClassName = data.advanced?.className || '';
|
|
18
|
+
// Generate class names - ONLY semantic classes, NO Tailwind
|
|
19
|
+
const className = utils.cn('rive-component', customClassName);
|
|
20
|
+
// Map fit values to CSS object-fit
|
|
21
|
+
const getFitStyle = (fit) => {
|
|
22
|
+
switch (fit) {
|
|
23
|
+
case 'contain': return 'contain';
|
|
24
|
+
case 'cover': return 'cover';
|
|
25
|
+
case 'fill': return 'fill';
|
|
26
|
+
case 'none': return 'none';
|
|
27
|
+
case 'scale-down': return 'scale-down';
|
|
28
|
+
default: return 'contain';
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
// Map alignment to flexbox positioning
|
|
32
|
+
const getAlignmentStyles = (alignment) => {
|
|
33
|
+
switch (alignment) {
|
|
34
|
+
case 'top-left': return { alignItems: 'flex-start', justifyContent: 'flex-start' };
|
|
35
|
+
case 'top-right': return { alignItems: 'flex-start', justifyContent: 'flex-end' };
|
|
36
|
+
case 'bottom-left': return { alignItems: 'flex-end', justifyContent: 'flex-start' };
|
|
37
|
+
case 'bottom-right': return { alignItems: 'flex-end', justifyContent: 'flex-end' };
|
|
38
|
+
case 'center':
|
|
39
|
+
default:
|
|
40
|
+
return { alignItems: 'center', justifyContent: 'center' };
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
// Build inline styles - ALL visual styling via inline CSS
|
|
44
|
+
const containerStyle = {
|
|
45
|
+
// Width from data or default to 100%
|
|
46
|
+
width: data.width ? `${data.width}px` : '100%',
|
|
47
|
+
// Height from data or auto
|
|
48
|
+
height: data.height ? `${data.height}px` : 'auto',
|
|
49
|
+
// Ensure proper display
|
|
50
|
+
display: 'flex',
|
|
51
|
+
// Position for potential overlays
|
|
52
|
+
position: 'relative',
|
|
53
|
+
// Aspect ratio maintenance
|
|
54
|
+
aspectRatio: data.width && data.height ? `${data.width} / ${data.height}` : undefined,
|
|
55
|
+
// Alignment styles
|
|
56
|
+
...getAlignmentStyles(data.alignment),
|
|
57
|
+
};
|
|
58
|
+
// Placeholder style for SSR (before client hydration)
|
|
59
|
+
const placeholderStyle = {
|
|
60
|
+
width: '100%',
|
|
61
|
+
height: '100%',
|
|
62
|
+
display: 'flex',
|
|
63
|
+
alignItems: 'center',
|
|
64
|
+
justifyContent: 'center',
|
|
65
|
+
backgroundColor: 'rgba(0, 0, 0, 0.05)',
|
|
66
|
+
borderRadius: '4px',
|
|
67
|
+
minHeight: '100px',
|
|
68
|
+
objectFit: getFitStyle(data.fit),
|
|
69
|
+
};
|
|
70
|
+
return (_jsxs("div", { className: className, style: containerStyle, "aria-label": ariaLabel, "aria-describedby": ariaDescription ? `${elementId}-desc` : undefined, "data-component-id": elementId, "data-component-type": "rive", "data-src": data.src, "data-artboard": data.artboard, "data-autoplay": data.autoplay, "data-loop": data.loop, "data-fit": data.fit, "data-alignment": data.alignment, id: data.advanced?.id, "data-testid": data.advanced?.['data-testid'], tabIndex: data.advanced?.tabIndex, children: [_jsx("div", { style: placeholderStyle, children: _jsx("span", { style: { fontSize: '24px' }, children: "\uD83C\uDFAF" }) }), ariaDescription && (_jsx("span", { id: `${elementId}-desc`, style: {
|
|
71
|
+
position: 'absolute',
|
|
72
|
+
width: '1px',
|
|
73
|
+
height: '1px',
|
|
74
|
+
padding: 0,
|
|
75
|
+
margin: '-1px',
|
|
76
|
+
overflow: 'hidden',
|
|
77
|
+
clip: 'rect(0, 0, 0, 0)',
|
|
78
|
+
whiteSpace: 'nowrap',
|
|
79
|
+
border: 0,
|
|
80
|
+
}, children: ariaDescription }))] }));
|
|
81
|
+
}
|
|
82
|
+
// Display name for debugging
|
|
83
|
+
RiveRenderer.displayName = 'RiveRenderer';
|
|
84
|
+
export default RiveRenderer;
|
|
85
|
+
//# sourceMappingURL=renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../src/renderer.tsx"],"names":[],"mappings":";AAiCA;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,EAC5B,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,YAAY,GACO;IACnB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,YAAY,CAAC;IAE7C,gDAAgD;IAChD,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,EAAE,KAAK,IAAI,gBAAgB,CAAC;IAChE,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,EAAE,WAAW,IAAI,EAAE,CAAC;IAE9D,+CAA+C;IAC/C,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,IAAI,EAAE,CAAC;IAEvD,4DAA4D;IAC5D,MAAM,SAAS,GAAG,KAAK,CAAC,EAAE,CACzB,gBAAgB,EAChB,eAAe,CACf,CAAC;IAEF,mCAAmC;IACnC,MAAM,WAAW,GAAG,CAAC,GAAY,EAAoC,EAAE;QACtE,QAAQ,GAAG,EAAE,CAAC;YACb,KAAK,SAAS,CAAC,CAAC,OAAO,SAAS,CAAC;YACjC,KAAK,OAAO,CAAC,CAAC,OAAO,OAAO,CAAC;YAC7B,KAAK,MAAM,CAAC,CAAC,OAAO,MAAM,CAAC;YAC3B,KAAK,MAAM,CAAC,CAAC,OAAO,MAAM,C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;oBAClB,IAAI,EAAE,kBAAkB;oBACxB,UAAU,EAAE,QAAQ;oBACpB,MAAM,EAAE,CAAC;iBACT,YAEA,eAAe,GACV,CACP,IACI,CACN,CAAC;AACH,CAAC;AAED,6BAA6B;AAC7B,YAAY,CAAC,WAAW,GAAG,cAAc,CAAC;AAE1C,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rive-component.d.ts","sourceRoot":"","sources":["../src/rive-component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAExE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGxD,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA2K/C,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useCallback } from 'react';
|
|
3
|
+
import { useRive, useStateMachineInput } from 'rive-react';
|
|
4
|
+
import { cn } from './lib/utils';
|
|
5
|
+
const RiveComponent = ({ data, onChange, isEditing = false, className, }) => {
|
|
6
|
+
const [uploadedFile, setUploadedFile] = useState(null);
|
|
7
|
+
const containerRef = useRef(null);
|
|
8
|
+
const [hasError, setHasError] = useState(false);
|
|
9
|
+
const [errorMessage, setErrorMessage] = useState('');
|
|
10
|
+
const [animationData, setAnimationData] = useState(null);
|
|
11
|
+
// Parse animations and state machines from data
|
|
12
|
+
const animations = Array.isArray(data.animations)
|
|
13
|
+
? data.animations.join(',')
|
|
14
|
+
: data.animations || '';
|
|
15
|
+
const stateMachines = Array.isArray(data.stateMachines)
|
|
16
|
+
? data.stateMachines.join(',')
|
|
17
|
+
: data.stateMachines || '';
|
|
18
|
+
const riveParams = {
|
|
19
|
+
src: data.src || '',
|
|
20
|
+
animations: animations,
|
|
21
|
+
stateMachines: stateMachines,
|
|
22
|
+
autoplay: data.autoplay !== false,
|
|
23
|
+
onRiveReady: () => {
|
|
24
|
+
console.log('Rive animation loaded');
|
|
25
|
+
setHasError(false);
|
|
26
|
+
setErrorMessage('');
|
|
27
|
+
setAnimationData(true);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
if (data.artboard) {
|
|
31
|
+
riveParams.artboard = data.artboard;
|
|
32
|
+
}
|
|
33
|
+
const { RiveComponent: RiveComp, rive } = useRive(riveParams);
|
|
34
|
+
// Handle file upload
|
|
35
|
+
const handleFileUpload = useCallback(async (event) => {
|
|
36
|
+
const file = event.target.files?.[0];
|
|
37
|
+
if (!file)
|
|
38
|
+
return;
|
|
39
|
+
// Validate file type
|
|
40
|
+
if (!file.name.endsWith('.riv')) {
|
|
41
|
+
alert('Please upload a valid Rive .riv file');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
setUploadedFile(file);
|
|
46
|
+
const fileUrl = URL.createObjectURL(file);
|
|
47
|
+
onChange?.({
|
|
48
|
+
...data,
|
|
49
|
+
src: fileUrl,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.error('Failed to process Rive file:', error);
|
|
54
|
+
setHasError(true);
|
|
55
|
+
setErrorMessage('Failed to process Rive file');
|
|
56
|
+
}
|
|
57
|
+
}, [data, onChange]);
|
|
58
|
+
// State machine inputs for mouse interactions
|
|
59
|
+
const stateMachineName = Array.isArray(data.stateMachines) ? data.stateMachines[0] : data.stateMachines;
|
|
60
|
+
const mouseXInput = useStateMachineInput(rive, stateMachineName || '', data.stateMachineInputs?.mousePosition?.x || 'mouseX', 0);
|
|
61
|
+
const mouseYInput = useStateMachineInput(rive, stateMachineName || '', data.stateMachineInputs?.mousePosition?.y || 'mouseY', 0);
|
|
62
|
+
const hoverInput = useStateMachineInput(rive, stateMachineName || '', data.stateMachineInputs?.hover || 'isHovering', false);
|
|
63
|
+
const clickInput = useStateMachineInput(rive, stateMachineName || '', data.stateMachineInputs?.click || 'onClick', false);
|
|
64
|
+
// Handle mouse movement for tracking
|
|
65
|
+
const handleMouseMove = useCallback((event) => {
|
|
66
|
+
if (!data.mouseInteraction?.enabled || !containerRef.current || !rive)
|
|
67
|
+
return;
|
|
68
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
69
|
+
const x = (event.clientX - rect.left) / rect.width;
|
|
70
|
+
const y = (event.clientY - rect.top) / rect.height;
|
|
71
|
+
// Update mouse position in Rive (if inputs exist and rive is ready)
|
|
72
|
+
if (mouseXInput && mouseYInput) {
|
|
73
|
+
mouseXInput.value = x;
|
|
74
|
+
mouseYInput.value = y;
|
|
75
|
+
}
|
|
76
|
+
}, [data.mouseInteraction?.enabled, mouseXInput, mouseYInput, rive]);
|
|
77
|
+
// Handle mouse enter for hover effects
|
|
78
|
+
const handleMouseEnter = useCallback(() => {
|
|
79
|
+
if (!data.mouseInteraction?.enabled || !hoverInput || !rive)
|
|
80
|
+
return;
|
|
81
|
+
hoverInput.value = true;
|
|
82
|
+
}, [data.mouseInteraction?.enabled, hoverInput, rive]);
|
|
83
|
+
// Handle mouse leave for hover effects
|
|
84
|
+
const handleMouseLeave = useCallback(() => {
|
|
85
|
+
if (!data.mouseInteraction?.enabled || !hoverInput || !rive)
|
|
86
|
+
return;
|
|
87
|
+
hoverInput.value = false;
|
|
88
|
+
}, [data.mouseInteraction?.enabled, hoverInput, rive]);
|
|
89
|
+
// Handle click for click actions
|
|
90
|
+
const handleClick = useCallback(() => {
|
|
91
|
+
if (!data.mouseInteraction?.enabled || !clickInput || !rive)
|
|
92
|
+
return;
|
|
93
|
+
clickInput.value = true;
|
|
94
|
+
// Reset click trigger after a short delay
|
|
95
|
+
setTimeout(() => {
|
|
96
|
+
if (clickInput && rive) {
|
|
97
|
+
clickInput.value = false;
|
|
98
|
+
}
|
|
99
|
+
}, 100);
|
|
100
|
+
}, [data.mouseInteraction?.enabled, clickInput, rive]);
|
|
101
|
+
const containerProps = {
|
|
102
|
+
ref: containerRef,
|
|
103
|
+
className: cn('rive-container', data.mouseInteraction?.enabled && 'cursor-pointer interactive', className),
|
|
104
|
+
style: {
|
|
105
|
+
width: data.width || 300,
|
|
106
|
+
height: data.height || 300,
|
|
107
|
+
overflow: 'hidden',
|
|
108
|
+
borderRadius: '8px',
|
|
109
|
+
backgroundColor: '#f0f0f0',
|
|
110
|
+
border: '1px solid #e0e0e0',
|
|
111
|
+
},
|
|
112
|
+
onMouseMove: handleMouseMove,
|
|
113
|
+
onMouseEnter: handleMouseEnter,
|
|
114
|
+
onMouseLeave: handleMouseLeave,
|
|
115
|
+
onClick: handleClick,
|
|
116
|
+
};
|
|
117
|
+
if (hasError) {
|
|
118
|
+
return (_jsxs("div", { className: cn('rive-error-container', className), style: {
|
|
119
|
+
width: data.width || 300,
|
|
120
|
+
height: data.height || 300,
|
|
121
|
+
display: 'flex',
|
|
122
|
+
alignItems: 'center',
|
|
123
|
+
justifyContent: 'center',
|
|
124
|
+
flexDirection: 'column',
|
|
125
|
+
backgroundColor: '#fee',
|
|
126
|
+
border: '1px solid #fcc',
|
|
127
|
+
borderRadius: '8px',
|
|
128
|
+
color: '#c66',
|
|
129
|
+
}, children: [_jsx("div", { style: { fontSize: '48px', marginBottom: '8px' }, children: "\u26A0\uFE0F" }), _jsxs("div", { style: { textAlign: 'center', fontSize: '14px' }, children: [_jsx("div", { style: { fontWeight: 'bold', marginBottom: '4px' }, children: "Animation Error" }), _jsx("div", { style: { fontSize: '12px', opacity: 0.8 }, children: errorMessage })] })] }));
|
|
130
|
+
}
|
|
131
|
+
return (_jsx("div", { ...containerProps, children: RiveComp && (_jsx(RiveComp, { style: {
|
|
132
|
+
width: '100%',
|
|
133
|
+
height: '100%',
|
|
134
|
+
} })) }));
|
|
135
|
+
};
|
|
136
|
+
export default RiveComponent;
|
|
137
|
+
//# sourceMappingURL=rive-component.js.map
|