lkd-web-kit 0.0.0 → 0.0.2

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.
@@ -0,0 +1,71 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { Controller } from 'react-hook-form';
3
+ import '@mantine/core';
4
+ import { z as zodValidator } from './zodValidator-ChEQ3cmF.js';
5
+ import 'zod';
6
+ import { useState, useEffect } from 'react';
7
+
8
+ const withForm = (WrappedComponent, getControllerProps) => {
9
+ const FormField = (props) => {
10
+ const { validate, name = "", placeholder, label, description, ...withFormRestProps } = props;
11
+ return /* @__PURE__ */ jsx(
12
+ Controller,
13
+ {
14
+ name,
15
+ defaultValue: "",
16
+ rules: {
17
+ validate: validate && !props.disabled ? zodValidator(validate) : void 0
18
+ },
19
+ disabled: props.disabled,
20
+ ...getControllerProps?.(props),
21
+ render: (renderProps) => {
22
+ const {
23
+ fieldState: { isTouched, error }
24
+ } = renderProps;
25
+ const fieldProps = {
26
+ ...renderProps,
27
+ props: {
28
+ ...props,
29
+ validate: void 0
30
+ },
31
+ field: {
32
+ ...renderProps.field,
33
+ label,
34
+ placeholder,
35
+ description,
36
+ error: error?.message
37
+ },
38
+ ...withFormRestProps
39
+ };
40
+ return /* @__PURE__ */ jsx(WrappedComponent, { ...fieldProps });
41
+ }
42
+ }
43
+ );
44
+ };
45
+ FormField.displayName = `withForm(${WrappedComponent.displayName})`;
46
+ return FormField;
47
+ };
48
+
49
+ const withModalManager = (WrappedComponent) => {
50
+ const Component = ({
51
+ removeModal,
52
+ opened,
53
+ ...props
54
+ }) => {
55
+ const [isOpen, setIsOpen] = useState(false);
56
+ const onClose = () => {
57
+ setIsOpen(false);
58
+ setTimeout(() => removeModal(), 200);
59
+ props.onClose?.();
60
+ };
61
+ useEffect(() => {
62
+ if (opened) setTimeout(() => setIsOpen(true), 0);
63
+ else onClose();
64
+ }, [opened]);
65
+ return /* @__PURE__ */ jsx(WrappedComponent, { ...props, opened: isOpen, onClose });
66
+ };
67
+ Component.displayName = `withModalManager(${WrappedComponent.displayName})`;
68
+ return Component;
69
+ };
70
+
71
+ export { withForm, withModalManager };
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ require('@mantine/core');
6
+ const useFetchNextPageOnScroll = require('./useFetchNextPageOnScroll-Fqj7Vp-O.cjs');
7
+ require('./navigation-DnFkn_t2.cjs');
8
+
9
+
10
+
11
+ exports.useFetchNextPageOnScroll = useFetchNextPageOnScroll.useFetchNextPageOnScroll;
12
+ exports.useOnScrollProgress = useFetchNextPageOnScroll.useOnScrollProgress;
@@ -0,0 +1,11 @@
1
+ import { InfiniteData } from '@tanstack/react-query';
2
+ import { InfiniteQueryHookResult } from 'react-query-kit';
3
+ import { RefObject } from 'react';
4
+
5
+ export declare const useFetchNextPageOnScroll: (infinity: InfiniteQueryHookResult<InfiniteData<{
6
+ data: unknown[];
7
+ }, number>, Error>, elementRef?: RefObject<HTMLElement | null>) => void;
8
+
9
+ export declare const useOnScrollProgress: (triggerPercentage: number, callback: () => void, elementRef?: RefObject<HTMLElement | null>) => void;
10
+
11
+ export { }
@@ -0,0 +1,3 @@
1
+ import '@mantine/core';
2
+ export { u as useFetchNextPageOnScroll, a as useOnScrollProgress } from './useFetchNextPageOnScroll-08q9N5OE.js';
3
+ import './navigation-sZaWnl2V.js';
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const breakpointsWithPx = {
6
+ xs: "576px",
7
+ sm: "640px",
8
+ md: "768px",
9
+ lg: "1024px",
10
+ xl: "1280px",
11
+ ["2xl"]: "1536px"
12
+ };
13
+
14
+ const toTailwindColors = (colors) => Object.entries(colors).reduce(
15
+ (acc, [key, value]) => {
16
+ acc[key] = value.reduce(
17
+ (acc2, color, index) => {
18
+ acc2[index] = color;
19
+ return acc2;
20
+ },
21
+ {}
22
+ );
23
+ return acc;
24
+ },
25
+ {}
26
+ );
27
+
28
+ exports.breakpointsWithPx = breakpointsWithPx;
29
+ exports.toTailwindColors = toTailwindColors;
@@ -0,0 +1,16 @@
1
+ import { DefaultMantineColor } from '@mantine/core';
2
+ import { MantineColorShade } from '@mantine/core';
3
+ import { MantineThemeColors } from '@mantine/core';
4
+
5
+ export declare const breakpointsWithPx: {
6
+ xs: string;
7
+ sm: string;
8
+ md: string;
9
+ lg: string;
10
+ xl: string;
11
+ "2xl": string;
12
+ };
13
+
14
+ export declare const toTailwindColors: (colors: MantineThemeColors) => Record<DefaultMantineColor, Record<MantineColorShade, string>>;
15
+
16
+ export { }
@@ -0,0 +1,24 @@
1
+ const breakpointsWithPx = {
2
+ xs: "576px",
3
+ sm: "640px",
4
+ md: "768px",
5
+ lg: "1024px",
6
+ xl: "1280px",
7
+ ["2xl"]: "1536px"
8
+ };
9
+
10
+ const toTailwindColors = (colors) => Object.entries(colors).reduce(
11
+ (acc, [key, value]) => {
12
+ acc[key] = value.reduce(
13
+ (acc2, color, index) => {
14
+ acc2[index] = color;
15
+ return acc2;
16
+ },
17
+ {}
18
+ );
19
+ return acc;
20
+ },
21
+ {}
22
+ );
23
+
24
+ export { breakpointsWithPx, toTailwindColors };