lkd-web-kit 0.3.5 → 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.
Files changed (165) hide show
  1. package/dist/index.cjs.js +118 -0
  2. package/dist/index.cjs10.js +16 -0
  3. package/dist/index.cjs11.js +16 -0
  4. package/dist/index.cjs12.js +16 -0
  5. package/dist/index.cjs13.js +16 -0
  6. package/dist/index.cjs14.js +118 -0
  7. package/dist/index.cjs15.js +16 -0
  8. package/dist/index.cjs16.js +18 -0
  9. package/dist/index.cjs17.js +70 -0
  10. package/dist/index.cjs18.js +14 -0
  11. package/dist/index.cjs19.js +66 -0
  12. package/dist/index.cjs2.js +43 -0
  13. package/dist/index.cjs20.js +21 -0
  14. package/dist/index.cjs21.js +30 -0
  15. package/dist/index.cjs22.js +23 -0
  16. package/dist/index.cjs23.js +15 -0
  17. package/dist/index.cjs24.js +16 -0
  18. package/dist/index.cjs25.js +16 -0
  19. package/dist/index.cjs26.js +18 -0
  20. package/dist/index.cjs27.js +17 -0
  21. package/dist/index.cjs28.js +17 -0
  22. package/dist/index.cjs29.js +17 -0
  23. package/dist/index.cjs3.js +12 -0
  24. package/dist/index.cjs30.js +17 -0
  25. package/dist/index.cjs31.js +17 -0
  26. package/dist/index.cjs32.js +17 -0
  27. package/dist/index.cjs33.js +17 -0
  28. package/dist/index.cjs34.js +17 -0
  29. package/dist/index.cjs35.js +29 -0
  30. package/dist/index.cjs36.js +17 -0
  31. package/dist/index.cjs37.js +17 -0
  32. package/dist/index.cjs38.js +51 -0
  33. package/dist/index.cjs39.js +38 -0
  34. package/dist/index.cjs4.js +40 -0
  35. package/dist/index.cjs40.js +15 -0
  36. package/dist/index.cjs41.js +23 -0
  37. package/dist/index.cjs42.js +39 -0
  38. package/dist/index.cjs43.js +24 -0
  39. package/dist/index.cjs44.js +14 -0
  40. package/dist/index.cjs45.js +19 -0
  41. package/dist/index.cjs46.js +43 -0
  42. package/dist/index.cjs47.js +14 -0
  43. package/dist/index.cjs48.js +20 -0
  44. package/dist/index.cjs49.js +11 -0
  45. package/dist/index.cjs5.js +54 -0
  46. package/dist/index.cjs50.js +45 -0
  47. package/dist/index.cjs51.js +19 -0
  48. package/dist/index.cjs52.js +24 -0
  49. package/dist/index.cjs53.js +7 -0
  50. package/dist/index.cjs54.js +65 -0
  51. package/dist/index.cjs6.js +18 -0
  52. package/dist/index.cjs7.js +18 -0
  53. package/dist/index.cjs8.js +17 -0
  54. package/dist/index.cjs9.js +16 -0
  55. package/dist/index.es.js +52 -0
  56. package/dist/index.es10.js +12 -0
  57. package/dist/index.es11.js +12 -0
  58. package/dist/index.es12.js +12 -0
  59. package/dist/index.es13.js +12 -0
  60. package/dist/index.es14.js +114 -0
  61. package/dist/index.es15.js +12 -0
  62. package/dist/index.es16.js +14 -0
  63. package/dist/index.es17.js +66 -0
  64. package/dist/index.es18.js +10 -0
  65. package/dist/index.es19.js +60 -0
  66. package/dist/index.es2.js +39 -0
  67. package/dist/index.es20.js +16 -0
  68. package/dist/index.es21.js +26 -0
  69. package/dist/index.es22.js +19 -0
  70. package/dist/index.es23.js +11 -0
  71. package/dist/index.es24.js +12 -0
  72. package/dist/index.es25.js +12 -0
  73. package/dist/index.es26.js +14 -0
  74. package/dist/index.es27.js +13 -0
  75. package/dist/index.es28.js +13 -0
  76. package/dist/index.es29.js +13 -0
  77. package/dist/index.es3.js +8 -0
  78. package/dist/index.es30.js +13 -0
  79. package/dist/index.es31.js +13 -0
  80. package/dist/index.es32.js +13 -0
  81. package/dist/index.es33.js +13 -0
  82. package/dist/index.es34.js +13 -0
  83. package/dist/index.es35.js +23 -0
  84. package/dist/index.es36.js +13 -0
  85. package/dist/index.es37.js +13 -0
  86. package/dist/index.es38.js +47 -0
  87. package/dist/index.es39.js +34 -0
  88. package/dist/index.es4.js +36 -0
  89. package/dist/index.es40.js +11 -0
  90. package/dist/index.es41.js +19 -0
  91. package/dist/index.es42.js +35 -0
  92. package/dist/index.es43.js +20 -0
  93. package/dist/{src/mantine/breakpoints-with-px.js → index.es44.js} +4 -5
  94. package/dist/index.es45.js +15 -0
  95. package/dist/index.es46.js +39 -0
  96. package/dist/index.es47.js +10 -0
  97. package/dist/index.es48.js +15 -0
  98. package/dist/index.es49.js +7 -0
  99. package/dist/index.es5.js +50 -0
  100. package/dist/index.es50.js +40 -0
  101. package/dist/index.es51.js +15 -0
  102. package/dist/index.es52.js +20 -0
  103. package/dist/index.es53.js +3 -0
  104. package/dist/index.es54.js +63 -0
  105. package/dist/index.es6.js +14 -0
  106. package/dist/index.es7.js +14 -0
  107. package/dist/index.es8.js +13 -0
  108. package/dist/index.es9.js +12 -0
  109. package/dist/node_modules/@mantine/notifications/styles.css +42 -0
  110. package/package.json +15 -5
  111. package/dist/lkd-web-kit.css +0 -1
  112. package/dist/src/components/EmptyState/index.js +0 -36
  113. package/dist/src/components/Icon.js +0 -47
  114. package/dist/src/components/InfinityLoader/index.js +0 -9
  115. package/dist/src/components/MyDatePickerInput/CalendarIcon.js +0 -61
  116. package/dist/src/components/MyDatePickerInput/index.js +0 -14
  117. package/dist/src/components/MyDateTimePicker/index.js +0 -14
  118. package/dist/src/components/MyMonthPickerInput/index.js +0 -14
  119. package/dist/src/components/MyMultiSelect/index.js +0 -12
  120. package/dist/src/components/MyNotifications/index.js +0 -13
  121. package/dist/src/components/MyNumberInput/index.js +0 -12
  122. package/dist/src/components/MySelect/index.js +0 -12
  123. package/dist/src/components/MyTextInput/index.js +0 -12
  124. package/dist/src/components/MyTextarea/index.js +0 -12
  125. package/dist/src/components/MyTimeInput/index.js +0 -12
  126. package/dist/src/components/NavItems.js +0 -36
  127. package/dist/src/components/SelectInfinity/index.js +0 -106
  128. package/dist/src/consts/http-status.js +0 -4
  129. package/dist/src/consts/revalidate.js +0 -4
  130. package/dist/src/contexts/NavigationHistoryContext/index.js +0 -47
  131. package/dist/src/contexts/PageDataContext/index.js +0 -15
  132. package/dist/src/form/Form.js +0 -23
  133. package/dist/src/form/FormButtonSubmit.js +0 -18
  134. package/dist/src/form/base/FormCheckbox.js +0 -15
  135. package/dist/src/form/base/FormDatePickerInput.js +0 -21
  136. package/dist/src/form/base/FormDateTimePicker.js +0 -21
  137. package/dist/src/form/base/FormMonthPickerInput.js +0 -21
  138. package/dist/src/form/base/FormMultiSelect.js +0 -21
  139. package/dist/src/form/base/FormNumberInput.js +0 -21
  140. package/dist/src/form/base/FormRadioGroup.js +0 -14
  141. package/dist/src/form/base/FormSelect.js +0 -21
  142. package/dist/src/form/base/FormSelectInfinity.js +0 -21
  143. package/dist/src/form/base/FormTextInput.js +0 -21
  144. package/dist/src/form/base/FormTextarea.js +0 -21
  145. package/dist/src/form/base/FormTimeInput.js +0 -29
  146. package/dist/src/form/utils/nullable-but-required.js +0 -10
  147. package/dist/src/form/utils/optional-but-required.js +0 -10
  148. package/dist/src/form/utils/zodValidator.js +0 -9
  149. package/dist/src/hocs/withForm.js +0 -59
  150. package/dist/src/hocs/withModalManager.js +0 -29
  151. package/dist/src/hooks/useBreakpoint.js +0 -8
  152. package/dist/src/hooks/useFetchNextPageOnScroll.js +0 -19
  153. package/dist/src/hooks/useOnScrollProgress.js +0 -25
  154. package/dist/src/hooks/useUpdateSearchParams.js +0 -19
  155. package/dist/src/main.js +0 -113
  156. package/dist/src/mantine/my-default-theme.js +0 -39
  157. package/dist/src/mantine/to-tailwind-colors.js +0 -10
  158. package/dist/src/utils/array/groupBy.js +0 -36
  159. package/dist/src/utils/array/shuffleArray.js +0 -13
  160. package/dist/src/utils/formatBytes.js +0 -8
  161. package/dist/src/utils/isInfinityEmpty.js +0 -4
  162. package/dist/src/utils/ky/addBodyJsonHook.js +0 -12
  163. package/dist/src/utils/ky/parseJson.js +0 -6
  164. package/dist/src/utils/newHref.js +0 -20
  165. /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,11 @@
1
+ 'use client';
2
+ import { useMatches } from '@mantine/core';
3
+
4
+ const useBreakpoint = (breakpoint) => {
5
+ const result = useMatches({
6
+ [breakpoint]: true
7
+ });
8
+ return !!result;
9
+ };
10
+
11
+ export { useBreakpoint };
@@ -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 };
@@ -1,11 +1,10 @@
1
- const x = {
1
+ const breakpointsWithPx = {
2
2
  xs: "576px",
3
3
  sm: "640px",
4
4
  md: "768px",
5
5
  lg: "1024px",
6
6
  xl: "1280px",
7
- "2xl": "1536px"
8
- };
9
- export {
10
- x as breakpointsWithPx
7
+ ["2xl"]: "1536px"
11
8
  };
9
+
10
+ export { breakpointsWithPx };
@@ -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,7 @@
1
+ const parseJSON = async (response) => {
2
+ return response.text().then(function(text) {
3
+ return text ? JSON.parse(text) : {};
4
+ });
5
+ };
6
+
7
+ export { parseJSON };
@@ -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 };