minimal-shared 0.0.2 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/dist/hooks/index.d.ts +2 -4
  4. package/dist/hooks/index.js +0 -2
  5. package/dist/hooks/use-back-to-top/use-back-to-top.js +1 -64
  6. package/dist/hooks/use-boolean/use-boolean.js +1 -24
  7. package/dist/hooks/use-client-rect/use-client-rect.js +1 -47
  8. package/dist/hooks/use-cookies/index.d.ts +1 -1
  9. package/dist/hooks/use-cookies/use-cookies.d.ts +11 -10
  10. package/dist/hooks/use-cookies/use-cookies.js +1 -110
  11. package/dist/hooks/use-copy-to-clipboard/use-copy-to-clipboard.js +1 -27
  12. package/dist/hooks/use-countdown-date/use-countdown-date.js +1 -41
  13. package/dist/hooks/use-countdown-seconds/use-countdown-seconds.js +1 -36
  14. package/dist/hooks/use-debounce/use-debounce.js +1 -17
  15. package/dist/hooks/use-double-click/use-double-click.js +1 -33
  16. package/dist/hooks/use-is-client/use-is-client.js +1 -12
  17. package/dist/hooks/use-local-storage/index.d.ts +1 -1
  18. package/dist/hooks/use-local-storage/use-local-storage.d.ts +11 -10
  19. package/dist/hooks/use-local-storage/use-local-storage.js +1 -113
  20. package/dist/hooks/use-multi-select/use-multi-select.js +1 -36
  21. package/dist/hooks/use-popover/use-popover.js +1 -21
  22. package/dist/hooks/use-popover-hover/use-popover-hover.js +1 -24
  23. package/dist/hooks/use-scroll-offset-top/use-scroll-offset-top.js +1 -29
  24. package/dist/hooks/use-set-state/use-set-state.d.ts +5 -5
  25. package/dist/hooks/use-set-state/use-set-state.js +1 -26
  26. package/dist/hooks/use-tabs/use-tabs.js +1 -16
  27. package/dist/index.d.ts +4 -6
  28. package/dist/utils/active-link/active-link.js +1 -43
  29. package/dist/utils/classes/classes.js +1 -14
  30. package/dist/utils/color/color.js +2 -40
  31. package/dist/utils/cookies/cookies.js +1 -46
  32. package/dist/utils/font/font.js +1 -20
  33. package/dist/utils/index.d.ts +2 -2
  34. package/dist/utils/local-storage/index.d.ts +1 -1
  35. package/dist/utils/local-storage/local-storage.d.ts +2 -14
  36. package/dist/utils/local-storage/local-storage.js +1 -51
  37. package/dist/utils/object/object.js +1 -10
  38. package/dist/utils/url/index.d.ts +1 -1
  39. package/dist/utils/url/url.d.ts +9 -1
  40. package/dist/utils/url/url.js +1 -28
  41. package/dist/utils/uuidv4/uuidv4.js +1 -11
  42. package/package.json +21 -17
  43. package/dist/hooks/use-event-listener/index.d.ts +0 -2
  44. package/dist/hooks/use-event-listener/index.js +0 -1
  45. package/dist/hooks/use-event-listener/use-event-listener.d.ts +0 -7
  46. package/dist/hooks/use-event-listener/use-event-listener.js +0 -23
  47. package/dist/hooks/use-text-input/index.d.ts +0 -2
  48. package/dist/hooks/use-text-input/index.js +0 -1
  49. package/dist/hooks/use-text-input/use-text-input.d.ts +0 -16
  50. package/dist/hooks/use-text-input/use-text-input.js +0 -16
@@ -20,6 +20,14 @@ declare const hasParams: (url: string) => boolean;
20
20
  * console.log(cleanPathname); // '/dashboard/calendar'
21
21
  */
22
22
  declare function removeLastSlash(pathname: string): string;
23
+ /**
24
+ * Checks if two URLs have the same path.
25
+ *
26
+ * @param {string} targetUrl - The target URL to compare.
27
+ * @param {string} pathname - The pathname to compare.
28
+ * @returns {boolean} - True if the paths are equal, false otherwise.
29
+ */
30
+ declare function isEqualPath(targetUrl: string, pathname: string): boolean;
23
31
  /**
24
32
  * Removes query parameters from a URL.
25
33
  *
@@ -43,4 +51,4 @@ declare function removeParams(url: string): string;
43
51
  */
