@aiready/components 0.14.4 → 0.14.6

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 (30) hide show
  1. package/dist/charts/ForceDirectedGraph.js.map +1 -1
  2. package/dist/components/checkbox.js +3 -1
  3. package/dist/components/checkbox.js.map +1 -1
  4. package/dist/components/separator.js +1 -0
  5. package/dist/components/separator.js.map +1 -1
  6. package/dist/components/switch.js +64 -42
  7. package/dist/components/switch.js.map +1 -1
  8. package/dist/hooks/useForceSimulation.js.map +1 -1
  9. package/dist/index.js +68 -43
  10. package/dist/index.js.map +1 -1
  11. package/package.json +2 -2
  12. package/src/charts/force-directed/useGraphInteractions.ts +2 -2
  13. package/src/charts/force-directed/useImperativeHandle.ts +1 -1
  14. package/src/components/__tests__/badge.test.tsx +38 -0
  15. package/src/components/__tests__/button.test.tsx +54 -0
  16. package/src/components/__tests__/card.test.tsx +56 -17
  17. package/src/components/__tests__/checkbox.test.tsx +28 -58
  18. package/src/components/__tests__/container.test.tsx +44 -51
  19. package/src/components/__tests__/grid.test.tsx +27 -134
  20. package/src/components/__tests__/input.test.tsx +35 -20
  21. package/src/components/__tests__/label.test.tsx +29 -35
  22. package/src/components/__tests__/modal.test.tsx +43 -72
  23. package/src/components/__tests__/select.test.tsx +51 -84
  24. package/src/components/__tests__/separator.test.tsx +23 -56
  25. package/src/components/__tests__/switch.test.tsx +28 -68
  26. package/src/components/__tests__/textarea.test.tsx +29 -77
  27. package/src/components/checkbox.tsx +3 -1
  28. package/src/components/separator.tsx +1 -0
  29. package/src/components/switch.tsx +62 -41
  30. package/src/hooks/useForceSimulation.ts +2 -2
package/dist/index.js CHANGED
@@ -631,6 +631,7 @@ var Separator = React2.forwardRef(
631
631
  ref,
632
632
  role: decorative ? "none" : "separator",
633
633
  "aria-orientation": orientation,
634
+ "data-orientation": orientation,
634
635
  className: cn(
635
636
  "shrink-0 bg-border",
636
637
  orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
@@ -651,8 +652,10 @@ var Checkbox = React2.forwardRef(
651
652
  type: "checkbox",
652
653
  id: checkboxId,
653
654
  ref,
655
+ role: "checkbox",
656
+ "aria-checked": props.checked ? "true" : "false",
654
657
  className: cn(
655
- "h-4 w-4 rounded border-gray-300 text-primary focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
658
+ "peer h-4 w-4 rounded border-gray-300 text-primary focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
656
659
  className
657
660
  ),
658
661
  ...props
@@ -721,48 +724,70 @@ var RadioGroup = React2.forwardRef(
721
724
  }
722
725
  );
723
726
  RadioGroup.displayName = "RadioGroup";
724
- var Switch = React2.forwardRef(
725
- ({ className, label, id, checked, onCheckedChange, onChange, ...props }, ref) => {
726
- const switchId = id || React2.useId();
727
- const handleChange = (e) => {
728
- onChange?.(e);
729
- onCheckedChange?.(e.target.checked);
730
- };
731
- return /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
732
- /* @__PURE__ */ jsxs(
733
- "label",
734
- {
735
- htmlFor: switchId,
736
- className: "relative inline-flex cursor-pointer items-center",
737
- children: [
738
- /* @__PURE__ */ jsx(
739
- "input",
740
- {
741
- type: "checkbox",
742
- id: switchId,
743
- ref,
744
- checked,
745
- onChange: handleChange,
746
- className: "peer sr-only",
747
- ...props
748
- }
749
- ),
750
- /* @__PURE__ */ jsx(
751
- "div",
752
- {
753
- className: cn(
754
- 'peer h-6 w-11 rounded-full bg-gray-200 after:absolute after:left-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:border after:border-gray-300 after:bg-white after:transition-all after:content-[""] peer-checked:bg-primary peer-checked:after:translate-x-full peer-checked:after:border-white peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-ring peer-focus:ring-offset-2 peer-disabled:cursor-not-allowed peer-disabled:opacity-50',
755
- className
756
- )
757
- }
758
- )
759
- ]
760
- }
761
- ),
762
- label && /* @__PURE__ */ jsx("span", { className: "ml-3 text-sm font-medium text-foreground", children: label })
763
- ] });
764
- }
765
- );
727
+ var Switch = React2.forwardRef((props, ref) => {
728
+ const {
729
+ className,
730
+ label,
731
+ id,
732
+ checked,
733
+ onCheckedChange,
734
+ onChange,
735
+ disabled,
736
+ ...restProps
737
+ } = props;
738
+ const switchId = id || React2.useId();
739
+ const isChecked = checked ?? false;
740
+ const { type: _type, ...buttonProps } = restProps;
741
+ const handleChange = (e) => {
742
+ onChange?.(e);
743
+ onCheckedChange?.(e.target.checked);
744
+ };
745
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
746
+ /* @__PURE__ */ jsxs(
747
+ "label",
748
+ {
749
+ htmlFor: switchId,
750
+ className: "relative inline-flex cursor-pointer items-center",
751
+ children: [
752
+ /* @__PURE__ */ jsx(
753
+ "input",
754
+ {
755
+ type: "checkbox",
756
+ id: switchId,
757
+ ref,
758
+ checked: isChecked,
759
+ onChange: handleChange,
760
+ className: "peer sr-only",
761
+ disabled
762
+ }
763
+ ),
764
+ /* @__PURE__ */ jsx(
765
+ "button",
766
+ {
767
+ type: "button",
768
+ role: "switch",
769
+ "aria-checked": isChecked,
770
+ disabled,
771
+ className: cn(
772
+ "peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
773
+ 'bg-gray-200 after:absolute after:left-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:border after:border-gray-300 after:bg-white after:transition-all after:content-[""] peer-checked:bg-primary peer-checked:after:translate-x-full peer-checked:after:border-white peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-ring peer-focus:ring-offset-2 peer-disabled:cursor-not-allowed peer-disabled:opacity-50',
774
+ className
775
+ ),
776
+ onClick: () => {
777
+ if (!disabled) {
778
+ const newChecked = !isChecked;
779
+ onCheckedChange?.(newChecked);
780
+ }
781
+ },
782
+ ...buttonProps
783
+ }
784
+ )
785
+ ]
786
+ }
787
+ ),
788
+ label && /* @__PURE__ */ jsx("span", { className: "ml-3 text-sm font-medium text-foreground", children: label })
789
+ ] });
790
+ });
766
791
  Switch.displayName = "Switch";
767
792
  var Textarea = React2.forwardRef(
768
793
  ({ className, ...props }, ref) => {