analytica-frontend-lib 1.0.70 → 1.0.72

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.
Files changed (53) hide show
  1. package/dist/Accordation/index.d.mts +12 -0
  2. package/dist/Accordation/index.d.ts +12 -0
  3. package/dist/Accordation/index.js +1663 -0
  4. package/dist/Accordation/index.js.map +1 -0
  5. package/dist/Accordation/index.mjs +1654 -0
  6. package/dist/Accordation/index.mjs.map +1 -0
  7. package/dist/AlertDialog/index.d.mts +40 -0
  8. package/dist/AlertDialog/index.d.ts +40 -0
  9. package/dist/AlertDialog/index.js +233 -0
  10. package/dist/AlertDialog/index.js.map +1 -0
  11. package/dist/AlertDialog/index.mjs +212 -0
  12. package/dist/AlertDialog/index.mjs.map +1 -0
  13. package/dist/Alternative/index.d.mts +81 -0
  14. package/dist/Alternative/index.d.ts +81 -0
  15. package/dist/Alternative/index.js +745 -0
  16. package/dist/Alternative/index.js.map +1 -0
  17. package/dist/Alternative/index.mjs +728 -0
  18. package/dist/Alternative/index.mjs.map +1 -0
  19. package/dist/Badge/index.js +1 -1
  20. package/dist/Badge/index.js.map +1 -1
  21. package/dist/Badge/index.mjs +1 -1
  22. package/dist/Badge/index.mjs.map +1 -1
  23. package/dist/Card/index.js +1 -1
  24. package/dist/Card/index.js.map +1 -1
  25. package/dist/Card/index.mjs +1 -1
  26. package/dist/Card/index.mjs.map +1 -1
  27. package/dist/Radio/index.d.mts +120 -2
  28. package/dist/Radio/index.d.ts +120 -2
  29. package/dist/Radio/index.js +176 -3
  30. package/dist/Radio/index.js.map +1 -1
  31. package/dist/Radio/index.mjs +176 -4
  32. package/dist/Radio/index.mjs.map +1 -1
  33. package/dist/Skeleton/index.d.mts +10 -9
  34. package/dist/Skeleton/index.d.ts +10 -9
  35. package/dist/Skeleton/index.js.map +1 -1
  36. package/dist/Skeleton/index.mjs.map +1 -1
  37. package/dist/index.css +173 -83
  38. package/dist/index.css.map +1 -1
  39. package/dist/index.d.mts +4 -2
  40. package/dist/index.d.ts +4 -2
  41. package/dist/index.js +2361 -1916
  42. package/dist/index.js.map +1 -1
  43. package/dist/index.mjs +2412 -1962
  44. package/dist/index.mjs.map +1 -1
  45. package/dist/styles.css +173 -83
  46. package/dist/styles.css.map +1 -1
  47. package/package.json +4 -2
  48. package/dist/Tab/index.d.mts +0 -37
  49. package/dist/Tab/index.d.ts +0 -37
  50. package/dist/Tab/index.js +0 -182
  51. package/dist/Tab/index.js.map +0 -1
  52. package/dist/Tab/index.mjs +0 -161
  53. package/dist/Tab/index.mjs.map +0 -1
