@sohanemon/utils 4.1.14 → 4.1.15

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.
@@ -200,3 +200,12 @@ export declare function printf(format: string, ...args: unknown[]): string;
200
200
  */
201
201
  export type MergeRefs = <T>(...refs: Array<React.Ref<T> | undefined>) => React.RefCallback<T>;
202
202
  export declare const mergeRefs: MergeRefs;
203
+ /**
204
+ * Navigates to the specified client-side hash without ssr.
205
+ * use `scroll-margin-top` with css to add margins
206
+ *
207
+ * @param id - The ID of the element without # to navigate to.
208
+ *
209
+ * @example goToClientSideHash('my-element');
210
+ */
211
+ export declare function goToClientSideHash(id: string, opts: ScrollIntoViewOptions): void;
@@ -110,7 +110,7 @@ export const copyToClipboard = (value, onSuccess = () => { }) => {
110
110
  export function convertToNormalCase(inputString) {
111
111
  const splittedString = inputString.split('.').pop();
112
112
  const string = splittedString || inputString;
113
- const words = string.replace(/([a-z])([A-Z])/g, '$1 $2').split(/[-_|​\s]+/);
113
+ const words = string.replace(/([a-z])([A-Z])/g, '$1 $2').split(/[-_|�\s]+/);
114
114
  const capitalizedWords = words.map((word) => word.charAt(0).toUpperCase() + word.slice(1));
115
115
  return capitalizedWords.join(' ');
116
116
  }
@@ -361,3 +361,18 @@ export const mergeRefs = (...refs) => {
361
361
  }
362
362
  };
363
363
  };
364
+ /**
365
+ * Navigates to the specified client-side hash without ssr.
366
+ * use `scroll-margin-top` with css to add margins
367
+ *
368
+ * @param id - The ID of the element without # to navigate to.
369
+ *
370
+ * @example goToClientSideHash('my-element');
371
+ */
372
+ export function goToClientSideHash(id, opts) {
373
+ const el = document.getElementById(id);
374
+ if (!el)
375
+ return;
376
+ el.scrollIntoView({ behavior: 'smooth', block: 'start', ...opts });
377
+ window.history.pushState(null, '', `#${id}`);
378
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sohanemon/utils",
3
- "version": "4.1.14",
3
+ "version": "4.1.15",
4
4
  "author": "Sohan Emon <sohanemon@outlook.com>",
5
5
  "description": "",
6
6
  "type": "module",
@@ -54,5 +54,6 @@
54
54
  "clsx": "^2.1.1",
55
55
  "react": "^19.1.0",
56
56
  "tailwind-merge": "^1.14.0"
57
- }
57
+ },
58
+ "packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
58
59
  }