44
52
  declare function isExternalLink(url: string): boolean;
45
53
 
46
- export { hasParams, isExternalLink, removeLastSlash, removeParams };
54
+ export { hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams };
@@ -1,28 +1 @@
1
- // src/utils/url/url.ts
2
- var hasParams = (url) => {
3
- const queryString = url.split("?")[1];
4
- return queryString ? new URLSearchParams(queryString).toString().length > 0 : false;
5
- };
6
- function removeLastSlash(pathname) {
7
- if (pathname !== "/" && pathname.endsWith("/")) {
8
- return pathname.slice(0, -1);
9
- }
10
- return pathname;
11
- }
12
- function removeParams(url) {
13
- try {
14
- const urlObj = new URL(url, window.location.origin);
15
- return removeLastSlash(urlObj.pathname);
16
- } catch {
17
- return url;
18
- }
19
- }
20
- function isExternalLink(url) {
21
- return url.startsWith("http");
22
- }
23
- export {
24
- hasParams,
25
- isExternalLink,
26
- removeLastSlash,
27
- removeParams
28
- };
1
+ var e=t=>{let r=t.split("?")[1];return r?new URLSearchParams(r).toString().length>0:!1};function n(t){return t!=="/"&&t.endsWith("/")?t.slice(0,-1):t}function i(t,r){return n(t)===n(r)}function o(t){try{let r=new URL(t,window.location.origin);return n(r.pathname)}catch{return t}}function s(t){return t.startsWith("http")}export{e as hasParams,i as isEqualPath,s as isExternalLink,n as removeLastSlash,o as removeParams};
@@ -1,11 +1 @@
1
- // src/utils/uuidv4/uuidv4.ts
2
- function uuidv4() {
3
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
4
- const r = Math.random() * 16 | 0;
5
- const v = c === "x" ? r : r & 3 | 8;
6
- return v.toString(16);
7
- });
8
- }
9
- export {
10
- uuidv4
11
- };
1
+ function n(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let x=Math.random()*16|0;return(r==="x"?x:x&3|8).toString(16)})}export{n as uuidv4};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "minimal-shared",
3
3
  "author": "Minimals",
4
- "version": "0.0.2",
4
+ "version": "0.0.5",
5
5
  "description": "Shared hooks and utils used by Mnimal UI and Zone UI.",
6
6
  "keywords": [
7
7
  "typescript",
@@ -9,6 +9,10 @@
9
9
  "hooks",
10
10
  "utils"
11
11
  ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/minimal-ui-kit/minimal-shared"
15
+ },
12
16
  "license": "MIT",
13
17
  "sideEffects": false,
14
18
  "type": "module",
@@ -48,18 +52,6 @@
48
52
  "default": "./dist/utils/*/index.js"
49
53
  }
50
54
  },
51
- "scripts": {
52
- "dev": "NODE_OPTIONS='--max-old-space-size=16384' tsup --watch",
53
- "build": "NODE_OPTIONS='--max-old-space-size=16384' tsup",
54
- "test": "vitest run",
55
- "test:watch": "vitest",
56
- "lint": "eslint \"**/*.{js,jsx,ts,tsx}\"",
57
- "lint:fix": "eslint --fix \"**/*.{js,jsx,ts,tsx}\"",
58
- "lint:print": "npx eslint --print-config eslint.config.mjs > eslint-current-config.json",
59
- "clean": "rm -rf node_modules .turbo .next out dist build",
60
- "re:build": "pnpm clean && pnpm install && pnpm build",
61
- "tsc:print": "npx tsc --showConfig"
62
- },
63
55
  "dependencies": {
64
56
  "es-toolkit": "^1.26.1"
65
57
  },
@@ -73,15 +65,27 @@
73
65
  "fast-glob": "^3.3.2",
74
66
  "fs-extra": "^11.2.0",
75
67
  "glob": "^11.0.0",
76
- "internal-eslint-config": "workspace:*",
77
- "internal-ts-config": "workspace:*",
78
68
  "jsdom": "^25.0.1",
79
69
  "react": "^18.3.1",
80
70
  "tsup": "^8.3.5",
81
71
  "typescript": "^5.5.4",
82
- "vitest": "^2.1.4"
72
+ "vitest": "^2.1.4",
73
+ "internal-eslint-config": "1.0.0",
74
+ "internal-ts-config": "1.0.0"
83
75
  },
