@cripty2001/utils 0.0.110 → 0.0.112

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.
@@ -21,5 +21,17 @@ function Button({ title, onClick, className }) {
21
21
  .catch(e => setError(e instanceof Error ? e.message : "Unknown error"))
22
22
  .finally(() => setLoading(false));
23
23
  };
24
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { onClick: handleClick, className: `cursor-pointer ${className}`, children: loading ? (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "w-4 h-4 animate-spin" }) : (0, jsx_runtime_1.jsx)("div", { children: title }) }), error && (0, jsx_runtime_1.jsx)("div", { className: "text-red-500", children: error })] }));
24
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { onClick: handleClick, className: className, style: {
25
+ display: 'flex',
26
+ alignItems: 'center',
27
+ justifyContent: 'center',
28
+ textAlign: 'center',
29
+ cursor: 'pointer',
30
+ }, children: loading ? (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { style: {
31
+ width: '1rem',
32
+ height: '1rem',
33
+ animation: 'spin 1s linear infinite',
34
+ } }) : (0, jsx_runtime_1.jsx)("div", { children: title }) }), error && (0, jsx_runtime_1.jsx)("div", { style: {
35
+ color: '#ef4444'
36
+ }, children: error })] }));
25
37
  }
@@ -12,7 +12,7 @@ function FormComponent(props) {
12
12
  const variants = (0, react_1.useMemo)(() => ({
13
13
  default: props.variant
14
14
  }), [props.variant]);
15
- return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', gap: '1rem' }, children: [props.inputs.map(input => (() => {
15
+ return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', gap: '1rem' }, children: [props.inputs.map((input, index) => (() => {
16
16
  const value = props.value[input.key];
17
17
  const setValue = (v) => props.setValue(prev => ({
18
18
  ...prev,
@@ -23,12 +23,12 @@ function FormComponent(props) {
23
23
  case "email":
24
24
  case "password":
25
25
  case "tel":
26
- return (0, jsx_runtime_1.jsx)(input_1.default, { label: input.label, value: value, setValue: setValue, variant: "default", variants: variants, children: ({ value, setValue, className }) => ((0, jsx_runtime_1.jsx)("input", { type: input.type, value: value, onChange: (e) => setValue(e.target.value), required: input.required, className: className, placeholder: input.label })) });
26
+ return (0, jsx_runtime_1.jsx)(input_1.default, { label: input.label, value: value, setValue: setValue, variant: "default", variants: variants, children: ({ value, setValue, className }) => ((0, jsx_runtime_1.jsx)("input", { type: input.type, value: value, onChange: (e) => setValue(e.target.value), required: input.required, className: className, placeholder: input.label })) }, index);
27
27
  case "select":
28
28
  return (0, jsx_runtime_1.jsx)(input_1.default, { label: input.label, value: value, setValue: setValue, variant: "default", variants: variants, required: input.required, validate: (v) => {
29
29
  if (!input.options.includes(v))
30
30
  throw new Error("Invalid option");
31
- }, children: ({ value, setValue, className }) => ((0, jsx_runtime_1.jsx)("select", { value: value, onChange: (e) => setValue(e.target.value), required: input.required, className: className, children: input.options.map(option => ((0, jsx_runtime_1.jsx)("option", { value: option, children: option }, option))) })) });
31
+ }, children: ({ value, setValue, className }) => ((0, jsx_runtime_1.jsx)("select", { value: value, onChange: (e) => setValue(e.target.value), required: input.required, className: className, children: input.options.map(option => ((0, jsx_runtime_1.jsx)("option", { value: option, children: option }, option))) })) }, index);
32
32
  default:
33
33
  return (0, jsx_runtime_1.jsx)("div", { style: { color: '#ef4444', backgroundColor: 'white' }, children: "Unknown input type" });
34
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cripty2001/utils",
3
- "version": "0.0.110",
3
+ "version": "0.0.112",
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": {