minimal-shared 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/README.md +1 -1
  2. package/dist/hooks/index.d.ts +2 -4
  3. package/dist/hooks/index.js +0 -2
  4. package/dist/hooks/use-back-to-top/use-back-to-top.js +1 -64
  5. package/dist/hooks/use-boolean/use-boolean.js +1 -24
  6. package/dist/hooks/use-client-rect/use-client-rect.js +1 -47
  7. package/dist/hooks/use-cookies/index.d.ts +1 -1
  8. package/dist/hooks/use-cookies/use-cookies.d.ts +11 -10
  9. package/dist/hooks/use-cookies/use-cookies.js +1 -110
  10. package/dist/hooks/use-copy-to-clipboard/use-copy-to-clipboard.js +1 -27
  11. package/dist/hooks/use-countdown-date/use-countdown-date.js +1 -41
  12. package/dist/hooks/use-countdown-seconds/use-countdown-seconds.js +1 -36
  13. package/dist/hooks/use-debounce/use-debounce.js +1 -17
  14. package/dist/hooks/use-double-click/use-double-click.js +1 -33
  15. package/dist/hooks/use-is-client/use-is-client.js +1 -12
  16. package/dist/hooks/use-local-storage/index.d.ts +1 -1
  17. package/dist/hooks/use-local-storage/use-local-storage.d.ts +11 -10
  18. package/dist/hooks/use-local-storage/use-local-storage.js +1 -113
  19. package/dist/hooks/use-multi-select/use-multi-select.js +1 -36
  20. package/dist/hooks/use-popover/use-popover.js +1 -21
  21. package/dist/hooks/use-popover-hover/use-popover-hover.js +1 -24
  22. package/dist/hooks/use-scroll-offset-top/use-scroll-offset-top.js +1 -29
  23. package/dist/hooks/use-set-state/use-set-state.d.ts +5 -5
  24. package/dist/hooks/use-set-state/use-set-state.js +1 -26
  25. package/dist/hooks/use-tabs/use-tabs.js +1 -16
  26. package/dist/index.d.ts +4 -6
  27. package/dist/utils/active-link/active-link.js +1 -43
  28. package/dist/utils/classes/classes.js +1 -14
  29. package/dist/utils/color/color.js +2 -40
  30. package/dist/utils/cookies/cookies.js +1 -46
  31. package/dist/utils/font/font.js +1 -20
  32. package/dist/utils/index.d.ts +2 -2
  33. package/dist/utils/local-storage/index.d.ts +1 -1
  34. package/dist/utils/local-storage/local-storage.d.ts +2 -14
  35. package/dist/utils/local-storage/local-storage.js +1 -51
  36. package/dist/utils/object/object.js +1 -10
  37. package/dist/utils/url/index.d.ts +1 -1
  38. package/dist/utils/url/url.d.ts +9 -1
  39. package/dist/utils/url/url.js +1 -28
  40. package/dist/utils/uuidv4/uuidv4.js +1 -11
  41. package/package.json +6 -2
  42. package/dist/hooks/use-event-listener/index.d.ts +0 -2
  43. package/dist/hooks/use-event-listener/index.js +0 -1
  44. package/dist/hooks/use-event-listener/use-event-listener.d.ts +0 -7
  45. package/dist/hooks/use-event-listener/use-event-listener.js +0 -23
  46. package/dist/hooks/use-text-input/index.d.ts +0 -2
  47. package/dist/hooks/use-text-input/index.js +0 -1
  48. package/dist/hooks/use-text-input/use-text-input.d.ts +0 -16
  49. 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.3",
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",
@@ -50,7 +54,7 @@
50
54
  },
51
55
  "scripts": {
52
56
  "dev": "NODE_OPTIONS='--max-old-space-size=16384' tsup --watch",
53
- "build": "NODE_OPTIONS='--max-old-space-size=16384' tsup",
57
+ "build": "pnpm test && NODE_OPTIONS='--max-old-space-size=16384' tsup",
54
58
  "test": "vitest run",
55
59
  "test:watch": "vitest",
56
60
  "lint": "eslint \"**/*.{js,jsx,ts,tsx}\"",
@@ -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
- };