lkd-web-kit 0.0.5 → 0.0.6
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.d.ts +19 -0
- package/dist/index.js +21 -1
- package/dist/index.umd.cjs +25 -4
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -42,6 +42,13 @@ export declare interface ApiPagination<T> {
|
|
|
42
42
|
data: T[];
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
export declare type Args<T, S> = {
|
|
46
|
+
params?: T;
|
|
47
|
+
searchParams?: S & {
|
|
48
|
+
[QP_BACK_URL_NAME]?: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
45
52
|
export declare const breakpointsWithPx: {
|
|
46
53
|
xs: string;
|
|
47
54
|
sm: string;
|
|
@@ -187,6 +194,10 @@ export declare interface InfinityLoaderProps extends CenterProps {
|
|
|
187
194
|
loaderProps?: LoaderProps;
|
|
188
195
|
}
|
|
189
196
|
|
|
197
|
+
export declare const isInfinityEmpty: (data: InfiniteData<{
|
|
198
|
+
data: unknown[];
|
|
199
|
+
}> | undefined) => boolean;
|
|
200
|
+
|
|
190
201
|
export declare type KyError<T = unknown> = HTTPError<T> & {
|
|
191
202
|
response: {
|
|
192
203
|
bodyJson?: T;
|
|
@@ -232,6 +243,8 @@ export declare interface NavItemsProps {
|
|
|
232
243
|
}[];
|
|
233
244
|
}
|
|
234
245
|
|
|
246
|
+
export declare const newHref: <T extends TParams, S extends TSearchParams = TSearchParams>(fn: string | ((args: Args<T, S>) => string)) => (args?: Args<T, S>) => string;
|
|
247
|
+
|
|
235
248
|
export declare const nullableInput: <T extends ZodTypeAny>(schema: T, message?: string) => z.ZodEffects<z.ZodNullable<T>, (T["_output"] & undefined) | (T["_output"] & {}), T["_input"] | null>;
|
|
236
249
|
|
|
237
250
|
export declare const PageDataProvider: ({ value, children }: PageDataProviderProps) => JSX.Element;
|
|
@@ -321,6 +334,12 @@ declare const stylesBySize: {
|
|
|
321
334
|
|
|
322
335
|
export declare const toTailwindColors: (colors: MantineThemeColors) => Record<DefaultMantineColor, Record<MantineColorShade, string>>;
|
|
323
336
|
|
|
337
|
+
export declare type TParams = Record<string, any> | unknown;
|
|
338
|
+
|
|
339
|
+
export declare type TSearchParams = {
|
|
340
|
+
[x: string]: any;
|
|
341
|
+
};
|
|
342
|
+
|
|
324
343
|
export declare const useFetchNextPageOnScroll: (infinity: InfiniteQueryHookResult<InfiniteData<{
|
|
325
344
|
data: unknown[];
|
|
326
345
|
}, number>, Error>, elementRef?: RefObject<HTMLElement | null>) => void;
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Center, Loader, useCombobox, Combobox, InputBase, Input, ScrollArea, St
|
|
|
3
3
|
import require$$0, { useEffect, useRef, createContext, useState, useContext } from 'react';
|
|
4
4
|
import { FormProvider, useFormContext, Controller } from 'react-hook-form';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
+
import queryString from 'query-string';
|
|
6
7
|
|
|
7
8
|
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
8
9
|
|
|
@@ -6300,4 +6301,23 @@ const shuffleArray = (array) => {
|
|
|
6300
6301
|
return shuffledArray;
|
|
6301
6302
|
};
|
|
6302
6303
|
|
|
6303
|
-
|
|
6304
|
+
const newHref = (fn) => (args) => {
|
|
6305
|
+
const href = typeof fn === "string" ? fn : fn(
|
|
6306
|
+
args ?? {
|
|
6307
|
+
params: {},
|
|
6308
|
+
searchParams: {}
|
|
6309
|
+
}
|
|
6310
|
+
);
|
|
6311
|
+
if (args?.searchParams) {
|
|
6312
|
+
const qs = queryString.stringify(args.searchParams, {
|
|
6313
|
+
skipEmptyString: true,
|
|
6314
|
+
skipNull: true
|
|
6315
|
+
});
|
|
6316
|
+
return `${href}${qs ? `?${qs}` : ""}`;
|
|
6317
|
+
}
|
|
6318
|
+
return href;
|
|
6319
|
+
};
|
|
6320
|
+
|
|
6321
|
+
const isInfinityEmpty = (data) => data?.pages[0].data.length === 0;
|
|
6322
|
+
|
|
6323
|
+
export { EmptyState, Form, FormButtonSubmit, HttpStatus, InfinityLoader, NavItems, NavigationHistoryProvider, PageDataProvider, QP_BACK_URL_NAME, Revalidate, SelectInfinity, addBodyJsonHook, breakpointsWithPx, formatBytes, groupBy, indexBy, isInfinityEmpty, newHref, nullableInput, parseJSON, shuffleArray, toTailwindColors, useFetchNextPageOnScroll, useNavigationHistory, useOnScrollProgress, usePageData, withForm, withModalManager, zodValidator };
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('@mantine/core'), require('react'), require('react-hook-form'), require('zod')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', '@mantine/core', 'react', 'react-hook-form', 'zod'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["lkd-web-kit"] = {}, global.require$$1, global.core, global.require$$0, global.reactHookForm, global.zod));
|
|
5
|
-
})(this, (function (exports, require$$1, core, require$$0, reactHookForm, zod) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('@mantine/core'), require('react'), require('react-hook-form'), require('zod'), require('query-string')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', '@mantine/core', 'react', 'react-hook-form', 'zod', 'query-string'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["lkd-web-kit"] = {}, global.require$$1, global.core, global.require$$0, global.reactHookForm, global.zod, global.queryString));
|
|
5
|
+
})(this, (function (exports, require$$1, core, require$$0, reactHookForm, zod, queryString) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
8
8
|
|
|
@@ -6300,6 +6300,25 @@
|
|
|
6300
6300
|
return shuffledArray;
|
|
6301
6301
|
};
|
|
6302
6302
|
|
|
6303
|
+
const newHref = (fn) => (args) => {
|
|
6304
|
+
const href = typeof fn === "string" ? fn : fn(
|
|
6305
|
+
args ?? {
|
|
6306
|
+
params: {},
|
|
6307
|
+
searchParams: {}
|
|
6308
|
+
}
|
|
6309
|
+
);
|
|
6310
|
+
if (args?.searchParams) {
|
|
6311
|
+
const qs = queryString.stringify(args.searchParams, {
|
|
6312
|
+
skipEmptyString: true,
|
|
6313
|
+
skipNull: true
|
|
6314
|
+
});
|
|
6315
|
+
return `${href}${qs ? `?${qs}` : ""}`;
|
|
6316
|
+
}
|
|
6317
|
+
return href;
|
|
6318
|
+
};
|
|
6319
|
+
|
|
6320
|
+
const isInfinityEmpty = (data) => data?.pages[0].data.length === 0;
|
|
6321
|
+
|
|
6303
6322
|
exports.EmptyState = EmptyState;
|
|
6304
6323
|
exports.Form = Form;
|
|
6305
6324
|
exports.FormButtonSubmit = FormButtonSubmit;
|
|
@@ -6316,6 +6335,8 @@
|
|
|
6316
6335
|
exports.formatBytes = formatBytes;
|
|
6317
6336
|
exports.groupBy = groupBy;
|
|
6318
6337
|
exports.indexBy = indexBy;
|
|
6338
|
+
exports.isInfinityEmpty = isInfinityEmpty;
|
|
6339
|
+
exports.newHref = newHref;
|
|
6319
6340
|
exports.nullableInput = nullableInput;
|
|
6320
6341
|
exports.parseJSON = parseJSON;
|
|
6321
6342
|
exports.shuffleArray = shuffleArray;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lkd-web-kit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "A template for creating React component libraries with Vite.",
|
|
5
5
|
"author": "LKD",
|
|
6
6
|
"license": "MIT",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"@tanstack/react-query": "^5.72.2",
|
|
57
57
|
"ky": "^1.8.0",
|
|
58
58
|
"next": "^15.3.0",
|
|
59
|
+
"query-string": "^9.1.1",
|
|
59
60
|
"react": "^19.1.0",
|
|
60
61
|
"react-dom": "^19.1.0",
|
|
61
62
|
"react-hook-form": "^7.55.0",
|