lkd-web-kit 0.3.4 → 0.3.7
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.cjs.js +118 -0
- package/dist/index.cjs10.js +16 -0
- package/dist/index.cjs11.js +16 -0
- package/dist/index.cjs12.js +16 -0
- package/dist/index.cjs13.js +16 -0
- package/dist/index.cjs14.js +118 -0
- package/dist/index.cjs15.js +16 -0
- package/dist/index.cjs16.js +18 -0
- package/dist/index.cjs17.js +70 -0
- package/dist/index.cjs18.js +14 -0
- package/dist/index.cjs19.js +66 -0
- package/dist/index.cjs2.js +43 -0
- package/dist/index.cjs20.js +21 -0
- package/dist/index.cjs21.js +30 -0
- package/dist/index.cjs22.js +23 -0
- package/dist/index.cjs23.js +15 -0
- package/dist/index.cjs24.js +16 -0
- package/dist/index.cjs25.js +16 -0
- package/dist/index.cjs26.js +18 -0
- package/dist/index.cjs27.js +17 -0
- package/dist/index.cjs28.js +17 -0
- package/dist/index.cjs29.js +17 -0
- package/dist/index.cjs3.js +12 -0
- package/dist/index.cjs30.js +17 -0
- package/dist/index.cjs31.js +17 -0
- package/dist/index.cjs32.js +17 -0
- package/dist/index.cjs33.js +17 -0
- package/dist/index.cjs34.js +17 -0
- package/dist/index.cjs35.js +29 -0
- package/dist/index.cjs36.js +17 -0
- package/dist/index.cjs37.js +17 -0
- package/dist/index.cjs38.js +51 -0
- package/dist/index.cjs39.js +38 -0
- package/dist/index.cjs4.js +40 -0
- package/dist/index.cjs40.js +15 -0
- package/dist/index.cjs41.js +23 -0
- package/dist/index.cjs42.js +39 -0
- package/dist/index.cjs43.js +24 -0
- package/dist/index.cjs44.js +14 -0
- package/dist/index.cjs45.js +19 -0
- package/dist/index.cjs46.js +43 -0
- package/dist/index.cjs47.js +14 -0
- package/dist/index.cjs48.js +20 -0
- package/dist/index.cjs49.js +11 -0
- package/dist/index.cjs5.js +54 -0
- package/dist/index.cjs50.js +45 -0
- package/dist/index.cjs51.js +19 -0
- package/dist/index.cjs52.js +24 -0
- package/dist/index.cjs53.js +7 -0
- package/dist/index.cjs54.js +65 -0
- package/dist/index.cjs6.js +18 -0
- package/dist/index.cjs7.js +18 -0
- package/dist/index.cjs8.js +17 -0
- package/dist/index.cjs9.js +16 -0
- package/dist/index.es.js +52 -0
- package/dist/index.es10.js +12 -0
- package/dist/index.es11.js +12 -0
- package/dist/index.es12.js +12 -0
- package/dist/index.es13.js +12 -0
- package/dist/index.es14.js +114 -0
- package/dist/index.es15.js +12 -0
- package/dist/index.es16.js +14 -0
- package/dist/index.es17.js +66 -0
- package/dist/index.es18.js +10 -0
- package/dist/index.es19.js +60 -0
- package/dist/index.es2.js +39 -0
- package/dist/index.es20.js +16 -0
- package/dist/index.es21.js +26 -0
- package/dist/index.es22.js +19 -0
- package/dist/index.es23.js +11 -0
- package/dist/index.es24.js +12 -0
- package/dist/index.es25.js +12 -0
- package/dist/index.es26.js +14 -0
- package/dist/index.es27.js +13 -0
- package/dist/index.es28.js +13 -0
- package/dist/index.es29.js +13 -0
- package/dist/index.es3.js +8 -0
- package/dist/index.es30.js +13 -0
- package/dist/index.es31.js +13 -0
- package/dist/index.es32.js +13 -0
- package/dist/index.es33.js +13 -0
- package/dist/index.es34.js +13 -0
- package/dist/index.es35.js +23 -0
- package/dist/index.es36.js +13 -0
- package/dist/index.es37.js +13 -0
- package/dist/index.es38.js +47 -0
- package/dist/index.es39.js +34 -0
- package/dist/index.es4.js +36 -0
- package/dist/index.es40.js +11 -0
- package/dist/index.es41.js +19 -0
- package/dist/index.es42.js +35 -0
- package/dist/index.es43.js +20 -0
- package/dist/index.es44.js +10 -0
- package/dist/index.es45.js +15 -0
- package/dist/index.es46.js +39 -0
- package/dist/index.es47.js +10 -0
- package/dist/index.es48.js +15 -0
- package/dist/index.es49.js +7 -0
- package/dist/index.es5.js +50 -0
- package/dist/index.es50.js +40 -0
- package/dist/index.es51.js +15 -0
- package/dist/index.es52.js +20 -0
- package/dist/index.es53.js +3 -0
- package/dist/index.es54.js +63 -0
- package/dist/index.es6.js +14 -0
- package/dist/index.es7.js +14 -0
- package/dist/index.es8.js +13 -0
- package/dist/index.es9.js +12 -0
- package/dist/node_modules/@mantine/notifications/styles.css +42 -0
- package/package.json +15 -5
- package/dist/lkd-web-kit.css +0 -1
- package/dist/main.js +0 -779
- /package/dist/{main.d.ts → index.d.ts} +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { createContext, useContext } from 'react';
|
|
4
|
+
|
|
5
|
+
const PageData = createContext(void 0);
|
|
6
|
+
const PageDataProvider = ({
|
|
7
|
+
value,
|
|
8
|
+
children
|
|
9
|
+
}) => /* @__PURE__ */ jsx(PageData.Provider, { value, children });
|
|
10
|
+
const usePageData = () => {
|
|
11
|
+
const data = useContext(PageData);
|
|
12
|
+
if (data === void 0) throw new Error("Out of context: usePageData");
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { PageDataProvider, usePageData };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Box } from '@mantine/core';
|
|
4
|
+
import { FormProvider } from 'react-hook-form';
|
|
5
|
+
|
|
6
|
+
const Form = ({
|
|
7
|
+
methods,
|
|
8
|
+
onSubmit = () => {
|
|
9
|
+
},
|
|
10
|
+
onSubmitError,
|
|
11
|
+
...rest
|
|
12
|
+
}) => {
|
|
13
|
+
return /* @__PURE__ */ jsx(FormProvider, { ...methods, children: /* @__PURE__ */ jsx(
|
|
14
|
+
Box,
|
|
15
|
+
{
|
|
16
|
+
component: "form",
|
|
17
|
+
onSubmit: (e) => {
|
|
18
|
+
e.stopPropagation();
|
|
19
|
+
methods.handleSubmit(onSubmit, onSubmitError)(e);
|
|
20
|
+
},
|
|
21
|
+
...rest
|
|
22
|
+
}
|
|
23
|
+
) });
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { Form };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Button } from '@mantine/core';
|
|
4
|
+
import { useFormContext } from 'react-hook-form';
|
|
5
|
+
|
|
6
|
+
const FormButtonSubmit = (props) => {
|
|
7
|
+
const { formState } = useFormContext();
|
|
8
|
+
const { isSubmitting } = formState;
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
Button,
|
|
11
|
+
{
|
|
12
|
+
loading: isSubmitting,
|
|
13
|
+
type: "submit",
|
|
14
|
+
...props
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { FormButtonSubmit };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const zodValidator = (schema) => {
|
|
2
|
+
return (values) => {
|
|
3
|
+
const result = schema.safeParse(values);
|
|
4
|
+
if (result.success) return;
|
|
5
|
+
const { error } = result;
|
|
6
|
+
const firstError = error.issues[0];
|
|
7
|
+
return firstError?.message;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { zodValidator };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const nullableButRequired = (schema, message = "Campo requerido") => schema.nullable().superRefine((val, ctx) => {
|
|
4
|
+
if (val === null) {
|
|
5
|
+
ctx.addIssue({
|
|
6
|
+
code: z.ZodIssueCode.custom,
|
|
7
|
+
message
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export { nullableButRequired };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const optionalButRequired = (schema, message = "Campo requerido") => schema.optional().superRefine((val, ctx) => {
|
|
4
|
+
if (val === void 0) {
|
|
5
|
+
ctx.addIssue({
|
|
6
|
+
code: z.ZodIssueCode.custom,
|
|
7
|
+
message
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export { optionalButRequired };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Checkbox } from '@mantine/core';
|
|
3
|
+
import { withForm } from './index.es38.js';
|
|
4
|
+
|
|
5
|
+
const FormCheckbox = withForm(({ field, props }) => /* @__PURE__ */ jsx(
|
|
6
|
+
Checkbox,
|
|
7
|
+
{
|
|
8
|
+
...field,
|
|
9
|
+
checked: field.value,
|
|
10
|
+
...props
|
|
11
|
+
}
|
|
12
|
+
));
|
|
13
|
+
|
|
14
|
+
export { FormCheckbox };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { MyDatePickerInput } from './index.es6.js';
|
|
3
|
+
import { withForm } from './index.es38.js';
|
|
4
|
+
|
|
5
|
+
const FormDatePickerInput = withForm(({ field, props }) => /* @__PURE__ */ jsx(
|
|
6
|
+
MyDatePickerInput,
|
|
7
|
+
{
|
|
8
|
+
...field,
|
|
9
|
+
...props
|
|
10
|
+
}
|
|
11
|
+
));
|
|
12
|
+
|
|
13
|
+
export { FormDatePickerInput };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { MyDateTimePicker } from './index.es7.js';
|
|
3
|
+
import { withForm } from './index.es38.js';
|
|
4
|
+
|
|
5
|
+
const FormDateTimePicker = withForm(({ field, props }) => /* @__PURE__ */ jsx(
|
|
6
|
+
MyDateTimePicker,
|
|
7
|
+
{
|
|
8
|
+
...field,
|
|
9
|
+
...props
|
|
10
|
+
}
|
|
11
|
+
));
|
|
12
|
+
|
|
13
|
+
export { FormDateTimePicker };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { MyNumberInput } from './index.es9.js';
|
|
3
|
+
import { withForm } from './index.es38.js';
|
|
4
|
+
|
|
5
|
+
const FormNumberInput = withForm(({ field, props }) => /* @__PURE__ */ jsx(
|
|
6
|
+
MyNumberInput,
|
|
7
|
+
{
|
|
8
|
+
...field,
|
|
9
|
+
...props
|
|
10
|
+
}
|
|
11
|
+
));
|
|
12
|
+
|
|
13
|
+
export { FormNumberInput };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Center, Loader } from '@mantine/core';
|
|
3
|
+
|
|
4
|
+
const InfinityLoader = ({ infinity, loaderProps, ...props }) => {
|
|
5
|
+
return /* @__PURE__ */ jsx(Center, { ...props, children: infinity.isFetching ? /* @__PURE__ */ jsx(Loader, { ...loaderProps }) : !infinity.hasNextPage && (infinity.data?.pages.length ?? 0) > 1 && /* @__PURE__ */ jsx("p", { children: "No hay más resultados" }) });
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export { InfinityLoader };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Radio } from '@mantine/core';
|
|
3
|
+
import { withForm } from './index.es38.js';
|
|
4
|
+
|
|
5
|
+
const FormRadioGroup = withForm(({ field, props }) => /* @__PURE__ */ jsx(
|
|
6
|
+
Radio.Group,
|
|
7
|
+
{
|
|
8
|
+
...field,
|
|
9
|
+
...props
|
|
10
|
+
}
|
|
11
|
+
));
|
|
12
|
+
|
|
13
|
+
export { FormRadioGroup };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { MySelect } from './index.es10.js';
|
|
3
|
+
import { withForm } from './index.es38.js';
|
|
4
|
+
|
|
5
|
+
const FormSelect = withForm(({ field, props }) => /* @__PURE__ */ jsx(
|
|
6
|
+
MySelect,
|
|
7
|
+
{
|
|
8
|
+
...field,
|
|
9
|
+
...props
|
|
10
|
+
}
|
|
11
|
+
));
|
|
12
|
+
|
|
13
|
+
export { FormSelect };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { SelectInfinity } from './index.es14.js';
|
|
3
|
+
import { withForm } from './index.es38.js';
|
|
4
|
+
|
|
5
|
+
const FormSelectInfinity = withForm(({ field, props }) => /* @__PURE__ */ jsx(
|
|
6
|
+
SelectInfinity,
|
|
7
|
+
{
|
|
8
|
+
...field,
|
|
9
|
+
...props
|
|
10
|
+
}
|
|
11
|
+
));
|
|
12
|
+
|
|
13
|
+
export { FormSelectInfinity };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { MyTextarea } from './index.es11.js';
|
|
3
|
+
import { withForm } from './index.es38.js';
|
|
4
|
+
|
|
5
|
+
const FormTextarea = withForm(({ field, props }) => /* @__PURE__ */ jsx(
|
|
6
|
+
MyTextarea,
|
|
7
|
+
{
|
|
8
|
+
...field,
|
|
9
|
+
...props
|
|
10
|
+
}
|
|
11
|
+
));
|
|
12
|
+
|
|
13
|
+
export { FormTextarea };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { MyTextInput } from './index.es12.js';
|
|
3
|
+
import { withForm } from './index.es38.js';
|
|
4
|
+
|
|
5
|
+
const FormTextInput = withForm(({ field, props }) => /* @__PURE__ */ jsx(
|
|
6
|
+
MyTextInput,
|
|
7
|
+
{
|
|
8
|
+
...field,
|
|
9
|
+
...props
|
|
10
|
+
}
|
|
11
|
+
));
|
|
12
|
+
|
|
13
|
+
export { FormTextInput };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { MyTimeInput } from './index.es13.js';
|
|
3
|
+
import { withForm } from './index.es38.js';
|
|
4
|
+
|
|
5
|
+
const FormTimeInput = withForm(({ field, props }) => /* @__PURE__ */ jsx(
|
|
6
|
+
MyTimeInput,
|
|
7
|
+
{
|
|
8
|
+
...field,
|
|
9
|
+
...props
|
|
10
|
+
}
|
|
11
|
+
));
|
|
12
|
+
const timeInputToNumber = (timeInput) => {
|
|
13
|
+
const [hours, minutes] = timeInput.split(":").map(Number);
|
|
14
|
+
const result = hours + minutes / 60;
|
|
15
|
+
return Number(result.toFixed(2));
|
|
16
|
+
};
|
|
17
|
+
const numberToTimeInput = (number) => {
|
|
18
|
+
const hours = Math.floor(number);
|
|
19
|
+
const minutes = Math.round((number - hours) * 60);
|
|
20
|
+
return `${hours.toString().padStart(2, "0")}:${minutes.toString().padStart(2, "0")}`;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { FormTimeInput, numberToTimeInput, timeInputToNumber };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { MyMultiSelect } from './index.es15.js';
|
|
3
|
+
import { withForm } from './index.es38.js';
|
|
4
|
+
|
|
5
|
+
const FormMultiSelect = withForm(({ field, props }) => /* @__PURE__ */ jsx(
|
|
6
|
+
MyMultiSelect,
|
|
7
|
+
{
|
|
8
|
+
...field,
|
|
9
|
+
...props
|
|
10
|
+
}
|
|
11
|
+
));
|
|
12
|
+
|
|
13
|
+
export { FormMultiSelect };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { MyMonthPickerInput } from './index.es16.js';
|
|
3
|
+
import { withForm } from './index.es38.js';
|
|
4
|
+
|
|
5
|
+
const FormMonthPickerInput = withForm(({ field, props }) => /* @__PURE__ */ jsx(
|
|
6
|
+
MyMonthPickerInput,
|
|
7
|
+
{
|
|
8
|
+
...field,
|
|
9
|
+
...props
|
|
10
|
+
}
|
|
11
|
+
));
|
|
12
|
+
|
|
13
|
+
export { FormMonthPickerInput };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Controller } from 'react-hook-form';
|
|
4
|
+
import { zodValidator } from './index.es23.js';
|
|
5
|
+
|
|
6
|
+
const withForm = (WrappedComponent, getControllerProps) => {
|
|
7
|
+
const FormField = (props) => {
|
|
8
|
+
const { validate, name = "", placeholder, label, description, ...withFormRestProps } = props;
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
Controller,
|
|
11
|
+
{
|
|
12
|
+
name,
|
|
13
|
+
defaultValue: "",
|
|
14
|
+
rules: {
|
|
15
|
+
validate: validate && !props.disabled ? zodValidator(validate) : void 0
|
|
16
|
+
},
|
|
17
|
+
disabled: props.disabled,
|
|
18
|
+
...getControllerProps?.(props),
|
|
19
|
+
render: (renderProps) => {
|
|
20
|
+
const {
|
|
21
|
+
fieldState: { error }
|
|
22
|
+
} = renderProps;
|
|
23
|
+
const fieldProps = {
|
|
24
|
+
...renderProps,
|
|
25
|
+
props: {
|
|
26
|
+
...props,
|
|
27
|
+
validate: void 0
|
|
28
|
+
},
|
|
29
|
+
field: {
|
|
30
|
+
...renderProps.field,
|
|
31
|
+
label,
|
|
32
|
+
placeholder,
|
|
33
|
+
description,
|
|
34
|
+
error: error?.message
|
|
35
|
+
},
|
|
36
|
+
...withFormRestProps
|
|
37
|
+
};
|
|
38
|
+
return /* @__PURE__ */ jsx(WrappedComponent, { ...fieldProps });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
FormField.displayName = `WithForm(${WrappedComponent.displayName})`;
|
|
44
|
+
return FormField;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { withForm };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
|
|
5
|
+
const withModalManager = (WrappedComponent) => {
|
|
6
|
+
const Component = ({
|
|
7
|
+
removeModal,
|
|
8
|
+
opened,
|
|
9
|
+
...props
|
|
10
|
+
}) => {
|
|
11
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
12
|
+
const onClose = () => {
|
|
13
|
+
setIsOpen(false);
|
|
14
|
+
setTimeout(() => removeModal(), 200);
|
|
15
|
+
props.onClose?.();
|
|
16
|
+
};
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (opened) setTimeout(() => setIsOpen(true), 0);
|
|
19
|
+
else onClose();
|
|
20
|
+
}, [opened]);
|
|
21
|
+
return /* @__PURE__ */ jsx(
|
|
22
|
+
WrappedComponent,
|
|
23
|
+
{
|
|
24
|
+
...props,
|
|
25
|
+
opened: isOpen,
|
|
26
|
+
onClose
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
Component.displayName = `WithModalManager(${WrappedComponent.displayName})`;
|
|
31
|
+
return Component;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { withModalManager };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Stack, NavLink } from '@mantine/core';
|
|
4
|
+
import Link from 'next/link';
|
|
5
|
+
import { usePathname } from 'next/navigation';
|
|
6
|
+
|
|
7
|
+
const NavItems = ({ items, activeStrategy = "includes" }) => {
|
|
8
|
+
const pathname = usePathname();
|
|
9
|
+
return /* @__PURE__ */ jsx(Stack, { gap: 0, children: items.map(({ href, isActive, ...navLinkProps }) => {
|
|
10
|
+
if (href) {
|
|
11
|
+
const active = isActive ?? (activeStrategy === "equals" ? href === pathname : href.includes(pathname));
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
NavLink,
|
|
14
|
+
{
|
|
15
|
+
active,
|
|
16
|
+
component: Link,
|
|
17
|
+
prefetch: false,
|
|
18
|
+
href,
|
|
19
|
+
...navLinkProps
|
|
20
|
+
},
|
|
21
|
+
navLinkProps.label
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return /* @__PURE__ */ jsx(
|
|
25
|
+
NavLink,
|
|
26
|
+
{
|
|
27
|
+
active: isActive,
|
|
28
|
+
component: "button",
|
|
29
|
+
...navLinkProps
|
|
30
|
+
},
|
|
31
|
+
navLinkProps.label
|
|
32
|
+
);
|
|
33
|
+
}) });
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { NavItems };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useOnScrollProgress } from './index.es42.js';
|
|
3
|
+
|
|
4
|
+
const useFetchNextPageOnScroll = ({
|
|
5
|
+
infinity,
|
|
6
|
+
scrollRef,
|
|
7
|
+
disabled = false
|
|
8
|
+
}) => {
|
|
9
|
+
useOnScrollProgress({
|
|
10
|
+
triggerPercentage: 0.9,
|
|
11
|
+
callback: () => {
|
|
12
|
+
if (infinity.hasNextPage) infinity.fetchNextPage();
|
|
13
|
+
},
|
|
14
|
+
scrollRef,
|
|
15
|
+
disabled
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { useFetchNextPageOnScroll };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
const useOnScrollProgress = ({
|
|
5
|
+
triggerPercentage,
|
|
6
|
+
callback,
|
|
7
|
+
scrollRef,
|
|
8
|
+
disabled = false
|
|
9
|
+
}) => {
|
|
10
|
+
if (triggerPercentage < 0 || triggerPercentage > 1)
|
|
11
|
+
throw new Error("El porcentaje debe estar entre 0 y 1");
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (disabled || scrollRef && scrollRef.current === null) return;
|
|
14
|
+
let hasTriggered = false;
|
|
15
|
+
const handleScroll = () => {
|
|
16
|
+
const el = scrollRef?.current;
|
|
17
|
+
const target = el ?? document.documentElement;
|
|
18
|
+
const scrollHeight = target.scrollHeight - target.clientHeight;
|
|
19
|
+
const scrollTop = el ? target.scrollTop : window.scrollY;
|
|
20
|
+
const scrollProgress = scrollHeight > 0 ? Math.min(1, scrollTop / scrollHeight) : 0;
|
|
21
|
+
if (!hasTriggered && scrollProgress >= triggerPercentage) {
|
|
22
|
+
callback();
|
|
23
|
+
hasTriggered = true;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const scrollTarget = scrollRef?.current ?? window;
|
|
27
|
+
scrollTarget.addEventListener("scroll", handleScroll);
|
|
28
|
+
handleScroll();
|
|
29
|
+
return () => {
|
|
30
|
+
scrollTarget.removeEventListener("scroll", handleScroll);
|
|
31
|
+
};
|
|
32
|
+
}, [triggerPercentage, callback, scrollRef, disabled]);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { useOnScrollProgress };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useSearchParams } from 'next/navigation';
|
|
3
|
+
|
|
4
|
+
const useUpdateSearchParams = () => {
|
|
5
|
+
const searchParams = useSearchParams();
|
|
6
|
+
const updateSearchParams = (newSearchparams) => {
|
|
7
|
+
const params = new URLSearchParams(searchParams.toString());
|
|
8
|
+
Object.entries(newSearchparams).forEach(([key, value]) => {
|
|
9
|
+
if (value === null) {
|
|
10
|
+
params.delete(key);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
params.set(key, String(value));
|
|
14
|
+
});
|
|
15
|
+
window?.history?.pushState(null, "", `?${params.toString()}`);
|
|
16
|
+
};
|
|
17
|
+
return { updateSearchParams, searchParams };
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { useUpdateSearchParams };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const toTailwindColors = (colors) => Object.entries(colors).reduce(
|
|
2
|
+
(acc, [key, value]) => {
|
|
3
|
+
acc[key] = value.reduce(
|
|
4
|
+
(acc2, color, index) => {
|
|
5
|
+
acc2[index] = color;
|
|
6
|
+
return acc2;
|
|
7
|
+
},
|
|
8
|
+
{}
|
|
9
|
+
);
|
|
10
|
+
return acc;
|
|
11
|
+
},
|
|
12
|
+
{}
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export { toTailwindColors };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Tooltip, Menu, Select, AppShell, Notification } from '@mantine/core';
|
|
2
|
+
import { breakpointsWithPx } from './index.es44.js';
|
|
3
|
+
|
|
4
|
+
const myDefaultTheme = {
|
|
5
|
+
breakpoints: breakpointsWithPx,
|
|
6
|
+
cursorType: "pointer",
|
|
7
|
+
components: {
|
|
8
|
+
Notification: Notification.extend({
|
|
9
|
+
defaultProps: {
|
|
10
|
+
withBorder: true
|
|
11
|
+
}
|
|
12
|
+
}),
|
|
13
|
+
AppShell: AppShell.extend({
|
|
14
|
+
defaultProps: {
|
|
15
|
+
padding: 0
|
|
16
|
+
}
|
|
17
|
+
}),
|
|
18
|
+
Select: Select.extend({
|
|
19
|
+
defaultProps: {
|
|
20
|
+
allowDeselect: false,
|
|
21
|
+
withCheckIcon: false,
|
|
22
|
+
clearable: true
|
|
23
|
+
}
|
|
24
|
+
}),
|
|
25
|
+
Menu: Menu.extend({
|
|
26
|
+
defaultProps: {
|
|
27
|
+
position: "bottom-end"
|
|
28
|
+
}
|
|
29
|
+
}),
|
|
30
|
+
Tooltip: Tooltip.extend({
|
|
31
|
+
defaultProps: {
|
|
32
|
+
multiline: true,
|
|
33
|
+
w: 300
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { myDefaultTheme };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
function formatBytes(bytes, decimals = 2) {
|
|
2
|
+
if (!+bytes) return "0 Bytes";
|
|
3
|
+
const k = 1024;
|
|
4
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
5
|
+
const sizes = ["Bytes", "KB", "MB"];
|
|
6
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
7
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { formatBytes };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HTTPError } from 'ky';
|
|
2
|
+
import { parseJSON } from './index.es49.js';
|
|
3
|
+
|
|
4
|
+
class KyError extends HTTPError {
|
|
5
|
+
constructor(response, request, options, bodyJson) {
|
|
6
|
+
super(response, request, options);
|
|
7
|
+
this.response.bodyJson = bodyJson;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const addBodyJsonHook = async (error) => {
|
|
11
|
+
error.response.bodyJson = await parseJSON(error.response);
|
|
12
|
+
return error;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { KyError, addBodyJsonHook };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
|
|
5
|
+
const Icon = ({ i: I, size = "md", style, rotate, className, ...rest }) => {
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
|
+
I,
|
|
8
|
+
{
|
|
9
|
+
...typeof size === "number" ? {
|
|
10
|
+
height: size,
|
|
11
|
+
width: size
|
|
12
|
+
} : stylesBySize[size],
|
|
13
|
+
viewBox: "0 0 24 24",
|
|
14
|
+
style: {
|
|
15
|
+
...style,
|
|
16
|
+
transform: `rotate(${rotate}deg)`
|
|
17
|
+
},
|
|
18
|
+
className: clsx("shrink-0", className),
|
|
19
|
+
...rest
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
const stylesBySize = {
|
|
24
|
+
xs: {
|
|
25
|
+
height: 16,
|
|
26
|
+
width: 16
|
|
27
|
+
},
|
|
28
|
+
sm: {
|
|
29
|
+
height: 20,
|
|
30
|
+
width: 20
|
|
31
|
+
},
|
|
32
|
+
md: {
|
|
33
|
+
height: 24,
|
|
34
|
+
width: 24
|
|
35
|
+
},
|
|
36
|
+
lg: {
|
|
37
|
+
height: 28,
|
|
38
|
+
width: 28
|
|
39
|
+
},
|
|
40
|
+
xl: {
|
|
41
|
+
height: 32,
|
|
42
|
+
width: 32
|
|
43
|
+
},
|
|
44
|
+
["2xl"]: {
|
|
45
|
+
height: 40,
|
|
46
|
+
width: 40
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export { Icon };
|