next-helios-fe 1.3.4 → 1.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-helios-fe",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -16,7 +16,7 @@ interface ModalProps {
16
16
  };
17
17
  action?: React.ReactNode;
18
18
  open: boolean;
19
- onClose: (open: boolean) => void;
19
+ onClose: () => void;
20
20
  }
21
21
 
22
22
  export const Modal: React.FC<ModalProps> = ({
@@ -32,7 +32,7 @@ export const Modal: React.FC<ModalProps> = ({
32
32
  if (!options?.disableClose) {
33
33
  document.addEventListener("keydown", (e) => {
34
34
  if (e.key === "Escape") {
35
- onClose(false);
35
+ onClose && onClose();
36
36
  }
37
37
  });
38
38
  }
@@ -71,7 +71,7 @@ export const Modal: React.FC<ModalProps> = ({
71
71
  type="button"
72
72
  className="flex justify-center items-center rounded-full px-1 py-1 text-slate-400 hover:bg-secondary-light"
73
73
  onClick={() => {
74
- onClose(false);
74
+ onClose && onClose();
75
75
  }}
76
76
  >
77
77
  <Icon icon="pajamas:close" className="text-2xl" />
@@ -97,7 +97,7 @@ export const Modal: React.FC<ModalProps> = ({
97
97
  border: true,
98
98
  }}
99
99
  onClick={() => {
100
- onClose(false);
100
+ onClose && onClose();
101
101
  }}
102
102
  >
103
103
  Close
@@ -1,9 +1,10 @@
1
1
  "use client";
2
- import React from "react";
2
+ import React, { useState, useEffect } from "react";
3
3
 
4
4
  export interface CheckboxProps
5
5
  extends React.InputHTMLAttributes<HTMLInputElement> {
6
6
  options?: {
7
+ variant?: "basic" | "switch";
7
8
  disableHover?: boolean;
8
9
  };
9
10
  label?: string;
@@ -16,11 +17,32 @@ export const Checkbox: React.FC<CheckboxProps> = ({
16
17
  theme,
17
18
  ...rest
18
19
  }) => {
20
+ const [tempChecked, setTempChecked] = useState(false);
21
+
22
+ useEffect(() => {
23
+ if (rest.checked) {
24
+ setTempChecked(rest.checked as boolean);
25
+ return;
26
+ } else if (rest.defaultChecked) {
27
+ setTempChecked(rest.defaultChecked as boolean);
28
+ return;
29
+ }
30
+ }, [rest.value, rest.defaultValue]);
31
+
32
+ useEffect(() => {
33
+ if (tempChecked) {
34
+ rest.onChange &&
35
+ rest.onChange({
36
+ target: { checked: tempChecked } as HTMLInputElement,
37
+ } as any);
38
+ }
39
+ }, [tempChecked]);
40
+
19
41
  return (
20
42
  <label
21
- className={`flex items-center w-fit ${
43
+ className={`group/checkbox flex items-center ${
22
44
  !options?.disableHover ? "gap-2" : "gap-4"
23
- }`}
45
+ } ${options?.variant === "switch" ? "justify-between w-full" : "w-fit"}`}
24
46
  >
25
47
  <div
26
48
  className={`flex justify-center items-center ${
@@ -28,7 +50,7 @@ export const Checkbox: React.FC<CheckboxProps> = ({
28
50
  } ${
29
51
  !options?.disableHover &&
30
52
  "w-8 h-8 rounded-full hover:bg-secondary-light"
31
- }`}
53
+ } ${options?.variant === "switch" && "hidden"}`}
32
54
  >
33
55
  <input
34
56
  type="checkbox"
@@ -36,6 +58,10 @@ export const Checkbox: React.FC<CheckboxProps> = ({
36
58
  theme && "border-0"
37
59
  }`}
38
60
  style={{ backgroundColor: theme }}
61
+ checked={tempChecked}
62
+ onChange={(e) => {
63
+ setTempChecked(e.target.checked);
64
+ }}
39
65
  {...rest}
40
66
  />
41
67
  </div>
@@ -48,6 +74,13 @@ export const Checkbox: React.FC<CheckboxProps> = ({
48
74
  {label}
49
75
  </span>
50
76
  )}
77
+ <div
78
+ className={`flex items-center justify-start w-8 h-5 border rounded-full bg-secondary-bg overflow-hidden cursor-pointer duration-300 group-has-[:checked]/checkbox:justify-end group-has-[:checked]/checkbox:bg-primary ${
79
+ options?.variant !== "switch" && "hidden"
80
+ }`}
81
+ >
82
+ <div className="w-4 h-4 rounded-full bg-primary duration-300 group-has-[:checked]/checkbox:bg-secondary-bg"></div>
83
+ </div>
51
84
  </label>
52
85
  );
53
86
  };
@@ -4,7 +4,7 @@ import { Icon } from "@iconify/react";
4
4
 
5
5
  export interface FileProps extends React.InputHTMLAttributes<HTMLInputElement> {
6
6
  options?: {
7
- variant?: "default" | "drag&drop";
7
+ variant?: "basic" | "drag&drop";
8
8
  maxSizeInMb?: number;
9
9
  buttonOnly?: boolean;
10
10
  width?: "full" | "fit";