@cripty2001/utils 0.0.101 → 0.0.103

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.
@@ -11,6 +11,7 @@ function Button({ title, onClick, className }) {
11
11
  if (loading)
12
12
  return;
13
13
  setLoading(true);
14
+ setError(null);
14
15
  (async () => {
15
16
  const p = onClick();
16
17
  if (p instanceof Promise) {
@@ -1,4 +1,5 @@
1
- export type FormComponentPropsInput<Variants extends Record<string, string>> = {
1
+ import { InputComponentPropsVariants } from "./input";
2
+ export type FormComponentPropsInput = {
2
3
  label: string;
3
4
  required: boolean;
4
5
  key: string;
@@ -8,12 +9,12 @@ export type FormComponentPropsInput<Variants extends Record<string, string>> = {
8
9
  type: "select";
9
10
  options: string[];
10
11
  });
11
- export type FormComponentProps<T extends Record<string, string>, Variants extends Record<string, string>> = {
12
- inputs: FormComponentPropsInput<Variants>[];
12
+ export type FormComponentProps<T extends Record<string, string>, V extends InputComponentPropsVariants> = {
13
+ inputs: FormComponentPropsInput[];
13
14
  onSubmit: (values: T) => void;
14
15
  submitLabel: string;
15
16
  value: T;
16
17
  setValue: React.Dispatch<React.SetStateAction<T>>;
17
- variants: Variants;
18
+ variants: V;
18
19
  };
19
- export default function FormComponent<T extends Record<string, string>, Variants extends Record<string, string>>(props: FormComponentProps<T, Variants>): import("react/jsx-runtime").JSX.Element;
20
+ export default function FormComponent<T extends Record<string, string>, V extends InputComponentPropsVariants>(props: FormComponentProps<T, V>): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,7 @@
1
- export type InputComponentProps<Variants extends Record<string, string>> = {
1
+ export type InputComponentPropsVariants = Record<string, string> & {
2
+ default: string;
3
+ };
4
+ export type InputComponentProps<V extends InputComponentPropsVariants> = {
2
5
  label?: string;
3
6
  value: string;
4
7
  setValue: (value: string) => void;
@@ -9,8 +12,8 @@ export type InputComponentProps<Variants extends Record<string, string>> = {
9
12
  className: string;
10
13
  }) => React.ReactNode;
11
14
  copy?: boolean;
12
- variant?: keyof Variants;
15
+ variant?: keyof V;
13
16
  validate?: (value: string) => void;
14
- variants: Variants;
17
+ variants: V;
15
18
  };
16
- export default function InputComponent<Variants extends Record<string, string>>(props: InputComponentProps<Variants>): import("react/jsx-runtime").JSX.Element;
19
+ export default function InputComponent<Variants extends InputComponentPropsVariants>(props: InputComponentProps<Variants>): import("react/jsx-runtime").JSX.Element;
@@ -6,8 +6,8 @@ const utils_1 = require("@cripty2001/utils");
6
6
  const lucide_react_1 = require("lucide-react");
7
7
  const react_1 = require("react");
8
8
  function InputComponent(props) {
9
- const variant = props.variant ?? "";
10
- const baseClassName = props.variants[variant] ?? "";
9
+ const variant = props.variant;
10
+ const baseClassName = props.variants[variant ?? "default"];
11
11
  const [error, setError] = (0, react_1.useState)(null);
12
12
  return ((0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-2", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-row justify-between items-center gap-2", children: [props.label &&
13
13
  (0, jsx_runtime_1.jsx)("label", { className: "block mb-1 text-sm font-medium text-gray-700 dark:text-gray-300", children: props.label }), props.copy &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cripty2001/utils",
3
- "version": "0.0.101",
3
+ "version": "0.0.103",
4
4
  "description": "Internal Set of utils. If you need them use them, otherwise go to the next package ;)",
5
5
  "homepage": "https://github.com/cripty2001/utils#readme",
6
6
  "bugs": {