analytica-frontend-lib 1.0.16 → 1.0.17

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/index.mjs CHANGED
@@ -206,25 +206,196 @@ var Text = ({
206
206
  );
207
207
  };
208
208
 
209
- // src/components/Table/Table.tsx
210
- import { forwardRef as forwardRef2 } from "react";
209
+ // src/components/CheckBox/CheckBox.tsx
210
+ import {
211
+ forwardRef as forwardRef2,
212
+ useState,
213
+ useId
214
+ } from "react";
215
+ import { Check, Minus } from "phosphor-react";
211
216
  import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
212
- var Table = forwardRef2(
213
- ({ className, children, ...props }, ref) => /* @__PURE__ */ jsx5("div", { className: "border border-border-200 rounded-xl relative w-full overflow-hidden", children: /* @__PURE__ */ jsxs3(
217
+ var SIZE_CLASSES2 = {
218
+ small: {
219
+ checkbox: "w-4 h-4",
220
+ // 16px x 16px
221
+ textSize: "sm",
222
+ spacing: "gap-1.5",
223
+ // 6px
224
+ borderWidth: "border-2",
225
+ iconSize: 14,
226
+ // pixels for Phosphor icons
227
+ labelHeight: "h-[21px]"
228
+ },
229
+ medium: {
230
+ checkbox: "w-5 h-5",
231
+ // 20px x 20px
232
+ textSize: "md",
233
+ spacing: "gap-2",
234
+ // 8px
235
+ borderWidth: "border-2",
236
+ iconSize: 16,
237
+ // pixels for Phosphor icons
238
+ labelHeight: "h-6"
239
+ },
240
+ large: {
241
+ checkbox: "w-6 h-6",
242
+ // 24px x 24px
243
+ textSize: "lg",
244
+ spacing: "gap-2",
245
+ // 8px
246
+ borderWidth: "border-[3px]",
247
+ // 3px border
248
+ iconSize: 20,
249
+ // pixels for Phosphor icons
250
+ labelHeight: "h-[27px]"
251
+ }
252
+ };
253
+ var BASE_CHECKBOX_CLASSES = "rounded border cursor-pointer transition-all duration-200 flex items-center justify-center focus:outline-none";
254
+ var STATE_CLASSES = {
255
+ default: {
256
+ unchecked: "border-border-400 bg-background hover:border-border-500",
257
+ checked: "border-primary-950 bg-primary-950 text-text hover:border-primary-800 hover:bg-primary-800"
258
+ },
259
+ hovered: {
260
+ unchecked: "border-border-500 bg-background",
261
+ checked: "border-primary-800 bg-primary-800 text-text"
262
+ },
263
+ focused: {
264
+ unchecked: "border-indicator-info bg-background ring-2 ring-indicator-info/20",
265
+ checked: "border-indicator-info bg-primary-950 text-text ring-2 ring-indicator-info/20"
266
+ },
267
+ invalid: {
268
+ unchecked: "border-error-700 bg-background hover:border-error-600",
269
+ checked: "border-error-700 bg-primary-950 text-text"
270
+ },
271
+ disabled: {
272
+ unchecked: "border-border-400 bg-background cursor-not-allowed opacity-40",
273
+ checked: "border-primary-600 bg-primary-600 text-text cursor-not-allowed opacity-40"
274
+ }
275
+ };
276
+ var CheckBox = forwardRef2(
277
+ ({
278
+ label,
279
+ size = "medium",
280
+ state = "default",
281
+ indeterminate = false,
282
+ errorMessage,
283
+ helperText,
284
+ className = "",
285
+ labelClassName = "",
286
+ checked: checkedProp,
287
+ disabled,
288
+ id,
289
+ onChange,
290
+ ...props
291
+ }, ref) => {
292
+ const generatedId = useId();
293
+ const inputId = id ?? `checkbox-${generatedId}`;
294
+ const [internalChecked, setInternalChecked] = useState(false);
295
+ const isControlled = checkedProp !== void 0;
296
+ const checked = isControlled ? checkedProp : internalChecked;
297
+ const handleChange = (event) => {
298
+ if (!isControlled) {
299
+ setInternalChecked(event.target.checked);
300
+ }
301
+ onChange?.(event);
302
+ };
303
+ const currentState = disabled ? "disabled" : state;
304
+ const sizeClasses = SIZE_CLASSES2[size];
305
+ const checkVariant = checked || indeterminate ? "checked" : "unchecked";
306
+ const stylingClasses = STATE_CLASSES[currentState][checkVariant];
307
+ const borderWidthClass = state === "focused" || state === "hovered" && size === "large" ? "border-[3px]" : sizeClasses.borderWidth;
308
+ const checkboxClasses = `${BASE_CHECKBOX_CLASSES} ${sizeClasses.checkbox} ${borderWidthClass} ${stylingClasses} ${className}`;
309
+ const renderIcon = () => {
310
+ if (indeterminate) {
311
+ return /* @__PURE__ */ jsx5(
312
+ Minus,
313
+ {
314
+ size: sizeClasses.iconSize,
315
+ weight: "bold",
316
+ color: "currentColor"
317
+ }
318
+ );
319
+ }
320
+ if (checked) {
321
+ return /* @__PURE__ */ jsx5(
322
+ Check,
323
+ {
324
+ size: sizeClasses.iconSize,
325
+ weight: "bold",
326
+ color: "currentColor"
327
+ }
328
+ );
329
+ }
330
+ return null;
331
+ };
332
+ return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col", children: [
333
+ /* @__PURE__ */ jsxs3(
334
+ "div",
335
+ {
336
+ className: `flex flex-row items-center ${sizeClasses.spacing} ${disabled ? "opacity-40" : ""}`,
337
+ children: [
338
+ /* @__PURE__ */ jsx5(
339
+ "input",
340
+ {
341
+ ref,
342
+ type: "checkbox",
343
+ id: inputId,
344
+ checked,
345
+ disabled,
346
+ onChange: handleChange,
347
+ className: "sr-only",
348
+ ...props
349
+ }
350
+ ),
351
+ /* @__PURE__ */ jsx5("label", { htmlFor: inputId, className: checkboxClasses, children: renderIcon() }),
352
+ label && /* @__PURE__ */ jsx5(
353
+ "div",
354
+ {
355
+ className: `flex flex-row items-center ${sizeClasses.labelHeight}`,
356
+ children: /* @__PURE__ */ jsx5(
357
+ Text,
358
+ {
359
+ as: "label",
360
+ htmlFor: inputId,
361
+ size: sizeClasses.textSize,
362
+ weight: "normal",
363
+ color: "black",
364
+ className: `cursor-pointer select-none leading-[150%] flex items-center font-roboto ${labelClassName}`,
365
+ children: label
366
+ }
367
+ )
368
+ }
369
+ )
370
+ ]
371
+ }
372
+ ),
373
+ errorMessage && /* @__PURE__ */ jsx5(Text, { size: "sm", weight: "normal", className: "mt-1.5 text-error-600", children: errorMessage }),
374
+ helperText && !errorMessage && /* @__PURE__ */ jsx5(Text, { size: "sm", weight: "normal", className: "mt-1.5 text-text-500", children: helperText })
375
+ ] });
376
+ }
377
+ );
378
+ CheckBox.displayName = "CheckBox";
379
+
380
+ // src/components/Table/Table.tsx
381
+ import { forwardRef as forwardRef3 } from "react";
382
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
383
+ var Table = forwardRef3(
384
+ ({ className, children, ...props }, ref) => /* @__PURE__ */ jsx6("div", { className: "border border-border-200 rounded-xl relative w-full overflow-hidden", children: /* @__PURE__ */ jsxs4(
214
385
  "table",
215
386
  {
216
387
  ref,
217
388
  className: `w-full caption-bottom text-sm ${className ?? ""}`,
218
389
  ...props,
219
390
  children: [
220
- /* @__PURE__ */ jsx5("caption", { className: "sr-only", children: "My Table" }),
391
+ /* @__PURE__ */ jsx6("caption", { className: "sr-only", children: "My Table" }),
221
392
  children
222
393
  ]
223
394
  }
224
395
  ) })
225
396
  );
226
397
  Table.displayName = "Table";
227
- var TableHeader = forwardRef2(({ className, ...props }, ref) => /* @__PURE__ */ jsx5(
398
+ var TableHeader = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */ jsx6(
228
399
  "thead",
229
400
  {
230
401
  ref,
@@ -233,7 +404,7 @@ var TableHeader = forwardRef2(({ className, ...props }, ref) => /* @__PURE__ */
233
404
  }
234
405
  ));
235
406
  TableHeader.displayName = "TableHeader";
236
- var TableBody = forwardRef2(({ className, ...props }, ref) => /* @__PURE__ */ jsx5(
407
+ var TableBody = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */ jsx6(
237
408
  "tbody",
238
409
  {
239
410
  ref,
@@ -242,7 +413,7 @@ var TableBody = forwardRef2(({ className, ...props }, ref) => /* @__PURE__ */ js
242
413
  }
243
414
  ));
244
415
  TableBody.displayName = "TableBody";
245
- var TableFooter = forwardRef2(({ className, ...props }, ref) => /* @__PURE__ */ jsx5(
416
+ var TableFooter = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */ jsx6(
246
417
  "tfoot",
247
418
  {
248
419
  ref,
@@ -257,9 +428,9 @@ var VARIANT_STATES_ROW = {
257
428
  invalid: "border-b-2 border-indicator-error",
258
429
  disabled: "border-b border-border-100 bg-background-50 opacity-50 cursor-not-allowed"
259
430
  };
260
- var TableRow = forwardRef2(
431
+ var TableRow = forwardRef3(
261
432
  ({ state = "default", className, ...props }, ref) => {
262
- return /* @__PURE__ */ jsx5(
433
+ return /* @__PURE__ */ jsx6(
263
434
  "tr",
264
435
  {
265
436
  ref,
@@ -276,7 +447,7 @@ var TableRow = forwardRef2(
276
447
  }
277
448
  );
278
449
  TableRow.displayName = "TableRow";
279
- var TableHead = forwardRef2(({ className, ...props }, ref) => /* @__PURE__ */ jsx5(
450
+ var TableHead = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */ jsx6(
280
451
  "th",
281
452
  {
282
453
  ref,
@@ -285,7 +456,7 @@ var TableHead = forwardRef2(({ className, ...props }, ref) => /* @__PURE__ */ js
285
456
  }
286
457
  ));
287
458
  TableHead.displayName = "TableHead";
288
- var TableCell = forwardRef2(({ className, ...props }, ref) => /* @__PURE__ */ jsx5(
459
+ var TableCell = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */ jsx6(
289
460
  "td",
290
461
  {
291
462
  ref,
@@ -294,7 +465,7 @@ var TableCell = forwardRef2(({ className, ...props }, ref) => /* @__PURE__ */ js
294
465
  }
295
466
  ));
296
467
  TableCell.displayName = "TableCell";
297
- var TableCaption = forwardRef2(({ className, ...props }, ref) => /* @__PURE__ */ jsx5(
468
+ var TableCaption = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */ jsx6(
298
469
  "caption",
299
470
  {
300
471
  ref,
@@ -307,20 +478,20 @@ TableCaption.displayName = "TableCaption";
307
478
  // src/components/DropdownMenu/DropdownMenu.tsx
308
479
  import {
309
480
  createContext,
310
- useState,
481
+ useState as useState2,
311
482
  useCallback,
312
483
  useContext,
313
- forwardRef as forwardRef3,
484
+ forwardRef as forwardRef4,
314
485
  useEffect,
315
486
  useRef,
316
487
  useMemo
317
488
  } from "react";
318
- import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
489
+ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
319
490
  var DropdownMenuContext = createContext(
320
491
  void 0
321
492
  );
322
493
  var DropdownMenu = ({ children, open, onOpenChange }) => {
323
- const [internalOpen, setInternalOpen] = useState(false);
494
+ const [internalOpen, setInternalOpen] = useState2(false);
324
495
  const isControlled = open !== void 0;
325
496
  const currentOpen = isControlled ? open : internalOpen;
326
497
  const setOpen = useCallback(
@@ -355,14 +526,14 @@ var DropdownMenu = ({ children, open, onOpenChange }) => {
355
526
  () => ({ open: currentOpen, setOpen }),
356
527
  [currentOpen, setOpen]
357
528
  );
358
- return /* @__PURE__ */ jsx6(DropdownMenuContext.Provider, { value, children: /* @__PURE__ */ jsx6("div", { className: "relative", ref: menuRef, children }) });
529
+ return /* @__PURE__ */ jsx7(DropdownMenuContext.Provider, { value, children: /* @__PURE__ */ jsx7("div", { className: "relative", ref: menuRef, children }) });
359
530
  };
360
- var DropdownMenuTrigger = forwardRef3(({ className, children, onClick, ...props }, ref) => {
531
+ var DropdownMenuTrigger = forwardRef4(({ className, children, onClick, ...props }, ref) => {
361
532
  const context = useContext(DropdownMenuContext);
362
533
  if (!context)
363
534
  throw new Error("DropdownMenuTrigger must be used within a DropdownMenu");
364
535
  const { open, setOpen } = context;
365
- return /* @__PURE__ */ jsx6(
536
+ return /* @__PURE__ */ jsx7(
366
537
  "button",
367
538
  {
368
539
  ref,
@@ -394,7 +565,7 @@ var ALIGN_CLASSES = {
394
565
  center: "left-1/2 -translate-x-1/2",
395
566
  end: "right-0"
396
567
  };
397
- var MenuLabel = forwardRef3(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx6(
568
+ var MenuLabel = forwardRef4(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx7(
398
569
  "fieldset",
399
570
  {
400
571
  ref,
@@ -404,7 +575,7 @@ var MenuLabel = forwardRef3(({ className, inset, ...props }, ref) => /* @__PURE_
404
575
  }
405
576
  ));
406
577
  MenuLabel.displayName = "MenuLabel";
407
- var MenuContent = forwardRef3(
578
+ var MenuContent = forwardRef4(
408
579
  ({
409
580
  className,
410
581
  align = "start",
@@ -414,7 +585,7 @@ var MenuContent = forwardRef3(
414
585
  ...props
415
586
  }, ref) => {
416
587
  const { open } = useContext(DropdownMenuContext);
417
- const [isVisible, setIsVisible] = useState(open);
588
+ const [isVisible, setIsVisible] = useState2(open);
418
589
  useEffect(() => {
419
590
  if (open) {
420
591
  setIsVisible(true);
@@ -429,7 +600,7 @@ var MenuContent = forwardRef3(
429
600
  const horizontal = ALIGN_CLASSES[align];
430
601
  return `absolute ${vertical} ${horizontal}`;
431
602
  };
432
- return /* @__PURE__ */ jsx6(
603
+ return /* @__PURE__ */ jsx7(
433
604
  "div",
434
605
  {
435
606
  ref,
@@ -453,7 +624,7 @@ var MenuContent = forwardRef3(
453
624
  }
454
625
  );
455
626
  MenuContent.displayName = "MenuContent";
456
- var MenuItem = forwardRef3(
627
+ var MenuItem = forwardRef4(
457
628
  ({
458
629
  className,
459
630
  inset,
@@ -474,7 +645,7 @@ var MenuItem = forwardRef3(
474
645
  }
475
646
  onClick?.(e);
476
647
  };
477
- return /* @__PURE__ */ jsxs4(
648
+ return /* @__PURE__ */ jsxs5(
478
649
  "div",
479
650
  {
480
651
  ref,
@@ -503,7 +674,7 @@ var MenuItem = forwardRef3(
503
674
  }
504
675
  );
505
676
  MenuItem.displayName = "MenuItem";
506
- var MenuSeparator = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */ jsx6(
677
+ var MenuSeparator = forwardRef4(({ className, ...props }, ref) => /* @__PURE__ */ jsx7(
507
678
  "div",
508
679
  {
509
680
  ref,
@@ -514,9 +685,9 @@ var MenuSeparator = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ *
514
685
  MenuSeparator.displayName = "MenuSeparator";
515
686
 
516
687
  // src/components/NavButton/NavButton.tsx
517
- import { forwardRef as forwardRef4 } from "react";
518
- import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
519
- var NavButton = forwardRef4(
688
+ import { forwardRef as forwardRef5 } from "react";
689
+ import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
690
+ var NavButton = forwardRef5(
520
691
  ({ icon, label, selected = false, className = "", disabled, ...props }, ref) => {
521
692
  const baseClasses = [
522
693
  "flex",
@@ -543,7 +714,7 @@ var NavButton = forwardRef4(
543
714
  ];
544
715
  const stateClasses = selected ? ["bg-primary-50", "text-primary-950"] : [];
545
716
  const allClasses = [...baseClasses, ...stateClasses].join(" ");
546
- return /* @__PURE__ */ jsxs5(
717
+ return /* @__PURE__ */ jsxs6(
547
718
  "button",
548
719
  {
549
720
  ref,
@@ -553,8 +724,8 @@ var NavButton = forwardRef4(
553
724
  "aria-pressed": selected,
554
725
  ...props,
555
726
  children: [
556
- /* @__PURE__ */ jsx7("span", { className: "flex items-center justify-center w-5 h-5", children: icon }),
557
- /* @__PURE__ */ jsx7("span", { className: "whitespace-nowrap", children: label })
727
+ /* @__PURE__ */ jsx8("span", { className: "flex items-center justify-center w-5 h-5", children: icon }),
728
+ /* @__PURE__ */ jsx8("span", { className: "whitespace-nowrap", children: label })
558
729
  ]
559
730
  }
560
731
  );
@@ -563,9 +734,9 @@ var NavButton = forwardRef4(
563
734
  NavButton.displayName = "NavButton";
564
735
 
565
736
  // src/components/IconButton/IconButton.tsx
566
- import { forwardRef as forwardRef5 } from "react";
567
- import { jsx as jsx8 } from "react/jsx-runtime";
568
- var IconButton = forwardRef5(
737
+ import { forwardRef as forwardRef6 } from "react";
738
+ import { jsx as jsx9 } from "react/jsx-runtime";
739
+ var IconButton = forwardRef6(
569
740
  ({ icon, size = "md", active = false, className = "", disabled, ...props }, ref) => {
570
741
  const baseClasses = [
571
742
  "inline-flex",
@@ -597,7 +768,7 @@ var IconButton = forwardRef5(
597
768
  ...activeClasses
598
769
  ].join(" ");
599
770
  const ariaLabel = props["aria-label"] ?? "Bot\xE3o de a\xE7\xE3o";
600
- return /* @__PURE__ */ jsx8(
771
+ return /* @__PURE__ */ jsx9(
601
772
  "button",
602
773
  {
603
774
  ref,
@@ -607,7 +778,7 @@ var IconButton = forwardRef5(
607
778
  "aria-pressed": active,
608
779
  "aria-label": ariaLabel,
609
780
  ...props,
610
- children: /* @__PURE__ */ jsx8("span", { className: "flex items-center justify-center", children: icon })
781
+ children: /* @__PURE__ */ jsx9("span", { className: "flex items-center justify-center", children: icon })
611
782
  }
612
783
  );
613
784
  }
@@ -615,6 +786,7 @@ var IconButton = forwardRef5(
615
786
  IconButton.displayName = "IconButton";
616
787
  export {
617
788
  Button,
789
+ CheckBox,
618
790
  DropdownMenu,
619
791
  DropdownMenuTrigger,
620
792
  IconButton,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "analytica-frontend-lib",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "Repositório público dos componentes utilizados nas plataformas da Analytica Ensino",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "./dist/index.js",