analytica-frontend-lib 1.0.87 → 1.0.89

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.
@@ -0,0 +1,415 @@
1
+ // src/components/CheckBox/CheckboxList.tsx
2
+ import {
3
+ forwardRef as forwardRef2,
4
+ useId as useId2,
5
+ useEffect,
6
+ useRef,
7
+ Children,
8
+ cloneElement,
9
+ isValidElement
10
+ } from "react";
11
+ import { create, useStore } from "zustand";
12
+
13
+ // src/components/CheckBox/CheckBox.tsx
14
+ import {
15
+ forwardRef,
16
+ useState,
17
+ useId
18
+ } from "react";
19
+
20
+ // src/utils/utils.ts
21
+ import { clsx } from "clsx";
22
+ import { twMerge } from "tailwind-merge";
23
+ function cn(...inputs) {
24
+ return twMerge(clsx(inputs));
25
+ }
26
+
27
+ // src/components/Text/Text.tsx
28
+ import { jsx } from "react/jsx-runtime";
29
+ var Text = ({
30
+ children,
31
+ size = "md",
32
+ weight = "normal",
33
+ color = "text-text-950",
34
+ as,
35
+ className = "",
36
+ ...props
37
+ }) => {
38
+ let sizeClasses = "";
39
+ let weightClasses = "";
40
+ const sizeClassMap = {
41
+ "2xs": "text-2xs",
42
+ xs: "text-xs",
43
+ sm: "text-sm",
44
+ md: "text-md",
45
+ lg: "text-lg",
46
+ xl: "text-xl",
47
+ "2xl": "text-2xl",
48
+ "3xl": "text-3xl",
49
+ "4xl": "text-4xl",
50
+ "5xl": "text-5xl",
51
+ "6xl": "text-6xl"
52
+ };
53
+ sizeClasses = sizeClassMap[size] ?? sizeClassMap.md;
54
+ const weightClassMap = {
55
+ hairline: "font-hairline",
56
+ light: "font-light",
57
+ normal: "font-normal",
58
+ medium: "font-medium",
59
+ semibold: "font-semibold",
60
+ bold: "font-bold",
61
+ extrabold: "font-extrabold",
62
+ black: "font-black"
63
+ };
64
+ weightClasses = weightClassMap[weight] ?? weightClassMap.normal;
65
+ const baseClasses = "font-primary";
66
+ const Component = as ?? "p";
67
+ return /* @__PURE__ */ jsx(
68
+ Component,
69
+ {
70
+ className: cn(baseClasses, sizeClasses, weightClasses, color, className),
71
+ ...props,
72
+ children
73
+ }
74
+ );
75
+ };
76
+ var Text_default = Text;
77
+
78
+ // src/components/CheckBox/CheckBox.tsx
79
+ import { Check, Minus } from "phosphor-react";
80
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
81
+ var SIZE_CLASSES = {
82
+ small: {
83
+ checkbox: "w-4 h-4",
84
+ // 16px x 16px
85
+ textSize: "sm",
86
+ spacing: "gap-1.5",
87
+ // 6px
88
+ borderWidth: "border-2",
89
+ iconSize: 14,
90
+ // pixels for Phosphor icons
91
+ labelHeight: "h-[21px]"
92
+ },
93
+ medium: {
94
+ checkbox: "w-5 h-5",
95
+ // 20px x 20px
96
+ textSize: "md",
97
+ spacing: "gap-2",
98
+ // 8px
99
+ borderWidth: "border-2",
100
+ iconSize: 16,
101
+ // pixels for Phosphor icons
102
+ labelHeight: "h-6"
103
+ },
104
+ large: {
105
+ checkbox: "w-6 h-6",
106
+ // 24px x 24px
107
+ textSize: "lg",
108
+ spacing: "gap-2",
109
+ // 8px
110
+ borderWidth: "border-[3px]",
111
+ // 3px border
112
+ iconSize: 20,
113
+ // pixels for Phosphor icons
114
+ labelHeight: "h-[27px]"
115
+ }
116
+ };
117
+ var BASE_CHECKBOX_CLASSES = "rounded border cursor-pointer transition-all duration-200 flex items-center justify-center focus:outline-none";
118
+ var STATE_CLASSES = {
119
+ default: {
120
+ unchecked: "border-border-400 bg-background hover:border-border-500",
121
+ checked: "border-primary-950 bg-primary-950 text-text hover:border-primary-800 hover:bg-primary-800"
122
+ },
123
+ hovered: {
124
+ unchecked: "border-border-500 bg-background",
125
+ checked: "border-primary-800 bg-primary-800 text-text"
126
+ },
127
+ focused: {
128
+ unchecked: "border-indicator-info bg-background ring-2 ring-indicator-info/20",
129
+ checked: "border-indicator-info bg-primary-950 text-text ring-2 ring-indicator-info/20"
130
+ },
131
+ invalid: {
132
+ unchecked: "border-error-700 bg-background hover:border-error-600",
133
+ checked: "border-error-700 bg-primary-950 text-text"
134
+ },
135
+ disabled: {
136
+ unchecked: "border-border-400 bg-background cursor-not-allowed opacity-40",
137
+ checked: "border-primary-600 bg-primary-600 text-text cursor-not-allowed opacity-40"
138
+ }
139
+ };
140
+ var CheckBox = forwardRef(
141
+ ({
142
+ label,
143
+ size = "medium",
144
+ state = "default",
145
+ indeterminate = false,
146
+ errorMessage,
147
+ helperText,
148
+ className = "",
149
+ labelClassName = "",
150
+ checked: checkedProp,
151
+ disabled,
152
+ id,
153
+ onChange,
154
+ ...props
155
+ }, ref) => {
156
+ const generatedId = useId();
157
+ const inputId = id ?? `checkbox-${generatedId}`;
158
+ const [internalChecked, setInternalChecked] = useState(false);
159
+ const isControlled = checkedProp !== void 0;
160
+ const checked = isControlled ? checkedProp : internalChecked;
161
+ const handleChange = (event) => {
162
+ if (!isControlled) {
163
+ setInternalChecked(event.target.checked);
164
+ }
165
+ onChange?.(event);
166
+ };
167
+ const currentState = disabled ? "disabled" : state;
168
+ const sizeClasses = SIZE_CLASSES[size];
169
+ const checkVariant = checked || indeterminate ? "checked" : "unchecked";
170
+ const stylingClasses = STATE_CLASSES[currentState][checkVariant];
171
+ const borderWidthClass = state === "focused" || state === "hovered" && size === "large" ? "border-[3px]" : sizeClasses.borderWidth;
172
+ const checkboxClasses = cn(
173
+ BASE_CHECKBOX_CLASSES,
174
+ sizeClasses.checkbox,
175
+ borderWidthClass,
176
+ stylingClasses,
177
+ className
178
+ );
179
+ const renderIcon = () => {
180
+ if (indeterminate) {
181
+ return /* @__PURE__ */ jsx2(
182
+ Minus,
183
+ {
184
+ size: sizeClasses.iconSize,
185
+ weight: "bold",
186
+ color: "currentColor"
187
+ }
188
+ );
189
+ }
190
+ if (checked) {
191
+ return /* @__PURE__ */ jsx2(
192
+ Check,
193
+ {
194
+ size: sizeClasses.iconSize,
195
+ weight: "bold",
196
+ color: "currentColor"
197
+ }
198
+ );
199
+ }
200
+ return null;
201
+ };
202
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
203
+ /* @__PURE__ */ jsxs(
204
+ "div",
205
+ {
206
+ className: cn(
207
+ "flex flex-row items-center",
208
+ sizeClasses.spacing,
209
+ disabled ? "opacity-40" : ""
210
+ ),
211
+ children: [
212
+ /* @__PURE__ */ jsx2(
213
+ "input",
214
+ {
215
+ ref,
216
+ type: "checkbox",
217
+ id: inputId,
218
+ checked,
219
+ disabled,
220
+ onChange: handleChange,
221
+ className: "sr-only",
222
+ ...props
223
+ }
224
+ ),
225
+ /* @__PURE__ */ jsx2("label", { htmlFor: inputId, className: checkboxClasses, children: renderIcon() }),
226
+ label && /* @__PURE__ */ jsx2(
227
+ "div",
228
+ {
229
+ className: cn(
230
+ "flex flex-row items-center",
231
+ sizeClasses.labelHeight
232
+ ),
233
+ children: /* @__PURE__ */ jsx2(
234
+ Text_default,
235
+ {
236
+ as: "label",
237
+ htmlFor: inputId,
238
+ size: sizeClasses.textSize,
239
+ weight: "normal",
240
+ className: cn(
241
+ "cursor-pointer select-none leading-[150%] flex items-center font-roboto",
242
+ labelClassName
243
+ ),
244
+ children: label
245
+ }
246
+ )
247
+ }
248
+ )
249
+ ]
250
+ }
251
+ ),
252
+ errorMessage && /* @__PURE__ */ jsx2(
253
+ Text_default,
254
+ {
255
+ size: "sm",
256
+ weight: "normal",
257
+ className: "mt-1.5",
258
+ color: "text-error-600",
259
+ children: errorMessage
260
+ }
261
+ ),
262
+ helperText && !errorMessage && /* @__PURE__ */ jsx2(
263
+ Text_default,
264
+ {
265
+ size: "sm",
266
+ weight: "normal",
267
+ className: "mt-1.5",
268
+ color: "text-text-500",
269
+ children: helperText
270
+ }
271
+ )
272
+ ] });
273
+ }
274
+ );
275
+ CheckBox.displayName = "CheckBox";
276
+ var CheckBox_default = CheckBox;
277
+
278
+ // src/components/CheckBox/CheckboxList.tsx
279
+ import { jsx as jsx3 } from "react/jsx-runtime";
280
+ var createCheckboxListStore = (name, defaultValues, disabled, onValuesChange) => create((set, get) => ({
281
+ values: defaultValues,
282
+ setValues: (values) => {
283
+ if (!get().disabled) {
284
+ set({ values });
285
+ get().onValuesChange?.(values);
286
+ }
287
+ },
288
+ toggleValue: (value) => {
289
+ if (!get().disabled) {
290
+ const currentValues = get().values;
291
+ const newValues = currentValues.includes(value) ? currentValues.filter((v) => v !== value) : [...currentValues, value];
292
+ set({ values: newValues });
293
+ get().onValuesChange?.(newValues);
294
+ }
295
+ },
296
+ onValuesChange,
297
+ disabled,
298
+ name
299
+ }));
300
+ var useCheckboxListStore = (externalStore) => {
301
+ if (!externalStore) {
302
+ throw new Error("CheckboxListItem must be used within a CheckboxList");
303
+ }
304
+ return externalStore;
305
+ };
306
+ var injectStore = (children, store) => Children.map(children, (child) => {
307
+ if (!isValidElement(child)) return child;
308
+ const typedChild = child;
309
+ const shouldInject = typedChild.type === CheckboxListItem;
310
+ return cloneElement(typedChild, {
311
+ ...shouldInject ? { store } : {},
312
+ ...typedChild.props.children ? { children: injectStore(typedChild.props.children, store) } : {}
313
+ });
314
+ });
315
+ var CheckboxList = forwardRef2(
316
+ ({
317
+ values: propValues,
318
+ defaultValues = [],
319
+ onValuesChange,
320
+ name: propName,
321
+ disabled = false,
322
+ className = "",
323
+ children,
324
+ ...props
325
+ }, ref) => {
326
+ const generatedId = useId2();
327
+ const name = propName || `checkbox-list-${generatedId}`;
328
+ const storeRef = useRef(null);
329
+ storeRef.current ??= createCheckboxListStore(
330
+ name,
331
+ defaultValues,
332
+ disabled,
333
+ onValuesChange
334
+ );
335
+ const store = storeRef.current;
336
+ const { setValues } = useStore(store, (s) => s);
337
+ useEffect(() => {
338
+ const currentValues = store.getState().values;
339
+ if (currentValues.length > 0 && onValuesChange) {
340
+ onValuesChange(currentValues);
341
+ }
342
+ }, []);
343
+ useEffect(() => {
344
+ if (propValues !== void 0) {
345
+ setValues(propValues);
346
+ }
347
+ }, [propValues, setValues]);
348
+ useEffect(() => {
349
+ store.setState({ disabled });
350
+ }, [disabled, store]);
351
+ return /* @__PURE__ */ jsx3(
352
+ "div",
353
+ {
354
+ ref,
355
+ className: cn("flex flex-col gap-2 w-full", className),
356
+ "aria-label": name,
357
+ ...props,
358
+ children: injectStore(children, store)
359
+ }
360
+ );
361
+ }
362
+ );
363
+ CheckboxList.displayName = "CheckboxList";
364
+ var CheckboxListItem = forwardRef2(
365
+ ({
366
+ value,
367
+ store: externalStore,
368
+ disabled: itemDisabled,
369
+ size = "medium",
370
+ state = "default",
371
+ className = "",
372
+ id,
373
+ ...props
374
+ }, ref) => {
375
+ const store = useCheckboxListStore(externalStore);
376
+ const {
377
+ values: groupValues,
378
+ toggleValue,
379
+ disabled: groupDisabled,
380
+ name
381
+ } = useStore(store);
382
+ const generatedId = useId2();
383
+ const inputId = id ?? `checkbox-item-${generatedId}`;
384
+ const isChecked = groupValues.includes(value);
385
+ const isDisabled = groupDisabled || itemDisabled;
386
+ const currentState = isDisabled ? "disabled" : state;
387
+ return /* @__PURE__ */ jsx3(
388
+ CheckBox_default,
389
+ {
390
+ ref,
391
+ id: inputId,
392
+ name,
393
+ value,
394
+ checked: isChecked,
395
+ disabled: isDisabled,
396
+ size,
397
+ state: currentState,
398
+ className,
399
+ onChange: () => {
400
+ if (!isDisabled) {
401
+ toggleValue(value);
402
+ }
403
+ },
404
+ ...props
405
+ }
406
+ );
407
+ }
408
+ );
409
+ CheckboxListItem.displayName = "CheckboxListItem";
410
+ var CheckboxList_default = CheckboxList;
411
+ export {
412
+ CheckboxListItem,
413
+ CheckboxList_default as default,
414
+ useCheckboxListStore
415
+ };
@@ -4757,7 +4757,7 @@ var QuizFooter = (0, import_react11.forwardRef)(
4757
4757
  onClose: () => setModalNavigateOpen(false),
4758
4758
  title: "Quest\xF5es",
4759
4759
  size: "lg",
4760
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col w-full h-full", children: [
4760
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col w-full h-full not-lg:max-h-[calc(100vh-200px)] lg:max-h-[calc(687px-76px)]", children: [
4761
4761
  /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-row justify-between items-center py-6 pt-6 pb-4 border-b border-border-200", children: [
4762
4762
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-text-950 font-bold text-lg", children: "Filtrar por" }),
4763
4763
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "max-w-[266px]", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Select_default, { value: filterType, onValueChange: setFilterType, children: [
@@ -4769,7 +4769,7 @@ var QuizFooter = (0, import_react11.forwardRef)(
4769
4769
  ] })
4770
4770
  ] }) })