84
76
  "peerDependencies": {
85
77
  "react": "^17 || ^18"
78
+ },
79
+ "scripts": {
80
+ "dev": "NODE_OPTIONS='--max-old-space-size=16384' tsup --watch",
81
+ "build": "pnpm test && NODE_OPTIONS='--max-old-space-size=16384' tsup",
82
+ "test": "vitest run",
83
+ "test:watch": "vitest",
84
+ "lint": "eslint \"**/*.{js,jsx,ts,tsx}\"",
85
+ "lint:fix": "eslint --fix \"**/*.{js,jsx,ts,tsx}\"",
86
+ "lint:print": "npx eslint --print-config eslint.config.mjs > eslint-current-config.json",
87
+ "clean": "rm -rf node_modules .turbo .next out dist build",
88
+ "re:build": "pnpm clean && pnpm install && pnpm build",
89
+ "tsc:print": "npx tsc --showConfig"
86
90
  }
87
- }
91
+ }
@@ -1,2 +0,0 @@
1
- export { useEventListener } from './use-event-listener.js';
2
- import 'react';
@@ -1 +0,0 @@
1
- export * from './use-event-listener';
@@ -1,7 +0,0 @@
1
- import { RefObject } from 'react';
2
-
3
- declare function useEventListener<K extends keyof WindowEventMap>(eventName: K, handler: (event: WindowEventMap[K]) => void, element?: undefined, options?: boolean | AddEventListenerOptions): void;
4
- declare function useEventListener<K extends keyof HTMLElementEventMap, T extends HTMLElement = HTMLDivElement>(eventName: K, handler: (event: HTMLElementEventMap[K]) => void, element: RefObject<T>, options?: boolean | AddEventListenerOptions): void;
5
- declare function useEventListener<K extends keyof DocumentEventMap>(eventName: K, handler: (event: DocumentEventMap[K]) => void, element: RefObject<Document>, options?: boolean | AddEventListenerOptions): void;
6
-
7
- export { useEventListener };
@@ -1,23 +0,0 @@
1
- // src/hooks/use-event-listener/use-event-listener.ts
2
- import { useRef, useEffect, useLayoutEffect } from "react";
3
- var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
4
- function useEventListener(eventName, handler, element, options) {
5
- const savedHandler = useRef(handler);
6
- useIsomorphicLayoutEffect(() => {
7
- savedHandler.current = handler;
8
- }, [handler]);
9
- useEffect(() => {
10
- const targetElement = element?.current || window;
11
- if (!(targetElement && targetElement.addEventListener)) {
12
- return;
13
- }
14
- const eventListener = (event) => savedHandler.current(event);
15
- targetElement.addEventListener(eventName, eventListener, options);
16
- return () => {
17
- targetElement.removeEventListener(eventName, eventListener);
18
- };
19
- }, [eventName, element, options]);
20
- }
21
- export {
22
- useEventListener
23
- };
@@ -1,2 +0,0 @@
1
- export { UseTextInputReturn, useTextInput } from './use-text-input.js';
2
- import 'react';
@@ -1 +0,0 @@
1
- export * from './use-text-input';
@@ -1,16 +0,0 @@
1
- import { Dispatch, SetStateAction } from 'react';
2
-
3
- /**
4
- * Custom hook to manage text input state.
5
- *
6
- * @param {string} [defaultValue=''] - The default value for the input.
7
- * @returns {UseTextInputReturn} The current value, change handler, and setValue function.
8
- */
9
- type UseTextInputReturn = {
10
- value: string;
11
- setValue: Dispatch<SetStateAction<string>>;
12
- onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
13
- };
14
- declare function useTextInput(defaultValue?: string): UseTextInputReturn;
15
-
16
- export { type UseTextInputReturn, useTextInput };
@@ -1,16 +0,0 @@
1
- // src/hooks/use-text-input/use-text-input.ts
2
- import { useState, useCallback } from "react";
3
- function useTextInput(defaultValue = "") {
4
- const [value, setValue] = useState(defaultValue);
5
- const onChange = useCallback((event) => {
6
- setValue(event.target.value);
7
- }, []);
8
- return {
9
- value,
10
- setValue,
11
- onChange
12
- };
13
- }
14
- export {
15
- useTextInput
16
- };