@@ -0,0 +1,745 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/components/Alternative/Alternative.tsx
21
+ var Alternative_exports = {};
22
+ __export(Alternative_exports, {
23
+ AlternativesList: () => AlternativesList,
24
+ HeaderAlternative: () => HeaderAlternative
25
+ });
26
+ module.exports = __toCommonJS(Alternative_exports);
27
+ var import_phosphor_react2 = require("phosphor-react");
28
+
29
+ // src/components/Badge/Badge.tsx
30
+ var import_phosphor_react = require("phosphor-react");
31
+ var import_jsx_runtime = require("react/jsx-runtime");
32
+ var VARIANT_ACTION_CLASSES = {
33
+ solid: {
34
+ error: "bg-error-background text-error-700 focus-visible:outline-none",
35
+ warning: "bg-warning text-warning-800 focus-visible:outline-none",
36
+ success: "bg-success text-success-800 focus-visible:outline-none",
37
+ info: "bg-info text-info-800 focus-visible:outline-none",
38
+ muted: "bg-background-muted text-background-800 focus-visible:outline-none"
39
+ },
40
+ outlined: {
41
+ error: "bg-error text-error-700 border border-error-300 focus-visible:outline-none",
42
+ warning: "bg-warning text-warning-800 border border-warning-300 focus-visible:outline-none",
43
+ success: "bg-success text-success-800 border border-success-300 focus-visible:outline-none",
44
+ info: "bg-info text-info-800 border border-info-300 focus-visible:outline-none",
45
+ muted: "bg-background-muted text-background-800 border border-border-300 focus-visible:outline-none"
46
+ },
47
+ exams: {
48
+ exam1: "bg-exam-1 text-info-700 focus-visible:outline-none",
49
+ exam2: "bg-exam-2 text-typography-1 focus-visible:outline-none",
50
+ exam3: "bg-exam-3 text-typography-2 focus-visible:outline-none",
51
+ exam4: "bg-exam-4 text-success-700 focus-visible:outline-none"
52
+ },
53
+ resultStatus: {
54
+ negative: "bg-error text-error-800 focus-visible:outline-none",
55
+ positive: "bg-success text-success-800 focus-visible:outline-none"
56
+ },
57
+ notification: "text-primary"
58
+ };
59
+ var SIZE_CLASSES = {
60
+ small: "text-2xs px-2 py-1",
61
+ medium: "text-xs px-2 py-1",
62
+ large: "text-sm px-2 py-1"
63
+ };
64
+ var SIZE_CLASSES_ICON = {
65
+ small: "size-3",
66
+ medium: "size-3.5",
67
+ large: "size-4"
68
+ };
69
+ var Badge = ({
70
+ children,
71
+ iconLeft,
72
+ iconRight,
73
+ size = "medium",
74
+ variant = "solid",
75
+ action = "error",
76
+ className = "",
77
+ notificationActive = false,
78
+ ...props
79
+ }) => {
80
+ const sizeClasses = SIZE_CLASSES[size];
81
+ const sizeClassesIcon = SIZE_CLASSES_ICON[size];
82
+ const variantActionMap = VARIANT_ACTION_CLASSES[variant] || {};
83
+ const variantClasses = typeof variantActionMap === "string" ? variantActionMap : variantActionMap[action] ?? variantActionMap.muted ?? "";
84
+ const baseClasses = "inline-flex items-center justify-center rounded-xs font-normal gap-1 relative";
85
+ const baseClassesIcon = "flex items-center";
86
+ if (variant === "notification") {
87
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
88
+ "div",
89
+ {
90
+ className: `${baseClasses} ${variantClasses} ${sizeClasses} ${className}`,
91
+ ...props,
92
+ children: [
93
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_phosphor_react.Bell, { size: 24, className: "text-current", "aria-hidden": "true" }),
94
+ notificationActive && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
95
+ "span",
96
+ {
97
+ "data-testid": "notification-dot",
98
+ className: "absolute top-[5px] right-[10px] block h-2 w-2 rounded-full bg-indicator-error ring-2 ring-white"
99
+ }
100
+ )
101
+ ]
102
+ }
103
+ );
104
+ }
105
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
106
+ "div",
107
+ {
108
+ className: `${baseClasses} ${variantClasses} ${sizeClasses} ${className}`,
109
+ ...props,
110
+ children: [
111
+ iconLeft && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `${baseClassesIcon} ${sizeClassesIcon}`, children: iconLeft }),
112
+ children,
113
+ iconRight && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `${baseClassesIcon} ${sizeClassesIcon}`, children: iconRight })
114
+ ]
115
+ }
116
+ );
117
+ };
118
+ var Badge_default = Badge;
119
+
120
+ // src/components/Radio/Radio.tsx
121
+ var import_react = require("react");
122
+ var import_zustand = require("zustand");
123
+
124
+ // src/components/Text/Text.tsx
125
+ var import_jsx_runtime2 = require("react/jsx-runtime");
126
+ var Text = ({
127
+ children,
128
+ size = "md",
129
+ weight = "normal",
130
+ color = "text-text-950",
131
+ as,
132
+ className = "",
133
+ ...props
134
+ }) => {
135
+ let sizeClasses = "";
136
+ let weightClasses = "";
137
+ const sizeClassMap = {
138
+ "2xs": "text-2xs",
139
+ xs: "text-xs",
140
+ sm: "text-sm",
141
+ md: "text-md",
142
+ lg: "text-lg",
143
+ xl: "text-xl",
144
+ "2xl": "text-2xl",
145
+ "3xl": "text-3xl",
146
+ "4xl": "text-4xl",
147
+ "5xl": "text-5xl",
148
+ "6xl": "text-6xl"
149
+ };
150
+ sizeClasses = sizeClassMap[size] ?? sizeClassMap.md;
151
+ const weightClassMap = {
152
+ hairline: "font-hairline",
153
+ light: "font-light",
154
+ normal: "font-normal",
155
+ medium: "font-medium",
156
+ semibold: "font-semibold",
157
+ bold: "font-bold",
158
+ extrabold: "font-extrabold",
159
+ black: "font-black"
160
+ };
161
+ weightClasses = weightClassMap[weight] ?? weightClassMap.normal;
162
+ const baseClasses = "font-primary";
163
+ const Component = as ?? "p";
164
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
165
+ Component,
166
+ {
167
+ className: `${baseClasses} ${sizeClasses} ${weightClasses} ${color} ${className}`,
168
+ ...props,
169
+ children
170
+ }
171
+ );
172
+ };
173
+ var Text_default = Text;
174
+
175
+ // src/components/Radio/Radio.tsx
176
+ var import_jsx_runtime3 = require("react/jsx-runtime");
177
+ var SIZE_CLASSES2 = {
178
+ small: {
179
+ radio: "w-5 h-5",
180
+ textSize: "sm",
181
+ spacing: "gap-1.5",
182
+ borderWidth: "border-2",
183
+ dotSize: "w-2.5 h-2.5",
184
+ labelHeight: "h-5"
185
+ },
186
+ medium: {
187
+ radio: "w-6 h-6",
188
+ textSize: "md",
189
+ spacing: "gap-2",
190
+ borderWidth: "border-2",
191
+ dotSize: "w-3 h-3",
192
+ labelHeight: "h-6"
193
+ },
194
+ large: {
195
+ radio: "w-7 h-7",
196
+ textSize: "lg",
197
+ spacing: "gap-2",
198
+ borderWidth: "border-2",
199
+ dotSize: "w-3.5 h-3.5",
200
+ labelHeight: "h-7"
201
+ },
202
+ extraLarge: {
203
+ radio: "w-8 h-8",
204
+ textSize: "xl",
205
+ spacing: "gap-3",
206
+ borderWidth: "border-2",
207
+ dotSize: "w-4 h-4",
208
+ labelHeight: "h-8"
209
+ }
210
+ };
211
+ var BASE_RADIO_CLASSES = "rounded-full border cursor-pointer transition-all duration-200 flex items-center justify-center focus:outline-none";
212
+ var STATE_CLASSES = {
213
+ default: {
214
+ unchecked: "border-border-400 bg-background hover:border-border-500",
215
+ checked: "border-primary-950 bg-background hover:border-primary-800"
216
+ },
217
+ hovered: {
218
+ unchecked: "border-border-500 bg-background",
219
+ checked: "border-info-700 bg-background"
220
+ },
221
+ focused: {
222
+ unchecked: "border-border-400 bg-background",
223
+ checked: "border-primary-950 bg-background"
224
+ },
225
+ invalid: {
226
+ unchecked: "border-border-400 bg-background",
227
+ checked: "border-primary-950 bg-background"
228
+ },
229
+ disabled: {
230
+ unchecked: "border-border-400 bg-background cursor-not-allowed",
231
+ checked: "border-primary-950 bg-background cursor-not-allowed"
232
+ }
233
+ };
234
+ var DOT_CLASSES = {
235
+ default: "bg-primary-950",
236
+ hovered: "bg-info-700",
237
+ focused: "bg-primary-950",
238
+ invalid: "bg-primary-950",
239
+ disabled: "bg-primary-950"
240
+ };
241
+ var Radio = (0, import_react.forwardRef)(
242
+ ({
243
+ label,
244
+ size = "medium",
245
+ state = "default",
246
+ errorMessage,
247
+ helperText,
248
+ className = "",
249
+ labelClassName = "",
250
+ checked: checkedProp,
251
+ defaultChecked = false,
252
+ disabled,
253
+ id,
254
+ name,
255
+ value,
256
+ onChange,
257
+ ...props
258
+ }, ref) => {
259
+ const generatedId = (0, import_react.useId)();
260
+ const inputId = id ?? `radio-${generatedId}`;
261
+ const inputRef = (0, import_react.useRef)(null);
262
+ const [internalChecked, setInternalChecked] = (0, import_react.useState)(defaultChecked);
263
+ const isControlled = checkedProp !== void 0;
264
+ const checked = isControlled ? checkedProp : internalChecked;
265
+ const handleChange = (event) => {
266
+ const newChecked = event.target.checked;
267
+ if (!isControlled) {
268
+ setInternalChecked(newChecked);
269
+ }
270
+ if (event.target) {
271
+ event.target.blur();
272
+ }
273
+ onChange?.(event);
274
+ };
275
+ const currentState = disabled ? "disabled" : state;
276
+ const sizeClasses = SIZE_CLASSES2[size];
277
+ const actualRadioSize = sizeClasses.radio;
278
+ const actualDotSize = sizeClasses.dotSize;
279
+ const radioVariant = checked ? "checked" : "unchecked";
280
+ const stylingClasses = STATE_CLASSES[currentState][radioVariant];
281
+ const getBorderWidth = () => {
282
+ if (currentState === "focused") {
283
+ return "border-2";
284
+ }
285
+ return sizeClasses.borderWidth;
286
+ };
287
+ const borderWidthClass = getBorderWidth();
288
+ const radioClasses = `${BASE_RADIO_CLASSES} ${actualRadioSize} ${borderWidthClass} ${stylingClasses} ${className}`;
289
+ const dotClasses = `${actualDotSize} rounded-full ${DOT_CLASSES[currentState]} transition-all duration-200`;
290
+ const isWrapperNeeded = currentState === "focused" || currentState === "invalid";
291
+ const wrapperBorderColor = currentState === "focused" ? "border-indicator-info" : "border-indicator-error";
292
+ const getTextColor = () => {
293
+ if (currentState === "disabled") {
294
+ return checked ? "text-text-900" : "text-text-600";
295
+ }
296
+ if (currentState === "focused") {
297
+ return "text-text-900";
298
+ }
299
+ return checked ? "text-text-900" : "text-text-600";
300
+ };
301
+ const getCursorClass = () => {
302
+ return currentState === "disabled" ? "cursor-not-allowed" : "cursor-pointer";
303
+ };
304
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex flex-col", children: [
305
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
306
+ "div",
307
+ {
308
+ className: `flex flex-row items-center ${isWrapperNeeded ? `p-1 border-2 ${wrapperBorderColor} rounded-lg gap-1.5` : sizeClasses.spacing} ${disabled ? "opacity-40" : ""}`,
309
+ children: [
310
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
311
+ "input",
312
+ {
313
+ ref: (node) => {
314
+ inputRef.current = node;
315
+ if (typeof ref === "function") ref(node);
316
+ else if (ref) ref.current = node;
317
+ },
318
+ type: "radio",
319
+ id: inputId,
320
+ checked,
321
+ disabled,
322
+ name,
323
+ value,
324
+ onChange: handleChange,
325
+ className: "sr-only",
326
+ style: {
327
+ position: "absolute",
328
+ left: "-9999px",
329
+ visibility: "hidden"
330
+ },
331
+ ...props
332
+ }
333
+ ),
334
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
335
+ "button",
336
+ {
337
+ type: "button",
338
+ className: radioClasses,
339
+ disabled,
340
+ "aria-pressed": checked,
341
+ onClick: (e) => {
342
+ e.preventDefault();
343
+ if (!disabled) {
344
+ if (inputRef.current) {
345
+ inputRef.current.click();
346
+ inputRef.current.blur();
347
+ }
348
+ }
349
+ },
350
+ onKeyDown: (e) => {
351
+ if ((e.key === "Enter" || e.key === " ") && !disabled) {
352
+ e.preventDefault();
353
+ if (inputRef.current) {
354
+ inputRef.current.click();
355
+ inputRef.current.blur();
356
+ }
357
+ }
358
+ },
359
+ children: checked && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: dotClasses })
360
+ }
361
+ ),
362
+ label && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
363
+ "div",
364
+ {
365
+ className: `flex flex-row items-center ${sizeClasses.labelHeight} flex-1 min-w-0`,
366
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
367
+ Text_default,
368
+ {
369
+ as: "label",
370
+ htmlFor: inputId,
371
+ size: sizeClasses.textSize,
372
+ weight: "normal",
373
+ className: `${getCursorClass()} select-none leading-normal flex items-center font-roboto truncate ${labelClassName}`,
374
+ color: getTextColor(),
375
+ children: label
376
+ }
377
+ )
378
+ }
379
+ )
380
+ ]
381
+ }
382
+ ),
383
+ errorMessage && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
384
+ Text_default,
385
+ {
386
+ size: "sm",
387
+ weight: "normal",
388
+ className: "mt-1.5 truncate",
389
+ color: "text-error-600",
390
+ children: errorMessage
391
+ }
392
+ ),
393
+ helperText && !errorMessage && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
394
+ Text_default,
395
+ {
396
+ size: "sm",
397
+ weight: "normal",
398
+ className: "mt-1.5 truncate",
399
+ color: "text-text-500",
400
+ children: helperText
401
+ }
402
+ )
403
+ ] });
404
+ }
405
+ );
406
+ Radio.displayName = "Radio";
407
+ var createRadioGroupStore = (name, defaultValue, disabled, onValueChange) => (0, import_zustand.create)((set, get) => ({
408
+ value: defaultValue,
409
+ setValue: (value) => {
410
+ if (!get().disabled) {
411
+ set({ value });
412
+ get().onValueChange?.(value);
413
+ }
414
+ },
415
+ onValueChange,
416
+ disabled,
417
+ name
418
+ }));
419
+ var useRadioGroupStore = (externalStore) => {
420
+ if (!externalStore) {
421
+ throw new Error("RadioGroupItem must be used within a RadioGroup");
422
+ }
423
+ return externalStore;
424
+ };
425
+ var injectStore = (children, store) => import_react.Children.map(children, (child) => {
426
+ if (!(0, import_react.isValidElement)(child)) return child;
427
+ const typedChild = child;
428
+ const shouldInject = typedChild.type === RadioGroupItem;
429
+ return (0, import_react.cloneElement)(typedChild, {
430
+ ...shouldInject ? { store } : {},
431
+ ...typedChild.props.children ? { children: injectStore(typedChild.props.children, store) } : {}
432
+ });
433
+ });
434
+ var RadioGroup = (0, import_react.forwardRef)(
435
+ ({
436
+ value: propValue,
437
+ defaultValue = "",
438
+ onValueChange,
439
+ name: propName,
440
+ disabled = false,
441
+ className = "",
442
+ children,
443
+ ...props
444
+ }, ref) => {
445
+ const generatedId = (0, import_react.useId)();
446
+ const name = propName || `radio-group-${generatedId}`;
447
+ const storeRef = (0, import_react.useRef)(null);
448
+ storeRef.current ??= createRadioGroupStore(
449
+ name,
450
+ defaultValue,
451
+ disabled,
452
+ onValueChange
453
+ );
454
+ const store = storeRef.current;
455
+ const { setValue } = (0, import_zustand.useStore)(store, (s) => s);
456
+ (0, import_react.useEffect)(() => {
457
+ const currentValue = store.getState().value;
458
+ if (currentValue && onValueChange) {
459
+ onValueChange(currentValue);
460
+ }
461
+ }, []);
462
+ (0, import_react.useEffect)(() => {
463
+ if (propValue !== void 0) {
464
+ setValue(propValue);
465
+ }
466
+ }, [propValue, setValue]);
467
+ (0, import_react.useEffect)(() => {
468
+ store.setState({ disabled });
469
+ }, [disabled, store]);
470
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
471
+ "div",
472
+ {
473
+ ref,
474
+ className,
475
+ role: "radiogroup",
476
+ "aria-label": name,
477
+ ...props,
478
+ children: injectStore(children, store)
479
+ }
480
+ );
481
+ }
482
+ );
483
+ RadioGroup.displayName = "RadioGroup";
484
+ var RadioGroupItem = (0, import_react.forwardRef)(
485
+ ({
486
+ value,
487
+ store: externalStore,
488
+ disabled: itemDisabled,
489
+ size = "medium",
490
+ state = "default",
491
+ className = "",
492
+ id,
493
+ ...props
494
+ }, ref) => {
495
+ const store = useRadioGroupStore(externalStore);
496
+ const {
497
+ value: groupValue,
498
+ setValue,
499
+ disabled: groupDisabled,
500
+ name
501
+ } = (0, import_zustand.useStore)(store);
502
+ const generatedId = (0, import_react.useId)();
503
+ const inputId = id ?? `radio-item-${generatedId}`;
504
+ const isChecked = groupValue === value;
505
+ const isDisabled = groupDisabled || itemDisabled;
506
+ const currentState = isDisabled ? "disabled" : state;
507
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
508
+ Radio,
509
+ {
510
+ ref,
511
+ id: inputId,
512
+ name,
513
+ value,
514
+ checked: isChecked,
515
+ disabled: isDisabled,
516
+ size,
517
+ state: currentState,
518
+ className,
519
+ onChange: (e) => {
520
+ if (e.target.checked && !isDisabled) {
521
+ setValue(value);
522
+ }
523
+ },
524
+ ...props
525
+ }
526
+ );
527
+ }
528
+ );
529
+ RadioGroupItem.displayName = "RadioGroupItem";
530
+
531
+ // src/components/Alternative/Alternative.tsx
532
+ var import_react2 = require("react");
533
+ var import_jsx_runtime4 = require("react/jsx-runtime");
534
+ var AlternativesList = ({
535
+ alternatives,
536
+ name,
537
+ defaultValue,
538
+ value,
539
+ onValueChange,
540
+ disabled = false,
541
+ layout = "default",
542
+ className = "",
543
+ mode = "interactive",
544
+ selectedValue
545
+ }) => {
546
+ const uniqueId = (0, import_react2.useId)();
547
+ const groupName = name || `alternatives-${uniqueId}`;
548
+ const isReadonly = mode === "readonly";
549
+ const getStatusStyles = (status, isReadonly2) => {
550
+ const hoverClass = isReadonly2 ? "" : "hover:bg-background-50";
551
+ switch (status) {
552
+ case "correct":
553
+ return "bg-success-background border-success-300";
554
+ case "incorrect":
555
+ return "bg-error-background border-error-300";
556
+ default:
557
+ return `bg-background border-border-100 ${hoverClass}`;
558
+ }
559
+ };
560
+ const getStatusBadge = (status) => {
561
+ switch (status) {
562
+ case "correct":
563
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Badge_default, { variant: "solid", action: "success", iconLeft: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_phosphor_react2.CheckCircle, {}), children: "Resposta correta" });
564
+ case "incorrect":
565
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Badge_default, { variant: "solid", action: "error", iconLeft: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_phosphor_react2.XCircle, {}), children: "Resposta incorreta" });
566
+ default:
567
+ return null;
568
+ }
569
+ };
570
+ const getLayoutClasses = () => {
571
+ switch (layout) {
572
+ case "compact":
573
+ return "gap-2";
574
+ case "detailed":
575
+ return "gap-4";
576
+ default:
577
+ return "gap-3.5";
578
+ }
579
+ };
580
+ const renderReadonlyAlternative = (alternative) => {
581
+ const alternativeId = alternative.value;
582
+ const isUserSelected = selectedValue === alternative.value;
583
+ const isCorrectAnswer = alternative.status === "correct";
584
+ let displayStatus = void 0;
585
+ if (isUserSelected && !isCorrectAnswer) {
586
+ displayStatus = "incorrect";
587
+ } else if (isCorrectAnswer) {
588
+ displayStatus = "correct";
589
+ }
590
+ const statusStyles = getStatusStyles(displayStatus, true);
591
+ const statusBadge = getStatusBadge(displayStatus);
592
+ const renderRadio = () => {
593
+ const radioClasses = `w-6 h-6 rounded-full border-2 cursor-default transition-all duration-200 flex items-center justify-center ${isUserSelected ? "border-primary-950 bg-background" : "border-border-400 bg-background"}`;
594
+ const dotClasses = "w-3 h-3 rounded-full bg-primary-950 transition-all duration-200";
595
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: radioClasses, children: isUserSelected && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: dotClasses }) });
596
+ };
597
+ if (layout === "detailed") {
598
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
599
+ "div",
600
+ {
601
+ className: `border-2 rounded-lg p-4 w-full ${statusStyles} ${alternative.disabled ? "opacity-50" : ""}`,
602
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-start justify-between gap-3", children: [
603
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-start gap-3 flex-1", children: [
604
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "mt-1", children: renderRadio() }),
605
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex-1", children: [
606
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "block font-medium text-text-950", children: alternative.label }),
607
+ alternative.description && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "text-sm text-text-600 mt-1", children: alternative.description })
608
+ ] })
609
+ ] }),
610
+ statusBadge && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "flex-shrink-0", children: statusBadge })
611
+ ] })
612
+ },
613
+ alternativeId
614
+ );
615
+ }
616
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
617
+ "div",
618
+ {
619
+ className: `flex flex-row justify-between items-start gap-2 p-2 rounded-lg w-full ${statusStyles} ${alternative.disabled ? "opacity-50" : ""}`,
620
+ children: [
621
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center gap-2 flex-1", children: [
622
+ renderRadio(),
623
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "flex-1", children: alternative.label })
624
+ ] }),
625
+ statusBadge && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "flex-shrink-0", children: statusBadge })
626
+ ]
627
+ },
628
+ alternativeId
629
+ );
630
+ };
631
+ if (isReadonly) {
632
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
633
+ "div",
634
+ {
635
+ className: `flex flex-col ${getLayoutClasses()} w-full ${className}`,
636
+ children: alternatives.map(
637
+ (alternative) => renderReadonlyAlternative(alternative)
638
+ )
639
+ }
640
+ );
641
+ }
642
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
643
+ RadioGroup,
644
+ {
645
+ name: groupName,
646
+ defaultValue,
647
+ value,
648
+ onValueChange,
649
+ disabled,
650
+ className: `flex flex-col ${getLayoutClasses()} ${className}`,
651
+ children: alternatives.map((alternative, index) => {
652
+ const alternativeId = alternative.value || `alt-${index}`;
653
+ const statusStyles = getStatusStyles(alternative.status, false);
654
+ const statusBadge = getStatusBadge(alternative.status);
655
+ if (layout === "detailed") {
656
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
657
+ "div",
658
+ {
659
+ className: `border-2 rounded-lg p-4 transition-all ${statusStyles} ${alternative.disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}`,
660
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-start justify-between gap-3", children: [
661
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-start gap-3 flex-1", children: [
662
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
663
+ RadioGroupItem,
664
+ {
665
+ value: alternative.value,
666
+ id: alternativeId,
667
+ disabled: alternative.disabled,
668
+ className: "mt-1"
669
+ }
670
+ ),
671
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex-1", children: [
672
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
673
+ "label",
674
+ {
675
+ htmlFor: alternativeId,
676
+ className: `block font-medium text-text-950 ${alternative.disabled ? "cursor-not-allowed" : "cursor-pointer"}`,
677
+ children: alternative.label
678
+ }
679
+ ),
680
+ alternative.description && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "text-sm text-text-600 mt-1", children: alternative.description })
681
+ ] })
682
+ ] }),
683
+ statusBadge && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "flex-shrink-0", children: statusBadge })
684
+ ] })
685
+ },
686
+ alternativeId
687
+ );
688
+ }
689
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
690
+ "div",
691
+ {
692
+ className: `flex flex-row justify-between gap-2 items-start p-2 rounded-lg transition-all ${statusStyles} ${alternative.disabled ? "opacity-50 cursor-not-allowed" : ""}`,
693
+ children: [
694
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center gap-2 flex-1", children: [
695
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
696
+ RadioGroupItem,
697
+ {
698
+ value: alternative.value,
699
+ id: alternativeId,
700
+ disabled: alternative.disabled
701
+ }
702
+ ),
703
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
704
+ "label",
705
+ {
706
+ htmlFor: alternativeId,
707
+ className: `flex-1 ${alternative.disabled ? "cursor-not-allowed" : "cursor-pointer"}`,
708
+ children: alternative.label
709
+ }
710
+ )
711
+ ] }),
712
+ statusBadge && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "flex-shrink-0", children: statusBadge })
713
+ ]
714
+ },
715
+ alternativeId
716
+ );
717
+ })
718
+ }
719
+ );
720
+ };
721
+ var HeaderAlternative = (0, import_react2.forwardRef)(
722
+ ({ className, title, subTitle, content, ...props }, ref) => {
723
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
724
+ "div",
725
+ {
726
+ ref,
727
+ className: `bg-background p-4 flex flex-col gap-4 rounded-xl ${className}`,
728
+ ...props,
729
+ children: [
730
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "flex flex-col", children: [
731
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "text-text-950 font-bold text-lg", children: title }),
732
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "text-text-700 text-sm ", children: subTitle })
733
+ ] }),
734
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "text-text-950 text-md", children: content })
735
+ ]
736
+ }
737
+ );
738
+ }
739
+ );
740
+ // Annotate the CommonJS export names for ESM import in node:
741
+ 0 && (module.exports = {
742
+ AlternativesList,
743
+ HeaderAlternative
744
+ });
745
+ //# sourceMappingURL=index.js.map