4771
4771
  ] }),
4772
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex flex-col gap-2 not-lg:h-[calc(100vh-200px)] lg:max-h-[687px] overflow-y-auto", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
4772
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex flex-col gap-2 overflow-y-auto", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
4773
4773
  QuizQuestionList,
4774
4774
  {
4775
4775
  filterType,
@@ -4782,7 +4782,7 @@ var QuizFooter = forwardRef9(
4782
4782
  onClose: () => setModalNavigateOpen(false),
4783
4783
  title: "Quest\xF5es",
4784
4784
  size: "lg",
4785
- children: /* @__PURE__ */ jsxs13("div", { className: "flex flex-col w-full h-full", children: [
4785
+ children: /* @__PURE__ */ jsxs13("div", { className: "flex flex-col w-full h-full not-lg:max-h-[calc(100vh-200px)] lg:max-h-[calc(687px-76px)]", children: [
4786
4786
  /* @__PURE__ */ jsxs13("div", { className: "flex flex-row justify-between items-center py-6 pt-6 pb-4 border-b border-border-200", children: [
4787
4787
  /* @__PURE__ */ jsx16("p", { className: "text-text-950 font-bold text-lg", children: "Filtrar por" }),
4788
4788
  /* @__PURE__ */ jsx16("span", { className: "max-w-[266px]", children: /* @__PURE__ */ jsxs13(Select_default, { value: filterType, onValueChange: setFilterType, children: [
@@ -4794,7 +4794,7 @@ var QuizFooter = forwardRef9(
4794
4794
  ] })
4795
4795
  ] }) })
4796
4796
  ] }),
4797
- /* @__PURE__ */ jsx16("div", { className: "flex flex-col gap-2 not-lg:h-[calc(100vh-200px)] lg:max-h-[687px] overflow-y-auto", children: /* @__PURE__ */ jsx16(
4797
+ /* @__PURE__ */ jsx16("div", { className: "flex flex-col gap-2 overflow-y-auto", children: /* @__PURE__ */ jsx16(
4798
4798
  QuizQuestionList,
4799
4799
  {
4800
4800
  filterType,
package/dist/index.css CHANGED
@@ -3460,9 +3460,9 @@
3460
3460
  border-radius: var(--radius-xl);
3461
3461
  }
3462
3462
  }
3463
- .not-lg\:h-\[calc\(100vh-200px\)\] {
3463
+ .not-lg\:max-h-\[calc\(100vh-200px\)\] {
3464
3464
  @media not (width >= 64rem) {
3465
- height: calc(100vh - 200px);
3465
+ max-height: calc(100vh - 200px);
3466
3466
  }
3467
3467
  }
3468
3468
  .not-lg\:max-w-\[calc\(100vw-32px\)\] {
@@ -8039,9 +8039,9 @@
8039
8039
  height: calc(var(--spacing) * 6);
8040
8040
  }
8041
8041
  }
8042
- .lg\:max-h-\[687px\] {
8042
+ .lg\:max-h-\[calc\(687px-76px\)\] {
8043
8043
  @media (width >= 64rem) {
8044
- max-height: 687px;
8044
+ max-height: calc(687px - 76px);
8045
8045
  }
8046
8046
  }
8047
8047
  .lg\:w-3\.5 {