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